/* Flow: the session as a running log on a time rail. Paper, ink, hairlines, one amber.
   Values come from tokens.css; every transition and animation lives in motion.css.
   Hover styles only under (hover: hover); touch sizes under (pointer: coarse), (hover: none). */

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  font: var(--fs-base)/var(--lh) var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow-x: clip;
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button, a, summary, label, [role="button"] { touch-action: manipulation; }
textarea, input, select { font: inherit; color: inherit; }
/* Focus rings only while the person moves with the keyboard (body.kb-nav, set in app.js). Safari also matches
   :focus-visible on a focus set by script (the Orb, a menu item, a card after a double click), which drew black frames
   around things nobody tabbed to. Text fields keep their editing state: that is a fill and an edge, not an outline. */
body.kb-nav :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
body.kb-nav :is(textarea, input):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus-visible { outline: none; }
body:not(.kb-nav) :focus-visible { outline: none !important; }
body:not(.kb-nav) :is(.ui-select > select, .sel > select, .ui-menu-item):focus-visible { box-shadow: none; }
::selection { background: color-mix(in srgb, var(--ink) 14%, transparent); }

/* ---------- shell ---------- */
#app {
  display: flex; height: 100dvh; width: 100%; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: var(--panel);
}
#scrim { display: none; position: fixed; inset: 0; background: var(--scrim); touch-action: none; }
/* a phone sheet is open (app.js syncLayers): the page behind is inert and the document neither scrolls nor bounces */
html.is-locked, html.is-locked body { overflow: hidden; overscroll-behavior: none; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; position: relative; background: var(--paper); }
/* position: relative so a route's fade can lift the page through `top` (a transform would capture fixed layers inside it) */
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* ---------- sidebar (DESIGN-V2 section 5): the panel; no border to the page, the tone step is the edge ---------- */
#sidebar { width: var(--sidebar-w); flex: 0 0 auto; background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
body.sb-closed #sidebar { display: none; }
.sb-top { display: flex; align-items: center; gap: var(--sp-0h); height: var(--topbar-h); padding: 0 var(--sp-2); flex: 0 0 auto; }
.sb-title { flex: 1; min-width: 0; padding: 0 var(--sp-1h); font-size: var(--fs-md); font-weight: var(--w-semibold); line-height: var(--h-sm); color: var(--ink-2); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: var(--r-sm); }
.sb-top .ui-btn--icon { color: var(--ink-3); }

/* the rail: one row. The page's own item is a flat --active fill with its label; the others are icons with a tooltip.
   Inbox carries its count at the icon's upper right, ringed by the panel (amber while something needs Stevie). */
.sb-rail { display: flex; align-items: center; gap: var(--sp-0h); padding: 0 var(--sp-2) var(--sp-2); flex: 0 0 auto; min-width: 0; }
.rail-i { position: relative; flex: 1 1 0; min-width: 32px; height: var(--h-nav); display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1h); padding: 0; border-radius: var(--r-sm); color: var(--ink-3); text-decoration: none; }
.rail-i > svg, .rail-i > .ui-icon { flex: none; display: block; }
.rail-l { display: none; }
.rail-i.active { flex: 0 1 auto; padding: 0 var(--sp-2h) 0 var(--sp-2); min-width: 0; color: var(--ink); background: var(--active); }
.rail-i.active .rail-l { display: block; min-width: 0; font-size: var(--fs-sm); font-weight: var(--w-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-n { position: absolute; top: 1px; left: calc(50% + 3px); pointer-events: none; box-shadow: 0 0 0 2px var(--panel); }
.rail-n:empty { display: none; }
.rail-i.active .rail-n { position: static; box-shadow: none; }

/* one scroller under the rail: the module slot (AS.hooks.sidebar, empty) and the panes */
.sb-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--sp-2) var(--sp-4); position: relative; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sb-scroll:hover { scrollbar-color: var(--rule-2) transparent; }
.sb-hooks:empty { display: none; }
.sb-sec:first-of-type .ui-nav-sec { margin-top: var(--sp-1); }
.sb-sec-h { padding: 0 var(--sp-1) 0 var(--sp-2); }
.sb-list { position: relative; display: flex; flex-direction: column; gap: 1px; }
.sb-empty { font-size: var(--fs-sm); color: var(--ink-3); padding: var(--sp-1) var(--sp-2); line-height: var(--lh); }

/* chat rows (.ui-nav): lead slot (Orb, unread dot, pin), title 400, time; the time and More trade places on hover */
.s-item { padding-right: var(--sp-1h); }
.s-item .ui-nav-label { color: inherit; }
.s-item.active .ui-nav-label { font-weight: var(--w-medium); }
.s-lead > as-orb { display: block; }
.s-pin { display: inline-flex; color: var(--ink-4); }
.s-pin > svg { display: block; }
.s-trail { min-width: 24px; justify-content: flex-end; }
.s-item.is-unread .s-time { color: var(--ink-2); }
.s-item.archived .ui-nav-label { color: var(--ink-3); }
.s-more { position: absolute; right: 3px; top: 50%; margin-top: -12px; display: inline-flex; align-items: center; justify-content: center; width: var(--h-xs); height: var(--h-xs); border-radius: var(--r-sm); color: var(--ink-3); opacity: 0; }
.s-more:focus-visible { opacity: 1; outline: 2px solid var(--focus); outline-offset: -2px; }
.s-item.active .s-more { opacity: 1; }
.s-item.active .s-time { opacity: 0; }

.sp-row { padding-right: 0; }
/* New space: a quiet row that becomes a field in place */
.sb-add { width: 100%; border: 0; background: none; font: inherit; font-size: var(--fs-md); color: var(--ink-3); text-align: left; }
.sb-add .ui-nav-lead { color: var(--ink-4); }
.sp-new-wrap { margin-top: 1px; }
.sp-form { padding: 1px 0 var(--sp-1); }
.sp-input.ui-input { height: var(--h-nav); padding: 0 var(--sp-2); }
.sp-err { font-size: var(--fs-xs); color: var(--err); padding: var(--sp-1) var(--sp-2) 0; line-height: var(--lh-snug); }
.sp-err:empty { display: none; }

.sb-n { flex: none; font-size: var(--fs-xs); color: var(--ink-3); }
.sb-n:empty { display: none; }

/* the foot: Agents, then the profile row (avatar, name, the settings glyph); one line each */
.sb-foot { display: flex; flex-direction: column; gap: 1px; padding: var(--sp-2) var(--sp-2) calc(var(--sp-2) + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule-soft); flex: 0 0 auto; }
.foot-link .ui-nav-label { font-weight: var(--w-medium); color: var(--ink); }
.foot-link .ui-nav-lead { width: 20px; height: 20px; margin: 0 -2px; }
.foot-gear { color: var(--ink-4); }
.foot-link.active .foot-gear { color: var(--ink-3); }
/* V1 avatar (modules may still draw one): neutral, never a black disc */
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; background: var(--g-150); color: var(--ink-2); font-weight: var(--w-semibold); font-size: var(--fs-sm); flex: none; }
.avatar.big { width: 64px; height: 64px; font-size: var(--fs-2xl); }
.foot-nav { display: none; }

/* ---------- top bar ---------- */
#topbar { height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3) 0 var(--sp-2h); flex: 0 0 auto; border-bottom: 1px solid var(--rule); min-width: 0; }
/* the phone's way up one level (AS.setCrumbs); the full crumbs say the same on wider screens */
#crumbs > .crumb-back { display: none; } /* the id outranks `.crumbs a:not(.ui-crumb)` below, which showed it on desktop */
#sb-open { display: none; margin-right: calc(-1 * var(--sp-1)); color: var(--ink-3); }
body.sb-closed #sb-open { display: inline-flex; }
/* the crumbs: V2 .ui-crumb nodes from AS.setCrumbs, and the V1 markup modules still write (b, span > a, .sep) */
.crumbs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; overflow: hidden; }
/* earlier crumbs give way a hundred times faster than the title, which truncates last */
.crumbs > * { flex: 0 100 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs > :last-child { flex: 0 1 auto; }
.crumbs > .sep, .crumbs > .ui-crumb-sep { flex: none; overflow: visible; color: var(--ink-4); padding: 0 1px; }
.crumbs > span:not(.ui-crumb):not(.sep):not(.ui-crumb-sep) { display: inline-flex; }
.crumbs a:not(.ui-crumb), .crumb-link { display: inline-flex; align-items: center; height: var(--h-sm); padding: 0 var(--sp-1h); border-radius: var(--r-sm); color: inherit; text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crumbs > span:not(.ui-crumb):not(.sep):not(.ui-crumb-sep):not(:has(a)) { padding: 0 var(--sp-1h); }
.crumbs b { display: inline-flex; align-items: center; height: var(--h-sm); padding: 0 var(--sp-1h); color: var(--ink); font-weight: var(--w-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the chat's title: the rename button, with a chevron that shows on hover */
.title-edit { display: inline-flex; align-items: center; gap: var(--sp-1); cursor: pointer; }
.title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-chev { display: inline-flex; flex: none; color: var(--ink-4); opacity: 0; }
.title-edit:focus-visible .title-chev { opacity: 1; }
.title-edit:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.title-input { height: var(--h-sm); min-width: 220px; max-width: 100%; padding: 0 var(--sp-1h); border: 1px solid var(--rule-2); border-radius: var(--r-sm); background: var(--raised); box-shadow: var(--focus-halo); outline: 0; font: inherit; font-size: max(var(--field-min), var(--fs-md)); font-weight: var(--w-medium); color: var(--ink); }

/* the right side: a fixed status slot, then quiet 28 px buttons 2 apart */
.top-right { display: flex; gap: var(--sp-0h); align-items: center; flex: none; font-size: var(--fs-sm); color: var(--ink-3); white-space: nowrap; }
.top-right .ui-btn { color: var(--ink-3); }
.top-right .ui-btn[aria-pressed="true"], .top-right .ui-btn[aria-expanded="true"] { color: var(--ink); }
/* status: Needs you (amber pill), the Orb alone while working, Error, Reconnecting; nothing when idle (quiet is the default) */
.s-head .s-state { border: 0; font: inherit; cursor: default; }
.s-head .s-state.needs { cursor: pointer; }
.s-head .s-state.reconnecting { background: none; color: var(--ink-3); }
.s-head .s-state.needs:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* background tasks: a fixed slot; the button fades in while something runs */
.tb-tasks { min-width: 44px; visibility: hidden; opacity: 0; }
.tb-tasks.on { visibility: visible; opacity: 1; }
.tb-tasks-n { font-weight: var(--w-semibold); color: var(--ink); font-variant-numeric: tabular-nums; }
/* the Git slot: git.js renders one control into it (DESIGN-V2 6.1); nothing at all without a repository */
.tb-slot { display: inline-flex; align-items: center; flex: none; min-width: 0; max-width: 180px; }
/* (never display: none while it holds something: git.js moves its chip out of a slot it cannot see) */
.tb-slot:empty { display: none; }
.tb-slot > .git-chip.dim { display: none; }
.top-right > .git-bar { display: none !important; }
.tb-slot > .fchip { height: var(--h-sm); padding: 0 var(--sp-2); border-radius: var(--r-sm); background: transparent; color: var(--ink-3); font-size: var(--fs-sm); font-weight: var(--w-medium); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-details .ui-btn-count:empty { display: none; }
.ptab-n:empty { display: none; }
/* while the top bar has a status pill, the title still truncates first */

/* ---------- boot: new version pill and transcript-shaped placeholders ---------- */
.update-pill { position: fixed; z-index: var(--z-side); left: 50%; top: calc(var(--topbar-h) + env(safe-area-inset-top) + 10px); transform: translateX(-50%); display: inline-flex; align-items: center; gap: var(--sp-2h); padding: var(--sp-1) var(--sp-1) var(--sp-1) 14px; background: var(--float); color: var(--ink-2); border-radius: var(--r-md); box-shadow: var(--e-ring), var(--e-float); font-size: var(--fs-md); white-space: nowrap; }
.update-pill-text { color: var(--ink-2); }
.update-pill-btn { position: relative; height: var(--h-sm); padding: 0 var(--sp-2h); border-radius: var(--r-sm); background: var(--ink); color: var(--paper); font-size: var(--fs-sm); font-weight: var(--w-medium); }
.update-pill-btn:disabled { opacity: .6; }
.e-skel .e-c { display: flex; flex-direction: column; gap: 9px; padding: var(--sp-1) 0 10px; }
.skel { background: var(--pane); border-radius: var(--r-xs); }
.skel-line { height: 10px; }
.skel-w1 { width: 94%; } .skel-w2 { width: 82%; } .skel-w3 { width: 58%; } .skel-w4 { width: 36%; }
.skel-user { height: 40px; width: 62%; border-radius: var(--r-md); }
.skel-step { height: 12px; width: 44%; }

/* ---------- V1 control classes, restyled as their V2 counterparts (DESIGN-V2 9.1.7) ----------
   Modules still draw these; they now look exactly like .ui-btn--icon (28 ghost), --primary, --secondary and .ui-chip. */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--h-sm); height: var(--h-sm); border-radius: var(--r-sm); color: var(--ink-3); }
.icon-btn.small { width: var(--h-sm); height: var(--h-sm); }
.icon-btn > svg { display: block; }
.btn-ink, .btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1h); height: var(--h-md); padding: 0 var(--sp-3); border: 1px solid transparent; border-radius: var(--r-sm); font-size: var(--fs-md); font-weight: var(--w-medium); line-height: 1; white-space: nowrap; text-decoration: none; }
.btn-ink { background: var(--ink); color: var(--paper); box-shadow: var(--e-xs); }
.btn-ink:disabled { opacity: .4; cursor: default; box-shadow: none; }
.btn-ghost { background: var(--raised); color: var(--ink); border-color: var(--rule-2); box-shadow: var(--e-xs); }
.btn-ghost:disabled { opacity: .4; cursor: default; box-shadow: none; }
.btn-ghost.small, .btn-ink.small { height: var(--h-sm); padding: 0 var(--sp-2); gap: var(--sp-1); font-size: var(--fs-sm); margin-top: var(--sp-1h); }
.btn-ink:focus-visible, .btn-ghost:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.linkbtn { font-size: var(--fs-xs); color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-4); }

/* ---------- /new (and Home without home.js): the hero Orb, the title, one quiet line, the composer ---------- */
.home { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-8) var(--page-pad) var(--sp-8); }
.home-inner { max-width: 680px; margin: 0 auto; }
.home-orb { display: flex; justify-content: center; margin: 0 0 var(--sp-6); }
.home .home-title { margin: 0; }
.home .lede { margin: var(--sp-1h) 0 var(--sp-6); max-width: 64ch; }
.home .composer { padding: 0; border: 0; background: none; position: static; }
.home .c-inner { max-width: none; }
.home .c-box { background: var(--raised); -webkit-backdrop-filter: none; backdrop-filter: none; --c-surface: var(--raised); }

/* ---------- the rail ---------- */
.transcript { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-5) var(--sp-5) 160px; scroll-behavior: smooth; }
.fade { position: absolute; left: 0; right: 0; bottom: 0; height: 150px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--paper) 55%); }
.rail { --rail-x: 18px; max-width: var(--measure); margin: 0 auto; position: relative; padding-left: var(--gutter); }
.rail::before { content: ""; position: absolute; top: var(--sp-3); bottom: 0; left: calc(var(--gutter) - var(--rail-x)); width: 1px; background: var(--rule); }
.e { position: relative; padding: 6px 0; }
.e-t { position: absolute; left: calc(-1 * var(--gutter)); top: 9px; width: calc(var(--gutter) - 30px); text-align: right; font-size: var(--fs-xs); color: var(--ink-3); line-height: var(--lh); white-space: nowrap; }

/* rail markers: ink square for your prompt, ring for a step, amber diamond for a permission */
.rail > .e-user::after, .rail > .e-step::after, .rail > .e-perm::after {
  content: ""; position: absolute; left: calc(-1 * var(--rail-x) - 3px); width: 7px; height: 7px; box-sizing: border-box;
}
.rail > .e-user::after { top: 24px; background: var(--ink); border-radius: 1.5px; }
.rail > .e-user > .e-t { top: 18px; }
.rail > .e-usercmd::after { top: 18px; }
.rail > .e-usercmd > .e-t { top: 13px; }
.rail > .e-step::after { top: 12px; border-radius: 50%; border: 1px solid var(--ink-3); background: var(--paper); }
.rail > .e-step:has(> .e-c > .step-head > .step-state.run)::after { border-color: var(--ink); border-width: 1.5px; }
.rail > .e-step:has(> .e-c > .step-head > .step-state.err)::after { border-color: var(--err); background: var(--err); }
.rail > .e-perm::after { top: 16px; width: 6px; height: 6px; left: calc(-1 * var(--rail-x) - 2.5px); background: var(--amber); transform: rotate(45deg); }
.rail > .e-perm:has(> .e-c > .perm.done)::after { background: var(--rule-2); }
.sub-transcript .rail { padding-left: 0; }
.sub-transcript .rail::before, .sub-transcript .rail > .e::after { display: none; }

/* your prompt */
.e-user .e-c { background: var(--pane); border-radius: var(--r-md); padding: var(--sp-2h) 14px; font-size: var(--fs-prose); line-height: var(--lh); white-space: pre-wrap; overflow-wrap: anywhere; }
.e-usercmd .e-c { font-family: var(--mono); font-size: var(--fs-sm); padding: 6px var(--sp-3); display: inline-block; }
.u-imgs { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: 6px; }
.u-img { max-width: 220px; max-height: 220px; border-radius: var(--r-md); display: block; }
/* attached PDFs and text files: a quiet raised chip with the file name */
.u-files { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: 6px; white-space: normal; }
.u-file { display: inline-flex; align-items: baseline; gap: var(--sp-1h); max-width: 100%; min-width: 0; padding: 3px var(--sp-2h); border-radius: var(--r-sm); background: var(--raised); box-shadow: var(--e-ring); }
.u-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--fs-xs)/var(--lh) var(--mono); color: var(--ink); }
.u-file-kind { flex: none; font-size: var(--fs-xs); color: var(--ink-3); }

/* edit an earlier message: "Edit" sits in the gutter where the time is and trades places with it on hover */
.e-user > .u-edit { position: absolute; left: calc(-1 * var(--gutter)); top: 18px; width: calc(var(--gutter) - 30px); text-align: right; font-size: var(--fs-xs); line-height: var(--lh); color: var(--ink-3); opacity: 0; white-space: nowrap; }
.e-user > .u-edit:focus-visible { opacity: 1; }
.e-user.is-editing > .u-edit, .e-user.is-editing > .e-t { opacity: 0; pointer-events: none; }
.e-user.is-editing > .e-c { background: var(--raised); box-shadow: var(--e-ring), var(--e-xs); white-space: normal; }
.u-edit-ta { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; padding: 0; font: inherit; font-size: max(var(--field-min), var(--fs-prose)); line-height: var(--lh); color: var(--ink); }
.u-edit-note { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--ink-3); }
.u-edit-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-3); }

/* messages waiting for the agent: greyed at the end of the log with Send now and Remove */
.e-user.is-queued > .e-c { opacity: .55; }
.e-user.is-queued.is-now > .e-c { opacity: .75; }
.q-acts { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--sp-3); margin-top: 6px; font-size: var(--fs-xs); color: var(--ink-3); }
.q-label { color: var(--ink-3); }

/* agent prose */
.e-ai .e-c { overflow-wrap: break-word; font-size: var(--fs-lg); line-height: var(--lh-prose); max-width: 70ch; }
.e-ai p { margin: 0 0 var(--sp-3); }
.e-ai p:last-child { margin-bottom: 0; }
.e-ai h1, .e-ai h2, .e-ai h3 { margin: var(--sp-5) 0 var(--sp-1h); line-height: 1.3; font-weight: var(--w-semibold); }
.e-ai h1, .e-ai h2 { font-size: var(--fs-xl); letter-spacing: var(--track-title); }
.e-ai h3 { font-size: var(--fs-lg); }
.e-ai > .e-c > :first-child { margin-top: 0; }
.e-ai ul, .e-ai ol { margin: 6px 0 var(--sp-3); padding-left: 22px; }
.e-ai li { margin: 3px 0; }
.e-ai li::marker { color: var(--ink-3); }
.e-ai code { font: 0.875em/var(--lh) var(--mono); background: var(--pane); padding: 1px 5px; border-radius: var(--r-xs); }
.e-ai pre { background: var(--pane); border-radius: var(--r-md); padding: 14px var(--sp-4); overflow-x: auto; margin: var(--sp-2) 0 var(--sp-3); }
.e-ai pre code { background: none; padding: 0; font-size: var(--fs-sm); line-height: 1.6; }
.e-ai table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: var(--sp-2) 0 var(--sp-3); font-size: var(--fs-md); line-height: var(--lh); }
.e-ai th, .e-ai td { border-bottom: 1px solid var(--rule); padding: 6px 10px; text-align: left; }
.e-ai th { color: var(--ink-3); font-weight: var(--w-medium); font-size: var(--fs-sm); }
.e-ai blockquote { margin: var(--sp-2) 0; padding: 2px 14px; border-left: 2px solid var(--rule-2); color: var(--ink-2); }
.e-ai hr { border: 0; border-top: 1px solid var(--rule); margin: var(--sp-4) 0; }
.e-ai a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-4); }
.md-img { max-width: 100%; border-radius: var(--r-md); display: block; margin: var(--sp-2) 0; }

/* steps: ledger lines that open in place (grid rows 0fr to 1fr) */
.e-step { padding: 2px 0; }
.e-step > .e-c { display: grid; grid-template-rows: auto 0fr; min-width: 0; }
.e-step.open > .e-c, body.detail-all .e-step > .e-c { grid-template-rows: auto 1fr; }
.step-head { display: flex; align-items: baseline; gap: var(--sp-2h); min-width: 0; min-height: var(--h-sm); padding: var(--sp-1) var(--sp-1h) var(--sp-1) 0; cursor: pointer; font-size: var(--fs-md); color: var(--ink-2); border-radius: var(--r-sm); }
.step-head:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.step-name { font-weight: var(--w-medium); color: var(--ink); flex: 0 0 auto; min-width: 54px; }
.step-sum { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-3); }
.step-sum.link { cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.step-state { flex: 0 0 auto; font-size: var(--fs-xs); color: var(--ink-3); }
.step-state:empty { display: none; }
.step-state.run { color: var(--ink-2); }
.step-state.err { color: var(--err); }
.step-chev { flex: 0 0 auto; align-self: center; display: inline-flex; color: var(--ink-4); margin-left: 2px; }
.step-chev > svg { display: block; }
.e-step.open > .e-c > .step-head .step-chev { transform: rotate(90deg); }
.step-body { min-height: 0; overflow: hidden; visibility: hidden; font-size: var(--fs-sm); }
.e-step.open > .e-c > .step-body, body.detail-all .step-body { visibility: visible; }
.step-body > :first-child { margin-top: 2px; }
.step-body > :last-child { margin-bottom: 10px; }
.step-body pre { margin: var(--sp-1) 0 0; padding: var(--sp-2h) var(--sp-3); background: var(--pane); border-radius: var(--r-md); overflow: auto; font: var(--fs-xs)/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 420px; }
.step-label { color: var(--ink-3); font-size: var(--fs-xs); margin-top: var(--sp-2); }
.e.sub .e-c { margin-left: var(--sp-4); }
.e-step.sub .step-name { color: var(--ink-2); }
.sublog { margin: var(--sp-1) 0 0; padding-left: var(--sp-2h); border-left: 1px solid var(--rule); }
.sublog .e { padding: 2px 0; }
.sublog .e-t { display: none; }
.sublog .e-ai .e-c { font-size: var(--fs-md); color: var(--ink-2); }
.sublog .step-head { min-height: 26px; font-size: var(--fs-sm); }

/* system lines, thinking, commands */
.e-sys .e-c { font-size: var(--fs-xs); color: var(--ink-3); }
.thinking > .e-c { display: grid; grid-template-rows: auto 0fr; font-size: var(--fs-sm); color: var(--ink-3); cursor: pointer; }
.thinking.open > .e-c, body.detail-all .thinking > .e-c { grid-template-rows: auto 1fr; }
.thinking pre { min-height: 0; overflow: hidden; visibility: hidden; margin: 0; white-space: pre-wrap; font: var(--fs-md)/1.55 var(--font); color: var(--ink-2); }
.thinking pre::before { content: ""; display: block; height: 6px; }
.thinking.open > .e-c > pre, body.detail-all .thinking pre { visibility: visible; }
.e-cmd pre { margin: 0; padding: 10px var(--sp-3); background: var(--pane); border-radius: var(--r-md); font: var(--fs-xs)/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 480px; overflow: auto; }

/* the working row: the orb is the only thing on screen that moves */
.e-work .e-c { display: flex; align-items: center; gap: var(--sp-2h); color: var(--ink-3); font-size: var(--fs-sm); min-height: var(--h-sm); min-width: 0; }
.e-work .work-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* questions, plans, todos, result line */
.question { margin: var(--sp-2) 0 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; cursor: pointer; font-size: var(--fs-md); }
.opt input { margin-top: 4px; accent-color: var(--ink); }
.opt-other { width: 100%; height: var(--h-md); border: 1px solid var(--rule-2); border-radius: var(--r-sm); padding: 0 var(--sp-2h); background: var(--raised); box-shadow: var(--e-xs); margin-top: var(--sp-1); font-size: max(var(--field-min), var(--fs-md)); }
.opt-other:focus { outline: 0; border-color: var(--ink-3); box-shadow: var(--focus-halo); }
.plan { font-size: var(--fs-md); margin: var(--sp-1h) 0 var(--sp-3); padding: var(--sp-2h) 14px; background: var(--pane); border-radius: var(--r-md); max-height: 420px; overflow: auto; }
.todos { list-style: none; margin: var(--sp-1) 0 6px; padding: 0; }
.todo { display: flex; gap: 10px; align-items: baseline; padding: 3px 0; font-size: var(--fs-md); color: var(--ink-2); }
.todo-mark { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--rule-2); flex: 0 0 auto; align-self: center; }
.todo.completed { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--rule-2); }
.todo.completed .todo-mark { background: var(--ink-3); border-color: var(--ink-3); }
.todo.in_progress { color: var(--ink); }
.todo.in_progress .todo-mark { border-color: var(--ink); border-width: 2px; }
.e-result .e-c { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-3); padding-top: 2px; }
.e-result .e-c span:first-child { color: var(--ink-2); }

/* permission: the rail stops here; the request gets a thin amber edge all around */
.perm { padding: 2px 0 var(--sp-1); }
.perm-title { font-weight: var(--w-semibold); margin-bottom: 2px; }
.perm-sub { font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: var(--sp-2); }
.perm pre { margin: 6px 0 var(--sp-3); font: var(--fs-xs)/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--pane); border-radius: var(--r-md); padding: 10px var(--sp-3); max-height: 260px; overflow: auto; box-shadow: inset 0 0 0 1px var(--amber-line); }
.perm-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.perm-actions > .btn-ghost, .perm-actions > .btn-ink { max-width: 100%; }
.perm-always { display: inline-flex; align-items: center; gap: 0; min-width: 0; white-space: pre; overflow: hidden; }
.perm-always code { font: var(--fs-xs)/16px var(--mono); color: var(--ink); min-width: 0; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perm-reason { display: block; width: 100%; max-width: 560px; min-height: var(--h-md); margin: 0 0 var(--sp-3); padding: var(--sp-1h) var(--sp-2h); border: 1px solid var(--rule-2); border-radius: var(--r-sm); background: var(--raised); box-shadow: var(--e-xs); color: var(--ink); font: inherit; font-size: max(var(--field-min), var(--fs-md)); line-height: var(--lh-snug); resize: none; }
.perm-reason::placeholder { color: var(--ink-4); }
.perm-reason:focus { outline: 0; border-color: var(--ink-3); box-shadow: var(--focus-halo); }
.perm-done { margin-bottom: 0; }
.perm.done .perm-title { color: var(--ink-2); }
.perm.done pre { box-shadow: none; }

/* ---------- composer: the one glass element (DESIGN-V2 6.3) ---------- */
.composer { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 var(--sp-5) calc(var(--sp-4) + env(safe-area-inset-bottom)); pointer-events: none; z-index: 2; }
.c-inner { max-width: var(--measure); min-width: 0; margin: 0 auto; pointer-events: auto; }
.c-box {
  --c-gap: var(--sp-1); --c-surface: var(--glass-solid);
  position: relative; min-width: 0; max-width: 100%;
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) var(--sp-2) var(--sp-4);
  background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--rule); border-radius: var(--r-xl); box-shadow: var(--e-composer);
}
.c-box:focus-within { border-color: color-mix(in srgb, var(--ink) 22%, transparent); }
.c-box textarea { display: block; border: 0; outline: 0; resize: none; background: transparent; width: 100%; min-height: 24px; max-height: 220px; line-height: 1.5; padding: 0; font-size: max(var(--field-min), var(--fs-input)); color: var(--ink); }
.c-box textarea::placeholder { color: var(--ink-4); }
.c-row { margin-left: calc(-1 * var(--sp-2)); }

/* the context line above the box (a new chat): project, agent and account as quiet 24 px chips */
.c-context { display: flex; align-items: center; gap: var(--sp-1h); min-width: 0; margin: 0 0 var(--sp-2); padding: 3px var(--sp-1); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; font-size: var(--fs-sm); color: var(--ink-3); }
.c-context .chip { height: var(--h-xs); padding: 0 var(--sp-2) 0 var(--sp-2h); border-radius: var(--r-pill); background: var(--hover); color: var(--ink-2); }
.c-context .chip[aria-expanded="true"] { background: var(--active); color: var(--ink); }
.c-context::-webkit-scrollbar, .c-chips::-webkit-scrollbar, .c-row::-webkit-scrollbar { display: none; }
.c-context > * { flex: none; }

/* the row in the box: attach, chips, then context ring, stop and send, which never leave the box */
.c-row { display: flex; align-items: center; gap: var(--c-gap); min-width: 0; }
.c-row > * { flex: none; }
.c-row .spacer { flex: 1 1 0; min-width: 0; }
.c-chips { display: flex; align-items: center; gap: 2px; flex: 1 1 0; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; padding: 3px; margin: -3px; }
.c-chips > * { flex: none; }
/* today's flat markup: the whole row scrolls sideways under a pinned stop and send */
.c-row:not(:has(> .c-chips)) { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; padding: 3px; margin: -3px; }
.c-row:not(:has(> .c-chips)) > .c-send { position: sticky; right: 0; z-index: 1; border-radius: 0; background: radial-gradient(circle closest-side, var(--send-ink) calc(100% - 1px), transparent 100%), var(--c-surface); }
.c-row:not(:has(> .c-chips)) > .btn-ghost { position: sticky; right: calc(var(--send) + var(--c-gap)); z-index: 2; background-color: var(--c-surface); box-shadow: 0 0 0 6px var(--c-surface); }
.c-row:not(:has(> .c-chips)) > :is(.c-send, .btn-ghost)::before { content: ""; position: absolute; top: -3px; bottom: -3px; right: 100%; width: var(--c-gap); background: var(--c-surface); pointer-events: none; }
.c-row:not(:has(> .c-chips)) > .c-send::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: 100%; width: 4px; background: var(--c-surface); pointer-events: none; }
.c-row select { font-size: max(var(--field-min), var(--fs-sm)); color: var(--ink-2); background: transparent; border: 0; padding: 2px 0; max-width: 170px; cursor: pointer; appearance: none; -webkit-appearance: none; }
.c-row .sel:has(> select) { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--ink-3); font-size: var(--fs-sm); }
.c-row .sel:has(> select) svg { flex: 0 0 auto; }
.c-send { --send-ink: var(--ink); flex: none; position: relative; background: var(--send-ink); color: var(--paper); width: var(--send); height: var(--send); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.c-send svg { display: block; }
.c-send:disabled { --send-ink: color-mix(in srgb, var(--ink) 15%, var(--c-surface, var(--paper))); color: var(--ink-4); cursor: default; }
.c-send:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.c-hint { font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--sp-2); text-align: center; }
.home .c-hint { text-align: left; }
.c-err { font-size: var(--fs-sm); color: var(--err); margin-top: var(--sp-2); text-align: center; }
.home .c-err { text-align: left; }
.c-err:empty { display: none; }
.c-newproj { display: flex; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-2); flex-wrap: wrap; }
.c-newproj .ui-select { flex: none; }
.c-newproj .ui-input { flex: 1; width: auto; min-width: 140px; }

/* chips (the composer's mode, model and effort; module pickers): 28 high, 6 radius, 13/500; labels truncate, they
   never push the send button out */
.chip { display: inline-flex; align-items: center; gap: var(--sp-1); flex: none; height: var(--h-sm); max-width: 220px; padding: 0 var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: var(--w-medium); color: var(--ink-2); background: transparent; border: 1px solid transparent; white-space: nowrap; }
.chip-l { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chev { color: var(--ink-4); display: inline-flex; flex: none; }
.chip .chev > svg { display: block; }
.chip[aria-expanded="true"] { background: var(--active); color: var(--ink); }
.chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ring { display: inline-flex; line-height: 0; }
.ctx-ring { flex: none; display: inline-flex; align-items: center; gap: 5px; height: var(--h-sm); padding: 0 var(--sp-1h); border-radius: var(--r-sm); color: var(--ink-3); font-size: var(--fs-xs); }
.ctx-ring.warn { color: var(--amber); }
.ctx-pct:empty { display: none; }

/* dictation: the mic turns ink while it listens (no pulsing: the Orb is the only thing that keeps moving) */
.c-mic.is-on, .c-mic.is-on[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-radius: var(--r-pill); }
.c-box .ui-btn--icon { color: var(--ink-3); }
.c-mic.is-on:focus-visible { outline-offset: 3px; }

/* attachments */
.c-att { display: flex; gap: var(--sp-2); flex-wrap: wrap; padding: 2px 0 6px; }
.att { position: relative; display: inline-block; }
.att img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--rule); display: block; }
.att-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--paper); display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--c-surface, var(--paper)); }
.att-doc { display: inline-flex; flex-direction: column; justify-content: center; gap: 2px; height: 56px; max-width: 200px; min-width: 96px; padding: 0 var(--sp-3); border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--raised); }
.att-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--fs-xs)/1.35 var(--mono); color: var(--ink); }
.att-kind { font-size: var(--fs-xs); color: var(--ink-3); }
/* files dragged over the page land in the box */
.c-box.is-drop { border-color: var(--ink-3); box-shadow: var(--e-composer), var(--focus-halo); }

/* slash commands and @ files: a menu above the box (opaque, like every menu) */
.slash { position: absolute; left: 0; right: 0; bottom: calc(100% + var(--sp-2)); background: var(--float); border-radius: var(--r-lg); box-shadow: var(--e-ring), var(--e-float); max-height: 320px; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-1); }
.slash-item { display: flex; flex-direction: column; justify-content: center; gap: 1px; min-height: var(--h-md); padding: var(--sp-1h) var(--sp-2); border-radius: var(--r-sm); cursor: pointer; }
.slash-item.sel { background: var(--hover); }
.slash-name { font-size: var(--fs-md); font-weight: var(--w-medium); }
.slash-hint { font-weight: var(--w-regular); color: var(--ink-3); font-family: var(--mono); font-size: var(--fs-xs); }
.slash-desc { font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slash-desc.at-path { font-family: var(--mono); direction: rtl; text-align: left; } /* long paths keep their end */
.slash-empty { padding: var(--sp-1h) var(--sp-2); font-size: var(--fs-sm); color: var(--ink-3); }

/* ---------- popovers, menus, phone sheets: ui.css (.ui-pop, .ui-pop--bare, .ui-menu*, .ui-pop-body; round 4, L4) ----------
   switch rows (fast mode, thinking): AS.menu's { switch } items flip in place, the popover stays open */
.menu-switch { align-items: center; justify-content: space-between; }
.menu-switch:disabled { cursor: default; opacity: 1; }
.menu-switch:disabled .ms-text > :first-child, .menu-switch:disabled .ui-switch { opacity: .45; }
.ms-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.ms-hint { max-width: none; white-space: normal; }
/* V1 switch markup that modules may still draw looks like .ui-switch */
.switch { position: relative; flex: none; width: 30px; height: 18px; border-radius: var(--r-pill); background: var(--rule-2); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--g-0); box-shadow: var(--e-xs); }
.menu-switch[aria-checked="true"] .switch, .switch[aria-checked="true"] { background: var(--ink); }
.menu-switch[aria-checked="true"] .switch::after, .switch[aria-checked="true"]::after { transform: translateX(12px); }

/* ---------- the chat and its Details pane: one grid (DESIGN-V2 7.2) ----------
   From 1101 px the pane pushes: its track grows from 0 to --peek-w (motion.css) while the chat column re-wraps in place;
   the pane is laid out at its full width from the start and revealed by the track. Narrower it floats from the right
   (no scrim); on a phone it is a bottom sheet with a grab handle. */
.session { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--side-track, 0px); }
body.side-open .session { --side-track: var(--peek-w); }
body.side-open.side-full .session { --side-track: 100%; }
.session-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.session-main .transcript { flex: 1; }
#side { position: relative; display: block; min-width: 0; min-height: 0; overflow: hidden; border-left: 1px solid transparent; }
body.side-open #side, body.side-closing #side { border-left-color: var(--rule); }
/* AS.openSide's own panel (round 4, L3): a float from the right over the page (no dim; a click beside it closes it) or a
   bottom sheet over a dim (mode 'sheet', and every mode on a phone) with the grabber AS.ui.dragSheet follows. */
.side-scrim--clear { background: transparent; }
.ui-peek.side-own { position: fixed; z-index: calc(var(--z-sheet) + 1); height: auto; overflow: hidden; font-size: var(--fs-md); }
.ui-peek.side-own--float {
  top: calc(var(--inset) + env(safe-area-inset-top)); right: calc(var(--inset) + env(safe-area-inset-right)); bottom: calc(var(--inset) + env(safe-area-inset-bottom));
  width: min(calc(100vw - 2 * var(--inset)), var(--side-own-w, var(--peek-w)));
}
.ui-peek.side-own--sheet {
  left: max(calc(var(--inset) + env(safe-area-inset-left)), calc(50% - 360px)); right: max(calc(var(--inset) + env(safe-area-inset-right)), calc(50% - 360px)); bottom: calc(var(--inset) + env(safe-area-inset-bottom));
  top: calc(10vh + env(safe-area-inset-top)); border-radius: var(--r-sheet); box-shadow: var(--e-ring), var(--e-3);
  transition: transform var(--d3) var(--ease-move), opacity var(--d2) var(--ease-std);
}
@starting-style { .ui-peek.side-own--sheet { transform: translateY(var(--m-sheet)); opacity: 0; } }
.ui-peek.side-own--sheet.is-dragging { transition: none; }
.ui-peek.side-own--sheet.is-leaving { animation: sheet-out var(--d3-out) var(--ease-in) both; pointer-events: none; }
.ui-peek.side-own--sheet.is-swiped.is-leaving { animation: none; transform: translateY(100%); transition: transform var(--d3-out) var(--ease-in); }
.side-own--sheet > .ui-sheet-grab { flex: none; }
.side-own--sheet > .ui-peek-head { touch-action: none; }
body.kb-open .ui-peek.side-own { bottom: calc(var(--kb, 0px) + var(--inset)); max-height: calc(var(--vvh, 80vh) - env(safe-area-inset-top) - 2 * var(--inset)); }
#side > .ui-peek { position: absolute; top: 0; left: 0; bottom: 0; width: var(--peek-w); opacity: 0; }
body.side-open #side > .ui-peek { opacity: 1; }
body.side-full #side > .ui-peek { width: 100%; right: 0; }
#side .ui-sheet-grab { display: none; }
.ui-peek-head .side-back { margin-left: calc(-1 * var(--sp-2)); }
.side-peek .ui-peek-body { max-width: none; padding: var(--sp-4) var(--sp-4) var(--sp-8); }
.side-body { font-size: var(--fs-md); }
.side-peek .ui-peek-head { padding-left: var(--sp-4); }
.side-sub { margin: 0 0 var(--sp-3); font-size: var(--fs-xs); color: var(--ink-3); }
/* sections inside the pane: 12/500 ink-3 headers, quiet lists of rows */
.pane-h { display: flex; align-items: baseline; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-1); padding: 0; font-size: var(--fs-xs); font-weight: var(--w-medium); color: var(--ink-3); }
.pane-h:first-child { margin-top: 0; }
.pane-list { margin: 0 calc(-1 * var(--sp-2)); }
.pane-list > .pane-empty, .pane-body > .pane-empty { padding: var(--sp-1) var(--sp-2); }
.pane-body > .pane-empty { padding-left: 0; }
.pane-empty { margin: 0; }
.p-file.ui-row { width: 100%; min-height: var(--h-row); border: 0; background: none; font: inherit; text-align: left; }
.p-file.ui-row .ui-row-title { font-size: var(--fs-md); }
.p-file.ui-row .ui-row-sub { flex: 0 1 auto; max-width: 55%; direction: rtl; text-align: left; }
.pane-info > .ui-props { margin-top: 0; }
.pane-info .ui-prop-k { flex-basis: 136px; }
.pane-info .ui-peek-sec { margin-top: var(--sp-4); padding-top: var(--sp-4); }
.pane-info .ui-peek-sec-h { padding: 0; margin-bottom: var(--sp-2); }
.ui-prop-v.pane-mono { font: var(--fs-sm)/20px var(--mono); color: var(--ink-2); }
.pane-link { color: inherit; text-decoration: underline; text-decoration-color: var(--ink-4); text-underline-offset: 3px; }
/* V1 pane markup modules still draw (git, diff, config): property rows, lists and file buttons in the V2 look */
.p-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); height: 44px; font-weight: var(--w-medium); color: var(--ink); font-size: var(--fs-md); min-width: 0; }
.p-sec { padding: var(--sp-3) 0 var(--sp-1h); border-top: 1px solid var(--rule-soft); }
.p-sec h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-xs); font-weight: var(--w-medium); color: var(--ink-3); }
.p-row { display: flex; align-items: flex-start; gap: var(--sp-3); min-height: var(--h-md); padding: var(--sp-1) 0; font-size: var(--fs-md); }
.p-k { flex: 0 0 104px; color: var(--ink-3); font-size: var(--fs-sm); line-height: 20px; }
.p-v { flex: 1; min-width: 0; color: var(--ink); word-break: break-word; line-height: 20px; }
/* the slim context popover (round 5, Y3): the bar (the tasks bar), one line, the account, the breakdown behind Details */
.ctx-pop .ctx-bar { flex: none; display: block; margin: var(--sp-1) 0 var(--sp-2); }
.ctx-line { margin: 0; font-size: var(--fs-md); line-height: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ctx-acc { margin: 2px 0 var(--sp-2); font-size: var(--fs-xs); line-height: var(--lh); color: var(--ink-3); }
.ctx-details { margin-bottom: var(--sp-1); }
.p-list { border-top: 1px solid var(--rule-soft); }
.p-list summary { cursor: pointer; display: flex; align-items: center; gap: var(--sp-2); min-height: var(--h-md); padding: 0; color: var(--ink-2); font-size: var(--fs-md); list-style: none; }
.p-list summary::-webkit-details-marker { display: none; }
.p-list summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--r-sm); }
.p-list-l { flex: 1; }
.p-list-chev { display: inline-flex; color: var(--ink-4); }
.p-list[open] .p-list-chev .ui-chev { transform: rotate(90deg); }
.p-count { color: var(--ink-3); }
.p-list > div { padding: 0 0 var(--sp-2); max-height: 260px; overflow-y: auto; }
.p-item { padding: 2px 0; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; }
.p-item b { font-weight: var(--w-medium); color: var(--ink); }
.p-dim { color: var(--ink-3); }
.p-foot { color: var(--ink-3); font-size: var(--fs-xs); margin: 14px 0 0; }
.p-file:not(.ui-row) { display: block; width: 100%; text-align: left; padding: var(--sp-1h) var(--sp-2); margin: 0 calc(-1 * var(--sp-2)); color: var(--ink-2); font-size: var(--fs-md); border-radius: var(--r-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-file b { font-weight: var(--w-medium); color: var(--ink); }
.ptabs { display: flex; gap: var(--sp-4); margin: 0 0 var(--sp-3); border-bottom: 1px solid var(--rule-soft); }
.ptab:not(.ui-tab) { padding: var(--sp-2) var(--sp-0h); font-size: var(--fs-md); font-weight: var(--w-medium); color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ptab:not(.ui-tab).sel { color: var(--ink); border-bottom-color: var(--ink); }

/* file viewer */
.v-title { display: inline-flex; align-items: center; gap: var(--sp-1h); min-width: 0; }
.v-name { font-weight: var(--w-medium); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.v-path { font: var(--fs-xs)/var(--lh) var(--mono); color: var(--ink-3); margin: 0 0 var(--sp-2h); word-break: break-all; }
.v-actions { margin: 0 0 var(--sp-2h); }
.viewer img, .viewer video { max-width: 100%; border-radius: var(--r-md); display: block; }
.viewer iframe { width: 100%; height: calc(100dvh - 160px); border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--canvas-doc); }
.viewer pre { margin: 0; padding: var(--sp-2h) var(--sp-3); background: var(--pane); border-radius: var(--r-md); font: var(--fs-xs)/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }
.viewer pre mark.v-line { background: var(--active); color: inherit; border-radius: 2px; box-shadow: 0 0 0 2px var(--active); }
.viewer .v-md { font-size: var(--fs-prose); }

/* rich blocks in answers: diagrams and pages render on a white sheet */
.rich { margin: var(--sp-2h) 0 14px; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; }
.rich-tabs { display: inline-flex; gap: var(--sp-0h); margin: var(--sp-1h); padding: 2px; border-radius: 7px; background: var(--hover); }
.rich-tab { height: 22px; padding: 0 var(--sp-2); font-size: var(--fs-xs); font-weight: var(--w-medium); color: var(--ink-3); border-radius: 5px; }
.rich-tab.sel { color: var(--ink); background: var(--raised); box-shadow: var(--e-ring), var(--e-xs); }
.rich-view { padding: 10px; background: var(--canvas-doc); color: var(--canvas-ink); }
.rich-view iframe { display: block; width: 100%; height: 360px; border: 0; background: var(--canvas-doc); }
.rich-view img { max-width: 100%; display: block; margin: 0 auto; }
.rich-view svg { max-width: 100%; height: auto; }
.e-ai .rich pre, .rich .rich-code { margin: 0; border-radius: 0; }

/* a message found by a conversation search: marked for a moment when the session opens at it */
.e.is-hit > .e-c { background: var(--active); box-shadow: 0 0 0 6px var(--active); border-radius: var(--r-sm); }
.e-user.is-hit > .e-c { border-radius: var(--r-md); }

/* background tasks in the session pane */
.bg-task { padding: var(--sp-3) 0; border-top: 1px solid var(--rule-soft); }
.pane-h + .bg-task { border-top: 0; padding-top: 2px; }
.bg-head { display: flex; align-items: baseline; gap: var(--sp-2); width: 100%; min-width: 0; text-align: left; font-size: var(--fs-md); }
.bg-head:disabled { cursor: default; }
.bg-name { flex: 1; min-width: 0; font-weight: var(--w-medium); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-word { flex: none; font-size: var(--fs-xs); color: var(--ink-2); }
.bg-task.is-done .bg-word, .bg-task.is-done .bg-name { color: var(--ink-3); }
.bg-task.is-failed .bg-word { color: var(--err); }
.bg-desc { margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.bg-desc:empty { display: none; }
.bg-cmd { display: block; margin-top: var(--sp-1h); padding: var(--sp-1h) var(--sp-2h); background: var(--pane); border-radius: var(--r-sm); font: var(--fs-xs)/1.5 var(--mono); color: var(--ink-2); white-space: pre-wrap; word-break: break-word; max-height: 96px; overflow: auto; }
.bg-meta { margin-top: 6px; font-size: var(--fs-xs); color: var(--ink-3); }
.bg-sum { margin-top: 6px; font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.bg-err { margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--err); }
.bg-err:empty { display: none; }
.bg-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.bg-acts:empty { display: none; }
.bg-acts .btn-ghost.small { margin-top: 0; }
.bg-head:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }

/* ---------- strip and tasks card ---------- */
.strip { display: flex; align-items: center; gap: var(--sp-1h); padding: var(--sp-1h) var(--sp-5); border-bottom: 1px solid var(--rule); font-size: var(--fs-xs); color: var(--ink-3); overflow-x: auto; white-space: nowrap; flex: 0 0 auto; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip-l { margin-right: var(--sp-1); }
/* .fchip (V1 filter chip, modules still draw it) looks like .ui-chip */
.fchip { display: inline-flex; align-items: center; gap: var(--sp-1); height: var(--h-sm); padding: 0 var(--sp-2); border: 1px solid var(--rule); border-radius: var(--r-sm); background: transparent; color: var(--ink-2); font-size: var(--fs-sm); font-weight: var(--w-medium); white-space: nowrap; }
.fchip.sel { background: var(--active); border-color: transparent; color: var(--ink); }
.fchip.more { border-style: dashed; color: var(--ink-3); }
.fchip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.strip-mcp { display: inline-flex; align-items: center; gap: var(--sp-1h); color: var(--ink-3); padding: 3px var(--sp-1h); border-radius: var(--r-sm); }
.strip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); }
.strip .dot.ok { background: var(--ok); }
.strip .dot.warn { background: var(--amber-fill); }

/* the agent's to-do list (TodoWrite): a quiet card above the log */
.tasks { display: grid; grid-template-rows: auto 1fr; align-self: center; flex: 0 0 auto; width: calc(100% - 2 * var(--sp-5)); max-width: var(--measure); margin-top: var(--sp-2h); border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--raised); box-shadow: var(--e-xs); overflow: hidden; }
.tasks.closed { grid-template-rows: auto 0fr; }
.tasks-head { display: flex; align-items: center; gap: var(--sp-2h); width: 100%; min-height: var(--h-row); text-align: left; padding: 0 14px; font-size: var(--fs-sm); color: var(--ink-2); }
.tasks-head:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.tasks-title { font-weight: var(--w-medium); color: var(--ink); }
.tasks-count { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tasks-bar { flex: 1; height: 2px; background: var(--rule); border-radius: 2px; overflow: hidden; }
/* fills by transform: the client sets --p (0..1); an inline width still works until it does */
.tasks-bar span { display: block; width: 100%; height: 100%; background: var(--ink); transform-origin: 0 50%; transform: scaleX(var(--p, 1)); }
.tasks .chev { color: var(--ink-4); display: inline-flex; }
.tasks.closed .chev { transform: rotate(-90deg); }
.tasks .todos { min-height: 0; overflow: hidden; margin: 0; padding: 0 14px; }
.tasks.closed .todos { visibility: hidden; }
.tasks .todos > :first-child { margin-top: 2px; }
.tasks .todos > :last-child { margin-bottom: var(--sp-2h); }
.tasks .todo { font-size: var(--fs-md); }

/* ---------- detail levels ---------- */
body.detail-min .e-step:not(.sub), body.detail-min .thinking, body.detail-min .e-result, body.detail-min .e-cmd, body.detail-min .e-sys:not(.loading) { display: none; }
body.detail-all .step-chev { display: none; }

/* ---------- settings (DESIGN-V2 9.1.10): a tab list of sections on the left, one section beside it ---------- */
.set-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.set-grid { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: var(--sp-8); align-items: start; }
.set-nav { position: sticky; top: var(--sp-4); display: flex; flex-direction: column; gap: 1px; }
.set-nav .ui-nav.active { font-weight: var(--w-medium); }
.set-body { min-width: 0; max-width: 600px; }
.set-sec { padding: 0 0 var(--sp-2); }
.set-body > .set-sec[hidden] { display: none; }
.set-sec h2, .set-h { margin: 0 0 var(--sp-4); font-size: var(--fs-sm); font-weight: var(--w-medium); color: var(--ink); }
.set-sec h3 { margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-sm); font-weight: var(--w-medium); color: var(--ink-2); }
/* fields: label above, the control, a hint under it at 64ch. Controls modules hand in raw take the .ui-input look. */
.ui-field.f { max-width: 600px; }
.f-label { display: block; width: fit-content; max-width: 100%; }
.f > :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, .sel:has(> select), .ui-select) { max-width: 420px; }
.f > textarea, .f > .ui-textarea { max-width: 100%; }
.f input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.ui-input), .f textarea:not(.ui-textarea) {
  display: block; width: 100%; min-width: 0; height: var(--h-md); padding: 0 var(--sp-2h); border: 1px solid var(--rule-2); border-radius: var(--r-sm); background: var(--raised); box-shadow: var(--e-xs);
  font: inherit; font-size: max(var(--field-min), var(--fs-md)); color: var(--ink); outline: 0;
}
.f textarea:not(.ui-textarea) { height: auto; min-height: 72px; padding: var(--sp-2) var(--sp-2h); resize: vertical; }
.f textarea { font-family: var(--mono); font-size: max(var(--field-min), var(--fs-sm)); line-height: 1.55; }
/* a text field frames on focus; anything else only when the keyboard put the focus there */
.f :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), textarea):not(.ui-input):not(.ui-textarea):focus { border-color: var(--field-edge); background: var(--field-edit); box-shadow: var(--e-xs); }
/* a select in a wrapper (selWrap, and modules' own .sel): the .ui-select look with its chevron at the right. Scoped to a
   wrapper that holds a select: .sel is also the "selected" state of tabs, segments and menu items (ui.css), whose last
   span must never be pulled out of place by the chevron rule. */
.sel:has(> select) { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.sel > select { display: block; width: 100%; min-width: 0; height: var(--h-md); padding: 0 28px 0 var(--sp-2h); border: 1px solid var(--rule-2); border-radius: var(--r-sm); background: var(--raised); box-shadow: var(--e-xs); font: inherit; font-size: max(var(--field-min), var(--fs-md)); color: var(--ink); outline: 0; -webkit-appearance: none; appearance: none; cursor: pointer; }
.sel > select:focus-visible { box-shadow: var(--focus-ring); }
.sel:has(> select) > span:last-child { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: inline-flex; pointer-events: none; color: var(--ink-3); }
.sel:has(> select) > span:last-child > svg { display: block; }
.avatar-row { display: flex; gap: var(--sp-4); align-items: center; margin: 0 0 var(--sp-4); }
.avatar-row > div { display: flex; gap: var(--sp-2); }
.set-avatar { position: relative; }
.set-avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.set-logout { margin: var(--sp-4) 0 0; }
.mcp-row { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-2) 0; border-top: 1px solid var(--rule-soft); font-size: var(--fs-md); }
.mcp-row:first-child { border-top: 0; }
.mcp-add { margin-top: 14px; padding-top: var(--sp-2h); border-top: 1px solid var(--rule-soft); }
.mcp-add h3 { font-size: var(--fs-sm); font-weight: var(--w-medium); margin: 0 0 var(--sp-2h); color: var(--ink-2); }
.saved { font-size: var(--fs-sm); color: var(--ok); min-height: 18px; }

/* full-screen viewer */
.overlay { position: fixed; inset: 0; z-index: var(--z-dialog); background: var(--paper); display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.ov-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; height: var(--topbar-h); padding: 0 var(--sp-3); border-bottom: 1px solid var(--rule); }
.ov-head .spacer { flex: 1; }
.ov-sub { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ov-body { flex: 1; min-height: 0; display: flex; align-items: stretch; justify-content: center; overflow: auto; background: var(--well); }
.ov-body iframe { width: 100%; height: 100%; border: 0; background: var(--canvas-doc); }
.ov-body img { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; display: block; }
.ov-body video, .ov-body audio { margin: auto; max-width: 100%; }
.ov-doc { max-width: var(--measure); width: 100%; margin: 0 auto; padding: var(--sp-7) var(--sp-6); background: var(--paper); }
pre.ov-doc { font: var(--fs-sm)/var(--lh) var(--mono); white-space: pre-wrap; }

/* ---------- login (loads tokens.css and this file only) ---------- */
body.login { display: grid; place-items: center; min-height: 100dvh; background: var(--panel); padding: var(--sp-5); }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-7) var(--sp-6) var(--sp-6); border-radius: var(--r-lg); background: var(--float); box-shadow: var(--e-ring), var(--e-float); }
.login-mark { display: block; width: 28px; height: 28px; margin-bottom: var(--sp-2); }
.login-title { margin: 0; font-weight: var(--w-semibold); font-size: var(--fs-xl); line-height: var(--lh-tight); letter-spacing: var(--track-title); color: var(--ink); }
.login-sub { margin: 0 0 var(--sp-2); font-size: var(--fs-md); color: var(--ink-3); }
.login-card input { height: 40px; border: 1px solid var(--rule-2); border-radius: var(--r-sm); padding: 0 var(--sp-3); outline: 0; background: var(--raised); box-shadow: var(--e-xs); font-size: max(16px, var(--fs-md)); color: var(--ink); }
.login-card input::placeholder { color: var(--ink-4); }
.login-card input:focus { border-color: var(--ink-3); box-shadow: var(--focus-halo); }
.login-card input[aria-invalid="true"] { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-wash); }
.login-card button { height: 40px; border-radius: var(--r-sm); background: var(--ink); color: var(--paper); font-size: var(--fs-md); font-weight: var(--w-medium); box-shadow: var(--e-xs); }
.login-card button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.login-err { color: var(--err); font-size: var(--fs-sm); min-height: 18px; margin: 0; }

/* ---------- hover: only where a real pointer hovers (colour and opacity only) ---------- */
@media (hover: hover) {
  .s-item:hover .s-more, .s-item:focus-within .s-more { opacity: 1; }
  .s-item:hover .s-time, .s-item:focus-within .s-time { opacity: 0; }
  .s-more:hover { background: var(--active); color: var(--ink); }
  .e-user:not(.is-editing):hover > .u-edit { opacity: 1; }
  .e-user:not(.is-editing):hover > .e-t:has(~ .u-edit) { opacity: 0; }
  .e-user > .u-edit:hover { color: var(--ink); }
  .sb-title:hover { color: var(--ink); }
  .sb-add:hover .ui-nav-lead { color: var(--ink-2); }
  .rail-i:not(.active):hover { background: var(--hover); color: var(--ink); }
  .ui-nav:hover .foot-gear { color: var(--ink-3); }
  .crumbs a:hover, .crumb-link:hover { background: var(--hover); color: var(--ink); }
  .title-edit:hover { background: var(--hover); }
  .title-edit:hover .title-chev { opacity: 1; }
  .icon-btn:hover { background: var(--hover); color: var(--ink); }
  .btn-ink:not(:disabled):hover { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
  .btn-ghost:not(:disabled):hover { background: var(--pane); }
  .update-pill-btn:not(:disabled):hover { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
  .c-send:not(:disabled):hover { --send-ink: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
  .c-row:not(:has(> .c-chips)) > .btn-ghost:hover { background-image: linear-gradient(var(--hover), var(--hover)); }
  .chip:not([aria-expanded="true"]):hover, .ctx-ring:hover { background: var(--hover); color: var(--ink); }
  .c-context .chip:not([aria-expanded="true"]):hover { background: var(--active); }
  .fchip:not(.sel):hover { background: var(--hover); color: var(--ink); }
  .strip-mcp:hover { background: var(--hover); color: var(--ink); }
  .linkbtn:hover { color: var(--ink); text-decoration-color: currentColor; }
  .step-head:hover { color: var(--ink); }
  .step-head:hover .step-chev { color: var(--ink-3); }
  .step-sum.link:hover { text-decoration-color: currentColor; color: var(--ink); }
  .thinking > .e-c:hover { color: var(--ink-2); }
  .e-ai a:hover { text-decoration-color: currentColor; }
  .slash-item:not(.sel):hover { background: var(--hover); }
  .p-file:not(.ui-row):hover { background: var(--hover); color: var(--ink); }
  .p-list summary:hover { color: var(--ink); }
  .pane-link:hover { text-decoration-color: currentColor; }
  .ptab:not(.ui-tab):hover { color: var(--ink); }
  .rich-tab:not(.sel):hover { color: var(--ink); }
  .tb-tasks.on:hover { color: var(--ink); }
  .bg-head:not(:disabled):hover .bg-name { text-decoration: underline; text-decoration-color: var(--ink-4); text-underline-offset: 3px; }
  .tasks-head:hover .tasks-title { color: var(--ink); }
}

/* ---------- touch: 44 px targets, 16 px fields ---------- */
@media (hover: none) {
  .s-more { display: none; }
  .s-item .s-time, .s-item.active .s-time { opacity: 1; }
  .s-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  /* touch: a long press on your message opens Edit and Copy text */
  .e-user > .u-edit { display: none; }
  .e-user[data-uuid]:not(.is-editing) { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .e-user[data-uuid].is-pressed > .e-c { background: var(--active); }
  .title-chev { opacity: 1; }
}
@media (pointer: coarse), (hover: none) {
  .btn-ink, .btn-ghost { min-height: var(--hit); padding: 0 var(--sp-4); }
  .btn-ghost.small, .btn-ink.small { min-height: 36px; padding: 0 var(--sp-3); }
  .icon-btn, .icon-btn.small { width: var(--hit); height: var(--hit); }
  .step-head { min-height: var(--hit); align-items: center; }
  .rail > .e-step > .e-t { top: 15px; }
  .rail > .e-step::after { top: 20px; }
  .sublog .step-head { min-height: var(--hit); }
  .slash-item { min-height: var(--hit); }
  /* the rail keeps one row down to 320 px: icons may narrow to 40 px, an invisible strip makes up the 44 px target */
  .rail-i { height: var(--hit); min-width: 40px; }
  .rail-i:not(.active)::after { content: ""; position: absolute; inset: 0 -2px; }
  .sb-top .ui-btn--icon { width: var(--hit); height: var(--hit); }
  .sp-input.ui-input { height: var(--hit); }
  .p-file:not(.ui-row) { min-height: var(--hit); display: flex; align-items: center; }
  .tasks-head { min-height: var(--hit); }
  .p-list summary { min-height: var(--hit); }
  .opt { min-height: var(--hit); align-items: center; }
  .opt input { margin-top: 0; }
  .thinking > .e-c { grid-template-rows: minmax(var(--hit), auto) 0fr; align-items: center; }
  .thinking.open > .e-c, body.detail-all .thinking > .e-c { grid-template-rows: minmax(var(--hit), auto) 1fr; }
  .f input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.ui-input), .sel > select { height: var(--hit); }
  .tb-slot > .fchip { min-height: var(--hit); }
  .top-right .ui-btn, #sb-open, .crumb-back, .ui-peek-acts .ui-btn, .side-back { min-height: var(--hit); }
  .c-box .ui-btn--icon { height: var(--hit); }
  /* small inline controls keep their look and get an invisible 44 px hit area */
  .chip, .ctx-ring, .rich-tab, .linkbtn, .att-x, .fchip, .s-head .s-state { position: relative; }
  .chip::after, .ctx-ring::after, .rich-tab::after, .linkbtn::after, .s-head .s-state::after { content: ""; position: absolute; inset: -8px -2px; }
  .fchip::after { content: ""; position: absolute; inset: -10px -2px; }
  .update-pill-btn { min-height: 36px; padding: 0 14px; }
  .update-pill-btn::after { content: ""; position: absolute; inset: -4px; }
  .att-x::after { content: ""; position: absolute; inset: -12px; }
  .chip { height: 32px; }
  .sb-title { min-height: var(--hit); display: inline-flex; align-items: center; }
  .bg-head { min-height: var(--hit); align-items: center; }
}

/* ---------- under 1101 px: the Details pane floats from the right over the chat (no scrim) ---------- */
@media (max-width: 1100px) {
  .session { grid-template-columns: minmax(0, 1fr) 0px; }
  #side { display: none; position: fixed; z-index: calc(var(--z-side) - 9); top: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--inset) + var(--vvtop, 0px)); right: calc(var(--inset) + env(safe-area-inset-right)); bottom: calc(var(--inset) + env(safe-area-inset-bottom)); width: min(calc(100vw - 2 * var(--inset)), var(--peek-w)); border: 0 !important; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--e-ring), var(--e-peek), var(--e-float); }
  body.side-open #side, body.side-closing #side { display: block; }
  body.side-full #side { width: calc(100vw - 2 * var(--inset)); }
  #side > .ui-peek, body.side-open #side > .ui-peek { width: 100%; right: 0; opacity: 1; }
  .side-expand { display: none; }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  #sidebar {
    position: fixed; z-index: calc(var(--z-side) - 10); display: flex;
    top: calc(var(--inset) + env(safe-area-inset-top) + var(--vvtop, 0px)); bottom: calc(var(--inset) + env(safe-area-inset-bottom)); left: calc(var(--inset) + env(safe-area-inset-left));
    width: min(86vw, 340px); border-radius: var(--r-lg); overflow: hidden;
    box-shadow: var(--e-ring), var(--e-overlay); transform: translateX(0);
  }
  body.sb-closed #sidebar { display: flex; visibility: hidden; transform: translateX(calc(-100% - var(--inset) - 64px)); }
  #scrim { display: block; z-index: calc(var(--z-side) - 11); opacity: 1; }
  body.sb-closed:not(.side-open) #scrim { opacity: 0; pointer-events: none; }
  body.side-open #scrim { z-index: calc(var(--z-side) - 10); }
  #sb-open { display: inline-flex; }
  #topbar { padding: 0 var(--sp-2) 0 var(--sp-1h); gap: var(--sp-1); }
  /* phones: the last crumb only, after a back chevron on pages with a parent; the right side keeps the status, Git,
     Details and More */
  .crumbs > :not(:last-child):not(.crumb-back) { display: none; }
  #crumbs > .crumb-back { display: inline-flex; flex: none; overflow: visible; color: var(--ink-3); margin-right: calc(-1 * var(--sp-1)); }
  /* the page's own crumb over its own title steps aside; the arrow names where it goes (X-UI2) */
  #crumbs.crumbs-dup > .ui-crumb.is-current { display: none; }
  #crumbs.crumbs-dup > .crumb-back { width: auto; gap: var(--sp-1); padding: 0 var(--sp-2) 0 var(--sp-1); margin-right: 0; }
  #crumbs.crumbs-dup > .crumb-back::after { content: attr(data-label); font-size: var(--fs-md); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-right .tb-slot { max-width: 96px; }
  .update-pill { top: auto; bottom: calc(env(safe-area-inset-bottom) + 112px); }
  /* the tasks control takes no room of its own: it floats at the left edge of the right side, over the end of the
     (already truncated) title, with a paper ground, so nothing moves when it comes */
  .top-right { position: relative; }
  .tb-tasks { position: absolute; right: calc(100% + 2px); top: 50%; margin-top: calc(var(--hit) / -2); background: var(--paper); box-shadow: -16px 0 10px -6px var(--paper); }

  /* the Details pane: a bottom sheet, 92 % high, with a grab handle; a pull on its head closes it */
  #side { top: auto; left: calc(var(--inset) + env(safe-area-inset-left)); right: calc(var(--inset) + env(safe-area-inset-right)); bottom: calc(var(--inset) + env(safe-area-inset-bottom)); width: auto; height: 92dvh; max-height: calc(100dvh - env(safe-area-inset-top) - 2 * var(--inset)); border-radius: var(--r-xl); box-shadow: var(--e-ring), var(--e-overlay); transform: translateY(var(--drag, 0px)); }
  body.side-full #side { width: auto; }
  #side .ui-sheet-grab { display: block; touch-action: none; }
  #side .ui-peek-head { touch-action: none; }
  #side .ui-peek-head { border-bottom-color: var(--rule-soft); }

  .transcript { padding: 14px 14px 150px; }
  .rail { --rail-x: 15px; }
  .e-t { width: calc(var(--gutter) - 26px); top: 10px; }
  .composer { padding: 0 var(--sp-2h) calc(var(--sp-2h) + env(safe-area-inset-bottom)); }
  .c-box { --c-gap: var(--sp-1); padding: var(--sp-2h) var(--sp-2) var(--sp-2) 14px; }
  .chip { max-width: 160px; }
  .c-hint { display: none; }
  .c-newproj { gap: var(--sp-1h); }
  .ring { display: inline-flex; }

  .home { padding: var(--sp-6) var(--page-pad) var(--sp-8); }
  .home-orb { margin-bottom: var(--sp-4); }
  .strip { padding: var(--sp-1h) var(--sp-3); }
  .tasks { width: calc(100% - 2 * var(--sp-3)); margin-top: var(--sp-2); }

  /* Settings: the sections are one row that scrolls sideways and stays at the top */
  .set-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-2); }
  .set-nav { position: sticky; top: 0; z-index: 3; flex-direction: row; flex-wrap: nowrap; gap: var(--sp-1); overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--page-pad)); padding: var(--sp-2) var(--page-pad); background: var(--paper); border-bottom: 1px solid var(--rule-soft); }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav .ui-nav { flex: none; white-space: nowrap; }
  .f > :is(input, textarea, .sel:has(> select), .ui-select) { max-width: none; }
}

/* ======================================================================================================================
   DESIGN-V3 Phase B (docs/design/DESIGN-V3.md section 10): the shell in the V3 materials. One block that overrides the
   V2 shell rules above it by order; the phone keyboard rules stay last, below it.
   ====================================================================================================================== */

/* ---------- B1. the window (desktop): the base ground; the glass sidebar and the white work sheet float on it ---------- */
@media (min-width: 761px) {
  #app {
    gap: var(--inset);
    padding: calc(var(--inset) + env(safe-area-inset-top)) calc(var(--inset) + env(safe-area-inset-right)) var(--inset) calc(var(--inset) + env(safe-area-inset-left));
    background: var(--base);
  }
  #sidebar {
    position: relative; width: var(--sidebar-w); border-radius: var(--r-panel);
    background: var(--glass-chrome); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-edge), var(--glass-ring), var(--e-1);
  }
  #main { border-radius: var(--r-panel); overflow: hidden; box-shadow: var(--e-ring), var(--e-1); }
}
.rail-n { box-shadow: 0 0 0 2px var(--base); }
body.login { background: var(--base); }
.login-card { border-radius: var(--r-xl); }
.login-card input { border: 1px solid transparent; border-radius: var(--r-sm); background: var(--field); box-shadow: none; }
.login-card input:focus { border-color: var(--field-edge); background: var(--field-edit); box-shadow: var(--e-xs); }
.login-card button { border-radius: var(--r-pill); }

/* ---------- B2. the top bar: glass over the page, which scrolls under it ---------- */
#topbar {
  position: absolute; z-index: 6; top: 0; left: 0; right: 0; height: var(--topbar-h); padding: 0 var(--sp-3) 0 var(--sp-3);
  border-bottom: 0; background: var(--glass-bar); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
/* every page starts under the bar and scrolls beneath it; --view-top is the bar's height over a page (for a height or a
   max-height). A sticky element's top and a jump's scroll-margin count from the page's padding (and scroll-padding), which
   already clear the bar: they add only their own gap (the audit of 2026-11-11: the Settings nav stood 52 px low, on a
   phone in the middle of the page with the text showing above and through it) */
#view { --view-top: var(--topbar-h); }
#view > * { padding-top: var(--topbar-h); scroll-padding-top: var(--topbar-h); }
#view > .home { padding-top: calc(var(--topbar-h) + var(--sp-8)); }
#view > .session { padding-top: 0; }
.session-main .transcript { padding-top: calc(var(--topbar-h) + var(--sp-4)); scroll-padding-top: var(--topbar-h); }
/* v7 (F14, Stevie 2026-11-15): the session's head sits in the top bar right after the crumbs: the status, then who works
   on it (faces and names). Fixed: the status slot keeps one width so the agents never shift when Ready becomes Working;
   the crumbs give way (they shorten) before the head does; the buttons stay at the right edge */
#topbar:has(> .s-head) > .crumbs { flex: 0 1 auto; }
#topbar > .s-head { flex: 0 0 auto; margin-right: auto; display: flex; align-items: center; gap: var(--sp-3); height: var(--h-sm);
  padding-left: var(--sp-3); margin-left: var(--sp-1); border-left: 1px solid var(--rule); font-size: var(--fs-sm); max-width: 50%; min-width: 0; }
.s-head-status { flex: none; display: inline-flex; min-width: 92px; }
@media (max-width: 760px) { #topbar > .s-head { gap: var(--sp-2); padding-left: var(--sp-2); } .s-head-status { min-width: 0; } .s-agents-l { display: none; } }
.s-head .s-state { display: inline-flex; align-items: center; gap: var(--sp-1); white-space: nowrap; }
.s-head .s-state as-orb.is-off { display: none; }
.s-agents { flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: var(--sp-1h); color: var(--ink-2); }
.s-agents-stack { flex: none; display: inline-flex; align-items: center; }
.s-agents-stack.is-many > .s-agent-av + .s-agent-av { margin-left: -6px; }
.s-agents-stack.is-many > .s-agent-av { border-radius: 50%; box-shadow: 0 0 0 2px var(--paper); }
.s-agents-more { margin-left: var(--sp-1); font-size: var(--fs-xs); color: var(--ink-3); }
.s-agents-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#side > .ui-peek { top: var(--topbar-h); }
.set-nav { top: var(--sp-4); }
.set-sec { scroll-margin-top: var(--sp-4); }
/* the bar shows its lower edge only while something is scrolled under it (scroll-driven; without support it stays clear) */
@supports (animation-timeline: scroll()) {
  #main { timeline-scope: --page-y; }
  #view > :is(.hm, .lib, .pj, .ag, .set-scroll, .home, .it-scroll, .hb-view), .session-main .transcript, .chats-page .db-body, .it-dbpage .db-body, .pl-page--upcoming > .pl-week { scroll-timeline: --page-y y; }
  #topbar { animation: bar-edge linear both; animation-timeline: --page-y; animation-range: 0 32px; }
}
@keyframes bar-edge { from { box-shadow: inset 0 -0.5px 0 transparent; } to { box-shadow: inset 0 -0.5px 0 var(--rule); } }
.update-pill { top: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--inset) + 10px); border-radius: var(--r-pill); background: var(--glass-float); -webkit-backdrop-filter: var(--glass-blur-float); backdrop-filter: var(--glass-blur-float); box-shadow: var(--glass-edge), var(--glass-ring), var(--e-2); }
.update-pill-btn { border-radius: var(--r-pill); }

/* ---------- B3. the sidebar's head and the rail: a soft tray with a glass lens and filled icons ---------- */
.sb-top { height: var(--topbar-h); padding: 0 var(--sp-2h) 0 var(--sp-2); }
.sb-title { font-weight: var(--w-semibold); color: var(--ink); letter-spacing: -0.01em; }
.sb-rail { position: relative; gap: var(--sp-0h); margin: 0 var(--sp-2) var(--sp-2); padding: 3px; border-radius: var(--r-pill); background: var(--fill); }
.rail-i { z-index: 1; flex: 1 1 0; height: 30px; min-width: 0; padding: 0; border-radius: var(--r-pill); color: var(--ink-3); }
.rail-i.active { flex: 1 1 0; padding: 0; color: var(--ink); background: transparent; }
.rail-i > .ui-icon { width: 20px; height: 20px; }
.rail-i .rail-l, .rail-i.active .rail-l { display: none; }
.rail-n { top: 0; left: calc(50% + 4px); }
.rail-i.active .rail-n { position: absolute; box-shadow: 0 0 0 2px var(--thumb); }
/* the lens: AS.ui.tabIndicator(rail, { kind: 'thumb', item: '.rail-i.active' }) puts one .ui-seg-thumb in the rail */
.sb-rail > .ui-seg-thumb { background: var(--thumb); box-shadow: var(--thumb-shadow); }
/* without the lens (an old cached app.js) the active item carries it itself */
.sb-rail:not(:has(> .ui-seg-thumb)) > .rail-i.active { background: var(--thumb); box-shadow: var(--thumb-shadow); }

/* ---------- B4. sidebar rows: airier, capsule-soft ---------- */
.sb-scroll { padding: 0 var(--sp-2) var(--sp-4); }
.sb-list { gap: 2px; }
.sb-foot { padding: var(--sp-2) var(--sp-2) calc(var(--sp-2) + env(safe-area-inset-bottom)); border-top: 0; box-shadow: inset 0 0.5px 0 var(--rule-soft); }
.s-more { border-radius: var(--r-pill); right: 4px; }

/* ---------- B5. the resizer (AS.ui.panelSize); the icon-only rail is gone (v5, SB3) ---------- */
#sb-resize { display: block; }
/* a reflowing sidebar never wraps text while it narrows */
#sidebar .ui-nav-label, #sidebar .sb-title { white-space: nowrap; }

/* ---------- B6. the chat: the composer is glass, the prompt a soft card ---------- */
.composer { padding: 0 var(--sp-5) calc(var(--sp-4) + env(safe-area-inset-bottom)); }
.c-box {
  border: 0; border-radius: var(--r-xl); padding: var(--sp-3) var(--sp-3) var(--sp-2h) var(--sp-4);
  background: var(--glass); -webkit-backdrop-filter: var(--glass-blur-float); backdrop-filter: var(--glass-blur-float);
  box-shadow: var(--glass-edge), var(--glass-ring), var(--e-composer);
}
.c-box:focus-within { box-shadow: var(--glass-edge), 0 0 0 0.5px var(--field-edge), var(--e-composer); }
.c-box.is-drop { box-shadow: var(--glass-edge), 0 0 0 2px var(--focus), var(--e-composer); }
.home .c-box { background: var(--raised); box-shadow: var(--e-ring), var(--e-1); }
.c-context .chip, .chip, .ctx-ring { border-radius: var(--r-pill); }
.slash { border-radius: var(--r-lg); padding: var(--sp-1h); background: var(--glass-float); -webkit-backdrop-filter: var(--glass-blur-float); backdrop-filter: var(--glass-blur-float); box-shadow: var(--glass-edge), var(--glass-ring), var(--e-2); }
.slash-item { border-radius: var(--r-sm); }
.e-user .e-c { border-radius: var(--r-md); }
.att img, .att-doc { border-radius: var(--r-sm); }
.tasks { border: 0; border-radius: var(--r-lg); box-shadow: var(--e-ring), var(--e-1); }
.rich { border: 0; border-radius: var(--r-md); box-shadow: var(--e-ring); }
.rich-tabs { border-radius: var(--r-pill); background: var(--fill); }
.rich-tab { border-radius: var(--r-pill); }
.rich-tab.sel { background: var(--thumb); box-shadow: var(--thumb-shadow); }
.fade { background: linear-gradient(to bottom, transparent, var(--paper) 62%); }

/* ---------- B7. the Details pane: inset in the sheet on wide screens, a floating glass card under 1101 px ---------- */
body.side-open #side, body.side-closing #side { border-left-color: var(--rule-soft); }
@media (max-width: 1100px) { #side > .ui-peek { top: 0; } }
@media (min-width: 761px) and (max-width: 1100px) {
  #side { top: calc(var(--topbar-h) + env(safe-area-inset-top) + 2 * var(--inset) + var(--vvtop, 0px)); right: calc(2 * var(--inset) + env(safe-area-inset-right)); bottom: calc(2 * var(--inset) + env(safe-area-inset-bottom)); border-radius: var(--r-xl); box-shadow: var(--e-ring), var(--e-peek), var(--e-2); }
}

/* ---------- B8. V1 controls modules still draw, in the V3 look ---------- */
.icon-btn { border-radius: var(--r-pill); }
.btn-ink, .btn-ghost { border: 0; border-radius: var(--r-pill); padding: 0 var(--sp-3h); }
.btn-ink { box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.16), var(--e-xs); }
.btn-ghost { background: var(--fill); box-shadow: none; }
.fchip { border: 0; border-radius: var(--r-pill); background: var(--fill); }
.fchip.sel { background: var(--fill-3); }
.fchip.more { background: transparent; box-shadow: inset 0 0 0 1px var(--rule-2); }
.switch { width: 34px; height: 20px; background: var(--fill-3); }
.switch::after { top: 2px; left: 2px; width: 16px; height: 16px; background: var(--knob); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.22); }
.menu-switch[aria-checked="true"] .switch::after, .switch[aria-checked="true"]::after { transform: translateX(14px); }
.title-input { border: 1px solid var(--field-edge); border-radius: var(--r-sm); box-shadow: var(--e-xs); }
.opt-other, .perm-reason { border: 1px solid transparent; border-radius: var(--r-sm); background: var(--field); box-shadow: none; }
.opt-other:focus, .perm-reason:focus { border-color: var(--field-edge); background: var(--field-edit); box-shadow: var(--e-xs); }
.update-pill-btn, .linkbtn { border-radius: var(--r-pill); }

/* ---------- B9. Settings: a nav of capsules, fields as soft fills, every section a grouped card ---------- */
@media (min-width: 761px) { .set-grid { grid-template-columns: 184px minmax(0, 1fr); gap: var(--sp-9); } }
.set-nav .ui-nav { border-radius: var(--r-sm); }
.set-body { max-width: 720px; }   /* v6: the wide page (the one title offset); a form keeps its width beside the nav */
.set-sec { margin: 0 0 var(--sp-6); padding: var(--sp-5) var(--sp-5) var(--sp-2); border: 0; border-radius: var(--r-lg); background: var(--well); box-shadow: inset 0 0 0 0.5px var(--rule-soft); }
.set-body > .set-sec:first-child { padding-top: var(--sp-5); }
.set-sec h2, .set-h { margin: 0 0 var(--sp-4); font-size: var(--fs-md); font-weight: var(--w-semibold); color: var(--ink); }
.f input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.ui-input), .f textarea:not(.ui-textarea), .sel > select {
  border: 1px solid transparent; border-radius: var(--r-sm); background: var(--raised); box-shadow: var(--e-ring);
}
.set-sec .ui-input, .set-sec .ui-textarea, .set-sec .ui-select > select { background: var(--raised); box-shadow: var(--e-ring); }
.f :is(input, textarea):not(.ui-input):not(.ui-textarea):focus, .set-sec :is(.ui-input, .ui-textarea):focus { border-color: var(--field-edge); box-shadow: var(--e-xs); }
.sel > select:focus { border-color: transparent; box-shadow: var(--e-ring); }
.sel > select:focus-visible { box-shadow: var(--focus-ring); }
.mcp-row, .mcp-add { border-top-color: var(--rule); }

/* ---------- B10. hover (pointer only): colour and fill, nothing moves ---------- */
@media (hover: hover) {
  .rail-i:not(.active):hover { background: transparent; color: var(--ink); }
  .btn-ghost:not(:disabled):hover { background: var(--fill-2); }
  .fchip:not(.sel):hover { background: var(--fill-2); }
  .f input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.ui-input):not(:focus):hover, .sel > select:not(:focus):hover { box-shadow: var(--e-ring), 0 0 0 0.5px var(--rule-2); }
}

/* ---------- B11. phones: the sheet runs to the edges, the sidebar is a glass sheet over the page ---------- */
@media (max-width: 760px) {
  #sidebar { width: min(86vw, 340px); border-radius: var(--r-sheet); background: var(--glass-sheet); -webkit-backdrop-filter: var(--glass-blur-float); backdrop-filter: var(--glass-blur-float); box-shadow: var(--glass-edge), var(--glass-ring), var(--e-3); }
  #sb-resize { display: none; }
  #topbar { padding: 0 var(--sp-2) 0 var(--sp-1h); }
  .sb-rail { margin: 0 var(--sp-3) var(--sp-2); }
  .rail-i { height: 38px; }
  .rail-i > .ui-icon { width: 20px; height: 20px; }
  #side { border-radius: var(--r-sheet); background: var(--glass-sheet); -webkit-backdrop-filter: var(--glass-blur-float); backdrop-filter: var(--glass-blur-float); box-shadow: var(--glass-edge), var(--glass-ring), var(--e-3); }
  #side > .ui-peek { background: transparent; }
  .composer { padding: 0 var(--sp-2) calc(var(--sp-2) + env(safe-area-inset-bottom)); }
  .c-box { border-radius: var(--r-xl); }
  .set-nav { top: 0; background: var(--glass-bar); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-bottom: 0; }
  .set-sec { padding: var(--sp-4) var(--sp-4) var(--sp-1); scroll-margin-top: 64px; }
}

/* ---------- round 4 (builder O): one way for the shell ---------- */
/* Done is a quiet check in a session row's lead (the initials were the icon-only rail's, gone in v5) */
.s-ini { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: var(--r-pill); background: var(--fill-2); color: var(--ink-2); font-size: var(--fs-2xs); font-weight: var(--w-semibold); letter-spacing: 0; line-height: 1; }
.s-item.active .s-ini { background: var(--fill-3); color: var(--ink); }
.s-done { display: inline-flex; color: var(--ink-3); }
/* a chat's own marks on its header line: Done, Archived (a button that unarchives) */
.tb-flag { display: inline-flex; align-items: center; }
.tb-flag:empty { display: none; }
.tb-flag-btn { display: inline-flex; padding: 0; border: 0; background: none; border-radius: var(--r-pill); cursor: pointer; }
/* Settings: the nav in four groups with headings you cannot miss (round 6, S1: General, Connections, Claude Code, Data) */
.set-group { padding: 0 var(--sp-2h); margin: var(--sp-6) 0 var(--sp-2); font-size: var(--fs-xs); font-weight: var(--w-semibold); line-height: 18px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.set-nav > .set-group:first-child { margin-top: var(--sp-1); }
.set-group-hint { padding: 0 var(--sp-2h); margin: calc(-1 * var(--sp-1)) 0 var(--sp-2); font-size: var(--fs-xs); line-height: var(--lh); color: var(--ink-3); }
@media (max-width: 760px) {
  .sb-menu, .set-group, .set-group-hint { display: none; }
  /* the phone's one sideways row: no names, a small gap where a group starts */
  .set-nav .set-tab--gs { margin-left: var(--sp-3); }
}
/* ---------- Settings v2 (round 6, S1): one padding rule for every card ----------
   Every card (a section, the raised cards inside it: Storage, the Server pages, Accounts and its sign-in panel, the
   Voice card, the Calendars cards, Capture's new token) has --card-pad on all four sides. Its first visible child adds
   no space above, its last visible child none below (a hidden error line or an empty slot does not count), rows keep
   their rhythm but the first and last row of a list drop their outer padding, a sub-heading has --sp-5 above and --sp-2
   below (none above when it opens its box), the lead sits --sp-4 under the title, a form or button row at the end
   is --card-gap under the row above it. */
.set-body > .set-sec, .set-body > .set-sec:first-child,
.set-sec :is(.cfg-el, .acc-card, .acc-login, .cn-card, .cs-new) { padding: var(--card-pad); }
.set-sec :is(.acc-card, .cn-card) { margin-top: 0; }
/* the first and the last child that shows. Written with :nth-child(1 of ...) under a plain .set-sec ancestor (the lead, round 6):
   the first form, :not(:has(~ ...)) on any element under an :is() list, made the browser re-check every sibling in the whole
   app on each change (a 3000-row list went back and searched three times slower, items.db-plus's perf checks). */
.set-body > .set-sec > :nth-child(1 of :not([hidden], :empty)),
.set-sec :is(.cfg-el, .acc-login, .cn-card, .cs-new, .cfg-el-body, .cn-rows, .cfg-list, .srv-page, .srv-body, .acc-list) > :nth-child(1 of :not([hidden], :empty)) { margin-top: 0; }
.set-body > .set-sec > :nth-last-child(1 of :not([hidden], :empty)),
.set-sec :is(.cfg-el, .acc-login, .cn-card, .cs-new, .cfg-el-body, .cn-rows, .cfg-list, .srv-page, .srv-body, .acc-list) > :nth-last-child(1 of :not([hidden], :empty)) { margin-bottom: 0; }
.set-sec :is(.cfg-el-row, .cfg-item, .cfg-row, .cfg-file, .cfg-tool, .cfg-hrow, .cn-row, .ui-group-row):first-child { padding-top: 0; }
.set-sec :is(.cfg-el-row, .cfg-item, .cfg-row, .cfg-file, .cfg-tool, .cfg-hrow, .cn-row, .ui-group-row):last-child { padding-bottom: 0; }
.set-sec > :is(h2, .set-h) { margin: 0 0 var(--sp-4); }
.set-sec > .cfg-lead { margin: 0 0 var(--sp-4); }
.set-sec :is(.cfg-h, h3:not(.set-h)) { height: auto; min-height: 0; margin: var(--sp-5) 0 var(--sp-2); }
.set-sec :is(.cfg-h, h3:not(.set-h)):first-child, .set-sec > .cfg-lead + :is(.cfg-h, h3) { margin-top: 0; }
.set-sec :is(.cfg-more, .cn-foot, .acc-foot, .cfg-foot, .cs-make, .cfg-run, .cfg-save, .set-logout):last-child { margin-top: var(--card-gap); padding-top: 0; margin-bottom: 0; }
.set-sec .ui-group-row { padding-left: 0; padding-right: 0; }
.set-sec .ui-group-row + .ui-group-row::before { left: 0; }

.set-link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
@media (hover: hover) { .set-link:hover { text-decoration-color: currentColor; } }
/* the nav with its four headings is taller than a laptop's window: it scrolls inside itself, so it stays stuck beside
   the section instead of scrolling away with a long one; --set-nav-max is the room from where the nav stands with the
   page at its top to the window's bottom (renderSettings measures it), less the gap below */
@media (min-width: 761px) { .set-nav { max-height: calc(var(--set-nav-max, calc(100dvh - var(--view-top))) - var(--sp-4) - var(--inset)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; } .set-nav > * { flex-shrink: 0; } .set-nav::-webkit-scrollbar { display: none; } }
/* a footer whose buttons are all hidden takes no room (Calendars' Connect Google before a client is saved) */
.set-sec :is(.cn-foot, .cfg-more, .acc-foot, .cfg-foot):not(:has(> :not([hidden]))) { display: none; }
/* Layout stability (round 6, S1, Stevie's rule): nothing in Settings stretches or shifts the page when it expands.
   A tree has a fixed box, a list that can grow stops at --set-box-max and scrolls inside, an expander's body is the
   same bounded box; the page below never moves while one of them grows. */
.set-sec :is(.cfg-hooks, .cfg-place-body, .cs-list, .cn-subs-list, .cn-accs, .acc-list) { max-height: var(--set-box-max); overflow-y: auto; overscroll-behavior: contain; }
#set-memory .cfg-list, #set-style .cfg-items { max-height: var(--set-box-max); overflow-y: auto; overscroll-behavior: contain; }
/* a bounded box that is a flex column would squeeze its rows to fit instead of scrolling (rows ran over each other in
   Backups on the phone): its rows keep their own height */
.set-sec :is(.cfg-hooks, .cfg-place-body, .cs-list, .cn-subs-list, .cn-accs, .acc-list, .cfg-list, .cfg-items, .srv-list, .srv-jobs, .srv-backups, .srv-errors, .srv-level) > *,
#srv-routines .cfg-el-body > * { flex-shrink: 0; }

/* a chat that is gone: the Nothing here page's frame */
.gone-chat { margin-top: var(--sp-9); }
/* the phone's "+" (capture.js's button): app.js decides when it shows (body.fab-on); on Home it rests above Zmey's composer */
body:not(.fab-on) .cp-plus { display: none; }
/* the phone: the New version pill rests at the bottom as a pill (the global rule's top no longer stretches it, A32);
   the composer's chips wrap onto a second line instead of scrolling out of sight (the model chip stays on screen, A33) */
@media (max-width: 760px) {
  .update-pill { top: auto; }
  .c-chips { flex-wrap: wrap; overflow: visible; row-gap: var(--sp-1); }
}
@media (max-width: 760px) {
  body.fab-on .cp-plus { display: inline-flex; bottom: calc(var(--sp-4) + env(safe-area-inset-bottom) + var(--fab-lift, 0px)); }
}

/* ---------- phone keyboard open (app.js sets body.kb-open, --vvh, --vvtop and --kb from visualViewport) ----------
   The app takes exactly the visible height above the keyboard and follows iOS's pan, so the composer rests on the
   keyboard; the bottom safe area is under the keyboard and goes. #app moves by `top`, never a transform: a transform
   would make it the containing block of the fixed sidebar and sheets, put them under the scrim and clip them. Each fixed
   layer meets the keyboard once, on its own: its top follows --vvtop, its bottom rests on --kb. */
body.kb-open #app { height: var(--vvh, 100dvh); position: relative; top: var(--vvtop, 0px); }
body.kb-open .composer { padding-bottom: var(--sp-2); }
body.kb-open .sb-foot { padding-bottom: var(--sp-2); }
body.kb-open .update-pill { bottom: calc(var(--kb, 0px) + 96px); }
body.kb-open #side { bottom: calc(var(--kb, 0px) + var(--inset)); max-height: calc(var(--vvh, 80vh) - env(safe-area-inset-top) - 2 * var(--inset)); }
@media (max-width: 760px) { body.kb-open #sidebar { bottom: calc(var(--kb, 0px) + var(--inset)); } }

/* ---------- very narrow phones: the chat's title wins over the Git control ---------- */
/* ---------- structure v4 (builder C): the sidebar as rows in sections (spec 4.1) ---------- */
.sb-cap { margin-top: var(--sp-3); }
.sb-cap[hidden] { display: none; }
/* the counts at a row's right: quiet numbers, the Inbox's in the accent while something needs Stevie */
.sb-n:empty { display: none; }
.ui-nav .sb-n.ui-count--needs, .ui-nav .sb-n.ui-count--badge { margin-right: -2px; }
/* a session row has no glyph of its own (its Orb comes and goes) */
.s-item .s-ic { display: none; }

/* ---------- round 4 (T): the sidebar per place. One pane at a time under the rail (#sb-panes: Home, Chats, Library) ---------- */
.sb-pane[hidden] { display: none; }
.sb-home-more { margin-top: var(--sp-3); }
/* the Sessions pane: its groups (v7, F11: no filter field) */
.sb-chats > .sb-grp .ui-nav-sec { margin-top: var(--sp-3); }
/* a group's head: the state's word and the count of the rows under it, a plain label like every section's (W18) */
.sb-grp-h { gap: var(--sp-1h); justify-content: flex-start; }
.sb-grp-l { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-grp-n { font-weight: var(--w-regular); }
.sb-new-chat { margin-top: var(--sp-1); }
/* a row and its "..." (W18: one link per row, nothing folds open under it) */
.sp-node { position: relative; display: flex; flex-direction: column; gap: 2px; }
/* a database row's More button trades places with its count under the pointer */
.sb-more { position: absolute; z-index: 1; right: 4px; top: calc(var(--h-nav) / 2 - 12px); display: inline-flex; align-items: center; justify-content: center; width: var(--h-xs); height: var(--h-xs); padding: 0; border: 0; border-radius: var(--r-pill); background: none; color: var(--ink-3); opacity: 0; cursor: pointer; }
.sb-more:focus-visible { opacity: 1; outline: 2px solid var(--focus); outline-offset: -2px; }
.sb-db { padding-right: var(--sp-2h); }
.sb-rename { padding: var(--sp-1h); }
.sb-rename-in.ui-input { width: 100%; }
@media (hover: hover) {
  .sp-node:has(> .ui-nav:hover) > .sb-more, .sp-node > .sb-more:hover, .sp-node > .sb-more:focus-visible { opacity: 1; }
  .sp-node:has(> .ui-nav:hover, > .sb-more:hover, > .sb-more:focus-visible) > .sb-db .ui-nav-trail { opacity: 0; }
  .sb-more:hover { background: var(--active); color: var(--ink); }
}
@media (hover: none) {
  /* touch has no hover: the menu is a long press */
  .sb-more { display: none; }
}

/* ---------- /library (round 4, T3): the databases as a page, in the app's one list row ---------- */
.lib-ix-sub { margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--ink-3); }
.lib-ix-row .ui-row-title { flex: 0 1 auto; }
.lib-ix-row .ui-row-sub { flex: 1 1 auto; }
.lib-ix-add { width: 100%; border: 0; background: none; font: inherit; color: var(--ink-3); text-align: left; }
.lib-ix-add .ui-row-title { color: var(--ink-3); }
.lib-ix-add .ui-row-lead { color: var(--ink-4); }

/* ---------- round 4 (T, auditor A2) ---------- */
/* A2N4 is replaced by v5's SB2 (end of this file): the sidebar keeps its width and moves with a transform */
/* A2N3: on a phone the "+" rests above Zmey's composer; the conversation keeps room under its last bubble for it */
@media (max-width: 760px) {
  body.fab-on .hm-page { padding-bottom: calc(var(--hit) + var(--sp-6)); }
}
/* A2N6: under reduced motion the rail's icons do not pop from half their size on a route change (their fill just shows) */
@media (prefers-reduced-motion: reduce) {
  #sb-rail .ui-icon .ic-fill, #sidebar .ui-nav .ui-icon .ic-fill { transform: none; transition: opacity var(--d1) linear; }
}

/* ======================================================================================================================
   Structure v5 (builder V1, 2026-11-13): the sidebar Stevie asked for (docs/feedback/2026-11-13-first-look.md, SB1 to SB10)
   ====================================================================================================================== */
/* SB1, SB5: one top row: the hide control, then the rail of five in its tray with the sliding lens; no app name */
.sb-top { gap: var(--sp-1); padding: 0 var(--sp-2) 0 var(--sp-1h); }
.sb-top > #sb-close { flex: none; }
.sb-top > .sb-rail { flex: 1 1 auto; min-width: 0; margin: 0; }
/* SB7: compact rows, the phone most of all: 28 px rows on the desktop, 36 on a phone (Notion's pitch), no gap between them,
   quieter section heads */
#sidebar { --h-nav: 28px; }
#sidebar .sb-list { gap: 0; }
#sidebar .sp-node { gap: 0; }
#sidebar .ui-nav-sec { height: 24px; margin-top: var(--sp-3); }
#sidebar .sb-sec:first-child .ui-nav-sec, #sidebar .sb-cap + .sb-sec .ui-nav-sec { margin-top: var(--sp-2); }
.sb-cap { margin-top: var(--sp-1); }
.sb-core { margin-top: var(--sp-1); }
@media (max-width: 760px) {
  #sidebar { --h-nav: 36px; }
  #sidebar .ui-nav-sec { height: 24px; margin-top: var(--sp-2h); }
  .sb-top { padding: 0 var(--sp-2) 0 var(--sp-1); }
  .sb-top > .sb-rail { margin: 0; }
}
/* SB8: New space is a small popup with one field (a sheet on a phone), never a field inside the sidebar */
.sp-pop { display: flex; flex-direction: column; gap: var(--sp-1h); padding: var(--sp-2) var(--sp-2h) var(--sp-2h); }
.sp-pop-h { padding: 0; }
.sp-pop .sp-input.ui-input { width: 100%; height: var(--hit); padding: 0 var(--sp-2h); }
.sp-pop .sp-err { padding: 0; }
/* SB10: New database is the Library's first row, a quiet create row */
.sb-new-db { margin-bottom: var(--sp-1); }
/* SB2, v7 F1: the desktop sidebar keeps its width while it hides; app.js slides it out through its margin and the page
   widens with it. Hidden it stays in the layout, out of sight: the margin takes its width and the gap off the window
   (the main column starts at the inset), visibility hides it from the eye, the pointer and the keyboard, and its scroll
   and state survive (no display: none on the desktop) */
@media (min-width: 761px) {
  body.sb-closed #sidebar { display: flex; visibility: hidden; margin-left: calc(-1 * var(--sidebar-w) - var(--inset)); }
}
/* N3: the place picker of a new session: a search, the recent places, every space with its places as a tree; the list
   scrolls inside its own box (a sheet on a phone, N4) */
.pp { display: flex; flex-direction: column; min-height: 0; }
.pp-find { flex: none; margin: var(--sp-2) var(--sp-2) var(--sp-1); }
.pp-find > .ui-input { width: 100%; }
.pp-list { flex: 1 1 auto; min-height: 0; max-height: min(52vh, 420px); overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--sp-1) var(--sp-1); box-shadow: none; background: none; }
.pp-list .pp-place { padding-left: calc(var(--sp-2h) + (var(--pp-depth, 1) - 1) * 16px + 12px); }
.pp-list .pp-space .ui-menu-item-l { font-weight: var(--w-medium); }
.pp-space-h { margin-top: var(--sp-1); }
.pp-empty { margin: 0; padding: var(--sp-2) var(--sp-2h); font-size: var(--fs-sm); color: var(--ink-3); }
@media (max-width: 760px) {
  .pp-list { max-height: 58vh; }
  .pp-find > .ui-input { height: var(--hit); font-size: max(16px, var(--fs-md)); }
}
/* X8: on a phone the floating "+" never covers the last rows: while it shows, every list page's scroller keeps room for it
   under its last row (the button is --hit high and rests --sp-4 above the bottom edge) */
@media (max-width: 760px) {
  body.fab-on #view :is(.db-fill .db-body, .pl-page--upcoming, .pl-cal-scroll, .cp, .dbp-works, .ib, .ag, .pj) { padding-bottom: calc(var(--hit) + var(--sp-6) + env(safe-area-inset-bottom)); }
  body.fab-on #view .hm-page { padding-bottom: calc(var(--hit) + var(--sp-6) + env(safe-area-inset-bottom)); }
}
.ui-pop.sheet .sp-pop { padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); }
/* N4: on a phone every dialog is a bottom sheet (New database, Import, ...), lifted by the keyboard; the search window
   keeps the top (it is the whole screen there) and the capture sheet has its own edge-to-edge form */
@media (max-width: 760px) {
  .ui-dialog:not(.sr-win):not(.cp-quick) {
    top: auto; bottom: calc(var(--inset) + env(safe-area-inset-bottom)); left: calc(var(--inset) + env(safe-area-inset-left)); right: calc(var(--inset) + env(safe-area-inset-right));
    width: auto; margin-left: 0; max-height: calc(var(--vvh, 100dvh) - 2 * var(--inset) - env(safe-area-inset-top)); overflow-y: auto; transform-origin: 50% 100%;
  }
  body.kb-open .ui-dialog:not(.sr-win):not(.cp-quick) { bottom: calc(var(--kb, 0px) + var(--inset)); }
  @starting-style { .ui-dialog:not(.sr-win):not(.cp-quick) { opacity: 0; transform: translateY(var(--m-rise)); } }
}

/* v7 (F31): Back and Forward at the top left, as Notion's arrows; quiet until hovered, faint while there is nowhere to go.
   A phone keeps its up arrow inside the crumbs instead. */
.nav-arrows { display: inline-flex; align-items: center; gap: 0; flex: none; margin-right: var(--sp-1); }
.nav-arrows .nav-btn { color: var(--ink-3); }
.nav-arrows .nav-btn:disabled { opacity: .35; }
@media (hover: hover) { .nav-arrows .nav-btn:not(:disabled):hover { color: var(--ink); } }
@media (max-width: 760px) { .nav-arrows { display: none; } }

/* ---------- v7 (W5): the last picture of a page, painted at once on a reload (app.js ghostPaint), gone in one frame
   once the real page has drawn. Still and inert (motion.css: nothing in it moves). ---------- */
html.ghost-wait #app { visibility: hidden; }
.view-ghost { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; min-height: 0; background: var(--paper); pointer-events: none; --view-top: var(--topbar-h); }
.view-ghost > * { padding-top: var(--topbar-h); scroll-padding-top: var(--topbar-h); }
.view-ghost *, .sb-ghost * { content-visibility: visible !important; }   /* still and small: every part paints in its first frame */
.view-ghost > .home { padding-top: calc(var(--topbar-h) + var(--sp-8)); }
.view-ghost > .session { padding-top: 0; }
.sb-ghost { position: absolute; inset: 0; z-index: 2; padding: 0 var(--sp-2) var(--sp-4); background: var(--panel); pointer-events: none; overflow: hidden; }
