/* carvel — base and components: the shared parts every view and panel builds from, a rail, nav, bar, tab, list, row, detail, composer, menu and table among them.
   It reads tokens.css only. */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--w-regular) var(--text-md)/var(--lh-ui) var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-md); }
::selection { background: var(--accent-soft); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* icon: 16 px, 1.5 stroke, currentColor */
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 14px; height: 14px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); height: 100vh; }
.rail { display: flex; flex-direction: column; background: var(--bg-rail); border-right: 1px solid var(--line); padding: var(--s-2); gap: 2px; min-height: 0; }
.main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); min-width: 0; min-height: 0; }

/* rail */
.switch { display: flex; align-items: center; gap: var(--s-2); height: 36px; padding: 0 var(--s-2); border-radius: var(--r-md); font-weight: var(--w-strong); width: 100%; text-align: left; }
.switch:hover, .nav:hover { background: var(--surface-2); }
.mark { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: var(--text); color: var(--bg); font-size: 11px; font-weight: 700; flex: none; }
.rail-head { display: flex; align-items: center; gap: 2px; margin-bottom: var(--s-2); }
.nav { display: flex; align-items: center; gap: 10px; height: var(--row-h); padding: 0 var(--s-2); border-radius: var(--r-md); color: var(--text-2); width: 100%; text-align: left; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.nav:hover { color: var(--text); }
.nav[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.nav .i { color: var(--text-3); }
.nav[aria-current="page"] .i, .nav:hover .i { color: var(--text-2); }
.rail-label { padding: var(--s-4) var(--s-2) var(--s-1); font-size: var(--text-sm); color: var(--text-3); }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); color: var(--text-3); font-size: var(--text-sm); }

/* count, dot, chip, kbd */
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center; font-size: var(--text-xs); font-variant-numeric: tabular-nums; color: var(--text-2); background: var(--surface-3); }
.count.attn { color: var(--attn); background: var(--attn-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.attn { background: var(--attn); }
.dot.live { background: var(--accent); box-shadow: 0 0 0 0 var(--accent-line); animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-line); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: var(--r-sm); font-size: var(--text-sm); color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap; }
.chip.attn { color: var(--attn); background: var(--attn-soft); box-shadow: none; }
.chip.bad { color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.chip.ok { color: var(--ok); background: var(--ok-soft); box-shadow: none; }
kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 4px; font: var(--w-regular) var(--text-xs)/1 var(--font-ui); color: var(--text-3); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }

/* buttons: one solid, one outlined, one ghost */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-h); padding: 0 10px; border-radius: var(--r-md); white-space: nowrap; transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.btn:active { transform: scale(.98); }
.btn-solid, .btn-primary { background: var(--solid); color: var(--text-on-solid); }
.btn-solid:hover, .btn-primary:hover { background: var(--solid-hover); }
.btn-solid kbd { background: var(--on-solid-fill); color: inherit; box-shadow: none; opacity: .75; }
/* The five names the page grew before this sheet are the same parts under an
   old name, and the extension panels' own scripts still write them; one rule
   carries both until the last caller moves. */
.btn-line, .btn-outline, .btn-danger, .btn-amber { box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-line:hover, .btn-outline:hover, .btn-danger:hover, .btn-amber:hover { background: var(--surface-2); }
.btn-ghost, .btn-quiet { color: var(--text-2); }
.btn-ghost:hover, .btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-icon { width: var(--control-h); padding: 0; color: var(--text-3); }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-lg { height: var(--control-h-lg); padding: 0 12px; }

/* inputs: one field, whether the markup names .input or is a bare box. A
   select keeps the browser's own arrow; a textarea drops the fixed height. */
.input, input:not([type]), input[type="text"], input[type="search"], input[type="number"], input[type="email"], input[type="url"], input[type="password"], select, textarea {
  height: var(--control-h-lg); padding: 0 10px; border: 0; border-radius: var(--r-md);
  background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line-strong);
  outline: none; transition: box-shadow var(--t-fast) var(--ease);
}
.input { width: 100%; }
textarea { height: auto; min-height: 56px; padding: 7px 10px; }
::placeholder { color: var(--text-3); }
.input:focus, input:focus, select:focus, textarea:focus { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
.input:disabled, input:disabled, select:disabled, textarea:disabled { color: var(--text-3); }

/* ---------- the bar above a view ---------- */
.bar { display: flex; align-items: center; gap: var(--s-3); height: 48px; padding: 0 var(--s-4) 0 var(--s-5); border-bottom: 1px solid var(--line); }
.bar h1 { font-size: var(--text-md); font-weight: var(--w-strong); }
.tabs { display: flex; gap: 2px; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: var(--control-h); padding: 0 9px; border-radius: var(--r-md); color: var(--text-2); }
.tab:hover { background: var(--surface-2); color: var(--text); }
/* A picked tab: aria-selected where the tab set owns the choice, aria-current
   where the page marks the view it shows, aria-pressed where the control is a
   pressed toggle. */
.tab[aria-selected="true"], .tab[aria-current], .tab[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.sep { width: 1px; height: 16px; background: var(--line-strong); }

/* ---------- list ---------- */
.split { display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr); min-height: 0; }
.list { overflow: auto; border-right: 1px solid var(--line); padding: 0 var(--s-2) var(--s-6); }
.group { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: var(--s-2); height: 36px; padding: 0 var(--s-3); background: var(--bg); font-size: var(--text-sm); color: var(--text-2); }
.group .btn { margin-left: auto; height: 24px; font-size: var(--text-sm); }
.row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; column-gap: var(--s-3); align-items: start; padding: 9px var(--s-3); border-radius: var(--r-lg); cursor: default; position: relative; transition: background var(--t-fast) var(--ease); }
.row + .row { margin-top: 1px; }
.row:hover { background: var(--surface-2); }
.row[aria-selected="true"] { background: var(--surface-3); }
.row .i { margin-top: 2px; }
.row-title { color: var(--text); }
.row-sub { color: var(--text-2); margin-top: 1px; }
.row-meta { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--text-3); padding-top: 1px; }
.row.read .row-title { color: var(--text-2); }
.row.more { color: var(--text-2); align-items: center; }
.k-decision { color: var(--attn); }
.k-order { color: var(--accent); }
.k-failed { color: var(--bad); }
.k-proof { color: var(--info); }
.k-note { color: var(--text-3); }

/* ---------- detail ---------- */
.detail { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.detail-body { overflow: auto; padding: var(--s-8) var(--s-10) var(--s-10); }
.detail-inner { max-width: var(--read-w); margin: 0 auto; }
.eyebrow { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--text-2); margin-bottom: var(--s-3); }
.detail h2 { font-size: var(--text-2xl); line-height: 1.25; font-weight: var(--w-strong); letter-spacing: -.01em; text-wrap: balance; }
.prose { font-family: var(--font-read); font-size: var(--text-lg); line-height: var(--lh-read); color: var(--text-2); margin-top: var(--s-4); max-width: 62ch; }
.prose p + p { margin-top: var(--s-3); }
.prose strong { color: var(--text); font-weight: var(--w-strong); }
.section { margin-top: var(--s-8); }
.section-label { font-size: var(--text-sm); color: var(--text-3); margin-bottom: var(--s-2); }
.choices { display: grid; gap: var(--s-2); }
.choice { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; column-gap: var(--s-3); align-items: start; width: 100%; text-align: left; padding: var(--s-3) var(--s-4) var(--s-3) var(--s-3); border-radius: var(--r-lg); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.choice:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.choice[aria-checked="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.choice-title { display: flex; align-items: center; gap: var(--s-2); }
.choice-sub { color: var(--text-2); margin-top: 2px; }
.choice kbd { margin-top: 1px; }
.choice[aria-checked="true"] kbd { color: var(--accent); background: transparent; box-shadow: inset 0 0 0 1px var(--accent-line); }
.timer { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3); font-size: var(--text-sm); color: var(--text-3); }
.meter { width: 72px; height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--attn); border-radius: 2px; }
.detail-foot { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-10); border-top: 1px solid var(--line); }
.detail-foot .inner { display: flex; align-items: center; gap: var(--s-2); width: 100%; max-width: var(--read-w); margin: 0 auto; }

/* ---------- dialog ----------
   A popup over the page: the `pop` part on the browser's own <dialog>, so the
   focus is held inside it and Escape closes it without a line of script. The
   backdrop is the scrim; a press on it closes the dialog (web/app-wiring.js). */
.dialog {
  width: min(34rem, calc(100vw - var(--s-6)));
  max-width: none;
  max-height: min(84vh, 46rem);
  margin: auto;
  padding: 0 var(--s-4) var(--s-4);
  border: 0;
  overflow: auto;
  background: var(--surface-1);
  color: var(--text);
  font-size: var(--text-md);
  box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.dialog:not([open]) { display: none; }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  padding: var(--s-4) 0 var(--s-3);
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
}
.dialog-title { flex: 1; min-width: 0; font-size: var(--text-xl); font-weight: var(--w-strong); line-height: 1.25; text-wrap: balance; }
.dialog-close { flex: none; align-self: flex-start; }
.dialog-id { flex: none; font: var(--w-regular) var(--text-xs)/1 var(--font-mono); color: var(--text-3); }
.dialog-lead {
  margin: var(--s-3) 0 0;
  font-family: var(--font-read);
  font-size: var(--text-lg);
  line-height: var(--lh-read);
  color: var(--text-2);
  text-wrap: pretty;
}
.dialog-waits {
  display: grid;
  gap: 2px;
  margin-top: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  background: var(--attn-soft);
}
.dialog-wait { margin: 0; font-size: var(--text-sm); line-height: 1.5; color: var(--text); }
.dialog-error { margin: var(--s-3) 0 0; font-size: var(--text-sm); color: var(--bad); }
.dialog-picks { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-3); }
.dialog-machine { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--text-3); }
.dialog-fold { margin-top: var(--s-3); }
.dialog-fold-head { font-size: var(--text-sm); color: var(--text-2); cursor: pointer; }
.dialog-fold-head:hover { color: var(--text); }
.dialog-overlap, .dialog-rule { margin-top: var(--s-3); font-size: var(--text-sm); color: var(--text-2); }
.model-rules-picked { margin: var(--s-2) 0 0; padding: 0; list-style: none; font-size: var(--text-xs); color: var(--text-2); max-height: 14rem; overflow: auto; }
.model-rules-picked li { display: flex; gap: var(--s-2); padding: var(--s-1) 0; }
.model-rules-order { flex: none; font-family: var(--font-mono); color: var(--text); }
.model-rules-line { min-width: 0; overflow-wrap: anywhere; }
.dialog-file { margin-top: var(--s-2); border-radius: var(--r-md); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.dialog-file-text {
  margin: 0;
  max-height: 40vh;
  overflow: auto;
  padding: var(--s-3);
  font: var(--w-regular) var(--text-sm)/20px var(--font-mono);
  color: var(--text-2);
  white-space: pre-wrap;
}
.dialog .order-actions { margin-top: var(--s-4); }
.dialog .field-readonly { font-size: var(--text-sm); color: var(--text-2); }

/* ---------- composer ---------- */
.composer { padding: var(--s-3) var(--s-5) var(--s-4); border-top: 1px solid var(--line); }
.composer-box { display: flex; align-items: center; gap: var(--s-2); max-width: 820px; margin: 0 auto; min-height: 48px; padding: 6px 8px 6px 14px; border-radius: var(--r-xl); background: var(--surface-1); box-shadow: var(--shadow-float); }
.composer-box input { font-family: var(--font-read); flex: 1; min-width: 0; height: 34px; border: 0; outline: 0; background: transparent; font-size: var(--text-lg); }
.composer-box input::placeholder { color: var(--text-3); }
.send { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--solid); color: var(--text-on-solid); }
.send .i { stroke-width: 2.1; }

/* ---------- menus, the palette, toasts ---------- */
.pop { background: var(--surface-1); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); }
.scrim { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px); display: grid; place-items: start center; padding-top: 14vh; }
.palette { width: 620px; overflow: hidden; }
.palette-in { display: flex; align-items: center; gap: var(--s-3); height: 52px; padding: 0 var(--s-4); border-bottom: 1px solid var(--line); font-size: 15px; color: var(--text-3); }
.palette-list { padding: var(--s-2); }
.cmd { display: flex; align-items: center; gap: var(--s-3); height: 36px; padding: 0 var(--s-3); border-radius: var(--r-md); color: var(--text-2); }
.cmd[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
.cmd .keys { margin-left: auto; display: flex; gap: 3px; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: var(--s-3); height: 40px; padding: 0 6px 0 14px; }

/* ================= the parts added for the other screens =================
   Same tokens, radii and motion as the reference; nothing here restates a colour. */
[hidden] { display: none !important; }

/* menu: a pop anchored to the control that opened it */
.menu { position: relative; display: inline-flex; }
.menu-list { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; min-width: 232px; padding: var(--s-2); border-radius: var(--r-lg); background: var(--surface-1); box-shadow: var(--shadow-pop); }
.menu-list.left { right: auto; left: 0; }
.menu-label { padding: var(--s-1) var(--s-2); font-size: var(--text-sm); color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: var(--s-2); width: 100%; height: var(--control-h); padding: 0 var(--s-2); border-radius: var(--r-md); color: var(--text-2); text-align: left; }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item .keys { margin-left: auto; display: flex; gap: 3px; }
.menu-sep { height: 1px; margin: var(--s-2) 0; background: var(--line); }

/* select: a native select wearing the control */
.select { position: relative; display: inline-flex; align-items: center; }
.select select { appearance: none; height: var(--control-h); padding: 0 24px 0 9px; border: 0; border-radius: var(--r-md); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--text); }
.select select:hover { background: var(--surface-2); }
.select .i { position: absolute; right: 6px; color: var(--text-3); pointer-events: none; }

/* toggle */
.toggle { position: relative; width: 34px; height: 20px; flex: none; border-radius: 10px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); transition: background var(--t-fast) var(--ease); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.toggle[aria-checked="true"] { background: var(--accent); box-shadow: none; }
.toggle[aria-checked="true"]::after { transform: translateX(14px); background: var(--text-on-solid); }

/* tooltip: on hover and focus; .open holds it still for the kit */
.tip { position: relative; display: inline-flex; }
.tip::after { content: attr(data-tip); position: absolute; z-index: 40; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 2px); padding: 3px var(--s-2); border-radius: var(--r-sm); background: var(--surface-3); color: var(--text); font-size: var(--text-sm); line-height: 18px; white-space: nowrap; box-shadow: var(--shadow-float); opacity: 0; pointer-events: none; transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.tip:hover::after, .tip:focus-visible::after, .tip.open::after { opacity: 1; transform: translate(-50%, 0); }

/* table: the fleet's groups; the group label rides inside a full-width row */
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th { height: 32px; padding: 0 var(--s-2); font-size: var(--text-sm); font-weight: var(--w-regular); color: var(--text-3); border-bottom: 1px solid var(--line); }
.table td { height: 44px; padding: 4px var(--s-2); color: var(--text-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[aria-selected="true"] { background: var(--surface-3); }
.table .crew { display: flex; align-items: center; gap: var(--s-2); color: var(--text); }
.table .state { display: block; }
.table .step { display: block; font-size: var(--text-sm); color: var(--text-3); }
.table .num { color: var(--text-3); }
.table .end { text-align: right; }
.table .grouprow td { height: auto; padding: 0; border-bottom: 0; }

/* notice: one line, one action, in place */
.notice { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: var(--text-sm); }
.notice .i { color: var(--text-3); }
.notice.attn { color: var(--attn); background: var(--attn-soft); box-shadow: none; }
.notice.bad { color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.notice.info { color: var(--info); background: var(--info-soft); box-shadow: none; }
.notice.ok { color: var(--ok); background: var(--ok-soft); box-shadow: none; }
.notice.attn .i, .notice.bad .i, .notice.info .i, .notice.ok .i { color: inherit; }
.notice .btn { margin-left: auto; height: 22px; padding: 0 7px; font-size: var(--text-sm); color: inherit; }
.notice .btn:hover { background: var(--surface-2); }

/* skeleton row: the shape of a row while it loads, no shimmer, no shift */
.skel { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; column-gap: var(--s-3); align-items: start; padding: 9px var(--s-3); }
.skel span { display: block; height: 10px; border-radius: var(--r-sm); background: var(--surface-3); }
.skel .t { margin-top: 3px; }
.skel .s { margin-top: 9px; }
.skel .m { width: 40px; margin-top: 4px; }

/* code: one ink at two weights; the header names the language and copies */
.code { border-radius: var(--r-lg); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.code-head { display: flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-2) 0 var(--s-3); border-bottom: 1px solid var(--line); font-size: var(--text-sm); color: var(--text-3); }
.code-head .btn { margin-left: auto; height: 22px; padding: 0 7px; font-size: var(--text-xs); }
.code pre { margin: 0; padding: var(--s-3); overflow: auto; font: var(--w-regular) var(--text-sm)/20px var(--font-mono); color: var(--text-2); }
.code .w { font-weight: var(--w-strong); }
.code .c { color: var(--text-3); }

/* diff */
.diff { border-radius: var(--r-lg); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; font: var(--w-regular) var(--text-sm)/20px var(--font-mono); color: var(--text-2); }
.diff-head { display: flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3); border-bottom: 1px solid var(--line); font-size: var(--text-sm); color: var(--text-3); }
.diff-line { display: flex; gap: var(--s-3); padding: 0 var(--s-3); }
.diff-line .ln { width: 26px; flex: none; text-align: right; color: var(--text-3); }
.diff-line .sg { width: 8px; flex: none; color: var(--text-3); }
.diff-line.add { background: var(--ok-soft); }
.diff-line.add .sg { color: var(--ok); }
.diff-line.del { background: var(--bad-soft); }
.diff-line.del .sg { color: var(--bad); }
.diff-line.ctx { color: var(--text-3); }

/* message: no bubbles; the owner's own words sit on the raised surface */
.msg { max-width: var(--chat-w); }
.msg + .msg { margin-top: var(--s-6); }
.msg-meta { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-1); font-size: var(--text-sm); color: var(--text-3); }
.msg-meta b { font-weight: var(--w-strong); color: var(--text-2); }
.msg-body { max-width: 62ch; font-family: var(--font-read); font-size: var(--text-lg); line-height: var(--lh-read); color: var(--text-2); }
.msg-body p + p { margin-top: var(--s-3); }
.msg-body strong { color: var(--text); font-weight: var(--w-strong); }
.msg-body code { font-family: var(--font-mono); font-size: var(--text-md); color: var(--text); }
.msg-owner .msg-body { padding: var(--s-3) var(--s-4); border-radius: var(--r-lg); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); }
.msg > .code, .msg > .diff { margin-top: var(--s-3); }

/* work fold: the steps between two answers, one line until opened */
.work { max-width: var(--chat-w); margin: var(--s-5) 0; }
.work-line { display: flex; align-items: center; gap: var(--s-2); height: var(--control-h); padding: 0 var(--s-2); border-radius: var(--r-md); font-size: var(--text-sm); color: var(--text-3); text-align: left; }
.work-line:hover { background: var(--surface-2); color: var(--text-2); }
.work-line > .i { transition: transform var(--t-fast) var(--ease); }
.work-line .num { color: var(--text-2); }
.work[aria-expanded="true"] .work-line { color: var(--text-2); }
.work[aria-expanded="true"] .work-line > .i { transform: rotate(90deg); }
.work-body { display: grid; gap: 2px; margin: var(--s-1) 0 0 14px; padding-left: var(--s-3); border-left: 1px solid var(--line); font-size: var(--text-sm); color: var(--text-2); }
.work-step { display: flex; align-items: center; gap: var(--s-2); height: 26px; }
.work-step .i { color: var(--text-3); }
.work-step .num { margin-left: auto; color: var(--text-3); }

/* timeline: a hairline through the dots of a part's checkpoints */
.timeline { display: flex; align-items: center; margin-top: var(--s-3); }
.timeline > * + * { margin-left: var(--s-2); }
.timeline .seg { flex: 1; height: 1px; background: var(--line-strong); }

/* empty: one sentence and one action */
.empty { display: grid; justify-items: center; align-content: center; gap: var(--s-2); height: 100%; padding: var(--s-8) var(--s-5); text-align: center; }
.empty h2 { font-size: var(--text-xl); font-weight: var(--w-strong); }
.empty p { max-width: 46ch; color: var(--text-2); }
.empty .btn, .empty .tn { margin-top: var(--s-3); }
.input.on { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--bad); }
.page-inner.narrow { max-width: var(--chat-w); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.toast.inline { position: static; transform: none; }
.row > .dot { margin-top: 6px; }

/* the shell and the parts the reference did not need yet */
.split > .list { grid-column: 1; grid-row: 1; }
.split > .detail { grid-column: 2; grid-row: 1; min-height: 0; }
.split.fleet { grid-template-columns: var(--fleet-w) minmax(0, 1fr); }
.detail h2.sm { font-size: var(--text-xl); }
.detail-back { display: none; margin-bottom: var(--s-3); }
.transcript { overflow: auto; padding: var(--s-6) var(--s-5); }
.transcript-inner { max-width: var(--chat-w); margin: 0 auto; }
.ctx { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--text-3); }
.ctx .meter { width: 72px; }
.ctx .meter > i { background: var(--accent); }
.ctx.hi { color: var(--attn); }
.ctx.hi .meter { background: var(--attn-soft); }
.ctx.hi .meter > i { background: var(--attn); }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-2); font-size: var(--text-sm); color: var(--text-3); }
.meta-line b { font-weight: var(--w-regular); color: var(--text-2); }
.subnav { width: 208px; padding: var(--s-4) var(--s-2) var(--s-6) 0; border-right: 1px solid var(--line); }
.settings { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 0; }
.page { overflow: auto; }
.page-inner { max-width: 820px; padding: var(--s-8) var(--s-10) var(--s-10); }
.page h2 { font-size: var(--text-2xl); line-height: 1.25; font-weight: var(--w-strong); letter-spacing: -.01em; }
.page-lead { max-width: 62ch; margin-top: var(--s-2); font-family: var(--font-read); font-size: var(--text-lg); line-height: var(--lh-read); color: var(--text-2); }
.setrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-6); align-items: center; padding: var(--s-4) 0; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }
.setrow-label { color: var(--text); }
.setrow-help { max-width: 46ch; margin-top: 2px; font-size: var(--text-sm); color: var(--text-2); }
.setrow-ctl { display: flex; align-items: center; gap: var(--s-2); }
.setrow-ctl .input { width: 96px; text-align: right; }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); }
.seg .tab { height: 24px; }
.danger { color: var(--bad); }
.token { font-family: var(--font-mono); color: var(--text); }
.quote { margin: var(--s-3) 0 0; padding-left: var(--s-4); border-left: 2px solid var(--line-strong); font-family: var(--font-read); font-size: var(--text-lg); line-height: var(--lh-read); color: var(--text); }
.part { margin-top: var(--s-3); padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); }
.part-head { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--text-3); }
.part-head b { font-weight: var(--w-strong); color: var(--text); }
.part .prose { margin-top: var(--s-2); font-size: var(--text-md); }
.topic-view { display: grid; grid-template-columns: minmax(0, 1fr) 216px; min-height: 0; }
.outline { position: sticky; top: 0; align-self: start; padding: var(--s-8) var(--s-4) 0; font-size: var(--text-sm); color: var(--text-3); }
.outline a { display: block; padding: 3px 0; color: var(--text-3); }
.outline a:hover { color: var(--text); }
.login-shell { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 100dvh; }
.login { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; min-height: 0; padding: var(--s-5); }
.login-card { display: grid; gap: var(--s-3); width: 360px; max-width: 100%; padding: var(--s-6); border-radius: var(--r-xl); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); }
.login-card h1 { font-size: var(--text-xl); font-weight: var(--w-strong); }
.login-card p { font-size: var(--text-sm); color: var(--text-2); }
.login-card .mark { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
.login-card .btn { width: 100%; justify-content: center; }
.shot { margin-top: var(--s-4); padding: var(--s-3); border-radius: var(--r-lg); background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line); }
.shot svg { display: block; width: 100%; height: auto; border-radius: var(--r-sm); }
.tabbar { display: none; }

/* ---------- 720 to 1099 px: the rail keeps its icons, the detail slides over the list ---------- */
@media (min-width: 720px) and (max-width: 1099px) {
  .app { grid-template-columns: var(--rail-w-compact) minmax(0, 1fr); }
  .rail { padding: var(--s-2) 6px; }
  .rail-head { justify-content: center; }
  .rail .switch { justify-content: center; padding: 0; }
  .rail .switch span:not(.mark), .rail .rail-head > .btn-icon, .rail .rail-head > .switch .i,
  .rail .nav .grow, .rail .nav .faint, .rail .nav .count, .rail .nav .dot,
  .rail .rail-label, .rail-foot .grow { display: none; }
  .nav { justify-content: center; padding: 0; }
  .rail-foot { justify-content: center; padding: var(--s-2) 0; }
  .split, .split.fleet { position: relative; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
  /* The sheet covers the list here; its 180 ms slide belongs to the running page, so a reference
     page opens at rest and a screenshot is the state, not a frame of an animation. */
  .split > .detail { position: absolute; inset: 0; z-index: 2; grid-column: 1; grid-row: 1; background: var(--bg); }
  /* a narrow screen shows the list until a detail is named in the query */
  :root:not([data-detail]) .split > .detail { display: none; }
  .detail-back { display: inline-flex; }
  .detail-body { padding: var(--s-6) var(--s-5) var(--s-8); }
  .detail-foot { padding: var(--s-3) var(--s-5); }
  .list { border-right: 0; }
  .settings { grid-template-columns: 176px minmax(0, 1fr); }
  .page-inner { padding: var(--s-6) var(--s-5) var(--s-8); }
  .topic-view { grid-template-columns: minmax(0, 1fr); }
  .outline { display: none; }
}

/* ---------- below 720 px: no rail, a bottom tab bar, the detail as a full screen ---------- */
@media (max-width: 719px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100dvh; }
  /* `.rail` is the navigation rail alone; the transcript's class is `turn-rail`. */
  .rail { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom); background: var(--bg-rail); border-top: 1px solid var(--line); }
  .tabbar a { display: grid; place-items: center; align-content: center; gap: 3px; height: 100%; font-size: var(--text-xs); color: var(--text-3); }
  .tabbar a[aria-current="page"] { color: var(--text); }
  .bar { height: 52px; padding: 0 var(--s-3); gap: var(--s-2); }
  .bar h1 { font-size: var(--text-md); }
  .bar .btn, .btn-icon { height: 44px; }
  .btn-icon { width: 44px; }
  .detail-body, .page-inner, .transcript { padding: var(--s-4) var(--s-4) var(--s-6); }
  .detail-foot, .composer { padding: var(--s-2) var(--s-4) var(--s-3); }
  .composer-box { min-height: 44px; }
  .send { width: 36px; height: 36px; }
  .list { padding: 0 var(--s-1) var(--s-4); }
  .row { padding: 11px var(--s-2); }
  .detail h2, .page h2 { font-size: var(--text-xl); }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .subnav { display: flex; flex-wrap: wrap; width: auto; padding: var(--s-2) var(--s-3); border-right: 0; border-bottom: 1px solid var(--line); }
  .subnav .nav { width: auto; flex: none; height: 36px; padding: 0 10px; }
  .setrow { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .detail-foot .inner { flex-wrap: wrap; }
  .detail-foot .faint.num, .detail-foot kbd { display: none; }
  .table th:nth-child(2), .table td:nth-child(2), .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
  .palette { width: calc(100vw - 32px); }
  .hide-sm { display: none !important; }
  .bar .tabs { min-width: 0; flex: 0 1 auto; overflow: auto; }
  .toast { bottom: calc(var(--tabbar-h) + var(--s-3)); }
}

/* the kit: two columns of parts, one below the phone breakpoint */
.kit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-8) var(--s-10); margin-top: var(--s-8); }
.kit .section { margin-top: 0; }
.kit .wide { grid-column: 1 / -1; }
.kit-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-3); }
@media (max-width: 719px) { .kit { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); } }

/* The two modifiers the page needs beyond the design's three: a destructive
   action keeps its outline and takes the bad ink, a rebuild takes attention. */
.btn-bad, .btn-danger { color: var(--bad); }
.btn-bad:hover, .btn-danger:hover { background: var(--bad-soft); }
.btn-attn, .btn-amber { color: var(--attn); }
.btn-attn:hover, .btn-amber:hover { background: var(--attn-soft); }
/* The pressed state of a control that opens a panel: the same fill a picked
   tab takes, so an open panel reads on the control that opened it. */
.btn[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

/* ---------- the work pane: the file the selected chat's agent is writing ----------
   One monospace face, line numbers, the language's own colour from the chat's
   tokenizer, and a line's own indentation drawn as it is: `white-space: pre`
   and a tab that is a tab of the pane's width, never a trimmed or reflowed
   line. The edit's new words are a highlight range, so the marker adds no
   element and the syntax colour under it stays. */
.wp-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
  height: 40px;
  padding: 0 var(--s-2) 0 var(--s-3);
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
}
.wp-path { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text); }
.wp-meta { flex: none; font-size: var(--text-sm); color: var(--text-3); white-space: nowrap; }
.wp-close { width: var(--control-h); padding: 0; color: var(--text-3); }

.wp-note {
  flex: none;
  margin: 0;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--text-2);
}
.wp-note[hidden] { display: none; }
.wp-empty {
  flex: 1;
  display: grid;
  place-items: center;
  margin: 0;
  padding: var(--s-6) var(--s-5);
  color: var(--text-3);
  font-size: var(--text-sm);
  text-align: center;
}
.wp-empty[hidden] { display: none; }

.wp-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--s-2) 0 var(--s-6);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text);
  tab-size: 4;
  -moz-tab-size: 4;
}
.wp-body[hidden] { display: none; }
.wp-body:focus-visible { outline: var(--accent-line) solid 2px; outline-offset: -2px; }
.wp-line { display: flex; gap: var(--s-3); width: max-content; min-width: 100%; padding: 0 var(--s-3); }
.wp-line:hover { background: var(--surface-2); }
.wp-n {
  flex: none;
  width: 4.5ch;
  text-align: right;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  user-select: none;
}
/* A tab draws as a tab, and a line's own indentation is never trimmed: the
   only trimming is a scroll of the pane, never of the page. */
.wp-text { white-space: pre; }
.wp-line.is-hunk { background: var(--accent-soft); }
.wp-line.is-hunk:hover { background: var(--accent-soft); }
.wp-line.is-hunk-head { box-shadow: inset 2px 0 0 var(--accent); }
/* The marker: the words the edit added, underlined in the in-motion indigo
   under the syntax's own ink and washed lighter than the hunk's tint. A shape,
   not just a strength: an inserted block has no unchanged word inside its hunk,
   so a wash alone read as one deeper tint and the diff was invisible (13 Nov
   2026). Where CSS.highlights is missing, the hunk tint is what is left. */
::highlight(pane-mark) {
  background-color: color-mix(in srgb, var(--accent) 16%, transparent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
/* An edit that only removed words marks nothing: a small sign in the gutter at
   the line where they went, beside the number and taking no space of its own. */
.wp-line.is-del .wp-n { position: relative; }
.wp-line.is-del .wp-n::before {
  content: "−";
  position: absolute;
  left: calc(-1 * var(--s-3) + 2px);
  color: var(--accent);
  font-weight: 700;
}
/* The hunk lands once, when the call it came from is new. */
.wp-line.is-fresh { animation: wp-land 260ms var(--ease) both; }
@keyframes wp-land {
  from { background: var(--accent-line); }
  to { background: var(--accent-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .wp-line.is-fresh { animation: none; }
}
.wp-gap {
  padding: var(--s-1) var(--s-3);
  color: var(--text-3);
  font-size: var(--text-xs);
  background: var(--surface-2);
}

.wp-editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: var(--s-2) var(--s-3);
  border: 0;
  resize: none;
  background: var(--surface-1);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  tab-size: 4;
  -moz-tab-size: 4;
  white-space: pre;
  overflow: auto;
}
.wp-editor[hidden] { display: none; }

/* Settings -> Projects: project bundle export & import */
.settings-project-export { display: flex; flex-direction: column; gap: 0.375rem; padding-top: 0.5rem; border-top: 1px solid var(--border, rgba(255,255,255,0.08)); min-width: 0; max-width: 100%; }
.settings-export-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.settings-export-status, .settings-import-status { margin: 0; min-width: 0; max-width: min(65ch, 100%); overflow-wrap: anywhere; font-size: var(--fs-12, 0.8125rem); line-height: 1.45; color: var(--bone-2, var(--text, inherit)); }
.settings-export-status:empty, .settings-import-status:empty { display: none; }
.settings-bundle-error { color: var(--danger); }
.settings-project-import { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border, rgba(255,255,255,0.1)); display: flex; flex-direction: column; gap: 0.625rem; min-width: 0; max-width: 100%; }
.settings-project-import .field-label { margin: 0; color: var(--bone, var(--text, inherit)); }
.settings-project-hail-hint { min-width: 0; max-width: min(60ch, 100%); overflow-wrap: anywhere; }
.settings-import-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.settings-import-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: var(--fs-12, 0.8125rem); color: var(--bone-3, var(--text-muted, inherit)); min-width: 0; }
.settings-import-path-wrap { flex: 1 1 16rem; }
.settings-import-path, .settings-import-mode { min-height: 2rem; font-family: var(--font-mono); font-size: var(--fs-12, 0.8125rem); color: var(--bone, var(--text, inherit)); max-width: 100%; box-sizing: border-box; }
.settings-import-file { max-width: 100%; font-size: var(--fs-12, 0.75rem); }
.settings-import-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
@media (max-width: 700px) { .settings-import-field, .settings-import-path-wrap, .settings-import-path, .settings-import-mode { flex-basis: 100%; width: 100%; max-width: 100%; } }
