/* Agent Hub — app styles. Dark-first, light theme via [data-theme=light]. */

.voice-launch { margin: 0 16px 16px; padding: 13px 16px; border: 1px solid var(--border-2); border-radius: 15px; background: var(--accent-soft); color: var(--text); display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer; font: 600 15px var(--font); }
.voice-launch > span:first-child { font-size: 30px; color: var(--accent-2); }
.voice-launch small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 3px; }
.library-launch { display: block; margin: 0 16px 16px; padding: 12px 15px; border: 1px solid var(--border-2); border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600; }
.library-launch:hover { background: var(--card-2); }
.library-launch > span { float: right; color: var(--accent-2); }
.library-launch small { display: block; margin-top: 5px; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; line-height: 1.5; }
.voice-dialog { box-sizing: border-box; width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 24px; border: 1px solid var(--border-2); border-radius: 24px; background: var(--panel); color: var(--text); overflow-y: auto; box-shadow: var(--shadow); }
.voice-dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(7px); }
.voice-header { display: flex; align-items: center; justify-content: space-between; }
.voice-header h2 { margin: 4px 0; font-size: 26px; }
.voice-eyebrow { color: var(--muted); letter-spacing: .15em; font-size: 10px; }
.voice-orb { --voice-level: 0; display: grid; place-items: center; width: 86px; height: 86px; margin: 22px auto 16px; border-radius: 50%; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); font-size: 46px; transition: box-shadow .12s; }
.voice-orb[data-state="listening"] { color: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 0 0 calc(6px + var(--voice-level) * 18px) var(--accent-soft); }
.voice-orb[data-state="speaking"] { color: var(--ok); border-color: var(--ok); }
.voice-status { text-align: center; font-size: 19px; font-weight: 650; }
.voice-target { text-align: center; font-size: 14px; color: var(--accent-2); overflow-wrap: anywhere; }
.voice-hint { text-align: center; font-size: 13px; line-height: 1.6; color: var(--muted); }
.voice-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.voice-controls .btn { min-height: 44px; }
.voice-log { max-height: 220px; overflow-y: auto; padding: 0 4px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.voice-log p { padding: 10px 12px; background: var(--card); border-radius: 12px; }
.voice-log strong { color: var(--accent-2); }
.voice-draft { margin: 16px 0; font-size: 13px; }
.voice-draft textarea { display: block; box-sizing: border-box; resize: vertical; width: 100%; min-height: 110px; margin: 8px 0; padding: 12px; color: var(--text); background: var(--bg); border: 1px solid var(--border-2); border-radius: 12px; font: 15px var(--font); }
.voice-command { margin-top: 18px; }
.voice-command label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.voice-command > div { display: flex; gap: 8px; }
.voice-command input { min-width: 0; flex: 1; padding: 12px; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px; }
.voice-details { margin-top: 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.voice-details summary { cursor: pointer; padding: 6px 0; }
.voice-details select { display: block; width: 100%; margin: 6px 0; padding: 9px; color: var(--text); background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px; }
@media (max-width: 600px) { .voice-dialog { padding: 20px 16px; } .voice-orb { margin-top: 16px; } .voice-controls .btn { font-size: 13px; } }

:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-2: #0f1218;
  --panel: #12151d;
  --card: #181c26;
  --card-2: #1f2431;
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.13);
  --text: #e7e9ef;
  --muted: #8e97ab;
  --faint: #5b647a;
  --accent: #6d7cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(109, 124, 255, 0.16);
  --ok: #22c55e;
  --busy: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Type scale. Every font size is one of these tokens times two factors:
     --t-scale (bigger on phones, see the mobile media query) and --t-user
     (Settings → Text size, or the "text size" link in the nav footer). */
  --t-scale: 1;
  --t-user: 1;
  --t: calc(var(--t-scale) * var(--t-user));
  --fs-xs: calc(11px * var(--t));     /* chips, section labels, message roles */
  --fs-sm: calc(12px * var(--t));     /* meta lines, hints, footers */
  --fs-sm2: calc(12.5px * var(--t));  /* tool/system lines, code blocks */
  --fs-md: calc(13.5px * var(--t));   /* toasts, small buttons, errors */
  --fs-base: calc(14px * var(--t));   /* row titles, buttons */
  --fs-body: calc(15px * var(--t));   /* body copy, messages */
  --fs-lg: calc(15.5px * var(--t));   /* pane titles */
  --fs-xl: calc(17px * var(--t));     /* modal / empty-state titles */
  --fs-2xl: calc(22px * var(--t));    /* lock screen title */

  /* Touch targets (raised on phones). */
  --tap: 38px;
  --tap-sm: 30px;
}
html[data-text="small"] { --t-user: 0.9; }
html[data-text="large"] { --t-user: 1.15; }
html[data-text="xlarge"] { --t-user: 1.3; }

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-2: #eaedf4;
  --panel: #ffffff;
  --card: #ffffff;
  --card-2: #f1f3f9;
  --border: rgba(16, 24, 40, 0.08);
  --border-2: rgba(16, 24, 40, 0.16);
  --text: #131a2a;
  --muted: #5b6478;
  --faint: #98a1b3;
  --accent-soft: rgba(109, 124, 255, 0.12);
  --shadow: 0 12px 34px rgba(16, 24, 40, 0.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.45;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(109, 124, 255, 0.10), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(34, 211, 238, 0.08), transparent 60%),
              var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent-2); }
.hidden { display: none !important; }

/* ───────── Layout ───────── */
.app {
  display: grid;
  grid-template-columns: 300px 360px minmax(0, 1fr);
  height: 100dvh;
  padding-top: var(--safe-top);
}
.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;   /* never let a long no-wrap line widen the pane past its track */
  border-right: 1px solid var(--border);
  background: var(--panel);
}
.pane-chat { border-right: 0; background: transparent; }
.only-mobile { display: none; }

@media (max-width: 960px) {
  :root { --t-scale: 1.15; --tap: 44px; --tap-sm: 40px; }
  html, body { overflow-x: hidden; }
  body { line-height: 1.5; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .pane { display: none; border-right: 0; }
  body[data-view="nav"] .pane-nav,
  body[data-view="list"] .pane-list,
  body[data-view="chat"] .pane-chat { display: flex; }
  .only-mobile { display: inline-flex; }
  .only-desktop { display: none !important; }
  .pane-chat { background: var(--panel); }
}

/* ───────── Brand / nav ───────── */
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: white; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(109, 124, 255, 0.35);
}
.brand-text { flex: 1; min-width: 0; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: var(--fs-lg); }
.brand-sub { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-scroll { flex: 1; overflow-y: auto; padding: 0 12px 12px; }
.nav-footer {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--faint);
}
.sep { color: var(--faint); }
.section { margin-top: 10px; }
.section-title {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
  padding: 8px 6px 6px;
}
.link-btn { font-size: var(--fs-sm); color: var(--muted); }
.link-btn:hover { color: var(--text); }
.nav-footer .link-btn { min-height: 28px; }

.host-list, .agent-list { display: flex; flex-direction: column; gap: 6px; }
.host-row, .agent-row {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}
.host-row:hover, .agent-row:hover { background: var(--card); }
.host-row.active, .agent-row.active { background: var(--card-2); border-color: var(--border-2); }
.host-row:active, .agent-row:active { transform: scale(0.99); }
.agent-row.unavailable { opacity: 0.55; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title, .row-meta { display: block; }
.row-title { font-weight: 600; font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host-row .row-meta { font-family: var(--mono); font-size: calc(11.5px * var(--t)); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.dot.online, .dot.ready { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.dot.offline { background: var(--bad); }
.dot.unauthorized { background: var(--busy); }
.dot.probing { background: var(--busy); animation: pulse 1.1s ease-in-out infinite; }
.dot.busy { background: var(--busy); }
@keyframes pulse { 50% { opacity: 0.35; } }

.agent-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; font-size: var(--fs-sm); color: white; flex-shrink: 0;
  background: var(--pc, var(--accent));
}
.chip {
  font-size: calc(10.5px * var(--t)); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px; background: var(--card-2); color: var(--muted); flex-shrink: 0;
}
.chip.ok { color: var(--ok); background: rgba(34, 197, 94, 0.12); }
.chip.bad { color: var(--bad); background: rgba(239, 68, 68, 0.12); }
.chip.warn { color: var(--busy); background: rgba(245, 158, 11, 0.14); }
.chip.accent { color: var(--accent-2); background: rgba(34, 211, 238, 0.12); }

.auto-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  background: linear-gradient(180deg, var(--card), var(--panel));
}
.auto-card.on { border-color: rgba(34, 197, 94, 0.5); }
.auto-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auto-title { font-weight: 700; font-size: var(--fs-md); }
.auto-desc { font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; }
.switch {
  width: 44px; height: 26px; border-radius: 999px; background: var(--card-2); position: relative;
  border: 1px solid var(--border-2); transition: background 0.2s ease; flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform 0.2s ease, background 0.2s ease;
}
.switch.on { background: rgba(34, 197, 94, 0.25); border-color: var(--ok); }
.switch.on::after { transform: translateX(18px); background: var(--ok); }
.switch:disabled { opacity: 0.5; cursor: default; }

/* ───────── Pane chrome ───────── */
.pane-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  min-height: 62px;
}
.pane-header-text { flex: 1; min-width: 0; }
.pane-title { font-weight: 700; font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-sub { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-body { flex: 1; overflow-y: auto; padding: 12px; }
.pane-footer { padding: 12px; border-top: 1px solid var(--border); padding-bottom: calc(12px + var(--safe-bottom)); }

.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 10px; display: inline-grid; place-items: center;
  color: var(--muted); transition: background 0.15s ease, color 0.15s ease; flex-shrink: 0;
}
.icon-btn:hover { background: var(--card); color: var(--text); }
.icon-btn.recording { color: var(--bad); background: rgba(239, 68, 68, 0.12); animation: pulse 1s infinite; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: var(--fs-base);
  border: 1px solid var(--border-2); background: var(--card); color: var(--text);
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--card-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5b6cff); border-color: transparent; color: white; }
.btn-primary:hover { background: linear-gradient(135deg, #7c89ff, #6a79ff); }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.4); color: #ff8a8a; }
.btn-ok { background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.4); color: #7ee2a0; }
.btn-sm { padding: 7px 12px; font-size: var(--fs-md); border-radius: 10px; }
.btn-block { width: 100%; }

/* ───────── Lists (projects / sessions) ───────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--border); transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.row:hover { border-color: var(--border-2); background: var(--card-2); }
.row:active { transform: scale(0.995); }
.row.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.row.action { border-style: dashed; background: transparent; }
.row.action:hover { background: var(--accent-soft); border-color: var(--accent); }
.row-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--card-2); color: var(--muted); font-size: calc(16px * var(--t));
}
.row.action .row-icon { background: var(--accent-soft); color: var(--accent); }
.row .row-title { font-size: calc(14.5px * var(--t)); }
.row .row-meta { margin-top: 2px; }
.row-trail { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.list-empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: var(--fs-base); }
.list-error { color: #ff9c9c; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); padding: 12px 14px; border-radius: var(--radius-sm); font-size: var(--fs-md); word-break: break-word; }
.skeleton { height: 58px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ───────── Chat ───────── */
.chat-header { background: var(--panel); }
.chat-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.status-pill {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; background: var(--card-2); color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-pill[data-state="busy"] { color: var(--busy); }
.status-pill[data-state="busy"]::before { background: var(--busy); animation: pulse 1s infinite; }
.status-pill[data-state="awaiting"] { color: var(--accent-2); }
.status-pill[data-state="awaiting"]::before { background: var(--accent-2); animation: pulse 1s infinite; }
.status-pill[data-state="error"], .status-pill[data-state="offline"] { color: var(--bad); }
.status-pill[data-state="error"]::before, .status-pill[data-state="offline"]::before { background: var(--bad); }
.status-pill[data-state="new"] { color: var(--ok); }
.status-pill[data-state="new"]::before { background: var(--ok); }

.messages { flex: 1; overflow-y: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.empty-state { margin: auto; text-align: center; max-width: 380px; color: var(--muted); padding: 24px; }
.empty-art { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 28px; background: linear-gradient(135deg, var(--accent-soft), rgba(34, 211, 238, 0.15)); border: 1px solid var(--border-2); }
.empty-title { font-weight: 700; font-size: var(--fs-xl); color: var(--text); }
.empty-text { font-size: var(--fs-base); margin-top: 6px; }

.msg { max-width: min(760px, 92%); border-radius: 16px; padding: 12px 14px; position: relative; animation: rise 0.18s ease; min-width: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg-role { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(109, 124, 255, 0.28), rgba(34, 211, 238, 0.18)); border: 1px solid rgba(109, 124, 255, 0.35); white-space: pre-wrap; word-break: break-word; }
.msg.user .msg-role { color: var(--accent-2); }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--border); box-shadow: inset 3px 0 0 var(--pc, var(--accent)); }
.msg.assistant .msg-role { color: var(--pc, var(--accent)); }
.msg.tool { align-self: flex-start; background: transparent; border-left: 2px solid var(--busy); border-radius: 0; padding: 4px 12px; font-family: var(--mono); font-size: var(--fs-sm2); color: var(--muted); word-break: break-word; }
.msg.tool.done { border-left-color: var(--faint); }
.msg.system { align-self: center; background: transparent; color: var(--faint); font-size: var(--fs-sm2); padding: 2px 8px; text-align: center; }
.msg.error { align-self: flex-start; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.35); color: #ff9c9c; }
.msg.streaming .md::after { content: "▍"; color: var(--pc, var(--accent)); animation: pulse 0.9s infinite; margin-left: 2px; }

/* markdown */
.md { word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0.5em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 0.8em 0 0.4em; line-height: 1.25; }
.md h1 { font-size: 1.25em; } .md h2 { font-size: 1.15em; } .md h3 { font-size: 1.05em; } .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0.4em 0; padding-left: 1.4em; }
.md li { margin: 0.2em 0; }
.md code { font-family: var(--mono); font-size: 0.88em; background: rgba(127, 140, 170, 0.16); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; overflow-x: auto; margin: 0.6em 0; max-width: 100%; }
.md pre code { background: transparent; padding: 0; font-size: var(--fs-sm2); line-height: 1.5; }
.md blockquote { margin: 0.5em 0; padding: 4px 12px; border-left: 3px solid var(--border-2); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border-2); margin: 0.8em 0; }
.md table { border-collapse: collapse; margin: 0.6em 0; font-size: 0.92em; display: block; max-width: 100%; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-2); padding: 4px 8px; }
.md img.screenshot { max-width: 100%; border-radius: 10px; border: 1px solid var(--border-2); display: block; margin: 6px 0; }

/* composer */
.composer { padding: 10px 14px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--border); background: var(--panel); }
.composer-box {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--card); border: 1px solid var(--border-2); border-radius: 18px; padding: 6px 6px 6px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-box textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent; padding: 8px 0;
  max-height: 180px; min-height: 24px; line-height: 1.4;
}
.composer-box textarea::placeholder { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.send-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; border-radius: 12px; }
.send-btn:hover { color: white; filter: brightness(1.1); }
.send-btn:disabled { opacity: 0.45; cursor: default; }
.composer-hint { font-size: calc(11.5px * var(--t)); color: var(--faint); margin-top: 6px; padding-left: 6px; }
.composer.disabled .composer-box { opacity: 0.55; }

/* ───────── Modals / toasts ───────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 12, 0.62); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: min(85dvh, 760px); overflow: auto;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; box-shadow: var(--shadow);
  animation: rise 0.18s ease;
}
.modal-head { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; }
.modal-title { font-weight: 800; font-size: var(--fs-xl); flex: 1; }
.modal-body { padding: 8px 20px 12px; color: var(--text); }
.modal-body p { margin: 0.4em 0; }
.modal-body .detail { font-family: var(--mono); font-size: var(--fs-sm); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding: 8px 20px 18px; }
.modal-actions .btn { flex: 1 1 auto; }
.option-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.option { text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--card); }
.option:hover { background: var(--card-2); border-color: var(--accent); }
.option-label { font-weight: 600; }
.option-desc { font-size: var(--fs-sm2); color: var(--muted); margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.field input, .field select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--card); outline: 0;
  min-width: 0; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.host-editor { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: var(--card); }
.host-editor-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.host-editor .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.host-editor .grid .field.wide { grid-column: 1 / -1; }
@media (max-width: 520px) { .host-editor .grid { grid-template-columns: 1fr; } }

#toast-root { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; width: min(92vw, 460px); }
.toast {
  pointer-events: auto; padding: 11px 14px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border-2);
  box-shadow: var(--shadow); font-size: var(--fs-md); animation: rise 0.18s ease; display: flex; gap: 10px; align-items: center;
}
.toast.ok { border-color: rgba(34, 197, 94, 0.5); }
.toast.bad { border-color: rgba(239, 68, 68, 0.55); }
.toast.warn { border-color: rgba(245, 158, 11, 0.55); }

/* ───────── Lock screen ───────── */
.lock-screen {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 20% 0%, rgba(109, 124, 255, 0.16), transparent 60%),
              radial-gradient(700px 500px at 100% 100%, rgba(34, 211, 238, 0.12), transparent 60%),
              var(--bg);
}
.lock-card {
  width: min(400px, 100%); text-align: center;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 22px; box-shadow: var(--shadow);
  padding: 30px 26px 22px; display: flex; flex-direction: column; gap: 12px; animation: rise 0.25s ease;
}
.lock-mark { width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 4px; }
.lock-title { margin: 0; font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.01em; }
.lock-text { margin: 0; color: var(--muted); font-size: var(--fs-base); }
.lock-input {
  padding: 13px 14px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--card); outline: 0;
  font-size: max(16px, var(--fs-body)); text-align: center; letter-spacing: 0.08em; min-width: 0;
}
.lock-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lock-error { min-height: 18px; color: #ff8a8a; font-size: var(--fs-md); }
.lock-foot { color: var(--faint); font-size: var(--fs-sm); }
.lock-library { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; }

/* ───────── Misc ───────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--card-2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { font-family: var(--mono); font-size: var(--fs-xs); background: var(--card-2); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 5px; }

/* ───────── Row actions (computer tools, one-tap new session) ───────── */
.host-line, .agent-line { display: flex; align-items: center; gap: 4px; }
.host-line .host-row, .agent-line .agent-row { flex: 1; min-width: 0; }
.mini-btn {
  flex-shrink: 0; width: var(--tap-sm); height: var(--tap-sm); border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: calc(17px * var(--t)); line-height: 1; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.mini-btn:hover { background: var(--card); color: var(--text); border-color: var(--border); }
.mini-btn:active { transform: scale(0.94); }

/* Model chip in the conversation header */
.chip-btn {
  cursor: pointer; border: 1px solid var(--border); background: var(--card); color: var(--text); font-family: inherit;
  font-size: var(--fs-sm); font-weight: 600; padding: 6px 10px; border-radius: 999px; max-width: 180px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-btn:hover { border-color: var(--accent); background: var(--card-2); }
a.chip-btn { text-decoration: none; display: inline-block; line-height: 1.2; }

/* Pick lists (models, folders) and computer tools */
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow: auto; margin-top: 8px; }
.pick {
  text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); cursor: pointer; font-family: inherit;
}
.pick:hover { border-color: var(--accent); background: var(--card-2); }
.pick.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.pick-title { font-weight: 600; font-size: var(--fs-base); word-break: break-word; }
.pick-meta { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; word-break: break-word; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: var(--fs-md); margin: 6px 0 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.tools-grid .btn { width: 100%; }
@media (max-width: 520px) { .tools-grid { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; gap: 0 } .kv dd { margin-bottom: 6px; } }
.hint { font-size: var(--fs-sm); color: var(--muted); margin-top: 10px; }
.modal-body .detail.hidden { display: none; }

/* ───────── Phone layout ───────── */
@media (max-width: 960px) {
  /* Roomier rows and full-width messages; descriptions may wrap to a second
     line instead of being cut off mid-sentence. */
  .brand { padding: 18px 16px 12px; }
  .nav-scroll { padding: 0 10px 14px; }
  .host-row, .agent-row { padding: 12px 12px; gap: 12px; }
  .host-list, .agent-list { gap: 4px; }
  .agent-mark { width: 36px; height: 36px; border-radius: 10px; }
  .host-row .row-meta, .agent-row .row-meta, .row .row-meta {
    white-space: normal; overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2;
  }
  .row { padding: 14px 14px; }
  .row-icon { width: 40px; height: 40px; }
  .pane-header { padding: 12px 12px; min-height: 64px; gap: 8px; }
  .pane-body { padding: 12px 12px 16px; }
  .messages { padding: 14px 12px 8px; gap: 12px; }
  .msg { max-width: 100%; padding: 12px 14px; }
  .msg.assistant, .msg.error { max-width: 100%; }
  .msg.user { max-width: 94%; }
  .md pre { padding: 10px; }
  .composer { padding: 10px 10px calc(10px + var(--safe-bottom)); }
  .composer-box { padding: 4px 4px 4px 14px; border-radius: 22px; }
  /* 16px+ in inputs keeps mobile browsers from zooming into the field. */
  .composer-box textarea, .field input, .field select { font-size: max(16px, var(--fs-body)); }
  .composer-box textarea { padding: 10px 0; }
  .chip-btn { max-width: 112px; padding: 7px 9px; }
  .status-pill { padding: 4px 8px; letter-spacing: 0.04em; }
  .btn { padding: 12px 16px; min-height: 44px; }
  .btn-sm { padding: 9px 12px; min-height: 40px; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { width: 100%; max-height: min(92dvh, 900px); border-radius: 18px 18px 14px 14px; }
  .modal-actions .btn { flex: 1 1 calc(50% - 8px); }
  .option { padding: 14px 14px; }
  .pick { padding: 12px 12px; }
  .pick-list { max-height: 48vh; }
  .auto-card { padding: 14px 14px; }
  .switch { width: 50px; height: 30px; }
  .switch::after { width: 22px; height: 22px; }
  .switch.on::after { transform: translateX(20px); }
  .nav-footer { padding: 12px 16px calc(12px + var(--safe-bottom)); }
  #toast-root { width: min(94vw, 520px); }
}
