/* Layout: header bar, then three columns: code | stage (scene, narration, timeline) | inspector. Stacks to one column on phones. */
:root {
  --bg: #F6F1E7; --surface: #FFFDF8; --surface-2: #EFE7D6; --ink: #1F1A14; --muted: #5E5648; --line: #D9CFBC; --line-strong: #8C8066;
  --accent: #B8400F; --accent-soft: #F6E1D3; --teal: #146B5E; --teal-soft: #DCEFEA; --blue: #1F4FA8; --blue-soft: #E4EAF7; --note: #FFF6D6; --note-line: #9C7F1E;
  --ok: #1E6B47; --ok-soft: #DDEFE5; --bad: #A3261D; --bad-soft: #F7DDD8;
  --on-accent: #FFFFFF; --accent-ink: #A03609; --focus: #1A4FB8; --warn: #7A5C00;
  --code-bg: #EFE7D6; --code-edge: #D9CFBC; --code-ink: #2A241B; --code-muted: #6B6252; --code-muted-cur: #5A5142; --code-cur: #F3D9B8; --code-cur-bar: #B8400F; --code-err: #F7DDD8;
  --r-ctl: 4px; --r-panel: 6px; --fs-xs: 12px;
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235E5648' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5'/%3E%3Cpath d='m12.5 12.5 5 5'/%3E%3C/svg%3E"); /* the magnifier uses --muted: a data URI cannot read a variable */
  --f-ui: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #17130F; --surface: #1F1A14; --surface-2: #2A241B; --ink: #F3ECDD; --muted: #B7AC98; --line: #3A3228; --line-strong: #766A55;
  --accent: #F08A55; --accent-soft: #3A2417; --teal: #4FD1B8; --teal-soft: #0F3B35; --blue: #8FB0FF; --blue-soft: #1C2747; --note: #3A3312; --note-line: #7A6A2A;
  --ok: #6FD3A1; --ok-soft: #173326; --bad: #FF8A7E; --bad-soft: #3B1D19;
  --code-bg: #0F0C09; --code-edge: #3A3228; --code-ink: #EDE5D3; --code-muted: #A99E8A; --code-muted-cur: #A99E8A;
  --on-accent: #1A0F08; --accent-ink: #F59A6B; --focus: #8FB0FF; --warn: #E5C76B; --code-cur: #3A2A17; --code-cur-bar: #F08A55; --code-err: #3B1D19;
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23B7AC98' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5'/%3E%3Cpath d='m12.5 12.5 5 5'/%3E%3C/svg%3E");
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #17130F; --surface: #1F1A14; --surface-2: #2A241B; --ink: #F3ECDD; --muted: #B7AC98; --line: #3A3228; --line-strong: #766A55;
  --accent: #F08A55; --accent-soft: #3A2417; --teal: #4FD1B8; --teal-soft: #0F3B35; --blue: #8FB0FF; --blue-soft: #1C2747; --note: #3A3312; --note-line: #7A6A2A;
  --ok: #6FD3A1; --ok-soft: #173326; --bad: #FF8A7E; --bad-soft: #3B1D19;
  --code-bg: #0F0C09; --code-edge: #3A3228; --code-ink: #EDE5D3; --code-muted: #A99E8A; --code-muted-cur: #A99E8A;
  --on-accent: #1A0F08; --accent-ink: #F59A6B; --focus: #8FB0FF; --warn: #E5C76B; --code-cur: #3A2A17; --code-cur-bar: #F08A55; --code-err: #3B1D19;
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23B7AC98' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5'/%3E%3Cpath d='m12.5 12.5 5 5'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--f-ui); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.top { background: var(--surface); border-bottom: 1px solid var(--line);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; margin-right: 8px; color: var(--ink); text-decoration: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a { padding: 8px 12px; border-radius: var(--r-ctl); color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.grow { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--surface); display: inline-flex; align-items: center; justify-content: center; font: 700 12px var(--f-ui); letter-spacing: .02em; flex: none; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.btn { height: 38px; padding: 0 14px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.big { height: 46px; padding: 0 22px; font-size: 16px; }
.btn.danger { color: var(--bad); }
.btn:disabled, .btn.primary:disabled, .btn.danger:disabled { opacity: 1; background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); cursor: default; } /* a flat inactive look that still reads (muted on surface-2 is 5.9:1; opacity .5 put the text at 2.5-3.3:1); the dashed border tells it from a pill, which never has one */
.status { font-size: 13px; color: var(--muted); min-width: 0; }
.status.err { color: var(--bad); }
.err { color: var(--bad); font-size: 14px; margin: 0; min-height: 1.2em; }

.view { max-width: 1400px; margin-inline: auto; padding-block: 18px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; text-wrap: balance; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 10px; }

.auth { display: flex; justify-content: center; padding-top: 48px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 30px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; text-wrap: balance; } /* the two lines sat 46px apart; 1.15 reads as one heading */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 10px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.form input, .field input, .field textarea { border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); padding: 10px 12px; font-size: 15px; width: 100%; }
.mono { font-family: var(--f-mono); font-size: 13px !important; }

.composer { max-width: 1240px; display: flex; flex-direction: column; gap: 16px; }
.composer-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.composer-head .note { max-width: 70ch; margin: 0; }
.usage { font-size: 13px; color: var(--muted); }
.compose-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 860px) { .compose-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; min-width: 0; }
.field em { font-style: normal; color: var(--muted); font-weight: 500; }
.field textarea { resize: vertical; min-height: 280px; line-height: 1.55; tab-size: 4; }
.field textarea.mono { background: var(--code-bg); color: var(--code-ink); border-color: var(--code-bg); line-height: 1.75; white-space: pre; }
.wide { grid-column: 1 / -1; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font: 700 12px var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td a { display: inline-block; min-height: 24px; line-height: 24px; } /* a link standing alone in a cell is a control: 24px target (the admin feedback "Open run" links were 18px) */
.table tr.click { cursor: pointer; }
.table tr.click:hover td, .table tbody tr:not(.rv-row):hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--f-mono); font-size: 13px; }
.table th.num { font-size: 12px; } /* a numeric header is a Label (12px), not a 13px number */
.table .acts { display: flex; gap: 6px; justify-content: flex-end; }
.table .t { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 12px; }
a.pill { min-height: 24px; text-decoration: none; } /* a linked pill is a control: 24px target; the pill styling wins over the link underline */
a.pill:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; border-radius: var(--r-ctl); padding: 2px 9px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.busy { color: var(--blue); background: var(--blue-soft); }
.pill.muted { color: var(--muted); background: var(--surface-2); }
.empty-row { color: var(--muted); text-align: center; padding: 28px !important; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 14px; }
.tile .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tile .v { font: 600 26px var(--f-mono); font-variant-numeric: tabular-nums; margin-top: 4px; }
.tile .s { font-size: 12px; color: var(--muted); }
.admin-claude { margin-top: 12px; padding: 12px 14px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }

.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.run-head h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.run-head .summary { order: 3; flex: 1 1 100%; margin: 0; color: var(--muted); max-width: 90ch; }
.run-head .meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font: var(--fs-xs) var(--f-mono); color: var(--muted); }
.run-head .warns { order: 4; flex: 1 1 100%; }
.warns { font-size: 13px; color: var(--muted); }
.warns summary { cursor: pointer; }
.warns .hint { margin-left: 6px; }
.warns ul { margin: 6px 0 0; padding-left: 18px; max-height: 6em; overflow: auto; }
.warns li + li { margin-top: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar select, .toolbar input { height: 38px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctl); padding: 0 10px; min-width: 0; max-width: 100%; }
#custom { width: 100%; font-family: var(--f-mono); font-size: 13px; }
/* U11: one labelled toolbar. The picker's children join the toolbar's layout; a field whose control is hidden hides its label too. */
.toolbar { align-items: flex-end; gap: 12px 8px; }
.toolbar .picker { display: contents; }
.toolbar .picker[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.flabel { font-size: 12px; color: var(--muted); }
.field:has(> input[hidden], > select[hidden], > textarea[hidden]) { display: none; } /* a label whose own control is hidden goes with it. NOT any hidden child: a field's hidden error <p> used to hide the whole Problem field on the Dry run page */
.field-search { flex: 1 1 100%; }
.toolbar #run { min-width: 100px; } /* wide enough for "Run again", so the label swap does not move the selects */
::placeholder { color: var(--muted); opacity: 1; } /* every field: the browser's default grey is 3.7-4.5:1 on the paper fills; --muted is 5.9:1 or better */
.toolbar:has(> .picker[hidden]) .field-input { max-width: 480px; } /* run view: one lone select should not stretch across the page */
.field-problem { flex: 1 1 220px; }
.field-lang { flex: 0 0 140px; }
.field-input { flex: 1 1 180px; }
.field-custom, .toolbar .status { flex: 1 1 100%; }
.toolbar .field select { width: 100%; }
@media (max-width: 959px) {
  .toolbar { display: grid; grid-template-columns: 1fr 160px; align-items: end; }
  .toolbar > *, .toolbar .picker > * { min-width: 0; }
  .field-search, .field-custom, .toolbar .status { grid-column: 1 / -1; }
  .field-input { grid-column: 1; }
}
@media (max-width: 640px) {
  .toolbar { grid-template-columns: 1fr; }
  .toolbar .btn#run { width: 100%; min-height: 40px; }
}
.progress { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px; margin-bottom: 14px; }
.steps { display: flex; flex-wrap: wrap; gap: 8px 22px; list-style: none; margin: 0; padding: 0; font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.steps li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); }
.steps li.done { color: var(--ink); } .steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.now { color: var(--ink); font-weight: 600; } .steps li.now::before { border-color: var(--blue); background: var(--blue-soft); }
@media (prefers-reduced-motion: no-preference) { .steps li.now::before { animation: pulse 1.2s ease-in-out infinite; } @keyframes pulse { 50% { transform: scale(1.35); } } }
.scalar-big { font: 600 28px var(--f-mono); }
.narr .why { display: block; margin-bottom: 4px; font-weight: 600; }
.narr .what { color: var(--ink); font-size: 14px; }
.blk.unset { border: 1px dashed var(--muted); border-radius: var(--r-panel); padding: 8px 10px; } /* state is the dashed border and the words, not faintness (U27) */

.layout { display: grid; grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.6fr) minmax(250px, 0.7fr); gap: 14px; align-items: start; }
@media (max-width: 1180px) { .layout { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.5fr); } .side { grid-column: 1 / -1; } }
@media (max-width: 760px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); min-width: 0; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; font-weight: 700; }

/* code */
.code-panel { background: var(--code-bg); border-color: var(--code-edge); color: var(--code-ink); overflow: hidden; display: flex; flex-direction: column; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 14px; border-bottom: 1px solid var(--code-edge); font: var(--fs-xs) var(--f-mono); letter-spacing: .04em; color: var(--code-muted); }
.code-head .btn { font-family: var(--f-ui); height: 30px; background: transparent; color: var(--code-ink); border-color: var(--line-strong); font-size: 13px; }
.code { margin: 0; padding-top: 6px; font: 13.5px/1.9 var(--f-mono); overflow: auto; max-height: clamp(260px, calc(100vh - 480px), 560px); padding-bottom: 10px; } /* a vertical scroller, so a long solution scrolls inside the panel and the page stays put; 480px is about the header, toolbar and panel top, so the panel ends near the window's bottom */
.code .ln { display: block; padding: 0 14px 0 11px; border-left: 3px solid transparent; white-space: pre; }
/* The line number is a real button (U9): a breakpoint toggle with a 24px-high hit area. */
.code .bpbtn { display: inline-block; min-height: 24px; min-width: 24px; box-sizing: border-box; vertical-align: top; width: 2.4em; margin-right: 1em; padding: 0; border: 0; background: none; font: inherit; color: var(--code-muted); text-align: right; cursor: pointer; border-radius: 4px; }
.code .ln.cur { background: var(--code-cur); border-left-color: var(--code-cur-bar); }
.code .ln.cur .bpbtn { color: var(--accent-ink); } /* line numbers on the current line: --accent-ink (5.1:1), not --code-muted */
.code .ln.err { background: var(--code-err); border-left-color: var(--bad); }
.code .kw { color: var(--accent-ink); } .code .str { color: var(--ok); } .code .num { color: var(--blue); } .code .com { color: var(--code-muted); font-style: italic; }
.code .ln.cur .com { color: var(--code-muted-cur); } /* --code-muted on the current-line fill is 4.4:1 in light and fails; never use it there */
#editor { width: 100%; min-height: 360px; border: 0; padding: 4px 14px 14px; background: var(--code-bg); color: var(--code-ink); font: 13px/1.85 var(--f-mono); resize: vertical; tab-size: 4; white-space: pre; }
.statement { border-top: 1px solid var(--code-edge); padding: 12px 14px 14px; font-size: 14px; color: var(--code-ink); }
.statement b { color: var(--code-ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 12px; font-weight: 600; border-radius: var(--r-ctl); padding: 2px 9px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }

/* stage */
.stage { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
/* The page grows a little as steps change, and Chrome's scroll anchoring then nudged scrollY by the difference (qa8/swe2: 1 to 74 during Play). The anchor can be anything below the player too, so opt the whole page out while the player is showing. */
html:has(#view-player:not([hidden])) { overflow-anchor: none; }
.strip { margin: -16px -16px 0; padding: 9px 14px; border-bottom: 1px solid var(--line); font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.scene { display: flex; flex-direction: column; gap: 18px; min-height: 160px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.blk { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.blk-head { display: flex; align-items: baseline; gap: 8px; font-family: var(--f-mono); font-size: 13px; }
.blk-head b { font-weight: 600; }
.blk-head span { color: var(--muted); font-family: var(--f-ui); font-size: 12px; }
.scroll { overflow-x: auto; padding-bottom: 4px; }

.arr { display: flex; gap: 6px; width: max-content; padding-top: 2px; }
.cell { display: flex; flex-direction: column; align-items: stretch; gap: 0; min-width: 44px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); overflow: hidden; background: var(--surface); }
.cell .box { min-width: 44px; height: 52px; padding: 0 8px; display: flex; align-items: center; justify-content: center; border-radius: 0;
  background: var(--surface); border: 0; font: 600 22px var(--f-mono); white-space: nowrap; transition: background .15s, border-color .15s; }
.cell .idx { order: -1; text-align: center; padding: 1px 4px; background: var(--surface-2); border-bottom: 1px solid var(--line-strong); font: var(--fs-xs) var(--f-mono); color: var(--muted); } /* index strip above the value; DOM order stays value then index */
.cell.win .box { background: var(--accent-soft); }
.cell.win { border-color: var(--accent); }
.cell.dim { border-color: var(--line); } .cell.dim .box { background: var(--surface); color: var(--muted); } /* outside the window: quieter by colour, text stays readable (U27) */
.cell.read { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.cell.wrote { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); } .cell.wrote .box { background: var(--teal-soft); }
.ptrs { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; min-height: 18px; }
.ptr { font: 600 var(--fs-xs) var(--f-mono); padding: 0 5px; border-radius: 4px; background: var(--ink); color: var(--surface); }
.ptr.p0 { background: var(--accent); color: var(--on-accent); } .ptr.p1 { background: var(--teal); color: var(--on-accent); } .ptr.p2 { background: var(--blue); color: var(--on-accent); }
.oob { font: var(--fs-xs) var(--f-mono); color: var(--muted); align-self: center; }

.grid { display: grid; gap: 4px; width: max-content; font: 600 14px var(--f-mono); }
.grid .g { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--surface-2); border: 2px solid transparent; }
.grid .g.on { background: var(--teal-soft); }
.grid .g.read { border-color: var(--blue); }
.grid .g.wrote { border-color: var(--accent); background: var(--accent-soft); }
.grid .g.mark { box-shadow: inset 0 0 0 2px var(--accent); }
.grid .gh { font: var(--fs-xs) var(--f-mono); color: var(--muted); display: flex; align-items: center; justify-content: center; }

.map { border-collapse: collapse; font: 14px var(--f-mono); min-width: 180px; }
.map td { padding: 5px 12px; border-bottom: 1px solid var(--line); }
.map td:first-child { color: var(--muted); }
.map tr.read td { background: var(--blue-soft); }
.map tr.wrote td { background: var(--teal-soft); }
.map tr.gone td { text-decoration: line-through; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font: 600 14px var(--f-mono); }
.chip { padding: 6px 10px; border-radius: var(--r-ctl); background: var(--surface-2); border: 1px solid var(--line); }
.chip.wrote { border-color: var(--teal); background: var(--teal-soft); }
.chip.gone { border-style: dashed; border-color: var(--bad); color: var(--bad); text-decoration: line-through; background: transparent; }
.end-label { font: var(--fs-xs) var(--f-ui); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.svgwrap { overflow-x: auto; }
.svgwrap svg { display: block; }
.svgwrap text { font-family: var(--f-mono); }

/* narration + timeline */
.narr { margin: 0; padding: 12px 14px; border-radius: 0 var(--r-panel) var(--r-panel) 0; background: var(--accent-soft); border-left: 3px solid var(--accent); font: 14px/1.55 var(--f-mono); min-height: 48px; }
.narr code { font-family: var(--f-mono); font-size: 13.5px; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.rail { position: relative; height: 24px; }
.rail.has-pick { margin-top: 18px; }
.pick { position: absolute; z-index: 2; top: 4px; left: calc(9px + (100% - 18px) * var(--at, 0)); width: 3px; height: 16px; margin-left: -1px; pointer-events: none; }
.pick-tick { position: absolute; inset: 0; background: var(--bad); }
.pick-label { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 1px; font: 700 var(--fs-xs) var(--f-mono); white-space: nowrap; color: var(--bad); }
.rail::before { content: ""; position: absolute; left: 9px; right: 8px; top: 16px; height: 6px; pointer-events: none; /* one tick per step (thinned above 40), under the 18px thumb's travel; 8px on the right so the last step's tick is inside the box */
  background: repeating-linear-gradient(to right, var(--muted) 0 1px, transparent 1px calc(100% / (var(--steps, 2) - 1) * var(--every, 1))); }
.scrub { -webkit-appearance: none; appearance: none; position: relative; z-index: 1; width: 100%; margin: 0; background: transparent; accent-color: var(--accent); }
.scrub::-webkit-slider-runnable-track { height: 4px; border: 1px solid var(--line-strong); border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--surface-2) var(--fill, 0%)); }
.scrub::-moz-range-track { height: 4px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--surface-2); }
.scrub::-moz-range-progress { height: 4px; border-radius: 3px; background: var(--accent); }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -7px; border: 3px solid var(--accent); border-radius: 50%; background: var(--ink); }
.scrub::-moz-range-thumb { width: 12px; height: 12px; border: 3px solid var(--accent); border-radius: 50%; background: var(--ink); }
.ctrls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.icon { width: 42px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon svg { width: 18px; height: 18px; }
.stepno { font: 13px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 9ch; text-align: center; }
.ctrls .grow { flex: 1; }
.ctrls select { height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); padding: 0 8px; }
.hint { font-size: 12px; color: var(--muted); }

/* inspector */
.side { display: flex; flex-direction: column; gap: 14px; }
.side .panel { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
/* header strip: the existing h2, full width, hairline under it */
.side .panel h2 { margin: 0 -14px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-family: var(--f-mono); }
.result { font: 600 15px var(--f-mono); word-break: break-word; }
.verdict { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; border-radius: var(--r-ctl); padding: 3px 10px; align-self: flex-start; }
.verdict.ok { color: var(--ok); background: var(--ok-soft); }
.verdict.bad { color: var(--bad); background: var(--bad-soft); }
.diff { display: flex; flex-direction: column; gap: 2px; font-family: var(--f-mono); }
.drow { display: grid; grid-template-columns: 1.2em auto minmax(0, 1fr); gap: 0 8px; align-items: baseline; padding: 6px 10px; border-radius: var(--r-ctl); background: var(--surface-2); color: var(--ink); }
.drow .lbl { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.drow .val { text-align: right; font-size: 18px; font-weight: 600; word-break: break-word; }
.drow.exp { background: var(--ok-soft); color: var(--ok); }
.drow.got.bad { background: var(--bad-soft); color: var(--bad); }
.side .panel.nohead { padding-top: 14px; } .panel.nohead > h2 { display: none; }
.panel.res-bad { border-left: 4px solid var(--bad); }
.panel.res-ok { border-left: 4px solid var(--ok); }
.side .panel h2 .tpick { margin-left: auto; font-weight: 600; letter-spacing: .02em; text-transform: none; color: var(--accent-ink); }
.side .panel h2:has(.tpick) { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 14px; font: 14px var(--f-mono); }
.kv .k { color: var(--muted); }
.kv .k, .kv .v { padding: 5px 0; border-top: 1px solid var(--line); }
.kv > :nth-child(-n+2) { border-top: 0; }
.kv .v { word-break: break-word; }
.kv .v.changed { color: var(--accent-ink); font-weight: 600; }
.kv .v s { color: var(--muted); font-weight: 400; margin-right: 4px; }
.stack { display: flex; flex-direction: column; gap: 6px; font: 13px var(--f-mono); }
.frame { padding: 7px 10px; border-radius: var(--r-panel); background: var(--surface-2); word-break: break-word; }
.frame.cur { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.meta { font-size: 13px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); line-height: 1.45; }

@media (prefers-reduced-motion: no-preference) {
  .flash { animation: flash .5s ease-out; }
  @keyframes flash { from { transform: scale(1.08); } to { transform: scale(1); } }
}
.form p { margin: 0; }
.form .err:empty { display: none; }
#statementBox { white-space: pre-line; max-height: 320px; overflow: auto; }

/* ---- system design */
:root { --purple: #6B3FA0; --purple-soft: #ECE4F5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --purple: #C4A5F0; --purple-soft: #2A2143; } }
:root[data-theme="dark"] { --purple: #C4A5F0; --purple-soft: #2A2143; }
.admin-designs { padding: 16px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 14px; }
.admin-designs h2 { display: flex; align-items: center; gap: 8px; }
.design-form { display: grid; gap: 12px; }
.design-form details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.design-form details textarea { margin-top: 8px; width: 100%; min-height: 160px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); padding: 10px 12px; font: 14px/1.5 var(--f-ui); resize: vertical; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 16px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--ink); }
.card .card-title { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card .src { font: 12px var(--f-mono); color: var(--muted); margin-top: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.chiptag { font-size: 12px; font-weight: 600; border-radius: var(--r-ctl); padding: 2px 9px; background: var(--surface-2); color: var(--muted); }

.design-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.design-head h1 { margin: 0; }
.design-head .summary { margin: 0; color: var(--muted); max-width: 95ch; }
.design-head .row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; color: var(--muted); }
.design-head .admin-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--r-panel); }
#regenErr { margin-top: 8px; }
.regen-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; } /* two lines; the full text is the title */
.chapters { list-style: none; margin: 0 0 12px; padding: 3px; display: flex; gap: 6px; overflow-x: auto; /* padding keeps the focus ring inside the scroller */
  background: linear-gradient(to right, var(--bg), var(--bg)) 0 0 / 24px 100% no-repeat local, linear-gradient(to left, var(--bg), var(--bg)) 100% 0 / 24px 100% no-repeat local,
    linear-gradient(to right, color-mix(in srgb, var(--ink) 24%, transparent), transparent) 0 0 / 16px 100% no-repeat scroll, linear-gradient(to left, color-mix(in srgb, var(--ink) 24%, transparent), transparent) 100% 0 / 16px 100% no-repeat scroll; }
.chapters li { flex: 1 0 120px; min-width: 0; border-radius: var(--r-panel); padding: 8px 10px; background: var(--surface); border: 1px solid var(--line-strong); display: flex; flex-direction: column; gap: 2px; }
.chapters li .k { font: 700 var(--fs-xs) var(--f-mono); text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapters li .t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapters li .bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 4px; overflow: hidden; }
.chapters li .bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.chapters li.cur { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.chapters li.done .bar i { background: var(--teal); }
.chapter-now { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
/* header strips (refresh 5c): the label sits on a ruled strip across the top of the panel */
.panel-strip, .step-panel .chapter-now { margin: -12px -12px 0; padding: 9px 14px; border-bottom: 1px solid var(--line); font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.step-panel .chapter-now { margin: -16px -16px 0; }
.src-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.src-tab { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctl); padding: 5px 12px; font-size: 13px; font-weight: 600; }
.src-tab[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.diagram .node.unseen, .diagram .edge.unseen, .diagram .zone.unseen { display: none; }
.diagram .node.fresh rect.box { stroke: var(--teal); stroke-width: 2.5; }
.design-grid { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(320px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .design-grid { grid-template-columns: minmax(0, 1fr); } }
.diagram-panel { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
:is(.diagram, .ask-diagram) { overflow-x: auto; background: linear-gradient(to right, var(--surface), var(--surface)) 0 0 / 24px 100% no-repeat local, linear-gradient(to left, var(--surface), var(--surface)) 100% 0 / 24px 100% no-repeat local, linear-gradient(to right, color-mix(in srgb, var(--ink) 24%, transparent), transparent) 0 0 / 16px 100% no-repeat scroll, linear-gradient(to left, color-mix(in srgb, var(--ink) 24%, transparent), transparent) 100% 0 / 16px 100% no-repeat scroll; background-color: var(--surface); } /* edge fades at every width: the diagram scrolls, it never shrinks */
:is(.diagram, .ask-diagram) svg { display: block; font-family: var(--f-ui); max-width: none !important; } /* scroll, never shrink: scaled text drops under the 12px floor */
:is(.diagram, .ask-diagram) .node { cursor: pointer; }
:is(.diagram, .ask-diagram) .node rect.box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; transition: stroke .2s, fill .2s; }
:is(.diagram, .ask-diagram) .node .kind { font-size: 12px; font-weight: 700; }
:is(.diagram, .ask-diagram) .node .name { font-size: 15px; font-weight: 700; fill: var(--ink); }
:is(.diagram, .ask-diagram) .node .tech { font-size: 12px; fill: var(--muted); font-family: var(--f-mono); }
:is(.diagram, .ask-diagram) .node .band { opacity: .9; }
:is(.diagram, .ask-diagram) .node.c-edge .kind, :is(.diagram, .ask-diagram) .node.c-edge .band { fill: var(--blue); }
:is(.diagram, .ask-diagram) .node.c-compute .band { fill: var(--accent); }
:is(.diagram, .ask-diagram) .node.c-compute .kind { fill: var(--accent-ink); } /* 4.5:1 text; the band keeps the brand accent */
:is(.diagram, .ask-diagram) .node.c-data .kind, :is(.diagram, .ask-diagram) .node.c-data .band { fill: var(--teal); }
:is(.diagram, .ask-diagram) .node.c-msg .kind, :is(.diagram, .ask-diagram) .node.c-msg .band { fill: var(--purple); }
:is(.diagram, .ask-diagram) .node.c-other .kind, :is(.diagram, .ask-diagram) .node.c-other .band { fill: var(--muted); }
.diagram .node.dim rect.box { fill-opacity: .6; stroke-opacity: .6; }
.diagram .node.dim .band, .diagram .node.dim .icon { opacity: .6; } /* dim the shapes, never the label text (U27) */
:is(.diagram, .ask-diagram) .node:focus { outline: none; }
:is(.diagram, .ask-diagram) .node.active rect.box { stroke: var(--ink); stroke-width: 2.5; }
.diagram .node.failed rect.box { stroke: var(--bad); stroke-width: 2.5; fill: var(--bad-soft); }
:is(.diagram, .ask-diagram) .node .down { font-size: 12px; font-weight: 800; fill: var(--bad); }
.diagram .node.sel rect.box { stroke: var(--accent); stroke-width: 3; }
:is(.diagram, .ask-diagram) .edge path { fill: none; stroke: var(--muted); stroke-width: 1.8; transition: stroke .2s, opacity .25s; }
.diagram .edge.async path { stroke-dasharray: 6 5; }
:is(.diagram, .ask-diagram) .edge.hot path { stroke: var(--accent); stroke-width: 2.6; }
.diagram .edge.dim path { stroke: var(--muted); stroke-opacity: .7; } /* about 3.3:1 on the page; arrowheads share one marker per colour, so they stay full strength */
:is(.diagram, .ask-diagram) .edge text { opacity: 0; transition: opacity .2s; font-size: 12px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.diagram .edge:hover text { opacity: 1; fill: var(--ink); font-weight: 600; }
:is(.diagram, .ask-diagram) .edge.hot text { opacity: 0; } /* the moving message carries the label */
.diagram .pkt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
:is(.diagram, .ask-diagram) marker path { fill: var(--muted); }
.diagram marker#arr-hot path { fill: var(--accent); }
.legend { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--muted); }
.legend .key-note { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin: 0 11px 0 11px; vertical-align: -2px; background: var(--note); border: 1px solid var(--note-line); }
.comp-detail { border-top: 1px solid var(--line); padding-top: 10px; font-size: 14px; min-height: 40px; }
.comp-detail h3 { margin: 0 0 4px; font-size: 16px; }
.comp-detail ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink); }
.comp-detail .note { margin: 0; }
.step-panel { padding: 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 12px; }
.flow-desc { margin: 0; color: var(--muted); font-size: 14px; }
.step-meta { display: flex; align-items: center; gap: 8px; font: 13px var(--f-mono); color: var(--muted); }
.step-panel .step-title { margin: 0; font-size: 20px; letter-spacing: -0.01em; text-transform: none; color: var(--ink); }
.step-narr { margin: 0; font-size: 15.5px; line-height: 1.6; }
.metrics { display: flex; flex-wrap: wrap; gap: 8px; }
.metric { background: var(--surface-2); border-radius: var(--r-panel); padding: 6px 10px; }
.metric .l { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.metric .v { font: 600 15px var(--f-mono); }
.msgs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font: 13px var(--f-mono); }
.msgs li { display: flex; gap: 6px; flex-wrap: wrap; }
.msgs .arrow { color: var(--accent-ink); }
.msgs .lbl { color: var(--muted); }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 12px; border-radius: 0 var(--r-panel) var(--r-panel) 0; font-size: 14px; }
.callout b { display: block; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--accent-ink); margin-bottom: 2px; }
.step-list { margin: 0; padding: 0 0 0 22px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; max-height: 260px; overflow: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.step-list li { padding: 3px 6px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.step-list li:hover { background: var(--surface-2); }
.step-list li.cur { color: var(--ink); font-weight: 700; background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.design-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; margin-top: 14px; }
@media (max-width: 520px) { .design-sections { grid-template-columns: minmax(0, 1fr); } }
.dsec { padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dsec > h2 { margin: -16px -16px 0; padding: 9px 14px; border-bottom: 1px solid var(--line); font-family: var(--f-mono); } /* header strip, as the other panels (refresh 5d) */
.glossary { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 14px; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 0; color: var(--muted); }
.q { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.q:first-child { border-top: 0; padding-top: 0; }
.q p { margin: 0; font-weight: 600; }
.q .opts { display: flex; flex-direction: column; gap: 6px; }
.q .opt { text-align: left; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctl); padding: 9px 12px; font-size: 14px; }
.q .opt:hover:not(:disabled) { border-color: var(--ink); }
.q .opt.right { border-color: var(--ok); background: var(--ok-soft); }
.q .opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q .opt:disabled { cursor: default; }
.q .why { font-size: 14px; color: var(--muted); margin: 0; }
.quiz-score { font-size: 14px; color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; }
.design-head a.sub { text-decoration: none; }


/* ---- polish: shell */
.eyebrow { font-family: var(--f-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 6px; }
.back { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 8px; }
.back:hover { color: var(--ink); }
.note { color: var(--muted); font-size: 14px; margin: 0; }
.list-head .note { margin-top: 2px; }
/* Notices and toasts (U13) */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--nc, var(--line)); border-radius: var(--r-panel); font-size: 14px; line-height: 1.45; }
.notice svg { flex: none; margin-top: 2px; color: var(--nc); }
.notice.info { --nc: var(--accent-ink); } .notice.warn { --nc: var(--warn); } .notice.error { --nc: var(--bad); } .notice.success { --nc: var(--ok); }
.notice-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notice code { font-family: var(--f-mono); font-size: 13px; }
.toast-x.all { font-size: 13px; font-weight: 600; padding: 0 6px; text-decoration: underline; }
.notice-x, .toast-x { flex: none; min-width: 24px; min-height: 24px; border: 0; background: none; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; border-radius: 6px; }
.notice-action { flex: none; }
.notice[hidden] { display: none; }
#truncNote, #claudeOff { margin-bottom: 14px; }
@media (max-width: 640px) { .notice { flex-wrap: wrap; } .notice-action { flex-basis: 100%; } }
#banner.notice, #spendAlert.notice { margin: 12px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.toasts { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(360px, calc(100vw - 32px)); }
.toasts.top { bottom: auto; top: max(8px, env(safe-area-inset-top, 0px)); }
.toasts > div { display: flex; flex-direction: column; gap: 8px; }
/* The containers span the corner but only a toast takes the pointer: clicks pass through to the controls under the empty part (they were swallowed at 390) */
.toasts, .toasts > div { pointer-events: none; }
.toast, .toast * { pointer-events: auto; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: var(--r-panel); font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.18); display: flex; gap: 10px; align-items: center; }
.toast.ok::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.toast.bad::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast-in .2s ease-out; } @keyframes toast-in { from { transform: translateY(8px); opacity: 0; } } }
.skeleton { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.skeleton span { display: block; height: 14px; border-radius: 6px; background: var(--surface-2); }
.skeleton span:nth-child(2) { width: 70%; } .skeleton span:nth-child(3) { width: 45%; }
@media (prefers-reduced-motion: no-preference) { .skeleton span { animation: shimmer 1.2s ease-in-out infinite; } @keyframes shimmer { 50% { opacity: .45; } } }
.empty-state { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.empty-state b { color: var(--ink); font-size: 16px; }
.empty-state .btn { margin-top: 6px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; color: var(--surface); animation: spin .7s linear infinite; }
.btn.busy:not(.primary)::after { color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- polish: home */
.home-hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.home-hero h1 { font-size: clamp(30px, 4.2vw, 46px); font-weight: 800; letter-spacing: -.01em; line-height: 1.1; margin: 0; text-wrap: balance; }
.home-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 18px; }
@media (min-width: 960px) { .home-top.fr { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } } /* .fr is set from JS while the First-run panel shows (no :has(), which older Safari and Firefox lack) */
.home-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.home-top.fr .home-actions { grid-template-columns: minmax(0, 1fr); } /* beside the First-run panel the cards stack as command rows */
.action-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.action-card:hover { border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .action-card:hover { transform: translateY(-1px); } }
.action-icon { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.action-icon.alt { background: var(--teal-soft); color: var(--teal); }
.action-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.action-body b { font-size: 17px; letter-spacing: -0.01em; }
.action-body span { color: var(--muted); font-size: 14px; line-height: 1.45; }
.action-go { font: 700 18px var(--f-mono); color: var(--accent-ink); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
/* A user with zero dry runs: three columns while Continue and Recent are hidden; Continue, when it has rows, is moved last in the DOM (not by CSS order, which would leave Tab order wrong). */
.home-grid.zero { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
@media (max-width: 1179px) { .home-grid.zero { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .home-grid.zero { grid-template-columns: minmax(0, 1fr); } }
/* First-run panel (R4) */
.first-run { padding: 0; overflow: hidden; }
.first-run h2 .fr-sub { font: 600 14px var(--f-ui); letter-spacing: 0; text-transform: none; color: var(--muted); }
.first-run h2 .fr-dot { margin-right: .4em; } /* the nbsp alone gave 3px, against 8px after "RUN" (its letter-spacing) */
.fr-steps { list-style: none; margin: 0; padding: 14px 16px 6px; display: flex; flex-direction: column; gap: 12px; }
.fr-steps li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; }
.fr-n { width: 24px; height: 24px; display: inline-grid; place-items: center; border: 1px solid var(--accent); border-radius: var(--r-ctl); font: 700 var(--fs-xs) var(--f-mono); color: var(--accent-ink); }
.fr-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 16px 16px; }
.fr-foot .btn { min-height: 40px; }
.fr-foot .hint { margin: 0; }
/* difficulty beside a problem: a squared mono tag */
#homeNext .rowlist li a > .sub { font: 600 var(--fs-xs) var(--f-mono); padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); color: var(--muted); }
.home-sec { padding: 0; overflow: hidden; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sec-head h2 { font: 700 var(--fs-xs) var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
.sec-head a { font-size: 13px; display: inline-flex; align-items: center; min-height: 24px; }
.home-sec .empty-state { align-items: flex-start; text-align: left; padding: 16px; }
.home-sec .empty-state p { margin: 0; }
.home-sec .rowlist .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .rowlist li a:has(.pill) { grid-template-columns: minmax(0, 1fr); } .rowlist li a:has(.pill) .pill { justify-self: start; } }
.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.rowlist li:last-child a { border-bottom: 0; }
.rowlist li a:hover { background: var(--surface-2); }
.rowlist .t { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowlist .sub { display: block; }

/* ---- polish: player */
.statement.collapsed .st-text { max-height: 120px; overflow: hidden; -webkit-mask-image: linear-gradient(black 60%, transparent); mask-image: linear-gradient(black 60%, transparent); }
.st-toggle { background: none; border: 0; color: var(--code-ink); font: 600 13px var(--f-ui); padding: 6px 0 0; cursor: pointer; text-decoration: underline; }

/* ---- polish: system design */
.flow-progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.flow-progress div { height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .25s; }
.diagram .pkt { r: 7; }
.diagram .pkt-label { font: 600 12px var(--f-ui); fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.next-flow { align-self: flex-start; margin-top: 4px; }

.search { width: 100%; max-width: 520px; margin: 0 0 12px; padding: 9px 12px 9px 34px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface) no-repeat 11px center / 15px var(--icon-search); color: var(--ink); font: inherit; font-size: 14px; }
.search:focus-visible { border-color: var(--accent); }
.search.compact { max-width: 320px; margin: 0; padding-top: 7px; padding-bottom: 7px; }
.search-empty { padding: 14px; color: var(--muted); font-size: 14px; }
.inline-select { font: inherit; font-size: 12px; margin-left: 6px; padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink); }
.code-head .lang { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--code-muted); margin-left: 8px; }

/* system design: zones, icons, notes, story */
.diagram .zone rect { fill: var(--surface-2); fill-opacity: .45; stroke: var(--line); stroke-dasharray: 7 5; stroke-width: 1.3; }
.diagram .zone text { font-size: 12px; font-weight: 800; letter-spacing: .06em; fill: var(--muted); }
:is(.diagram, .ask-diagram) .node .icon { fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:is(.diagram, .ask-diagram) .node.c-edge .icon { stroke: var(--blue); }
:is(.diagram, .ask-diagram) .node.c-compute .icon { stroke: var(--accent); }
:is(.diagram, .ask-diagram) .node.c-data .icon { stroke: var(--teal); }
:is(.diagram, .ask-diagram) .node.c-msg .icon { stroke: var(--purple); }
:is(.diagram, .ask-diagram) .node.c-other .icon { stroke: var(--muted); }
:is(.diagram, .ask-diagram) .node .scale { font: 600 12px var(--f-mono); fill: var(--muted); }
.diagram .snote rect { fill: var(--note); stroke: var(--note-line); stroke-width: 1; }
.diagram .snote path { fill: var(--note-line); }
.diagram .snote text { font: 600 12px var(--f-ui); fill: var(--ink); }
.scenario { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border-radius: var(--r-panel); padding: 10px 12px; font-size: 14px; line-height: 1.45; }
.scenario svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }
.scenario .setting { display: block; color: var(--muted); font-size: 13px; }
.payload { display: flex; flex-direction: column; gap: 4px; background: var(--code-bg); color: var(--code-ink); border-radius: var(--r-panel); padding: 8px 12px; }
.payload .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--code-muted); }
.payload code { font: 13px/1.5 var(--f-mono); white-space: pre-wrap; word-break: break-word; }
.state-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.state-list li { display: flex; gap: 8px; align-items: baseline; padding: 5px 10px; background: var(--note); border: 1px solid var(--note-line); border-radius: 6px; }
.state-list li b { font-weight: 700; white-space: nowrap; }
.callout.takeaway { border-left-color: var(--teal); background: var(--teal-soft); }
.callout.takeaway b { color: var(--teal); }

/* learning loop: progress, predict, jumps, tutor */
.learnbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.learnbar.compact { margin: 8px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.learnbar .btn[aria-pressed="true"], .ctrls .btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.predict { background: var(--blue-soft); border: 1px solid var(--blue); border-radius: var(--r-panel); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.predict .q { font-weight: 700; }
.predict .q code { display: inline; font-family: var(--f-mono); background: var(--surface); padding: 1px 6px; border-radius: 4px; }
.predict .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.predict .opt { font-family: var(--f-mono); }
.predict .opt.right { background: var(--ok-soft); border-color: var(--ok); }
.predict .opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
.predict .score { font-size: 12px; color: var(--muted); }
.code .ln.bp .bpbtn { color: var(--accent-ink); } /* the marker is text: --accent-ink, since --code-cur-bar is only 4.1:1 on the light current-line fill (BUG-U1-1 stays fixed) */
.code .ln.bp .bpbtn::before { content: '● '; }
.code .ln.bp { border-left-color: var(--accent); }
.kv .k { cursor: pointer; background: none; border: 0; padding: 0; font: inherit; text-align: left; min-height: 24px; min-width: 24px; }
.kv .k:hover { color: var(--accent-ink); text-decoration: underline; }
.tutor { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.tutor .why { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.tutor .why .wprob { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; line-height: 1.3; }
.tutor .why p { margin: 0; }
.fixbox { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; background: var(--code-bg); color: var(--code-ink); border-left: 3px solid var(--ok); border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.fixbox b { font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ok); }
.aigen { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.aigen .sq { flex: none; width: 8px; height: 8px; border: 1.5px solid var(--accent-ink); }
/* beside the section header on desktop, under it on phones (refresh 5e); the same sentence as the Why panel's */
.dsec { position: relative; }
@media (min-width: 641px) { .dsec > .aigen.head { position: absolute; top: 9px; right: 14px; } }
.tutor .reason { font-size: 13px; color: var(--muted); }
.option-group-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 12px; }
.compare-grid .num { font-family: var(--f-mono); }
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.bars .row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; font-size: 13px; }
.bars .barline { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.bars .barline:first-child { margin-top: 0; }
.bars .bar { height: 12px; border-radius: 4px; background: var(--accent); min-width: 2px; flex: none; width: calc((100% - 96px) * var(--w)); } /* 96px is reserved for the value label so it never leaves the panel */
.bars .bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; } /* background-only bars would print as nothing: keep the fill and the hatch on paper */
.bars .bar.b { background: repeating-linear-gradient(45deg, var(--hatch) 0 2px, transparent 2px 5px), var(--blue); } /* the hatch, not colour alone, tells B from A in greyscale and print */
.bars { --hatch: rgba(255, 255, 255, .45); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bars { --hatch: rgba(0, 0, 0, .35); } }
:root[data-theme="dark"] .bars { --hatch: rgba(0, 0, 0, .35); }
.cmp-legend { margin: 0; font: 12px var(--f-mono); color: var(--muted); }
.bars .barline > span { font: 12px var(--f-mono); color: var(--muted); white-space: nowrap; }
.compare-grid .panel, #compareBody > .panel { padding: 14px 16px; }
.compare-grid .panel > * + * { margin-top: 8px; }
.compare-grid .btn.small { min-height: 24px; }
@media (max-width: 640px) { .bars .row { grid-template-columns: 1fr; gap: 4px; } }
.askform { display: flex; gap: 8px; margin-bottom: 10px; }
.askform input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); font: inherit; background: var(--surface); color: var(--ink); }
.asklog { display: flex; flex-direction: column; gap: 10px; }
.ask-q { font-weight: 700; }
.ask-a { white-space: pre-wrap; font-size: 14px; line-height: 1.55; background: var(--surface-2); border-radius: var(--r-panel); padding: 10px 12px; }
#proposal { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); font: inherit; font-size: 14px; background: var(--surface); color: var(--ink); resize: vertical; }
.critique { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.critique .score { font: 700 28px var(--f-mono); }
.critique ul { margin: 4px 0 0; padding-left: 18px; }
.critique .gap { background: var(--bad-soft); border-left: 3px solid var(--bad); padding: 8px 10px; border-radius: 0 var(--r-panel) var(--r-panel) 0; font-size: 14px; }
.critique .gap small { display: block; color: var(--muted); margin-top: 2px; }
.dsec.wide { grid-column: 1 / -1; }
.diagram .node.asked rect.box { stroke: var(--blue); stroke-width: 3; }
.row.wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.row.wrap .search { margin: 0; }
.runs-pick { width: 16px; height: 16px; }
.home-sec .rowlist .tag-sm { font-size: var(--fs-xs); color: var(--muted); }

/* phones: one column, the picture first, the code folded away */
@media (max-width: 760px) {
  .top { padding: 8px 12px; }
  .tabs { overflow-x: auto; white-space: nowrap; }
  .layout { display: flex; flex-direction: column; }
  .layout > * { width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden; }
  .narr { overflow-wrap: anywhere; }
  .narr code { white-space: pre-wrap; }
  .layout .stage { order: 0; }
  .layout .code-panel { order: 1; }
  .layout .side { order: 2; }
  .code-panel .code { max-height: 260px; overflow: auto; font-size: 12px; }
  .scene { overflow-x: auto; }
  .timeline { position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; z-index: 5; }
  .ctrls { flex-wrap: wrap; }
  .diagram-panel { padding: 8px; }
  .panel-strip { margin: -8px -8px 0; }
  .step-panel { position: static; }
  .design-head h1 { font-size: 22px; }
  .home-actions { grid-template-columns: minmax(0, 1fr); }
  .action-card, .fr-foot .btn { min-height: 44px; }
  .table td, .table th { padding: 8px 6px; }
  .table td { font-size: 13px; }
  .compose-grid textarea { min-height: 160px; }
  .learnbar .btn { padding: 6px 8px; font-size: 12px; }
}

/* ---- lesson extras: tracks, prerequisites, break-it, what-if, depth, calculator, drawing, present, review, interview, requests */
.track { margin-bottom: 22px; }
.track .sec-head { margin-bottom: 8px; }
.track .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card.done { border-color: var(--ok); }
.card .card-title .pill { font-size: var(--fs-xs); vertical-align: middle; margin-left: 4px; }
.prereqs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 13px; }
.prereqs .k, .seerun .k, .breakit .k, .quote .k, .bkv .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-right: 4px; }
.prereqs .chiptag.done { color: var(--ok); background: var(--ok-soft); }
.chiptag[href], a.chiptag { text-decoration: none; }
a.chiptag:hover { color: var(--ink); }
.seerun, .breakit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.breakit .btn { padding: 3px 9px; }
.breakout { margin-top: 10px; border-left: 3px solid var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: 0 var(--r-panel) var(--r-panel) 0; font-size: 14px; }
.breakout.slow { border-color: var(--note-line); background: var(--note); }
.breakout.full { border-color: var(--purple); background: var(--surface-2); }
.breakout p { margin: 4px 0 8px; }
.bkv { font-size: 13px; margin-top: 4px; }
.bkv i { color: var(--muted); }
.diagram .node.broken rect.box { stroke: var(--bad); stroke-width: 3; fill: var(--bad-soft); }
.diagram .node.broken.slow rect.box { stroke: var(--note-line); fill: var(--note); }
.diagram .node.broken.slow .down { fill: var(--warn); }
.diagram .node.broken.full rect.box { stroke: var(--purple); fill: var(--surface-2); }
.diagram .node.broken.full .down { fill: var(--purple); }
.diagram .node.affected rect.box { stroke: var(--bad); stroke-dasharray: 5 4; stroke-width: 2; }
.diagram .node.removed rect.box { fill-opacity: .6; } /* struck-through name stays full strength */
.diagram .node.removed rect.box { stroke-dasharray: 6 4; stroke: var(--bad); }
.diagram .node.removed .name { text-decoration: line-through; }
.diagram .node.changed rect.box { stroke: var(--purple); stroke-width: 2.5; }
.chapters li.variant { border-style: dashed; }
.chapters li.variant .k { color: var(--purple); }
.chapters li.whatif { border-style: dashed; color: var(--muted); flex: 0 0 auto; }
.chapters li.whatif .k { color: var(--accent-ink); }
.chapters li.whatif.open { flex: 1 0 100%; cursor: default; }
.whatif-form { display: flex; flex-direction: column; gap: 8px; }
.whatif-form .wchips { display: flex; flex-wrap: wrap; gap: 6px; }
.whatif-form .wchips .chiptag { border: 0; cursor: pointer; }
.whatif-form .wchips .chiptag:hover { color: var(--ink); }
.whatif-form .row { display: flex; gap: 6px; }
.whatif-form input { flex: 1; min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 6px 10px; background: var(--surface); }
.quote { margin: 0; border-left: 3px solid var(--blue); background: var(--blue-soft); padding: 8px 12px; border-radius: 0 var(--r-panel) var(--r-panel) 0; font-size: 13.5px; font-style: italic; }
.quote .k { display: block; font-style: normal; margin-bottom: 2px; }
select.btn { appearance: auto; padding-right: 8px; }
.menu { position: relative; display: inline-block; }
.menu-items[hidden] { display: none; }
.menu-items .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu-items { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: 0 10px 30px rgba(0,0,0,.12); display: flex; flex-direction: column; min-width: 190px; padding: 4px; }
.menu-items button { background: none; border: 0; text-align: left; padding: 8px 10px; min-height: 36px; border-radius: 6px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.menu-items button:disabled { color: var(--muted); cursor: default; }
.menu-items button:hover { background: var(--surface-2); }
.admin-edit { margin: 4px 0; }
.edit-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; border: 1px dashed var(--line); border-radius: var(--r-panel); padding: 10px; }
.edit-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); font-weight: 600; }
.edit-form input, .edit-form textarea { border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 6px 10px; background: var(--surface); font-weight: 400; color: var(--ink); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.check input { margin-top: 4px; }
/* calculator */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 18px; }
.calc-in { display: flex; flex-direction: column; gap: 8px; }
.calc-in label { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 2px 10px; align-items: center; font-size: 13px; }
.calc-in label span { grid-column: 1; }
.calc-in label b { grid-column: 2; grid-row: 1 / span 2; font: 600 13px var(--f-mono); text-align: right; }
.calc-in input[type=range] { grid-column: 1; width: 100%; accent-color: var(--accent); }
.calc-out { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; align-content: start; }
.metric.wide .v { font-size: 18px; }
.metric .how { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; line-height: 1.35; }
/* drawing */
.draw { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.pal { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctl); padding: 4px 10px 4px 6px; font-size: 13px; }
.pal:hover { border-color: var(--ink); }
.pal svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.canvas-box { position: relative; max-width: 900px; }
.canvas-wrap { overflow-x: auto; scroll-padding-inline: 36px; /* a box scrolled into view clears the 28px edge fade */ background: var(--surface-2); border: 1px dashed var(--muted); border-radius: var(--r-panel); } /* --line-strong on --surface-2 is 3.16 light but 2.90 dark (measured), so the outline uses --muted (5.9 / 6.9) */
.canvas { display: block; width: 900px; max-width: none; height: auto; font-family: var(--f-ui); touch-action: pan-x pan-y pinch-zoom; } /* a swipe on empty canvas pans the page or the wrapper; a box drag is claimed below */
.canvas .dbox { touch-action: none; }
/* Phones: keep the natural size (the 24px hit circles need scale 1) and scroll sideways; the edge fade says there is more. */
.canvas-box::before, .canvas-box::after { content: ""; position: absolute; top: 1px; bottom: 1px; width: 28px; pointer-events: none; opacity: 0; z-index: 1; }
.canvas-box::before { left: 1px; background: linear-gradient(to right, var(--surface-2) 15%, transparent); border-radius: calc(var(--r-panel) - 1px) 0 0 calc(var(--r-panel) - 1px); }
.canvas-box::after { right: 1px; background: linear-gradient(to left, var(--surface-2) 15%, transparent); border-radius: 0 calc(var(--r-panel) - 1px) calc(var(--r-panel) - 1px) 0; }
.canvas-box.more-left::before, .canvas-box.more-right::after { opacity: 1; }
.canvas .dbox { cursor: grab; }
.canvas .dbox rect { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; } /* the box edge sits on --surface-2, where --line-strong is 2.90:1 in dark */
.canvas .dbox.from rect { stroke: var(--accent); stroke-width: 3; }
.canvas .dbox .icon { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.canvas .dbox .kind { font-size: 12px; font-weight: 700; fill: var(--muted); }
.canvas .dbox.c-edge .kind { fill: var(--blue); } .canvas .dbox.c-compute .kind { fill: var(--accent); } .canvas .dbox.c-data .kind { fill: var(--teal); } .canvas .dbox.c-msg .kind { fill: var(--purple); }
.canvas .dbox .name { font-size: 13px; font-weight: 700; fill: var(--ink); }
.canvas .dbox .x { font-size: 14px; fill: var(--muted); cursor: pointer; }
.canvas .dline line { stroke: var(--muted); stroke-width: 1.8; }
.canvas .dedge circle { fill: var(--surface); stroke: var(--line-strong); cursor: pointer; }
.canvas .dedge text { font-size: 12px; fill: var(--muted); pointer-events: none; }
.canvas marker path { fill: var(--muted); }
.draw-hint { font-size: 12.5px; color: var(--muted); }
.draw-bar { display: flex; align-items: center; gap: 10px; }
@media (max-width: 640px) { .draw-bar { flex-wrap: wrap; } .draw-bar .btn { min-height: 40px; } }
/* Keyboard focus: a full-strength --focus stroke on the box / the handle (SVG outline is unreliable); declared after .from so it wins */
.canvas .dbox:focus, .canvas .dedge:focus { outline: none; }
.canvas .dbox:focus-visible rect { stroke: var(--focus); stroke-width: 4; }
.canvas .dedge { cursor: pointer; }
.canvas .dedge .hit { fill: transparent; stroke: none; } /* the 24px target must stay invisible: beats `.dedge circle` */
.canvas .dedge:focus-visible circle:not(.hit) { stroke: var(--focus); stroke-width: 3; }
/* present mode */
.present { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
body.presenting { overflow: hidden; }
.present-top { display: flex; gap: 10px; align-items: center; padding: 10px 18px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.present-diagram { padding: 12px 24px; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; }
.present-diagram svg { max-width: 100%; max-height: 100%; height: auto; width: auto; }
.present-text { padding: 14px 10vw 26px; border-top: 1px solid var(--line); background: var(--surface); }
.present-text h2 { margin: 0 0 6px; font-size: 26px; }
.present-text p { margin: 0; font-size: 19px; line-height: 1.5; max-width: 1100px; }
.present-text code { display: block; margin-top: 10px; font: 14px var(--f-mono); color: var(--muted); }
/* review */
.flashcard { max-width: 720px; margin: 0 auto; text-align: center; padding: 28px 24px; }
.flashcard .front { font-size: 22px; font-weight: 700; margin: 14px 0; }
.flashcard .back { font-size: 17px; margin: 8px 0 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.flashcard .actions { justify-content: center; }
.grades .btn { min-width: 78px; }
.review-done { max-width: 720px; margin: 0 auto; }
.mastery { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#homeMastery { align-self: start; }
#homeMastery .mastery .bar { outline: 1px solid var(--line); }
#homeMastery .mastery { padding: 12px 16px; }
#homeMastery .note { padding: 12px 16px; margin: 0; }
.mastery li { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.mastery .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mastery .bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.mastery .bar i { display: block; height: 100%; background: var(--teal); }
/* interview */
.interview { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 240px; max-height: 60vh; overflow: auto; padding: 14px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: var(--r-panel); font-size: 15px; line-height: 1.5; white-space: pre-wrap; position: relative; }
.bubble.interviewer { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble.candidate { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.bubble.err { color: var(--bad); }
.bubble .phase { display: block; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 6px; }
#chatForm { flex-wrap: wrap; }
#chatForm textarea { flex: 1 1 100%; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 8px 12px; background: var(--surface); resize: vertical; }
#scorecard .score { font: 700 22px var(--f-mono); color: var(--accent-ink); margin-left: 8px; }
#scorecard ul { padding-left: 18px; }
/* requests */
.overview { display: block; }
.requests { margin-top: 22px; padding: 0; }
.requests .sec-head { flex-wrap: wrap; gap: 4px 12px; }
.requests .sec-head .sub { font-size: 13px; color: var(--muted); }
.requests .reqform { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.requests .reqform .field input { min-height: 40px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); font: inherit; font-weight: 400; background: var(--surface); color: var(--ink); }
.requests .reqform .btn { align-self: flex-start; }
.requests .rowlist .note { padding: 12px 16px; }
/* one lesson (the wave-1 state): the card sits beside the Request panel from 960px, so the page does not look empty */
@media (min-width: 960px) { .overview[data-n="1"] { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 14px; align-items: start; } .overview[data-n="1"] .requests { margin-top: 0; } }
.requests .rowlist li.req { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.requests .rowlist li.req:last-child { border-bottom: 0; }
.requests .rowlist li.req:hover { background: var(--surface-2); }
.requests .rowlist li.req > .req-main { display: block; min-width: 0; padding: 0; border-bottom: 0; background: none; color: var(--ink); text-decoration: none; }
.requests .rowlist li.req > a.req-main:hover { text-decoration: underline; }
.vote { min-width: 56px; min-height: 24px; border-radius: var(--r-ctl); border-color: var(--line-strong); }
.vote.on { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
@media (max-width: 760px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .present-text { padding: 12px 16px 18px; }
  .present-text h2 { font-size: 20px; } .present-text p { font-size: 16px; }
  .chapters li.whatif .t { display: none; }
}
@media print {
  .tabs, .topbar, .learnbar, .chapters li.whatif, .admin-bar, #regenErr, .admin-edit, #askForm, .step-meta .btn, .next-flow, .design-sections .dsec.wide:not(#calcSec), #interviewSec, #calcSec, .step-list, .learn-row, .details-toggle, .def-strip, .card30-start, #askExp, #practiceExp { display: none !important; }
  .exp-body[hidden], .step-details[hidden], .key-body[hidden] { display: block !important; } .key-toggle { display: none; } /* paper shows the whole lesson notes and the details */
  .exp-btn::after { content: none !important; }
  /* Paper: the light tokens whatever theme the screen is in, with the paper tint and the dark code panel replaced by white and a light grey one. Hex is allowed here. */
  html:root:not([data-theme="none"]) {
    --bg: #fff; --surface: #fff; --surface-2: #f5f5f5; --ink: #000; --muted: #333; --line: #999; --line-strong: #666;
    --accent: #B8400F; --accent-soft: #F6E1D3; --teal: #146B5E; --teal-soft: #DCEFEA; --blue: #1F4FA8; --blue-soft: #E4EAF7; --note: #FFF6D6; --note-line: #9C7F1E;
    --ok: #1E6B47; --ok-soft: #DDEFE5; --bad: #A3261D; --bad-soft: #F7DDD8; --accent-ink: #A03609; --warn: #7A5C00;
    --code-bg: #f5f5f5; --code-edge: #999; --code-ink: #000; --code-muted: #333; --code-muted-cur: #333; --code-cur: #e6e6e6; --code-cur-bar: #000; --code-err: #F7DDD8;
    --on-accent: #FFFFFF; /* the dark theme's dark-on-orange button text would print dark on the light orange (3.4:1; the delete button 2.6:1) */
    color-scheme: light;
  }
  body { background: #fff; color: #000; }
  .panel { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .design-grid { display: block; }
  .diagram svg { max-width: 100% !important; height: auto !important; }
  .diagram .node.unseen, .diagram .edge.unseen, .diagram .zone.unseen { display: initial !important; }
  .diagram .node.dim { opacity: 1; }
}

/* first-run tour */
.tour { position: fixed; z-index: 20; width: 280px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-panel); padding: 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.tour h2 { margin: 0 0 4px; font: 700 var(--fs-xs) var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent-ink); }
.tour .hint { font-family: var(--f-mono); color: var(--muted); }
.tour p { margin: 0 0 10px; font-size: 14px; }
.tour::before { content: ""; position: absolute; left: var(--ax, 24px); width: 12px; height: 12px; margin-left: -6px; background: var(--surface); border: 1px solid var(--line-strong); transform: rotate(45deg); }
.tour[data-dir="below"]::before { top: -7px; border-right: 0; border-bottom: 0; }
.tour[data-dir="above"]::before { bottom: -7px; border-left: 0; border-top: 0; }
.tour.dock::before { display: none; }
.tour.dock { position: fixed; left: 16px; right: 16px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); top: auto; width: auto; max-height: 40vh; overflow: auto; }
.tour-on { outline: 3px solid var(--focus); outline-offset: 3px; }
.fb { margin-top: 10px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fb input { flex: 1; min-width: 160px; }

/* panel header links: accent-ink text, no visited purple */
.sec-head a, .back, .design-head a.sub, .compare-grid .sub a { color: var(--accent-ink); }
.sec-head a:visited, .back:visited, .design-head a.sub:visited, .compare-grid .sub a:visited { color: var(--accent-ink); }
.sec-head a:hover, .back:hover, .design-head a.sub:hover, .compare-grid .sub a:hover { text-decoration: underline; }

/* U2: skip link, heading focus target, 24 px targets */
.skip { position: fixed; left: 8px; top: 8px; z-index: 60; padding: 8px 14px; border-radius: var(--r-ctl); background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); font-weight: 600; transform: translateY(-200%); }
.skip:focus { transform: none; }
main:focus, h1[tabindex="-1"]:focus { outline: none; }
.back, #playerBack, .sec-head a, .design-head a.sub { display: inline-flex; align-items: center; min-height: 24px; }
.sub a { display: inline-block; padding-block: 4px; }
.runs-pick, #designPrimer { width: 24px; height: 24px; }
.inline-select { min-height: 32px; }
.check input { flex: none; }
.scrub { height: 24px; min-height: 24px; } /* a range input can ignore min-height alone; the hit area is the box height (WCAG 2.5.8) */
/* Failed run (U3) */
.notice-fail { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; border: 1px solid var(--bad); border-left-width: 4px; border-radius: var(--r-panel); background: var(--bad-soft); max-width: 70ch; } /* the same 4px state rule as .notice: the title is bold text, the rule is not the only cue */
.notice-fail p { margin: 0; }
.notice-fail .err { white-space: pre-wrap; font-family: ui-monospace, monospace; margin-top: 8px; user-select: text; color: var(--ink); }
.submission { margin-top: 16px; max-width: 90ch; }
.submission summary { cursor: pointer; font-weight: 600; }
.submission pre { margin: 6px 0 12px; padding: 10px 12px; max-height: 280px; overflow: auto; white-space: pre-wrap; background: var(--surface-2); border-radius: var(--r-panel); font-size: 13px; }
.speed { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.chapters .chbtn { display: flex; flex-direction: column; gap: 2px; width: 100%; min-height: 24px; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.chapters li.whatif.open { cursor: default; }

/* Keyboard focus on a diagram node: SVG outline is unreliable, so the ring is a stroke. Last in the file so it beats .active/.sel/.failed. */
.diagram .node.node:focus-visible rect.box { stroke: var(--focus); stroke-width: 4; stroke-opacity: 1; } /* a dimmed node's stroke is at .6; the focus ring must stay full strength (WCAG 1.4.11) */
/* Admin review of requests and request-born drafts (U20) */
.rv-row > td { padding: 0; background: var(--surface-2); }
.review { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; overflow-wrap: anywhere; }
.review .rv-url { font-family: var(--f-mono); font-size: 13px; }
.rv-text { white-space: pre-wrap; max-height: 12em; overflow: auto; margin-top: 4px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); font-size: 14px; }
.rv-caution { margin: 0; color: var(--muted); font-size: 13px; }
.rv-hint { align-self: center; font-size: 13px; }
.review a { color: var(--accent-ink); }
/* At phone width the request and draft tables stack: title first, then status and actions, and the review region spans the row (U20) */
@media (max-width: 640px) {
  #requestsTable thead, #draftsTable thead { display: none; }
  #requestsTable, #requestsTable tbody, #draftsTable, #draftsTable tbody { display: block; }
  #requestsTable tr, #draftsTable tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  #requestsTable td, #draftsTable td { display: block; padding: 0; border: 0; }
  #requestsTable td:first-child, #draftsTable td:first-child { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
  #requestsTable tr.rv-row, #draftsTable tr.rv-row { display: block; padding: 0; }
  #requestsTable tr.rv-row[hidden], #draftsTable tr.rv-row[hidden] { display: none; }
  .rv-row > td { width: 100%; }
  #requestsTable .acts, #draftsTable .acts { flex-wrap: wrap; }
}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.tab-hint { font-size: 12px; font-weight: 400; color: var(--muted); }

/* The language select follows the solution box in the DOM, so Tab goes statement, solution, language, input (spec-composer-validation); the grid keeps it beside the title. */
.field.sol { display: grid; grid-template-columns: auto 1fr; column-gap: 6px; row-gap: 6px; align-items: center; }
.field.sol .sol-title { grid-area: 1 / 1; }
.field.sol #language { grid-area: 1 / 2; justify-self: start; margin-left: 0; }
.field.sol textarea { grid-area: 2 / 1 / 3 / 3; }
.field.sol .field-err { grid-area: 3 / 1 / 4 / 3; }
.field.sol .tab-hint { grid-area: 4 / 1 / 5 / 3; }

/* Player control bar = two groups (U22): transport never wraps inside itself; the options group wraps as a whole under it when the row is short */
.transport { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; white-space: nowrap; }
.options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 0 1 auto; margin-left: auto; }
@media (max-width: 960px) { .options { margin-left: 0; } }
@media (pointer: coarse) { .timeline > .hint { display: none; } }
/* Composer validation and busy notice (U25) */
.field textarea[aria-invalid="true"], .field textarea.mono[aria-invalid="true"] { border: 2px solid var(--bad); }
/* The ring is drawn whenever an invalid field has focus: focus is moved there by script after a click, which :focus-visible does not count (WCAG 2.4.7) */
.field textarea[aria-invalid="true"]:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.field-err { margin: 0; color: var(--bad); font-size: 13px; font-weight: 600; }
.field-err::before, #authErr:not(:empty)::before { content: "!"; display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 6px; border-radius: 50%; border: 1.5px solid currentColor; font-size: var(--fs-xs); font-weight: 800; }
.new-summary { display: flex; flex-direction: column; gap: 8px; }
.new-summary .err:empty { display: none; }
.new-summary .err { font-weight: 600; }

#editorHint { padding: 0 14px 10px; margin: 0; } /* the editor hint sits inside the code card's content padding (KB-1 follow-up) */

/* Scroll cue on wide tables (U10): a right-edge shadow while there is more to the right, drawn with background-attachment (cover moves with the content, shadow stays) so no JS observer is needed. */
.table-wrap[role="region"] {
  background:
    linear-gradient(to left, var(--surface), var(--surface)) 100% 0 / 24px 100% no-repeat local,
    linear-gradient(to left, color-mix(in srgb, var(--ink) 24%, transparent), transparent) 100% 0 / 16px 100% no-repeat scroll;
  background-color: var(--surface);
}
.table-wrap[role="region"]:focus-visible { outline-offset: -2px; }

/* My runs becomes cards at phone width: one DOM, restyled. The header row stays for assistive tech (visually hidden), and cells keep explicit table roles in the markup. */
@media (max-width: 640px) {
  #runsTable, #runsTable tbody { display: block; }
  #runsTable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #runsTable tbody tr { display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px 12px; align-items: center; padding: 12px; margin: 8px; border: 1px solid var(--line); border-radius: 12px; }
  #runsTable td { display: block; padding: 0; border: 0; min-width: 0; }
  #runsTable td:nth-child(1) { grid-column: 1 / 4; grid-row: 1; }
  #runsTable td:nth-child(5) { grid-column: 4; grid-row: 1; }
  #runsTable td:nth-child(2) { grid-column: 1; grid-row: 2; }
  #runsTable td:nth-child(3) { grid-column: 2; grid-row: 2; }
  #runsTable td:nth-child(4) { grid-column: 3; grid-row: 2; }
  #runsTable td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-family: var(--f-ui); font-size: 12px; }
  #runsTable td:nth-child(1) .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
  #runsTable .row { display: flex; align-items: flex-start; flex-wrap: nowrap; gap: 10px; }
  #runsTable .row > div { min-width: 0; }
  #runsTable td:nth-child(n+2):nth-child(-n+3) { white-space: nowrap; }
  #runsTable td:nth-child(4) { grid-column: 3 / 5; white-space: normal; overflow-wrap: break-word; text-align: right; } /* a longer 'Started' wraps at words, under the Delete column too, instead of clipping */
  #runsTable .acts .btn { min-height: 32px; }
  #view-runs .row.wrap.picking { position: sticky; top: 0; z-index: 6; background: var(--bg); padding: 8px 0; }
  #view-runs .row.wrap.picking #compareBtn { flex: 1; min-height: 40px; }
}

/* The guest library picker listed its longest option at full width and pushed the page to 497px on a 390px phone */
.picker { min-width: 0; max-width: 100%; }
.picker select, #problem { max-width: 100%; min-width: 0; text-overflow: ellipsis; }

/* Shared dialog (U16) and the account page (U19) */
.dialog { scroll-padding-bottom: 90px; width: min(440px, 92vw); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); color: var(--ink); box-shadow: 0 12px 40px rgba(0, 0, 0, .35); overflow: auto; }
.dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog p, .dialog ul { margin: 0 0 6px; font-size: 14px; }
.dialog ul { padding-left: 20px; }
.dialog .hint { font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -20px; background: var(--surface); padding: 12px 0 20px; margin: 0 0 -20px; border-top: 1px solid var(--line); box-shadow: 0 -8px 8px -8px rgba(0, 0, 0, .25); } /* stays reachable when the dialog scrolls on a short screen */
.dialog-actions .btn { min-height: 40px; }
.dialog-actions { flex-wrap: wrap; } /* so the cue can take a row of its own above the buttons */
.dialog-cue { flex: 1 0 100%; width: 100%; margin: 0; text-align: center; font-size: 13px; color: var(--muted); } /* plain text above the buttons while the inputs are out of view */
.dialog-cue[hidden] { display: none; }
.btn.danger.solid { background: var(--bad); color: var(--on-accent); border-color: var(--bad); }
.btn.danger.solid:disabled { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); opacity: 1; }
@media (max-width: 480px) { .dialog-actions { flex-direction: column; } .dialog-actions .btn { width: 100%; } .dialog { scroll-padding-bottom: 130px; } }
@media (prefers-reduced-motion: no-preference) { .dialog[open] { animation: dlg-in .15s ease-out; } @keyframes dlg-in { from { opacity: 0; } } }
.who-link { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; border-radius: var(--r-ctl); }
.who-link:hover #whoEmail { text-decoration: underline; }
.account-sec { padding: 16px; margin: 0 0 16px; max-width: 640px; }
.account-sec h2 { margin: -16px -16px 12px; padding: 9px 14px; border-bottom: 1px solid var(--line); font: 700 var(--fs-xs) var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); } /* header strip, as the other panels (refresh 6b) */
.account-sec h3 { margin: 0 0 4px; font-size: 16px; }
.account-sec p { margin: 0 0 12px; }
.kv-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 14px; }
.kv-list dt { color: var(--muted); } .kv-list dd { margin: 0; overflow-wrap: anywhere; }
.danger-zone { border-color: var(--bad); }
.danger-zone h2 { color: var(--bad); }
.dialog .field-err { margin: 0; color: var(--bad); font-size: 13px; font-weight: 600; }
.dialog .notice a { white-space: nowrap; }
/* Not-found view (U24) */
.nf { max-width: 480px; margin: 40px auto; }
.nf h1 { margin: 0; font-size: 24px; color: var(--ink); }
.nf p { margin: 0; color: var(--muted); }
.nf .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.nf .btn { min-height: 40px; display: inline-flex; align-items: center; }

/* U7: first frame, result card order, phone Why strip */
.callcard .chips { gap: 8px; }
.blk.unset { min-height: 56px; }
.coach { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.coach.done { visibility: hidden; }
.tutor .block { width: 100%; }
.tutor .fb { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.linkbtn { border: 0; background: none; padding: 4px 2px; min-height: 24px; color: var(--accent-ink); font: inherit; text-decoration: underline; cursor: pointer; }
.whystrip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.whystrip[hidden] { display: none; }
.whystrip .btn { min-height: 40px; }
.chapters:has(li.whatif.open) { flex-wrap: wrap; } /* the What-if form takes its own row */
/* Rendered markdown in Claude's prose slots (answers, interviewer replies): paragraphs and lists, no pre-wrap */
.md { white-space: normal; overflow-wrap: anywhere; } /* a 20,000-character unbroken string wraps instead of widening the page */
.ask-a.md, .bubble.md { white-space: normal; overflow-wrap: anywhere; } /* a 20,000-character unbroken string wraps instead of widening the page */
.md p { margin: 0 0 .6em; } .md > :last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.md code { font: 13px var(--f-mono); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 0 4px; }
.md pre { white-space: pre; overflow-wrap: normal; margin: .4em 0 .6em; padding: 8px 10px; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--line-strong); border-radius: var(--r-panel); overflow-x: auto; } /* --code-bg is the same colour as the answer box in the light theme, so the block is also outlined */
.md pre code { background: none; border: 0; padding: 0; }
/* Zoom controls (lesson diagram, draw canvas): - level + Reset */
.zoom { display: flex; align-items: center; gap: 6px; }
.zoom .btn { min-width: 30px; min-height: 30px; }
.zoom-level { min-width: 4ch; text-align: center; font: 600 13px var(--f-mono); color: var(--muted); }
.btn[aria-disabled="true"] { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); cursor: default; } /* at a zoom limit: dashed like :disabled, but still focusable */
@media print { .zoom { display: none !important; } .diagram svg { width: 100% !important; } }
/* Ask answers with a diagram (row C): drawn by the lesson diagram's own node and edge styles */
.ask-diag { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ask-diag-title { margin: 0; font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ask-diagram { border: 1px solid var(--line); border-radius: var(--r-panel); } /* its own class on purpose: no .diagram query in the lesson code or a harness can reach it; the shared look comes from the :is(.diagram, .ask-diagram) rules above */
.ask-diagram .node { cursor: default; }
.ask-diagram .edge text { opacity: 1; fill: var(--ink); font-weight: 600; } /* the lesson diagram shows edge labels on hover only; here they stay */
.ask-diag-ctrl { display: flex; gap: 6px; }
.ask-diag-cap { min-height: 1.5em; font-size: 14px; color: var(--ink); }
.ask-diag-ctrl .btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
@media print { .ask-diag-ctrl { display: none !important; } }
/* Invites with several seats (admin) */
.invite-form { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 12px; margin-bottom: 10px; }
.invite-form > input { flex: 1 1 220px; min-width: 0; min-height: 40px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); font: inherit; background: var(--surface); color: var(--ink); }
.invite-form .btn { min-height: 40px; align-self: flex-start; }
.invite-uses { flex: 1 1 260px; }
.invite-uses label { font-size: 13px; font-weight: 600; }
.invite-uses input { max-width: 120px; min-height: 40px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); font: inherit; background: var(--surface); color: var(--ink); }
.invite-uses input[aria-invalid="true"] { border-color: var(--bad); }
.uses summary { cursor: pointer; min-height: 24px; display: flex; align-items: center; }
.uses ul { margin: 6px 0 0; padding-left: 18px; }
.uses li { overflow-wrap: anywhere; }
/* Held for review (I-27): a lesson's published version beside the new version waiting for an admin */
.pill.review { color: var(--accent-ink); background: var(--accent-soft); }
.held { margin: 0 0 14px; padding: 0; }
.held-row { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.held-row:last-child { border-bottom: 0; }
.held-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.held-head .t { margin: 0; font-size: 16px; }
.held-cells { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.held-cell { border: 1px solid var(--line); border-radius: var(--r-panel); padding: 10px 12px; min-width: 0; }
.held-cell p { margin: 0 0 6px; overflow-wrap: anywhere; }
.held-h { font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.held-cell .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.held-notice { margin-top: 8px; }
.held-rv { margin-top: 10px; }
@media (max-width: 960px) { .held-cells { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .held-cell .btn, .held-cell .btn.small, .held-head .btn, .held-head .btn.small, .rv-switch .btn.small, .rv-foot .btn, .rv-foot .btn.small, .rv-pick select { min-height: 40px; height: 40px; } }
/* the review region of a held lesson */
.rv-h { margin: 0 0 8px; font-size: 15px; }
.rv-given, .rv-compare { margin-bottom: 14px; }
.rv-given h5, .rv-compare h5 { margin: 0 0 6px; font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rv-label { margin: 8px 0 4px; font-weight: 600; font-size: 13px; }
.rv-text { max-height: 240px; overflow: auto; white-space: pre-wrap; border: 1px solid var(--line); border-radius: var(--r-panel); padding: 8px 10px; font-size: 13px; background: var(--surface-2); }
.rv-pick { max-width: 360px; margin-bottom: 8px; }
.rv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-height: 520px; overflow: auto; }
.rv-col { min-width: 0; border: 1px solid var(--line); border-radius: var(--r-panel); padding: 10px 12px; }
.rv-col h6 { margin: 0 0 6px; font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rv-col h6.rv-sec { margin-top: 12px; }
.rv-col p { margin: 0 0 6px; overflow-wrap: anywhere; font-size: 14px; }
.rv-col .rv-chname { font-weight: 700; }
.rv-col .rv-step-t { font-weight: 600; margin-top: 8px; }
.rv-col ul { margin: 0; padding-left: 18px; font-size: 13px; overflow-wrap: anywhere; }
.rv-switch { display: none; } .rv-switch .btn[aria-pressed="true"] { background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 700; }
@media (max-width: 960px) { .rv-cols { grid-template-columns: 1fr; } .rv-switch { display: flex; gap: 8px; margin-bottom: 8px; } .rv-cols[data-side="old"] > .rv-col:nth-child(2), .rv-cols[data-side="new"] > .rv-col:nth-child(1) { display: none; } }
.rv-pick select { min-height: 32px; }
.held-head .t { min-width: 0; overflow-wrap: anywhere; }
.rv-h { overflow-wrap: anywhere; }
td.soon { color: var(--warn); font-weight: 600; }
.blog-label { font-weight: 600; }
.blog-check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.blog-check { padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--r-panel); background: var(--surface); overflow-wrap: anywhere; }
.blog-check.block { border-left-color: var(--bad); } .blog-check.warn { border-left-color: var(--warn); }
.blog-check p { margin: 0; } .chk-kind { font: 12px var(--f-mono); color: var(--muted); }
.blog-source { padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.blog-source-title { margin: 0; font-size: 15px; }
.blog-excerpt .excerpt { max-height: 14em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px; background: var(--surface-2); border-radius: var(--r-ctl); font: 13px/1.5 var(--f-mono); }
.blog-preview { padding: 16px; margin-top: 16px; } .blog-preview p { max-width: 70ch; overflow-wrap: anywhere; }
.blog-footer { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0; margin-top: 16px; background: var(--bg); border-top: 1px solid var(--line); }
.blog-footer .hint { flex-basis: 100%; }
.blog-footer [aria-disabled="true"] { cursor: not-allowed; } /* the shared .btn[aria-disabled] look (muted text on surface-2, dashed border) already reads as inactive; no opacity, which dropped it under 3:1 */
.dialog-extras fieldset { border: 0; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.dialog-extras input[type="datetime-local"] { max-width: 100%; }
@media (max-width: 640px) { .blog-footer .btn { min-height: 40px; } }
.blog-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; } .blog-tools #blogDiff { flex-basis: 100%; }
.blog-edit { display: grid; gap: 14px; max-width: 70ch; } .blog-edit textarea, .blog-edit input { width: 100%; font: inherit; }
.blog-diff { border: 1px solid var(--line); border-radius: var(--r-panel); padding: 10px 12px; background: var(--surface); }
.diff-row { margin: 4px 0; display: flex; gap: 8px; overflow-wrap: anywhere; } .diff-row.same { color: var(--muted); }
.diff-sign { flex: none; width: 1.2em; font: 700 14px var(--f-mono); }
.diff-row ins { text-decoration: underline; background: var(--ok-soft); color: var(--ink); } .diff-row del { text-decoration: line-through; background: var(--bad-soft); color: var(--ink); }
.blog-link { display: inline-flex; align-items: center; min-height: 24px; }
.scroll-hint { display: none; margin: 6px 0 0; }
@media (max-width: 640px) { .scroll-hint { display: block; } }
/* The sticky footer must never cover a focused control: browsers scroll a focused element only to the viewport edge, so reserve the footer's worst-case height (padding 24 + border 1 + a button row + the reason hint at 2 lines, or 3 on phones). */
html:has(#view-blogdraft:not([hidden])) { scroll-padding-bottom: 112px; }
@media (max-width: 640px) { html:has(#view-blogdraft:not([hidden])) { scroll-padding-bottom: 140px; } }
/* Blog settings panel (admin) */
.blog-settings { padding: 16px; margin-bottom: 16px; display: grid; gap: 14px; }
.bs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.bs-why { flex-basis: 100%; }
.bs-harness h3, .bs-card h3 { margin: 0 0 6px; font-size: 16px; overflow-wrap: anywhere; }
.bs-switch { display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 2px 12px 2px 4px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-2); color: var(--ink); font: 700 13px var(--f-ui); cursor: pointer; }
.bs-switch::before { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); }
.bs-switch.on { border-color: var(--ok); background: var(--ok-soft); }
.bs-switch.on::before { background: var(--ok); margin-left: 12px; }
.bs-switch[aria-disabled="true"] { border-style: dashed; color: var(--muted); cursor: not-allowed; }
.bs-card { border: 1px solid var(--line); border-radius: var(--r-panel); padding: 12px 14px; display: grid; gap: 10px; min-width: 0; }
.bs-per input { width: 6em; min-height: 32px; }
.bs-sources h4 { margin: 0 0 4px; font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.bs-src-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; overflow-wrap: anywhere; }
.bs-feed, .bs-src-list code { overflow-wrap: anywhere; word-break: break-all; }
.bs-edit-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.bs-edit-row input { width: 100%; min-height: 32px; }
.bs-alert { margin: 0; }
@media (max-width: 640px) { .bs-switch, .blog-settings .btn, .blog-settings .btn.small, .bs-per input, .bs-edit-row input { min-height: 40px; } .bs-edit-row { grid-template-columns: 1fr; } }
/* Daily lesson panel (admin, System design page) */
.daily-panel { padding: 16px; margin-bottom: 16px; display: grid; gap: 10px; }
.daily-panel p { margin: 0; overflow-wrap: anywhere; }
.daily-notice { align-items: center; gap: 10px; }
@media (max-width: 640px) { .daily-panel .btn, .daily-panel .btn.small, .daily-panel .bs-switch { min-height: 40px; } }

/* ---- Lesson clarity, slice 1: the In 30 seconds card, the Details fold, the definition strip, More, the Lesson notes drawer */
.card30 { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "h h" "body side"; gap: 6px 20px; padding: 14px 16px; align-items: center; }
.card30-h { grid-area: h; margin: 0; font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card30-body { grid-area: body; min-width: 0; display: grid; gap: 6px; }
.card30-body p { margin: 0; overflow-wrap: anywhere; max-width: 75ch; }
.card30-core { font-weight: 700; }
.card30-sum { color: var(--muted); }
.card30-side { grid-area: side; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.card30-meta { margin: 0; font: 13px var(--f-mono); color: var(--muted); }
.path-toggle { align-self: flex-start; }
.chapter-q { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.details-toggle { align-self: flex-start; }
.step-details { display: flex; flex-direction: column; gap: 12px; }
.def-strip:empty { display: none; }
.def-box { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-panel); font-size: 14px; overflow-wrap: anywhere; }
.def-box .btn { margin-left: auto; }
.term { font: inherit; color: var(--accent-ink); background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.term:hover { text-decoration-style: solid; }
.learn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 14px 0 0; }
.learn-row .btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.notes-drawer { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.notes-drawer > h2 { margin: 0; font-size: 17px; }
.notes-drawer > .note { margin: 2px 0 10px; }
.exp { border-top: 1px solid var(--line); }
.exp-h { margin: 0; font-size: 15px; }
.exp-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; padding: 8px 4px; background: none; border: 0; font: 600 15px var(--f-ui); color: var(--ink); text-align: left; cursor: pointer; }
.exp-btn::after { content: "▸"; color: var(--muted); }
.exp-btn[aria-expanded="true"]::after { content: "▾"; }
.exp-body { padding: 4px 4px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.exp.sub { margin-left: 12px; }
.exp.sub .exp-btn { min-height: 44px; font-size: 14px; }
@media (max-width: 639px) {
  .design-grid .step-panel { order: -1; }
  .card30 { grid-template-columns: minmax(0, 1fr); grid-template-areas: "h" "body" "side"; }
  .card30-side { align-items: stretch; }
  .card30-start { width: 100%; min-height: 44px; }
  .details-toggle { width: 100%; min-height: 44px; align-self: stretch; }
  .learn-row .btn, .learn-row .btn.small { min-height: 40px; }
  .path-toggle { width: 100%; min-height: 44px; }
}

/* ---- D1: developer-grade symbols, silhouettes, the Key */
/* the silhouette path (cylinder, tube) takes every state the box rect takes: mirrored, so the rect rules above are untouched */
.diagram .node.fresh path.shape { stroke: var(--teal); stroke-width: 2.5; }
.diagram .node path.shape { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; transition: stroke .2s, fill .2s; }
.diagram .node.dim path.shape { fill-opacity: .6; stroke-opacity: .6; }
.diagram .node.active path.shape { stroke: var(--ink); stroke-width: 2.5; }
.diagram .node.failed path.shape { stroke: var(--bad); stroke-width: 2.5; fill: var(--bad-soft); }
.diagram .node.sel path.shape { stroke: var(--accent); stroke-width: 3; }
.diagram .node.asked path.shape { stroke: var(--blue); stroke-width: 3; }
.diagram .node.broken path.shape { stroke: var(--bad); stroke-width: 3; fill: var(--bad-soft); }
.diagram .node.broken.slow path.shape { stroke: var(--note-line); fill: var(--note); }
.diagram .node.broken.full path.shape { stroke: var(--purple); fill: var(--surface-2); }
.diagram .node.affected path.shape { stroke: var(--bad); stroke-dasharray: 5 4; stroke-width: 2; }
.diagram .node.removed path.shape { fill-opacity: .6; } /* struck-through name stays full strength */
.diagram .node.removed path.shape { stroke-dasharray: 6 4; stroke: var(--bad); }
.diagram .node.changed path.shape { stroke: var(--purple); stroke-width: 2.5; }
.diagram .node.node:focus-visible path.shape { stroke: var(--focus); stroke-width: 4; stroke-opacity: 1; } /* a dimmed node's stroke is at .6; the focus ring must stay full strength (WCAG 1.4.11) */
.diagram .node:is(.sil-cylinder, .sil-tube) rect.box { fill: transparent !important; stroke: none !important; } /* the silhouette path carries the look; the rect stays as the hit area and keyboard geometry */
.diagram .node .shape { pointer-events: none; }
.diagram .node.ext rect.box, .diagram .node.ext path.shape { stroke-dasharray: 5 4; } /* dashed outline = outside the system, in every state */
.diagram .node.failed.ext rect.box, .diagram .node.broken.ext rect.box, .diagram .node.affected.ext rect.box { stroke-dasharray: 5 4; }
:is(.diagram, .ask-diagram) .node .icon.sym { stroke-width: 2; }
.diagram .node .downx { fill: none; stroke: var(--bad); stroke-width: 2.4; stroke-linecap: round; visibility: hidden; }
.diagram .node.failed .downx, .diagram .node.broken .downx { visibility: visible; }
.diagram .edge .async-tag { opacity: 1; font-size: 12px; font-weight: 700; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.key-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 6px; background: none; border: 0; font: 700 var(--fs-xs) var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.key-toggle::after { content: "▾"; }
.key-toggle[aria-expanded="false"]::after { content: "▸"; }
.key-body { display: flex; flex-direction: column; gap: 8px; }
.key-kinds, .key-edges { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.key-kinds li, .key-edges li { display: inline-flex; align-items: center; gap: 8px; }
.key-glyph { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.key-line { flex: none; fill: var(--muted); stroke: var(--muted); stroke-width: 1.8; }
.key-line path:last-child { stroke: none; }
.key-hint { margin: 0; font-size: 12px; }
@media (max-width: 639px) { .key-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } .key-toggle { min-height: 40px; } }

/* ---- D2: the view switch and the Sequence view */
.view-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 0 0 8px; }
.view-help { margin: 0; flex: 1 1 200px; }
.view-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); overflow: hidden; }
.view-switch button { min-height: 32px; padding: 0 14px; background: transparent; border: 0; font: 600 13px var(--f-ui); color: var(--muted); cursor: pointer; }
.view-switch button + button { border-left: 1px solid var(--line-strong); }
.view-switch button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.seq-region { overflow: auto; max-height: min(70vh, 520px); position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.seq-svg { display: block; }
.seq-life { stroke: var(--line-strong); stroke-width: 1.2; fill: none; }
.seq-headbg { fill: var(--surface); }
.seq-part rect { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.2; }
.seq-part text { font: 700 12px var(--f-ui); fill: var(--ink); }
.seq-part .sym { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.seq-bandbg { fill: transparent; }
.seq-step.cur .seq-bandbg { fill: var(--accent-soft); }
.seq-bar { fill: var(--accent); }
.seq-bubble { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.seq-step.cur .seq-bubble { fill: var(--accent); stroke: var(--accent); }
.seq-num { font: 700 12px var(--f-ui); fill: var(--ink); }
.seq-step.cur .seq-num { fill: var(--on-accent); }
.seq-arrow { fill: none; stroke: var(--ink); stroke-width: 1.8; }
.seq-arrow.async { stroke-dasharray: 6 5; }
#seqarr path { fill: var(--ink); }
.seq-label { font: 12px var(--f-ui); fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.seq-pill { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.2; }
.seq-pilltext { font: 600 12px var(--f-ui); fill: var(--ink); }
.seq-down path { stroke: var(--bad); stroke-width: 2.4; fill: none; stroke-linecap: round; }
.seq-down text { font: 800 12px var(--f-ui); fill: var(--bad); }
.seq-note rect { fill: var(--note); stroke: var(--note-line); }
.seq-note text { font: 12px var(--f-mono); fill: var(--ink); }
.seq-hit { fill: transparent; cursor: pointer; }
.seq-row:focus { outline: none; }
.seq-row:focus-visible .seq-hit { stroke: var(--focus); stroke-width: 3; }
.seq-hint, .seq-hidden { margin: 6px 12px; font-size: 12px; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); text-decoration: underline; cursor: pointer; min-height: 24px; }
@media (max-width: 639px) {
  .view-row { flex-direction: column-reverse; align-items: stretch; }
  .view-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-switch button { min-height: 40px; }
  .seq-region { max-height: 60vh; }
}
@media print { .view-row { display: none !important; } #seqRegion { display: none !important; } #diagram[hidden] { display: block !important; } }

/* ---- D3: the C4 Context view and the system boundary on Containers */
.view-switch button[hidden] + button { border-left: 0; } /* a hidden first tab must not leave its divider behind */
.ctx-region { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow-x: auto; }
.ctx-svg { display: block; margin: 0 auto; }
.ctx-sysbox { fill: var(--surface-2); stroke: var(--ink); stroke-width: 2; }
.ctx-sys.active .ctx-sysbox { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.5; }
.ctx-box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.ctx-node { cursor: pointer; }
.ctx-node.ext .ctx-box { stroke-dasharray: 5 4; } /* dashed outline = outside the system, as on Containers; the caption says it in words too */
.ctx-node.active .ctx-box { stroke: var(--ink); stroke-width: 2.5; }
.ctx-node.sel .ctx-box { stroke: var(--accent); stroke-width: 3; }
.ctx-node:focus { outline: none; }
.ctx-node:focus-visible .ctx-box { stroke: var(--focus); stroke-width: 4; }
.ctx-name, .ctx-sysname { font: 700 14px var(--f-ui); fill: var(--ink); }
.ctx-sysname { font-size: 15px; }
.ctx-cap { font: 12px var(--f-ui); fill: var(--muted); }
.ctx-desc { font: 12px var(--f-ui); fill: var(--ink); }
.ctx-svg .sym { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ctx-edge path { fill: none; stroke: var(--ink); stroke-width: 1.8; }
.ctx-edge.async path { stroke-dasharray: 6 5; }
.ctx-svg marker path { fill: var(--ink); stroke: none; }
.ctx-label { font: 12px var(--f-ui); fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.diagram .boundary { pointer-events: none; }
.diagram .boundary path { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.diagram .boundary text { font: 700 12px var(--f-ui); fill: var(--muted); }
