/* Rebuilding Echo: the workshop.
   Design system: ../../DESIGN.md. Echo is an instrument on a desk;
   you write its brain on the sheet beside it. */

:root {
  --desk: #E8E6E1;
  --desk-dot: rgba(29, 28, 26, .10);
  --sheet: #FCFBF8;
  --sheet-2: #F4F2ED;
  --ink: #1D1C1A;
  --ink-2: #5E5B55;
  --ink-3: #97938B;
  --rule: rgba(29, 28, 26, .10);
  --rule-2: rgba(29, 28, 26, .16);

  /* concept colours: one meaning each */
  --tok: #2F6BD8;
  --cnt: #23885A;
  --chn: #7B4FD3;
  --voice: #FF5A1F;
  --bad: #D23F2A;

  --screen: #131210;
  --keycap: #F2F0EB;

  --lift-1: 0 1px 1px rgba(60, 48, 30, .06), 0 2px 4px rgba(60, 48, 30, .06);
  --lift-2: 0 1px 2px rgba(60, 48, 30, .07), 0 4px 8px rgba(60, 48, 30, .07), 0 12px 24px rgba(60, 48, 30, .07);
  --lift-3: 0 2px 4px rgba(60, 48, 30, .08), 0 8px 16px rgba(60, 48, 30, .08), 0 24px 48px rgba(60, 48, 30, .10), 0 48px 80px rgba(60, 48, 30, .08);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.23, 1, .32, 1);

  --display: "Fraunces", Georgia, serif;
  --sans: "Satoshi", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --dots: "Doto", var(--mono);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15.5px/1.55 var(--sans);
  color: var(--ink);
  background: var(--desk);
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr) 28px;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .86em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--tok); outline-offset: 2px; border-radius: 4px; }

/* concept words, used in prose */
.c-tok { color: var(--tok); }
.c-cnt { color: var(--cnt); }
.c-chn { color: var(--chn); }
.c-voice { color: var(--voice); }
code.c-tok, code.c-cnt, code.c-chn, code.c-voice { background: currentColor; }
code.c-tok, code.c-cnt, code.c-chn, code.c-voice { background: none; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; gap: 28px; padding: 0 20px;
  background: rgba(232, 230, 225, .86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  position: relative; z-index: 20; grid-area: 1 / 1;
}
.wordmark { color: inherit; text-decoration: none; font-family: var(--display); font-size: 19px; font-weight: 420; letter-spacing: -.02em; font-variation-settings: "opsz" 144; }
.wordmark i { font-weight: 380; }
.crumb {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 8px; border-radius: 9px;
  color: var(--ink-2); font-size: 14px; white-space: nowrap; transition: background-color .16s var(--ease);
}
.crumb:hover { background: rgba(29, 28, 26, .05); }
.crumb svg { width: 14px; height: 14px; color: var(--ink-3); }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; margin-left: 8px; }
/* the machine: its little folder cover, then its name */
.cr-thumb { position: relative; flex: none; width: 17px; height: 21px; }
.cr-thumb .face { position: absolute; inset: 0; border-radius: 1.5px 3px 3px 1.5px; overflow: hidden; background: var(--fold); box-shadow: inset 0 0 0 1px rgba(29, 28, 26, .14), 0 1px 1px rgba(60, 48, 30, .14); transform-origin: left center; transition: transform .2s var(--ease); }
.cr-thumb .tab { position: absolute; right: -2px; top: 3px; width: 4px; height: 10px; border-radius: 0 2px 2px 0; background: var(--fold-2); }
.cr-thumb svg { width: 100%; height: 100%; display: block; }
.crumb-home:hover .cr-thumb .face { transform: perspective(120px) rotateY(-16deg); }
#crumb-machine { color: var(--ink-2); }
.crumb-sep { color: rgba(29, 28, 26, .2); font-size: 18px; font-weight: 300; margin: 0 2px; }
/* the unit: its number, its name, how far through it you are */
.crumb-unit-btn { padding: 0 8px 0 10px; }
.crumb-unit { font-size: 12.5px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
#crumb-unit-t { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.cr-prog { flex: none; width: 26px; height: 3px; border-radius: 2px; background: rgba(29, 28, 26, .12); overflow: hidden; margin-left: 2px; }
.cr-prog i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 2px; transition: width .4s var(--ease); }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.py { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.py i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.py.loading i { background: var(--voice); animation: blink 1.1s infinite; }
.py.ready i { background: var(--cnt); }
.py.bad { color: var(--bad); }
.py.bad i { background: var(--bad); }
@keyframes blink { 50% { opacity: .25; } }
.btn-quiet {
  height: 34px; padding: 0 12px; border-radius: 9px; font-size: 14px; font-weight: 500;
  background: var(--sheet); box-shadow: var(--lift-1), inset 0 0 0 1px var(--rule);
  transition: transform .14s var(--ease);
}
.btn-quiet:active { transform: translateY(1px); }
.btn-quiet b { font-variant-numeric: tabular-nums; color: var(--voice); margin-left: 4px; font-weight: 700; }
.btn-text { white-space: nowrap; font-size: 13px; color: var(--ink-2); padding: 6px 8px; border-radius: 6px; }
.btn-text:hover { color: var(--ink); background: rgba(29, 28, 26, .05); }

/* layout toggles in the bar */
.layout { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(29, 28, 26, .04); box-shadow: inset 0 0 0 1px var(--rule); }
.lay-btn { position: relative; width: 32px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: var(--ink-3); transition: background-color .16s var(--ease), color .16s var(--ease); }
.lay-btn svg { width: 18px; height: 15px; }
.lay-btn .fill { fill: currentColor; opacity: 0; transition: opacity .16s var(--ease); }
.lay-btn:hover { color: var(--ink); }
.lay-btn[aria-pressed="true"] { color: var(--ink); background: var(--sheet); box-shadow: var(--lift-1); }
.lay-btn[aria-pressed="true"] .fill { opacity: .22; }
.lay-btn .unread { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--voice); box-shadow: 0 0 0 2px var(--desk); }

/* status bar */
.status {
  grid-area: 3 / 1; display: flex; align-items: center; gap: 18px; padding: 0 16px;
  border-top: 1px solid var(--rule); background: rgba(232, 230, 225, .9);
  font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; z-index: 20;
}
.status .py { font-size: 12px; }
.st-gap { flex: 1; }
.st-item { font-variant-numeric: tabular-nums; }
#saved.saving { color: var(--ink-2); }

/* ---------- studio layout ---------- */
/* Like an editor: job | code | Echo + printout. The gaps are drag handles;
   the side panels can be hidden (⌘B, ⌘J) and their widths are remembered. */
.studio {
  grid-area: 2 / 1; display: grid; min-height: 0; padding: 12px 12px 10px;
  /* JS sets the open widths; collapsing overrides --brief-w without losing them */
  --brief-w: var(--brief-open, 360px); --desk-w: var(--desk-open, 460px);
  grid-template-columns: var(--brief-w) 12px minmax(380px, 1fr) 12px var(--desk-w);
}
.studio.no-brief { --brief-w: 44px; }
.studio.no-desk { grid-template-columns: var(--brief-w) 12px minmax(380px, 1fr) 0 0; }
.studio.no-desk .desk, .studio.no-desk .split[data-split="desk"] { display: none; }
.studio.tracing { --brief-w: 44px; grid-template-columns: var(--brief-w) 12px minmax(380px, 1fr) 12px minmax(560px, 1.25fr); }

.split { position: relative; cursor: col-resize; touch-action: none; }
.split::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 4px; height: 36px; margin: -18px 0 0 -2px; border-radius: 2px;
  background: var(--rule-2); opacity: 0; transition: opacity .16s var(--ease), height .16s var(--ease), background-color .16s var(--ease);
}
.split:hover::after, .split:focus-visible::after { opacity: 1; }
.split.dragging::after { opacity: 1; height: 64px; margin-top: -32px; background: var(--ink-3); }
.split:focus-visible { outline: none; }
.studio.no-brief .split[data-split="brief"], .studio.tracing .split { pointer-events: none; }
.studio.no-brief .split[data-split="brief"]::after, .studio.tracing .split::after { display: none; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }

.brief-col { position: relative; min-width: 0; min-height: 0; display: flex; }
.rail {
  display: none; width: 100%; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0;
  border-radius: 12px; color: var(--ink-2); transition: background-color .16s var(--ease), color .16s var(--ease);
}
.rail:hover { background: rgba(29, 28, 26, .05); color: var(--ink); }
.rail svg { width: 16px; height: 16px; flex: none; }
.rail span { writing-mode: vertical-rl; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 70vh; }
.rail span b { font-weight: 500; color: var(--ink-3); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.studio.no-brief .brief, .studio.tracing .brief { display: none; }
.studio.no-brief .rail, .studio.tracing .rail { display: flex; }

/* the sheet */
.sheet {
  background: var(--sheet); border-radius: 14px;
  box-shadow: var(--lift-2), 0 0 0 1px var(--rule);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.brief { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 14px 10px 24px 8px; scrollbar-width: none; min-height: 0; }
.brief > *, .mira-col { min-width: 0; }
.brief::-webkit-scrollbar { display: none; }

/* ---------- brief ---------- */
/* where you are: one tick per step, like marks on a ruler */
.bf-steps { display: grid; grid-template-columns: 24px 1fr auto 24px; align-items: center; gap: 8px; margin: 0 0 2px; }
.bf-steps .ticks { display: flex; gap: 3px; align-items: center; height: 24px; }
.tick { flex: 1; height: 4px; border-radius: 2px; background: rgba(29, 28, 26, .10); transition: background-color .16s var(--ease), height .16s var(--ease); position: relative; }
.tick::before { content: ""; position: absolute; inset: -10px 0; }
.tick.done { background: var(--ink-3); }
.tick.open:hover, .tick.done:hover { background: var(--ink-2); }
.tick.cur { height: 8px; background: var(--ink); }
.tick.locked { background: rgba(29, 28, 26, .06); cursor: default; }
.bf-count { font: 12px var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.bf-count b { color: var(--ink); font-weight: 500; }
.ic { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; color: var(--ink-2); transition: background-color .16s var(--ease), color .16s var(--ease); }
.ic svg { width: 14px; height: 14px; }
.ic:hover:not(:disabled) { background: rgba(29, 28, 26, .06); color: var(--ink); }
.ic:disabled { opacity: .3; cursor: default; }
/* the step's name: which part of Echo this is, then the title */
.bf-head { margin: 18px 0 16px; }
.bf-part { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.bf-part span { font: 800 13px var(--dots); letter-spacing: .04em; color: var(--voice); }
.brief h1 {
  font-family: var(--display); font-weight: 400; font-variation-settings: "opsz" 144;
  font-size: 34px; line-height: 1.08; letter-spacing: -.012em; word-spacing: .04em; margin: 0; text-wrap: balance; color: var(--ink);
}
.brief h1 i { font-weight: 350; letter-spacing: -.005em; padding-right: .04em; }
/* the job: the one thing to do, and how it's going */
.bf-job { margin: 4px 0 0; padding: 16px 18px; border-radius: 14px; background: var(--sheet); box-shadow: var(--lift-1), inset 0 0 0 1px var(--rule); }
.bf-job h3 { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.goal { font-size: 16.5px; line-height: 1.5; max-width: 62ch; margin: 0; color: var(--ink); }
.goal code, .poke code, .hint code, .bf-story code { font-size: .88em; color: var(--ink); background: var(--sheet-2); padding: 1px 5px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--rule); }
.bf-status { display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.bf-status svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.bf-status.ok svg, .bf-status.wait svg { color: var(--cnt); }
.bf-status.no svg { color: var(--bad); }
.bf-status.no span { color: var(--ink); }
.bf-checks { margin-top: 6px; }
.bf-checks summary { cursor: pointer; font-size: 12.5px; color: var(--ink-3); list-style: none; }
.bf-checks summary::-webkit-details-marker { display: none; }
.bf-checks summary:hover { color: var(--ink); }
.bf-checks .checks { margin-top: 6px; }

/* watch, build, trace: one compact switch */
.bf-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 12px 0 0; padding: 3px; border-radius: 11px; background: rgba(29, 28, 26, .045); box-shadow: inset 0 0 0 1px var(--rule); }
.bf-mode { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; border-radius: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); transition: background-color .16s var(--ease), color .16s var(--ease); }
.bf-mode:hover:not(:disabled) { color: var(--ink); }
.bf-mode.on { color: var(--ink); background: var(--sheet); box-shadow: var(--lift-1), inset 0 0 0 1px var(--rule); }
.bf-mode:disabled { opacity: .4; cursor: not-allowed; }
.bf-mode svg { width: 13px; height: 13px; color: var(--cnt); }

/* the story behind the job: quiet, one line until opened */
.bf-story { margin-top: 16px; }
.bf-story summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }
.bf-story summary::-webkit-details-marker { display: none; }
.bf-story .mono-av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); font: 12px var(--display); color: var(--ink-2); }
.bf-story-line { font-size: 14px; line-height: 1.5; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bf-story[open] .bf-story-line { -webkit-line-clamp: unset; display: block; }
.bf-story-line b { color: var(--ink); font-weight: 500; }
.bf-story p { margin: 6px 0 0 34px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 6px 0; font-size: 14.5px; border-bottom: 1px solid var(--rule); }
.checks li:last-child { border-bottom: 0; }
.checks svg { width: 18px; height: 18px; margin-top: 2px; }
.checks li.ok svg { color: var(--cnt); }
.checks li.no svg { color: var(--bad); }
.checks li.no span { color: var(--ink); }
.checks-wait { margin: 0; color: var(--ink-3); font-size: 14.5px; }

/* help is Mira talking: her note, then each hint as her next line */
.mira { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; margin-top: 18px; }
.mira .mono-av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); font: 12px var(--display); color: var(--ink-2); }
.mira-col { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.mira .bf-story { margin: 0; width: 100%; }
.mira .bf-story summary { display: block; }
.mira .bf-story p { margin-left: 0; }
.m-note { width: 100%; font-size: 14.5px; line-height: 1.55; color: var(--ink); animation: rise .3s var(--ease-in); }
.m-note.old { color: var(--ink-3); cursor: pointer; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.m-note.old pre { display: none; }
.m-note.old:hover { color: var(--ink-2); }
.m-note.old.open { display: block; color: var(--ink-2); }
.m-note.old.open pre { display: block; }
.code-wrap { position: relative; }
.code-copy { position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px; color: rgba(236, 232, 223, .7); background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1); transition: color .16s var(--ease), background-color .16s var(--ease); }
.code-copy svg { width: 13px; height: 13px; }
.code-copy:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.code-copy.done { color: #9BE0BC; }
.m-note.old .code-wrap { display: none; }
.m-note.old.open .code-wrap { display: block; }
.m-tag { display: block; font-size: 12px; color: var(--voice); margin-bottom: 2px; }
.m-ask { justify-self: start; display: inline-flex; align-items: center; gap: 4px; padding: 0; font-size: 14px; font-weight: 500; color: var(--ink-2); border-bottom: 1px solid var(--rule-2); line-height: 1.6; transition: color .16s var(--ease), border-color .16s var(--ease); }
.m-ask svg { width: 13px; height: 13px; transition: transform .16s var(--ease); }
.m-ask:hover { color: var(--ink); border-color: var(--ink); }
.m-ask:hover svg { transform: translateX(2px); }
.hint pre, .card pre, .m-note pre { font: 12px/1.6 var(--mono); background: #1F1E1B; color: #ECE8DF; padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 10px 0 2px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.m-note code { font-size: .88em; color: var(--ink); background: var(--sheet-2); padding: 1px 5px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--rule); }
.m-note.old code { color: inherit; background: none; box-shadow: none; padding: 0; }

/* after it works: a short list of things to poke at, and the maths if there is any */
.tries { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); }
.tries h3 { margin: 0 0 6px; font-family: var(--display); font-size: 17px; font-weight: 400; color: var(--ink); }
.math { font-family: var(--display); font-size: 17px; color: var(--ink); line-height: 1.5; }

/* ---------- the maths: typeset on graph paper, symbols that explain themselves ---------- */
.mth { position: relative; margin-top: 22px; }
.mth-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.mth-h span { font-family: var(--display); font-size: 17px; font-weight: 400; color: var(--ink); }
.mth-paper {
  position: relative; display: grid; gap: 14px; padding: 18px 18px 18px; border-radius: 14px;
  background:
    linear-gradient(rgba(47, 107, 216, .06) 1px, transparent 1px) 0 0 / 100% 16px,
    linear-gradient(90deg, rgba(47, 107, 216, .06) 1px, transparent 1px) 0 0 / 16px 100%,
    #FFFEFB;
  box-shadow: inset 0 0 0 1px var(--rule), var(--lift-1);
}
.m-eqrow { display: grid; gap: 4px; min-width: 0; }
.m-label { font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-align: center; }
.m-cap { text-align: center; }
.m-eqrow + .m-p { padding-top: 12px; border-top: 1px dashed rgba(29, 28, 26, .12); }
.m-eq {
  font-family: var(--display); font-variation-settings: "opsz" 72; font-size: 23px; line-height: 1.5; color: var(--ink);
  overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; padding: 8px 0; text-align: center;
}
.m-eq::-webkit-scrollbar { display: none; }
.m-eq .mv { font-style: italic; font-weight: 400; padding: 0 1px; }
.m-eq .mw { font-weight: 400; }
.m-eq .mf { font-style: normal; font-weight: 400; color: var(--ink-2); }
.m-eq .mn { font-variant-numeric: lining-nums tabular-nums; }
.m-eq .mo { display: inline-block; margin: 0 .22em; color: var(--ink-2); font-weight: 300; }
.m-eq .mo.u { margin: 0 .02em 0 0; }
.m-eq .mtxt { font-family: var(--sans); font-size: .62em; color: var(--ink-3); margin: 0 .2em; vertical-align: .15em; }
.m-eq .mc { color: var(--ink-3); font-weight: 300; }
.m-eq sub, .m-eq sup { font-size: .62em; line-height: 0; }
.m-eq sub { vertical-align: -.32em; }
.m-eq sub .mv, .m-eq sup .mv { padding: 0; }
.m-eq sub .mo, .m-eq sup .mo { margin: 0 .08em; }
.m-eq .msym[data-k="Σ"] { font-size: 1.15em; }
.m-eq .mpunct { color: var(--ink-3); margin-right: .25em; }
.m-cap { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.m-def { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.m-def { text-align: left; }
.m-def .m-eq { display: inline; font-size: 19px; white-space: normal; overflow: visible; text-align: left; padding: 0; }
.m-p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); text-wrap: pretty; }
.m-p .mi, .m-def .mi, .m-cap .mi { font-family: var(--display); font-style: italic; font-size: 1.08em; color: var(--ink); }
/* symbols you can ask about, and variables that light up together */
.msym { cursor: help; border-bottom: 1.5px dotted rgba(255, 90, 31, .55); color: var(--ink); transition: color .15s var(--ease), background-color .15s var(--ease); border-radius: 2px; }
.m-p .msym { font-family: var(--display); font-size: 1.1em; padding: 0 1px; }
.mth [data-v] { border-radius: 4px; transition: background-color .15s var(--ease), color .15s var(--ease); }
.mth .lit { background: #FFE9DE; color: #C2410C; }
.mth .m-key.lit { box-shadow: inset 0 0 0 1px rgba(255, 90, 31, .5); background: #FFF4EE; }
.m-tip { position: absolute; z-index: 5; max-width: 220px; padding: 6px 10px; border-radius: 8px; background: #1F1E1B; color: #F3EFE7; font-size: 12.5px; line-height: 1.4; pointer-events: none; box-shadow: 0 6px 16px rgba(30, 20, 10, .2); animation: tipIn .14s var(--ease); }
.m-tip[hidden] { display: none; }
@keyframes tipIn { from { opacity: 0; transform: translateY(3px); } }
/* the key: every symbol on this card, like a legend on a map */
.mth-key { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.m-key { display: inline-flex; align-items: baseline; gap: 7px; padding: 4px 9px 4px 7px; border-radius: 8px; font-size: 12.5px; color: var(--ink-2); background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule); cursor: default; transition: box-shadow .15s var(--ease), background-color .15s var(--ease); }
.m-key b { font-family: var(--display); font-size: 16px; line-height: 1; font-weight: 500; color: var(--voice); min-width: 10px; text-align: center; }
/* the first time a step opens, each formula writes itself in, piece by piece */
.mth.write .m-eq .mp { display: inline-block; animation: mWrite .5s var(--ease-in) both; animation-delay: calc(var(--i) * 45ms + 150ms); }
@keyframes mWrite { from { opacity: 0; transform: translateY(5px); filter: blur(3px); } }
.mth.write .m-p, .mth.write .m-cap, .mth.write .mth-key { animation: rise .5s var(--ease-in) .5s both; }
@media (prefers-reduced-motion: reduce) { .mth.write .m-eq .mp, .mth.write .m-p, .mth.write .m-cap, .mth.write .mth-key { animation: none; } }

/* each thing to try: click the line to run its code */
.poke { margin: 0; padding: 0; list-style: none; display: grid; }
.poke li { position: relative; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); padding: 7px 0 7px 16px; }
.poke li::before { content: "–"; position: absolute; left: 0; top: 7px; color: var(--ink-3); }
.poke li.can-run { cursor: pointer; }
.poke li.can-run:hover { color: var(--ink); }
.poke li.can-run:hover::before { content: "▸"; color: var(--voice); }
.poke code.run-me { cursor: pointer; transition: box-shadow .16s var(--ease), background-color .16s var(--ease); }
.poke code.run-me:hover { background: var(--sheet); box-shadow: inset 0 0 0 1px var(--ink-3); }

.btn-line {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 9px;
  font-size: 14px; font-weight: 500; box-shadow: inset 0 0 0 1px var(--rule-2); background: var(--sheet);
  transition: background-color .16s var(--ease), transform .12s var(--ease);
}
.btn-line:hover { background: var(--sheet-2); }
.btn-line:active { transform: translateY(1px); }

/* ---------- code area ---------- */
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 0 16px; height: 52px; border-bottom: 1px solid var(--rule); }
.files { display: flex; gap: 2px; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.files::-webkit-scrollbar { display: none; }
.file { flex: none; }
.code-tools { flex: none; display: flex; align-items: center; gap: 4px; }
.sheet { container-type: inline-size; }
@container (max-width: 560px) {
  .code-tools kbd, #reset { display: none; }
  .file { padding: 0 9px; }
}
.file {
  position: relative; padding: 0 12px; font: 13px var(--mono); color: var(--ink-3); height: 100%;
  transition: color .16s var(--ease);
}
.file:hover { color: var(--ink); }
.file.on { color: var(--ink); }
.file.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.file .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--voice); margin-left: 6px; vertical-align: 2px; }
.code-tools { display: flex; align-items: center; gap: 8px; }

/* keys */
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 9px; font-size: 14px; font-weight: 500; position: relative; user-select: none;
  transition: transform .09s var(--ease), box-shadow .14s var(--ease), filter .16s var(--ease);
}
.key:active, .key.pressed { transform: translateY(2px); }
.key-dark {
  color: #F6F3EC; background: linear-gradient(#3A3936, #262523);
  box-shadow: inset 0 -3px 0 #171614, inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 2px rgba(0, 0, 0, .18), 0 4px 10px rgba(0, 0, 0, .12);
}
.key-dark:hover { filter: brightness(1.08); }
.key-dark:active { box-shadow: inset 0 -1px 0 #171614, inset 0 1px 0 rgba(255, 255, 255, .14), 0 1px 1px rgba(0, 0, 0, .2); }
.key-dark kbd { font: 11px var(--sans); color: rgba(246, 243, 236, .55); }
.key .led { width: 7px; height: 7px; border-radius: 50%; background: var(--voice); box-shadow: 0 0 6px rgba(255, 90, 31, .7); }
.key.busy .led { animation: blink .5s infinite; }
.key.busy { pointer-events: none; }
.key-light {
  background: linear-gradient(#F7F5F0, #E9E6DF); color: var(--ink);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .13), inset 0 1px 0 rgba(255, 255, 255, .9), 0 1px 2px rgba(60, 48, 30, .14);
}
.key-light:active, .key-light.on { box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .12), inset 0 1px 2px rgba(0, 0, 0, .08); transform: translateY(2px); background: linear-gradient(#ECE9E2, #E4E0D8); }
.key-signal {
  color: #fff; background: linear-gradient(#FF7444, #F24F14);
  box-shadow: inset 0 -3px 0 #B8380B, inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 6px rgba(242, 79, 20, .3);
}
.key-signal:active { box-shadow: inset 0 -1px 0 #B8380B, 0 1px 2px rgba(242, 79, 20, .3); }

.editor { flex: 1 1 auto; min-height: 0; position: relative; }
.editor .CodeMirror { position: absolute; inset: 0; height: 100%; }
.CodeMirror { font: 13.5px/1.7 var(--mono); background: var(--sheet); color: #2A2925; }
.CodeMirror-gutters { background: var(--sheet); border-right: 0; }
.CodeMirror-linenumber { color: #C3BFB6; padding: 0 14px 0 6px; font-variant-numeric: tabular-nums; }
.CodeMirror-lines { padding: 16px 0 40px; }
.CodeMirror-cursor { border-left: 2px solid var(--ink); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: rgba(47, 107, 216, .14) !important; }
.CodeMirror-matchingbracket { color: var(--voice) !important; font-weight: 700; }
.cm-s-default .cm-keyword { color: #8A3FB8; }
.cm-s-default .cm-def { color: #1D1C1A; font-weight: 700; }
.cm-s-default .cm-variable { color: #2A2925; }
.cm-s-default .cm-variable-2 { color: #3E5C8A; }
.cm-s-default .cm-builtin { color: #1F6F8B; }
.cm-s-default .cm-string { color: #2E7D4F; }
.cm-s-default .cm-number { color: #B6531C; }
.cm-s-default .cm-comment { color: #A39E94; font-style: italic; }
.cm-s-default .cm-operator { color: #6E6A62; }
.cm-s-default .cm-property { color: #4B4840; }
.cm-errline { background: rgba(210, 63, 42, .09); box-shadow: inset 3px 0 0 var(--bad); }
.cm-traceline { background: rgba(47, 107, 216, .10); box-shadow: inset 3px 0 0 var(--tok); }

/* ---------- desk: Echo on top, the printout under it ---------- */
.desk { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }

/* the instrument */
.instrument {
  flex: 0 0 auto; padding: 14px 16px 16px; border-radius: 18px;
  background: linear-gradient(170deg, #E4E1DA 0%, #D6D2CA 55%, #CBC7BE 100%);
  box-shadow: var(--lift-2), inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -2px 0 rgba(0, 0, 0, .08), 0 0 0 1px rgba(60, 48, 30, .12);
}
.instrument.min { padding-bottom: 14px; }
.instrument.min .inst-body { display: none; }
.instrument.min .inst-top { margin-bottom: 0; }
.inst-mini { display: none; margin-left: auto; font: 12px var(--mono); color: #6B665D; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.instrument.min .inst-mini { display: block; }
.instrument.min .inst-model { display: none; }
.instrument.min .lamp { margin-left: 0; }
.inst-fold {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #6B665D;
  transition: background-color .16s var(--ease), color .16s var(--ease);
}
.inst-fold:hover { background: rgba(255, 255, 255, .45); color: var(--ink); }
.inst-fold svg { width: 16px; height: 16px; transition: transform .2s var(--ease); }
.instrument.min .inst-fold svg { transform: rotate(180deg); }
.inst-top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.grill {
  width: 64px; height: 34px; border-radius: 6px;
  background-image: radial-gradient(circle, rgba(40, 34, 26, .55) 1.6px, transparent 2px);
  background-size: 7px 7px; opacity: .65;
}
.inst-id { line-height: 1.1; }
.inst-name { font: 700 13px var(--sans); letter-spacing: .32em; color: #4A463F; }
.inst-model { font-size: 11.5px; color: #7A756C; margin-top: 3px; }
.lamp {
  margin-left: auto; width: 34px; height: 34px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 50% 40%, #CFCAC1, #B5B0A6); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25), 0 1px 0 rgba(255, 255, 255, .6);
}
.lamp i { position: absolute; inset: 8px; border-radius: 50%; background: #6E665A; transition: background-color .9s var(--ease), box-shadow .9s var(--ease); }
.lamp.s1 i { background: #8E5A33; }
.lamp.s2 i { background: #D0652C; box-shadow: 0 0 10px rgba(255, 90, 31, .45); }
.lamp.s3 i { background: #FF6A2B; box-shadow: 0 0 14px rgba(255, 90, 31, .85), 0 0 34px rgba(255, 90, 31, .35); }
.lamp.talk i { animation: lampTalk .6s ease-in-out infinite; }
@keyframes lampTalk { 50% { box-shadow: 0 0 22px rgba(255, 90, 31, 1), 0 0 48px rgba(255, 90, 31, .5); } }

.screen {
  background: var(--screen); border-radius: 10px; padding: 10px 14px 12px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .7), inset 0 0 0 1px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 255, 255, .55);
  position: relative; overflow: hidden;
}
.screen::after { /* faint scanlines */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(transparent 0 2px, rgba(255, 255, 255, .025) 2px 3px);
}
.screen-top { display: flex; justify-content: space-between; font: 11.5px var(--mono); color: rgba(255, 140, 90, .55); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.screen-body { height: 150px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: transparent transparent; font-family: var(--dots); font-weight: 800; color: var(--voice); text-shadow: 0 0 6px rgba(255, 90, 31, .45); }
/* a thin, dim scrollbar shows up when the pointer is over the screen, so it's clear you can scroll back */
.screen-body:hover { scrollbar-color: rgba(255, 120, 70, .35) transparent; }
.screen-body::-webkit-scrollbar { width: 6px; }
.screen-body::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.screen-body:hover::-webkit-scrollbar-thumb { background: rgba(255, 120, 70, .35); }
.sc-newest { position: absolute; z-index: 2; right: 12px; bottom: 10px; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 12px; font: 600 11px var(--mono); letter-spacing: .04em; color: #1A1917; background: #FF8A5B; box-shadow: 0 0 12px rgba(255, 90, 31, .45); animation: rise .2s var(--ease-in); }
.sc-newest[hidden] { display: none; }
.sc-newest:hover { background: #FFA27E; }
/* older lines fade out at the top edge, so a half-cut line reads as history, not a glitch */
.screen-body.scrolled { -webkit-mask: linear-gradient(180deg, transparent 0, #000 22px); mask: linear-gradient(180deg, transparent 0, #000 22px); }
.sc-line { font-size: 19px; line-height: 1.25; margin-bottom: 8px; letter-spacing: .02em; word-break: break-word; }
.sc-line.you { color: rgba(255, 190, 160, .55); text-shadow: none; font-size: 15px; }
.sc-line.note { color: rgba(255, 190, 160, .5); text-shadow: none; font: 13px/1.45 var(--mono); }
.sc-line.err { color: #FF5A4A; }
.sc-off { height: 100%; display: grid; place-items: center; color: rgba(255, 140, 90, .28); text-shadow: none; font-size: 22px; letter-spacing: .1em; }

/* table mode on the screen */
.sc-table-head { font: 12.5px var(--mono); color: rgba(255, 190, 160, .65); text-shadow: none; margin-bottom: 8px; }
.sc-table-head b { font-family: var(--dots); font-size: 17px; color: var(--voice); text-shadow: 0 0 6px rgba(255, 90, 31, .45); font-weight: 800; }
.sc-bar { display: grid; grid-template-columns: 96px 1fr 70px; align-items: center; gap: 10px; width: 100%; padding: 2px 0; text-align: left; }
.sc-bar .w { font: 13px var(--mono); color: #FFB494; text-shadow: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-bar .t { height: 9px; background-image: radial-gradient(circle, rgba(255, 90, 31, .16) 1.5px, transparent 1.8px); background-size: 5px 5px; position: relative; }
.sc-bar .t i { position: absolute; inset: 0 auto 0 0; background-image: radial-gradient(circle, var(--voice) 1.7px, transparent 2px); background-size: 5px 5px; filter: drop-shadow(0 0 3px rgba(255, 90, 31, .6)); }
.sc-bar .n { font: 12px var(--mono); color: rgba(255, 190, 160, .6); text-shadow: none; text-align: right; font-variant-numeric: tabular-nums; }
.sc-bar:hover .w { color: #fff; }
.sc-trail { font-size: 17px; margin-top: 10px; }

.controls { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 12px; }
.modes { display: flex; gap: 8px; }
.modes .key { height: 32px; font-size: 13px; padding: 0 14px; }

.switch { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #615C53; }
.switch-track { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 76px; height: 30px; border-radius: 8px; background: #BDB8AF; box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25), 0 1px 0 rgba(255, 255, 255, .6); padding: 3px; }
.switch-track button { position: relative; z-index: 2; font-size: 12.5px; font-weight: 700; color: #6E685E; font-variant-numeric: tabular-nums; }
.switch-track button.on { color: var(--ink); }
.switch-track button:disabled { opacity: .4; cursor: not-allowed; }
.switch-thumb { position: absolute; z-index: 1; top: 3px; left: 3px; width: 35px; height: 24px; border-radius: 6px; background: linear-gradient(#F7F5F0, #E5E1D9); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.switch[data-v="2"] .switch-thumb { transform: translateX(35px); }

.slot { display: flex; gap: 8px; }
.slot input {
  flex: 1; height: 40px; border: 0; border-radius: 9px; padding: 0 14px; background: #F6F4EF; outline: none;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .12), 0 1px 0 rgba(255, 255, 255, .6); font-size: 15px;
}
.slot input:focus { box-shadow: inset 0 2px 3px rgba(0, 0, 0, .12), 0 0 0 2px var(--voice); }
.slot .key { height: 40px; min-width: 72px; }

/* the printout: comes out under Echo */
.tape {
  flex: 1 1 auto; min-height: 140px; display: flex; flex-direction: column; overflow: hidden;
  background: #F7F5F0; border-radius: 14px; box-shadow: var(--lift-2), 0 0 0 1px var(--rule);
}
.tape-head { display: flex; justify-content: space-between; align-items: center; height: 38px; padding: 0 8px 0 16px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
.tape-body { padding-top: 8px !important; }
.tape-body { flex: 1; overflow-y: auto; padding: 2px 16px 10px; font: 12.5px/1.65 var(--mono); color: #34322D; scrollbar-width: thin; }
.tp { white-space: pre-wrap; word-break: break-word; }
.tp.sys { color: var(--ink-3); }
.tp.sys::before { content: "— "; }
.tp.err { color: var(--bad); }
.tp.warn { color: #A0520F; }
.tp.res { color: var(--tok); }
.tp.in { color: var(--ink-3); }
.tp.in::before { content: ">>> "; }
.tp-err { margin: 6px 0; padding: 10px 12px; border-radius: 8px; background: #FBEDEA; box-shadow: inset 0 0 0 1px rgba(210, 63, 42, .2); font-family: var(--sans); }
.tp-err b { display: block; font: 600 12.5px var(--mono); color: var(--bad); }
.tp-err p { margin: 2px 0 0; font-size: 14px; color: var(--ink); }
.tp-err small { display: block; margin-top: 4px; font: 12px var(--mono); color: var(--ink-3); }
.repl { display: flex; align-items: center; gap: 8px; padding: 8px 16px 10px; border-top: 1px dashed var(--rule-2); }
.prompt { font: 12.5px var(--mono); color: var(--ink-3); }
.repl input { flex: 1; border: 0; background: transparent; outline: none; font: 12.5px var(--mono); }

/* ---------- trace stage ---------- */
.stage {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
  background: var(--sheet); border-radius: 14px; box-shadow: var(--lift-3), 0 0 0 1px var(--rule);
  animation: rise .36s var(--ease-in); overflow: hidden;
}
.st-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px 12px; border-bottom: 1px solid var(--rule); }
.st-title { font-family: var(--display); font-size: 22px; font-weight: 400; letter-spacing: -.015em; font-variation-settings: "opsz" 144; }
.st-title i { font-weight: 340; }
.st-call { font-size: 13.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; max-width: 70ch; }
.st-call code { color: var(--ink-2); }
.st-close { margin-left: auto; white-space: nowrap; flex: 0 0 auto; }
.st-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.st-body > * { flex-shrink: 0; }
.st-say {
  margin-bottom: 4px;
  font-size: 18px; line-height: 1.45; min-height: 52px; max-width: 60ch;
}
.st-say .step-no { display: block; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.st-say b { font-weight: 500; }
.st-say .next { display: block; margin-top: 6px; font-size: 15px; color: var(--ink-2); }
.st-say .next em { font-style: normal; color: var(--ink-3); }

.tiles { display: flex; flex-wrap: wrap; gap: 6px 6px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; min-width: 46px; padding: 7px 10px 5px; border-radius: 8px;
  background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); font: 14px var(--mono);
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.tile small { font: 10.5px var(--sans); color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile.at { background: #E7EEFB; box-shadow: inset 0 0 0 2px var(--tok); transform: translateY(-3px); }
.tile.next { box-shadow: inset 0 0 0 2px rgba(47, 107, 216, .45); }
.tile.next2 { box-shadow: inset 0 0 0 2px rgba(47, 107, 216, .28); }
.tile.hit { background: #E3F2EA; box-shadow: inset 0 0 0 2px var(--cnt); }
.tile.pickable { cursor: pointer; }
.tile.pickable:hover { box-shadow: inset 0 0 0 2px var(--ink); }
.tile.ch { min-width: 24px; padding: 6px 6px 4px; }
.tile.ch.space { color: var(--ink-3); }

.st-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr); gap: 18px; align-items: start; }
.panel { border-radius: 12px; box-shadow: inset 0 0 0 1px var(--rule); padding: 12px 14px; background: #FFFEFB; }
.panel h4 { margin: 0 0 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

.vars { display: grid; gap: 4px; font: 12.5px var(--mono); }
.var { display: grid; grid-template-columns: 80px 1fr; gap: 8px; padding: 3px 6px; border-radius: 6px; transition: background-color .3s var(--ease); }
.var .k { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.var .v { color: var(--ink); word-break: break-word; }
.var.changed { background: #FFF3D6; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font: 13px var(--mono); padding: 3px 9px; border-radius: 999px; background: #E7EEFB; color: var(--tok); }
.chip.new { animation: pop .4s var(--ease-in); box-shadow: 0 0 0 2px var(--tok); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.empty { color: var(--ink-3); font-size: 13.5px; }

.ttable { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); }
.ttable td { padding: 4px 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ttable td:first-child { color: var(--ink); white-space: nowrap; width: 1%; padding-right: 12px; }
.cell { display: inline-block; margin: 1px 4px 1px 0; padding: 1px 7px; border-radius: 999px; background: #E3F2EA; color: var(--cnt); }
.cell b { font-weight: 700; margin-left: 4px; font-variant-numeric: tabular-nums; }
.cell.bump { animation: bump .5s var(--ease-in); box-shadow: 0 0 0 2px var(--cnt); }
@keyframes bump { 30% { transform: scale(1.12); } }
tr.row-at td:first-child { color: var(--cnt); font-weight: 700; }

.dice { display: grid; gap: 10px; padding-top: 22px; }
.dice-bar { position: relative; display: flex; height: 44px; border-radius: 8px; overflow: visible; box-shadow: inset 0 0 0 1px var(--rule); }
.dice-seg { position: relative; display: grid; place-items: center; font: 12px var(--mono); color: #fff; background: var(--chn); border-right: 2px solid #FFFEFB; overflow: hidden; white-space: nowrap; transition: filter .2s var(--ease); }
.dice-seg:nth-child(2n) { background: #9472DF; }
.dice-seg:nth-child(3n) { background: #6A3FC2; }
.dice-seg:first-child { border-radius: 8px 0 0 8px; }
.dice-seg:last-of-type { border-radius: 0 8px 8px 0; border-right: 0; }
.dice-seg.won { filter: brightness(1.15); box-shadow: inset 0 0 0 3px var(--voice); }
.dice-seg.pickable { cursor: pointer; }
.dice-seg.pickable:hover { filter: brightness(1.12); }
.dice-mark { position: absolute; top: -10px; bottom: -10px; width: 2px; background: var(--voice); border-radius: 2px; transition: left .6s var(--ease-in); }
.dice-mark::before { content: attr(data-roll); position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font: 11px var(--mono); color: var(--voice); white-space: nowrap; }
.dice-cap { font-size: 13.5px; color: var(--ink-2); }
.sentence { font: 15px var(--mono); }
.sentence .w-new { color: var(--voice); }

.algo { list-style: none; margin: 0; padding: 0; counter-reset: a; display: grid; gap: 2px; }
.algo li { counter-increment: a; display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 5px 8px; border-radius: 7px; font-size: 13.5px; color: var(--ink-3); transition: background-color .2s var(--ease), color .2s var(--ease); }
.algo li::before { content: counter(a); font-variant-numeric: tabular-nums; font-weight: 700; }
.algo li.on { background: #E7EEFB; color: var(--ink); }

.ask { border-radius: 12px; padding: 12px 14px; background: #FFF6E5; box-shadow: inset 0 0 0 1px rgba(160, 82, 15, .25); font-size: 15px; animation: rise .3s var(--ease-in); }
.ask b { font-weight: 700; }
.ask.right { background: #E3F2EA; box-shadow: inset 0 0 0 1px rgba(35, 136, 90, .3); }
.ask.wrong { background: #FBEDEA; box-shadow: inset 0 0 0 1px rgba(210, 63, 42, .25); }

.st-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--rule); background: var(--sheet); }
.st-foot .key { height: 34px; padding: 0 12px; }
.st-foot input[type=range] { flex: 1; accent-color: var(--ink); }
.st-count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 74px; text-align: right; }
.speed { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); }
.speed button { font-size: 12px; padding: 4px 8px; border-radius: 6px; color: var(--ink-3); }
.speed button.on { background: var(--sheet); color: var(--ink); box-shadow: var(--lift-1); }
.st-err { color: var(--bad); font-size: 14px; }

/* ---------- popover: jobs ---------- */
.pop {
  position: fixed; top: 52px; left: 12px; width: min(520px, 92vw); z-index: 30;
  background: var(--sheet); border-radius: 14px; box-shadow: var(--lift-3), 0 0 0 1px var(--rule); padding: 18px 8px 10px;
  animation: popIn .22s var(--ease-in); transform-origin: top left;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.pop h2 { font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: -.02em; margin: 0 14px 4px; font-variation-settings: "opsz" 144; }
.pop h2 i { font-weight: 340; }
.pop p.sub { margin: 0 14px 12px; font-size: 13.5px; color: var(--ink-3); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li { display: grid; grid-template-columns: 34px 1fr auto 22px; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--rule); font-size: 15px; border-radius: 8px; }
.toc li.open, .toc li.done { cursor: pointer; }
.toc li.open:hover, .toc li.done:hover { background: var(--sheet-2); }
.toc li.cur { background: var(--sheet-2); }
.toc .n { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 13px; }
.toc .m { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.toc .s svg { width: 16px; height: 16px; color: var(--cnt); }
.toc li.locked { color: var(--ink-3); }
.toc li.unit { margin-top: 6px; }
.toc li.unit .pro { font-size: 11.5px; font-weight: 700; color: var(--ink-2); padding: 2px 8px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--rule-2); }

/* ---------- reveal: the part card ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: rgba(232, 230, 225, .72); backdrop-filter: blur(6px); animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.card {
  width: min(600px, 100%); max-height: 88vh; overflow-y: auto; background: var(--sheet); border-radius: 16px;
  box-shadow: var(--lift-3), 0 0 0 1px var(--rule); animation: cardIn .42s var(--ease-in);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.985); } }
.plate {
  margin: 14px 14px 0; border-radius: 10px; padding: 16px 18px; display: flex; align-items: center; gap: 16px;
  background: linear-gradient(170deg, #E4E1DA, #CFCBC2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -2px 0 rgba(0, 0, 0, .08);
}
.plate-n { font-family: var(--dots); font-weight: 800; font-size: 34px; color: var(--voice); background: var(--screen); border-radius: 8px; padding: 4px 12px; text-shadow: 0 0 8px rgba(255, 90, 31, .5); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .6); }
.plate-t { line-height: 1.2; }
.plate-t small { display: block; font-size: 12px; color: #6E685E; }
.plate-t b { font: 700 15px var(--sans); letter-spacing: .02em; color: #3C3832; }
.card-body { padding: 20px 26px 24px; }
.card h2 { font-family: var(--display); font-weight: 380; font-size: 32px; letter-spacing: -.025em; line-height: 1.05; margin: 0 0 12px; font-variation-settings: "opsz" 144; }
.card h2 i { font-weight: 340; }
.found { font-size: 16.5px; line-height: 1.6; margin: 0 0 16px; }
.real { font-size: 14.5px; color: var(--ink-2); padding: 12px 14px; border-radius: 10px; background: var(--sheet-2); margin: 0 0 16px; }
.real b { color: var(--ink); font-weight: 700; display: block; font-size: 13px; margin-bottom: 2px; }
.tags { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.tag { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.tag-term { font-family: var(--display); font-size: 18px; font-weight: 420; letter-spacing: -.01em; }
.tag p { margin: 0; font-size: 14.5px; color: var(--ink-2); }
.card .actions { display: flex; gap: 10px; margin-top: 20px; }
.card .actions .key { height: 40px; padding: 0 16px; }

/* ---------- reveal: Echo prints a slip for the new part ---------- */
.rv2 { width: min(860px, 100%); display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 56px; align-items: start; padding: 8px; }
/* the printer: a small dark machine, the paper feeds down out of its slot */
.printer { position: relative; width: 300px; }
.pr-body {
  position: relative; z-index: 2; height: 58px; border-radius: 14px 14px 10px 10px; display: flex; align-items: center; gap: 10px; padding: 0 18px;
  background: linear-gradient(180deg, #2B2925, #1D1C19); box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 -2px 0 rgba(0, 0, 0, .4) inset, 0 10px 24px rgba(40, 30, 20, .22), 0 2px 4px rgba(40, 30, 20, .2);
  animation: cardIn .4s var(--ease-in);
}
.pr-led { width: 7px; height: 7px; border-radius: 50%; background: var(--voice); box-shadow: 0 0 8px var(--voice); animation: blink .5s steps(2) 0s 5, ledHold 0s 2.6s forwards; }
@keyframes blink { 50% { opacity: .25; } }
@keyframes ledHold { to { background: #6FBF8E; box-shadow: 0 0 8px rgba(111, 191, 142, .8); } }
.pr-name { font: 600 11px var(--mono); letter-spacing: .22em; color: rgba(236, 232, 223, .55); }
.pr-slot { position: absolute; left: 14px; right: 14px; bottom: 8px; height: 5px; border-radius: 3px; background: #0D0C0B; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .06); }
.pr-feed { position: relative; z-index: 1; margin: -12px 22px 0; overflow: hidden; padding: 0 6px 18px; }
.slip {
  position: relative; padding: 26px 18px 30px; background: #FFFEFA; color: #2A2723;
  font: 12px/1.55 var(--mono); letter-spacing: .02em;
  box-shadow: 0 1px 2px rgba(40, 30, 20, .10), 0 8px 18px rgba(40, 30, 20, .10);
  /* torn bottom edge */
  -webkit-mask: linear-gradient(#000, #000) top / 100% calc(100% - 7px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 7px repeat-x;
  mask: linear-gradient(#000, #000) top / 100% calc(100% - 7px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 10px 7px repeat-x;
  background-image: linear-gradient(180deg, rgba(0, 0, 0, .05), transparent 18px);
  animation: printOut 2.2s steps(22, end) .45s both;
}
@keyframes printOut { from { transform: translateY(-101%); } }
.sl-top { text-align: center; font-size: 10.5px; letter-spacing: .14em; color: #6E685E; }
.sl-rule { height: 0; margin: 12px 0; border-top: 1.5px dashed rgba(42, 39, 35, .35); }
.sl-k { font-size: 10.5px; letter-spacing: .16em; color: #6E685E; }
.sl-part { margin-top: 2px; font: 800 26px/1.1 var(--dots); letter-spacing: .02em; color: #1D1C1A; word-break: break-word; }
.sl-row { display: flex; align-items: baseline; gap: 6px; text-transform: uppercase; }
.sl-row i { flex: 1; border-bottom: 1.5px dotted rgba(42, 39, 35, .4); transform: translateY(-3px); }
.sl-foot { display: flex; justify-content: space-between; font-size: 11px; color: #6E685E; }
.sl-thanks { margin-top: 14px; text-align: center; font-size: 11px; letter-spacing: .18em; }

/* the words beside it: one sentence, a note, the way on */
.rv2-text { padding-top: 34px; max-width: 460px; animation: rise .5s var(--ease-in) .9s both; }
.rv2-k { margin: 0; font-size: 13px; color: var(--ink-3); }
.rv2 h2 { margin: 12px 0 0; font-family: var(--display); font-weight: 380; font-size: 36px; line-height: 1.08; letter-spacing: -.025em; font-variation-settings: "opsz" 144; color: var(--ink); text-wrap: balance; }
.rv2-rest { margin: 16px 0 0; font-size: 17px; line-height: 1.55; color: var(--ink); text-wrap: pretty; }
.rv2-real { margin: 14px 0 0; font-size: 15px; line-height: 1.6; color: var(--ink-2); text-wrap: pretty; }
.rv2-real em { font-family: var(--display); font-style: italic; font-size: 16px; color: var(--ink); }
/* the one button: it fills up like a fuse, then goes by itself */
.rv2-go {
  position: relative; overflow: hidden; margin-top: 30px; display: inline-flex; align-items: baseline; gap: 10px; height: 50px; padding: 0 18px 0 22px; border-radius: 13px;
  background: #1F1E1B; color: #F6F3EC; font-size: 16px; font-weight: 500; isolation: isolate;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .35), 0 2px 4px rgba(40, 30, 20, .18), 0 8px 18px rgba(40, 30, 20, .14);
  transition: transform .12s var(--ease);
}
.rv2-go:active { transform: translateY(1px); }
.rv2-go > * { position: relative; z-index: 1; align-self: center; }
.rv2-fill { position: absolute !important; inset: 0; z-index: 0 !important; background: #3A3833; transform: scaleX(0); transform-origin: left; }
.rv2-go-s { font-size: 14px; color: rgba(246, 243, 236, .55); }
.rv2-go svg { width: 16px; height: 16px; margin-left: 6px; }
.rv2-go:hover svg { transform: translateX(2px); transition: transform .16s var(--ease); }
.rv2-go:focus { outline: none; }
.rv2-go:focus-visible { outline: 2px solid rgba(29, 28, 26, .28); outline-offset: 3px; }
.rv2-nb { font: inherit; font-weight: 500; color: var(--ink-2); padding: 0; border-bottom: 1px solid var(--rule-2); transition: color .16s var(--ease), border-color .16s var(--ease); }
.rv2-nb:hover { color: var(--ink); border-color: var(--ink); }
.rv2-small { margin: 18px 0 0; font-size: 13.5px; color: var(--ink-3); }
.rv2-small .rv2-nb { color: var(--ink-2); font-weight: 400; }
#reveal:has(.rv2) { background: rgba(236, 233, 227, .86); backdrop-filter: blur(12px); }
@media (max-width: 820px) {
  .rv2 { grid-template-columns: 1fr; gap: 8px; justify-items: center; max-height: calc(100vh - 32px); overflow-y: auto; }
  .printer { width: 260px; }
  .rv2-text { padding-top: 0; }
  .rv2 h2 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { .slip, .pr-led, .rv2-text, .pr-body { animation: none; } }

/* notebook: a page in a side peek, like a doc */
.drawer-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(232, 230, 225, .5); backdrop-filter: blur(3px); animation: fade .2s var(--ease); }
@keyframes drawerIn { from { transform: translateX(28px); opacity: 0; } }
.nb { position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(680px, calc(100vw - 20px)); display: flex; flex-direction: column; background: #FFFFFE; border-radius: 14px; box-shadow: var(--lift-3), 0 0 0 1px var(--rule); overflow: hidden; animation: drawerIn .32s cubic-bezier(.32, .72, 0, 1); }
.nb-top { flex: none; display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 10px 0 16px; font-size: 13px; color: var(--ink-3); }
.nb-path { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.nb-path i { font-style: normal; color: rgba(29, 28, 26, .22); }
.nb-path b { font-weight: 500; color: var(--ink-2); }
.nb-x { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: var(--ink-3); }
.nb-x:hover { background: rgba(29, 28, 26, .06); color: var(--ink); }
.nb-x svg { width: 15px; height: 15px; }
.nb-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.nb-cover { height: 120px; background: radial-gradient(circle at 1px 1px, rgba(29, 28, 26, .13) 1px, transparent 0) 0 0 / 12px 12px, linear-gradient(120deg, var(--fold), var(--fold-2)); }
.nb-page { max-width: 560px; margin: 0 auto; padding: 0 40px 64px; }
.nb-icon { position: relative; width: 62px; height: 78px; margin-top: -40px; }
.nb-icon .face { position: absolute; inset: 0; border-radius: 3px 6px 6px 3px; overflow: hidden; background: var(--fold); box-shadow: 0 0 0 3px #FFFFFE, inset 0 0 0 1px rgba(29, 28, 26, .14), 0 6px 14px rgba(60, 48, 30, .18); }
.nb-icon .tab { position: absolute; right: -5px; top: 10px; width: 9px; height: 26px; border-radius: 0 4px 4px 0; background: var(--fold-2); }
.nb-icon svg { width: 100%; height: 100%; display: block; }
.nb-page h1 { margin: 18px 0 14px; font: 700 34px/1.15 var(--sans); letter-spacing: -.02em; color: var(--ink); }
.nb-props { margin: 0 0 8px; display: grid; gap: 2px; }
.nb-props > div { display: grid; grid-template-columns: 132px 1fr; align-items: center; min-height: 32px; border-radius: 6px; }
.nb-props dt { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); }
.nb-props dt svg { width: 15px; height: 15px; }
.nb-props dd { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); }
.nb-bar { width: 84px; height: 5px; border-radius: 3px; background: rgba(29, 28, 26, .09); overflow: hidden; }
.nb-bar i { display: block; height: 100%; background: var(--cnt); border-radius: 3px; }
.nb-page h2 { margin: 30px 0 6px; padding-top: 22px; border-top: 1px solid var(--rule); font: 600 20px/1.3 var(--sans); letter-spacing: -.01em; color: var(--ink); }
.nb-h2row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--rule); }
.nb-h2row h2 { margin: 0; padding: 0; border: 0; }
/* toggle blocks */
.nb-tog { border-radius: 6px; }
.nb-tog summary, .nb-row { list-style: none; display: grid; grid-template-columns: 22px 26px 1fr auto; align-items: center; gap: 4px; min-height: 34px; padding: 0 6px 0 2px; border-radius: 6px; font-size: 15px; cursor: pointer; }
.nb-tog summary::-webkit-details-marker { display: none; }
.nb-tog summary:hover { background: rgba(29, 28, 26, .04); }
.nb-tri { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; color: var(--ink-3); transition: transform .16s var(--ease); }
.nb-tri svg { width: 12px; height: 12px; }
.nb-tog[open] .nb-tri { transform: rotate(90deg); }
.nb-num { font: 800 12px var(--dots); color: var(--voice); letter-spacing: .04em; }
.nb-pt { font-weight: 500; color: var(--ink); }
.nb-step { font-size: 12.5px; color: var(--ink-3); opacity: 0; transition: opacity .15s var(--ease); }
.nb-tog summary:hover .nb-step, .nb-next .nb-step { opacity: 1; }
.nb-tog-body { padding: 2px 6px 12px 52px; font-size: 15px; line-height: 1.6; color: var(--ink); }
.nb-tog-body p { margin: 4px 0 10px; }
.nb-callout { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 12px 14px; border-radius: 8px; background: #F7F5F0; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.nb-callout-i { color: var(--voice); padding-top: 1px; }
.nb-callout-i svg { width: 17px; height: 17px; }
.nb-callout b { display: block; font-weight: 600; color: var(--ink); margin-bottom: 1px; }
.nb-row { cursor: default; color: var(--ink-3); }
.nb-row .nb-pt { color: var(--ink-3); font-weight: 400; }
.nb-dot { width: 7px; height: 7px; margin-left: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(29, 28, 26, .25); }
.nb-next .nb-num { color: var(--ink-3); }
.nb-later { grid-template-columns: 22px 1fr; font-size: 14px; }
/* the words: a small table you can search */
.nb-search { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 7px; color: var(--ink-3); background: rgba(29, 28, 26, .04); }
.nb-search svg { width: 14px; height: 14px; flex: none; }
.nb-search input { width: 150px; border: 0; background: none; font: 13.5px var(--sans); color: var(--ink); outline: none; }
.nb-search:focus-within { box-shadow: inset 0 0 0 1px rgba(29, 28, 26, .2); background: #FFFFFE; }
.nb-table { margin-top: 10px; border-top: 1px solid var(--rule); }
.nb-tr { display: grid; grid-template-columns: 150px 1fr 64px; gap: 14px; padding: 10px 4px; border-bottom: 1px solid var(--rule); font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.nb-tr[hidden] { display: none; }
.nb-th { padding: 7px 4px; font-size: 12.5px; color: var(--ink-3); }
.nb-tr:not(.nb-th):hover { background: rgba(29, 28, 26, .025); }
.nb-term { font-family: var(--display); font-size: 17px; color: var(--ink); line-height: 1.35; }
.nb-from { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.nb-none, .nb-empty { margin: 8px 0 0; font-size: 14px; color: var(--ink-3); }
@media (max-width: 640px) {
  .nb-page { padding: 0 20px 48px; }
  .nb-tr { grid-template-columns: 1fr; gap: 2px; }
  .nb-th { display: none; }
  .nb-props > div { grid-template-columns: 96px 1fr; }
}
.parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-bottom: 22px; }
.part { border-radius: 10px; padding: 10px; background: linear-gradient(170deg, #E9E6E0, #D9D5CD); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 1px 2px rgba(60, 48, 30, .12); font-size: 12.5px; line-height: 1.25; }
.part b { display: block; font-family: var(--dots); font-weight: 800; font-size: 18px; color: var(--voice); }
.part.empty { background: transparent; box-shadow: inset 0 0 0 1px dashed var(--rule-2); color: var(--ink-3); border: 1px dashed var(--rule-2); }
.part.empty b { color: var(--ink-3); }

/* ---------- intro ---------- */
.intro { position: fixed; inset: 0; z-index: 60; background: var(--desk); display: grid; place-items: center; transition: opacity .6s var(--ease);
  background-image: radial-gradient(circle, var(--desk-dot) 1px, transparent 1.3px); background-size: 22px 22px; }
.intro.leaving { opacity: 0; pointer-events: none; }
.intro-inner { width: min(720px, 88vw); }
.intro-screen { background: var(--screen); border-radius: 14px; padding: 26px 30px; min-height: 230px; box-shadow: var(--lift-3), inset 0 2px 8px rgba(0, 0, 0, .7); }
.intro-screen p { margin: 0 0 14px; font-family: var(--dots); font-weight: 800; font-size: clamp(18px, 2.2vw, 24px); line-height: 1.3; color: var(--voice); text-shadow: 0 0 8px rgba(255, 90, 31, .45); }
.intro-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.intro-foot .key { height: 42px; padding: 0 18px; }
.intro-title { font-family: var(--display); font-weight: 380; font-size: 44px; letter-spacing: -.03em; margin: 0 0 18px; font-variation-settings: "opsz" 144; }
.intro-title i { font-weight: 340; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@container (max-width: 680px) { .st-grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- medium screens ---------- */
@media (max-width: 1560px) {
  .brief h1 { font-size: 32px; }
}

/* ---------- small screens: everything stacks, nothing hides ---------- */
@media (max-width: 1100px) {
  html, body { height: auto; }
  body { overflow: visible; min-height: 100vh; grid-template-rows: 56px auto 28px; }
  .bar { position: sticky; top: 0; }
  .studio { min-height: auto; }
  .map { position: fixed; inset: 56px 0 28px; }
  .bar { flex-wrap: nowrap; padding: 0 14px; gap: 12px; }
  .layout, .split, .rail { display: none !important; }
  .studio, .studio.tracing, .studio.no-desk, .studio.no-brief { grid-template-columns: 1fr; gap: 12px; }
  .brief-col { display: block; }
  .brief, .studio.no-brief .brief, .studio.tracing .brief { display: block; overflow: visible; padding: 8px 4px 8px; }
  .studio.no-desk .desk { display: flex; }
  .sheet { height: 70vh; }
  .tape { min-height: 280px; }
  .stage { position: fixed; inset: 8px; z-index: 35; }
  .st-grid { grid-template-columns: 1fr; }
  .status { position: sticky; bottom: 0; height: 28px; }
}

@media (max-width: 640px) { .crumb-home, .crumb-sep, .cr-prog { display: none; } }
/* tracing always shows the right column, even if it was hidden */
.studio.tracing .desk { display: flex !important; }
.studio.tracing .split { display: block !important; }

/* generic trace visuals: bars and matrices */
.vbars { display: grid; gap: 4px; }
.vbar { display: grid; grid-template-columns: 90px 1fr 64px; gap: 10px; align-items: center; font: 12.5px var(--mono); }
.vbar .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.vbar .t { height: 10px; border-radius: 3px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); overflow: hidden; }
.vbar .t i { display: block; height: 100%; background: var(--chn); border-radius: 3px; transition: width .3s var(--ease); }
.vbar .n { text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.vmat { border-collapse: separate; border-spacing: 3px; font: 11px var(--mono); }
.vmat td { width: 34px; height: 26px; text-align: center; border-radius: 4px; color: var(--ink);
  background: rgba(47, 107, 216, calc(var(--a) * .85 + .04)); }
.vmat th { font-weight: 400; color: var(--ink-3); padding: 0 4px; text-align: right; }
.vscatter { width: 100%; max-width: 420px; height: auto; display: block; }
.vscatter .axis { stroke: var(--rule-2); stroke-width: 1; fill: none; }
.vscatter circle { fill: var(--tok); }
.vscatter circle.moved { fill: var(--voice); }
.vscatter .trail { stroke: rgba(255, 90, 31, .45); stroke-width: 1.5; stroke-dasharray: 2 3; }
.vscatter text { font: 11px var(--mono); fill: var(--ink); }
.vmat-row { display: flex; flex-wrap: wrap; gap: 18px; }
.vmat-wrap h4 { margin: 0 0 8px; }
.vmat td.vmat-x { background: repeating-linear-gradient(135deg, var(--sheet-2) 0 4px, transparent 4px 8px); color: var(--ink-3); }
.vlog { font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.sc-line { white-space: pre-line; }
.vmat.compact td { width: 18px; height: 16px; font-size: 0; }
.vmat.compact th { font-size: 9.5px; }

.vbar-multi .tm { display: grid; gap: 2px; }
.vbar-multi .t { height: 7px; }
.vbar .t i.s1 { background: var(--voice); }
.vbar .t i.s2 { background: var(--cnt); }
.vser { font-weight: 700; }
.vser.s0 { color: var(--chn); } .vser.s1 { color: var(--voice); } .vser.s2 { color: var(--cnt); }
.vmat td.vcat { background: hsl(var(--h) 55% 82%); color: hsl(var(--h) 45% 25%); }

/* ---------- account (panel styles live in src/account.css) ---------- */
.acct-btn.signed-in { padding: 0 12px 0 6px; font-weight: 500; }

/* ---------- end of a unit: Echo speaks ---------- */
.uc {
  width: min(1040px, 100%); max-height: 92vh; overflow-y: auto; display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  border-radius: 24px; background: var(--sheet); box-shadow: var(--lift-3), 0 0 0 1px var(--rule); animation: cardIn .42s var(--ease-in);
}
.uc-stage { display: flex; flex-direction: column; justify-content: center; padding: 40px 36px; background: #F1E8DD; border-radius: 24px 0 0 24px; }
.uc-machine {
  padding: 16px 18px 18px; border-radius: 20px; transform: rotate(-1deg);
  background: linear-gradient(170deg, #E4E1DA 0%, #D6D2CA 55%, #CBC7BE 100%);
  box-shadow: var(--lift-3), inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -2px 0 rgba(0, 0, 0, .08), 0 0 0 1px rgba(60, 48, 30, .12);
}
.uc-screen { min-height: 150px; display: flex; align-items: center; }
.uc-line { font: 700 24px/1.35 var(--dots); color: var(--voice); text-shadow: 0 0 8px rgba(255, 90, 31, .5); }
.uc-line.off { color: #3A3631; text-shadow: none; letter-spacing: .3em; }
.uc-again { align-self: flex-start; margin-top: 22px; }
.uc-cap { margin: 10px 2px 0; font-size: 13px; color: var(--ink-2); }
.uc-body { padding: 40px 44px 36px; }
.uc-kicker { font-size: 13.5px; color: var(--ink-3); }
.uc-body h2 { margin: 8px 0 0; font: 500 40px/1.04 var(--sans); letter-spacing: -0.045em; color: #232220; }
.uc-body h2 i { font-style: normal; }
.uc-body > p { margin: 12px 0 0; font-size: 16.5px; line-height: 1.55; color: var(--ink-2); max-width: 46ch; }
.uc-body h3 { margin: 26px 0 10px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.uc-parts { display: flex; flex-wrap: wrap; gap: 6px; }
.uc-parts span { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 500; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); }
.uc-parts small { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.uc-ideas { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.uc-next { margin-top: 28px; padding: 20px 22px; border-radius: 16px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); }
.uc-next small { font-size: 12.5px; color: var(--ink-3); }
.uc-next b { display: block; margin-top: 2px; font: 380 24px/1.15 var(--display); letter-spacing: -.02em; font-variation-settings: "opsz" 72; }
.uc-next p { margin: 6px 0 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.uc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
.uc-actions a.btn-line { text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.uc-soon { font-size: 13px; color: var(--ink-3); }
@media (max-width: 860px) {
  .uc { grid-template-columns: 1fr; }
  .uc-stage { border-radius: 24px 24px 0 0; padding: 28px 22px; }
  .uc-body { padding: 26px 22px; }
}

/* ---------- workshop tour ---------- */
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-hole { position: fixed; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(29, 28, 26, .48), 0 0 0 2px rgba(255, 255, 255, .9); transition: all .32s var(--ease); pointer-events: none; }
.tour-card {
  position: fixed; width: 320px; padding: 18px 20px 16px; border-radius: 16px; background: var(--sheet); color: var(--ink);
  box-shadow: var(--lift-3), 0 0 0 1px var(--rule); transition: left .32s var(--ease), top .32s var(--ease); animation: rise .28s var(--ease-in);
}
.tour-top { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tour-skip { font-size: 12.5px; color: var(--ink-3); }
.tour-skip:hover { color: var(--ink); text-decoration: underline; }
.tour-card h3 { margin: 10px 0 0; font: 600 17px/1.25 var(--sans); letter-spacing: -.01em; }
.tour-card p { margin: 6px 0 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.tour-card kbd { font: 12px var(--sans); padding: 1px 6px; border-radius: 5px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); color: var(--ink); }
.tour-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.tour-back { height: 34px; padding: 0 12px; border-radius: 9px; font-size: 14px; color: var(--ink-2); }
.tour-back:hover { color: var(--ink); background: rgba(29, 28, 26, .05); }
.tour-next {
  height: 36px; padding: 0 16px; border-radius: 10px; font-size: 14px; font-weight: 500; color: #F6F3EC;
  background: linear-gradient(#3A3936, #262523); box-shadow: inset 0 -3px 0 #171614, inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 2px rgba(0, 0, 0, .18);
}
.tour-next:active { transform: translateY(2px); }
@media (prefers-reduced-motion: reduce) { .tour-hole, .tour-card { transition: none; animation: none; } }
.st-btn { font: inherit; color: inherit; padding: 0; }
.st-btn:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Watch it work / Trace: the focused stage ---------- */
/* A demo isn't the learner's code, so it takes the whole bench; a trace keeps the editor beside it. */
.studio.watching { grid-template-columns: var(--brief-w) 12px minmax(0, 1fr); }
.studio.watching .sheet, .studio.watching .split[data-split="desk"] { display: none !important; }
.studio.watching .desk { grid-column: 3; }
.st-head { padding: 18px 24px 14px; align-items: flex-start; }
.st-title { font: 600 17px/1.3 var(--sans); letter-spacing: -.01em; font-variation-settings: normal; }
.st-call { margin-top: 4px; font-size: 14px; color: var(--ink-2); gap: 6px 12px; max-width: 76ch; }
.st-call code { font-size: 12.5px; color: var(--ink-3); }
.st-body { padding: 22px 24px 24px; gap: 20px; }
.st-say { font-size: 21px; line-height: 1.4; letter-spacing: -.01em; min-height: 62px; max-width: 46ch; margin: 0; color: var(--ink); }
.st-say .step-no { font-size: 12.5px; letter-spacing: 0; margin-bottom: 6px; }
.st-say .next { font-size: 14.5px; margin-top: 8px; letter-spacing: 0; }
.st-say code { font-size: .8em; background: var(--sheet-2); padding: 1px 6px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--rule); }

.st-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 20px; align-items: start; }
.st-canvas { display: grid; gap: 18px; min-width: 0; padding: 20px; border-radius: 16px; background: #FFFEFB; box-shadow: inset 0 0 0 1px var(--rule); }
.cv-row { display: grid; gap: 8px; min-width: 0; }
.cv-k { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.cv-main h4 { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.st-side { display: grid; gap: 12px; min-width: 0; }
.st-side .panel h4 { color: var(--ink-3); font-weight: 600; }
.st-vars summary { cursor: pointer; list-style: none; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.st-vars summary::-webkit-details-marker { display: none; }
.st-vars summary::after { content: " +"; }
.st-vars[open] summary { margin-bottom: 8px; }
.st-vars[open] summary::after { content: " –"; }

/* one quiet palette: ink for what's happening, orange for the thing that just changed */
.tile { font-size: 15px; background: var(--sheet); }
.tile.past { color: var(--ink-3); background: var(--sheet-2); }
.tile.at { background: var(--sheet); box-shadow: inset 0 0 0 2px var(--ink); transform: translateY(-4px); }
.tile.next { box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.tile.next2 { box-shadow: inset 0 0 0 1px var(--ink-3); }
.tile.hit { background: #FFF1EA; box-shadow: inset 0 0 0 2px var(--voice); }
.tile.ch { min-width: 30px; padding: 8px 8px 6px; }
.chip { font-size: 14px; padding: 5px 11px; border-radius: 8px; background: var(--sheet-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); }
.chip.hand { background: var(--sheet); box-shadow: inset 0 0 0 1.5px var(--ink); }
.chip.new { box-shadow: inset 0 0 0 2px var(--voice); background: #FFF1EA; }
.algo li { font-size: 14px; padding: 7px 10px; color: var(--ink-3); }
.algo li.on { background: var(--sheet-2); color: var(--ink); box-shadow: inset 3px 0 0 var(--voice); }
.var.changed { background: #FFF1EA; }

.st-end { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-radius: 16px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); animation: rise .3s var(--ease-in); }
.st-end b { display: block; font-size: 16px; font-weight: 600; }
.st-end span { display: block; margin-top: 3px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); max-width: 60ch; }
.st-end code { color: var(--ink); font-size: .88em; background: var(--sheet); padding: 1px 5px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--rule); }
.st-end .key { flex: none; }

.st-foot { padding: 12px 20px; }
.st-keys { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.st-keys kbd { font: 11px var(--sans); padding: 1px 5px; border-radius: 4px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); }
@media (max-width: 1280px) { .st-keys { display: none; } }
@media (max-width: 1100px) { .st-main { grid-template-columns: 1fr; } }
.studio.watching .st-body { justify-content: safe center; padding-left: max(24px, calc((100% - 1180px) / 2)); padding-right: max(24px, calc((100% - 1180px) / 2)); }
.ask { background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule), inset 3px 0 0 var(--voice); font-size: 15.5px; }
.ask.right { background: #EEF6F1; box-shadow: inset 0 0 0 1px rgba(35, 136, 90, .25), inset 3px 0 0 var(--cnt); }
.ask.wrong { background: #FBF0EE; box-shadow: inset 0 0 0 1px rgba(210, 63, 42, .2), inset 3px 0 0 var(--bad); }
.cell { background: var(--sheet-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); }
.cell.bump { background: #FFF1EA; box-shadow: inset 0 0 0 2px var(--voice); }
tr.row-at td:first-child { color: var(--ink); }

/* ---------- trace v2: one caption, one stage, one timeline ---------- */
.st-head { padding: 20px 24px 16px; align-items: flex-start; }
.st-eyebrow { font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: .01em; }
.st-callbig { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font: 500 22px/1.25 var(--mono); color: var(--ink); letter-spacing: -.01em; }
.st-callbig code { font: inherit; }
.st-ret { display: inline-flex; align-items: baseline; gap: 12px; opacity: 0; transform: translateX(-6px); transition: opacity .4s var(--ease), transform .4s var(--ease); }
.st-ret.on { opacity: 1; transform: none; }
.st-ret .arrow { color: var(--ink-3); font-family: var(--sans); }
.st-ret code { font: inherit; color: var(--voice); }
.st-intro { margin: 6px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); max-width: 70ch; }

.st-body { padding: 22px 24px 28px; gap: 18px; }
.st-say { max-width: none; min-height: 96px; font-size: 20px; }
.cap-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cap-top .step-no { margin: 0; display: inline; font: 12px var(--mono); color: var(--ink-3); }
.round { font-size: 12px; font-weight: 500; color: var(--ink-2); padding: 2px 8px; border-radius: 999px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); font-variant-numeric: tabular-nums; }
.cap-main { margin: 0; font-size: 20px; line-height: 1.45; letter-spacing: -.01em; color: var(--ink); max-width: 52ch; animation: capIn .28s var(--ease-in); }
.cap-main b { font-weight: 600; }
.cap-main .t-yes { color: var(--cnt); }
.cap-main .t-no { color: var(--ink-3); }
.cap-next { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.cap-next em { font-style: normal; font-size: 12px; color: var(--ink-3); }
.cap-next .ln { font: 11px var(--mono); color: var(--ink-3); min-width: 22px; height: 20px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 5px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); }
.cap-next code { font-size: 13px; background: none; box-shadow: none; padding: 0; }
@keyframes capIn { from { opacity: .35; transform: translateY(3px); } }

.st-main.solo { grid-template-columns: minmax(0, 1fr); }
.st-canvas { padding: 26px; gap: 26px; border-radius: 18px; background: #FFFEFB radial-gradient(circle at 1px 1px, rgba(29, 28, 26, .07) 1px, transparent 0) 0 0 / 18px 18px; box-shadow: inset 0 0 0 1px var(--rule), var(--lift-1); overflow: hidden; }
.cv-tiles .tiles { position: relative; gap: 30px 8px; padding-bottom: 28px; }
.cv-tiles .tile { min-width: 52px; padding: 10px 13px 7px; font-size: 16px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--rule-2), 0 1px 0 rgba(29, 28, 26, .06); }
.cv-tiles .tile.at { transform: translateY(-5px); box-shadow: inset 0 0 0 2px var(--ink), 0 6px 14px rgba(29, 28, 26, .10); }
.cv-tiles .tile.hit { background: #FFF1EA; box-shadow: inset 0 0 0 2px var(--voice), 0 6px 14px rgba(255, 90, 31, .18); }
.cv-tiles .tile.next { box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.caret { position: absolute; z-index: 2; transform-origin: top center; pointer-events: none; font-style: normal; translate: -50% 0; display: grid; justify-items: center; }
.caret::before { content: ""; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 6px solid var(--ink); }
.caret b { margin-top: 1px; font: 500 11px var(--mono); color: #fff; background: var(--ink); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.caret.c1::before { border-bottom-color: var(--ink-3); }
.caret.c1 b { background: var(--sheet); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--rule-2); }

.tray { border-radius: 14px; padding: 14px 16px 16px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); }
.tray-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.tray-k { font: 500 13px var(--mono); color: var(--ink); }
.tray-n { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tray .chips { gap: 6px; min-height: 36px; }
.tray .chip { font: 15px var(--mono); padding: 7px 12px; border-radius: 9px; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule-2), 0 1px 0 rgba(29, 28, 26, .06); }
.tray .chip.new { background: #FFF1EA; box-shadow: inset 0 0 0 2px var(--voice); animation: none; }
.tray .empty { margin: 0; min-height: 36px; display: flex; align-items: center; font-size: 13.5px; color: var(--ink-3); }

.watch { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 -26px -26px; padding: 12px 26px; border-top: 1px solid var(--rule); background: rgba(244, 242, 237, .7); }
.watch-k { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-right: 6px; }
.watch .empty { font-size: 12.5px; color: var(--ink-3); }
.wv { display: inline-flex; align-items: center; gap: 0; font: 12.5px var(--mono); border-radius: 7px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--rule-2); background: var(--sheet); max-width: 100%; }
.wv .k { padding: 4px 7px; color: var(--ink-3); border-right: 1px solid var(--rule); }
.wv .v { padding: 4px 8px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.wv.changed { box-shadow: inset 0 0 0 1.5px var(--voice); }
.wv.changed .v { background: #FFF1EA; animation: flash .5s var(--ease-in); }
@keyframes flash { from { background: #FFD9C7; } }

/* the timeline: one mark per step, so the run has a shape you can read and jump around in */
.st-foot { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 24px 14px; }
.tl { position: relative; display: flex; align-items: flex-end; gap: 0; height: 30px; cursor: pointer; touch-action: none; outline: none; padding: 0 1px; }
.tl:focus-visible { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--ink-3); border-radius: 4px; }
.tm { flex: 1; min-width: 1px; height: 8px; border-radius: 1.5px; background: rgba(29, 28, 26, .13); transition: background-color .2s var(--ease); }
.tm.no { height: 8px; }
.tm.yes { height: 16px; background: rgba(35, 136, 90, .35); }
.tm.grow { height: 24px; background: rgba(255, 90, 31, .4); }
.tm.ret { height: 30px; background: rgba(29, 28, 26, .35); }
.tm.past { background: var(--ink-3); }
.tm.yes.past { background: var(--cnt); }
.tm.grow.past { background: var(--voice); }
.tm.ret.past, .tm.cur { background: var(--ink); }
.tl .tm { position: relative; background: none !important; height: 30px; display: flex; align-items: flex-end; justify-content: center; }
.tl .tm::after { content: ""; width: min(100%, 4px); height: 10px; border-radius: 3px; background: rgba(29, 28, 26, .13); transition: background-color .2s var(--ease), transform .2s var(--ease); transform-origin: bottom; }
.tl .tm.yes::after { height: 15px; background: rgba(35, 136, 90, .35); }
.tl .tm.grow::after { height: 22px; background: rgba(255, 90, 31, .4); }
.tl .tm.ret::after { height: 28px; background: rgba(29, 28, 26, .35); }
.tl .tm.past::after { background: var(--ink-3); }
.tl .tm.yes.past::after { background: var(--cnt); }
.tl .tm.grow.past::after { background: var(--voice); }
.tl .tm.ret.past::after, .tl .tm.cur::after { background: var(--ink); }
.tl .tm.cur::after { transform: scaleY(1.15); }
.tl .tm:hover::after { background: var(--ink-2); }
.tl-head { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; transition: left .18s var(--ease); pointer-events: none; }
.tl-head::before { content: ""; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.tl-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-3); min-height: 14px; }
.tl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tl-legend .tm { flex: none; width: 4px; height: 10px; border-radius: 2px; }
.tl-legend .tm.yes { background: var(--cnt); } .tl-legend .tm.grow { background: var(--voice); } .tl-legend .tm.ret { background: var(--ink); }
.st-ctrl { display: flex; align-items: center; gap: 8px; }
.st-ctrl .st-step { width: 34px; padding: 0; font-size: 18px; }
.st-ctrl .key:focus { outline: none; }
.st-ctrl .key:focus-visible { outline: 2px solid rgba(29, 28, 26, .28); outline-offset: 2px; }
.st-playbtn { min-width: 96px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.st-playbtn svg { width: 13px; height: 13px; }
.st-playbtn .i-pause, .st-playbtn.playing .i-play { display: none; }
.st-playbtn.playing .i-pause { display: block; }
.st-ctrl .st-count { margin-left: 6px; text-align: left; min-width: 0; font: 12px var(--mono); }
.st-ctrl .st-count b { color: var(--ink); font-weight: 500; }
.st-ctrl .st-keys { margin-left: auto; }
.st-ctrl .speed { margin-left: 8px; }
@media (max-width: 1280px) { .st-ctrl .speed { margin-left: auto; } }

/* ---------- end of a unit: the moment, then the decision ---------- */
.scrim.ucx-scrim { padding: 0; background: rgba(12, 14, 20, .55); backdrop-filter: blur(10px); }
.ucx { position: relative; width: min(1080px, calc(100vw - 48px)); height: min(720px, calc(100vh - 48px)); border-radius: 28px; overflow: hidden; box-shadow: 0 40px 120px rgba(0, 0, 0, .45); }

/* beat 1: the stage */
.ucx-stage {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 32px; text-align: center; color: #F3EEE3;
  background: radial-gradient(90% 70% at 50% 38%, #233456 0%, #131E36 55%, #0B1324 100%);
  transition: opacity .5s var(--ease), transform .6s var(--ease);
}
.ucx-stage.gone { opacity: 0; transform: scale(.98); pointer-events: none; }
.ucx-glow { position: absolute; left: 50%; top: 40%; width: 640px; height: 420px; transform: translate(-50%, -50%); background: radial-gradient(closest-side, rgba(255, 106, 43, .22), transparent); pointer-events: none; animation: ucxGlow 4s ease-in-out infinite; }
@keyframes ucxGlow { 50% { opacity: .65; } }
.ucx-kicker { position: relative; margin: 0 0 26px; font-size: 13.5px; font-weight: 500; letter-spacing: .02em; color: rgba(243, 238, 227, .6); }
.ucx-machine {
  position: relative; width: min(520px, 100%); padding: 18px 20px 20px; border-radius: 22px; text-align: left;
  background: linear-gradient(170deg, #E4E1DA 0%, #D6D2CA 55%, #CBC7BE 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .12), inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -2px 0 rgba(0, 0, 0, .08);
}
.ucx-screen { min-height: 150px; display: flex; align-items: center; padding: 18px 22px; }
.ucx-line { font: 700 27px/1.38 var(--dots); color: var(--voice); text-shadow: 0 0 10px rgba(255, 90, 31, .6); }
.ucx-line.off { color: #3A3631; text-shadow: none; letter-spacing: .3em; }
.ucx-title { position: relative; margin: 40px 0 0; font: 500 44px/1.05 var(--sans); letter-spacing: -0.045em; color: #FBF7EE; }
.ucx-sub { position: relative; margin: 14px auto 0; max-width: 46ch; font-size: 16.5px; line-height: 1.55; color: rgba(243, 238, 227, .72); }
.ucx-actions { position: relative; display: flex; gap: 12px; margin-top: 30px; }
.ucx-ghost { height: 46px; padding: 0 18px; border-radius: 12px; font-size: 15px; font-weight: 500; color: #F3EEE3; background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.ucx-ghost:hover { background: rgba(255, 255, 255, .14); }
.ucx-go {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 46px; padding: 0 20px; border-radius: 12px; font-size: 15px; font-weight: 500; text-decoration: none;
  color: var(--ink); background: linear-gradient(#F7F5F0, #E4E0D7); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .9), 0 2px 8px rgba(0, 0, 0, .25);
}
.ucx-go kbd { font: 12px var(--sans); color: rgba(29, 28, 26, .45); }
.ucx-go:active { transform: translateY(2px); }
.ucx-go-dark { color: #F6F3EC; background: linear-gradient(#3A3936, #262523); box-shadow: inset 0 -3px 0 #171614, inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 2px rgba(0, 0, 0, .18); }
.ucx-go-dark kbd { color: rgba(246, 243, 236, .5); }

/* beat 2: the sheet */
.ucx-sheet { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); background: var(--sheet); opacity: 0; transform: translateY(12px); transition: opacity .5s var(--ease) .15s, transform .6s var(--ease) .15s; }
.ucx-sheet.in { opacity: 1; transform: none; }
.ucx-recap { padding: 48px 44px; overflow-y: auto; background: #F1E8DD; }
.ucx-next { display: flex; flex-direction: column; padding: 48px 48px 40px; overflow-y: auto; }
.ucx-k { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.ucx-k2 { margin-top: 30px; }
.ucx-recap h3 { margin: 0 0 22px; font: 380 30px/1.1 var(--display); letter-spacing: -.02em; font-variation-settings: "opsz" 144; }
.ucx-parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ucx-parts li { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 12px; font-size: 15px; font-weight: 500; background: rgba(255, 255, 255, .7); box-shadow: inset 0 0 0 1px rgba(29, 28, 26, .07); }
.ucx-parts li span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font: 600 11.5px var(--sans); font-variant-numeric: tabular-nums; color: #F6F3EC; background: var(--ink); }
.ucx-ideas { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.ucx-ideas span { padding: 5px 10px; border-radius: 8px; font-size: 13px; color: var(--ink-2); background: rgba(255, 255, 255, .55); box-shadow: inset 0 0 0 1px rgba(29, 28, 26, .06); }
.ucx-saved { margin: 26px 0 0; font-size: 13px; color: var(--ink-3); }
.ucx-next-t { margin: 0; font: 500 34px/1.08 var(--sans); letter-spacing: -0.04em; color: #232220; }
.ucx-hook { margin: 14px 0 0; font-size: 16px; line-height: 1.6; color: var(--ink-2); max-width: 48ch; }
.ucx-facts { display: grid; gap: 14px; margin: 26px 0 0; padding: 20px 0 0; border-top: 1px solid var(--rule); }
.ucx-facts div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
.ucx-facts dt { font-size: 13.5px; color: var(--ink-3); }
.ucx-facts dd { margin: 0; font-size: 14.5px; font-weight: 500; color: var(--ink); }
.ucx-cta { margin-top: auto; padding-top: 28px; display: grid; gap: 14px; }
.ucx-cta .ucx-go { width: 100%; height: 50px; font-size: 15.5px; }
.ucx-offer { display: grid; gap: 14px; padding: 20px; border-radius: 18px; background: var(--sheet-2); box-shadow: inset 0 0 0 1px var(--rule); }
.ucx-offer b { display: block; font-size: 16px; font-weight: 600; }
.ucx-offer span { display: block; margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.ucx-later { justify-self: center; font-size: 14px; color: var(--ink-2); text-decoration: none; }
.ucx-later:hover { color: var(--ink); text-decoration: underline; }
.ucx-soon { margin: 0; font-size: 14.5px; color: var(--ink-2); }

@media (max-width: 860px) {
  .ucx { width: 100vw; height: 100vh; border-radius: 0; }
  .ucx-sheet { grid-template-columns: 1fr; overflow-y: auto; }
  .ucx-recap, .ucx-next { overflow: visible; padding: 32px 22px; }
  .ucx-title { font-size: 34px; }
  .ucx-line { font-size: 21px; }
  .ucx-actions { flex-direction: column; width: 100%; max-width: 320px; }
}
@media (prefers-reduced-motion: reduce) { .ucx-glow { animation: none; } .ucx-stage, .ucx-sheet { transition: none; } }

/* ---------- Echo wakes up on a first pass ---------- */
.instrument.wake { animation: instWake 1.1s var(--ease); }
@keyframes instWake { 0% { box-shadow: var(--lift-2), 0 0 0 1px rgba(60,48,30,.12); } 30% { box-shadow: var(--lift-2), 0 0 0 3px rgba(255,90,31,.5), 0 0 40px rgba(255,90,31,.25); } 100% { box-shadow: var(--lift-2), 0 0 0 1px rgba(60,48,30,.12); } }
.sc-line.news { color: #FFD3BC; }
.sc-line.know { color: var(--voice); }
.sc-line.sc-hint { margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { .instrument.wake { animation: none; } }
