:root {
  --bg: #08080c;
  --bg-2: #14141b;
  --surface: #1c1c22;
  --surface-hi: #24242d;
  --line: #2c2c36;
  --ink: #f0f0f6;
  --ink-dim: #a6a6b2;
  --ink-faint: #7c7c88;   /* lifted from #6a6a76 — small labels now clear 4:1 */
  --accent: #8aa6ff;
  --accent-deep: #6b86f0;
  --accent-rgb: 138,166,255;   /* matches --accent — use for every accent glow/tint */
  --warn: #f87171;
  --ok: #34d399;
  --add: #9ece6a;
  --del: #f7768e;
  /* radius scale — every component pulls from these */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 22px;
  /* elevation — inset highlight + dark drop, one recipe per role */
  --sh-1: 0 1px 0 rgba(255,255,255,.06) inset, 0 1px 2px rgba(0,0,0,.45);    /* raised control */
  --sh-2: 0 1px 0 rgba(255,255,255,.04) inset, 0 2px 14px rgba(0,0,0,.45);   /* chrome bar */
  --sh-dock: 0 -1px 0 rgba(255,255,255,.04) inset, 0 -4px 18px rgba(0,0,0,.4); /* upward dock */
  --sh-pressed: 0 1px 2px rgba(0,0,0,.5) inset;                             /* pressed / active */
  --sh-modal: 0 24px 60px rgba(0,0,0,.5);                                   /* overlay lift */
  --glow: 0 2px 10px rgba(var(--accent-rgb),.4);                            /* accent control */
  --glow-lg: 0 4px 14px rgba(var(--accent-rgb),.5);                         /* prominent accent (FAB) */
  /* motion */
  --t-fast: .15s;
  --t-slow: .3s;
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);   /* slight overshoot for presses */
  /* apple-glass — frosted translucent surface for cards */
  --glass-bg: rgba(26,26,36,.62);
  --glass-blur: saturate(180%) blur(22px);
  --glass-line: rgba(255,255,255,.12);
  --glass-hi: 0 1px 0 rgba(255,255,255,.13) inset;
  --glass-accent: rgba(138,166,255,.20);   /* accent-tinted glass — keeps "you" identity */
  --glass-tint: rgba(255,255,255,.06);     /* control fill on a glass/dark panel — NO own blur */
  --glass-inset: rgba(0,0,0,.28);          /* recessed code/diff area inside a card */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --kbd: 0px;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; height: 100dvh;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  overflow: hidden; overscroll-behavior: none;
  touch-action: pan-y;
}
body {
  display: flex; flex-direction: column; height: var(--app-h, 100dvh);
  /* ambient light under the glass — without it backdrop-blur has nothing to
     frost and every panel reads as flat gray */
  background:
    radial-gradient(1100px 700px at 85% -10%, rgba(var(--accent-rgb),.20), transparent 60%),
    radial-gradient(900px 600px at -15% 30%, rgba(158,120,255,.13), transparent 55%),
    radial-gradient(1000px 800px at 50% 115%, rgba(64,90,200,.16), transparent 60%),
    var(--bg);
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button svg { display: block; pointer-events: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
.hidden { display: none !important; }

/* ── top bar: floating glass island ── */
.bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  margin: calc(var(--safe-top) + 8px) 10px 4px;
  padding: 8px 12px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: .5px solid var(--glass-line);
  border-radius: var(--r-pill);
  box-shadow: var(--glass-hi), var(--sh-2);
}
.bar .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink-faint); flex: none;
  transition: background var(--t-slow), box-shadow var(--t-slow);
}
.bar .dot.connected { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.15), 0 0 10px rgba(52,211,153,.7); }
.bar .dot.connecting { background: #f5c451; box-shadow: 0 0 0 3px rgba(245,196,81,.15), 0 0 10px rgba(245,196,81,.6); animation: pulseDot 1.4s ease-in-out infinite; }
.bar .dot.disconnected { background: var(--warn); box-shadow: 0 0 0 3px rgba(248,113,113,.15); }
@keyframes pulseDot { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.bar .name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.bar .sub { font-size: 11px; color: var(--ink-dim); margin-right: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 48vw; }
.ico {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: .5px solid var(--glass-line);
  background: var(--glass-tint);
  display: grid; place-items: center; font-size: 15px; color: var(--ink-dim);
  box-shadow: var(--glass-hi);
  transition: transform var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.ico svg { width: 16px; height: 16px; }
.ico:active { background: var(--bg-2); color: var(--ink); transform: scale(.92); box-shadow: var(--sh-pressed); }

/* raw-terminal view: the top bar stops being a solid strip — the terminal runs
   all the way up and the dot + buttons float over it */
body.termview .bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 7;
  margin: calc(var(--safe-top) + 6px) 10px 0; padding: 0;
  background: transparent; border: none; box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  pointer-events: none;
}
body.termview .bar .name, body.termview .bar .sub { display: none; }
body.termview .bar .ico { pointer-events: auto; background: rgba(10,10,16,.72); }
body.termview .bar .dot { margin-right: auto; }

/* ── stage (holds the conversation + floating jump button) ── */
.stage { flex: 1; min-height: 0; display: flex; position: relative; }

/* Live raw-terminal view (xterm), fills the stage; toggled against .chat. */
.term { position: absolute; inset: 0; padding: 6px 8px; background: #08080c; }
/* full-bleed: background reaches the very top; text clears only the status
   bar — the translucent buttons float over the content itself. The composer
   dock below already clears the home indicator, so only a slim bottom pad. */
body.termview .term { padding-top: calc(var(--safe-top) + 46px); padding-bottom: 4px; }
body.kb .term { padding-bottom: 4px; }
.term .xterm { height: 100%; }
/* JS owns touch here (swipe → wheel in Claude's TUI, or term scrollback at a
   shell). Disable the browser's native touch panning — with touch-action:pan-y
   the browser claims the vertical gesture and our touchmove can't cancel it, so
   the swipe never reaches our handler. Keep overflow for xterm's own scroll. */
.term .xterm, .term .xterm-viewport, .term .xterm-screen { touch-action: none; }
.term .xterm-viewport {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.ico.active { color: var(--accent); background: rgba(var(--accent-rgb), .14); }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── live terminal console, in a glass card ── */
.thinking {
  display: flex; flex-direction: column; align-items: flex-start;
  align-self: flex-start; max-width: 92%; user-select: none;
  animation: fade .2s ease-out;
}
.thinking .who {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 6px 3px;
}
.think-card {
  width: min(340px, 88vw); overflow: hidden;
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: .5px solid var(--glass-line);
  border-radius: var(--r-lg); border-bottom-left-radius: 6px;
  box-shadow: var(--glass-hi), var(--sh-2), 0 0 0 1px rgba(var(--accent-rgb),.07);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.think-card:active { transform: scale(.985); box-shadow: var(--glass-hi), var(--sh-pressed); }
/* "live ↗" affordance in the card's title bar */
.term-open {
  margin-left: auto; display: flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: rgba(var(--accent-rgb),.85);
}
.term-open svg { width: 11px; height: 11px; }
/* terminal title bar */
.term-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px; border-bottom: .5px solid var(--glass-line);
  background: rgba(255,255,255,.03);
}
.term-dots { display: flex; gap: 5px; flex: none; }
.term-dots i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.term-dots i:nth-child(1) { background: var(--del); }
.term-dots i:nth-child(2) { background: #e0af68; }
.term-dots i:nth-child(3) { background: var(--add); }
.term-title { font-size: 11px; color: var(--ink-faint); letter-spacing: .03em; }
.term-body { display: flex; flex-direction: column; min-height: 0; }
/* the live console — every tool/line streams in here */
.term-log {
  max-height: 210px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 9px 13px; display: flex; flex-direction: column; gap: 2px;
  font-size: 11.5px; line-height: 1.5; color: var(--ink-dim);
}
.term-log::-webkit-scrollbar { width: 5px; }
.term-log::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb),.3); border-radius: 3px; }
.tlog { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.tlog.tool { color: var(--ink); }
.term-log:empty::after { content: "no activity yet"; color: var(--ink-faint); }
/* idle state — persistent card resting between turns */
.think-card.idle .term-foot .spin { text-shadow: none; color: var(--ink-faint); }
.think-card.idle .term-label {
  animation: none; background: none;
  -webkit-text-fill-color: currentColor; color: var(--ink-faint);
}
.think-card.idle .term-cursor { opacity: .35; animation: none; box-shadow: none; }
/* status footer */
.term-foot {
  display: flex; align-items: center; gap: 9px; flex: none;
  padding: 8px 13px; border-top: .5px solid var(--glass-line);
  font-size: 12px; color: var(--ink-dim);
}
.term-foot .spin {
  color: var(--accent); width: 1ch; text-align: center; flex: none;
  text-shadow: 0 0 9px rgba(var(--accent-rgb),.75);
}
.term-label {
  background: linear-gradient(90deg, var(--ink-faint) 30%, var(--ink) 50%, var(--ink-faint) 70%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: shimmer 1.8s linear infinite;
}
.term-cursor {
  width: 8px; height: 15px; flex: none; background: var(--accent); margin-left: auto;
  box-shadow: 0 0 9px rgba(var(--accent-rgb),.75);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── conversation feed ── */
.chat {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: transparent; /* let the body's ambient glow show through the glass */
  padding: 16px 13px 18px;
  max-width: 820px; margin: 0 auto;   /* readable column on tablets/desktop */
  display: flex; flex-direction: column; gap: 12px;
  -webkit-user-select: text; user-select: text;
  touch-action: pan-y;
}
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb),.3); border-radius: 3px; }
.chat-empty { margin: auto; color: var(--ink-faint); font-size: 14px; text-align: center; }
/* while the transcript loads, show ghost bubbles instead of a bare word */
.chat-empty.loading { width: 100%; margin: 0; padding-top: 8px; color: transparent; user-select: none; position: relative; }
.chat-empty.loading::before, .chat-empty.loading::after {
  content: ""; display: block; height: 58px; border-radius: var(--r-lg);
  background: linear-gradient(100deg, rgba(255,255,255,.05) 40%, rgba(255,255,255,.10) 50%, rgba(255,255,255,.05) 60%);
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
}
.chat-empty.loading::before { width: 72%; margin-bottom: 14px; border-bottom-left-radius: 7px; }
.chat-empty.loading::after { width: 58%; margin-left: auto; border-bottom-right-radius: 7px; }

.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.live { animation: fade .2s ease-out; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; align-items: flex-start; }
/* group runs of the same sender: label the first message only, pull the rest closer */
.msg.me + .msg.me .who, .msg.bot + .msg.bot .who, .msg.tool + .msg.bot .who { display: none; }
.msg.me + .msg.me, .msg.bot + .msg.bot { margin-top: -4px; }
.msg .who {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 6px 3px;
}
.msg .bubble {
  border-radius: var(--r-lg); padding: 10px 14px; font-size: 16px; line-height: 1.5;
  word-break: break-word; overflow-wrap: anywhere;
  border: .5px solid var(--line);
}
.msg.me .bubble {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),.34), rgba(107,134,240,.20));
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  color: var(--ink); border-color: rgba(var(--accent-rgb),.30); border-bottom-right-radius: 7px;
  white-space: pre-wrap;
  box-shadow: var(--glass-hi), 0 6px 20px rgba(var(--accent-rgb),.22);
}
/* Buffered while the socket is down — message is queued, not lost. Dim it and
   tag it "sending…" so it reads as in-flight until the reconnect delivers it. */
.msg.me.pending .bubble { opacity: .55; }
.msg.me.pending .who::after { content: " · sending…"; font-weight: 600; opacity: .8; }

.msg.bot .bubble {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  color: var(--ink); border-color: rgba(255,255,255,.08); border-bottom-left-radius: 7px;
  box-shadow: var(--glass-hi), 0 6px 18px rgba(0,0,0,.35);
}
.msg.bot .bubble:empty::after { content: "…"; color: var(--ink-faint); }

/* markdown inside an assistant bubble */
.bubble strong { font-weight: 700; }
.bubble a { color: var(--accent); text-decoration: underline; }
.bubble code.inline {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace; font-size: .88em;
  background: var(--glass-tint); border: .5px solid var(--glass-line);
  border-radius: 6px; padding: 1px 5px;
}
.bubble pre.code {
  margin: 8px 0 4px; padding: 10px 12px;
  background: var(--glass-inset); border: .5px solid var(--glass-line); border-radius: var(--r-md);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  max-height: 300px; overflow-y: auto; /* long dumps scroll inside, don't own the feed */
}
.bubble pre.code::-webkit-scrollbar { height: 5px; width: 5px; }
.bubble pre.code::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb),.3); border-radius: 3px; }
.bubble pre.code code {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  font-size: 12.5px; line-height: 1.5; white-space: pre; color: #cdd6f4;
}

/* ── tool-call rows (console-style) ── */
.msg.tool { max-width: 100%; align-self: stretch; align-items: stretch; gap: 0; }
/* consecutive tool rows fuse into one quiet activity rail */
.msg.tool + .msg.tool { margin-top: -8px; }
.tool-line {
  display: flex; align-items: baseline; gap: 7px;
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  font-size: 11px; line-height: 1.45; color: var(--ink-faint);
  padding: 3px 12px; word-break: break-word; overflow-wrap: anywhere;
  border-left: 2px solid rgba(var(--accent-rgb),.28);
}
.tool-line .tool-ico { color: rgba(var(--accent-rgb),.75); flex: none; }
/* compact diff block under a file-editing tool row */
.diff {
  margin: 2px 0 4px 12px; border: .5px solid var(--glass-line); border-radius: var(--r-sm);
  overflow: hidden; background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
}
.diff-file {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  font-size: 11px; color: var(--ink-dim); padding: 5px 10px;
  border-bottom: .5px solid var(--glass-line); background: var(--glass-tint);
  word-break: break-all;
}
.diff-body {
  margin: 0; padding: 6px 0; max-height: 260px; overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace; font-size: 11.5px; line-height: 1.45;
}
.diff-body::-webkit-scrollbar { width: 5px; height: 5px; }
.diff-body::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb),.3); border-radius: 3px; }
.diff-line { padding: 0 10px; white-space: pre; }
.diff-line.add { color: var(--add); background: rgba(158,206,106,.08); }
.diff-line.del { color: var(--del); background: rgba(247,118,142,.08); }

/* "load earlier messages" pager */
.load-older {
  align-self: center; margin: 2px auto 6px; padding: 7px 16px;
  border-radius: var(--r-pill); border: .5px solid var(--glass-line);
  background: var(--glass-bg); color: var(--ink); font-size: 12.5px; font-weight: 600;
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-hi);
}
.load-older:active { background: var(--accent); color: #07080f; }
.load-older:disabled { opacity: .55; }

/* terminal-only keys (⌨ / A− / A+) live inside the keybar scroller and only
   appear in termmode — they used to float over the TUI's input line */
.keys .termkey { display: none; }
.dock.termmode .keys .termkey { display: grid; place-items: center; }
.keys .termkey svg { width: 15px; height: 15px; }

/* ── floating jump-to-latest ── */
.jump {
  position: absolute; right: 14px; bottom: 14px; z-index: 6;
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #07080f; border: .5px solid transparent;
  font-size: 22px; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, var(--glow-lg);
  transition: transform var(--t-fast), opacity var(--t-fast);
}
.jump svg { width: 22px; height: 22px; }
.jump:active { transform: scale(.92); }

/* ── dock: transparent stage for the floating composer capsule ── */
.dock {
  flex: none; position: relative; z-index: 5;
  background: linear-gradient(180deg, transparent, rgba(8,8,12,.72) 55%);
}
/* slim grab-handle: one tap hides/shows everything below it (keys + composer) */
.dock-handle {
  display: block; width: 100%; height: 22px; padding: 0;
  background: transparent; border: none; color: var(--ink-faint);
  transition: color var(--t-fast);
}
.dock-handle:active { color: var(--accent); }
.dock-handle svg { width: 16px; height: 16px; margin: 0 auto; transition: transform var(--t-slow); }
.dock.collapsed .dock-handle svg { transform: rotate(180deg); }
/* collapse hides ONLY the keybar — the chat box must stay visible at all
   times on the conversation page (user got stranded twice when it hid) */
.dock.collapsed .keys { display: none; }

/* raw-terminal mode: the chat box stays PRESENT AT ALL TIMES (Richard,
   2026-07-07 — it kept "hiding" under the old pure-raw spec). Only the
   keybar and chevron handle go; the composer capsule stays, compacted. */
.dock.termmode .dock-handle,
.dock.termmode .keys { display: none; }
.dock.termmode { padding-bottom: 0; }
.dock.termmode .row { margin: 4px 10px calc(6px + var(--safe-bottom)); }
.dock.termmode .row textarea { min-height: 36px; }
/* the persisted chat-view collapse (ct3.dock='min') must never take the
   composer with it here — there's no handle in termmode to bring it back.
   (.pill excluded: the top-bar toggle legitimately hides it on both pages) */
.dock.termmode.collapsed:not(.pill) .row { display: flex; }

/* composer hide (imp30/31): the #rowToggle chat-bubble icon in the TOP-RIGHT
   bar completely hides/shows the chat box — on BOTH the chat and raw pages
   (one persisted state). The bar button is always reachable, so the "never
   stranded" law holds without a pill remnant. */
.dock.pill .dock-handle,
.dock.pill .keys,
.dock.pill .row { display: none; }
/* keyboard open (body.kb from trackKeyboard): it covers the home-indicator
   zone, so safe-bottom padding just leaves a dead gap — sit flush instead */
body.kb .dock.termmode .keys { padding-bottom: 4px; }
body.kb .row { margin-bottom: 8px; }
body.kb .dock.collapsed { padding-bottom: 0; }
.dock.termmode .keys button {
  height: 24px; min-width: 36px; padding: 0 8px;
  font-size: 11px; border-radius: 8px; box-shadow: none;
}

.keys {
  display: flex; gap: 7px; padding: 9px 10px 1px;
  overflow-x: auto; white-space: nowrap;
  scrollbar-width: none; touch-action: pan-x;
}
.keys::-webkit-scrollbar { display: none; }
.keys button {
  flex: none; min-width: 44px; height: 34px; padding: 0 12px;
  background: var(--glass-tint);
  border: .5px solid var(--glass-line); border-radius: var(--r-pill);
  color: var(--ink); font-size: 13px; font-weight: 600;
  box-shadow: var(--glass-hi);
  transition: transform var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.keys button:active {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep)); color: #07080f;
  transform: translateY(1px);
  box-shadow: var(--sh-pressed);
}
/* unified capsule: attach + input + send live in one floating glass pill */
.row {
  display: flex; align-items: flex-end; gap: 2px;
  margin: 6px 10px calc(8px + var(--safe-bottom)); padding: 4px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: .5px solid var(--glass-line); border-radius: 27px;
  box-shadow: var(--glass-hi), var(--sh-2);
  transition: border-color var(--t-fast);
}
.row:focus-within { border-color: rgba(var(--accent-rgb),.55); }
.row textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 120px;
  background: transparent; color: var(--ink);
  border: none; border-radius: var(--r-pill);
  padding: 12px 8px; font-size: 16px; line-height: 1.35; outline: none;
  -webkit-user-select: text; user-select: text;
}
.row textarea::placeholder { color: var(--ink-faint); }
.circle {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: transparent; color: var(--ink-dim);
  display: grid; place-items: center; font-size: 18px;
  transition: transform var(--t-fast) var(--ease-spring), background var(--t-fast), color var(--t-fast);
}
.circle svg { width: 20px; height: 20px; }
.circle:active { transform: scale(.9); background: var(--glass-tint); color: var(--ink); }
.send {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #07080f;
  box-shadow: var(--glow);
}
.send:active { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #07080f; }
.send:disabled { opacity: .4; box-shadow: none; }

/* ── image attachments ── */
.attach {
  display: flex; gap: 8px; padding: 8px 10px 0; overflow-x: auto;
  scrollbar-width: none; touch-action: pan-x;
}
.attach::-webkit-scrollbar { display: none; }
.attach .chip {
  position: relative; flex: none; width: 56px; height: 56px;
  border-radius: var(--r-sm); overflow: hidden;
  border: .5px solid var(--glass-line); background: var(--glass-tint);
  display: grid; place-items: center;
}
.attach .chip img { width: 100%; height: 100%; object-fit: cover; }
.attach .chip.busy { opacity: .6; }
.attach .chip.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.attach .chip.err { border-color: var(--warn); }
.attach .chip-err {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 2px;
  font-size: 9px; line-height: 1.1; text-align: center; color: var(--warn); background: rgba(0,0,0,.5);
}
.attach .chip-x {
  position: absolute; top: 1px; right: 1px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 1;
  display: grid; place-items: center;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* thumbnails inside a sent bubble */
.bubble-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.bubble-imgs:last-child { margin-bottom: 0; }
.bubble-imgs img {
  width: 130px; max-width: 100%; border-radius: var(--r-sm);
  border: .5px solid var(--glass-line); display: block;
}

/* ── login modal ── */
.modal { position: fixed; inset: 0; z-index: 20; display: none; place-items: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(8px); padding: 20px; }
.modal.show { display: grid; }
.card {
  width: 100%; max-width: 380px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: .5px solid var(--glass-line); border-radius: var(--r-lg);
  padding: 24px 22px; box-shadow: var(--glass-hi), var(--sh-modal);
}
.card h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.card .sub { display: block; margin: 0 0 18px; color: var(--ink-dim); font-size: 13.5px; }
.card label { display: block; margin-bottom: 12px; }
.card label span { display: block; font-size: 12px; color: var(--ink-dim); margin: 0 0 5px 4px; font-weight: 600; }
.card label input {
  width: 100%; background: var(--glass-tint); color: var(--ink);
  border: .5px solid var(--glass-line); border-radius: var(--r-md);
  padding: 13px 14px; font-size: 16px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.card label input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.18); }
.card .err { color: var(--warn); font-size: 13px; min-height: 18px; margin: 2px 2px 10px; }
.card .primary {
  width: 100%; background: var(--accent); color: #07080f;
  border: 0; border-radius: var(--r-md); padding: 14px; font-size: 16px; font-weight: 700;
  box-shadow: var(--glow);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.card .primary:active { transform: scale(.98); box-shadow: var(--sh-pressed); }
.card .primary:disabled { opacity: .55; box-shadow: none; }

/* ────────── files page ────────── */
/* Panel gets the glass treatment (head + viewer blur); rows are tinted
   controls per the two-tier scheme — no nested blurs, keeps scroll smooth. */
.files { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.files-head {
  display: flex; align-items: center; gap: 6px;
  margin: 8px 10px 6px; padding: 6px 8px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line); border-radius: var(--r-pill);
  box-shadow: var(--sh-2), var(--glass-hi);
}
.files-head .ico[disabled] { opacity: .35; pointer-events: none; }
.files-path {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.files-list {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 10px calc(12px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 5px;
}
.files-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; margin: 0;
  background: var(--glass-tint); color: var(--ink);
  border: 1px solid var(--glass-line); border-radius: var(--r-md);
  font: inherit; text-align: left; width: 100%;
  transition: transform var(--t-fast) var(--ease-spring), background var(--t-fast);
}
.files-row:active { transform: scale(.985); background: rgba(255,255,255,.10); }
.files-row.dim { opacity: .55; }
.files-ico { flex: 0 0 auto; display: grid; place-items: center; width: 22px; color: var(--ink-faint); }
.files-ico.dir { color: var(--accent); }
.files-ico svg { width: 18px; height: 18px; }
.files-name { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files-meta { flex: 0 0 auto; font-size: 11px; color: var(--ink-faint); }
.files-msg { margin: 14px auto; font-size: 12.5px; color: var(--ink-faint); text-align: center; max-width: 82%; }
.files-msg.error { color: var(--warn); }
.files-load-more {
  align-self: center; margin: 10px 0 4px; padding: 10px 16px;
  border: 1px solid var(--glass-line); border-radius: var(--r-pill);
  background: var(--glass-tint); color: var(--accent); font: inherit; font-size: 13px; font-weight: 700;
}
.files-load-more:disabled { opacity: .55; }
/* full-page file viewer over the list */
.files-view {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  background: rgba(8,8,12,.9);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.files-view-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--glass-line);
}
.files-view-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files-notice { min-height: 18px; margin: 6px 12px 0; color: var(--ink-faint); font-size: 12px; }
.files-view-body {
  flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(14px + var(--safe-bottom));
}
.files-pre {
  margin: 0; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word; color: var(--ink);
}
.files-img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: var(--r-md); }
/* the files page has no composer — the dock belongs to chat/terminal */
body.filesview .dock { display: none; }
body.filesview .jump { display: none !important; }
