:root {
  color-scheme: light dark;
  --bg: #f2f5f8;
  --bg-elevated: #ffffff;
  --bg-soft: #e9eef3;
  --bg-message: #ffffff;
  --text: #101a26;
  --text-soft: #536274;
  --text-faint: #7d8a99;
  --line: rgba(16, 26, 38, 0.1);
  --line-strong: rgba(16, 26, 38, 0.16);
  --accent: #087f6d;
  --accent-strong: #046b5b;
  --accent-soft: rgba(8, 127, 109, 0.1);
  --user-bubble: #0c6f60;
  --user-text: #f4fffc;
  --danger: #c53b34;
  --danger-soft: rgba(197, 59, 52, 0.1);
  --warning: #a96b12;
  --warning-soft: rgba(169, 107, 18, 0.12);
  --shadow: 0 8px 30px rgba(24, 40, 58, 0.08);
  --shadow-strong: 0 18px 50px rgba(15, 28, 43, 0.18);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "HarmonyOS Sans SC", "HarmonyOS Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080e16;
    --bg-elevated: #111a25;
    --bg-soft: #16222f;
    --bg-message: #121c27;
    --text: #eef5fa;
    --text-soft: #a7b5c4;
    --text-faint: #778696;
    --line: rgba(226, 240, 248, 0.1);
    --line-strong: rgba(226, 240, 248, 0.18);
    --accent: #59d6bd;
    --accent-strong: #7ee7d2;
    --accent-soft: rgba(89, 214, 189, 0.12);
    --user-bubble: #126f61;
    --user-text: #f4fffc;
    --danger: #ff8379;
    --danger-soft: rgba(255, 131, 121, 0.12);
    --warning: #f0b45f;
    --warning-soft: rgba(240, 180, 95, 0.12);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
    --shadow-strong: 0 18px 50px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.5;
}

button svg,
.security-note svg,
.search-box svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button svg {
  pointer-events: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  max-width: 100%;
  overflow: hidden;
}

.boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
}

.boot-text {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.brand-mark {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: var(--accent);
  background: var(--accent-soft);
}

.brand-mark svg {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark-large {
  width: 86px;
  height: 86px;
  border-radius: 28px;
  margin-bottom: 20px;
}

.brand-mark-large svg {
  width: 64px;
  height: 64px;
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.primary-button,
.secondary-button,
.small-button,
.stop-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  min-height: 42px;
  padding: 0 16px;
  transition: transform 120ms ease, background 160ms ease;
}

.primary-button {
  color: #ffffff;
  background: var(--accent-strong);
}

.primary-button:active {
  transform: scale(0.98);
}

.secondary-button {
  background: var(--bg-soft);
  border-color: var(--line);
  color: var(--text);
}

.small-button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  font-size: 13px;
}

.small-button svg {
  width: 17px;
  height: 17px;
}

.stop-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
  font-size: 12px;
}

.stop-button svg {
  width: 16px;
  height: 16px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  transition: background 160ms ease;
}

.icon-button:active {
  background: var(--bg-soft);
}

/* Login */
.login-view {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: max(32px, var(--safe-top)) 22px max(32px, var(--safe-bottom));
  background:
    radial-gradient(circle at 12% 8%, var(--accent-soft), transparent 42%),
    radial-gradient(circle at 92% 88%, rgba(69, 118, 188, 0.1), transparent 46%);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 32px 26px 26px;
  box-shadow: var(--shadow-strong);
}

.login-card h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin: 10px 0 26px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.login-form {
  display: flex;
  flex-direction: column;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
}

.token-field {
  position: relative;
}

.token-field input,
.select-input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--bg);
  padding: 0 48px 0 15px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.07em;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.token-field input:focus,
.select-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.token-field .icon-button {
  position: absolute;
  right: 5px;
  top: 5px;
}

.field-hint {
  margin: 9px 2px 0;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.55;
}

.form-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.login-submit {
  margin-top: 18px;
  min-height: 50px;
  font-size: 16px;
  border-radius: 14px;
}

.security-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.55;
}

.security-note svg {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 1px;
}

/* Top bar */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-caption {
  margin: 2px 0 0;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.brand-dot {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sessions-main {
  padding: 22px 18px calc(110px + var(--safe-bottom));
}

.sessions-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sessions-heading h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.03em;
}

.muted {
  margin: 4px 0 0;
  color: var(--text-faint);
  font-size: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 14px;
  margin-bottom: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text-faint);
}

.search-box svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--text-faint);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-card {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 15px 15px 15px 14px;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, border-color 160ms ease;
}

.session-card:active {
  transform: scale(0.988);
  border-color: var(--line-strong);
}

.session-card-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}

.session-card-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.session-card-body {
  flex: 1;
  min-width: 0;
}

.session-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-card-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.session-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  min-width: 0;
  color: var(--text-faint);
  font-size: 11.5px;
}

.session-cwd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-separator::before {
  content: "·";
}

.session-card-chevron {
  flex: none;
  color: var(--text-faint);
}

.session-card-chevron svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.running-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

.running-pill .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.72); }
}

.fab {
  position: fixed;
  right: max(20px, calc(50vw - 430px));
  bottom: calc(24px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 19px;
  background: var(--accent-strong);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(4, 107, 91, 0.32);
  transition: transform 120ms ease;
  z-index: 4;
}

.fab:active {
  transform: scale(0.94);
}

.fab svg {
  width: 25px;
  height: 25px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 28px;
}

.empty-icon {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: var(--bg-soft);
  color: var(--text-faint);
  margin-bottom: 18px;
}

.empty-icon svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state h3 {
  margin: 0;
  font-size: 18px;
}

.empty-state p {
  margin: 8px 0 20px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.connection-banner {
  margin: 10px 16px 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
  line-height: 1.5;
}

/* Session */
.session-topbar {
  min-height: 62px;
}

.session-heading {
  flex: 1;
  min-width: 0;
}

.session-heading h1 {
  font-size: 16px;
}

.running-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  margin-right: 2px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.running-badge .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.messages-loading,
.messages-empty {
  margin: auto;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
  padding: 40px 20px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: message-in 180ms ease-out;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.message.user {
  align-items: flex-end;
}

.message-bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 17px 17px 5px 17px;
  background: var(--user-bubble);
  color: var(--user-text);
  font-size: 14.5px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 2px 10px rgba(4, 70, 60, 0.12);
}

.message.assistant {
  align-items: stretch;
}

.assistant-card {
  width: 100%;
  background: var(--bg-message);
  border: 1px solid var(--line);
  border-radius: 5px 18px 18px 18px;
  padding: 13px 15px 14px;
  box-shadow: var(--shadow);
}

.assistant-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.assistant-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.assistant-content {
  font-size: 14.5px;
  line-height: 1.72;
  word-break: break-word;
}

.assistant-content p {
  margin: 0 0 0.72em;
}

.assistant-content p:last-child {
  margin-bottom: 0;
}

.assistant-content h1,
.assistant-content h2,
.assistant-content h3,
.assistant-content h4 {
  margin: 1em 0 0.45em;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.assistant-content h1 { font-size: 19px; }
.assistant-content h2 { font-size: 17px; }
.assistant-content h3 { font-size: 15.5px; }
.assistant-content h4 { font-size: 14.5px; }

.assistant-content h1:first-child,
.assistant-content h2:first-child,
.assistant-content h3:first-child {
  margin-top: 0;
}

.assistant-content ul,
.assistant-content ol {
  margin: 0 0 0.75em;
  padding-left: 1.45em;
}

.assistant-content li {
  margin: 0.2em 0;
}

.assistant-content blockquote {
  margin: 0.6em 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--text-soft);
}

.assistant-content code {
  font-family: "JetBrains Mono", "Cascadia Mono", "HarmonyOS Sans SC", ui-monospace, monospace;
  font-size: 0.88em;
  padding: 0.14em 0.36em;
  border-radius: 5px;
  background: var(--bg-soft);
}

.assistant-content pre {
  margin: 0.7em 0;
  padding: 12px 13px;
  border-radius: 11px;
  background: #0c141d;
  color: #dce8f2;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 12.5px;
  line-height: 1.55;
}

.assistant-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 12.5px;
  white-space: pre;
}

.assistant-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-all;
}

.interrupted-label {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 10.5px;
}

.tool-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elevated);
  font-size: 12px;
  color: var(--text-soft);
  overflow: hidden;
}

/* A running tool is a single quiet line, not a boxed card: the phone does not
   need a frame around every intermediate step. */
.tool-running {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 2px;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
}

.tool-running .tool-spinner {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

.tool-card summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  list-style: none;
  cursor: pointer;
}

.tool-card summary::-webkit-details-marker {
  display: none;
}

.tool-card .tool-name {
  font-family: "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;
  font-weight: 600;
  color: var(--text);
}

.tool-card .tool-state {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 10.5px;
  white-space: nowrap;
}

.tool-card .tool-spinner {
  width: 11px;
  height: 11px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.tool-card pre {
  margin: 0;
  padding: 0 12px 11px;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-soft);
}

.tool-card.is-failed .tool-state {
  color: var(--danger);
}

.notice {
  align-self: center;
  max-width: 92%;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.45;
  text-align: center;
}

.notice.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.scroll-bottom {
  position: absolute;
  right: 18px;
  bottom: calc(118px + var(--safe-bottom));
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-soft);
  box-shadow: var(--shadow);
  z-index: 5;
}

.scroll-bottom svg {
  width: 20px;
  height: 20px;
}

/* Composer */
.composer {
  flex: none;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.composer-box {
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  padding: 9px 9px 7px 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

.composer textarea {
  width: 100%;
  min-height: 28px;
  max-height: 132px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 3px 2px 5px;
  font-size: 15px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: var(--text-faint);
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--bg-soft);
  flex: none;
}

.mode-button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 4px 8px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.mode-button.is-active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.composer-hint {
  flex: 1;
  min-width: 0;
  color: var(--text-faint);
  font-size: 10.5px;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.send-button {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--accent-strong);
  color: #ffffff;
  transition: transform 120ms ease;
}

.send-button:active {
  transform: scale(0.94);
}

.send-button svg {
  width: 19px;
  height: 19px;
}

/* Dialog */
.dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: min(420px, calc(100vw - 32px));
  width: 100%;
}

.dialog::backdrop {
  background: rgba(5, 12, 20, 0.5);
  backdrop-filter: blur(4px);
}

.dialog-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow-strong);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.dialog-description {
  margin: 9px 0 20px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.select-input {
  padding: 0 14px;
  font-size: 14px;
  letter-spacing: 0;
  font-weight: 500;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

/* Remote approval */
.approval-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: max(18px, var(--safe-top)) 14px calc(18px + var(--safe-bottom));
  background: rgba(4, 10, 17, 0.64);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.approval-panel {
  width: 100%;
  max-width: 560px;
  max-height: min(82dvh, 720px);
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-strong);
  animation: approval-in 180ms ease-out;
}

@keyframes approval-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.approval-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.approval-eyebrow {
  margin: 0 0 4px;
  color: var(--warning);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.approval-heading h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.025em;
}

.approval-count {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 11px;
  font-weight: 700;
}

.approval-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.approval-item {
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 14px;
  background: var(--bg-message);
}

.approval-item-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.approval-tool {
  font-family: "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}

.approval-session {
  color: var(--text-faint);
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.approval-reason {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.approval-state {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 11.5px;
  line-height: 1.5;
}

.approval-actions {
  display: flex;
  gap: 8px;
  margin-top: 13px;
}

.approval-actions .secondary-button,
.approval-actions .primary-button {
  flex: 1;
}

.approval-deny {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

.approval-foot {
  margin: 14px 2px 0;
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.5;
  text-align: center;
}

/* Toast */
.toast {  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: min(88vw, 420px);
  padding: 10px 15px;
  border-radius: 12px;
  background: rgba(12, 22, 33, 0.92);
  color: #f5fbff;
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  box-shadow: var(--shadow-strong);
  z-index: 20;
  animation: toast-in 160ms ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Wider screens */
@media (min-width: 760px) {
  .topbar {
    padding-left: max(24px, calc(50vw - 430px));
    padding-right: max(24px, calc(50vw - 430px));
  }

  .sessions-main,
  .messages {
    padding-left: max(24px, calc(50vw - 430px));
    padding-right: max(24px, calc(50vw - 430px));
  }

  .composer {
    padding-left: max(20px, calc(50vw - 450px));
    padding-right: max(20px, calc(50vw - 450px));
  }

  .fab {
    right: max(24px, calc(50vw - 430px));
  }

  .login-card {
    padding: 38px 34px 30px;
  }
}

@media (max-width: 360px) {
  .login-card {
    padding: 26px 20px 22px;
  }

  .login-card h1 {
    font-size: 24px;
  }

  .session-card {
    padding: 13px 12px;
  }

  .messages {
    padding-left: 12px;
    padding-right: 12px;
  }

  .composer {
    padding-left: 8px;
    padding-right: 8px;
  }

  .running-badge {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Model chip + sheets */
.model-chip {
  max-width: 132px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sessions-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.small-button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-soft);
}

.dialog.sheet {
  max-width: min(560px, calc(100vw - 24px));
  margin: auto auto 0;
  vertical-align: bottom;
}

.sheet-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(16px + var(--safe-bottom));
  box-shadow: var(--shadow-strong);
  max-height: min(86dvh, 760px);
  display: flex;
  flex-direction: column;
}

.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  margin: 2px auto 10px;
  flex: none;
}

.sheet-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 60px;
  margin: 4px 0;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0 12px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 48px;
  padding: 0 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: left;
}

.menu-row:active {
  background: var(--bg-soft);
}

.menu-row svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: var(--text-soft);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-hint {
  margin-bottom: 0;
}

.model-group {
  margin: 4px 0 12px;
}

.model-group-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.model-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-message);
  text-align: left;
}

.model-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.model-option-main {
  flex: 1;
  min-width: 0;
}

.model-option-name {
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.model-option-desc {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}

.effort-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 2px 0 14px;
}

.effort-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

.effort-chip.is-selected {
  border-color: transparent;
  background: var(--accent-strong);
  color: #ffffff;
}

.archive-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
}

.archive-row:last-child {
  border-bottom: 0;
}

.archive-row-main {
  flex: 1;
  min-width: 0;
}

.archive-row-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-row-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* File browser + plugins */
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: var(--text);
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row-icon {
  width: 20px;
  flex: none;
  font-size: 15px;
  line-height: 1;
}

.file-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-row-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row-meta {
  font-size: 11px;
  color: var(--text-faint);
}

.files-path {
  padding: 6px 2px;
  font-family: "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}

.file-editor {
  width: 100%;
  min-height: 46dvh;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
  white-space: pre;
}
