:root{color-scheme:dark;--bg:#0b1117;--chat:#0d141b;--panel:#151d27;--surface:#1c2733;--surface2:#263241;--line:#263342;
  --text:#e9edf2;--muted:#9aa6b6;--accent:#8b7cf6;--accent2:#6d5ce8;--accent-soft:rgba(139,124,246,.14);--out:#372c7a;
  --out-meta:#c8c0ff;--read:#7dd3fc;--bad:#f87171;--warn:#3a2c12;--warn-line:#f5b544;--link:#b9afff}
*{box-sizing:border-box}
html{font-family:-apple-system,system-ui,"Segoe UI","PingFang TC","Microsoft JhengHei",sans-serif;font-size:17px;
  font:-apple-system-body;-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font-size:1.12rem;line-height:1.5;-webkit-tap-highlight-color:transparent;
  -webkit-font-smoothing:antialiased}
button{font:inherit;color:inherit;cursor:pointer;border:0;background:none;padding:0}
a{color:var(--link)}
.i{flex:none;display:block}
#app{min-height:100dvh}
.screen{min-height:100dvh;display:flex;flex-direction:column;position:relative}
@media (min-width:700px){body{background:#06090d}#app{max-width:560px;margin:0 auto;background:var(--bg);box-shadow:0 0 0 1px var(--line)}}

/* setup */
.setup main{flex:1;display:flex;flex-direction:column;justify-content:center;width:100%;max-width:480px;margin:0 auto;
  padding:32px 24px calc(32px + env(safe-area-inset-bottom))}
.logo{display:block;width:88px;height:88px;margin:0 auto 14px;border-radius:24px;box-shadow:0 12px 32px rgba(109,92,232,.35)}
.setup h1{margin:6px 0;text-align:center;font-size:1.6em}
.setup p{margin:8px 0 16px;text-align:center;color:var(--muted)}
.setup label{display:block;margin:18px 0 6px;color:var(--muted);font-size:.9em}
.btn{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:58px;margin:10px 0;border-radius:29px;
  background:var(--accent);color:#fff;font-weight:700;font-size:1.05em}
.btn:active{background:var(--accent2)}.btn.ghost{background:var(--surface);color:var(--text)}.btn:disabled{opacity:.55}
.btn-link{display:block;min-height:48px;margin:6px auto;padding:12px;color:var(--link);text-decoration:underline}
input.code{width:100%;padding:14px;border-radius:14px;border:1px solid var(--line);outline:none;background:var(--surface);
  color:var(--text);font:inherit;font-size:1.25em;letter-spacing:.06em;text-align:center}
input.code:focus{border-color:var(--accent)}
.bigcode{margin:14px 0;padding:20px 8px;border-radius:18px;border:2px dashed var(--accent);background:var(--surface);
  font-size:1.8em;font-weight:800;letter-spacing:.1em;text-align:center;word-break:break-word}
.err{min-height:1.5em;color:var(--bad);text-align:center;font-weight:600}
.back-float{position:absolute;top:calc(10px + env(safe-area-inset-top));left:8px}

/* headers */
header.top{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:10px;background:var(--panel);
  padding:calc(14px + env(safe-area-inset-top)) 18px 14px}
header.top h1{flex:1;margin:0;font-size:1.45em;font-weight:800}
header.top .lock{color:var(--muted)}
.chat-head{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:8px;background:var(--panel);
  padding:calc(8px + env(safe-area-inset-top)) 12px 8px 2px;box-shadow:0 1px 0 var(--line)}
.h-text{flex:1;min-width:0}
.h-title{font-weight:700;font-size:1.02em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.h-sub{min-height:1.2em;font-size:.78em;color:var(--accent);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.icon-btn{width:48px;height:48px;flex:none;border-radius:50%;display:grid;place-items:center;color:var(--muted)}
.icon-btn:active{background:var(--surface2)}.chat-head .icon-btn{color:var(--text)}.icon-btn.danger{color:var(--bad)}

/* avatars */
.av{width:54px;height:54px;flex:none;border-radius:50%;display:grid;place-items:center;overflow:hidden;color:#fff;
  background:linear-gradient(140deg,var(--a1,#a78bfa),var(--a2,#6d28d9));box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}
.av .i{width:28px;height:28px;filter:drop-shadow(0 1px 1px rgba(0,0,0,.3))}
.av.sm{width:42px;height:42px}.av.sm .i{width:22px;height:22px}
.av img{width:100%;height:100%;object-fit:cover}

/* conversation list */
.rows{flex:1;padding:4px 0 120px}
.row{display:flex;align-items:center;gap:14px;width:100%;padding:8px 16px 0;text-align:left}
.row:active{background:var(--surface)}
.row-main{flex:1;min-width:0;padding:8px 0 14px;border-bottom:1px solid var(--line)}
.row-top,.row-bottom{display:flex;align-items:center;gap:8px}
.row-title{flex:1;min-width:0;font-weight:650;font-size:1.03em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row-time{flex:none;font-size:.76em;color:var(--muted)}
.row.unread .row-time{color:var(--accent);font-weight:700}
.row-bottom{margin-top:2px}
.row-preview{flex:1;min-width:0;display:flex;align-items:center;gap:5px;color:var(--muted);font-size:.9em}
.pv{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row-preview.busy{color:var(--accent);font-style:italic}
.badge{flex:none;min-width:24px;height:24px;padding:0 7px;border-radius:12px;display:grid;place-items:center;
  background:var(--accent);color:#fff;font-size:.78em;font-weight:800}
.banner{display:flex;align-items:center;gap:8px;margin:10px 16px;padding:10px 14px;border-radius:12px;background:var(--warn);
  color:#fde68a;font-size:.9em}
.sos{display:flex;align-items:center;justify-content:center;gap:8px;margin:24px 16px;padding:14px;border-radius:14px;
  border:1px solid rgba(248,113,113,.5);color:var(--bad);font-weight:700;text-decoration:none}
.fab{position:fixed;z-index:4;right:max(16px,calc((100vw - 560px) / 2 + 16px));bottom:calc(20px + env(safe-area-inset-bottom));
  display:flex;align-items:center;gap:10px;height:60px;padding:0 22px 0 18px;border-radius:20px;background:var(--accent);
  color:#fff;font-weight:800;font-size:1.02em;box-shadow:0 8px 24px rgba(0,0,0,.45)}
.fab:active{background:var(--accent2)}
.empty{padding:64px 32px;text-align:center;color:var(--muted)}
.empty-art{width:112px;height:112px;margin:0 auto 18px;border-radius:50%;display:grid;place-items:center;color:var(--accent);
  background:var(--accent-soft)}
.empty h2{margin:0 0 6px;color:var(--text);font-size:1.2em}

/* chat */
.chat{height:100dvh;min-height:0}
.msgs{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;padding:10px 12px 16px;background-color:var(--chat);
  background-image:radial-gradient(rgba(255,255,255,.04) 1px,transparent 1.3px);background-size:22px 22px;-webkit-overflow-scrolling:touch}
.day{align-self:center;margin:10px 0;padding:4px 12px;border-radius:9px;background:var(--panel);color:var(--muted);font-size:.78em;
  box-shadow:0 1px 1px rgba(0,0,0,.3)}
.bubble{position:relative;max-width:82%;margin:3px 0;padding:8px 11px 5px;border-radius:14px;box-shadow:0 1px 1px rgba(0,0,0,.35);
  overflow-wrap:anywhere}
.bubble.out{align-self:flex-end;background:var(--out);border-top-right-radius:4px}
.bubble.in{align-self:flex-start;max-width:94%;background:var(--surface);border-top-left-radius:4px}
.stack{align-self:flex-end;max-width:82%;display:flex;flex-direction:column;align-items:flex-end}.stack .bubble{max-width:100%}
.txt{white-space:pre-wrap}
.meta{display:flex;align-items:center;justify-content:flex-end;gap:6px;margin-top:3px;font-size:.72em;color:var(--muted);line-height:1}
.out .meta{color:var(--out-meta)}.meta .read{color:var(--read)}
.failed{display:flex;align-items:center;gap:6px;margin:2px 4px 6px;color:var(--bad);font-size:.85em}
.att img,.att video{display:block;width:100%;max-width:320px;margin:2px 0 4px;border-radius:10px}
.att audio{display:block;width:250px;max-width:100%;margin:4px 0}
.voice-l{display:flex;align-items:center;gap:6px;color:var(--out-meta);font-size:.88em}
.doc{display:flex;align-items:center;gap:10px;margin:2px 0 4px;padding:10px 12px;border-radius:10px;background:rgba(0,0,0,.2)}
.quote{display:flex;align-items:center;gap:10px;padding:8px 6px 8px 12px;border-left:4px solid var(--accent);border-radius:8px;
  background:rgba(0,0,0,.22)}
.quote>div{flex:1;min-width:0}
.q-label{color:var(--accent);font-size:.75em;font-weight:700}
.q-ref{font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.quote.in-bubble{margin:0 0 6px}
.typing{align-self:flex-start;display:flex;align-items:center;gap:10px;max-width:88%;margin:6px 0;padding:10px 14px;border-radius:14px;
  border-top-left-radius:4px;background:var(--surface);color:var(--muted);font-size:.9em}
.dots{display:inline-flex;gap:4px}
.dots span{width:7px;height:7px;border-radius:50%;background:var(--accent);animation:blink 1.4s infinite both}
.dots span:nth-child(2){animation-delay:.2s}.dots span:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.25}40%{opacity:1}}
.chat-empty{margin:auto;padding:24px;text-align:center;color:var(--muted)}
.chat-empty .empty-art{width:88px;height:88px}

/* answers */
.ans{padding:10px 14px 7px}
.asked{margin-bottom:6px;color:var(--muted);font-size:.8em}
.short{margin:2px 0 10px;padding:10px 12px;border-radius:10px;border-left:4px solid var(--accent);background:var(--accent-soft);font-weight:650}
.sos-ans .short{border-left-color:var(--bad);background:rgba(248,113,113,.14)}
.body{font-size:.98em}
.body p{margin:.5em 0}
.body h2{margin:1.1em 0 .3em;color:#fff;font-size:1.08em}
.body h3{margin:.9em 0 .25em;font-size:1em}
.body ol,.body ul{margin:.4em 0;padding-left:1.35em}.body li{margin:.3em 0}
.body strong{color:#fff}
.body figure{margin:12px 0}
.body img{display:block;width:100%;max-width:100%;height:auto;border-radius:10px;background:#fff}
.body figcaption{margin-top:4px;color:var(--muted);font-size:.85em}
.body blockquote{margin:10px 0;padding:8px 12px;border-left:4px solid var(--line);border-radius:8px;background:rgba(0,0,0,.18)}
.body blockquote.warn{border-left-color:var(--warn-line);background:var(--warn);color:#fde7b0}
.body blockquote p{margin:.2em 0}
.body table{display:block;max-width:100%;overflow-x:auto;margin:10px 0;border-collapse:collapse;font-size:.92em}
.body th,.body td{padding:6px 9px;border:1px solid var(--line);text-align:left;vertical-align:top}
.body th{background:var(--surface2)}
.body section.more h2{color:var(--muted);font-size:.95em}
.card{display:block;margin:8px 0;padding:10px 12px;border-radius:12px;background:var(--surface2)}
.card a{font-weight:650;text-decoration:none}
.card small{display:block;margin-top:2px;color:var(--muted);font-size:.85em}
.chip-btn{display:inline-flex;align-items:center;gap:6px;min-height:40px;margin:6px 6px 0 0;padding:6px 12px;border-radius:20px;
  background:rgba(255,255,255,.06);color:var(--link);font-size:.85em}
.follow{margin-top:12px;padding-top:8px;border-top:1px solid var(--line)}
.f-label{margin-bottom:4px;color:var(--muted);font-size:.8em}
.fu{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;min-height:50px;margin:6px 0;padding:10px 12px;
  border-radius:12px;background:var(--accent-soft);text-align:left;font-size:.95em}
.fu .i{color:var(--accent)}
.ans .meta{justify-content:space-between}
.speak{margin:0;min-height:36px}

/* composer */
.tray{padding:0 10px;background:var(--chat)}
.tray .quote{margin:6px 0 2px;background:var(--panel)}
.thumbs{display:flex;gap:8px;overflow-x:auto;padding:6px 0}
.thumb{position:relative;flex:none;width:76px;height:76px;border-radius:12px;display:flex;flex-direction:column;align-items:center;
  justify-content:center;gap:2px;overflow:hidden;background:var(--surface);color:var(--muted)}
.thumb img{width:100%;height:100%;object-fit:cover}
.thumb small{max-width:68px;font-size:.6em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.thumb-x{position:absolute;top:4px;right:4px;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;
  background:rgba(0,0,0,.65);color:#fff}
.composer{display:flex;align-items:flex-end;gap:8px;padding:8px 8px calc(8px + env(safe-area-inset-bottom));background:var(--chat)}
.pill{flex:1;min-width:0;display:flex;align-items:flex-end;min-height:54px;padding:3px 4px 3px 16px;border-radius:27px;background:var(--surface)}
.pill textarea{display:block;flex:1;min-width:0;align-self:center;height:calc(1.35em + 24px);max-height:160px;margin:0;
  padding:12px 0;border:0;outline:none;resize:none;overflow-y:auto;background:none;color:var(--text);font:inherit;font-size:1.02em;
  line-height:1.35;box-sizing:border-box}
.pill textarea::placeholder{color:var(--muted);opacity:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.round{width:54px;height:54px;flex:none;border-radius:50%;display:grid;place-items:center;background:var(--accent);color:#fff;
  box-shadow:0 2px 6px rgba(0,0,0,.35)}
.round:active{background:var(--accent2)}.round.idle{background:var(--surface2);color:var(--muted);box-shadow:none}
.pill.rec{align-items:center;gap:12px;padding-left:4px}
.rec-dot{width:12px;height:12px;border-radius:50%;background:var(--bad);animation:blink 1.2s infinite}
.rec-time{font-weight:700;font-variant-numeric:tabular-nums}
.rec-label{color:var(--muted);font-size:.9em}
.toast{position:fixed;z-index:9;left:16px;right:16px;bottom:calc(96px + env(safe-area-inset-bottom));max-width:528px;margin:0 auto;
  padding:13px 16px;border-radius:14px;background:#2a3442;color:#fff;font-size:.95rem;box-shadow:0 8px 24px rgba(0,0,0,.4)}
.langs{display:flex;justify-content:center;gap:8px;margin:0 0 6px}.lang{min-height:40px;padding:6px 16px;border-radius:20px;background:var(--surface);color:var(--muted);font-size:.9em}.lang.on{background:var(--accent);color:#fff}
.steps{list-style:none;margin:8px 0 18px;padding:0}.steps li{display:flex;align-items:center;gap:12px;margin:10px 0;padding:14px;border-radius:14px;background:var(--surface)}.steps .n{flex:none;width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:var(--accent);color:#fff;font-weight:800}.steps .i{color:var(--accent)}
.keys{margin:0 0 12px;padding:10px 12px;border-radius:10px;background:rgba(52,211,153,.10);border-left:4px solid #34d399}.keys-t{font-weight:800;font-size:.85em;color:#6ee7b7;margin-bottom:4px}.keys ul{margin:0;padding-left:1.2em}.keys li{margin:.25em 0}
.prog{flex:1;min-width:0}.prog-meta{font-size:.82em;color:var(--muted)}.bar{height:6px;margin:6px 0 4px;border-radius:3px;background:var(--surface2);overflow:hidden}.bar span{display:block;height:100%;width:0;border-radius:3px;background:linear-gradient(90deg,var(--accent2),var(--accent));transition:width 1.5s ease}
