/* Regie: the phone app. One accent (blue, the data-viz sequential hue), status colours only with an icon or a word. */
:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #efeeea;
  --line: #e6e5e0;
  --line-2: #d9d8d2;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #75746f;
  --accent: #2a78d6;
  --accent-soft: #e6f0fc;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --good-soft: #e5f5e5;
  --warn: #b77700;
  --warn-mark: #fab219;
  --warn-soft: #fff4dc;
  --bad: #d03b3b;
  --bad-soft: #fbe7e7;
  --track: #ecebe7;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --bubble: #2a78d6;
  --r: 18px;
  --r-sm: 12px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f0e;
    --surface: #1a1a19;
    --surface-2: #212120;
    --surface-3: #2a2a28;
    --line: #2c2c2a;
    --line-2: #3a3a37;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e87;
    --accent: #3987e5;
    --accent-soft: #172a42;
    --good: #2fbf2f;
    --good-soft: #14281a;
    --warn: #fab219;
    --warn-mark: #fab219;
    --warn-soft: #2d2410;
    --bad: #ec6060;
    --bad-soft: #321818;
    --track: #2c2c2a;
    --shadow: none;
    --bubble: #2f6fc0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #212120; --surface-3: #2a2a28; --line: #2c2c2a; --line-2: #3a3a37;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e87; --accent: #3987e5; --accent-soft: #172a42;
  --good: #2fbf2f; --good-soft: #14281a; --warn: #fab219; --warn-soft: #2d2410; --bad: #ec6060; --bad-soft: #321818;
  --track: #2c2c2a; --shadow: none; --bubble: #2f6fc0;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); overflow-x: clip; }
main, .view, .card, .list, .grow { min-width: 0; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num, .tab-num { font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a.row, a.card, .tabs a { color: inherit; }
.tabs a { color: var(--muted); }

/* ------------------------------------------------------------- boot & login */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.boot img { border-radius: 18px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .75; } }

.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-logo { border-radius: 16px; box-shadow: 0 8px 30px rgba(42, 120, 214, .3); }
.login h1 { font-size: 30px; letter-spacing: -.02em; margin: 18px 0 4px; }
.login-sub { color: var(--text-2); margin: 0 0 28px; }
.login-note { color: var(--text-2); font-size: 14px; text-align: left; margin: 0 0 12px; }
.field { display: block; text-align: left; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 6px 2px; }
.field input {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; font-size: 16px;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-error { color: var(--bad); min-height: 22px; margin: 4px 0 10px; font-size: 14px; }
.passkey-step { padding: 8px 0 4px; }
.passkey-step p { color: var(--text-2); margin: 14px 0 0; }
.fp-ring { width: 92px; height: 92px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); animation: pulse 2s ease-in-out infinite; }
.fp-ring svg { width: 46px; height: 46px; stroke-width: 1.5; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(42, 120, 214, .35); } 50% { box-shadow: 0 0 0 14px rgba(42, 120, 214, 0); } }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 15px;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { height: 36px; padding: 0 14px; border-radius: 11px; font-size: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 19px; height: 19px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--text-2); }
.icon-btn:active { background: var(--surface-3); }
.icon-btn b { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--bg); }
.chip-btn { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); }
.chip-btn svg { width: 16px; height: 16px; }
.chip-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line-2)); }
.voice-bar { position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b) + 66px); align-self: center; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.voice-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: blink 1s ease-in-out infinite; }
.voice-bar i.speak { background: var(--good); }
.voice-bar i.wait { background: var(--accent); }
.say { border: 0; background: none; color: var(--muted); padding: 2px 0 0; display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; }
.say svg { width: 15px; height: 15px; }
.chip-btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-2)); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.link-btn svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------- shell */
.app { min-height: 100dvh; }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); padding-top: var(--safe-t); }
.top-inner { max-width: 720px; margin: 0 auto; height: 56px; padding: 0 12px 0 20px; display: flex; align-items: center; justify-content: space-between; }
.top h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; font-weight: 750; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-right: 4px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.live.stale i { background: var(--warn-mark); }
.live.off i { background: var(--bad); }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px calc(var(--tabs-h) + var(--safe-b) + 24px); }
.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + var(--safe-b)); padding: 6px 6px var(--safe-b);
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.tabs a { position: relative; flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 14px; }
.tabs a svg { width: 24px; height: 24px; transition: transform .15s; }
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs a[aria-current="page"] svg { transform: translateY(-1px); stroke-width: 2.1; }
.tabs a:active { background: var(--surface-3); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-style: normal; box-shadow: 0 0 0 2px var(--surface); }

/* ------------------------------------------------------------- blocks */
.section { margin: 22px 0 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
.section-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; font-weight: 700; }
.section-head .aside { font-size: 13px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 56px; }
.row + .row { border-top: 1px solid var(--line); }
.row.tap { cursor: pointer; }
.row.tap:active { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: none; font-size: 13px; color: var(--text-2); }
.row .end b { display: block; color: var(--text); font-size: 15px; }
.row > svg.chev { width: 18px; height: 18px; color: var(--muted); }
.ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.ico svg { width: 20px; height: 20px; }
.ico.ok { background: var(--good-soft); color: var(--good); }
.ico.warn { background: var(--warn-soft); color: var(--warn); }
.ico.bad { background: var(--bad-soft); color: var(--bad); }
.ico.info { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--good); } .dot.warn { background: var(--warn-mark); } .dot.bad { background: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill.ok { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill svg { width: 14px; height: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* hero */
.hero { padding: 20px; display: flex; gap: 16px; align-items: center; }
.hero .grow { flex: 1; min-width: 0; }
.hero .ico { width: 52px; height: 52px; border-radius: 16px; }
.hero .ico svg { width: 28px; height: 28px; }
.hero h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.hero p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.issue { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }
.issue + .issue { border-top: 1px solid var(--line); }
.issue .ico { width: 32px; height: 32px; border-radius: 10px; }
.issue .ico svg { width: 18px; height: 18px; }
.issue .t { font-weight: 650; }
.issue .grow { min-width: 0; }
.issue .s { font-size: 13.5px; color: var(--text-2); margin-top: 1px; overflow-wrap: anywhere; }
.issue .fix { margin-top: 10px; }

/* meters */
.meter { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .4s ease; }
.meter.warn > i { background: var(--warn-mark); }
.meter.bad > i { background: var(--bad); }
.meter.good > i { background: var(--good); }
.mini { display: grid; grid-template-columns: 62px minmax(0, 1fr) 38px; gap: 8px; align-items: center; font-size: 12px; color: var(--text-2); }
.mini + .mini { margin-top: 6px; }
.mini .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

/* servers grid */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 360px) { .grid2 { grid-template-columns: 1fr; } }
.srv { padding: 14px; cursor: pointer; transition: transform .08s; }
.srv:active { transform: scale(.985); }
.srv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.srv-head .t { font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv .s { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

/* subscriptions */
.sub { padding: 16px; }
.sub + .sub { border-top: 1px solid var(--line); }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sub-head h3 { margin: 0; font-size: 17px; }
.sub-head .pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.win { padding: 10px 0 0; }
.win + .win { border-top: 1px dashed var(--line); margin-top: 10px; }
.win-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.win-name { font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.win-val { font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.win-val small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.win-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; font-size: 12.5px; color: var(--muted); }
.fc { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; font-weight: 600; }
.fc svg { width: 16px; height: 16px; }
.fc.ok { color: var(--good); } .fc.warn { color: var(--warn); } .fc.bad { color: var(--bad); }
.compact-sub { display: grid; grid-template-columns: 64px minmax(0, 1fr) 72px; gap: 12px; align-items: center; }
.compact-sub .name { font-weight: 650; font-size: 14px; }
.compact-sub .pct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.compact-sub .pct small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); }

/* plan */
.plan { padding: 16px; }
.plan-order { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 8px; }
.plan-order .step { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 30px; padding: 0 10px; border-radius: 10px; background: var(--surface-3); font-weight: 700; font-size: 13.5px; }
.plan-order .step.first { background: var(--accent); color: var(--accent-ink); }
.plan-order svg { width: 14px; height: 14px; color: var(--muted); }
.plan-fam { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-right: 4px; }

/* chart */
.chart { padding: 16px 12px 10px 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; padding-right: 4px; }
.chart-head .big { font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chart svg { width: 100%; height: 132px; display: block; overflow: visible; stroke: none; }
.chart .bar { fill: var(--accent); }
.chart .bar.sel { fill: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .lbl { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.chart-tip { min-height: 20px; font-size: 13px; color: var(--text-2); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* segmented */
.seg { display: flex; background: var(--surface-3); border-radius: 12px; padding: 3px; margin: 8px 0 4px; }
.seg button { flex: 1; height: 34px; border: 0; background: transparent; border-radius: 9px; font-size: 13.5px; font-weight: 650; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.loglines { font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: var(--text-2); padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.stages { display: flex; gap: 3px; margin-top: 10px; }
.stages i { flex: 1; height: 6px; border-radius: 3px; background: var(--track); }
.stages i.done { background: var(--good); }
.stages i.cur { background: var(--accent); }

/* toggles */
.switch { position: relative; width: 48px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: var(--line-2); transition: background .18s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ------------------------------------------------------------- chat */
.chat-view { display: flex; flex-direction: column; min-height: calc(100dvh - 56px - var(--safe-t) - var(--tabs-h) - var(--safe-b) - 28px); }
.chat-bar { position: sticky; top: calc(56px + var(--safe-t)); z-index: 5; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 10px; background: var(--bg); }
.chat-bar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-sel { display: flex; gap: 8px; min-width: 0; }
.sel { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 650; font-size: 14px; min-width: 0; flex: none; }
.sel span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel svg { width: 17px; height: 17px; color: var(--accent); }
.sel .chev-d { transform: rotate(90deg); color: var(--muted); width: 15px; height: 15px; }
.sel.grow-sel { flex: 1; justify-content: space-between; font-weight: 500; color: var(--text-2); }
.pick { display: flex; flex-direction: column; gap: 8px; }
.pick button { text-align: left; display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.pick button.on { border-color: var(--accent); background: var(--accent-soft); }
.pick .t { font-weight: 650; }
.pick .s { font-size: 13px; color: var(--text-2); }
.orch { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); min-width: 0; }
.orch span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orch i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.orch i.ok { background: var(--good); }
.orch i.busy { background: var(--accent); animation: blink 1s ease-in-out infinite; }
.orch i.off { background: var(--bad); }
@keyframes blink { 50% { opacity: .3; } }
.chat-bar-actions { display: flex; gap: 6px; flex: none; }
.chat-list { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.msg { max-width: 88%; }
.msg.user { align-self: flex-end; background: var(--bubble); color: #fff; padding: 10px 14px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant { align-self: flex-start; max-width: 100%; padding: 2px 2px; overflow-wrap: anywhere; }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.assistant li { margin: 2px 0; }
.msg.assistant h3, .msg.assistant h4 { margin: 12px 0 6px; font-size: 15px; }
.msg.assistant code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.msg.assistant pre { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; overflow-x: auto; font-size: 12px; margin: 6px 0 8px; }
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant table { border-collapse: collapse; font-size: 13px; margin: 6px 0 8px; display: block; overflow-x: auto; }
.msg.assistant th, .msg.assistant td { border-bottom: 1px solid var(--line); padding: 5px 10px 5px 0; text-align: left; white-space: nowrap; }
.msg.assistant .cursor { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--accent); border-radius: 2px; animation: blink .9s steps(2) infinite; }
.tool { align-self: stretch; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 12.5px; color: var(--text-2); overflow: hidden; }
.tool summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary span { font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tool summary svg { width: 15px; height: 15px; }
.tool .st { width: 16px; height: 16px; display: grid; place-items: center; flex: none; }
.tool .st.run::before { content: ""; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.tool .st.ok { color: var(--good); } .tool .st.err { color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }
.tool pre { margin: 0; padding: 8px 10px 10px; border-top: 1px solid var(--line); max-height: 260px; overflow: auto; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tools-group { align-self: stretch; display: flex; flex-direction: column; gap: 4px; }
.meta-line { align-self: center; font-size: 12px; color: var(--muted); padding: 2px 10px 6px; font-variant-numeric: tabular-nums; text-align: center; }
.meta-line.err { color: var(--bad); }
.approval { align-self: stretch; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--warn-mark) 55%, var(--line)); background: var(--warn-soft); padding: 14px; }
.approval .h { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--warn); }
.approval .h svg { width: 18px; height: 18px; }
.approval .sum { margin: 6px 0 8px; font-weight: 600; }
.approval pre { margin: 0 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.approval.done { background: var(--surface); border-color: var(--line); }
.approval.done .h { color: var(--text-2); }
.suggest { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 36px 8px 16px; text-align: center; }
.suggest .ico { width: 56px; height: 56px; border-radius: 18px; }
.suggest .ico svg { width: 28px; height: 28px; }
.suggest h2 { margin: 0; font-size: 19px; }
.suggest p { margin: 0; color: var(--text-2); font-size: 14px; max-width: 320px; }
.suggest .chips { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 360px; margin-top: 4px; }
.suggest .chips button { text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 550; }
.suggest .chips button:active { background: var(--surface-2); }
.composer {
  position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b) + 8px); display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 14px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: 0 6px 24px rgba(0, 0, 0, .08);
}
.attach { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; flex: none; margin-left: -8px; }
.attach:active { background: var(--surface-3); }
.attach.listening { background: var(--bad); color: #fff; animation: pulse-red 1.2s ease-in-out infinite; }
@keyframes pulse-red { 50% { box-shadow: 0 0 0 8px rgba(208, 59, 59, .18); } }
.attach-row { position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b) + 66px); display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px; }
body.keyboard .attach-row { bottom: 66px; }
.att { position: relative; flex: none; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; font-size: 11px; color: var(--text-2); border: 1px solid var(--line); }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; padding: 0; }
.att button svg { width: 13px; height: 13px; }
.att.busy::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }
.msg-files img { width: 120px; height: 120px; object-fit: cover; border-radius: 14px; display: block; }
.msg-files .doc { padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.18); font-size: 13px; }
.question { align-self: stretch; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); padding: 14px; }
.question .q { font-weight: 650; margin-bottom: 10px; }
.question .opts { display: flex; flex-direction: column; gap: 8px; }
.question .opts button { text-align: left; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: 14.5px; }
.question .opts button:first-child { border-color: var(--accent); }
.question.done { opacity: .6; }
.question.done button { pointer-events: none; }
.composer textarea { flex: 1; border: 0; outline: none; background: transparent; resize: none; max-height: 160px; padding: 9px 0; font-size: 16px; line-height: 1.35; }
.send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; transition: opacity .15s, transform .08s; }
.send:active { transform: scale(.94); }
.send[disabled] { opacity: .35; }
.send svg { width: 20px; height: 20px; stroke-width: 2.2; }
.send.stop { background: var(--text); color: var(--bg); }
.send.stop svg { fill: currentColor; width: 16px; height: 16px; }
.msg-state { align-self: flex-end; font-size: 11.5px; color: var(--muted); margin: -4px 4px 2px; }
.thinking { align-self: flex-start; display: inline-flex; gap: 5px; padding: 12px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.steps { align-self: stretch; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--text-2); overflow: hidden; }
.steps > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; }
.steps > summary::-webkit-details-marker { display: none; }
.steps > summary .now { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 12px; }
.steps > summary b { color: var(--text); font-weight: 650; flex: none; }
.steps[open] > summary { border-bottom: 1px solid var(--line); }
.steps .tool { border: 0; border-radius: 0; border-top: 1px solid var(--line); }
.steps .tool:first-of-type { border-top: 0; }
.tool .st.stop { color: var(--muted); }
.appr-bar { position: sticky; top: calc(56px + var(--safe-t) + 104px); z-index: 4; display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; margin-bottom: 8px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--warn-mark) 55%, var(--line)); background: var(--warn-soft); color: var(--warn); font-weight: 650; text-align: left; }
.appr-bar svg { width: 20px; height: 20px; }
.to-bottom { position: fixed; right: 18px; bottom: calc(var(--tabs-h) + var(--safe-b) + 84px); width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; box-shadow: 0 4px 16px rgba(0,0,0,.18); z-index: 6; }
.to-bottom svg { transform: rotate(90deg); width: 20px; height: 20px; }
body.keyboard .tabs { display: none; }
body.keyboard .composer { bottom: 8px; }
body.keyboard main { padding-bottom: 16px; }

/* ------------------------------------------------------------- sheet & toast */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .38); animation: fadein .2s ease-out; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--bg); border-radius: 22px 22px 0 0; padding-bottom: var(--safe-b); animation: up .26s cubic-bezier(.2, .8, .2, 1); }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 2px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px 6px 20px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.sheet-body { overflow-y: auto; padding: 4px 16px 20px; overscroll-behavior: contain; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fadein { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 70; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 550; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); animation: toast .22s ease-out; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.share { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 4px 12px; align-items: center; font-size: 13px; margin-top: 10px; }
.share .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.share .meter { grid-column: 1 / -1; height: 4px; margin-bottom: 4px; }
.advice { padding: 16px; }
.advice + .advice { border-top: 1px solid var(--line); }
.advice h3 { margin: 6px 0 4px; font-size: 15.5px; }
.advice p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; }

@media (min-width: 760px) {
  .tabs { left: 50%; right: auto; transform: translateX(-50%); width: 560px; bottom: 14px; border-radius: 22px; border: 1px solid var(--line); height: var(--tabs-h); padding: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .12); }
  main { padding-bottom: calc(var(--tabs-h) + 48px); }
  .composer { bottom: calc(var(--tabs-h) + 28px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
