/* =========================================================
   OpenCode Pocket — UI
   Design language: neutral slate canvas, blue accent,
   workspace-grouped sessions, big rounded composer.
   ========================================================= */

/* Bundled faces: Android theme fonts can replace the system sans, so the app
   ships its own so typography never turns into a decorative device font. */
@font-face {
  font-family: "Pocket Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Pocket Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-var-latin.woff2") format("woff2");
}

:root {
  --font: "Pocket Sans", "Noto Sans", "Noto Sans Devanagari", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "Pocket Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --accent-line: rgba(37, 99, 235, 0.26);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --ok: #16a34a;
  --warn: #d97706;

  --radius: 8px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --topbar-h: 52px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fafafa;
  --bg-deep: #f4f4f5;
  --elev: #ffffff;
  --elev-2: #f8fafc;
  --soft: #f1f5f9;
  --soft-2: #e9eef4;
  --line: #e4e7ec;
  --line-strong: #cfd6df;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --code-bg: #0f172a;
  --scrim: rgba(15, 23, 42, 0.35);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 -12px 40px rgba(15, 23, 42, 0.14);
}

/* True black: OLED panels switch those pixels off, so the background is #000
   and only raised surfaces carry a hint of grey. */
:root[data-theme="amoled"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-deep: #000000;
  --elev: #0a0a0b;
  --elev-2: #111113;
  --soft: #141416;
  --soft-2: #1c1c1f;
  --line: #1d1d20;
  --line-strong: #2b2b30;
  --text: #ededf0;
  --muted: #8d8d96;
  --muted-2: #62626b;
  --code-bg: #000000;
  --scrim: rgba(0, 0, 0, 0.72);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.9);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
  --shadow-lg: 0 -14px 44px rgba(0, 0, 0, 0.95);
  --accent: #4f8dfd;
  --accent-soft: rgba(79, 141, 253, 0.14);
  --accent-line: rgba(79, 141, 253, 0.34);
  --danger-soft: rgba(220, 38, 38, 0.14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-deep: #080b10;
  --elev: #11161d;
  --elev-2: #161c25;
  --soft: #1a212b;
  --soft-2: #222b37;
  --line: #232c38;
  --line-strong: #334052;
  --text: #e6edf5;
  --muted: #8b98a9;
  --muted-2: #64707f;
  --code-bg: #0a0e13;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 -14px 44px rgba(0, 0, 0, 0.5);
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-line: rgba(59, 130, 246, 0.32);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
svg { display: block; }
:root[data-theme="amoled"] .topbar,
:root[data-theme="amoled"] .composer,
:root[data-theme="amoled"] .sheet { background: var(--bg); }
:root[data-theme="amoled"] .composer-box { background: var(--elev); }
:root[data-theme="amoled"] .session-row:active,
:root[data-theme="amoled"] .sheet-item:active { background: var(--elev-2); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon-btn svg, .tool-btn svg, .chip svg, .fab svg, .send-btn svg,
.brand-mark svg, .connect-foot svg, .chat-title svg {
  width: 21px; height: 21px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.brand-mark svg, .hero-logo svg { fill: currentColor; stroke: none; }

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.screen[hidden] { display: none; }

/* ---------- topbar ---------- */
.topbar {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) 10px 0 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 26px; height: 26px; }
.brand-name { font-weight: 650; font-size: 15.5px; letter-spacing: -0.015em; display: flex; align-items: center; gap: 7px; }
.brand-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); background: var(--soft); border: 1px solid var(--line);
  padding: 2px 5px; border-radius: 5px;
}

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: grid; place-items: center; color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease, transform 0.1s ease;
}
.icon-btn:active { background: var(--soft); color: var(--text); transform: scale(0.94); }

.conn-dot { width: 36px; height: 36px; display: grid; place-items: center; }
.conn-dot span {
  width: 8px; height: 8px; border-radius: 99px; background: var(--muted-2);
  transition: background 0.2s, box-shadow 0.2s;
}
.conn-dot[data-state="online"] span { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14); }
.conn-dot[data-state="offline"] span { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.conn-dot[data-state="busy"] span { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- connect ---------- */
.connect-screen { overflow-y: auto; }
.connect-wrap {
  width: 100%; max-width: 430px; margin: 0 auto;
  padding: calc(44px + var(--sat)) 20px calc(28px + var(--sab));
  display: flex; flex-direction: column; justify-content: center; min-height: 100%;
}
.hero { text-align: center; margin-bottom: 26px; }
.hero-logo { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--accent); }
.hero-logo svg { width: 56px; height: 56px; }
.hero h1 { margin: 0; font-size: 26px; letter-spacing: -0.03em; font-weight: 700; }
.hero h1 span { display: block; color: var(--muted); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; margin-top: 7px; font-weight: 600; }
.hero-sub { margin: 10px 0 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.connect-card { padding: 20px; display: flex; flex-direction: column; gap: 15px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); }
.input {
  height: 44px; width: 100%; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--elev); padding: 0 12px; font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted-2); }

.btn {
  height: 42px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform 0.1s var(--ease), filter 0.15s, background 0.15s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:disabled { opacity: 0.6; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--elev); border-color: var(--line); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 24%, transparent); }

.form-error {
  margin: 0; font-size: 12.5px; color: var(--danger); background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  padding: 9px 11px; border-radius: var(--radius); line-height: 1.45;
}

.help { border-top: 1px solid var(--line); padding-top: 13px; }
.help summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 6px; }
.help summary::-webkit-details-marker { display: none; }
.help summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-left: auto; transition: transform 0.2s; }
.help[open] summary::after { transform: rotate(225deg); }
.help-body { padding-top: 11px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.help-body p { margin: 0 0 9px; }
.help-body pre {
  margin: 0 0 11px; background: var(--code-bg); color: #d7dbe0;
  padding: 10px 11px; border-radius: var(--radius); overflow-x: auto;
}
.help-body code { font-family: var(--mono); font-size: 12px; }
.help-body .hint { font-size: 11.5px; color: var(--muted-2); margin-bottom: 0; }
.demo-link {
  display: flex; align-items: center; gap: 5px; margin: 16px auto 0;
  font-size: 13px; font-weight: 500; color: var(--muted);
}
.demo-link svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.demo-link:active { color: var(--text); }
.connect-foot { display: flex; justify-content: center; align-items: center; gap: 7px; color: var(--muted-2); font-size: 12px; margin: 18px 0 0; }.connect-foot a { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.connect-foot svg { width: 14px; height: 14px; }

/* ---------- sessions ---------- */
.list-head { padding: 10px 14px 6px; }
.archived-toggle {
  margin-top: 8px; height: 30px; padding: 0 12px; border-radius: 99px;
  background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 600;
  border: 1px solid var(--line);
}
.archived-toggle.on { background: var(--accent-soft, var(--soft)); color: var(--accent); border-color: var(--accent); }
.search-box {
  display: flex; align-items: center; gap: 8px; height: 40px;
  background: var(--elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 8px 0 11px;
  box-shadow: var(--shadow-sm);
}
.search-box > svg { width: 17px; height: 17px; fill: none; stroke: var(--muted-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.search-input { flex: 1; height: 100%; border: 0; background: none; outline: none; font-size: 16px; min-width: 0; }
.search-input::placeholder { color: var(--muted-2); }
.search-clear { width: 26px; height: 26px; border-radius: 99px; background: var(--soft); display: grid; place-items: center; color: var(--muted); }
.search-clear svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.session-list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 8px calc(88px + var(--sab));
  overscroll-behavior-y: contain;
}

.ws-group { margin-bottom: 6px; }
.ws-head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 9px 8px 7px; text-align: left; color: var(--muted);
}
.ws-dot { width: 9px; height: 9px; border-radius: 99px; background: var(--c, var(--muted-2)); flex: none; }
.ws-name { font-size: 12.5px; font-weight: 650; color: var(--text); letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-count { font-size: 10.5px; color: var(--muted-2); }
.ws-head .ws-caret { margin-left: auto; width: 14px; height: 14px; fill: none; stroke: var(--muted-2); stroke-width: 2; transition: transform 0.2s; }
.ws-group.closed .ws-caret { transform: rotate(-90deg); }
.ws-group.closed .ws-items { display: none; }

.session-row {
  display: flex; align-items: center; width: 100%; border-radius: var(--radius);
  transition: background 0.12s, transform 0.1s; position: relative;
  margin-bottom: 1px;
}
.session-row:active { background: var(--soft); transform: scale(0.995); }
.session-row.active { background: var(--soft); }
.session-main {
  flex: 1; min-width: 0; text-align: left;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 8px 10px 12px; min-height: 44px;
}
.session-title {
  font-size: 13.5px; font-weight: 500; line-height: 1.35; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.session-time { font-size: 11px; color: var(--muted-2); flex: none; }
.session-archived {
  font-size: 10px; font-weight: 600; letter-spacing: .02em; color: var(--muted-2);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; flex: none;
}
.session-row.archived .session-title { color: var(--muted); }
.session-busy { width: 6px; height: 6px; border-radius: 99px; background: var(--warn); flex: none; animation: pulse 1.2s infinite; }
.session-more {
  width: 30px; height: 34px; flex: none; display: grid; place-items: center; color: var(--muted-2);
  opacity: 0.55; border-radius: 6px;
}
.session-more svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.session-more:active { background: var(--soft-2); opacity: 1; }

.session-skel {
  height: 46px; border-radius: var(--radius); margin: 4px 8px;
  background: linear-gradient(100deg, var(--soft) 30%, var(--elev) 50%, var(--soft) 70%);
  background-size: 220% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { to { background-position: -120% 0; } }

.welcome {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 28px 18px 40px; text-align: center;
}
.welcome-mark {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: var(--soft); color: var(--accent); margin-bottom: 6px;
}
.welcome-mark svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.welcome h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -0.02em; }
.welcome > p { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }
.welcome-sep { padding: 0 4px; opacity: .6; }
.welcome-starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 460px; }
.starter {
  display: flex; align-items: center; gap: 9px; text-align: left; min-height: 48px;
  padding: 8px 11px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--elev); color: var(--text); font-size: 12.5px; line-height: 1.25;
}
.starter:hover { border-color: var(--accent); }
.starter-icon { width: 22px; height: 22px; flex: none; display: grid; place-items: center; color: var(--accent); }
.starter-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* left sidebar */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 70;
  width: min(86vw, 320px); display: flex; flex-direction: column;
  background: var(--bg); border-right: 1px solid var(--line);
  box-shadow: 12px 0 40px rgba(0,0,0,.5);
  transform: translateX(-102%); transition: transform .22s ease;
  padding-top: env(safe-area-inset-top);
}
.sidebar.open { transform: translateX(0); }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 69; background: rgba(0,0,0,.6); }
.side-top { display:flex; align-items:center; justify-content:space-between; padding:14px 14px 8px; }
.side-brand { display:flex; align-items:center; gap:9px; font-size:14px; }
.side-brand svg { width:22px; height:22px; color:var(--accent); }
.side-brand b { color:var(--accent); }
.side-new { margin: 6px 12px 10px; height:40px; border-radius:10px; background:var(--accent); color:#000; font-weight:650; display:flex; align-items:center; justify-content:center; gap:8px; }
.side-new svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2.2; }
.side-search { display:flex; align-items:center; gap:8px; margin:0 12px 10px; height:36px; padding:0 10px; border-radius:9px; background:var(--elev); border:1px solid var(--line); }
.side-search svg { width:15px; height:15px; fill:none; stroke:var(--muted); stroke-width:2; }
.side-search input { flex:1; min-width:0; border:0; background:none; outline:none; color:var(--text); font-size:13px; }
.side-nav { padding: 0 8px 8px; display:flex; flex-direction:column; }
.side-nav button {
  display:flex; align-items:center; gap:10px; height:38px; padding:0 10px; border-radius:9px;
  color:var(--muted); font-size:13px; text-align:left;
}
.side-nav button:hover { background:var(--soft); color:var(--text); }
.side-nav svg, .side-bottom svg { width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; flex:none; }
.side-scroll { flex:1; overflow-y:auto; padding: 4px 8px 12px; }
.side-section { margin-bottom:14px; }
.side-head { display:flex; justify-content:space-between; align-items:center; padding:6px 10px; color:var(--muted-2); font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; }
.side-head button { color:var(--muted); font-size:16px; line-height:1; }
.side-item { display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:9px; font-size:12.5px; color:var(--text); }
.side-item:hover { background:var(--soft); }
.side-item.active { background:var(--accent-soft, var(--soft)); color:var(--accent); }
.side-item .si-label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.side-item .si-dot { width:6px; height:6px; border-radius:99px; background:var(--warn); flex:none; }
.side-bottom { border-top:1px solid var(--line); padding:10px 10px 9px; background: var(--bg); }
.side-profile { display:flex; align-items:center; gap:10px; }
.side-profile-text { flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.side-profile-text b { font-size:13px; font-weight:600; color:var(--text); line-height:1.2; }
.side-conn { display:flex; align-items:center; gap:5px; padding:0; color:var(--muted-2); font-size:10.5px; line-height:1.2; }
.side-conn i { width:5px; height:5px; border-radius:99px; background:var(--ok); }
.side-chat-pill {
  width:34px; height:34px; padding:0; margin:0; flex:none; border-radius:99px;
  display:grid; place-items:center; background:var(--soft); color:var(--text);
}
.side-chat-pill:active { background:var(--line); }
.side-chat-pill svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2.2; }
.side-avatar { width:34px; height:34px; flex:none; border-radius:99px; background:var(--accent); color:var(--accent-ink); font-size:12.5px; font-weight:650; display:grid; place-items:center; }
@media (min-width: 900px) {
  .sidebar { position:relative; transform:none; width:264px; box-shadow:none; flex:none; }
  .sidebar:not(.open) { display:none; }
  .sidebar-backdrop { display:none; }
  .side-toggle { display:none; }
  .app { flex-direction:row; }
}
.sidebar[hidden], .sidebar-backdrop[hidden] { display:none !important; }
.catalog-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.catalog-card {
  display:flex; align-items:center; gap:9px; min-height:56px; padding:8px;
  border:1px solid var(--line); border-radius:11px; background:var(--elev); text-align:left;
}
.catalog-card img { width:26px; height:26px; flex:none; }
.catalog-text { min-width:0; flex:1; }
.catalog-name { display:block; font-size:12.5px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.catalog-sub { display:block; font-size:10.5px; color:var(--muted); }
.catalog-free { font-size:9px; font-weight:700; color:#000; background:var(--accent); padding:1px 5px; border-radius:5px; }
.catalog-models { margin-top:12px; }
.model-logo { width:24px; height:24px; flex:none; display:grid; place-items:center; border-radius:7px; background:var(--soft); }
.model-logo img { width:16px; height:16px; }
.si-check { width:18px; flex:none; color:var(--accent); }
.si-check svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2.4; }
.session-tabs { display:flex; gap:6px; padding:6px 10px 0; overflow-x:auto; border-bottom:1px solid var(--line); }
.session-tab {
  display:flex; align-items:center; gap:6px; flex:none; max-width:170px;
  padding:5px 8px; border-radius:8px 8px 0 0; background:var(--elev);
  border:1px solid var(--line); border-bottom:0; font-size:11.5px; color:var(--muted);
}
.session-tab span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.session-tab.active { background:var(--soft); color:var(--text); border-color:var(--accent); }
.session-tab i { font-style:normal; opacity:.6; padding:0 2px; }
.session-tab i:hover { opacity:1; color:var(--danger, #f87171); }
.updates-card { border:1px solid var(--line); border-radius:12px; padding:12px; margin-bottom:10px; background:var(--elev); }
.updates-head { display:flex; justify-content:space-between; align-items:center; font-size:13.5px; font-weight:600; }
.updates-head b { color:var(--accent); font-weight:600; }
.updates-sub { margin-top:3px; font-size:11.5px; color:var(--muted); }
.updates-notes { margin-top:8px; max-height:120px; overflow:auto; font-size:11.5px; color:var(--muted); white-space:pre-wrap; }
.updates-actions { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }
.updates-progress { height:6px; border-radius:99px; background:var(--soft); margin-top:10px; overflow:hidden; }
.updates-progress i { display:block; height:100%; width:0; background:var(--accent); transition:width .3s; }
.sched-row { display:flex; gap:8px; align-items:center; padding:9px 10px; border-bottom:1px solid var(--line); }
.sched-main { flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.sched-main b { font-size:12.5px; }
.sched-main span { font-size:10.5px; color:var(--muted); }
.sched-main em { font-size:11px; color:var(--muted-2); font-style:normal; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sched-actions { display:flex; flex-direction:column; gap:4px; }
.sched-actions button { font-size:10.5px; padding:3px 7px; border-radius:6px; background:var(--soft); color:var(--muted); }
.sched-new { margin-top:12px; border-top:1px solid var(--line); padding-top:10px; }
.instr-card { border:1px solid var(--line); border-radius:10px; padding:10px; margin-bottom:8px; }
.instr-card b { font-size:12.5px; }
.instr-card span { display:block; font-size:10.5px; color:var(--muted); }
.instr-card pre { white-space:pre-wrap; font-size:11px; max-height:180px; overflow:auto; }
.empty {
  padding: 64px 24px; text-align: center; color: var(--muted-2); font-size: 13.5px; line-height: 1.6;
}
.empty svg { width: 36px; height: 36px; margin: 0 auto 12px; fill: none; stroke: currentColor; stroke-width: 1.5; opacity: 0.55; }
.empty b { color: var(--muted); display: block; margin-bottom: 4px; font-size: 14.5px; font-weight: 600; }

.fab {
  position: absolute; right: 16px; bottom: calc(18px + var(--sab));
  height: 48px; padding: 0 18px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.32), var(--shadow-sm);
  transition: transform 0.14s var(--ease), filter 0.15s;
  z-index: 15;
}
.fab svg { width: 18px; height: 18px; stroke-width: 2.1; }
.fab:active { transform: scale(0.95); }

/* ---------- chat ---------- */
.chat-topbar { padding-left: 2px; }
.chat-title {
  flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 1px;
  padding: 4px; border-radius: var(--radius);
}
.chat-title-text { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.chat-sub { font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--muted); font-weight: 500;
  margin-right: 2px; white-space: nowrap;
}
.chat-status .dot { width: 6px; height: 6px; border-radius: 99px; background: var(--accent); animation: pulse 1.1s infinite; }
/* Thinking = the model is working with no tool running; Working = a tool is
   actually executing. The header must not read the same for both. */
.chat-status.thinking .dot { background: var(--muted-2); animation: pulse 1.6s ease-in-out infinite; }

/* Chrome is not text. A long press on a button, chip or status line used to
   start a selection and bring up Android's floating selection bar in the
   middle of a chat; the transcript itself stays fully selectable. */
button,
.chat-status,
.chat-sub,
.chat-title-text,
.session-tab,
.activity-head,
.inbox-chip,
.net-banner,
.todo-panel,
.branch-chip,
.si-icon,
.caret {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ---- connection banner ---- */
.net-banner {
  display: flex; align-items: center; gap: 8px;
  margin: 0 10px 6px; padding: 8px 10px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px;
  font-size: 12px; color: var(--text);
}
.net-banner[hidden] { display: none; }
.net-banner .net-dot {
  width: 7px; height: 7px; flex: none; border-radius: 99px;
  background: var(--danger); animation: pulse 1.2s infinite;
}
.net-banner .net-text { flex: 1; min-width: 0; }
.net-retry {
  flex: none; height: 28px; padding: 0 12px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11.5px; font-weight: 600;
}
.net-retry[hidden] { display: none; }
.net-retry:active { transform: scale(0.97); }

/* ---- history pagination ---- */
.load-older-row { display: flex; justify-content: center; padding: 2px 0 10px; }
.load-older-row .btn {
  height: 32px; padding: 0 14px; border-radius: 99px;
  font-size: 12px; background: var(--elev); border-color: var(--line); color: var(--muted);
}

/* ---- partial-answer / unconfirmed-message cards ---- */
.limit-card {
  margin: 8px 0 4px; padding: 11px 12px;
  background: var(--elev); border: 1px solid var(--line); border-radius: 12px;
}
.limit-head { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--warn); margin-bottom: 5px; }
.limit-head svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.limit-card p { margin: 0 0 9px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.limit-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-sm { height: 32px; padding: 0 13px; border-radius: 9px; font-size: 12px; }
.limit-note { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ok); }
.limit-note svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.pending-card { border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.pending-card .limit-head { color: var(--warn); }
.sys-limit .sys { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }

.messages {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 4px;
  overscroll-behavior-y: contain;
}

/* The transcript is re-rendered from scratch on every event, so the entry
   animation lives on .enter and is only added to messages that are new to the
   view. Animating every .msg meant the whole screen faded in several times per
   turn, which read as a flash. */
.msg { display: flex; flex-direction: column; }
.msg.enter { animation: rise 0.24s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { .msg.enter { animation: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slide-up { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }

.msg-user { align-items: flex-end; margin: 10px 0 12px; }
.msg-user .bubble {
  max-width: 86%; background: var(--soft);
  border-radius: 16px; padding: 9px 13px;
  font-size: calc(14.6px * var(--font-scale)); line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.msg-user .files { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; justify-content: flex-end; }
.msg-user .files img { width: 68px; height: 68px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.msg-assistant { padding: 3px 0 6px; }
.assistant-body { font-size: 14px; line-height: 1.62; word-break: break-word; color: var(--text); }

.msg-system { align-items: center; margin: 8px 0; }
.msg-system .sys {
  font-size: 11px; color: var(--muted-2); background: var(--soft);
  padding: 4px 10px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 5px;
}
.msg-system .sys svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.failure {
  width: 100%; text-align: left; background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
  border-radius: 12px; padding: 10px 12px;
}
.failure-head {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--danger); margin-bottom: 4px;
}
.failure-head svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.failure-text { font-size: 12.5px; line-height: 1.5; color: var(--text); }
.failure-hint { font-size: 11.5px; line-height: 1.5; color: var(--muted); margin-top: 5px; }

.assistant-note {
  display: inline-flex; align-items: center; gap: 5px; margin: 8px 0 2px;
  font-size: 11px; color: var(--muted-2); background: var(--soft);
  padding: 4px 10px; border-radius: 99px;
}
.assistant-note svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.assistant-body > .msg-system .failure { margin-top: 2px; }

/* markdown */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 9px; }
.md h1, .md h2, .md h3, .md h4 { margin: 16px 0 7px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 650; }
.md h1 { font-size: 19px; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 15.5px; }
.md h4 { font-size: 14.5px; }
.md ul, .md ol { margin: 0 0 9px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md li > p { margin: 0; }
.md blockquote { margin: 0 0 9px; padding: 1px 0 1px 11px; border-left: 2px solid var(--line-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md code {
  font-family: var(--mono); font-size: 0.86em; background: var(--soft);
  border: 1px solid var(--line); padding: 1px 4px; border-radius: 5px; word-break: break-word;
}
.md pre { margin: 0; border-radius: 0; overflow: visible; border: 0; background: none; }
.md .code-block {
  margin: 0 0 11px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--code-bg);
}
.md .code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 9px 6px 11px; border-bottom: 1px solid rgba(255,255,255,0.07);
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: #8b929c;
}
.md .copy { font-family: var(--font); font-size: 10.5px; letter-spacing: 0; text-transform: none; color: #b9c0ca; padding: 3px 7px; border-radius: 5px; background: rgba(255,255,255,0.08); }
.md .code-block code {
  display: block; padding: 11px; overflow-x: auto; background: none; border: 0;
  color: #d6dbe2; font-size: 12.2px; line-height: 1.55; white-space: pre; word-break: normal;
}
.md table { width: 100%; border-collapse: collapse; margin: 0 0 11px; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 7px; text-align: left; word-break: normal; overflow-wrap: break-word; min-width: 3.5em; }
.md th { background: var(--soft); font-weight: 600; }
.md img { max-width: 100%; border-radius: 8px; }
.md .task { display: inline-block; color: var(--accent); font-weight: 700; margin-right: 2px; }
.md .task.done { color: var(--muted-2); }

.stream-caret {
  display: inline-block; width: 2px; height: 15px; margin-left: 2px; vertical-align: -2px;
  background: var(--text); border-radius: 1px; animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* reasoning */
.reasoning { margin: 2px 0 8px; }
.reasoning-toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500;
  color: var(--muted); padding: 4px 8px 4px 2px; border-radius: 6px;
}
.reasoning-toggle svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reasoning-toggle .caret { transform: rotate(90deg); transition: transform 0.2s; opacity: 0.6; }
.reasoning.open .reasoning-toggle .caret { transform: rotate(270deg); }
.reasoning-body {
  display: none; margin-top: 4px; padding: 2px 0 2px 12px; border-left: 2px solid var(--line);
  color: var(--muted); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.reasoning.open .reasoning-body { display: block; }
.reasoning.live .reasoning-toggle { color: var(--text); }

/* tool rows */
.tool-card { margin: 1px 0 5px; }
.tool-head {
  width: 100%; display: flex; align-items: center; gap: 7px; padding: 4px 2px; text-align: left;
  font-size: 12.5px; color: var(--muted); min-height: 30px;
}
.tool-icon { width: 15px; height: 15px; flex: none; color: var(--muted-2); display: grid; place-items: center; }
.tool-icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool-name { font-weight: 500; color: var(--text); flex: none; }
.tool-summary {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.tool-state { flex: none; display: grid; place-items: center; width: 14px; height: 14px; }
.tool-state svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.tool-state[data-status="running"] { color: var(--warn); }
.tool-state[data-status="completed"] { color: var(--ok); }
.tool-state[data-status="error"] { color: var(--danger); }
.spinner { width: 12px; height: 12px; border: 1.5px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; border-radius: 99px; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tool-body { display: none; padding: 6px 0 8px 22px; }
.tool-card.open .tool-body { display: block; }
.tool-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted-2); margin-bottom: 4px; font-weight: 600; }
.tool-pre {
  margin: 0 0 8px; font-family: var(--mono); font-size: 11px; line-height: 1.5;
  background: var(--code-bg); color: #ccd2da; border-radius: 7px; padding: 8px 9px;
  overflow-x: auto; max-height: 220px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.tool-pre:last-child { margin-bottom: 0; }
.tool-pre.err { color: #ffb4b4; }

.typing-row { display: flex; align-items: center; gap: 8px; padding: 8px 0 10px; }
.typing-row span { font-size: 12.5px; color: var(--muted-2); }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 5px; height: 5px; border-radius: 99px; background: var(--muted-2); animation: bounce 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.12s; }
.typing i:nth-child(3) { animation-delay: 0.24s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-3px); opacity: 1; } }

.jump-latest { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(98px + var(--sab)); z-index: 12; }
.jump-latest button {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px;
  border-radius: 99px; background: var(--elev); border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 500; color: var(--muted); box-shadow: var(--shadow-sm);
}
.jump-latest svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.2; transform: rotate(90deg); }

/* composer */
.composer {
  flex: none; padding: 6px 10px calc(10px + var(--sab));
  background: linear-gradient(to top, var(--bg) 55%, transparent); position: relative; z-index: 14;
}
.perm-banner {
  width: 100%; display: flex; align-items: center; gap: 8px;
  margin: 0 0 7px; padding: 9px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 10%, var(--elev));
  border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line));
  font-size: 12.5px; font-weight: 500; color: var(--text); text-align: left;
}
.perm-banner .perm-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--warn); flex: none; }
.perm-banner .perm-review { margin-left: auto; color: var(--accent); font-weight: 600; flex: none; }
.composer-box {
  background: color-mix(in srgb, var(--elev) 82%, transparent);
  backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--line); border-radius: 24px;
  padding: 5px 6px 5px 4px; box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-box:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-input {
  width: 100%; border: 0; background: none; outline: none; resize: none;
  padding: 10px 11px 6px; font-size: 16px; line-height: 1.45; max-height: 34dvh; min-height: 24px;
  display: block;
}
.composer-input::placeholder { color: var(--muted-2); }
.composer-tools { display: flex; align-items: center; gap: 2px; padding: 2px; }
.tool-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted-2); flex: none; }
.tool-btn:active { background: var(--soft); color: var(--text); }
.composer-hint { flex: 1; font-size: 10.5px; color: var(--muted-2); padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 8px;
  border-radius: var(--radius); color: var(--muted);
  font-size: 12px; font-weight: 500; white-space: nowrap; max-width: 52vw;
  flex: none;
}
.chip:active { background: var(--soft); }
.chip svg { width: 14px; height: 14px; stroke-width: 1.8; flex: none; }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip .chip-caret { width: 11px; height: 11px; transform: rotate(90deg); opacity: 0.55; }
@media (max-width: 430px) {
  .composer-hint { display: none; }
  .chip { max-width: 46vw; }
}
.send-btn {
  width: 34px; height: 34px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; flex: none;
  transition: transform 0.12s var(--ease), opacity 0.15s;
}
.send-btn:active { transform: scale(0.9); }
.send-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.send-btn[data-mode="stop"] { background: var(--soft-2); color: var(--text); }
.send-btn[data-mode="stop"] svg { fill: currentColor; stroke: none; }
.send-btn[disabled] { opacity: 0.35; }

.attach-strip { display: flex; gap: 7px; padding: 5px 5px 2px; overflow-x: auto; }
.attach-chip { position: relative; flex: none; width: 52px; height: 52px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: var(--soft); }
.attach-chip img { width: 100%; height: 100%; object-fit: cover; }
.attach-chip button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 99px;
  background: rgba(0,0,0,0.65); color: #fff; display: grid; place-items: center;
}
.attach-chip svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------- scrim + sheet ---------- */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 40;
  opacity: 0; transition: opacity 0.22s ease;
}
.scrim.open { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--elev); border-top-left-radius: 18px; border-top-right-radius: 18px;
  border-top: 1px solid var(--line);
  max-height: 86dvh; display: flex; flex-direction: column;
  transform: translateY(102%); transition: transform 0.3s var(--ease);
  padding-bottom: var(--sab);
  box-shadow: var(--shadow-lg);
}
.sheet.open { transform: translateY(0); }
.sheet-grab { width: 34px; height: 4px; border-radius: 99px; background: var(--line-strong); margin: 8px auto 2px; flex: none; }

/* A destination takes the whole app area: no grab handle, no rounded top, a
   back arrow in the header, and its own scroll. Sheets that interrupt a chat
   keep the sheet form above. */
.sheet.page {
  top: 0; bottom: 0; max-height: none; height: 100%;
  border-radius: 0; border-top: none;
  padding-top: env(safe-area-inset-top, 0px);
}
.sheet.page .sheet-grab { display: none; }
.sheet.page .sheet-head {
  padding: 10px 8px 10px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--elev-2, var(--elev));
}
.sheet.page .sheet-head h2 { font-size: 17px; font-weight: 650; }
.sheet.page .sheet-body { padding: 10px 14px 24px; }
.sheet-back { flex: none; }
.sheet.page #sheet-close { color: var(--muted); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 18px; flex: none; }
.sheet-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.015em; flex: 1; min-width: 0; }
.sheet-body { padding: 2px 14px 18px; overflow-y: auto; overscroll-behavior: contain; }

.sheet-list { display: flex; flex-direction: column; gap: 1px; }
.sheet-list.scroll { max-height: 42dvh; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.sheet-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 9px;
  border-radius: var(--radius); border: 1px solid transparent; text-align: left;
  transition: background 0.1s, border-color 0.1s; min-height: 46px;
}
.sheet-item:active { background: var(--soft); }
.sheet-item.selected { background: var(--accent-soft); border-color: var(--accent-line); }
.sheet-item .si-text { flex: 1; min-width: 0; }
.sheet-item .si-title { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sheet-item .si-sub { font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; display: block; }
.sheet-item .si-check { color: var(--accent); flex: none; }
.sheet-item .si-check svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.sheet-item.danger .si-title { color: var(--danger); }
.si-icon { width: 28px; height: 28px; border-radius: 7px; background: var(--soft); display: grid; place-items: center; color: var(--muted); flex: none; }
.si-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sheet-item.danger .si-icon { color: var(--danger); background: var(--danger-soft); }

.sheet-search { position: sticky; top: 0; background: var(--elev); padding: 2px 0 8px; z-index: 2; }
.sheet-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 2px 2px 10px; }

.permission-card { border: 1px solid var(--line); background: var(--elev-2); border-radius: var(--radius-lg); padding: 12px; margin-bottom: 12px; }
.permission-action { font-size: 13.5px; font-weight: 600; margin: 0 0 6px; }
.permission-res { font-family: var(--mono); font-size: 11px; background: var(--code-bg); color: #ccd2da; border-radius: 7px; padding: 8px 9px; margin: 0 0 6px; max-height: 150px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.permission-actions { display: flex; gap: 7px; margin-top: 12px; }
.permission-actions .btn { height: 40px; flex: 1; font-size: 12.5px; }

.settings-grid { display: flex; flex-direction: column; }
.setting-row { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-text { flex: 1; min-width: 0; }
.setting-title { font-size: 13.5px; font-weight: 500; }
.setting-sub { font-size: 11px; color: var(--muted-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: flex; background: var(--soft); border-radius: var(--radius); padding: 2px; gap: 1px; }
.seg button { padding: 6px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--elev); color: var(--text); box-shadow: var(--shadow-sm); }
.switch { width: 42px; height: 25px; border-radius: 99px; background: var(--line-strong); padding: 3px; transition: background 0.2s; flex: none; }
.switch::after { content: ""; display: block; width: 19px; height: 19px; border-radius: 99px; background: #fff; transition: transform 0.2s var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(17px); }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--sab)); transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--bg); border-radius: var(--radius);
  padding: 9px 14px; font-size: 12.5px; z-index: 80;
  box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s, transform 0.2s; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 900px) {
  body { background: var(--bg-deep); }
  .app { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet { max-width: 520px; margin: 0 auto; border-radius: 18px 18px 0 0; }
}
@media (min-width: 1200px) {
  .app { max-width: 640px; }
  .sheet { max-width: 640px; }
}

/* A phone turned sideways is still a phone: the desktop phone-frame above left
   it as a narrow column with dead black margins. Use the whole screen and keep
   only the transcript at a readable measure. */
@media (min-width: 900px) and (pointer: coarse) {
  .app { max-width: none; border-left: 0; border-right: 0; }
  .sheet { max-width: none; }
  .messages { padding-left: max(16px, calc((100% - 760px) / 2)); padding-right: max(16px, calc((100% - 760px) / 2)); }
  .composer { padding-left: max(10px, calc((100% - 780px) / 2)); padding-right: max(10px, calc((100% - 780px) / 2)); }
  .welcome { padding-left: max(18px, calc((100% - 760px) / 2)); padding-right: max(18px, calc((100% - 760px) / 2)); }
}

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

[hidden] { display: none !important; }

/* ---- opencode feature surface ------------------------------------------- */

/* changed-file chip in the chat header */
.diff-chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  height: 28px; padding: 0 9px; border-radius: 99px;
  background: var(--soft); border: 1px solid var(--line);
  color: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.diff-chip:active { background: var(--soft-2); color: var(--text); }
.diff-chip svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* staged-undo banner above the composer */
.revert-banner {
  width: 100%; display: flex; align-items: center; gap: 8px;
  margin: 0 0 7px; padding: 9px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 9%, var(--elev));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  font-size: 12.5px; font-weight: 500; color: var(--text); text-align: left;
}
.revert-banner .rev-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revert-banner .rev-actions { display: flex; gap: 6px; flex: none; }
.revert-banner .rev-btn {
  padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--elev); border: 1px solid var(--line); color: var(--text);
}
.revert-banner .rev-btn[data-revert="keep"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.revert-banner .rev-btn:active { background: var(--soft); }

/* diff list */
.adds { color: var(--ok, #16a34a); }
.dels { color: var(--danger); }
.diff-list { display: flex; flex-direction: column; gap: 8px; }
.diff-file { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--elev); }
.diff-head {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px 11px; text-align: left;
}
.diff-head:active { background: var(--soft); }
.df-status {
  width: 20px; height: 20px; border-radius: 6px; flex: none; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--soft-2);
}
.df-status[data-s="added"] { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.df-status[data-s="deleted"] { color: var(--danger); background: var(--danger-soft); }
.df-status[data-s="modified"] { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.df-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.df-name { font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.df-dir { font-size: 10.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.df-counts { display: flex; gap: 6px; flex: none; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.diff-head .caret { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--muted-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); transition: transform 0.18s; }
.diff-file.open .diff-head .caret { transform: rotate(-90deg); }
.diff-body { display: none; border-top: 1px solid var(--line); }
.diff-file.open .diff-body { display: block; }
.patch {
  margin: 0; padding: 9px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  font-family: var(--mono); font-size: 11px; line-height: 1.5; background: var(--soft);
}
.patch .dl { display: block; white-space: pre; font-style: normal; }
.patch .dl.add { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.patch .dl.del { color: var(--danger); background: var(--danger-soft); }
.patch .dl.hunk { color: var(--accent); }
.patch .dl.meta { color: var(--muted-2); }

/* per-message usage footer */
.usage-line {
  margin-top: 5px; font-size: 10.5px; color: var(--muted-2);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}

/* status dots in list rows */
.dot-status { width: 8px; height: 8px; border-radius: 99px; flex: none; background: var(--muted-2); margin: 0 11px; }
.dot-status[data-s="connected"] { background: var(--ok); }
.dot-status[data-s="pending"] { background: var(--warn); }
.dot-status[data-s="failed"] { background: var(--danger); }
.dot-status[data-s="needs_auth"] { background: var(--warn); }
.dot-status[data-s="disabled"] { background: var(--line-strong); }

/* destructive affordance inside a list row */
.rule-remove {
  width: 30px; height: 30px; border-radius: 99px; flex: none; display: grid; place-items: center;
  color: var(--muted-2); background: var(--soft);
}
.rule-remove:active { background: var(--danger-soft); color: var(--danger); }
.rule-remove svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.setting-value { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
button.setting-row { width: 100%; text-align: left; background: none; border: 0; }


/* ---- forms, inbox, delivery, artifact shell ------------------------------
   Forms block a turn, so they read as a piece of the conversation with their
   own weight: a raised panel, the question as a heading, the choices as chips
   that stay thumb-sized on a 390px screen. */

.form-card {
  margin: 14px 0 6px;
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  background: var(--elev);
  padding: 13px 13px 11px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  animation: rise 0.22s var(--ease) both;
}
.form-card.answered,
.form-card.cancelled {
  border-color: var(--line);
  background: transparent;
  padding: 9px 12px;
  gap: 3px;
}
.form-head { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.form-answer { font-size: 12.5px; color: var(--muted); }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field[hidden] { display: none; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.form-label .req { color: var(--danger, #f87171); margin-left: 3px; }
.form-sub { font-size: 11.5px; color: var(--muted-2); margin-top: -2px; }
.form-options { display: flex; flex-wrap: wrap; gap: 6px; }
.form-options[data-multi="0"] { flex-direction: column; align-items: stretch; }
.opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 1px solid var(--line-strong);
  background: var(--soft);
  color: var(--text);
  border-radius: 11px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease);
}
.opt[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.opt-label { font-weight: 550; }
.opt-sub { font-size: 11.5px; color: var(--muted); }
.form-custom { margin-top: 2px; }
.form-input { font-size: 14px; }
.form-actions { display: flex; gap: 8px; align-items: center; }
.form-actions .btn { height: 38px; padding: 0 14px; font-size: 13px; }
.form-external { display: inline-flex; gap: 8px; align-items: center; font-size: 12.5px; }
.form-external .muted { color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; }

/* the queue sits directly above the composer, like the attachment strip */
.inbox-bar {
  display: flex;
  gap: 6px;
  padding: 0 2px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.inbox-bar::-webkit-scrollbar { display: none; }
.inbox-chip {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--soft);
  overflow: hidden;
  flex: 0 0 auto;
  max-width: 280px;
}
.ib-main {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 7px 9px;
  cursor: pointer;
  min-width: 0;
}
.ib-mode {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 700;
}
.ib-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ib-x {
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted-2);
  padding: 0 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.ib-x svg { width: 13px; height: 13px; stroke-width: 2; }

.chip.delivery { border-color: var(--accent-line); color: var(--accent); }
.chip.delivery span { font-weight: 600; }
.chip.delivery.queue { color: #f5b544; border-color: rgba(245, 181, 68, 0.45); }

/* ---- artifact workspace shell (filled in by the artifact module) */
.artifact-screen {
  position: fixed;
  inset: 0;
  /* Above the chat, below the scrim (40) and the sheet (50): the artifact's
     own action menu is a sheet, so it must be able to cover the workspace. */
  z-index: 30;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  animation: slide-up 0.22s var(--ease) both;
}
.artifact-screen[hidden] { display: none; }
.artifact-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 4px;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}
.artifact-head .icon-btn svg { transform: rotate(180deg); }
.artifact-heading { flex: 1; min-width: 0; }
.artifact-title { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-sub { font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
}
.artifact-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px 8px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.artifact-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.artifact-body { flex: 1; overflow: auto; padding: 12px; }
.artifact-body pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}
.artifact-body.wrap pre { white-space: pre-wrap; word-break: break-word; }
.artifact-frame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 12px;
  background: #fff;
}
.artifact-doc { font-size: 14.5px; line-height: 1.62; }


/* ---- chat experience: activity, actions, artifacts, reading modes --------
   The answer stays the spine. Tool work folds into one row, actions stay quiet
   until wanted, and anything substantial gets a card that opens full screen. */

:root { --font-scale: 1; --code-scale: 1; }

.md { font-size: calc(14.6px * var(--font-scale)); line-height: 1.62; }
.md .code-block code,
.md pre code { font-size: calc(12.2px * var(--code-scale)); }
.md p + p { margin-top: 0; }
.md strong { font-weight: 650; }
.md h1, .md h2, .md h3 { letter-spacing: -0.018em; }
.md ul ul, .md ol ol, .md ul ol, .md ol ul { margin: 3px 0 3px; }
.md li.has-sub { margin-bottom: 3px; }
.md .task {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-right: 6px; border-radius: 4px;
  border: 1px solid var(--line-strong); font-size: 10px; vertical-align: -2px;
}
.md .task.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.md .task.done::after {
  content: ""; width: 7px; height: 4px; margin-top: -2px;
  border-left: 1.6px solid var(--accent); border-bottom: 1.6px solid var(--accent);
  transform: rotate(-45deg);
}
.md .table-wrap { overflow-x: auto; margin: 0 0 11px; border-radius: 9px; border: 1px solid var(--line); }
.md .table-wrap table { margin: 0; font-size: calc(13px * var(--font-scale)); min-width: max-content; }
.md .md-img { display: block; margin: 4px 0 10px; }
.md .image { max-width: 100%; border-radius: 9px; }
.math-inline, .math-block {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--soft); border-radius: 5px; padding: 1px 4px;
}
.math-block { display: block; padding: 9px 11px; margin: 0 0 10px; white-space: pre-wrap; overflow-x: auto; }

/* code block controls */
.md .code-tools { display: inline-flex; align-items: center; gap: 5px; }
.code-btn {
  font-family: var(--font); font-size: 10.5px; line-height: 1;
  color: #b9c0ca; background: rgba(255, 255, 255, 0.08);
  border: 0; border-radius: 5px; padding: 4px 7px; cursor: pointer;
}
.code-btn:active { background: rgba(255, 255, 255, 0.16); }
.md .code-block.wrap pre { white-space: pre-wrap; word-break: break-word; }
.md .code-block.wrap code { white-space: pre-wrap; }
.md pre.numbered code,
.artifact-body pre.numbered code { display: block; counter-reset: line; }
.md pre.numbered .cl,
.artifact-body pre.numbered .cl { display: block; counter-increment: line; padding-left: 2.9em; position: relative; }
.md pre.numbered .cl::before,
.artifact-body pre.numbered .cl::before {
  content: counter(line);
  position: absolute; left: 0; width: 2.2em; text-align: right;
  color: #4b5563; font-size: 0.92em; user-select: none;
}

/* ---- activity rows */
.activity { margin: 6px 0 10px; width: 100%; align-self: stretch; position: static; }
.activity-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: 0; padding: 5px 2px; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 12.5px; text-align: left;
}
.act-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted-2); flex: 0 0 auto;
}
.act-dot.live { background: var(--accent); animation: pulse 1.4s infinite; }
.act-title { font-weight: 600; color: var(--text); }
.act-sub { color: var(--muted-2); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-head .caret {
  margin-left: auto; width: 13px; height: 13px; transform: rotate(90deg);
  transition: transform 0.18s var(--ease); opacity: 0.6; flex: 0 0 auto;
}
.activity.open .activity-head .caret { transform: rotate(270deg); }
.activity-body { display: none; padding-left: 2px; width: 100%; }
.activity.open .activity-body { display: block; width: 100%; }
.activity-body .tool-card { margin: 4px 0; }

/* ---- message actions and timestamps */
.msg-actions {
  display: flex; gap: 2px; margin: 2px 0 0 -6px;
  opacity: 0.5; transition: opacity 0.15s var(--ease);
}
.msg-actions:hover, .msg-actions:focus-within { opacity: 1; }
.msg-actions button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 0; background: transparent;
  border-radius: 8px; color: var(--muted); cursor: pointer;
}
.msg-actions button:active { background: var(--soft); color: var(--text); }
.msg-actions svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.msg-user .msg-actions { justify-content: flex-end; margin: 2px -4px 0 0; }
.msg-time { display: none; font-size: 10.5px; color: var(--muted-2); margin-top: 4px; }
:root[data-timestamps="on"] .msg-time { display: block; }
.msg-user .msg-time { text-align: right; }

/* ---- follow-up chips */
.follow-ups { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 2px; }
.follow-chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; padding: 6px 11px; border-radius: 99px; cursor: pointer;
}
.follow-chip:active { background: var(--soft); color: var(--text); }

/* ---- artifact cards */
.artifact-cards { display: flex; flex-direction: column; gap: 7px; margin: 4px 0 8px; }
.artifact-card {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1px solid var(--line-strong); background: var(--elev);
  border-radius: 13px; padding: 10px 12px; cursor: pointer; text-align: left;
  font: inherit; color: var(--text);
}
.artifact-card:active { background: var(--elev-2); }
.ac-icon {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.ac-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ac-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ac-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-sub { font-size: 11.5px; color: var(--muted-2); }
.ac-open { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ---- artifact workspace body */
.artifact-note {
  font-size: 12.5px; color: var(--muted); background: var(--soft);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-bottom: 10px;
}
.artifact-code { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.artifact-code-head {
  display: flex; justify-content: space-between; padding: 7px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-family: var(--mono); font-size: 10.5px; color: #8b929c;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.artifact-code pre, .artifact-diff { margin: 0; padding: 11px; overflow: auto; }
.artifact-code code, .artifact-diff code {
  font-family: var(--mono); font-size: calc(12.2px * var(--code-scale));
  line-height: 1.6; color: #d6dbe2; white-space: pre;
}
.artifact-code.wrap code { white-space: pre-wrap; word-break: break-word; }
.artifact-diff .cl.add { color: #6ee7a8; background: rgba(52, 211, 153, 0.1); }
.artifact-diff .cl.del { color: #fca5a5; background: rgba(248, 113, 113, 0.1); }
.artifact-diff .cl.hunk { color: var(--accent); }
.artifact-diff .cl { display: block; }
.artifact-img { max-width: 100%; border-radius: 12px; display: block; margin: 0 auto; }
.artifact-body .md { padding-bottom: 24px; }

/* ---- reading modes */
:root[data-density="compact"] .msg { margin-bottom: 8px; }
:root[data-density="compact"] .md { line-height: 1.5; }
:root[data-density="compact"] .md p { margin-bottom: 6px; }
:root[data-density="compact"] .msg-user { margin: 6px 0 8px; }
:root[data-density="compact"] .messages { padding-top: 6px; }
:root[data-density="focus"] .activity,
:root[data-density="focus"] .reasoning,
:root[data-density="focus"] .msg-actions,
:root[data-density="focus"] .follow-ups { display: none; }
:root[data-density="focus"] .messages { padding-left: 18px; padding-right: 18px; }
:root[data-density="focus"] .md { font-size: calc(15.4px * var(--font-scale)); line-height: 1.7; }

/* reduced motion is a real switch, not a hint */
:root[data-motion="off"] *,
:root[data-motion="off"] *::before,
:root[data-motion="off"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- preferences studio --------------------------------------------------
   Sections rather than one long list: appearance, chat, code, composer. */

.prefs-section { margin: 0 0 6px; }
.prefs-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted-2); font-weight: 700;
  padding: 14px 2px 6px;
}
.prefs-section:first-child .prefs-head { padding-top: 2px; }
.accent-row { display: flex; gap: 9px; align-items: center; }
.accent-dot {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent;
  background: var(--dot); cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.accent-dot.on { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--bg); }
.stepper { display: inline-flex; gap: 6px; }
.stepper button {
  height: 34px; min-width: 42px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--soft); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
}
.stepper button:active { background: var(--elev-2); }
.prefs-foot { padding: 16px 0 8px; }
.prefs-foot .btn { width: 100%; }
.seg { flex: 0 0 auto; }

/* ---- unread, failed runs, find, branch chip ----------------------------- */
.session-unread {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex: 0 0 auto;
}
.session-failed {
  width: 7px; height: 7px; border-radius: 50%;
  background: #f87171; flex: 0 0 auto;
}
.session-row.unread .session-title { font-weight: 700; }

.branch-chip {
  max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10.5px; font-family: var(--mono); color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px; padding: 3px 6px;
}

.msg.flash { animation: flash-msg 1.1s var(--ease); }
@keyframes flash-msg {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

.find-hit { align-items: flex-start; }
.find-hit .si-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.find-time { font-size: 10.5px; color: var(--muted-2); flex: 0 0 auto; margin-left: 8px; }


/* Long conversations are handled in JS: the transcript signature skips
   identical rebuilds and only new messages animate. `content-visibility: auto`
   was tried here for off-screen layout skipping, but its placeholder sizing
   makes scrollHeight unstable right after a rebuild, which sent "scroll to
   bottom" to the top of the transcript. Correct scrolling wins over that
   optimisation. */


/* ---- connections, MCP actions, todos ------------------------------------- */

.todo-panel {
  margin: 0;
  padding: 9px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--elev);
  flex: 0 0 auto;
}
.todo-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted-2); margin-bottom: 6px;
}
.todo-head span { color: var(--accent); }
.todo-list { display: flex; flex-direction: column; gap: 4px; }
.todo-row { display: flex; gap: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.todo-mark {
  width: 15px; height: 15px; flex: 0 0 auto; border-radius: 4px;
  border: 1px solid var(--line-strong); text-align: center;
  line-height: 13px; font-size: 10px;
}
.todo-row.done { color: var(--muted-2); text-decoration: line-through; }
.todo-row.done .todo-mark { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.todo-row.active { color: var(--text); }
.todo-row.active .todo-mark { color: var(--accent); }

.auth-provider {
  border: 1px solid var(--line); border-radius: 12px;
  margin: 0 0 10px; overflow: hidden;
}

/* ---- account sheet ---- */
.account-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--soft); margin: 0 0 12px;
}
.account-avatar {
  width: 40px; height: 40px; flex: none; border-radius: 99px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.account-avatar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.account-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.account-text b { font-size: 14px; font-weight: 600; color: var(--text); }
.account-text span { font-size: 11.5px; color: var(--muted); }
.device-code {
  margin: 6px 0 14px; padding: 16px 10px; text-align: center;
  font-family: var(--mono); font-size: 27px; font-weight: 650; letter-spacing: 0.16em;
  color: var(--text); background: var(--soft); border: 1px solid var(--line); border-radius: 14px;
  user-select: all; -webkit-user-select: all;
}
.auth-provider-head { padding: 11px 12px 4px; }
.auth-provider-head .si-title,
.auth-provider-head .si-sub,
.auth-cred .si-title,
.auth-cred .si-sub { display: block; }
.auth-provider-head .si-title,
.auth-cred .si-title { font-size: 13.5px; font-weight: 600; }
.auth-provider-head .si-sub,
.auth-cred .si-sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.auth-provider .sheet-item { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.auth-method { width: 100%; text-align: left; cursor: pointer; }
.auth-go { font-size: 11.5px; color: var(--accent); font-weight: 600; flex: 0 0 auto; }
.auth-active {
  font-size: 9.5px; color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.06em; margin-left: 4px;
}
.auth-cred {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-top: 1px solid var(--line);
}
.auth-cred .si-text { flex: 1; min-width: 0; }
.auth-cred-actions { display: inline-flex; gap: 4px; }
.auth-cred-actions button {
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: var(--soft); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.auth-cred-actions svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; }

.mcp-row { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; margin-bottom: 8px; }
.mcp-row .sheet-item { border: 0; border-radius: 0; }
.mcp-actions { display: flex; gap: 0; border-top: 1px solid var(--line); }
.mcp-actions button {
  flex: 1; border: 0; background: var(--soft); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600; padding: 9px;
  cursor: pointer; border-right: 1px solid var(--line);
}
.mcp-actions button:last-child { border-right: 0; }
.mcp-actions button:active { background: var(--elev-2); color: var(--text); }

/* ---- rich markdown in the transcript ---------------------------------------
   Libraries ported from Aurora Preview (MIT, see docs/THIRD-PARTY.md): GitHub
   callouts, KaTeX math, highlight.js tokens, footnotes, a frontmatter card, and
   the image/diagram lightbox. Colours come from the app's own palette, so the
   AMOLED theme and the accent stay in charge. */

/* GitHub-style callouts: > [!NOTE] and friends */
.md .markdown-alert {
  margin: 0 0 10px; padding: 9px 11px 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--muted-2);
  background: var(--soft);
}
.md .markdown-alert-title {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 4px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.md .markdown-alert .octicon { width: 14px; height: 14px; fill: currentColor; flex: none; }
.md .markdown-alert > p:last-child { margin-bottom: 0; }
.md .markdown-alert-note { border-left-color: var(--accent); background: var(--accent-soft); }
.md .markdown-alert-note .markdown-alert-title { color: var(--accent); }
.md .markdown-alert-tip { border-left-color: var(--ok); }
.md .markdown-alert-tip .markdown-alert-title { color: var(--ok); }
.md .markdown-alert-important { border-left-color: var(--accent); }
.md .markdown-alert-important .markdown-alert-title { color: var(--accent); }
.md .markdown-alert-warning { border-left-color: var(--warn); }
.md .markdown-alert-warning .markdown-alert-title { color: var(--warn); }
.md .markdown-alert-caution { border-left-color: var(--danger); }
.md .markdown-alert-caution .markdown-alert-title { color: var(--danger); }

/* math: KaTeX renders into <eq>/<eqn> wrappers from markdown-it-texmath */
.md eq, .md eqn { display: inline; }
.md eqn { display: block; margin: 0 0 11px; }
.md .katex { font-size: 1.03em; }
.md .katex-display { margin: 0; padding: 8px 2px; overflow-x: auto; overflow-y: hidden; }
.md eqn > .katex-display { padding: 8px 10px; background: var(--soft); border-radius: 9px; }
/* the plain-notation fallback still exists for documents rendered earlier */
.math-inline, .math-block {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--soft); border-radius: 5px; padding: 1px 4px;
}
.math-block { display: block; padding: 9px 11px; margin: 0 0 10px; white-space: pre-wrap; overflow-x: auto; }

/* syntax highlighting tokens, tuned for a black OLED screen */
.hljs { color: #e6e8ec; background: transparent; }
.hljs-comment, .hljs-quote { color: #7a8394; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: #c792ea; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #9ece6a; }
.hljs-number, .hljs-symbol, .hljs-bullet { color: #ffb86c; }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: #82aaff; }
.hljs-title.class_, .hljs-type, .hljs-class .hljs-title { color: #ffcb6b; }
.hljs-variable, .hljs-template-variable, .hljs-params { color: #e6e8ec; }
.hljs-built_in, .hljs-builtin-name { color: #f78c6c; }
.hljs-attr, .hljs-attribute, .hljs-property { color: #ffcb6b; }
.hljs-tag, .hljs-name, .hljs-selector-id, .hljs-selector-class { color: #f07178; }
.hljs-meta, .hljs-meta .hljs-keyword { color: #82aaff; }
.hljs-deletion { color: #f07178; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 650; }
/* The code surface stays dark in every theme (`--code-bg`), so the token
   palette above is the only one: a light-page token set here would put dark
   text on a dark block. */

/* Mermaid: the source shows while the turn is still running, the drawing
   replaces it once it settles. Tap either to open it full screen. */
.md pre.mermaid {
  margin: 0 0 11px; padding: 10px 12px; border-radius: 10px;
  border: 1px dashed var(--line-strong); background: var(--soft);
  font-family: var(--mono); font-size: calc(11.6px * var(--code-scale));
  line-height: 1.5; color: var(--muted); overflow-x: auto; white-space: pre;
}
.md pre.mermaid::before {
  content: "diagram"; display: block; margin-bottom: 6px;
  font-family: var(--font); font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2);
}
.md pre.mermaid.drawn {
  border: 1px solid var(--line); background: var(--elev); padding: 12px;
  cursor: zoom-in; text-align: center;
}
.md pre.mermaid.drawn::before { content: none; }
.md pre.mermaid.drawn svg { max-width: 100%; height: auto; }
.md pre.mermaid.failed { border-style: solid; border-color: var(--danger); }
.md .mermaid-error {
  display: block; margin: -4px 0 11px; font-size: 11.5px; color: var(--danger);
}

/* footnotes */
.md .footnote-ref a { text-decoration: none; }
.md .footnotes-sep { margin: 14px 0 8px; border: 0; border-top: 1px solid var(--line); }
.md .footnotes { font-size: calc(12.8px * var(--font-scale)); color: var(--muted); }
.md .footnotes-list { padding-left: 18px; }
.md .footnote-backref { text-decoration: none; margin-left: 4px; }

/* task lists (the engine swaps the checkbox for this mark) */
.md .contains-task-list { padding-left: 4px; }
.md .task-list-item { list-style: none; }
.md .task-list-item > label { display: inline; }

/* frontmatter card */
.md .frontmatter {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--soft);
}
.md .fm-title { font-size: 14px; font-weight: 650; }
.md .fm-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 5px; }
.md .fm-field { font-size: 11.5px; color: var(--muted); }
.md .fm-key { color: var(--muted-2); margin-right: 4px; }
.md .fm-key::after { content: ":"; }

/* ---- image and diagram lightbox ------------------------------------------- */
.md img, .md pre.mermaid.drawn { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 80; display: none;
  background: rgba(0, 0, 0, 0.92); padding: calc(18px + var(--sat)) 14px calc(18px + var(--sab));
}
.lightbox.open { display: flex; align-items: center; justify-content: center; }
.lightbox-content { max-width: 100%; max-height: 100%; overflow: auto; text-align: center; padding-top: 34px; }
.lightbox-content img { max-width: 100%; max-height: 82dvh; border-radius: 10px; }
.lightbox-content.diagram svg { max-width: 100%; height: auto; background: var(--elev); border-radius: 10px; }
.lightbox-code {
  margin: 0 auto; text-align: left; max-width: min(92vw, 760px); max-height: 78dvh;
  overflow: auto; padding: 14px 16px; border-radius: 10px;
  background: #0d0d11; color: #e8e8ee; border: 1px solid rgba(255, 255, 255, 0.12);
  font: calc(12.4px * var(--code-scale)) / 1.6 var(--mono);
  white-space: pre-wrap; word-break: break-word;
}
.lightbox-bar {
  position: absolute; top: calc(12px + var(--sat)); right: 12px; z-index: 2;
  display: flex; align-items: center; gap: 8px;
}
.lightbox-tool {
  height: 34px; padding: 0 13px; border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.12);
  color: #fff; font: 600 12px/1 var(--font); cursor: pointer;
}
.lightbox-close {
  position: static;
  width: 34px; height: 34px; border-radius: 99px; border: 0;
  background: rgba(255, 255, 255, 0.12); color: #fff; display: grid; place-items: center;
}
.lightbox-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

/* a diagram opened from the artifact card */
.artifact-body pre.mermaid {
  margin: 0; padding: 12px; border-radius: 10px; border: 1px dashed var(--line-strong);
  background: var(--soft); color: var(--muted);
  font: calc(11.6px * var(--code-scale)) / 1.55 var(--mono);
  overflow-x: auto; white-space: pre;
}
.artifact-diagram.drawn { border: 0; background: none; padding: 0; text-align: center; cursor: zoom-in; }
.artifact-diagram.drawn svg { max-width: 100%; height: auto; }

/* ---- icon system ----------------------------------------------------------
   All non-brand glyphs come from the committed Lucide sprite in index.html.
   One stroke language, one default optical size, one minimum touch target for
   icon-only controls. Per-context sizes above still win where they are
   deliberate (empty states, hero logo, diff headers). Colours and the AMOLED
   palette are untouched: every glyph inherits currentColor. */
:root {
  --icon-size: 18px;
  --icon-stroke: 1.8;
  --icon-touch: 40px;
}
svg[aria-hidden="true"] {
  flex: none;
  vertical-align: middle;
  width: var(--icon-size);
  height: var(--icon-size);
  stroke-width: var(--icon-stroke) !important;
}
svg.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon-btn, .tool-btn, .send-btn, .search-clear, .msg-actions button,
.side-chat-pill, .side-head button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--icon-touch);
  min-height: var(--icon-touch);
}
.side-head button, .side-chat-pill { min-width: 34px; min-height: 34px; }
.activity-head .caret { transform: none; opacity: 0.7; }
.activity.open .activity-head .caret { transform: none; opacity: 1; }

/* ---- prompt mentions, library attach, instructions ---------------------- */
.mention-tabs { display: flex; gap: 6px; margin: 2px 0 10px; }
.mention-tabs button {
  flex: 1; height: 32px; border-radius: 9px; background: var(--soft);
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.mention-tabs button.on { background: var(--accent-soft, var(--soft)); color: var(--accent); }

/* Long model/agent names must ellipsize, not push Send off the screen. */
.composer-tools { min-width: 0; }
.composer-tools .chip { min-width: 0; flex: 0 1 auto; overflow: hidden; }
.composer-tools .chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lib-row { display: flex; gap: 6px; align-items: stretch; }
.lib-row .sheet-item { flex: 1; min-width: 0; }
.lib-attach {
  width: 44px; flex: none; border-radius: 10px; background: var(--soft);
  color: var(--muted); display: grid; place-items: center;
}
.lib-attach:active { background: var(--line); color: var(--text); }
.lib-attach svg { width: 17px; height: 17px; }

.instructions-input { width: 100%; min-height: 150px; resize: vertical; font-size: 13px; line-height: 1.5; }
.instructions-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---- export ---------------------------------------------------------------
   HTML export and printing build their own documents (assets/export.js); the
   chat stylesheet deliberately has no print rules, so nothing here can leak
   into a printed page. */
