/* 青鸟 Qingniao — design system
   Surface: Operate (a working console you give tasks to). Density and calm over decoration.
   Palette: ink neutrals + one accent, 青 (a cool celadon-teal). Brand mark: a square seal stamp. */

@font-face { font-family: "Geist"; src: url("/static/vendor/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/static/vendor/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --font: "Geist", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --rail-w: 268px;
  --col: 760px;
}

[data-theme="dark"] {
  --bg: oklch(0.165 0.006 240);
  --bg-2: oklch(0.19 0.007 240);
  --surface: oklch(0.215 0.008 240);
  --surface-2: oklch(0.25 0.009 240);
  --line: oklch(0.29 0.009 240);
  --line-2: oklch(0.35 0.01 240);
  --ink: oklch(0.95 0.004 240);
  --ink-2: oklch(0.78 0.008 240);
  --muted: oklch(0.69 0.01 240);
  --faint: oklch(0.57 0.01 240);
  --accent: oklch(0.78 0.11 185);
  --accent-ink: oklch(0.2 0.04 185);
  --accent-soft: oklch(0.78 0.11 185 / 0.14);
  --accent-line: oklch(0.78 0.11 185 / 0.38);
  --danger: oklch(0.7 0.16 25);
  --warn: oklch(0.8 0.13 80);
  --ok: oklch(0.78 0.13 150);
  --user-bg: oklch(0.255 0.012 220);
  --code-bg: oklch(0.14 0.006 240);
  --shadow: 0 1px 0 oklch(1 0 0 / 0.04) inset, 0 12px 40px -12px oklch(0 0 0 / 0.6);
  --shadow-pop: 0 0 0 1px var(--line), 0 24px 60px -16px oklch(0 0 0 / 0.7);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: oklch(0.985 0.003 90);
  --bg-2: oklch(0.97 0.004 90);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.955 0.005 90);
  --line: oklch(0.91 0.005 90);
  --line-2: oklch(0.85 0.006 90);
  --ink: oklch(0.22 0.01 240);
  --ink-2: oklch(0.38 0.01 240);
  --muted: oklch(0.47 0.01 240);
  --faint: oklch(0.58 0.01 240);
  --accent: oklch(0.52 0.1 190);
  --accent-ink: oklch(0.99 0.01 190);
  --accent-soft: oklch(0.52 0.1 190 / 0.1);
  --accent-line: oklch(0.52 0.1 190 / 0.35);
  --danger: oklch(0.56 0.18 25);
  --warn: oklch(0.65 0.14 70);
  --ok: oklch(0.56 0.13 150);
  --user-bg: oklch(0.945 0.012 200);
  --code-bg: oklch(0.975 0.004 90);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.04), 0 10px 30px -14px oklch(0 0 0 / 0.18);
  --shadow-pop: 0 0 0 1px var(--line), 0 24px 60px -20px oklch(0 0 0 / 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.65 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
.hidden { display: none !important; }
.no-anim, .no-anim * { transition: none !important; }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; border-radius: var(--r-sm); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); border: 3px solid transparent; background-clip: padding-box; }

/* icons are inline SVG injected by JS into [data-ic] / <i data-ic> */
.ic { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
i[data-ic] { display: inline-flex; }

/* ── brand ── */
.seal {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; letter-spacing: 0;
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.12);
}
.seal.lg { width: 56px; height: 56px; border-radius: 14px; font-size: 30px; }
.brand { display: flex; align-items: center; gap: 10px; }
.wordmark { font-weight: 600; letter-spacing: .02em; }

/* ── layout ── */
.app { display: flex; height: 100dvh; overflow: hidden; }
.rail {
  width: var(--rail-w); flex: none; display: flex; flex-direction: column;
  background: var(--bg-2); border-right: 1px solid var(--line);
  transition: margin .28s var(--ease), transform .28s var(--ease);
}
.app.collapsed .rail { margin-left: calc(-1 * var(--rail-w)); }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 10px 16px; }
.rail-actions { display: grid; gap: 2px; padding: 4px 8px 8px; }
.rail-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px; text-align: left; transition: background .15s, color .15s;
}
.rail-btn:hover { background: var(--surface); color: var(--ink); }
.rail-btn.primary { color: var(--ink); }
.rail-btn.active { background: var(--surface-2); }
.chip > .ic { width: 14px; height: 14px; color: var(--accent); }
.rail-btn kbd { margin-left: auto; font: 10.5px/18px var(--font); color: var(--faint); padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; letter-spacing: .02em; }
.rail-btn .ic { color: var(--muted); }
.sessions { flex: 1; overflow-y: auto; padding: 4px 8px 12px; mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 16px), transparent); }
.s-group { font-size: 11.5px; color: var(--faint); padding: 14px 10px 4px; font-weight: 500; }
.s-item {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 13.5px; cursor: pointer; transition: background .12s;
}
.s-item:hover { background: var(--surface); color: var(--ink); }
.s-item.active { background: var(--surface-2); color: var(--ink); }
.s-item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-src { font-size: 10.5px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 0 6px; line-height: 17px; flex: none; }
.s-live { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.6s infinite; }
.rail-foot { border-top: 1px solid var(--line); padding: 8px; display: grid; gap: 2px; }
.gw { margin-left: auto; display: flex; gap: 4px; }
.gw b { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.gw b.on { background: var(--ok); } .gw b.err { background: var(--danger); }
.scrim { display: none; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.stage.no-chat #renameChat, .stage.no-chat #deleteChat, .stage.no-chat .top-actions .vr { display: none; }
.chip.effort-chip { display: none; }
.topbar { position: relative; z-index: 5; background: var(--bg); height: 52px; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 16px; flex: none; }
.topbar .title { font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.top-actions { display: flex; gap: 2px; opacity: .8; }
.ibtn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--r-sm); color: var(--muted); transition: background .12s, color .12s; flex: none; }
.ibtn:hover { background: var(--surface); color: var(--ink); }
.show-collapsed, .show-mobile { display: none; }
.app.collapsed .show-collapsed { display: inline-grid; }

.scroller { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.thread { max-width: calc(var(--col) + 48px); margin: 0 auto; padding: 8px 24px 56px; }

/* ── messages ── */
.turn { padding: 14px 0; animation: rise .35s var(--ease) both; }
.turn.user { display: flex; justify-content: flex-end; }
.u-bubble {
  max-width: 82%; background: var(--user-bg); padding: 10px 16px; border-radius: 18px 18px 6px 18px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.6;
}
.turn.ai { display: grid; grid-template-columns: 26px 1fr; gap: 16px; }
.prose + .steps, .steps + div > .prose { margin-top: 14px; }
.ai-mark { width: 26px; height: 26px; margin-top: 2px; border-radius: 7px; font-size: 13px; }
.ai-body { min-width: 0; }
.ai-body > * + * { margin-top: 10px; }

.prose { word-break: break-word; }
.prose > :first-child { margin-top: 0; } .prose > :last-child { margin-bottom: 0; }
.prose p { margin: .55em 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.35; margin: 1.2em 0 .5em; font-weight: 600; letter-spacing: -.005em; }
.prose h1 { font-size: 1.35em; } .prose h2 { font-size: 1.2em; } .prose h3 { font-size: 1.06em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: .5em 0; } .prose li { margin: .2em 0; } .prose li::marker { color: var(--faint); }
.prose a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.prose a:hover { border-bottom-color: var(--accent); }
.prose blockquote { margin: .8em 0; padding: .1em 0 .1em 1em; color: var(--ink-2); border-left: 2px solid var(--line-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.prose table { border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; font-variant-numeric: tabular-nums; max-width: 100%; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 28px 8px 0; text-align: left; vertical-align: top; font-weight: 400; }
.prose th { font-weight: 500; color: var(--muted); font-size: 12.5px; letter-spacing: .02em; }
.prose td:first-child { color: var(--ink-2); white-space: nowrap; }
.prose strong { font-weight: 600; }
.prose :not(pre) > code { font: .88em var(--mono); background: var(--surface); border: 1px solid var(--line); padding: .1em .38em; border-radius: 5px; }
.codeblock { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--code-bg); margin: .8em 0; }
.codeblock-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; font: 11.5px var(--mono); color: var(--faint); border-bottom: 1px solid var(--line); }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 13px/1.6 var(--mono); }
.copy-btn { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 5px; font: 11.5px var(--font); color: var(--muted); }
.copy-btn:hover { background: var(--surface); color: var(--ink); }

/* thinking + tool steps */
.steps { display: grid; gap: 2px; }
.step { border-radius: var(--r-sm); }
.step-head {
  display: flex; align-items: center; gap: 8px; width: calc(100% + 8px); margin-left: -8px; padding: 5px 8px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--muted); text-align: left; transition: background .12s, color .12s;
}
.step-head:hover { background: var(--surface); color: var(--ink-2); }
.step-ic { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); flex: none; }
.step.running .step-ic { color: var(--accent); }
.step.error .step-ic { color: var(--danger); }
.step-name { color: var(--ink-2); font-weight: 500; flex: none; }
.step-arg { font: 12.5px var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.step-meta { margin-left: auto; font: 11.5px var(--mono); color: var(--faint); flex: none; padding-left: 8px; }
.step-chev { transition: transform .2s var(--ease); color: var(--faint); flex: none; }
.step.open .step-chev { transform: rotate(90deg); }
.step-body { display: none; margin: 2px 0 8px 9px; border-left: 1px solid var(--line); padding-left: 14px; }
.step.open .step-body { display: block; animation: fade .2s var(--ease); }
.step-body pre { margin: 0 0 6px; font: 12px/1.55 var(--mono); color: var(--ink-2); white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; }
.step-body .lbl { font-size: 11px; color: var(--faint); margin: 6px 0 3px; letter-spacing: .04em; }
.think-text { font-size: 13.5px; line-height: 1.65; color: var(--muted); white-space: pre-wrap; max-height: 420px; overflow: auto; }
.shimmer {
  background: linear-gradient(90deg, var(--muted) 0%, var(--ink) 40%, var(--muted) 80%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.8s linear infinite;
}
.spin { animation: spin 1s linear infinite; }

.turn-meta { display: flex; align-items: center; gap: 2px; margin-top: 8px; font: 11.5px var(--mono); color: var(--faint); opacity: 0; transition: opacity .2s; }
.turn.ai:hover .turn-meta, .turn-meta.show { opacity: 1; }
.turn-meta .sep { margin: 0 6px; }
.turn-meta .ibtn { width: 26px; height: 26px; }
.err-card { border: 1px solid oklch(from var(--danger) l c h / .4); background: oklch(from var(--danger) l c h / .08); color: var(--ink); padding: 10px 14px; border-radius: var(--r); font-size: 13.5px; }
.cursor::after { content: ""; display: inline-block; width: 7px; height: 1.05em; vertical-align: -0.15em; margin-left: 2px; background: var(--accent); border-radius: 1px; animation: blink 1s steps(2) infinite; }

/* empty state */
.hello { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 4vh 0 6vh; }
.thread:has(.hello) { height: 100%; }
.hello .seal.lg { width: 44px; height: 44px; font-size: 24px; border-radius: 11px; }
.hello h1 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 600; letter-spacing: -.02em; margin: 18px 0 6px; line-height: 1.2; }
.hello p { color: var(--muted); margin: 0 0 28px; }
.starters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.starter {
  text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2);
  transition: border-color .15s, background .15s, transform .15s var(--ease);
}
.starter:hover { border-color: var(--line-2); background: var(--surface); transform: translateY(-1px); }
.starter b { display: block; font-weight: 500; font-size: 14px; }
.starter span { font-size: 12.5px; color: var(--muted); }

/* ── composer ── */
.dock { position: relative; padding: 0 24px calc(14px + env(safe-area-inset-bottom)); flex: none; }
.dock::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 36px; background: linear-gradient(to bottom, transparent, var(--bg)); pointer-events: none; }
.composer {
  max-width: var(--col); margin: 0 auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--line-2); }
.composer textarea {
  display: block; width: 100%; resize: none; border: 0; outline: 0; background: transparent;
  padding: 14px 18px 4px; min-height: 52px; max-height: 40vh; line-height: 1.55; font-size: 15px;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px 10px; }
.spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2); border: 1px solid var(--line); transition: background .12s, border-color .12s;
  max-width: 46vw;
}
.chip:hover { background: var(--surface-2); }
.chip > span:not(.dot) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.seg { display: inline-flex; padding: 2px; border-radius: 999px; border: 1px solid var(--line); height: 30px; align-items: center; }
.seg button { white-space: nowrap; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; color: var(--muted); transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface-2); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2) inset; }
.tokens { font: 11.5px var(--mono); color: var(--faint); padding-right: 4px; }
.send {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); transition: transform .15s var(--ease), opacity .15s, background .15s;
}
.send:disabled { opacity: .25; cursor: default; }
.send:not(:disabled):hover { transform: scale(1.06); }
.send.stop { background: var(--surface-2); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2) inset; }
.send .ic { width: 17px; height: 17px; stroke-width: 2.2; }
.dock-hint { color: var(--muted) !important; display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); margin-top: 8px; }
.dock-hint .ic { width: 13px; height: 13px; color: var(--warn); }
.effort { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.effort > .ic { width: 15px; height: 15px; margin-left: 4px; }
.top-actions .vr { width: 1px; height: 16px; background: var(--line); margin: 0 4px; align-self: center; }

/* ── popovers / palette ── */
.pop {
  position: fixed; z-index: 60; min-width: 260px; max-width: min(380px, 92vw); max-height: 56vh; overflow: auto;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px;
  animation: pop .16s var(--ease);
}
.pop-group { font-size: 11px; color: var(--faint); padding: 8px 10px 4px; letter-spacing: .04em; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm); font-size: 13.5px; text-align: left; }
.pop-item:hover, .pop-item.hl { background: var(--surface-2); }
.pop-item .check { margin-left: auto; color: var(--accent); }
.pop-item small { color: var(--faint); font: 11px var(--mono); }
.pop-foot { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }

.overlay { position: fixed; inset: 0; z-index: 50; background: oklch(0 0 0 / .42); backdrop-filter: blur(2px); display: grid; place-items: start center; animation: fade .15s; }
#settings { place-items: center; }
.palette { margin-top: 14vh; width: min(620px, 92vw); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; animation: pop .18s var(--ease); }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-in input { flex: 1; height: 52px; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--ink); }
.palette-list { max-height: 50vh; overflow: auto; padding: 6px; }
.palette-list .pop-item small { margin-left: auto; }

/* ── settings ── */
.settings {
  position: relative; width: min(980px, 94vw); height: min(720px, 88dvh); display: grid; grid-template-columns: 210px 1fr;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; animation: pop .2s var(--ease);
}
.settings-nav { background: var(--bg-2); border-right: 1px solid var(--line); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.settings-title { font-weight: 600; padding: 0 10px 12px; }
.settings-nav .rail-btn.active { background: var(--surface-2); color: var(--ink); }
.settings-main { overflow: auto; padding: 28px 36px 40px; }
.settings-close { position: absolute; top: 24px; right: 20px; }
.pane h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 4px; }
.pane > .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.group { border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; background: var(--bg-2); }
.group-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 500; font-size: 14px; }
.row { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.row + .row { border-top: 1px solid var(--line); }
.row .lab { flex: 1; min-width: 0; }
.row .lab b { display: block; font-weight: 450; font-size: 14px; }
.row .lab span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.in, .sel {
  height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 0 11px; outline: 0;
  font-size: 14px; color: var(--ink); transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.in:focus, .sel:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.in { height: auto; padding: 10px 11px; line-height: 1.55; resize: vertical; }
.in.mono { font: 13px/1.55 var(--mono); }
.in.w { width: 260px; } .in.full { width: 100%; }
.btn {
  height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .22s var(--ease); box-shadow: 0 1px 2px oklch(0 0 0 / .3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: oklch(from var(--ok) l c h / .35); background: oklch(from var(--ok) l c h / .08); }
.badge.warn { color: var(--warn); border-color: oklch(from var(--warn) l c h / .35); }
.badge.err { color: var(--danger); border-color: oklch(from var(--danger) l c h / .35); }
.badge.accent { color: var(--accent); border-color: var(--accent-line); }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.prov { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.prov + .prov { border-top: 1px solid var(--line); }
.prov-av { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); font-weight: 600; font-size: 14px; color: var(--ink-2); flex: none; text-transform: uppercase; }
.prov .lab { flex: 1; min-width: 0; }
.prov .lab b { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.prov .lab span { display: block; font: 12px var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); font: 12px var(--mono); color: var(--ink-2); background: var(--surface); cursor: pointer; transition: border-color .12s, color .12s, background .12s; }
.tag:hover { border-color: var(--line-2); }
.tag.on { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.tag .x { opacity: .6; } .tag .x:hover { opacity: 1; }
.hint { font-size: 12.5px; color: var(--muted); }
.hint.err { color: var(--danger); } .hint.ok { color: var(--ok); }
.mem-meter { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.mem-meter i { display: block; height: 100%; background: var(--accent); transition: width .3s var(--ease); }

/* platform cards */
.plat { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: start; padding: 18px; }
.plat-logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
.plat-logo .ic { width: 22px; height: 22px; stroke-width: 1.8; }
.plat-logo.tg { background: oklch(0.62 0.13 240); } .plat-logo.wx { background: oklch(0.66 0.17 145); }
.plat h3 { margin: 2px 0 2px; font-size: 15px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.plat p { margin: 0; color: var(--muted); font-size: 13px; }
.plat-body { grid-column: 1 / -1; display: grid; gap: 12px; }
.qr-box { display: grid; grid-template-columns: 216px 1fr; gap: 20px; align-items: center; padding: 16px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.qr { width: 216px; height: 216px; background: #fff; border-radius: 14px; display: grid; place-items: center; padding: 16px; color: #333; }
.qr svg { shape-rendering: crispEdges; }
.qr svg, .qr img { width: 100%; height: 100%; }
.steps-list { margin: 0; padding-left: 1.2em; color: var(--ink-2); font-size: 13.5px; }
.steps-list li { margin: 4px 0; }
.pending { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 13px; }
.pending > .ic { color: var(--accent); }
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r); font-size: 13px; margin-bottom: 16px; background: oklch(from var(--warn) l c h / .08); border: 1px solid oklch(from var(--warn) l c h / .3); }
.notice > .ic { color: var(--warn); }
.plat > div:nth-child(3) { align-self: center; display: flex; gap: 8px; align-items: center; }
.plat-body:empty { display: none; }
.plat { align-items: center; }
.plat > div:nth-child(2) { align-self: center; }
.pending code { font-family: var(--mono); }

/* dialog */
.dialog { margin-top: 20vh; width: min(440px, 92vw); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 20px; animation: pop .18s var(--ease); }
.dialog h3 { margin: 0 0 6px; font-size: 16px; }
.dialog p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* login */
.login { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: var(--bg); }
.login::before { content: ""; position: absolute; inset: 0; background: radial-gradient(600px 400px at 50% 38%, var(--accent-soft), transparent 70%); pointer-events: none; }
.login-card { position: relative; width: min(340px, 88vw); display: grid; gap: 12px; justify-items: center; text-align: center; animation: rise .5s var(--ease); }
.login-card h1 { margin: 10px 0 0; font-size: 26px; font-weight: 600; letter-spacing: .04em; }
.login-card p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.login-card .in, .login-card .btn { width: 100%; height: 42px; font-size: 15px; justify-content: center; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; }

.toast { position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 8px); z-index: 90; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* highlight.js tokens, theme-aware */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: oklch(0.72 0.12 300); }
.hljs-string, .hljs-attr, .hljs-template-variable { color: oklch(0.74 0.11 150); }
.hljs-number, .hljs-literal { color: oklch(0.76 0.12 60); }
.hljs-comment, .hljs-quote { color: var(--faint); font-style: italic; }
.hljs-title, .hljs-function .hljs-title, .hljs-section { color: oklch(0.75 0.1 230); }
.hljs-variable, .hljs-params { color: var(--ink-2); }
.hljs-meta { color: var(--muted); }
[data-theme="light"] .hljs-keyword, [data-theme="light"] .hljs-built_in { color: oklch(0.5 0.17 300); }
[data-theme="light"] .hljs-string, [data-theme="light"] .hljs-attr { color: oklch(0.5 0.13 150); }
[data-theme="light"] .hljs-number, [data-theme="light"] .hljs-literal { color: oklch(0.55 0.15 50); }
[data-theme="light"] .hljs-title { color: oklch(0.5 0.14 240); }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px transparent; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ── mobile ── */
@media (max-width: 860px) {
  .rail { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-102%); width: min(84vw, 320px); box-shadow: var(--shadow-pop); }
  .app.collapsed .rail { margin-left: 0; }
  .app.rail-open .rail { transform: none; }
  .app.rail-open .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: oklch(0 0 0 / .45); animation: fade .2s; }
  .show-mobile { display: inline-grid; } .show-collapsed { display: none !important; }
  #collapseRail { display: none; }
  .rail-btn kbd { display: none; }
  .thread { padding: 4px 16px 28px; }
  .dock { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .dock-hint { display: none; }
  .turn.ai { grid-template-columns: 1fr; gap: 6px; }
  .ai-mark { display: none; }
  .u-bubble { max-width: 90%; }
  .starters { grid-template-columns: 1fr; }
  .hello { padding-top: 8vh; }
  .effort { display: none; }
  .chip.effort-chip { display: inline-flex; }
  .chip { max-width: 52vw; }
  .send { width: 38px; height: 38px; }
  .tokens { display: none; }
  .composer textarea { min-height: 46px; padding: 12px 14px 2px; }
  .step-head { min-height: 38px; }
  .scroller::-webkit-scrollbar { width: 0; }
  .settings { margin: 0; width: 100vw; height: 100dvh; border-radius: 0; grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav { flex-direction: row; padding: 10px 52px 10px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .settings-title { display: none; }
  .settings-nav .rail-btn { width: auto; white-space: nowrap; }
  .settings-nav .rail-btn .ic { display: none; }
  .settings-main { padding: 20px 16px 40px; }
  .row { flex-wrap: wrap; }
  .in.w { width: 100%; }
  .qr-box { grid-template-columns: 1fr; justify-items: center; }
  .top-actions #toggleTheme { display: none; }
}
