/* Tink: paper and ink. A quiet editorial page around one screen that shows what a sound means.
   Each taught sound owns a soft tint, and the screen takes that tint when the sound is heard. */
:root {
  /* paper and ink: one off-white page, near-black type, hairline rules, a single red for hover */
  --house: #fafaf7; --surface: #ffffff; --surface-2: #f3f3ee; --line: #e5e5e0;
  --fg: #111111; --muted: #555555; --control-line: #b8b8b0;
  --ink: #111111;            /* type on the screen */
  --paper: #ffffff;          /* the screen while listening */
  --paper-dim: #f3f3ee;      /* the screen at rest */
  --ash: #d9d9d2;            /* nothing matched */
  --light: #111111;          /* primary control fill */
  --on-light: #fafaf7;       /* text on a primary control */
  --hover: #c45c5c;
  --grid: #d4d4cd;
  --miss: #b4483f;
  --alarm: #e0675b;          /* urgent: ink on it 5.3:1 */
  /* screen tints, one per taught sound, in teaching order; all light enough for ink type */
  --t0: #eadcae; --t1: #cfe0c8; --t2: #efcdc4; --t3: #cddcea; --t4: #e0d7ea; --t5: #dde6bd;
  --scrim: var(--paper-dim);
  --display: "Spectral", Georgia, serif;
  --body: "Inter Tight", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 4px; --r-pill: 2px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
/* Increase Contrast: secondary text to full strength, every edge to control strength */
@media (prefers-contrast: more) {
  :root { --muted: var(--fg); --line: var(--control-line); }
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--control-line) transparent; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--house); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; caret-color: var(--light); accent-color: var(--light); overflow-x: hidden; }
::selection { background: var(--ink); color: var(--on-light); }
.wrap { max-width: 1340px; margin: 0 auto; padding: 18px 22px 56px; display: grid; gap: 20px; }
h1, h2 { margin: 0; text-wrap: balance; }
h2 { font-family: var(--body); font-weight: 700; font-size: 19px; letter-spacing: 0; }
button, select { font: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 10px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ph, .ph-fill { font-size: 1.15em; line-height: 1; }

/* everything outside the screen steps back while Tink speaks */
.top, .side, .lower, .pad { transition: opacity .4s var(--ease); }
body.speaking .top, body.speaking .side, body.speaking .lower, body.speaking .pad { opacity: .38; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; min-height: 64px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand h2 { font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1; letter-spacing: -.01em; }
.brand > div { display: grid; gap: 4px; }
.app-mark { width: 34px; height: 26px; fill: var(--ink); }
.tagline { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.top-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode { font-family: var(--mono); font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 7px 12px; }
.select { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px 0 14px; border: 1px solid var(--control-line); border-radius: var(--r); color: var(--fg); }
.select select { appearance: none; border: 0; background: transparent; color: var(--fg); padding: 8px 26px 8px 2px; min-height: 42px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) 52%, calc(100% - 8px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.select select option { background: var(--surface); color: var(--fg); }
.select:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 0; border-radius: var(--r); padding: 11px 22px; font-weight: 500; background: var(--light); color: var(--on-light); white-space: nowrap; transition: transform .15s var(--ease), background .2s, border-color .2s; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn.quiet { background: transparent; color: var(--fg); border: 1px solid var(--control-line); }
.btn.quiet:hover:not(:disabled) { border-color: var(--ink); color: var(--hover); }
.btn:not(.quiet):hover:not(:disabled) { background: #333; }
.btn.quiet[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); }
.btn.small { min-height: 40px; padding: 7px 16px; font-size: 15px; }
.btn.danger { background: var(--miss); color: var(--on-light); }
.icon-btn span { font-size: 15px; }
.btn.listen { min-height: 64px; padding: 14px 38px; font-size: 20px; position: relative; }
.btn.listen .ph-fill { font-size: 24px; }
.btn.listen .lvl { position: absolute; inset: 0; border-radius: inherit; background: var(--on-light); opacity: .22; transform-origin: left; transform: scaleX(0); pointer-events: none; }
.listening .btn.listen .lvl { transform: scaleX(calc(.08 + .92 * var(--lvl))); transition: transform .08s linear; }
.btn.listen { overflow: visible; isolation: isolate; }
.listening .btn.listen:disabled { opacity: 1; cursor: default; } /* busy listening, not unavailable */
.listening .btn.listen::after { content: ""; position: absolute; inset: -6px; border-radius: inherit; border: 1px solid var(--ink); opacity: .6; animation: ring 1.4s var(--ease) infinite; }
@keyframes ring { from { transform: scale(.96); opacity: .7; } to { transform: scale(1.12); opacity: 0; } }

/* ---------- layout ---------- */
.main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(330px, 1fr); gap: 22px; align-items: start; }
.col { display: grid; gap: 22px; min-width: 0; }
.side { align-self: start; }
.lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 980px) { .main { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .lower { grid-template-columns: 1fr; } }

/* ---------- the stage: a house frame holding one backlit screen ---------- */
.stage { --lvl: 0; display: grid; gap: 18px; min-width: 0; }
.scrim {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 560px; padding: 22px 26px 56px; border-radius: var(--r);
  background-color: var(--scrim); color: var(--ink);
  background-image: linear-gradient(rgba(17, 17, 17, .055) 1px, transparent 1px), linear-gradient(90deg, rgba(17, 17, 17, .055) 1px, transparent 1px);
  background-size: 28px 28px; background-position: -1px -1px;
  display: grid; grid-template-rows: auto 1fr; gap: 12px;
  transition: background-color .7s var(--ease);
  border: 1px solid var(--line);
}
#dust { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; }
.scrim > :not(canvas) { position: relative; }

.idle .scrim { --scrim: var(--paper-dim); }
.listening .scrim { --scrim: var(--paper); }
.missed .scrim { --scrim: var(--paper-dim); }
.error .scrim { --scrim: var(--ash); }
/* .heard sets --scrim inline to the heard sound's tint */
/* urgent: the screen turns alarm red and pulses about once a second until someone answers */
.alarm .scrim { --scrim: var(--alarm) !important; animation: alarm-pulse 1.6s steps(1, end) infinite; }
@keyframes alarm-pulse { 0%, 100% { background-color: var(--alarm); } 50% { background-color: #f6b1a6; } } /* ink on the light phase 10:1 */
/* on the lit screen, focus is drawn in ink: the lamp colour would vanish against the paper or an amber tint */
.scrim :focus-visible { outline-color: var(--ink); }

.stage-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.status { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 15px; min-height: 32px; color: var(--ink); }
.bars { display: flex; gap: 3px; align-items: center; height: 22px; }
.bars i { display: block; width: 4px; height: 22px; border-radius: 2px; background: var(--ink); transform: scaleY(calc(.22 + .78 * var(--lvl))); transition: transform .08s linear; }
.bars i:nth-child(2), .bars i:nth-child(4) { transform: scaleY(calc(.22 + .52 * var(--lvl))); }

.center { display: grid; justify-items: center; text-align: center; gap: 16px; align-content: center; padding-block: 6px; }
.phrase { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 5.2vw, 68px); line-height: 1.06; letter-spacing: -.012em; max-width: 17ch; text-wrap: balance; min-height: 1.06em; color: var(--ink); }
/* the paper-cut reveal is driven from app.js (castPhrase); the blade is its cutting edge */
.center { position: relative; }
.blade { position: absolute; top: 0; width: 3px; border-radius: 2px; background: var(--ink); pointer-events: none; }
.why { font-size: 16.5px; min-height: 1.5em; max-width: 54ch; color: var(--ink); opacity: .82; }
.why b { opacity: 1; }
.conf { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* first run: a real sequence, so it is numbered */
.guide { list-style: none; counter-reset: step; margin: 4px 0 0; padding: 0; display: grid; align-items: start; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; width: min(660px, 100%); text-align: left; border-top: 1px solid rgba(17, 17, 17, .18); }
.guide li { counter-increment: step; display: grid; gap: 2px; padding: 14px 16px 4px 6px; }
.guide li + li { padding-left: 16px; border-left: 1px solid rgba(17, 17, 17, .18); }
.guide li::before { content: counter(step); font-family: var(--display); font-size: 30px; line-height: 1; }
.guide b { font-size: 16px; }
.guide span { font-size: 14.5px; opacity: .8; }
.guide li.done b::after { content: " · done"; font-weight: 400; }
@media (max-width: 560px) { .guide { grid-template-columns: 1fr; } .guide li + li { border-left: 0; padding-left: 0; border-top: 1px solid rgba(17, 17, 17, .18); } }

/* result, set in ink on the screen */
.taught { display: flex; gap: 6px 12px; align-items: center; flex-wrap: wrap; justify-content: center; font-size: 15px; }
.linkish { border: 0; background: none; color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; min-height: 36px; padding: 4px 6px; border-radius: 8px; }
.ranked { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; width: min(460px, 100%); text-align: left; }
.ranked li { animation: row-in .42s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.ranked li .bar { animation-delay: calc(120ms + var(--i, 0) * 70ms); animation-fill-mode: both; }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ranked li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; font-size: 15.5px; align-items: center; }
.ranked .sw { width: 14px; height: 14px; border-radius: 2px; background: var(--t); border: 1px solid var(--ink); }
.ranked li.lead .sw, .ranked li.lead .bar { background: var(--ink); }
.ranked .p { font-family: var(--mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ranked .bar { grid-column: 1 / -1; height: 6px; border-radius: 1px; background: var(--t); box-shadow: inset 0 0 0 1px var(--ink); transform-origin: left; animation: grow .6s var(--ease); }
.ranked li.unknown .bar { background: rgba(17, 17, 17, .2); box-shadow: none; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.alarm-box { display: grid; justify-items: center; gap: 8px; font-weight: 700; }
.btn.ack { min-height: 72px; padding: 16px 44px; font-size: 22px; background: var(--ink); color: var(--paper); }
.btn.ack .ph-fill { font-size: 26px; }
body.present .btn.ack { min-height: 88px; font-size: 28px; }
.feedback { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; font-size: 15.5px; }
.feedback .btn { background: var(--ink); color: var(--paper); }
.feedback .btn.quiet { background: transparent; color: var(--ink); border-color: var(--ink); }

/* controls in the house, under the screen */
.pad { display: grid; gap: 12px; justify-items: center; text-align: center; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: center; }
.toggles { display: flex; gap: 8px 24px; flex-wrap: wrap; justify-content: center; }
.toggle { display: flex; gap: 8px; align-items: center; min-height: 36px; color: var(--fg); cursor: pointer; }
.toggle input { width: 20px; height: 20px; }
.hint { margin: 0; color: var(--muted); font-size: 14.5px; }
.note { margin: 0; color: var(--muted); font-size: 14px; max-width: 62ch; }
.note .ph { vertical-align: -2px; }

/* camera preview sits on the screen's corner */
.cam { display: grid; gap: 6px; justify-items: end; }
.cam video { width: 132px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r); border: 1px solid var(--ink); transform: scaleX(-1); background: var(--ink); }
.cue-chips, .cue-boxes { display: flex; gap: 6px; flex-wrap: wrap; }
.cue { font-size: 13.5px; padding: 3px 10px; border-radius: var(--r-pill); border: 1px solid var(--line); color: var(--muted); }
.cam .cue { border-color: rgba(17, 17, 17, .35); color: var(--ink); }
.cam .cue.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* the heard sound's swatch flies from the list and blooms into the screen */
.flight { position: fixed; z-index: 30; pointer-events: none; background: var(--t); }

/* present mode morphs through a view transition */
.scrim { view-transition-name: scrim; }
.brand h2 { view-transition-name: wordmark; }
::view-transition-group(scrim) { animation-duration: .5s; animation-timing-function: cubic-bezier(.16, 1, .3, 1); }

/* ---------- side panels ---------- */
.side { display: grid; gap: 22px; align-content: start; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; display: grid; gap: 14px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.head small { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.panel h2 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.2; }
.head-icon { color: var(--muted); font-size: 22px; }
.empty { margin: 0; color: var(--muted); }

.selftest { order: 3; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14.5px; }
.selftest b { color: var(--fg); }
.selftest:empty { display: none; }
.sounds { list-style: none; margin: 0; padding: 0; display: grid; }
.sound { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 2px 12px; padding: 12px 6px; align-items: center; border-top: 1px solid var(--line); transition: background .3s; border-radius: 10px; }
.sound:first-child { border-top: 0; }
.sound .sw { width: 18px; height: 18px; border-radius: 2px; background: var(--t); box-shadow: inset 0 0 0 1px rgba(17, 17, 17, .25); }
.sound.learned .sw { animation: learned .6s var(--ease); }
@keyframes learned { 40% { transform: scale(1.6); } }
.sound.lit { background: color-mix(in srgb, var(--t) 45%, transparent); }
.sound .name { font-weight: 700; }
.sound .says, .sound .cuelist { grid-column: 2 / -1; }
.sound .says { color: var(--muted); font-size: 15px; }
.sound .cuelist { display: flex; gap: 4px; flex-wrap: wrap; }
.cue.role { border-color: var(--t); color: var(--fg); }
.forget { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted); min-width: 40px; min-height: 40px; border-radius: 10px; font-size: 18px; }
.bank { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted); min-width: 40px; min-height: 40px; border-radius: 10px; font-size: 18px; }
.bank:hover { color: var(--hover); background: var(--surface-2); }
.bank.recording { color: var(--on-light); background: var(--miss); }
.cue.voice { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; background: none; font: inherit; font-size: 13.5px; border-color: var(--ink); color: var(--fg); }
.cue.voice:hover { color: var(--hover); border-color: var(--hover); }
.forget:hover { color: var(--miss); background: color-mix(in srgb, var(--miss) 12%, transparent); }
.confirm-row { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 8px; font-size: 15px; }
.takes { display: flex; gap: 4px; align-items: center; }
.takes i { width: 8px; height: 8px; border-radius: 50%; background: var(--fg); }
.takes i.off { background: transparent; border: 1.5px solid var(--control-line); }

form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: 15px; }
.field input:not([type="checkbox"]):not([type="radio"]) { width: 100%; min-height: 48px; padding: 11px 14px; border-radius: var(--r); border: 1px solid var(--control-line); background: var(--house); color: var(--fg); font: inherit; }
.field input:not([type="checkbox"]):not([type="radio"]):focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 1px var(--ink); }
.field input::placeholder { color: var(--muted); opacity: .8; }
.field input[readonly] { opacity: .75; }
.help { color: var(--muted); font-size: 14px; }
.optional { font-weight: 400; color: var(--muted); font-size: 13.5px; margin-left: 4px; }
.cue-pick { border: 0; padding: 0; margin: 0; }
.cue-pick legend { font-weight: 700; font-size: 15px; padding: 0; margin-bottom: 8px; }
.cue-boxes label { display: flex; gap: 6px; align-items: center; min-height: 40px; padding: 6px 13px; border: 1px solid var(--control-line); border-radius: var(--r-pill); font-size: 14.5px; font-weight: 400; white-space: nowrap; cursor: pointer; }
.cue-boxes label:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }
.cue-boxes input { width: 18px; height: 18px; margin: 0; }
.enroll-takes { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.enroll-takes .takes i { width: 14px; height: 14px; }
.takes i.new { animation: pop .32s var(--ease) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#roomTake { position: relative; overflow: hidden; isolation: isolate; }
#roomTake::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--surface-2); transform-origin: left; transform: scaleX(0); }
#roomTake.filling::after { animation: fill 3s linear forwards; }
@keyframes fill { to { transform: scaleX(1); } }
.recording #take { background: var(--miss); color: var(--on-light); }
.urgent-pick { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--control-line); border-radius: var(--r); cursor: pointer; }
.urgent-pick:has(input:checked) { border-color: var(--alarm); background: color-mix(in srgb, var(--alarm) 12%, transparent); }
.urgent-pick input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--alarm); }
.urgent-pick > span { display: grid; gap: 2px; }
.cue.urgent { border-color: var(--alarm); color: var(--fg); }
.err { color: var(--miss); font-size: 14.5px; min-height: 1.2em; margin: 0; }

/* no server behind the page: only the screen stays, with the run instructions on it */
body.no-server .side, body.no-server .lower, body.no-server .reply-panel, body.no-server .pad, body.no-server .guide, body.no-server .top-controls { display: none; }
body.no-server .app-region .main { grid-template-columns: 1fr; }
body.no-server .scrim { min-height: 360px; }
.why code { display: inline-block; margin-top: 10px; padding: 8px 12px; font-family: var(--mono); font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow-wrap: anywhere; }

/* ---------- profiles (public mode) ---------- */
.profile-chip { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--line); }
.profile-chip > span { font-weight: 700; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.onboard { position: relative; z-index: 2; display: grid; gap: 12px; justify-items: center; text-align: center; align-self: center; max-width: 520px; margin: 0 auto; color: var(--ink); }
.onboard h2 { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 4vw, 52px); line-height: 1.05; }
.onboard p { margin: 0; font-size: 16.5px; }
.onboard-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; width: 100%; }
.onboard input { min-height: 52px; padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--ink); background: color-mix(in srgb, var(--paper) 70%, transparent); color: var(--ink); font: inherit; font-size: 18px; min-width: 0; }
.onboard .btn { min-height: 52px; background: var(--ink); color: var(--paper); }
.onboard .err { color: var(--ink); font-weight: 700; }
.onboarding .center, .onboarding .pad, .onboarding .stage-top .status { visibility: hidden; }
body.present .profile-chip { display: none; }
@media (max-width: 560px) { .onboard-row { grid-template-columns: 1fr; } .profile-chip .btn span { display: none; } }

/* ---------- answer back ---------- */
.reply-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.reply-row input { min-height: 52px; padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--control-line); background: var(--house); color: var(--fg); font: inherit; font-size: 18px; min-width: 0; }
.reply-row input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 1px var(--ink); }
.reply-row input::placeholder { color: var(--muted); opacity: .8; }
.reply-row .btn { min-height: 52px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.small-select { min-height: 40px; font-size: 15px; }
.small-select .lbl { color: var(--muted); }
.small-select select { min-height: 38px; }
.reply .scrim { --scrim: var(--paper); }
.stamp.replied { border-color: var(--fg); }
body.present .reply-panel { display: none; }
@media (max-width: 560px) { .reply-row { grid-template-columns: 1fr; } }

/* ---------- lower: the stamped log and the packet ---------- */
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; padding: 12px 6px; border-top: 1px solid var(--line); align-items: center; }
.log li:first-child { border-top: 0; }
.log time { font-family: var(--mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log .text { min-width: 0; }
.log .text.struck { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.stamp { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 2px; border: 1.5px solid var(--t, var(--control-line)); color: var(--fg); transform: rotate(-2deg); white-space: nowrap; }
.log li.fresh { animation: row-in .35s var(--ease) both; }
.log li.fresh .stamp { animation: thunk .34s cubic-bezier(.2, 1.4, .4, 1) .12s both; }
@keyframes thunk { 0% { opacity: 0; transform: scale(1.9) rotate(-14deg); } 70% { opacity: 1; transform: scale(.94) rotate(-1deg); } 100% { opacity: 1; transform: scale(1) rotate(-2deg); } }
.stamp.wrong { border-color: var(--miss); color: var(--miss); }
.stamp.urgent { border-color: var(--alarm); background: var(--alarm); color: var(--ink); }
.packet { color: var(--muted); font-size: 14.5px; }
.packet summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.packet pre { margin: 8px 0 0; padding: 14px; border-radius: var(--r); background: var(--house); border: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; overflow: auto; max-height: 260px; color: var(--fg); }

/* ---------- present mode: the screen fills the projector ---------- */
body.present .side, body.present .lower, body.present .tagline, body.present .mode, body.present .hint, body.present .toggles, body.present .note { display: none; }
body.present .top { border-bottom: 0; padding-bottom: 0; }
body.present .wrap { max-width: none; padding: 14px 28px 18px; gap: 14px; }
body.present .main { grid-template-columns: 1fr; }
body.present .scrim { min-height: calc(100dvh - 210px); padding-bottom: 80px; }
body.present .phrase { font-size: clamp(56px, 8vw, 140px); max-width: 18ch; }
body.present .why { font-size: clamp(17px, 1.5vw, 24px); max-width: 70ch; }
body.present .ranked { width: min(720px, 100%); }
body.present .ranked li { font-size: clamp(16px, 1.4vw, 22px); }
body.present .ranked .p { font-size: clamp(14px, 1.15vw, 18px); }
body.present .guide { width: min(940px, 100%); }
body.present .guide b { font-size: 20px; }

@media (max-width: 560px) {
  .wrap { padding: 14px 14px 40px; }
  .scrim { padding: 18px 16px 40px; min-height: 0; }
    .brand h2 { font-size: 24px; }
  .icon-btn span { display: none; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .actions .btn { width: 100%; }
  .btn.listen { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .listening .btn.listen .lvl { transform: scaleX(calc(.08 + .92 * var(--lvl))); } /* the level itself is information */
}

/* ---------- landing page ---------- */
.skip-link { position: fixed; left: 18px; top: 12px; z-index: 100; transform: translateY(-150%); background: var(--ink); color: var(--on-light); padding: 10px 16px; font-weight: 500; }
.skip-link:focus { transform: none; }
a { color: inherit; text-decoration: none; }
.eyebrow, .site-shell .eyebrow { font-family: var(--mono); font-size: clamp(11px, .8vw, 12px); font-weight: 500; letter-spacing: .12em; text-transform: uppercase; line-height: 1.4; color: var(--muted); margin: 0; }

/* side rail: labels sit sideways until the rail is hovered, then turn upright as it widens */
.rail { position: fixed; inset: 0 auto 0 0; z-index: 50; width: 72px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 32px 0; background: var(--house); border-right: 1px solid var(--line); transition: width .2s var(--ease); }
.rail:hover, .rail:focus-within { width: 172px; }
.rail-mark { display: inline-flex; color: var(--ink); transition: opacity .15s; }
.rail-mark:hover { opacity: .7; }
.rail-mark svg { width: 34px; height: 26px; fill: currentColor; }
.rail-links { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rail-links a { display: block; padding: 22px 12px; font-size: 14px; white-space: nowrap; color: var(--muted); transform: rotate(-90deg); transition: transform .2s var(--ease), color .15s, padding .2s var(--ease); }
.rail:hover .rail-links a, .rail:focus-within .rail-links a { transform: none; padding: 10px 12px; }
.rail-links a[aria-current="page"] { color: var(--ink); }
.rail-links a:hover { color: var(--hover); }
.rail-year { font-family: var(--mono); font-size: 10px; letter-spacing: .04em; color: var(--muted); transform: rotate(-90deg); }

.topbar { display: none; position: fixed; inset: 0 0 auto; z-index: 50; }
.topbar nav { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); background: rgba(250, 250, 247, .95); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.topbar .rail-mark svg { width: 24px; height: 18px; }
.topbar-links { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.topbar-links a { color: var(--muted); padding: 8px 4px; transition: color .15s; }
.topbar-links a[aria-current="page"] { color: var(--ink); }
.topbar-links a:hover { color: var(--hover); }
.topbar-links span { color: var(--muted); }

.site-shell, .site-footer, .app-region { padding-left: 72px; }
.site-shell > * { max-width: 1280px; margin-inline: auto; padding-inline: 48px; }
.site-shell section { position: relative; }

/* headings: Spectral, set large and quiet */
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(48px, 5vw, 72px); line-height: 1.05; letter-spacing: -.02em; color: var(--ink); }
.site-shell h2, .site-shell .statement p { font-family: var(--display); font-weight: 400; font-size: clamp(30px, 3vw, 40px); line-height: 1.12; letter-spacing: -.01em; color: var(--ink); margin: 0; }
.site-shell h3 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.25; color: var(--ink); margin: 16px 0 0; }
.site-shell p { color: var(--muted); font-size: clamp(16px, 1.1vw, 17px); line-height: 1.65; }
.site-shell h3 + p { margin: 10px 0 0; }
[data-letters] .ch { transition: color .1s ease; }
[data-letters] .ch:hover { color: var(--hover); }

.arrow-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; transition: color .15s, text-decoration-thickness .15s; }
.arrow-link:hover { color: var(--hover); text-decoration-thickness: 2px; }
.arrow-link span:last-child { display: inline-block; text-decoration: none; transition: transform .2s var(--ease); }
.arrow-link:hover span:last-child { transform: translateX(4px); }

.hero { min-height: min(75vh, 820px); display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 32px; align-items: center; padding-block: 96px; }
.hero-copy { grid-column: 1 / span 6; }
.lede { max-width: 480px; margin: 24px 0 0; }
.links { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 32px; }
.site-shell .byline { margin-top: 48px; }
.byline a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; transition: color .15s; }
.byline a:hover { color: var(--hover); }

.hero-figure { grid-column: 7 / -1; position: relative; min-height: 560px; display: grid; place-items: center; overflow: hidden; }
.hero-grid { position: absolute; inset: -20%; width: 140%; height: 140%; z-index: -1; }
.specimen { width: min(360px, 90%); background: var(--surface); border: 1px solid var(--line); padding: 28px 28px 24px; display: grid; gap: 18px; box-shadow: 0 1px 0 var(--line), 0 24px 48px -32px rgba(17, 17, 17, .25); }
.wave { height: 96px; display: flex; align-items: center; gap: 6px; }
.wave i { flex: 1; height: calc(var(--h) * 100%); background: var(--ink); border-radius: 2px; transform-origin: center; animation: breathe 2.8s var(--ease) infinite; animation-delay: calc(var(--h) * -2.8s); }
@keyframes breathe { 50% { transform: scaleY(.55); } }
.specimen-row { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; }
.specimen-arrow { color: var(--muted); }
.site-shell .specimen-phrase { margin: -6px 0 0; font-family: var(--display); font-size: 34px; line-height: 1.1; color: var(--ink); }
.specimen-foot { display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hover); animation: blink 1.6s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: .25; } }

.statement { padding-block: 160px; }
.site-shell .statement p { max-width: 900px; margin: 0; }

.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding-block: 96px; }
.columns > div { padding: 0 32px; }
.columns > div:first-child { padding-left: 0; }
.columns > div:last-child { padding-right: 0; }
.columns > div + div { border-left: 1px solid var(--line); }

.section-head { display: grid; gap: 16px; max-width: 760px; }
.steps, .privacy, .tech { padding-block: 120px; }
.step-list, .pipeline { list-style: none; margin: 64px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--ink); }
.step-list li, .pipeline li { padding: 24px 32px 0 0; }
.step-list li + li, .pipeline li + li { padding-left: 32px; border-left: 1px solid var(--line); }
.step-n { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--muted); }

.demo-intro { display: grid; gap: 16px; padding-block: 120px 48px; border-top: 1px solid var(--line); }
.site-shell .demo-intro p { max-width: 560px; margin: 0; }

.privacy { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 32px; align-items: start; }
.privacy .section-head { grid-column: 1 / span 5; }
.ledger { grid-column: 7 / -1; margin: 0; border-top: 1px solid var(--ink); }
.ledger div { display: flex; justify-content: space-between; gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.ledger dt { color: var(--ink); }
.ledger dd { margin: 0; color: var(--muted); text-align: right; }

.tech { border-top: 1px solid var(--line); }
.pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pipeline b { display: block; margin-top: 14px; font-family: var(--display); font-weight: 400; font-size: 24px; color: var(--ink); }
.pipeline small { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
.site-shell .measured { max-width: 760px; margin: 64px 0 0; }
.measured .eyebrow { margin-right: 10px; color: var(--hover); }
.measured .arrow-link { margin-left: 4px; }

.site-footer { border-top: 1px solid var(--line); margin-top: 80px; padding-block: 96px 48px; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding-inline: 48px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 32px; align-items: start; font-size: 14px; color: var(--muted); }
.footer-brand { display: grid; gap: 12px; }
.footer-brand a { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); transition: color .15s; }
.footer-brand a:hover { color: var(--hover); }
.footer-mark { width: 24px; height: 18px; fill: currentColor; }
.footer-brand p, .footer-meta p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; }
.footer-links span { color: var(--line); }
.footer-links a, .footer-meta a { transition: color .15s; }
.footer-links a:hover { color: var(--hover); }
.footer-meta a { color: var(--ink); }
.footer-meta a:hover { color: var(--hover); }
.footer-meta { text-align: right; display: grid; gap: 4px; }

/* scroll reveal, driven by site.js */
.motion-ready .reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.motion-ready .reveal.revealed { opacity: 1; transform: none; }

/* live product frame */
.app-region .wrap { max-width: 1280px; padding-inline: 48px; }
.app-region .top { min-height: 72px; }

/* presentation mode isolates the live product */
body.present .site-shell, body.present .rail, body.present .topbar, body.present .site-footer { display: none; }
body.present .app-region { padding-left: 0; }
body.present .app-region .wrap { padding-inline: 28px; }

@media (max-width: 1024px) {
  .rail { display: none; }
  .topbar { display: block; }
  .site-shell, .site-footer, .app-region { padding-left: 0; }
  .site-shell { padding-top: 56px; }
  .site-shell > *, .footer-inner, .app-region .wrap { padding-inline: 24px; }
  .app-region .top { align-items: flex-start; }
  .app-region .top-controls { width: 100%; }
  .hero { grid-template-columns: 1fr; padding-block: 48px; min-height: 0; gap: 0; }
  .hero-copy, .hero-figure { grid-column: 1; }
  .hero-figure { min-height: 440px; }
  .statement { padding-block: 64px; }
  .privacy { grid-template-columns: 1fr; }
  .privacy .section-head, .ledger { grid-column: 1; }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline li:nth-child(3) { padding-left: 0; border-left: 0; }
  .pipeline li:nth-child(n + 3) { padding-top: 32px; }
}
@media (max-width: 760px) {
  .columns, .step-list, .pipeline { grid-template-columns: 1fr; }
  .columns { padding-block: 48px; }
  .columns > div, .columns > div:first-child, .columns > div:last-child { padding: 32px 0; }
  .columns > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .step-list li, .pipeline li, .step-list li + li, .pipeline li + li, .pipeline li:nth-child(3) { padding: 24px 0; border-left: 0; }
  .step-list li + li, .pipeline li + li { border-top: 1px solid var(--line); }
  .steps, .privacy, .tech { padding-block: 72px; }
  .demo-intro { padding-block: 72px 32px; }
  .ledger div { flex-direction: column; gap: 2px; }
  .ledger dd { text-align: left; }
  .app-region .wrap { padding-inline: 16px; }
  .app-region .mode { display: none; }
  .app-region .select { flex: 1; }
  .app-region .select select { min-width: 0; width: 100%; }
  .footer-inner { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .footer-meta { text-align: center; }
  .site-footer { margin-top: 40px; padding-block: 48px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .motion-ready .reveal { opacity: 1; transform: none; }
}
