/* Claude Bot — calm, plain, fast. Warm off-white / near-black, one clay accent. */

:root {
  color-scheme: light dark;
  --bg: #F8F6F1;
  --bg-side: #F1EEE7;
  --surface: #FFFFFF;
  --surface-2: #F3F0E9;
  --line: #E6E1D7;
  --line-strong: #D5CFC2;
  --text: #22201C;
  --muted: #6B665C;
  --faint: #8D877B;
  --accent: #D97757;
  --accent-strong: #B04E2B;
  --accent-ink: #2B160C;
  --accent-soft: #F7E6DC;
  --user-bg: #F1DFD3;
  --user-ink: #2A1B14;
  --info: #5B8DB8;
  --danger: #B3402F;
  --danger-soft: #FBEAE6;
  --wait: #D9A21B;
  --wait-ink: #8A5A00;
  --warn-bg: #FFF0B8;
  --warn-ink: #47350A;
  --warn-line: #E6C24E;
  --screen-bg: #12110F;
  --shadow: 0 1px 2px rgb(50 35 20 / .06), 0 6px 18px rgb(50 35 20 / .08);
  --shadow-lg: 0 24px 64px rgb(40 25 10 / .28), 0 2px 8px rgb(40 25 10 / .12);
  --side-w: 296px;
  --screen-w: 448px;
  --tab-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --bg-side: #1B1A17;
    --surface: #211F1C;
    --surface-2: #2A2723;
    --line: #322F2A;
    --line-strong: #453F38;
    --text: #ECE8E0;
    --muted: #A8A196;
    --faint: #857F74;
    --accent-strong: #EE9873;
    --accent-soft: #3A2A22;
    --user-bg: #402D22;
    --user-ink: #F6E8DD;
    --info: #7FAAD0;
    --danger: #EA7A66;
    --danger-soft: #3A2320;
    --wait: #E6B031;
    --wait-ink: #F0C453;
    --warn-bg: #4A3D11;
    --warn-ink: #FBE9A6;
    --warn-line: #7C6821;
    --screen-bg: #0C0B0A;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 18px rgb(0 0 0 / .3);
    --shadow-lg: 0 24px 64px rgb(0 0 0 / .6), 0 2px 8px rgb(0 0 0 / .4);
  }
}

/* press-edges: tokens for the lit edges and the pressed look (clay beads, dark edge lights, the dip and its spring back) */
:root {
  --clay-top: color-mix(in srgb, var(--accent), white 24%);                  /* lit top edge of a clay button */
  --clay-bottom: color-mix(in srgb, var(--accent), var(--accent-ink) 24%);   /* shaded bottom edge */
  --clay-drop: 0 1px 2px rgb(50 35 20 / .14);
  --press-in: inset 0 1px 2px rgb(43 22 12 / .28);   /* pressed: the lit edge gives way to a small inner shadow */
  --press-dim: brightness(.95);
  --press-dim-img: brightness(.86);                  /* pictures need a firmer dim than a flat button to show at all */
  --press-tint: color-mix(in srgb, var(--text) 5.5%, transparent);       /* the tint rows only had on mouse hover */
  --press-ring: color-mix(in srgb, var(--text) 5.5%, var(--bg-side));    /* the same tint, solid, for the status dot's ring */
  --spring: cubic-bezier(.3, 1.5, .5, 1);            /* release: a hair of overshoot */
  --press-t: transform .18s var(--spring), background-color .18s ease-out, border-color .12s, filter .14s, box-shadow .14s, opacity .12s;
}
@media (prefers-color-scheme: dark) {
  :root {
    --edge-top: color-mix(in srgb, var(--line-strong) 88%, white);       /* lit top edge of a bordered dark surface */
    --edge-ring: color-mix(in srgb, var(--line) 88%, white);             /* the same for the selected row's ring */
    --edge-hi: rgb(255 255 255 / .08);                                   /* top lip on a dark surface that has no border */
    --clay-drop: 0 1px 2px rgb(0 0 0 / .35);
    --press-in: inset 0 1px 2px rgb(0 0 0 / .35);
    --press-dim: brightness(.9);
    --press-tint: color-mix(in srgb, var(--text) 7%, transparent);
    --press-ring: color-mix(in srgb, var(--text) 7%, var(--bg-side));
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
a { color: var(--accent-strong); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- small parts ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); }

.wordmark { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
/* The favicon's art; ui-common.js liveMarks() puts the same art on top, with live eyes. */
.wordmark .mark { width: 24px; height: 24px; border-radius: 7px; background: url(/app/favicon.svg) center / cover no-repeat; flex: none; overflow: hidden; }
.wordmark-lg { font-size: 22px; }
.wordmark-lg .mark { width: 32px; height: 32px; border-radius: 9px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; min-height: 38px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-weight: 550; white-space: nowrap; text-decoration: none; line-height: 1.2;
  transition: background .12s, border-color .12s, filter .12s;
}
@media (hover: hover) { .btn:hover { background: var(--surface-2); } }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 5px 11px; min-height: 32px; font-size: 13px; border-radius: 9px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (hover: hover) { .btn-primary:hover { background: var(--accent); filter: brightness(1.06); } }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (hover: hover) { .btn-danger:hover { background: var(--danger); filter: brightness(1.08); } }
.btn-danger-text { color: var(--danger); }
.btn-stop { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line-strong)); }
.btn-block { width: 100%; }
/* press-edges: filled buttons are slightly domed beads (lit top, shaded bottom) and every button dips under the thumb.
   filter, not background, so every button colour (clay, red, the hand-off card's) dims the same way. */
.btn { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.btn-primary { border-color: var(--clay-top) var(--accent) var(--clay-bottom); box-shadow: var(--clay-drop); }
.btn-danger { border-color: color-mix(in srgb, var(--danger), white 24%) var(--danger) color-mix(in srgb, var(--danger), var(--accent-ink) 24%); box-shadow: var(--clay-drop); }
/* Dark only: a light edge on neutral raised surfaces. :where() keeps the app's own button variants in charge (hand-off card, Start, Stop). */
@media (prefers-color-scheme: dark) { .btn:where(:not(.btn-primary, .btn-danger, .btn-quiet, .btn-ghost, .btn-stop)) { border-top-color: var(--edge-top); } }
.btn:active:not(:disabled) { transform: scale(.97); filter: var(--press-dim); box-shadow: var(--press-in); transition-duration: .06s; }
.btn-primary:active:not(:disabled), .btn-danger:active:not(:disabled) { border-color: transparent; }   /* the fill shows through: no lit edge while held */
.btn-quiet:active:not(:disabled), .btn-ghost:active:not(:disabled) { background: var(--press-tint); box-shadow: none; filter: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
@media (hover: hover) { .icon-btn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); } }
.icon-btn[aria-pressed="true"], .icon-btn.is-on { color: var(--accent-strong); }
/* press-edges: pressed */
.icon-btn { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.icon-btn:active { transform: scale(.92); background-color: color-mix(in srgb, var(--text) 9%, transparent); transition-duration: .06s; }
.link-btn { border: 0; background: none; padding: 2px 0; color: var(--accent-strong); font-size: 13px; font-weight: 550; text-align: left; }
/* press-edges: text-only buttons have no surface to press, so they dim under the finger */
.link-btn { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.link-btn:active { opacity: .55; transition-duration: .06s; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1; }
.field-label { font-size: 12.5px; font-weight: 550; color: var(--muted); }
input[type="text"], input[type="password"], textarea, select {
  width: 100%; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); min-height: 40px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 0; border-color: var(--accent); }
.form-error { color: var(--danger); font-size: 13px; }

.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 460px); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: auto; }
.toast.in { opacity: 1; transform: none; }
.toast-error { background: var(--danger); color: #fff; }

.offline { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 28px; z-index: 90; display: flex; align-items: center; justify-content: center; background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--warn-line); font-size: 13px; font-weight: 600; }
#app.is-offline { padding-top: 28px; }

/* avatars (faces drawn by avatars.js, live eyes from eyes.js) + status dots */
.avatar { display: inline-flex; flex: none; line-height: 0; user-select: none; }
.avatar .av, .wordmark .mark .av { width: 100%; height: 100%; }
.av { display: block; --av-t: var(--av-lt); --av-i: var(--av-li); --av-s: var(--av-ls); }
@media (prefers-color-scheme: dark) { .av { --av-t: var(--av-dt); --av-i: var(--av-di); --av-s: var(--av-ds); } }
.av .av-t, .av .eyes { fill: var(--av-t); }
.av .av-i { fill: var(--av-i); }
.av .av-s { fill: var(--av-s); }
/* Working: staff rock on two sines (3 s + 7.3 s, at most 4 deg, about the hub: never a spin); Vale breathes instead. */
.av-m1, .av-m2 { transform-box: view-box; transform-origin: 12px 12.3px; }
.av-vale, .av-vale .av-m2 { transform-origin: 12px 12.2px; }
.av.is-working .av-staff { animation: av-rock 3s infinite; }
.av.is-working .av-staff > .av-m2 { animation: av-rock-slow 7.3s infinite; }
.av.is-working .av-vale { animation: av-breathe 2.4s ease-in-out infinite; }
@keyframes av-rock { 0% { transform: rotate(0deg); animation-timing-function: ease-out; } 25% { transform: rotate(2.5deg); animation-timing-function: ease-in-out; } 75% { transform: rotate(-2.5deg); animation-timing-function: ease-in; } 100% { transform: rotate(0deg); } }
@keyframes av-rock-slow { 0% { transform: rotate(0deg); animation-timing-function: ease-out; } 25% { transform: rotate(-1.5deg); animation-timing-function: ease-in-out; } 75% { transform: rotate(1.5deg); animation-timing-function: ease-in; } 100% { transform: rotate(0deg); } }
@keyframes av-breathe { 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .av .av-m1, .av .av-m2 { animation: none !important; } }
/* avatar-play: each face acts out its bot's state (ui-common.js sets the classes and data-act; avatars.js draws the two wrapper groups).
   .av-c = the standing pose (asleep); .av-a = one-off acts (hop, bob, squish). Both stand on the tile's own 24-unit grid
   (1 unit = 1/24 of the face), transforms only. .av-m1/.av-m2 stay what they are above (the working rock). Lively level (Tom, 23 Nov). */
.av { overflow: visible; /* a hop may rise a hair out of the tile */
  --ap-hop: -1.5px; --ap-bob: -0.8px; --ap-sx: 1.08; --ap-sy: 0.88; }
.av-c { transform-box: view-box; transform-origin: 12px 12.3px; } /* about the hub, like the working rock */
.av-a { transform-box: view-box; transform-origin: 12px 21.5px; } /* stands on the floor of the tile: squashes land there */
.av .eyes .eye-line { fill: none; stroke: var(--av-t); } /* the closed-eye lines eyes.js draws (asleep, the squint-smile) take the tile colour, as the eyes do */
/* Asleep after a long idle: slumped a little, breathing slowly. The pose is the plain style, so it holds with reduced motion. */
.av.is-asleep .av-c { transform: translateY(0.7px); animation: av-doze 1.2s ease-out both, av-sleep 6.4s ease-in-out 1.2s infinite; }
@keyframes av-doze { from { transform: none; } }
@keyframes av-sleep { 50% { transform: translateY(0.7px) scale(1.045); } }
/* Just finished: one hop. Crouch, up, land, settle. */
.av[data-act="hop"] .av-a { animation: av-hop 0.86s both; }
@keyframes av-hop {
  0% { transform: none; animation-timing-function: ease-out; }
  17% { transform: scale(1.07, 0.88); animation-timing-function: cubic-bezier(.2, .7, .3, 1); }
  45% { transform: translateY(var(--ap-hop)) scale(0.96, 1.06); animation-timing-function: cubic-bezier(.6, 0, .9, .5); }
  66% { transform: scale(1.06, 0.92); animation-timing-function: ease-out; }
  83% { transform: scale(0.985, 1.02); animation-timing-function: ease-in-out; }
  100% { transform: none; }
}
/* Waiting for Tom: one small hopeful bob now and then (ui-common.js backs the gap off: 2.2 s, 8, 16, 32, then about once a minute). */
.av[data-act="bob"] .av-a { animation: av-bob 0.62s both; }
@keyframes av-bob {
  0% { transform: none; animation-timing-function: ease-out; }
  24% { transform: scale(1.03, 0.95); animation-timing-function: cubic-bezier(.2, .7, .3, 1); }
  56% { transform: translateY(var(--ap-bob)) scale(0.985, 1.03); animation-timing-function: ease-in; }
  82% { transform: scale(1.015, 0.985); animation-timing-function: ease-out; }
  100% { transform: none; }
}
/* Tapped: squashes under the finger, springs back on release (the release also blinks; that is eyes.js). */
.av .av-a { transition: transform 0.36s cubic-bezier(.3, 1.9, .5, 1); }
.av.is-pressed .av-a { transform: scale(var(--ap-sx), var(--ap-sy)); transition: transform 0.08s ease-out 0.05s; } /* 50 ms late, as a bot row is: on iOS a scroll that starts on a face is cancelled before it squashes */
/* Woken (tapped, or work arrives, while asleep): one stretch. */
.av[data-act="wake"] .av-a { animation: av-wake 0.6s both; }
@keyframes av-wake {
  0% { transform: none; animation-timing-function: ease-out; }
  38% { transform: translateY(-0.5px) scale(0.95, 1.08); animation-timing-function: ease-in-out; }
  72% { transform: scale(1.02, 0.98); animation-timing-function: ease-out; }
  100% { transform: none; }
}
/* Reduced motion: no movement at all; the standing poses above (and the eyes) still tell the state. */
@media (prefers-reduced-motion: reduce) {
  .av .av-c, .av .av-a { animation: none !important; transition: none !important; }
  .av.is-pressed .av-a { transform: none; }
}
.avatar-wrap { position: relative; display: inline-block; flex: none; }
.dot { position: absolute; right: -2px; bottom: -2px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--ring, var(--bg-side)); background: var(--faint); opacity: 1; }
.dot-idle { background: color-mix(in srgb, var(--faint) 70%, var(--bg-side)); }
.dot-working { background: var(--accent); animation: pulse 1.5s ease-out infinite; }
.dot-waiting { background: var(--wait); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
.dot-inline { position: static; display: inline-block; width: 8px; height: 8px; border: 0; flex: none; animation: none; }
.head-status.st-idle .dot-inline { background: var(--faint); opacity: .6; }
.head-status.st-working .dot-inline { background: var(--accent); animation: pulse 1.5s ease-out infinite; }
.head-status.st-waiting .dot-inline { background: var(--wait); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent-strong); white-space: nowrap; flex: none; }

/* ---------- app shell ---------- */
#app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) var(--screen-w); }
#app[data-view="computer"], #app[data-view="routines"] { grid-template-columns: var(--side-w) minmax(0, 1fr); }
#app[data-view="computer"] #screen-panel, #app[data-view="routines"] #screen-panel { display: none; }
#main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); position: relative; }
/* Phones and home-screen web apps: viewport-fit=cover lets the page run under the status bar and Safari's top bar, which
   hid (browser) or faded (web app) the headers. Each pane pads itself, so its own background fills that strip. 0 on desktops. */
#app { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
#sidebar, #main, #screen-panel { padding-top: env(safe-area-inset-top, 0px); }
/* Phones: a fixed strip behind the status bar, the colour of the top of the pane that is showing. iOS 26 lays a soft fade
   ("scroll edge effect") over the page's top edge, which dimmed the status bar and the chat header; a fixed element with a
   solid background at the top edge makes Safari paint a flat colour there instead. Height 0 where there is no inset (desktops).
   The home-screen app asks for black-translucent (index.html), which keeps the status-bar text white, so there the strip is
   dark ink in light mode, where the page colour would leave the time and battery unreadable. iOS reads that tag only when
   the icon is added, so the light-mode strip assumes the icon was re-added after this shipped (notes.md, 3 Nov). */
:root { --strip-main: var(--bg); --strip-side: var(--bg-side); }
@media (display-mode: standalone) and (prefers-color-scheme: light) { :root { --strip-main: var(--text); --strip-side: var(--text); } }
.top-strip { display: none; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
#tabbar { display: none; }

/* ---------- sidebar ---------- */
#sidebar { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg-side); border-right: 1px solid var(--line); --ring: var(--bg-side); }
.brand { height: 60px; padding: 0 12px 0 16px; display: flex; align-items: center; justify-content: space-between; flex: none; }
.brand-actions { display: flex; gap: 2px; }
.side-main { padding: 2px 10px 10px; border-bottom: 1px solid var(--line); flex: none; }
.side-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.side-list.is-empty { flex: none; padding: 0; }
.side-empty { display: none; color: var(--muted); font-size: 13px; padding: 14px 20px 6px; flex: 1; }
.side-list.is-empty + .side-empty { display: block; }

.bot-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; padding: 9px 10px; border: 0; border-radius: 12px; background: transparent; text-align: left; --ring: var(--bg-side);
}
@media (hover: hover) { .bot-row:hover { background: color-mix(in srgb, var(--text) 5.5%, transparent); } }
.bot-row.is-selected { background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgb(50 35 20 / .05); --ring: var(--surface); }
/* press-edges: rows are areas, not objects: they take the ink tint and give a little. 50 ms before a row shows as pressed, as iOS lists do,
   so starting a scroll on a row does not flash it. The status dot's ring follows the tint. */
.bot-row { -webkit-tap-highlight-color: transparent; transition: transform .2s var(--spring), background-color .2s ease-out; }
.bot-row:active { transform: scale(.985); background-color: var(--press-tint); --ring: var(--press-ring); transition-duration: .08s; transition-delay: .05s; }
.bot-row.is-selected:active { background-color: color-mix(in srgb, var(--text) 5.5%, var(--surface)); --ring: color-mix(in srgb, var(--text) 5.5%, var(--surface)); }
@media (prefers-color-scheme: dark) { .bot-row.is-selected { box-shadow: 0 -1px 0 0 var(--edge-ring), 0 0 0 1px var(--line), 0 1px 2px rgb(50 35 20 / .05); } }
.bot-row.is-main { padding: 11px 10px; }
.row-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-name { font-weight: 620; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12.8px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub.sub-working { color: var(--accent-strong); }
.row-sub.sub-waiting { color: var(--wait-ink); font-weight: 550; }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.count.count-wait { background: var(--wait); color: #3A2A00; }

.new-bot { margin: 6px 10px 8px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; background: transparent; color: var(--muted); font-weight: 560; display: flex; align-items: center; justify-content: center; gap: 8px; flex: none; }
@media (hover: hover) { .new-bot:hover { color: var(--text); border-color: var(--faint); background: color-mix(in srgb, var(--text) 4%, transparent); } }
/* press-edges: pressed */
.new-bot { -webkit-tap-highlight-color: transparent; transition: transform .2s var(--spring), background-color .2s ease-out; }
.new-bot:active { transform: scale(.985); background-color: var(--press-tint); transition-duration: .08s; transition-delay: .05s; }
.side-foot { flex: none; padding: 8px 10px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 550; text-align: left; width: 100%; }
@media (hover: hover) { .nav-item:hover { background: color-mix(in srgb, var(--text) 5.5%, transparent); color: var(--text); } }
.nav-item.is-active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
/* press-edges: pressed, and a lit top edge on the selected row (dark) */
.nav-item { -webkit-tap-highlight-color: transparent; transition: transform .2s var(--spring), background-color .2s ease-out; }
.nav-item:active { transform: scale(.985); background-color: var(--press-tint); transition-duration: .08s; transition-delay: .05s; }
.nav-item.is-active:active { background-color: color-mix(in srgb, var(--text) 5.5%, var(--surface)); }
@media (prefers-color-scheme: dark) { .nav-item.is-active { box-shadow: 0 -1px 0 0 var(--edge-ring), 0 0 0 1px var(--line); } }
.nav-label { flex: 1; }

[data-icon] { display: inline-flex; }
.brand-actions [data-icon], .brand-actions .icon-btn { display: inline-grid; }

/* ---------- chat ---------- */
#view-chat { position: relative; }
.chat-head { height: 60px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.head-avatar { flex: none; display: inline-flex; }
.head-text { flex: 1; min-width: 0; }
.head-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.head-name { font-size: 15.5px; font-weight: 650; letter-spacing: -.005em; white-space: nowrap; }
.head-title { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.head-status { display: flex; align-items: center; gap: 7px; font-size: 12.8px; color: var(--muted); min-width: 0; }
.head-status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-status.st-waiting { color: var(--wait-ink); font-weight: 550; }
.head-status.st-working { color: var(--accent-strong); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12.5px; font-weight: 600; white-space: nowrap; flex: none; }
.head-screen { display: none; }

.transcript { position: relative; flex: 1; min-height: 0; }
.scroller { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; scroll-behavior: auto; }
.stream-wrap { width: 100%; max-width: 800px; margin: 0 auto; padding: 22px 20px 14px; min-height: 100%; display: flex; flex-direction: column; }
.stream { display: flex; flex-direction: column; gap: 10px; }
/* rhythm-type: turn rhythm. The gap says what belongs together: 6px inside the bot's turn, 10px from Tom's message to the turn that
   answers it, 22px before Tom speaks again; a steps pill sits close above what it produced. Margins instead of the flex gap. */
.stream { gap: 0; }
.stream > * + * { margin-top: 6px; }                                   /* same turn: a reply after a card, two bubbles in a row */
.stream > .row-user + :not(.row-user, .day) { margin-top: 10px; }      /* Tom asks, the bot's turn follows (as today) */
.stream > :not(.row-user, .day) + .row-user { margin-top: 22px; }      /* the bot is done, Tom speaks again */
.stream > .tools + :not(.row-user, .day) { margin-top: 5px; }          /* the pill belongs to what follows it */
.stream > :not(.row-user, .day, .tools) + .tools { margin-top: 12px; } /* a later step in the same turn starts a new pair */
.stream > .day { margin: 24px 0 0; }                                   /* a new day is the widest break */
.stream > .day:first-child { margin-top: 10px; }
.stream > .day + * { margin-top: 12px; }
/* A time shows under a bubble unless the same side speaks again within three minutes, so a bubble after a timed one from the same
   side is a new message some time later, not part of the same burst: a little more room. */
.stream > .row-bot:has(> .meta) + .row-bot,
.stream > .row-user:has(> .meta) + .row-user { margin-top: 14px; }
/* arrive: a thing that has just happened settles into place; everything already there stays still. web/ui-chat.js adds .is-arriving to a node ONLY when a
   live event created it, and takes it off at animationend. Transform and opacity only: no blur, no shadow, nothing left on the element afterwards.
   Vale's side and everything that is not a bubble (step pills, cards, routine chips, a new day chip): up 6 px. Opacity is done by half-time so the
   words are readable at once; the last of the travel is the settle. Tom's bubble lifts out of the message box, 10 px low and 96% size, pinned at its tail. */
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } 50% { opacity: 1; } }
@keyframes msg-out { from { opacity: 0; transform: translateY(10px) scale(.96); } 50% { opacity: 1; } }
.stream > .is-arriving { animation: msg-in .22s cubic-bezier(.22, .61, .36, 1); }
.stream > .row-user.is-arriving { animation: msg-out .24s cubic-bezier(.22, .61, .36, 1); transform-origin: 100% 100%; }
/* arrive, "Chat makes room": while the chat glides up (web/ui-chat.js makeRoom), the shifted rows must not add to the scroll height. */
.stream-wrap.is-gliding { overflow: clip; }
@media (prefers-reduced-motion: reduce) { .stream > .is-arriving, .stream > .row-user.is-arriving { animation: none; } }
.top-note { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12.5px; padding: 0 0 12px; }
.empty { flex: 1; display: grid; place-items: center; padding: 40px 0; }
.empty-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; max-width: 360px; color: var(--muted); }
.empty-card .avatar { margin-bottom: 6px; }
.empty-title { font-weight: 640; font-size: 16px; color: var(--text); }
/* rhythm-type: titles balance their lines (ignored where unsupported) */
.empty-title { text-wrap: balance; }
.empty-sub { font-size: 13.5px; }
.jump { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: var(--shadow); font-weight: 560; font-size: 13px; z-index: 5; }
@media (hover: hover) { .jump:hover { background: var(--surface-2); } }
/* press-edges: the Latest pill dips and gets a lit top edge (dark). The press repeats the centring translate, so a rule that moves or re-centres .jump must change both. */
.jump { -webkit-tap-highlight-color: transparent; } /* its transition list is in the glass-dock rule below */
.jump:active { transform: translateX(-50%) scale(.96); filter: var(--press-dim); transition-duration: .06s; }
/* day-pill: the day Tom is looking at, floating under the chat header while he scrolls back. Solid on purpose (its top edge is ~115 px from the top of
   the phone, next to the iOS 26 top-fade zone): no blur, no see-through fill, only a short opacity fade. Set by syncDayPill in ui-chat.js. */
.day-pill { position: absolute; top: 8px; left: 50%; z-index: 5; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface-2); box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / .07); color: var(--muted); font-size: 12px; font-weight: 560; line-height: 16px; white-space: nowrap; pointer-events: none; -webkit-user-select: none; user-select: none; clip-path: inset(-8px -48px -48px -48px); opacity: 0; transform: translate(-50%, -3px); transition: opacity .32s ease, transform .32s ease; }
.day-pill.is-on { opacity: 1; transform: translate(-50%, 0); transition-duration: .14s; }
@media (prefers-reduced-motion: reduce) { .day-pill, .day-pill.is-on { transform: translate(-50%, 0); transition: none; } }
/* glass-dock: the "Latest" pill is a bead of glass ("New below" in web/ui-chat.js), and the message box is the frosted pane (composer block below); the dark values are the ones tuned. */
:root {
  --glass-fx: blur(20px) saturate(1.5);
  --glass-fx-sm: blur(12px) saturate(1.5);
  --glass-pane: color-mix(in srgb, var(--surface) 78%, transparent);   /* the message box */
  --glass-pane-focus: color-mix(in srgb, var(--surface) 94%, transparent);
  --glass-bead: color-mix(in srgb, var(--surface) 72%, transparent);   /* the "Latest" pill */
  --glass-edge: rgb(255 255 255 / .7);                                  /* the lit top edge */
  --glass-rim: color-mix(in srgb, var(--line-strong) 70%, transparent); /* the hairline around a small pane */
  --glint: rgb(255 255 255 / .6);
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass-fx: blur(12px) saturate(1.6);   /* a small blur on purpose: a bubble passing underneath keeps its shape */
    --glass-fx-sm: blur(10px) saturate(1.6);
    --glass-pane: color-mix(in srgb, var(--surface) 78%, transparent);
    --glass-pane-focus: color-mix(in srgb, var(--surface) 94%, transparent);
    --glass-bead: color-mix(in srgb, var(--surface) 58%, transparent);
    --glass-edge: rgb(255 255 255 / .07);
    --glass-rim: color-mix(in srgb, var(--line-strong) 80%, transparent);
    --glint: rgb(255 255 255 / .2);
  }
}
/* solid fallbacks: no blur support, or the person asked for less transparency or more contrast (iPhone Safari does not report Reduce Transparency; it does report Increase Contrast) */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  :root { --glass-fx: none; --glass-fx-sm: none; --glass-pane: var(--surface); --glass-pane-focus: var(--surface); --glass-bead: var(--surface); }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  :root { --glass-fx: none; --glass-fx-sm: none; --glass-pane: var(--surface); --glass-pane-focus: var(--surface); --glass-bead: var(--surface); --glass-rim: var(--line-strong); }
}
.jump {
  overflow: hidden;
  border-color: var(--glass-rim);
  background: var(--glass-bead);
  -webkit-backdrop-filter: var(--glass-fx-sm); backdrop-filter: var(--glass-fx-sm);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-edge);
  /* one list for both features: glass-dock's fade and grow, press-edges' dim, tint and edge (press-edges' .jump:active shortens them all while held) */
  transition: opacity .16s ease-out, transform .16s cubic-bezier(.2, .8, .2, 1), visibility 0s, filter .14s, background-color .18s ease-out, border-color .12s, box-shadow .14s;
}
/* it fades and grows in, instead of popping (the global [hidden] rule is display:none !important, so say it louder) */
.jump[hidden] {
  display: inline-flex !important; visibility: hidden; opacity: 0; pointer-events: none;
  transform: translateX(-50%) scale(.92);
  transition: opacity .12s ease-in, transform .12s ease-in, visibility 0s .12s;
}
@media (hover: hover) { .jump:hover { background: var(--glass-bead); } }
/* press-edges' lit top edge (dark), over the glass rim, as on the message box: after the glass rule so it wins */
@media (prefers-color-scheme: dark) { .jump { border-top-color: var(--edge-top); } }
/* a message landed below while he was reading further up: the words change to "New below" (JS), the arrow gives its place to a clay dot (the app's own
   mark for something unread), and one glint crosses the pill, once */
.jump.has-new svg { display: none; }
.jump.has-new::before { content: ""; flex: none; width: 7px; height: 7px; margin: 0 2px 0 1px; border-radius: 50%; background: var(--accent); }
.jump::after {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: 0; width: 42%; pointer-events: none; opacity: 0;
  background: linear-gradient(100deg, transparent, var(--glint) 50%, transparent);
  transform: translateX(-140%) skewX(-14deg);
}
.jump.is-glint::after { animation: jump-glint .8s cubic-bezier(.2, .6, .2, 1) 1 both; }
@keyframes jump-glint {
  0% { opacity: 0; transform: translateX(-140%) skewX(-14deg); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translateX(380%) skewX(-14deg); }
}
@media (prefers-reduced-motion: reduce) {
  .jump[hidden] { transform: translateX(-50%); }
  .jump.is-glint::after { animation: none; }
}

.working { display: flex; align-items: center; gap: 10px; margin: 12px 0 0 4px; font-size: 13px; color: var(--muted); }
/* Working line with a face (working-line): the bot's own small face, what it is doing in clay, a clock; a chief's chat gets a quiet "who else is working" line. Drawn by renderWorking in ui-chat.js. */
/* ---- the bot's own line ---- */
.working { gap: 8px; margin: 12px 0 0 1px; min-height: 20px; line-height: 20px; }
/* The line's entrance plays only when work starts live (arrive's showWorking in ui-chat.js adds .is-arriving): not on first load, a bot switch or a reconnect. */
.working.is-arriving { animation: working-in .24s ease-out both; }
@media (prefers-reduced-motion: reduce) { .working.is-arriving { animation: none; } }
.working-face { flex: none; display: inline-flex; }
.working-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.working-text.is-new { animation: working-swap .22s ease-out; }
.working-what { color: var(--accent-strong); }
.working-detail { color: var(--muted); }
.working-clock { flex: none; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .4s ease; }
.working-clock.is-on { opacity: 1; }

/* A 20 px face moves half as far as the 40 px one in the list for the same angle, which is too little to see. These carry the same
   travel in pixels: breathe 1.04 -> 1.08, rock 2.5 and 1.5 degrees -> 5 and 3. Same periods, same shape of curve as av-breathe / av-rock. */
.working-face .av.is-working .av-vale,
.working-other .av.is-working .av-vale { animation-name: working-breathe; }
.working-face .av.is-working .av-staff,
.working-other .av.is-working .av-staff { animation-name: working-rock; }
.working-face .av.is-working .av-staff > .av-m2,
.working-other .av.is-working .av-staff > .av-m2 { animation-name: working-rock-slow; }

/* ---- who else is working: one quiet line, a real button ---- */
.working-others { display: flex; flex-direction: column; align-items: flex-start; margin: -4px 0 -9px 1px; }
.working[hidden] + .working-others { margin-top: 0; }
/* integration (working-line x arrive): the foot of the chat stays put while the chat glides up (ui-chat.js makeRoom), so both lines stand on the page
   colour and what glides passes behind them, not through their words. The others line's top 4 px, where it overlaps the working line, stay clear. */
.working { position: relative; background: var(--bg); }
.working-others { position: relative; background: linear-gradient(transparent 4px, var(--bg) 4px); }
.working-other {
  position: relative; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; /* the whole 44 px takes the tap */
  padding: 0 4px 0 1px; border: 0; background: none; color: var(--muted); font-size: 12.5px; text-align: left;
  touch-action: manipulation;
}
/* Its entrance plays only when it comes in live (arrive's renderOthers in ui-chat.js adds .is-arriving), like the working line: not on a bot switch, a
   reconnect, or when the chat is shown again (an always-on animation restarts every time its pane goes from display:none to shown).
   backwards, not both: a held end state would block the press below. */
.working-other.is-arriving { animation: working-in .24s ease-out backwards; }
.working-other::before { content: ""; position: absolute; inset: 8px -4px 8px -5px; border-radius: 9px; background: transparent; transition: background-color .12s; }
.working-other:active::before { background: color-mix(in srgb, var(--text) 9%, transparent); }
/* press-edges: it is a row, so it gives a little like the bot rows (the tint above is its pressed colour); 50 ms late, so a scroll that starts on it does not flash it */
.working-other { -webkit-tap-highlight-color: transparent; transition: transform .2s var(--spring); }
.working-other:active { transform: scale(.985); transition-duration: .08s; transition-delay: .05s; }
.working-other:focus-visible { outline: none; }
.working-other:focus-visible::before { outline: 2px solid var(--accent-strong); outline-offset: 1px; }
.working-other-faces { position: relative; flex: none; display: inline-flex; gap: 3px; }
.working-other-text { position: relative; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.working-other-name { font-weight: 500; }
.working-other-chev { position: relative; flex: none; margin-left: -5px; color: var(--faint); }
@media (hover: hover) {
  .working-other:hover { color: var(--text); }
  .working-other:hover::before { background: color-mix(in srgb, var(--text) 5.5%, transparent); }
}

@keyframes working-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes working-swap { from { opacity: .25; } to { opacity: 1; } }
@keyframes working-breathe { 50% { transform: scale(1.08); } }
@keyframes working-rock { 0% { transform: rotate(0deg); animation-timing-function: ease-out; } 25% { transform: rotate(5deg); animation-timing-function: ease-in-out; } 75% { transform: rotate(-5deg); animation-timing-function: ease-in; } 100% { transform: rotate(0deg); } }
@keyframes working-rock-slow { 0% { transform: rotate(0deg); animation-timing-function: ease-out; } 25% { transform: rotate(-3deg); animation-timing-function: ease-in-out; } 75% { transform: rotate(3deg); animation-timing-function: ease-in; } 100% { transform: rotate(0deg); } }

/* Reduced motion: nothing moves. The line and the clock appear at once, the faces hold still (the app's own rule already stops
   .av-m1 / .av-m2), the clock still counts (a number changing in place, not movement). */
@media (prefers-reduced-motion: reduce) {
  .working-other.is-arriving,
  .working-text.is-new { animation: none; }
  .working-clock,
  .working-other::before { transition: none; }
}

.row { display: flex; flex-direction: column; min-width: 0; }
.row-user { align-items: flex-end; }
.row-bot { align-items: flex-start; }
.bubble { max-width: min(660px, 88%); padding: 9px 14px; border-radius: 18px; overflow-wrap: anywhere; min-width: 0; }
.bubble-user { background: var(--user-bg); color: var(--user-ink); border-bottom-right-radius: 6px; }
.user-text { white-space: pre-wrap; text-wrap: pretty; } /* rhythm-type */
.bubble-bot { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.meta { font-size: 11.5px; color: var(--faint); margin: 3px 6px 0; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.user-text + .atts { margin-top: 8px; }
.bubble-user > .atts:first-child { margin-top: 0; }
.att-img { display: block; }
.att-img img { display: block; min-width: 96px; min-height: 64px; max-width: 240px; max-height: 180px; object-fit: cover; border-radius: 10px; border: 1px solid rgb(0 0 0 / .08); }
.att-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: rgb(255 255 255 / .55); color: inherit; text-decoration: none; font-size: 13px; }
/* press-edges: pressed */
.att-chip { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.att-chip:active { opacity: .55; transition-duration: .06s; }
@media (prefers-color-scheme: dark) { .att-chip { background: rgb(255 255 255 / .1); } }

/* markdown */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .65em; }
.md ul, .md ol { margin: 0 0 .65em; padding-left: 1.35em; }
.md li { margin: .15em 0; }
.md li > p { margin: 0; }
/* rhythm-type: running text keeps company on its last line */
.md p, .md li { text-wrap: pretty; }
.md h1, .md h2, .md h3, .md h4 { margin: .9em 0 .35em; font-size: 1em; font-weight: 680; line-height: 1.3; }
.md h1 { font-size: 1.12em; }
.md h1, .md h2, .md h3, .md h4 { text-wrap: balance; } /* rhythm-type */
.md code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .38em; border-radius: 5px; }
.md pre { margin: 0 0 .7em; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.5; }
.md blockquote { margin: 0 0 .65em; padding: 0 0 0 12px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.md table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0 0 .7em; font-size: .95em; }
/* rhythm-type: tables in a bot's message: a quiet header with one firmer line under it, hairlines between rows, no boxes;
   fixed-width figures where numbers stack. */
.md table { font-variant-numeric: tabular-nums; }
.md th, .md td { border: 0; border-bottom: 1px solid var(--line); padding: 4px 18px 4px 0; text-align: left; vertical-align: top; }
.md th:last-child, .md td:last-child { padding-right: 2px; }
.md th { background: none; color: var(--muted); font-size: .88em; font-weight: 600; padding-top: 0; border-bottom-color: var(--line-strong); vertical-align: bottom; }
.md tbody tr:last-child td { border-bottom: 0; padding-bottom: 2px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: .9em 0; }
.md img { max-width: 100%; height: auto; border-radius: 8px; }
.md a { text-underline-offset: 2px; }
/* press-edges: pressed */
.md a { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.md a:active { opacity: .55; transition-duration: .06s; }

/* tool runs */
.tools { align-self: flex-start; max-width: 100%; min-width: 0; font-size: 12.8px; color: var(--muted); }
.tools-toggle { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 11px 4px 7px; border: 0; border-radius: 99px; background: color-mix(in srgb, var(--text) 5.5%, transparent); color: inherit; text-align: left; }
@media (hover: hover) { .tools-toggle:hover { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); } }
/* press-edges: pressed */
.tools-toggle { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.tools-toggle:active { transform: scale(.97); background-color: color-mix(in srgb, var(--text) 11%, transparent); transition-duration: .06s; }
.tools-chev { transition: transform .15s; flex: none; }
.tools.is-open .tools-chev { transform: rotate(90deg); }
.tools-count { font-weight: 600; white-space: nowrap; }
.tools-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tools-err { margin-left: 8px; color: var(--danger); font-weight: 600; white-space: nowrap; }
.tool-list { list-style: none; margin: 6px 0 2px 10px; padding: 0 0 0 4px; border-left: 2px solid var(--line); }
.tool-row { display: flex; gap: 10px; align-items: baseline; padding: 3px 0 3px 10px; min-width: 0; }
.tool-name { flex: none; width: 118px; color: var(--faint); font-size: 12px; }
.tool-summary { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.tool-row.is-error .tool-summary, .tool-row.is-error .tool-name { color: var(--danger); }

/* cards */
.card { width: min(660px, 100%); align-self: flex-start; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 11px 14px 12px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.card-title { font-weight: 640; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-time { font-size: 11.5px; color: var(--faint); margin-left: auto; flex: none; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.card-msg { background: var(--surface-2); border-left-width: 3px; }
.card-msg.is-out { border-left-color: var(--accent); }
.card-msg.is-in { border-left-color: var(--info); }
.card-msg .card-text { font-size: 14px; overflow-wrap: anywhere; }
/* Messages between bots: one muted line until opened */
.card-msg { padding: 6px 12px; }
.card-msg .card-head { margin: 0; }
.card-toggle { width: 100%; border: 0; background: none; padding: 2px 0; text-align: left; font: inherit; font-size: 13px; color: var(--muted); }
/* press-edges: pressed */
.card-toggle { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.card-toggle:active { opacity: .55; transition-duration: .06s; }
.card-toggle .card-title { flex: none; max-width: 40%; font-size: 13px; font-weight: 600; }
.card-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.card-chev { flex: none; transition: transform .15s; }
.card-msg.is-open .card-chev { transform: rotate(90deg); }
.card-msg.is-open .card-title { flex: 1; max-width: none; }
.card-msg.is-open .card-text { margin-top: 8px; }

.card-file { padding: 0; overflow: hidden; }
.card-file .result-player { display: block; width: 100%; color-scheme: light dark; } /* a recording or a clip plays in its card (grok-1); her room's look is in her-room.css */
.card-file .result-player.is-video { max-height: 340px; background: #000; object-fit: contain; }
.file-preview { display: block; background: var(--surface-2); border-bottom: 1px solid var(--line); }
/* press-edges: a picture in a file card darkens while held. filter, not opacity: the card behind must not show through.
   It waits 50 ms like a row, so starting a scroll on it does not flash it. */
.file-preview { -webkit-tap-highlight-color: transparent; transition: filter .18s ease-out; }
.file-preview:active { filter: var(--press-dim-img); transition-duration: .06s; transition-delay: .05s; }
.file-preview img { display: block; width: 100%; max-height: 340px; object-fit: contain; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; }
.file-icon { color: var(--muted); display: inline-flex; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12.5px; color: var(--muted); }

.card-approval.is-pending { border-color: var(--cb-wait-line); background: var(--cb-wait-bg); }
.card-approval .card-head svg { color: var(--accent-strong); }
.card-approval.is-decided { background: var(--bg-side); } /* approval-depth: a decided card lies below the bubbles (was --surface-2) */
.card-approval.st-denied .card-head svg { color: var(--danger); }
.card-approval.st-allowed .card-head svg { color: var(--info); }
.approval-action { font-weight: 620; overflow-wrap: anywhere; text-wrap: balance; } /* rhythm-type: balanced title */
.approval-details { margin-top: 3px; color: var(--muted); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* The shield is empty until there is a decision; the tick belongs to "allowed" (pathLength of the tick is about 8.5, so 9 hides it fully). */
.card-approval .card-head svg path:last-child { stroke-dasharray: 9; stroke-dashoffset: 0; }
.card-approval.is-pending .card-head svg path:last-child, .card-approval.st-denied .card-head svg path:last-child { stroke-dashoffset: 9; }
.card-handoff.is-pending { border-color: var(--cb-wait-line); background: var(--cb-wait-bg); color: var(--warn-ink); }
.card-handoff.is-pending .card-head, .card-handoff.is-pending .card-title, .card-handoff.is-pending .card-time { color: var(--warn-ink); }
.card-handoff .handoff-text { overflow-wrap: anywhere; text-wrap: pretty; } /* rhythm-type */
.card-handoff.is-decided { background: var(--bg-side); }
.card-handoff.is-pending .btn { border-color: var(--warn-line); background: rgb(255 255 255 / .55); color: var(--warn-ink); }
.card-handoff.is-pending .btn-primary { background: var(--warn-ink); border-color: var(--warn-ink); color: var(--warn-bg); }
.card-handoff.is-pending .btn-quiet { background: transparent; border-color: transparent; }
@media (prefers-color-scheme: dark) { .card-handoff.is-pending .btn { background: rgb(255 255 255 / .08); } .card-handoff.is-pending .btn-primary { background: var(--warn-ink); } }

/* approval-depth: a card that waits for Tom stands up, a decided one lies flat. Four parts: depth on a pending card, the settle when Tom
   decides, one glint when a card arrives live, and (further down, by the list rules) a finished list item closing up.
   The app never changes a card in place: a decision or an arrival builds a NEW card and reconcile swaps it in (ui-chat.js), so the motion
   is a one-shot animation started by a class the JS puts on the new card: .is-settling (0.5 s) and .is-new (1.3 s). Without the class a
   card simply appears in its final state. --cb-wait-bg / --cb-wait-line name the waiting colours once: the pending rules above and the
   settle's first frame both read them, so they cannot drift apart. No blur and no transparency on a card. */
.stream { isolation: isolate; } /* the lifted card's z-index stays inside the chat: it never paints over the composer, a pill or a sheet */
.card-approval { --cb-lift: var(--shadow); --cb-wait-bg: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); --cb-wait-line: color-mix(in srgb, var(--accent) 55%, var(--line)); --cb-wait-rim: var(--cb-wait-line); }
.card-handoff { --cb-lift: var(--shadow); --cb-wait-bg: var(--warn-bg); --cb-wait-line: var(--warn-line); --cb-wait-rim: var(--cb-wait-line); }
@media (prefers-color-scheme: dark) {
  /* On near-black the --shadow token (two blacks at 30%) cannot be seen: dark gets a deeper pair plus a lit top edge, which is what makes a dark surface read as an object. */
  .card-approval, .card-handoff { --cb-lift: inset 0 1px 0 color-mix(in srgb, var(--text) 16%, transparent), 0 2px 3px rgb(0 0 0 / .6), 0 14px 32px rgb(0 0 0 / .75); }
  .card-approval { --cb-wait-rim: color-mix(in srgb, var(--accent) 85%, var(--line)); }
}
/* z-index 1 lets the shadow fall ON the next bubble instead of being painted over by it: on a dark page that is the part of the shadow the eye can see */
.card-approval.is-pending, .card-handoff.is-pending { position: relative; z-index: 1; box-shadow: var(--cb-lift); border-top-color: var(--cb-wait-rim); }
/* the settle: starts at the waiting look and ends at whatever the decided card is (no fill-mode); z-index holds at 1 while it runs so the draining shadow stays over the bubble below */
.card-approval.is-settling, .card-handoff.is-settling { position: relative; animation: cb-settle .26s ease; }
@keyframes cb-settle {
  from { z-index: 1; box-shadow: var(--cb-lift); background-color: var(--cb-wait-bg); border-color: var(--cb-wait-line); border-top-color: var(--cb-wait-rim); }
  to { z-index: 1; }
}
/* letter: the same moment lands the shield. It comes down from larger and faint while its colour changes (cb-settle-ink), then the tick draws in
   (allowed and always allowed; a denied shield stays empty). One animation list, so nothing here fights the colour change: it moves transform and opacity only. */
.card-approval.is-settling .card-head svg { transform-origin: 50% 55%; animation: cb-settle-ink .26s ease, letter-stamp .3s cubic-bezier(.2, .8, .3, 1) backwards; }
.card-approval.st-allowed.is-settling .card-head svg path:last-child { animation: letter-tick .25s .16s ease-out backwards; }
@keyframes cb-settle-ink { from { color: var(--accent-strong); } }
@keyframes letter-stamp { from { transform: scale(1.5); opacity: .35; } to { transform: none; opacity: 1; } }
@keyframes letter-tick { from { stroke-dashoffset: 9; } to { stroke-dashoffset: 0; } }
/* the glint: the card stands up and one band of light crosses its surface, once, UNDER the text and buttons (z-index -1 in an isolated card) so it never sweeps over Allow */
.card-approval.is-new, .card-handoff.is-new, .waiting-strip.is-new { position: relative; overflow: hidden; isolation: isolate; }
.card-approval.is-new, .card-handoff.is-new { animation: cb-stand-up .3s ease both; }
@keyframes cb-stand-up { from { box-shadow: 0 0 0 rgb(0 0 0 / 0); } }
.card-approval.is-new::after, .card-handoff.is-new::after, .waiting-strip.is-new::after {
  content: ""; position: absolute; z-index: -1; top: -20%; bottom: -20%; left: 0; width: 38%; pointer-events: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 0%, transparent), color-mix(in srgb, var(--accent) 16%, transparent) 50%, color-mix(in srgb, var(--accent) 0%, transparent));
  transform: translateX(-170%) skewX(-14deg);
  animation: cb-glint .85s cubic-bezier(.45, .05, .35, 1) .12s 1 both;
}
.waiting-strip.is-new::after { animation-delay: .34s; animation-duration: .7s; } /* the same light, reaching the strip a moment later */
@keyframes cb-glint { to { transform: translateX(335%) skewX(-14deg); } }
@media (prefers-color-scheme: dark) {
  /* clay at 16% suits the pale blush card in light; on the dark card the band is the app's warm white, faint */
  .card-approval.is-new::after, .card-handoff.is-new::after, .waiting-strip.is-new::after {
    background: linear-gradient(90deg, color-mix(in srgb, var(--text) 0%, transparent), color-mix(in srgb, var(--text) 9%, transparent) 50%, color-mix(in srgb, var(--text) 0%, transparent));
  }
}
@media (prefers-reduced-motion: reduce) {
  .card-approval.is-settling, .card-handoff.is-settling, .card-approval.is-settling .card-head svg, .card-approval.st-allowed.is-settling .card-head svg path:last-child { animation: none; }
  .card-approval.is-new, .card-handoff.is-new { animation: none; }
  .card-approval.is-new::after, .card-handoff.is-new::after, .waiting-strip.is-new::after { display: none; }
}

.event { align-self: center; max-width: 90%; display: flex; gap: 6px; align-items: flex-start; text-align: left; font-size: 12.5px; line-height: 1.4; color: var(--muted); background: var(--surface-2); border-radius: 9px; padding: 3px 10px; overflow-wrap: anywhere; }
.event svg { flex: none; margin-top: 2px; color: var(--faint); }
.err-line { align-self: flex-start; display: flex; gap: 8px; align-items: flex-start; max-width: min(660px, 100%); padding: 8px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; overflow-wrap: anywhere; }
.err-line svg { flex: none; margin-top: 2px; }
.day { align-self: stretch; display: flex; align-items: center; gap: 12px; margin: 10px 0 2px; color: var(--faint); font-size: 12px; font-weight: 550; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
/* day-pill: a day line passing under the pill hands its word to the pill and gets it back when it moves clear (so two day labels never collide). It hides at once and returns slowly. */
.day > span { transition: opacity .32s ease; }
.day.is-lifted > span { opacity: 0; transition-duration: 0s; }
@media (prefers-reduced-motion: reduce) { .day > span, .day.is-lifted > span { transition: none; } }

/* composer */
.composer { flex: none; width: 100%; max-width: 800px; margin: 0 auto; padding: 4px 20px 18px; }
.composer-box { display: flex; align-items: flex-end; gap: 4px; padding: 6px 6px 6px 6px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s; }
.composer-box:focus-within { border-color: color-mix(in srgb, var(--accent) 75%, var(--line-strong)); box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
/* press-edges: a light top edge on the message box (dark; the focus ring takes over while typing) */
@media (prefers-color-scheme: dark) { .composer-box:not(:focus-within) { border-top-color: var(--edge-top); } }
/* glass-dock (phone): the message box floats over the chat as the frosted pane; --composer-h (web/ui-chat.js) sizes the chat's bottom padding and the pill. #view-chat outranks the phone block's .stream-wrap padding. */
@media (max-width: 700px) {
  #view-chat .composer {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; pointer-events: none;
    /* the page's own colour, fading out: text dissolves into the floor instead of being cut by the tab bar */
    background: linear-gradient(to top, var(--bg) 12px, color-mix(in srgb, var(--bg) 0%, transparent) 50px);
  }
  #view-chat .composer > * { pointer-events: auto; }
  /* Something sits above the box (the "Waiting for you" strip, a reply, attachments, dictation): the tray is now taller than that fade, and chat would show sharp
     between the strip and the box. So the tray becomes the page-coloured floor, with a short fade at its top. The strip keeps today's solid look. */
  #view-chat .composer:has(> :is(.waiting-strip, .reply-strip, .chips, .dict-strip):not([hidden])) {
    padding-top: 18px; pointer-events: auto;
    background: linear-gradient(to top, var(--bg) calc(100% - 18px), color-mix(in srgb, var(--bg) 0%, transparent));
  }
  #view-chat .stream-wrap { padding-bottom: calc(var(--composer-h, 70px) + 10px); }
  #view-chat .jump { bottom: calc(var(--composer-h, 70px) + 8px); }
  .composer-box {
    border-color: var(--glass-rim);
    background: var(--glass-pane);
    -webkit-backdrop-filter: var(--glass-fx); backdrop-filter: var(--glass-fx);
    box-shadow: var(--shadow), inset 0 1px 0 var(--glass-edge);
    transition: border-color .12s, box-shadow .12s, background-color .12s;
  }
  /* nearly solid while he types, so his own words stay sharp */
  .composer-box:focus-within {
    border-color: color-mix(in srgb, var(--accent) 75%, var(--line-strong));
    background: var(--glass-pane-focus);
    box-shadow: var(--shadow), inset 0 1px 0 var(--glass-edge), 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  }
}
.composer-input { flex: 1; min-width: 0; border: 0; background: transparent; resize: none; padding: 8px 4px; min-height: 36px; max-height: 190px; line-height: 1.45; font-size: 15px; outline: none; }
.composer-input:focus-visible { outline: none; }
.composer-input::placeholder { color: var(--faint); }
.composer-attach { width: 36px; height: 36px; border-radius: 50%; }
.send-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; flex: none; transition: background .12s, opacity .12s; }
@media (hover: hover) { .send-btn:hover:not(:disabled) { filter: brightness(1.06); } }
.send-btn:disabled { background: var(--line); color: var(--faint); cursor: default; }
/* press-edges: Send is a bead when it can send (a disabled Send stays flat), and dips when pressed */
.send-btn { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.send-btn:not(:disabled) { box-shadow: inset 0 1px 0 var(--clay-top), inset 0 -1px 0 var(--clay-bottom), var(--clay-drop); }
.send-btn:active:not(:disabled) { transform: scale(.92); filter: var(--press-dim); box-shadow: var(--press-in); transition-duration: .06s; }
/* arrive: grey to clay is the .12s background transition above; this adds the small swell. Class set when Send goes from off to on. */
@keyframes send-wake { 0% { transform: scale(.9); } 55% { transform: scale(1.08); } 100% { transform: none; } }
.send-btn.is-waking { animation: send-wake .16s ease-out; }
@media (prefers-reduced-motion: reduce) { .send-btn.is-waking { animation: none; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px 8px; }
.chip-file { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.8px; max-width: 100%; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.chip-x { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); padding: 0; }
@media (hover: hover) { .chip-x:hover { background: color-mix(in srgb, var(--text) 10%, transparent); } }
/* press-edges: pressed */
.chip-x { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.chip-x:active { transform: scale(.92); background-color: color-mix(in srgb, var(--text) 9%, transparent); transition-duration: .06s; }

.drop-veil { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(3px); border: 2px dashed var(--accent); border-radius: 14px; margin: 8px; pointer-events: none; }
.drop-card { display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

/* ---------- screen panel ---------- */
#screen-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; background: var(--bg-side); border-left: 1px solid var(--line); }
.scr-head { height: 60px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px 0 16px; }
.scr-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.scr-label { font-weight: 640; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scr-head-actions { display: flex; align-items: center; gap: 6px; }
.scr-close { display: none; }
.led { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint); opacity: .55; }
.led-on { background: #4FB477; opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, #4FB477 25%, transparent); }
.led-wait { background: var(--wait); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--wait) 30%, transparent); }

.scr-stagewrap { position: relative; flex: none; }
.scr-stage { position: relative; aspect-ratio: 16 / 10; margin: 0 16px; background: var(--screen-bg); border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--line-strong), 0 6px 20px rgb(30 20 10 / .16); flex: none; }
.scr-stage.is-control { box-shadow: 0 0 0 2px var(--accent), 0 6px 20px rgb(30 20 10 / .16); }
.scr-stage.is-tall { margin: 0 auto; width: min(100%, calc((100dvh - 250px) * 1.6)); }
.scr-host, .scr-live, .scr-snap { position: absolute; inset: 0; width: 100%; height: 100%; }
.scr-snap { object-fit: contain; background: var(--screen-bg); }
.scr-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 22px; text-align: center; color: #CFC9BC; background: color-mix(in srgb, var(--screen-bg) 94%, transparent); font-size: 13.5px; }
.scr-overlay svg { color: #8E887C; }
.ov-title { font-weight: 640; color: #ECE8E0; font-size: 14.5px; text-wrap: balance; } /* rhythm-type */
.ov-sub { max-width: 30ch; color: #A8A196; font-size: 12.8px; margin-bottom: 4px; }
.scr-note { position: absolute; left: 8px; top: 8px; padding: 3px 10px; border-radius: 99px; background: rgb(0 0 0 / .6); color: #ECE8E0; font-size: 12px; }
.scr-placeholder { position: absolute; inset: 0; display: grid; place-items: center; background: var(--screen-bg); color: #A8A196; font-size: 13px; }

.handoff-banner { position: absolute; left: 24px; right: 24px; bottom: 8px; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 11px; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); box-shadow: 0 8px 24px rgb(0 0 0 / .35); font-size: 13px; z-index: 3; }
.hb-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hb-text strong { font-weight: 680; }
.hb-text span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.hb-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.handoff-banner .btn { border-color: var(--warn-line); background: rgb(255 255 255 / .55); color: var(--warn-ink); min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.handoff-banner .btn.hb-open { background: var(--warn-ink); border-color: var(--warn-ink); color: var(--warn-bg); }
.handoff-banner .btn-ghost { background: transparent; border-color: transparent; }
@media (prefers-color-scheme: dark) { .handoff-banner .btn { background: rgb(255 255 255 / .09); } .handoff-banner .btn.hb-open { background: var(--warn-ink); } }

.scr-foot { padding: 14px 18px 24px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.scr-status { font-size: 13px; color: var(--muted); }
.scr-status.st-working { color: var(--accent-strong); }
.scr-status.st-waiting { color: var(--wait-ink); font-weight: 550; }
.scr-tools { margin: 4px 0 0; }
.scr-tools .tool-name { width: auto; min-width: 0; max-width: 42%; }
.scr-tools .tool-row { flex-direction: column; gap: 0; padding: 4px 0 4px 10px; }

/* full-screen modal */
.dlg.dlg-screen { width: min(1240px, calc(100vw - 24px), calc((100dvh - 250px) * 1.6 + 34px)); max-width: none; }
.screen-modal { display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 16px; }
.screen-modal .scr-head { padding: 0; }
.screen-modal .scr-stage { margin: 0 auto; }
.screen-modal .scr-stagewrap { margin: 0; }
.modal-note { text-align: center; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.modal-ask { overflow-wrap: anywhere; }
.dlg-screen.is-control .modal-note { color: var(--accent-strong); font-weight: 550; }

/* "Type on screen" bar: shown only while Take control is on */
.type-bar { display: flex; flex-direction: column; gap: 8px; width: min(100%, 720px); margin: 0 auto; }
.tb-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-input { flex: 1; min-width: 0; font-size: 16px; } /* 16px: iOS zooms the page on focus below this */
.tb-input.is-masked { -webkit-text-security: disc; }
.tb-send { min-width: 64px; min-height: 40px; }
.tb-keys { flex-wrap: wrap; }
.tb-key { flex: 1 1 auto; padding-inline: 8px; }

.switch { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; padding: 4px 6px; border: 0; background: transparent; border-radius: 99px; font-weight: 560; font-size: 13.5px; }
.switch-track { position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong); transition: background .15s; flex: none; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.switch[aria-checked="true"] .switch-track { background: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); }
.switch-plain { padding: 2px; }
/* press-edges: a switch does what an iPhone switch does: the knob stretches toward the other side while held. */
.switch { -webkit-tap-highlight-color: transparent; }
.switch-thumb { transition: transform .15s, width .15s; }
.switch:active .switch-thumb { width: 22px; border-radius: 99px; }   /* 99px: the stretched knob is a pill, not an oval */
.switch[aria-checked="true"]:active .switch-thumb { transform: translateX(12px); }

/* ---------- other views ---------- */
.view-head { padding: 16px 24px 10px; flex: none; display: flex; align-items: flex-end; justify-content: space-between; min-height: 60px; border-bottom: 1px solid var(--line); }
.view-title { font-size: 19px; font-weight: 660; letter-spacing: -.01em; }
.view-sub { margin-top: 1px; color: var(--muted); font-size: 13px; min-height: 1.2em; }
.view-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* press-edges: Computer cards sit in a list that scrolls, so they behave like rows (same give, same 50 ms wait) but dim like a button,
   because the card is mostly a picture and a tint would not show on it. The amber "waiting" ring stays. */

.rt-list { list-style: none; margin: 0; padding: 18px 24px 28px; max-width: 1000px; }
.rt { display: grid; grid-template-columns: minmax(0, 1fr) 130px 150px auto; gap: 16px; align-items: center; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.rt.is-off { background: transparent; }
.rt.is-off .rt-main { opacity: .6; }
.rt-name { font-weight: 640; overflow-wrap: anywhere; }
.rt-when { font-size: 13px; color: var(--accent-strong); }
.rt-prompt { margin-top: 3px; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.rt-bot { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; }
.rt-bot span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-next { display: flex; flex-direction: column; font-size: 13.5px; }
.rt-next-label { font-size: 11.5px; color: var(--faint); }
.rt-next-val { font-variant-numeric: tabular-nums; } /* rhythm-type: Next times stack in a column */
.rt-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.rt-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 56px 16px; color: var(--muted); }
.rt-empty .empty-sub { max-width: 36ch; }

/* ---------- dialogs ---------- */
.dlg { border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; }
/* press-edges: a faint lit top edge on the dialog (dark), so it reads as an object and not a hole */
@media (prefers-color-scheme: dark) { .dlg { box-shadow: var(--shadow-lg), inset 0 1px 0 var(--edge-hi); } }
.dlg::backdrop { background: rgb(24 16 8 / .5); backdrop-filter: blur(2px); }
.dlg[open] { animation: dlg-in .16s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }
.dlg-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 15px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -8px 0 0; }
.dlg-title { font-size: 18px; font-weight: 660; letter-spacing: -.01em; text-wrap: balance; } /* rhythm-type */
.dlg-text { color: var(--muted); }
.dlg-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.dlg-actions .spacer { flex: 1; }
.dlg-confirm { width: min(420px, calc(100vw - 24px)); }
.bd-top { display: flex; align-items: flex-end; gap: 14px; }
.bd-preview { display: inline-flex; padding-bottom: 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; min-height: 32px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; font-weight: 520; }
@media (hover: hover) { .chip:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong)); } }
/* press-edges: pressed */
.chip { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.chip:active { transform: scale(.97); background-color: var(--accent-soft); transition-duration: .06s; }

.look-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 0; padding: 0; display: inline-grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1); }
.swatch svg { opacity: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch[aria-pressed="true"] svg { opacity: 1; }
/* press-edges: pressed (colour dots in the bot dialog) */
.swatch { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.swatch:active { transform: scale(.92); filter: var(--press-dim); transition-duration: .06s; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top, 0px)) 16px max(24px, env(safe-area-inset-bottom, 0px)); overflow: auto; position: fixed; inset: 0; background: var(--bg); }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 32px 30px 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-lede { color: var(--muted); margin-top: -8px; }

/* ---------- files panel (web/ui-files.js): over the chat's right edge; beside it when the screen is wide enough ---------- */
.files-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 300px; max-width: 100%; z-index: 15; display: flex; flex-direction: column; background: var(--bg-side); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.files-panel[hidden] { display: none; }
.files-head { height: 60px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); }
.files-title { font-size: 15px; font-weight: 650; }
.files-note { padding: 16px; color: var(--muted); font-size: 13.5px; }
.files-note:empty { display: none; }
.files-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 8px 12px; }
.files-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; text-decoration: none; font: inherit; cursor: pointer; }
@media (hover: hover) { .files-row:hover { background: var(--surface-2); } }
/* press-edges: pressed */
.files-row { -webkit-tap-highlight-color: transparent; transition: transform .2s var(--spring), background-color .2s ease-out; }
.files-row:active { transform: scale(.985); background-color: var(--press-tint); transition-duration: .08s; transition-delay: .05s; }
.files-icon, .files-thumb { flex: none; width: 36px; height: 36px; border-radius: 8px; }
.files-icon { display: inline-grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.files-thumb { object-fit: cover; border: 1px solid var(--line); }
.files-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.files-name { font-size: 13.5px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-sub { margin: 14px 8px 2px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.files-list .files-note { padding: 6px 8px; }
@media (min-width: 1500px) {
  #view-chat.files-open { padding-right: 300px; }
  .files-panel { box-shadow: none; }
}
@media (max-width: 700px) {
  .files-panel { width: 100%; border-left: 0; }
}

/* ---------- recent activity under the screen ---------- */
.scr-activity summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 4px 0; }
/* press-edges: pressed */
.scr-activity summary { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.scr-activity summary:active { opacity: .55; transition-duration: .06s; }


.scr-activity { padding: 0; }

.sheet-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 8px 16px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-body { overflow-y: auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }

/* glass-sheets: on a phone the app goes soft behind sheets and dialogs, and sheets rise from the bottom edge and leave the same way (web/sheet.js).
   A sheet opens at a resting height and its grab bar raises it to full; the confirm box rises and leaves too. Those get the frost and the lit edge.
   New Bot gets the veil (the stepped dim) only: they are as tall as the screen, so a frost behind them would never show, and their top
   edge sits at the safe-area line, where nothing translucent may be (no lit edge either). Phones only (max-width: 700px). Nothing is blurred in the top
   107px: the frost starts under the header, and .top-strip is not touched.
   Dark first. A rule that is repeated with the same :has() list is repeated on purpose: :has() takes the specificity of its most specific argument. */
@media (max-width: 700px) {
  /* the two heights: resting is what the content needs, up to 62dvh; .is-full is the height the sheet always had */
  
  
  /* the veil. The dim is a step, not a wash: heavier over the header (which stays sharp, so the dim alone must quieten it), lighter below, where the frost
     does the separating; the step sits on the header's own bottom line. Literal colours: ::backdrop only recently began inheriting custom properties
     (--veil is a nicety and falls back to 1). .dlg has a 2px blur on ::backdrop today; the frost layer replaces it. */
  .dlg:not(.dlg-screen)::backdrop { opacity: var(--veil, 1);
    background: linear-gradient(rgb(24 16 8 / .5) calc(env(safe-area-inset-top, 0px) + 60px), rgb(24 16 8 / .34) 0);
    -webkit-backdrop-filter: none; backdrop-filter: none; }
  /* the frost is an ordinary fixed layer over the app, under the dialog's dim: the well-trodden WebKit path for backdrop-filter. 60px is .chat-head's height;
     z-index 34 puts it over the tab bar (30) and under .top-strip (35) and the offline bar (90). */
  body:has(dialog.dlg-confirm[open]) #app::after { content: ""; position: fixed; z-index: 34; pointer-events: none;
    top: calc(env(safe-area-inset-top, 0px) + 60px); left: 0; right: 0; bottom: 0;
    -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
    animation: veil-in .2s ease-out; }
  body:has(dialog.dlg-confirm[open]) #app.is-offline::after { top: calc(env(safe-area-inset-top, 0px) + 88px); } /* the offline bar pushes the header down 28px */
  body:has(dialog.dlg.is-closing:not(.dlg-screen)) #app::after { animation: veil-out .2s ease-in forwards; }
  .dlg:not(.dlg-screen)[open]::backdrop { animation: veil-in .2s ease-out; }
  .dlg.dlg-confirm.is-closing::backdrop { animation: veil-out .2s ease-in forwards; }
}
@media (max-width: 700px) and (prefers-color-scheme: dark) {
  .dlg:not(.dlg-screen)::backdrop { background: linear-gradient(rgb(0 0 0 / .55) calc(env(safe-area-inset-top, 0px) + 60px), rgb(0 0 0 / .42) 0); }
}
@keyframes veil-in { from { opacity: 0; } }
@keyframes veil-out { to { opacity: 0; } }

/* glass-sheets, the sheet: a hairline of light along the top edge is what makes a dark sheet read as an object; the shadow is short so it stays off the header */
@media (max-width: 700px) {
  
   /* raised to full its top edge is ~127px down: the long shadow would reach the top 110px, so it is cut short */
  .dlg.dlg-confirm { box-shadow: inset 0 1px 0 rgb(255 255 255 / .7), var(--shadow-lg); }
  /* the grab bar is a real button (web/sheet.js); it sits in the bar's existing top padding, so the sheet keeps its height and nothing inside it moves.
     Its hit area is 76 x 28; the pill drawn in it is 36 x 5. The bar is the drag handle. */
  
  
   /* a mouse over the bar: it stays a plain pill, as mocked (press-edges already keeps .icon-btn's hover off touch screens) */
  
  .dlg.dlg-confirm[open] { animation: sheet-up .42s cubic-bezier(.32, .72, 0, 1); } /* replaces dlg-in here */
  /* while it leaves it takes no more taps: a Confirm tapped on the way down must not undo the Cancel that sent it down */
  .dlg.dlg-confirm.is-closing { animation: sheet-down .2s cubic-bezier(.4, 0, 1, 1) forwards; pointer-events: none; }
  
  
}
@media (max-width: 700px) and (prefers-color-scheme: dark) {
  
  
  .dlg.dlg-confirm { box-shadow: inset 0 1px 0 rgb(255 255 255 / .1), var(--shadow-lg); }
  /* New Bot, Card and the full-screen dialogs reach up to the safe-area line, where nothing translucent may be: no lit edge there (press-edges' .dlg edge is for wider screens) */
  .dlg:not(.dlg-confirm) { box-shadow: var(--shadow-lg); }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } } /* no "from": after a drag it carries on from where the finger left the sheet */

/* glass-sheets, fallbacks: reduced motion (no slide, no spring: the sheet and the veil appear and go at once, and web/sheet.js checks the same query);
   reduced transparency or more contrast (today's flat dim, no frost); no backdrop-filter at all */
@media (max-width: 700px) and (prefers-reduced-motion: reduce) {
  .dlg.dlg-confirm[open], .dlg.dlg-confirm.is-closing, .dlg:not(.dlg-screen)[open]::backdrop, .dlg.dlg-confirm.is-closing::backdrop, body:has(dialog.dlg-confirm[open]) #app::after, body:has(dialog.dlg.is-closing:not(.dlg-screen)) #app::after { animation: none; }
}
@media (max-width: 700px) and (prefers-reduced-transparency: reduce), (max-width: 700px) and (prefers-contrast: more) {
  .dlg:not(.dlg-screen)::backdrop { background: rgb(24 16 8 / .5); -webkit-backdrop-filter: none; backdrop-filter: none; }
  body:has(dialog.dlg-confirm[open]) #app::after { content: none; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  @media (max-width: 700px) {
    .dlg:not(.dlg-screen)::backdrop { background: rgb(24 16 8 / .5); }
    body:has(dialog.dlg-confirm[open]) #app::after { content: none; }
  }
}

/* ---------- narrow desktop: screen becomes a drawer ---------- */
@media (max-width: 1100px) and (min-width: 701px) {
  :root { --side-w: 264px; }
  #app, #app[data-view="computer"], #app[data-view="routines"] { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  #screen-panel { display: flex !important; position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 92vw); z-index: 40; transform: translateX(102%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; box-shadow: var(--shadow-lg); }
  #app[data-screen="open"] #screen-panel { transform: none; visibility: visible; transition: transform .22s ease; }
  .head-screen { display: inline-flex; }
  .scr-close { display: inline-grid; }
}

/* ---------- phone ---------- */
@media (max-width: 700px) {
  body { font-size: 15px; }
  #app, #app[data-view="computer"], #app[data-view="routines"] { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  #sidebar, #main, #screen-panel, #app[data-view="computer"] #screen-panel, #app[data-view="routines"] #screen-panel { display: none; }
  #app[data-pane="bots"] #sidebar { display: flex; border-right: 0; }
  #app[data-pane="main"] #main { display: flex; }
  #app[data-pane="screen"] #screen-panel { display: flex; border-left: 0; }
  .top-strip { display: block; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); z-index: 35; pointer-events: none; background: var(--strip-main); }
  #app[data-pane="bots"]:not([hidden]) ~ .top-strip, #app[data-pane="screen"]:not([hidden]) ~ .top-strip { background: var(--strip-side); }
  #tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--bg-side); border-top: 1px solid var(--line); }
  .tab { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 580; }
  .tab.is-active { color: var(--accent-strong); }
  .tab-icon { display: inline-flex; }
  /* press-edges: the tab icon dips, and springs back as the tab lights */
  .tab { -webkit-tap-highlight-color: transparent; }
  .tab-icon { transition: transform .2s var(--spring); }
  .tab:active .tab-icon { transform: scale(.88); transition-duration: .06s; }
  .tab-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
  .toasts { bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); }

  .bot-row { padding: 11px 10px; }
  .chat-head { padding: 0 6px 0 12px; gap: 10px; }
  .head-title, .head-line .badge { display: none; }
  .pill { padding: 6px; }
  .pill-text { display: none; }
  .stream-wrap { padding: 16px 12px 10px; }
  .bubble { max-width: 92%; }
  .composer { padding: 4px 10px 10px; }
  .composer-input { font-size: 16px; }
  .att-img img { max-width: 200px; }
  .tool-name { width: 92px; }
  .view-head { padding: 12px 16px 10px; }
  
  .rt-list { padding: 14px 14px 12px; }
  .rt { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; }
  .rt-main { grid-column: 1 / -1; }
  .rt-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .rt-next { align-items: flex-end; }
  .scr-stage { margin: 0 12px; }
  .handoff-banner { position: static; margin: 10px 12px 0; box-shadow: none; }
  .scr-head { padding: 0 8px 0 14px; }
  .dlg { width: 100vw; max-width: 100vw; max-height: calc(100dvh - env(safe-area-inset-top, 0px)); border-radius: 20px 20px 0 0; margin: auto 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .dlg.dlg-screen { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; padding-top: env(safe-area-inset-top, 0px); } /* .dlg.dlg-screen (desktop width) outranks .dlg, so say it again here */
  .dlg-screen .screen-modal { padding: 4px 10px 12px; min-height: 100%; }
  .scr-stage.is-tall { width: 100%; }
  .dlg-screen .scr-title .avatar { display: none; }
  .dlg-body { padding: 18px 16px 20px; }
  .login-card { padding: 26px 22px; }
}

@media (pointer: coarse) {
  .icon-btn { width: 42px; height: 42px; }
  .btn-sm { min-height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* press-edges, reduced motion: no movement. The colour change alone marks the press. (The rule above already makes every change instant.) */
@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled), .send-btn:active:not(:disabled), .icon-btn:active, .chip-x:active, .swatch:active, .tools-toggle:active, .chip:active, .bot-row:active, .nav-item:active, .new-bot:active, .files-row:active, .tab:active .tab-icon, .working-other:active { transform: none; transition-delay: 0s; }
  .file-preview:active { transition-delay: 0s; }
  .switch:active .switch-thumb { width: 18px; }
  .switch[aria-checked="true"]:active .switch-thumb { transform: translateX(16px); }
  .switch:active .switch-track { filter: var(--press-dim-img); }
  .jump:active { transform: translateX(-50%); }
}

/* Table cells must not inherit .bubble's overflow-wrap:anywhere, or columns squeeze words apart ("Le dg er"); .md table scrolls sideways instead. */
.md th, .md td { overflow-wrap: normal; word-break: normal; min-width: 6ch; }

/* In-app file viewer (web/viewer.js): full screen, close and download in the bar. */
.file-open { background: none; border: 0; padding: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
/* press-edges: pressed */
.file-open { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.file-open:active { opacity: .55; transition-duration: .06s; }
.viewer { border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; background: var(--surface); color: var(--text); flex-direction: column; }
.viewer[open] { display: flex; animation: dlg-in .16s ease-out; }
.viewer::backdrop { background: rgb(24 16 8 / .6); }
.viewer-bar { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); flex: none; }
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-name { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-size { font-size: 12px; color: var(--muted); }
.viewer-bar .icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.viewer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.viewer-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.viewer-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px; }
.viewer-center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px; min-height: 0; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-video { max-width: 100%; max-height: 100%; }
.viewer-audio { width: 100%; max-width: 520px; }
.viewer-pre { margin: 0; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.viewer-md { max-width: 760px; margin: 0 auto; }
.viewer-note { color: var(--muted); padding: 16px; margin: 0; }

/* Dictation (web/dictation.js) and image thumbnails in the composer (web/ui-chat.js). */
.composer-mic { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.composer-mic.is-recording { background: #c0392b; color: #fff; }
.dict-strip { display: flex; align-items: center; gap: 8px; padding: 0 10px 8px; font-size: 14px; line-height: 1.35; color: var(--muted); }
.dict-strip[hidden] { display: none; }
.dict-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #c0392b; animation: dict-pulse 1.2s ease-in-out infinite; }
.dict-strip.is-busy .dict-dot { background: var(--faint); animation: none; }
.dict-strip.is-failed { color: var(--text); }
.dict-strip.is-failed .dict-dot { background: var(--danger); animation: none; }
.dict-label { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.dict-strip .link-btn { flex: none; padding: 6px 4px; }
.dict-strip .link-btn[hidden] { display: none; }
@keyframes dict-pulse { 50% { opacity: .35; } }
.chip-thumb { position: relative; display: inline-block; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.chip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip-thumb.st-uploading img { opacity: .5; }
.thumb-wait { position: absolute; inset: 0; display: grid; place-items: center; }
.thumb-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; background: rgb(0 0 0 / .6); color: #fff; }
/* press-edges: pressed (the X on an attached photo). Its own reduced-motion line, because this rule sits after the global block. */
.thumb-x { -webkit-tap-highlight-color: transparent; transition: var(--press-t); }
.thumb-x:active { transform: scale(.92); background-color: rgb(0 0 0 / .85); transition-duration: .06s; }
@media (prefers-reduced-motion: reduce) { .thumb-x:active { transform: none; } }

/* Reply and quote (web/ui-chat.js) */
.bubble { position: relative; transition: transform .12s ease-out; }
.reply-btn { display: none; position: absolute; top: 4px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 0; place-items: center; }
.bubble-user .reply-btn { left: -32px; }
.bubble-bot .reply-btn { right: -32px; }
/* Desktop: always in the tab order, shown while the pointer is on the bubble or the button, or when it has keyboard focus. The ::before bridges the gap
   between bubble and button, so moving the mouse across it keeps the bubble hovered. */
@media (hover: hover) {
  .reply-btn { display: grid; opacity: 0; pointer-events: none; }
  .reply-btn::before { content: ''; position: absolute; top: -4px; bottom: -4px; width: 10px; }
  .bubble-user .reply-btn::before { right: -8px; }
  .bubble-bot .reply-btn::before { left: -8px; }
  .bubble:hover .reply-btn, .reply-btn:focus-visible { opacity: 1; pointer-events: auto; }
}
.bubble-bot, .bubble-user { -webkit-touch-callout: none; }
.quote { display: block; width: 100%; text-align: left; font: inherit; border: 0; border-left: 3px solid color-mix(in srgb, currentColor 45%, transparent); background: color-mix(in srgb, currentColor 10%, transparent); color: inherit; border-radius: 8px; padding: 4px 8px; margin: 0 0 6px; cursor: pointer; }
/* press-edges: pressed */
.quote { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.quote:active { opacity: .55; transition-duration: .06s; }
.quote-who { display: block; font-size: 12px; font-weight: 640; opacity: .85; }
.quote-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; opacity: .85; }
.is-flash .bubble, .card.is-flash { animation: reply-flash 1.5s ease-out; }
@keyframes reply-flash { 0%, 40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.reply-strip { display: flex; align-items: center; gap: 8px; margin: 0 6px 6px; padding: 6px 6px 6px 10px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 8px; font-size: 13px; }
.reply-strip[hidden] { display: none; }
.reply-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-who { font-weight: 640; font-size: 12px; color: var(--accent-strong); }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* "Waiting for you" strip above the composer (web/ui-chat.js) */
.waiting-strip { display: flex; flex-direction: column; gap: 2px; margin: 0 6px 6px; padding: 6px 10px; border-radius: 10px; background: color-mix(in srgb, var(--wait-ink) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--wait-ink) 35%, var(--line)); font-size: 13px; }
.waiting-strip[hidden] { display: none; }
.wait-head { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; color: var(--wait-ink); }
.wait-line { border: 0; background: none; padding: 3px 0; min-height: 28px; text-align: left; font: inherit; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
/* press-edges: pressed */
.wait-line { -webkit-tap-highlight-color: transparent; transition: opacity .18s ease-out; }
.wait-line:active { opacity: .55; transition-duration: .06s; }
.wait-more { font-size: 12px; color: var(--muted); }
@media (max-width: 700px) { .waiting-strip { max-height: 6.2em; overflow: hidden; } }

/* ---------- one-agent mode (ENGINE=codex): the agent, her chats, one box. Two columns, no screen, no team. Last, so it wins. ---------- */
#app[data-mode="oneagent"] { grid-template-columns: var(--side-w) minmax(0, 1fr); }
#app[data-mode="oneagent"] #screen-panel, #app[data-mode="oneagent"] .head-screen, #app[data-mode="oneagent"] .new-bot, #app[data-mode="oneagent"] .side-foot, #app[data-mode="oneagent"] #tab-screen { display: none !important; }
.side-label { margin: 12px 20px 2px; font-size: 12.8px; font-weight: 600; color: var(--muted); flex: none; }
.chat-tile { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--muted); box-shadow: 0 0 0 1px var(--line); }
.home-ask { flex: none; max-width: none; padding: 6px 10px 12px; }
.home-hello { flex: 1; }
@media (max-width: 700px) {
  #app[data-mode="oneagent"] { grid-template-columns: minmax(0, 1fr); }
  #app[data-mode="oneagent"] .head-title { display: block; }
}

/* ---------- take-over view (web/ui-screen.js openTakeoverView): the shop's page at phone size, the box she types in under it. Dark first, built for 390 wide. ----------
   The root is fixed to the part of the phone she can see (script sets left, top, width, height from visualViewport), so it follows her keyboard up and down. */
.tk { position: fixed; z-index: 1000; display: flex; flex-direction: column; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
.tk-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: env(safe-area-inset-top, 0px) 6px 0 12px; }
.tk-title { flex: 1; min-width: 0; font-weight: 640; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-ask { flex: none; padding: 0 14px 8px; }
.tk-instr { font-size: 14px; line-height: 1.35; }
.tk-small { margin-top: 2px; font-size: 12px; line-height: 1.3; color: var(--muted); }
/* the page area: whatever is left. The crop shows the page at full size; nothing in it is ever scaled. */
.tk-page { position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; background: var(--screen-bg); }
.tk-crop { position: absolute; left: 0; top: 0; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tk-frame { position: absolute; }
.tk.is-whole .tk-crop { inset: 0; }
.tk.is-whole .tk-frame { inset: 0; }
.tk-overlay { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 22px; text-align: center; color: #CFC9BC; background: color-mix(in srgb, var(--screen-bg) 94%, transparent); font-size: 13.5px; }
.tk .type-bar { flex: none; width: 100%; padding: 8px 10px 0; gap: 6px; }
.tk .tb-input { min-height: 44px; }
.tk .tb-input::placeholder { font-size: 13px; } /* the input itself stays 16px (iOS zooms below that); the long placeholder fits at 390 wide */
.tk .tb-keys { flex-wrap: nowrap; }
.tk .tb-key { min-height: 40px; }
.tk-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
.tk-foot .btn-primary { flex: 1; min-height: 44px; }
.tk-foot .btn-quiet { min-height: 44px; }
.tk-q { width: 44px; padding: 0; }
.tk-help { flex: none; padding: 0 14px 10px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.tk-link { border: 0; background: none; padding: 4px 0; color: var(--accent-strong); font-size: 13px; font-weight: 550; text-align: left; }
/* her keyboard is up: only the header, the page, the type box and the keys */
.tk.is-kb .tk-ask, .tk.is-kb .tk-foot, .tk.is-kb .tk-help { display: none; }
.tk.is-kb .type-bar { padding-bottom: 8px; }
