:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #eeece6;
  --line: #e0ddd5;
  --text: #1a1c1f;
  --muted: #6a6e75;
  --faint: #9a9da3;
  --accent: #0d7468;
  --accent-ink: #ffffff;
  --accent-soft: #d9eeea;
  --warn: #b45309;
  --warn-soft: #fdf0dc;
  --danger: #b42318;
  --danger-soft: #fbe4e1;
  --ok: #1f7a3d;
  --user: #1a1c1f;
  --user-ink: #f5f4f0;
  --term-bg: #0d0f11;
  --term-fg: #d8dadc;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 6px 24px rgba(20, 20, 20, .06);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --term-size: 12px;
  --cc-ink: brightness(.6) saturate(1.5);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1012; --surface: #16191c; --surface-2: #1e2226; --line: #2a2f34;
    --text: #e8e6e1; --muted: #8d9198; --faint: #5f646b;
    --accent: #3cc9b4; --accent-ink: #07211d; --accent-soft: #123430;
    --warn: #f0a531; --warn-soft: #33260f; --danger: #f2776b; --danger-soft: #3a1714; --ok: #5bd08a;
    --user: #e8e6e1; --user-ink: #121416; --cc-ink: none;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1012; --surface: #16191c; --surface-2: #1e2226; --line: #2a2f34;
  --text: #e8e6e1; --muted: #8d9198; --faint: #5f646b;
  --accent: #3cc9b4; --accent-ink: #07211d; --accent-soft: #123430;
  --warn: #f0a531; --warn-soft: #33260f; --danger: #f2776b; --danger-soft: #3a1714; --ok: #5bd08a;
  --user: #e8e6e1; --user-ink: #121416; --cc-ink: none;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
#app { display: flex; flex-direction: column; height: var(--app-h, 100dvh); max-width: 860px; margin: 0 auto; }
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px;
  height: calc(54px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; min-width: 0; margin: 0 4px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.bar h1 small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; font-weight: 450; color: var(--muted); margin-top: -2px; }
.bar h1 .t { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text); flex: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.stop { color: var(--danger); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 28px; height: 28px; flex: none; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; margin-right: 6px; }
.conn.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.conn.wait { background: var(--warn); }
main { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.pad { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }

/* ---------- home ---------- */
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px; }
.section-h h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.widget {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  min-height: 76px; position: relative;
}
.widget .k { font-size: 12px; color: var(--muted); }
.widget .v { font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
.widget.metric .v { font-family: var(--sans); font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.widget.bad .v { color: var(--danger); font-size: 12px; }
.widget.wide { grid-column: 1 / -1; }

.sessions { display: flex; flex-direction: column; gap: 8px; }
.srow {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 4px 12px; align-items: center; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.srow:active { transform: scale(.99); }
.srow .title { font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.srow .meta { grid-column: 2 / 4; display: flex; gap: 8px; align-items: center; min-width: 0; }
.srow .preview { color: var(--muted); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; flex: 1; }
.srow .when { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chip { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); flex: none; letter-spacing: .02em; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.dot.idle { background: var(--ok); }
.dot.running { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.dot.waiting { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.dot.error { background: var(--danger); }
.dot.closed { background: var(--faint); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 0%, transparent); opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none !important; } }

.empty { text-align: center; color: var(--muted); padding: 36px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.fab {
  position: fixed; right: max(18px, calc(50vw - 412px)); bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 6;
  height: 52px; padding: 0 20px 0 16px; border-radius: 26px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; gap: 8px; font-weight: 650; box-shadow: var(--shadow);
}
.fab svg { width: 22px; height: 22px; }

/* ---------- timeline ---------- */
.timeline { padding: 12px 14px 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 100%; min-width: 0; }
.msg.user { align-self: flex-end; max-width: 86%; background: var(--user); color: var(--user-ink); border-radius: 18px 18px 4px 18px; padding: 9px 14px; white-space: pre-wrap; word-break: break-word; }
.msg.assistant { display: flex; flex-direction: column; gap: 8px; }
.md { word-break: break-word; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: .5em 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1.02em; margin: 1em 0 .4em; }
.md ul, .md ol { padding-left: 1.3em; margin: .4em 0; }
.md li { margin: .15em 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.md pre { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; }
.md pre code { background: none; padding: 0; font-size: inherit; }
.md blockquote { margin: .5em 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md hr { border: 0; border-top: 1px solid var(--line); }
.draft { opacity: .85; }
.draft::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.thinking { font-size: 13px; color: var(--muted); }
.thinking summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.thinking summary::before { content: "◌"; }
.thinking .body { white-space: pre-wrap; padding: 6px 0 0 18px; font-size: 13px; }

.tool { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.tool > summary {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: 22px auto 1fr 16px; align-items: center; gap: 8px;
  padding: 8px 10px; font-size: 13px;
}
.tool > summary::-webkit-details-marker { display: none; }
.tool .ti { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.tool .ti svg { width: 14px; height: 14px; }
.tool .tn { font-weight: 600; }
.tool .ts { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.tool .st { width: 16px; height: 16px; border-radius: 50%; }
.tool .st.pending { border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.tool .st.ok { background: var(--ok); mask: var(--check) center / 12px no-repeat; -webkit-mask: var(--check) center / 12px no-repeat; }
.tool .st.err { background: var(--danger); mask: var(--cross) center / 11px no-repeat; -webkit-mask: var(--cross) center / 11px no-repeat; }
.tool.err { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.tool .io { border-top: 1px solid var(--line); }
.tool .io .lbl { font-size: 11px; color: var(--faint); padding: 6px 12px 0; letter-spacing: .04em; }
.tool pre { margin: 0; padding: 6px 12px 10px; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }
@keyframes spin { to { transform: rotate(360deg); } }
:root { --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        --cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E"); }

.notice { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 3px 10px; border-radius: 99px; max-width: 92%; text-align: center; }
.notice.warn { color: var(--warn); background: var(--warn-soft); }
.notice.error { color: var(--danger); background: var(--danger-soft); }
.result { align-self: center; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; display: flex; gap: 10px; }
.result.err { color: var(--danger); }
.apx { align-self: center; font-size: 12px; color: var(--muted); }

/* ---------- terminal ---------- */
.term-wrap { background: var(--term-bg); min-height: 100%; }
.term {
  margin: 0; padding: 10px 10px 16px; color: var(--term-fg); font: var(--term-size)/1.35 var(--mono);
  white-space: pre; overflow-x: auto; min-height: 100%; tab-size: 8;
}
.term.wrap { white-space: pre-wrap; word-break: break-all; }
.term .b { font-weight: 700; } .term .d { opacity: .6; } .term .i { font-style: italic; } .term .u { text-decoration: underline; }

/* ---------- bottom dock ---------- */
.dock {
  position: sticky; bottom: 0; z-index: 4; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.keys { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 1px; }
.keys::-webkit-scrollbar { display: none; }
.key {
  flex: none; min-width: 42px; height: 34px; padding: 0 10px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line);
  font: 600 13px var(--mono); color: var(--text);
}
.key:active { background: var(--surface-2); transform: translateY(1px); }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 40vh; padding: 10px 14px; border-radius: 22px; border: 1px solid var(--line);
  background: var(--surface); outline: none; line-height: 1.45;
}
.composer textarea:focus { border-color: var(--accent); }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.send:disabled { opacity: .35; }
.send svg { width: 20px; height: 20px; }

.approval {
  border: 1.5px solid var(--warn); background: var(--surface); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.approval .h { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--warn); font-weight: 650; letter-spacing: .03em; }
.approval .q { font-weight: 600; }
.approval pre { margin: 0; font: 12px/1.5 var(--mono); background: var(--surface-2); padding: 8px 10px; border-radius: 10px; max-height: 30vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.approval .opts { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { height: 40px; padding: 0 16px; border-radius: 11px; background: var(--surface-2); font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.grow { flex: 1; }
.btn:disabled { opacity: .5; }
.approval .more { font-size: 12px; color: var(--muted); }

/* ---------- sheet / forms ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 640px; margin: 0 auto; max-height: 88dvh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 12px; font-size: 17px; }
.seg { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { flex: 1; height: 34px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.field { display: flex; flex-direction: column; gap: 5px; margin: 14px 0; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.input { height: 44px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); outline: none; width: 100%; }
.input:focus { border-color: var(--accent); }
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.li { display: flex; flex-direction: column; gap: 1px; padding: 10px 14px; text-align: left; width: 100%; }
.li:active, .li.on { background: var(--accent-soft); }
.li .a { font-weight: 600; font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.li .b { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--mono); }
.li-h { padding: 6px 14px; font-size: 11.5px; color: var(--faint); font-weight: 650; letter-spacing: .05em; background: var(--surface-2); }
.row { display: flex; gap: 8px; align-items: center; }
.hint { font-size: 12.5px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }

.menu { position: fixed; z-index: 22; right: 10px; top: calc(52px + env(safe-area-inset-top)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 190px; padding: 5px; animation: fade .12s; }
.menu button { display: flex; width: 100%; padding: 10px 12px; border-radius: 9px; font-size: 14px; }
.menu button:active { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 30; background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 12px; font-size: 13.5px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); animation: rise .15s; }
.jump { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 4; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 99px; padding: 6px 14px; font-size: 13px; }
.md th { white-space: nowrap; }

/* ---------- tmux: claude code view ---------- */
main.tmain.dark { background: var(--term-bg); }
.cc { padding: 12px 14px 20px; display: flex; flex-direction: column; gap: 10px; font-size: var(--cc-size, 14.5px); }
.cc-l { white-space: pre-wrap; word-break: break-word; min-height: 1.2em; }
.cc-say { line-height: 1.6; }
.cc-say.error { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 8px 12px; font-size: .92em; }
.cc-say.error span[style] { color: inherit !important; }
.cc-user { align-self: flex-end; max-width: 88%; background: var(--user); color: var(--user-ink); border-radius: 18px 18px 4px 18px; padding: 8px 14px; white-space: pre-wrap; word-break: break-word; }
.cc-tbl { font: 12px/1.35 var(--mono); white-space: pre; overflow-x: auto; padding: 6px 0; }
.cc-raw { font: 12px/1.45 var(--mono); color: var(--muted); white-space: pre-wrap; word-break: break-all; }
.cc-res { font: 12px/1.5 var(--mono); padding: 8px 12px 10px; max-height: 320px; overflow: auto; }
.cc-res .cc-l { white-space: pre-wrap; word-break: break-all; }
.cc-peek { font: 11.5px/1.4 var(--mono); color: var(--muted); padding: 0 12px 8px 40px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-top: -4px; }
.cc-status { align-self: flex-start; font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.cc-status::before { content: "✻"; color: var(--warn); }
.cc-status.live { color: var(--accent); }
.cc-status.live::before { animation: spin 2.4s linear infinite; display: inline-block; color: var(--accent); }
.cc span[style*="color"] { filter: var(--cc-ink, none); }
.tbar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tbar .chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tbar .chips::-webkit-scrollbar { display: none; }
.tbar .chip { white-space: nowrap; }
.chip.input { background: var(--accent-soft); color: var(--accent); max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.seg.mini { flex: none; padding: 2px; border-radius: 9px; }
.seg.mini button { height: 26px; padding: 0 12px; font-size: 12.5px; border-radius: 7px; }
.chip.input { display: inline-block; white-space: nowrap; align-self: center; line-height: 1.7; }
.cc .b { font-weight: 700; } .cc .d { opacity: .65; } .cc .i { font-style: italic; } .cc .u { text-decoration: underline; }

.tbar .chips { align-items: center; }
.tbar .chip { height: 24px; line-height: 24px; padding: 0 9px; }
.fitbtn { flex: none; height: 26px; padding: 0 10px; border: 1px solid var(--line); background: transparent; }
.fitbtn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.live { background: var(--accent-soft); color: var(--accent); }
.chip.live::before { content: "✻ "; display: inline-block; animation: spin 2.4s linear infinite; }
.notice.error, .notice.warn { border-radius: 12px; text-align: left; align-self: stretch; max-width: 100%; padding: 8px 12px; word-break: break-word; }

/* ---------- wide screens: sidebar + pane ---------- */
#app.wide { --side-w: clamp(280px, 27vw, 360px); max-width: none; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: var(--app-h, 100dvh); }
.side, .pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.side { border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface-2) 45%, var(--bg)); }
.side .bar { background: transparent; }
.side .pad { padding: 4px 12px 16px; }
.side .widgets { grid-template-columns: 1fr 1fr; gap: 8px; }
.side .widget { padding: 10px 12px; min-height: 64px; }
.side .widget.metric .v { font-size: 22px; }
.side .widget .v { font-size: 11.5px; }
.side .srow { padding: 10px 12px; }
.srow.on { border-color: var(--accent); background: var(--accent-soft); }
@media (hover: hover) {
  .srow:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
  .icon-btn:hover, .key:hover, .li:hover { background: var(--surface-2); }
  .btn:hover { filter: brightness(1.06); }
  .tool > summary:hover { background: var(--surface-2); }
}
.wide .pane [data-act="back"] { display: none; }
.wide .pane .bar h1 { margin-left: 12px; }
.wide .pane .timeline, .wide .pane .cc, .wide .pane .pad { max-width: 880px; width: 100%; margin-inline: auto; }
.wide .pane .dock > * { max-width: 880px; width: 100%; margin-inline: auto; }
.wide .jump { left: calc(var(--side-w) + (100vw - var(--side-w)) / 2); }

.pane-empty { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; }
.pane-empty .logo { width: 48px; height: 48px; opacity: .9; }
.pane-empty h2 { margin: 6px 0 0; color: var(--text); font-size: 19px; }
.pane-empty p { margin: 0 0 8px; }
.pane-empty .btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; }
.pane-empty .btn svg { width: 18px; height: 18px; }
.keys-help { display: grid; grid-template-columns: auto auto; gap: 6px 16px; margin: 4px 0 0; font-size: 13px; text-align: left; }
.keys-help dt { font: 600 12px var(--mono); color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; justify-self: end; }
.keys-help dd { margin: 0; }
@media (min-width: 900px) {
  .sheet { top: 0; bottom: 0; margin: auto; height: fit-content; width: min(600px, calc(100vw - 48px)); max-height: 84dvh; border-radius: 20px; padding-bottom: 20px; box-shadow: var(--shadow); }
  .sheet .grab { display: none; }
  .sheet h3 { margin-top: 10px; }
  .menu { top: 58px; }
}
@media (min-width: 900px) { .sheet [data-src] { max-height: 30dvh !important; } }

/* ---------- touch tablets ---------- */
@media (pointer: coarse) {
  .key { height: 38px; min-width: 46px; }
  .srow { padding-block: 13px; }
  .term-wrap { touch-action: pan-x pan-y; }
}
@media (pointer: coarse) and (min-width: 700px) {
  .cc, .timeline { font-size: 15.5px; }
  .md pre, .tool pre { font-size: 13px; }
}
.side { padding-left: env(safe-area-inset-left); }
.pane { padding-right: env(safe-area-inset-right); }
.term-wrap { display: flex; flex-direction: column; } .term-wrap .term { flex: 1; }

.sessions .empty + .list { margin-top: 10px; }

/* assistant replies get a bubble too, mirroring the user's */
.msg.assistant { align-items: flex-start; }
.msg.assistant > .md, .cc-say:not(.error) {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px 18px 18px 4px;
  padding: 9px 14px; max-width: 92%; min-width: 0;
}
.cc-say:not(.error) { align-self: flex-start; }
.msg.assistant > .tool, .msg.assistant > .thinking { align-self: stretch; }
.msg.assistant > .md + .md { margin-top: -2px; }

/* ---------- images ---------- */
.imgs { display: flex; gap: 8px; flex-wrap: wrap; }
.imgs img { max-width: min(260px, 72%); max-height: 260px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: zoom-in; min-width: 48px; min-height: 48px; object-fit: contain; }
.imgs img.broken { cursor: default; font-size: 12px; color: var(--muted); padding: 8px; }
.msg.user .imgs { margin-top: 6px; }
.msg.user .imgs img { max-width: 200px; max-height: 200px; border-color: transparent; }
.msg.assistant > .imgs { margin-top: -4px; padding-left: 4px; }
.viewer { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .88); display: grid; place-items: center; cursor: zoom-out; animation: fade .12s; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.viewer img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 6px; }
.msg.assistant.live > .md { border-style: dashed; }
.msg.assistant.live .cc-l { white-space: pre-wrap; }
