.ͼ1.cm-focused {outline: 1px dotted #212121;}
.ͼ1 {position: relative !important; box-sizing: border-box; display: flex !important; flex-direction: column;}
.ͼ1 .cm-scroller {display: flex !important; align-items: flex-start !important; font-family: monospace; line-height: 1.4; height: 100%; overflow-x: auto; position: relative; z-index: 0; overflow-anchor: none;}
.ͼ1 .cm-content[contenteditable=true] {-webkit-user-modify: read-write-plaintext-only;}
.ͼ1 .cm-content {margin: 0; flex-grow: 2; flex-shrink: 0; display: block; white-space: pre; word-wrap: normal; box-sizing: border-box; min-height: 100%; padding: 4px 0; outline: none;}
.ͼ1 .cm-lineWrapping {white-space: pre-wrap; white-space: break-spaces; word-break: break-word; overflow-wrap: anywhere; flex-shrink: 1;}
.ͼ2 .cm-content {caret-color: black;}
.ͼ3 .cm-content {caret-color: white;}
.ͼ1 .cm-line {display: block; padding: 0 2px 0 6px;}
.ͼ1 .cm-layer > * {position: absolute;}
.ͼ1 .cm-layer {user-select: none; position: absolute; left: 0; top: 0; contain: size style;}
.ͼ2 .cm-selectionBackground {background: #d9d9d9;}
.ͼ3 .cm-selectionBackground {background: #222;}
.ͼ2.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground {background: #d7d4f0;}
.ͼ3.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground {background: #233;}
.ͼ1 .cm-cursorLayer {pointer-events: none;}
.ͼ1.cm-focused > .cm-scroller > .cm-cursorLayer {animation: steps(1) cm-blink 1.2s infinite;}
@keyframes cm-blink {50% {opacity: 0;}}
@keyframes cm-blink2 {50% {opacity: 0;}}
.ͼ1 .cm-cursor, .ͼ1 .cm-dropCursor {border-left: 1.2px solid black; margin-left: -0.6px; pointer-events: none;}
.ͼ1 .cm-cursor {display: none;}
.ͼ3 .cm-cursor {border-left-color: #ddd;}
.ͼ1 .cm-selectionHandle {background-color: currentColor; width: 1.5px;}
.ͼ1 .cm-selectionHandle-start::before, .ͼ1 .cm-selectionHandle-end::before {content: ""; background-color: inherit; border-radius: 50%; width: 8px; height: 8px; position: absolute; left: -3.25px;}
.ͼ1 .cm-selectionHandle-start::before {top: -8px;}
.ͼ1 .cm-selectionHandle-end::before {bottom: -8px;}
.ͼ1 .cm-dropCursor {position: absolute;}
.ͼ1.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor {display: block;}
.ͼ1 .cm-iso {unicode-bidi: isolate;}
.ͼ1 .cm-announced {position: fixed; top: -10000px;}
@media print {.ͼ1 .cm-announced {display: none;}}
.ͼ2 .cm-activeLine {background-color: #cceeff44;}
.ͼ3 .cm-activeLine {background-color: #99eeff33;}
.ͼ2 .cm-specialChar {color: red;}
.ͼ3 .cm-specialChar {color: #f78;}
.ͼ1 .cm-gutters {flex-shrink: 0; display: flex; height: 100%; box-sizing: border-box; z-index: 200;}
.ͼ1 .cm-gutters-before {inset-inline-start: 0;}
.ͼ1 .cm-gutters-after {inset-inline-end: 0;}
.ͼ2 .cm-gutters.cm-gutters-before {border-right-width: 1px;}
.ͼ2 .cm-gutters.cm-gutters-after {border-left-width: 1px;}
.ͼ2 .cm-gutters {background-color: #f5f5f5; color: #6c6c6c; border: 0px solid #ddd;}
.ͼ3 .cm-gutters {background-color: #333338; color: #ccc;}
.ͼ1 .cm-gutter {display: flex !important; flex-direction: column; flex-shrink: 0; box-sizing: border-box; min-height: 100%; overflow: hidden;}
.ͼ1 .cm-gutterElement {box-sizing: border-box;}
.ͼ1 .cm-lineNumbers .cm-gutterElement {padding: 0 3px 0 5px; min-width: 20px; text-align: right; white-space: nowrap;}
.ͼ2 .cm-activeLineGutter {background-color: #e2f2ff;}
.ͼ3 .cm-activeLineGutter {background-color: #222227;}
.ͼ1 .cm-panels {box-sizing: border-box; position: sticky; left: 0; right: 0; z-index: 300;}
.ͼ2 .cm-panels {background-color: #f5f5f5; color: black;}
.ͼ1 .cm-panels-top {top: 0;}
.ͼ1 .cm-panels-bottom {bottom: 0;}
.ͼ2 .cm-panels-top {border-bottom: 1px solid #ddd;}
.ͼ2 .cm-panels-bottom {border-top: 1px solid #ddd;}
.ͼ3 .cm-panels {background-color: #333338; color: white;}
.ͼ1 .cm-dialog label {font-size: 80%;}
.ͼ1 .cm-dialog {padding: 2px 19px 4px 6px; position: relative;}
.ͼ1 .cm-dialog-close {position: absolute; top: 3px; right: 4px; background-color: inherit; border: none; font: inherit; font-size: 14px; padding: 0;}
.ͼ1 .cm-tab {display: inline-block; overflow: hidden; vertical-align: bottom;}
.ͼ1 .cm-widgetBuffer {vertical-align: baseline; height: 1em; width: 0; display: inline;}
.ͼ1 .cm-placeholder {color: #888; display: inline-block; vertical-align: top; user-select: none;}
.ͼ1 .cm-highlightSpace {background: radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat; background-size: .4em; background-position: calc(min(50%, 0px)) center;}
.ͼ1 .cm-highlightTab {background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>'); background-size: auto 100%; background-position: right 90%; background-repeat: no-repeat;}
.ͼ1 .cm-trailingSpace {background-color: #ff332255;}
.ͼ1 .cm-button {vertical-align: middle; color: inherit; font-size: 70%; padding: .2em 1em; border-radius: 1px;}
.ͼ2 .cm-button:active {background-image: linear-gradient(#b4b4b4, #d0d3d6);}
.ͼ2 .cm-button {background-image: linear-gradient(#eff1f5, #d9d9df); border: 1px solid #888;}
.ͼ3 .cm-button:active {background-image: linear-gradient(#111, #333);}
.ͼ3 .cm-button {background-image: linear-gradient(#393939, #111); border: 1px solid #888;}
.ͼ1 .cm-textfield {vertical-align: middle; color: inherit; font-size: 70%; border: 1px solid silver; padding: .2em .5em;}
.ͼ2 .cm-textfield {background-color: white;}
.ͼ3 .cm-textfield {border: 1px solid #555; background-color: inherit;}
/* Layout: a daylit academy. Left, the scene and whoever is speaking; right, the workbench. Phones stack them. */
:root {
  --paper: #FAFBFA;
  --surface: #FFFFFF;
  --ink: #172022;
  --ink-2: #4E5B5D;
  --line: #DCE2E0;
  --line-2: #EEF2F1;
  --accent: #1D5C6E;
  --accent-soft: #E7F0F2;
  --signal: #B9770A;
  --signal-glow: #F6C35A;
  --signal-soft: #FFF5DE;
  --ok: #2B7448;
  --ok-soft: #E8F4EC;
  --bad: #B03A2E;
  --bad-soft: #FBECEA;
  --screen-off: #253236;

  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-read: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-code: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r: 6px;
  --topbar: 56px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--f-display); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-2); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; height: var(--topbar); display: flex; align-items: center; gap: 16px; padding-inline: 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.brand b { color: var(--signal); font-weight: 700; }
.where { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.where .ch { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.where #beat-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#beats { display: flex; gap: 5px; align-items: center; margin-left: auto; }
.beat-pip { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); padding: 0; cursor: pointer; }
.beat-pip.mission { border-radius: 2px; transform: rotate(45deg) scale(.9); }
.beat-pip.done { background: var(--signal-glow); border-color: var(--signal); }
.beat-pip.current { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }
.beat-pip:disabled { cursor: default; opacity: .5; }
#beat-count { white-space: nowrap; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); white-space: nowrap; cursor: default; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.chip[data-state="loading"] .dot { background: var(--signal-glow); animation: pulse 1.2s infinite; }
.chip[data-state="ready"] .dot { background: var(--ok); }
.chip[data-state="failed"] { cursor: pointer; border-color: var(--bad); color: var(--bad); }
.chip[data-state="failed"] .dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- stage ---------- */
.stage { display: grid; grid-template-columns: minmax(380px, 44%) minmax(0, 1fr); height: calc(100% - var(--topbar)); }
.scene-col { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); min-height: 0; overflow-y: auto; }
.work-col { overflow-y: auto; min-width: 0; padding: 28px clamp(16px, 3vw, 44px) 48px; }

/* ---------- scene drawing ---------- */
.scene { margin: 0; aspect-ratio: 800 / 460; max-width: 100%; border-bottom: 1px solid var(--line); background: var(--paper); }
.scene svg { display: block; width: 100%; height: 100%; }
.scene .wall { fill: #F1F4F2; } .scene .ceiling { fill: #E8ECEA; } .scene .side-wall { fill: #E6EAE8; } .scene .floor { fill: #E2E6E3; }
.scene .floor-line { stroke: #CDD4D0; stroke-width: 1; }
.scene .ink-line, .scene .mullion { stroke: #8F9C99; stroke-width: 1.2; fill: none; }
.scene .ink-fill { fill: #5C6967; }
.scene .glass { fill: #DCE9EE; stroke: #9DB2B8; stroke-width: 1; }
.scene .glass-dim { fill: #CFD9DC; }
.scene .frame { fill: #3A4648; }
.scene .screen.off { fill: var(--screen-off); }
.scene .screen.on { fill: #1D2A2D; filter: drop-shadow(0 0 10px rgba(246,195,90,.55)); }
.scene .screen-text { fill: var(--signal-glow); font-family: var(--f-code); }
.scene .board-head { fill: #FFFFFF; font-family: var(--f-code); font-weight: 600; letter-spacing: .08em; }
.scene .screen-cursor { fill: #5D6D70; font-family: var(--f-code); font-size: 14px; animation: blink 1.1s steps(2) infinite; }
/* location drawings */
.scene .screen.ambient { fill: #22343A; }
.scene .screen-ambient { fill: #7FB3C2; font-family: var(--f-code); }
.scene .wall-dark { fill: #E3E7E6; } .scene .wall-cool { fill: #EEF3F4; } .scene .wall-panel { fill: #DCE2E0; stroke: #8F9C99; }
.scene .strip { fill: #22343A; } .scene .bar { fill: #F6C35A; opacity: .85; }
.scene .chair { fill: #8F9C99; } .scene .keyboard { fill: #B9C3C0; }
.scene .paper { fill: #FFFFFF; stroke: #8F9C99; } .scene .route { stroke: #8FA9B1; stroke-width: 2.5; fill: none; }
.scene .node-on { fill: #F6C35A; stroke: #B9770A; } .scene .node-off { fill: #CBD3D1; stroke: #8F9C99; }
.scene .dome-wall { fill: #E9EEF0; } .scene .rib { stroke: #B8C4C6; fill: none; } .scene .slit { fill: #1E2B33; }
.scene .tube { fill: #F7F8F7; stroke: #6C7876; stroke-width: 1.5; } .scene .metal-dark { fill: #5C6967; }
.scene .shelf { fill: #CDD4D0; stroke: #8F9C99; } .scene .plate-text { fill: #F6C35A; font-family: var(--f-code); font-size: 9px; letter-spacing: .1em; }
.scene .pegboard { fill: #E7DCC6; stroke: #B9A47A; } .scene .tool { stroke: #5C6967; stroke-width: 3; stroke-linecap: round; fill: none; }
.scene .bench { fill: #D9CBB0; stroke: #8F9C99; } .scene .joint { fill: #3A4648; } .scene .grip { stroke: #3A4648; stroke-width: 3; stroke-linecap: round; }
.scene .robot-body { fill: #F7F8F7; stroke: #6C7876; stroke-width: 1.5; } .scene .wheel { fill: #3A4648; }
.scene .eye-on { fill: #F6C35A; filter: drop-shadow(0 0 4px rgba(246,195,90,.9)); } .scene .eye-off { fill: #8F9C99; }
.scene .hazard { fill: #F6C35A; stroke: #3A4648; stroke-dasharray: 8 8; stroke-width: 6; }
.scene .whiteboard { fill: #FFFFFF; stroke: #8F9C99; stroke-width: 2; } .scene .box { fill: #E7F0F2; stroke: #1D5C6E; }
.scene .box-text { font-family: var(--f-code); font-size: 10px; fill: #1D5C6E; } .scene .arrow { stroke: #1D5C6E; stroke-width: 1.5; fill: none; }
.scene .corkboard { fill: #E7DCC6; stroke: #B9A47A; stroke-width: 2; } .scene .board-label { font-family: var(--f-display); font-size: 8px; font-weight: 600; letter-spacing: .08em; fill: #6C5A33; }
.scene .note-y { fill: #FBE7A1; } .scene .note-b { fill: #CFE3EA; } .scene .note-g { fill: #CFE8D5; }
.scene .glass-tint { fill: #DCE9EE; opacity: .55; } .scene .mullion-thick { fill: #8F9C99; }
.scene .panel { fill: #3A4648; } .scene .gauge { stroke: #CFD6D3; stroke-width: 4; fill: none; } .scene .needle { stroke: #F6C35A; stroke-width: 2; }
.scene .cable { stroke: #6C7876; stroke-width: 3; fill: none; }
@keyframes blink { 50% { opacity: 0; } }
.scene .banner.off { fill: #CBD3D1; } .scene .banner.on { fill: var(--accent); }
.scene .banner-text { fill: #FFFFFF; font-family: var(--f-display); font-weight: 600; letter-spacing: .04em; }
.scene .door { fill: #C9D2CF; stroke: #8F9C99; }
.scene .desk-top { fill: #FFFFFF; stroke: #8F9C99; } .scene .desk-front { fill: #B9C3C0; }
.scene .pot { fill: #B9C3C0; } .scene .leaf { stroke: #5F8A6B; stroke-width: 3; fill: none; stroke-linecap: round; }
.scene .gate-post { fill: #8F9C99; } .scene .gate-arm { fill: var(--bad); transition: width .6s; } .scene .gate-arm.open { fill: var(--ok); }
.scene .light-stop { fill: var(--bad); } .scene .light-go { fill: #4CC27A; }
.scene .lamp-off { fill: #CFD6D3; } .scene .lamp-on { fill: var(--signal-glow); filter: drop-shadow(0 4px 8px rgba(246,195,90,.8)); }
.scene .dim { fill: #0E1719; pointer-events: none; transition: opacity 1.2s; }
.scene .obj.focus .frame, .scene .obj.focus .screen.off, .scene .obj.focus .banner.off, .scene .obj.focus .door { stroke: var(--signal); stroke-width: 3; stroke-dasharray: 6 4; animation: march 1s linear infinite; }
@keyframes march { to { stroke-dashoffset: -20; } }
.scene .sky { fill: #EAF1F4; } .scene .skyline rect { fill: #D3DCDF; }
.scene .facade { fill: #F7F8F7; stroke: #8F9C99; } .scene .facade-cap { fill: #3A4648; }
.scene .facade-name { font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: .18em; fill: #3A4648; }
.scene .street { fill: #D9DEDC; } .scene .rail { stroke: #8F9C99; stroke-width: 2; }
.scene .lamp line { stroke: #6C7876; stroke-width: 3; } .scene .lamp rect { fill: #6C7876; }

/* ---------- dialogue ---------- */
#dialogue { padding: 20px 22px 24px; flex: 1; }
.dlg { display: grid; gap: 14px; }
.nameplate { display: flex; align-items: center; gap: 12px; }
.monogram { position: relative; width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 600; letter-spacing: .04em; font-size: 15px; }
.wave { position: absolute; right: -10px; bottom: -2px; display: flex; gap: 2px; align-items: flex-end; height: 14px; padding: 2px 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; opacity: 0; transition: opacity .2s; }
.wave i { width: 2.5px; height: 4px; background: var(--signal); border-radius: 1px; }
.speaking .wave { opacity: 1; } .speaking .wave i { animation: eq .9s ease-in-out infinite; }
.speaking .wave i:nth-child(2) { animation-delay: .15s; } .speaking .wave i:nth-child(3) { animation-delay: .3s; } .speaking .wave i:nth-child(4) { animation-delay: .45s; }
@keyframes eq { 50% { height: 10px; } }
.np-text { display: flex; flex-direction: column; line-height: 1.25; }
.np-name { font-weight: 600; } .np-role { font-size: 12.5px; color: var(--ink-2); }
.nameplate.narrator .np-name { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.dlg-text { margin: 0; font: 400 19px/1.55 var(--f-read); max-width: 40em; text-wrap: pretty; }
.dlg[data-who="narrator"] .dlg-text { font-style: italic; }
.dlg.no-subs .dlg-text { visibility: hidden; height: 1.5em; overflow: hidden; }
.dlg-controls { display: flex; align-items: center; gap: 10px; }
.dlg-step { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-right: auto; }
.dlg-choices { display: grid; gap: 10px; }
.dlg-prompt { margin: 0; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.choice { text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font: 17px/1.4 var(--f-read); cursor: pointer; }
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.dlg-end { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dlg-end p { margin: 0; color: var(--ink-2); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 14px; border-radius: var(--r); border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #000; }
.btn-secondary { background: var(--surface); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-quiet { background: transparent; color: var(--ink-2); padding-inline: 8px; }
.btn-quiet:hover:not(:disabled) { color: var(--ink); }

/* ---------- pages ---------- */
.page { max-width: 760px; display: grid; gap: 16px; }
.page > * { margin: 0; }
.eyebrow { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.chapter-title { font-size: clamp(34px, 5vw, 56px); line-height: 1; letter-spacing: -0.03em; font-weight: 700; text-wrap: balance; }
.ch-num { display: block; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--signal); margin-bottom: 10px; font-weight: 600; }
.page-title { font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; text-wrap: balance; }
.h-small { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; margin-top: 8px !important; }
.lede, .concept { font: 19px/1.55 var(--f-read); max-width: 36em; }
.concept { padding-left: 16px; border-left: 3px solid var(--signal-glow); }
.meta-line, .note { color: var(--ink-2); font-size: 14px; }
.note { font-family: var(--f-read); font-size: 16px; }
.objectives { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font: 17px/1.45 var(--f-read); }
.objectives li { padding-left: 26px; position: relative; }
.objectives li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 9px; height: 9px; border: 1.5px solid var(--accent); transform: rotate(45deg); }
.objectives.done li::before { background: var(--signal-glow); border-color: var(--signal); }
.dossier { margin: 0; display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.dossier dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.dossier dt { color: var(--ink-2); } .dossier dd { margin: 0; }

.pipeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; counter-reset: p; }
.pipeline li { position: relative; padding: 12px 18px 12px 12px; border: 1px solid var(--line); background: var(--surface); margin-right: -1px; display: grid; gap: 2px; min-width: 0; }
.pipeline li:not(:last-child)::after { content: ""; position: absolute; right: -7px; top: 50%; width: 12px; height: 12px; background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: translateY(-50%) rotate(45deg); z-index: 1; }
.pipeline span { font-weight: 600; font-size: 14px; } .pipeline small { color: var(--ink-2); font-size: 12px; line-height: 1.3; }
.pipeline li:nth-child(2) span { color: var(--accent); } .pipeline li:last-child { background: var(--signal-soft); }

.code-block { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.code-head, .file-tab { font: 12px var(--f-code); color: var(--ink-2); padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--line-2); }
.code-block.diagnostic .cm-content { color: var(--bad); }
.try-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.expected-label, .io-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 4px; }
pre.expected, pre.code-inline { margin: 0; padding: 12px 14px; border-radius: var(--r); background: var(--signal-soft); border: 1px solid #F0DDB0; font: 14px/1.55 var(--f-code); white-space: pre-wrap; overflow-x: auto; }
pre.code-inline { background: var(--line-2); border-color: var(--line); }

/* ---------- CodeMirror ---------- */
.cm-editor { font: 14.5px/1.6 var(--f-code); background: var(--surface); }
.cm-editor.cm-focused { outline: none; }
.cm-scroller { font-family: var(--f-code); }
.cm-gutters { background: var(--surface); border-right: 1px solid var(--line-2); color: #9AA6A4; }
.cm-activeLine { background: #F5F8F7; } .cm-activeLineGutter { background: #F5F8F7; }
.cm-line.hl { background: var(--signal-soft); box-shadow: inset 3px 0 0 var(--signal); }
.cm-cursor { border-left: 2px solid var(--accent); }
.cm-selectionBackground, .cm-focused .cm-selectionBackground { background: #D6E6EA !important; }
.cm-matchingBracket { background: #E3EEDD; outline: 1px solid #A9C79B; }
.tok-kw { color: #8A3F7A; font-weight: 600; } .tok-type { color: #1D5C6E; font-weight: 600; } .tok-str { color: #2B7448; }
.tok-num { color: #B9770A; } .tok-com { color: #7E8A88; font-style: italic; } .tok-pre { color: #9A4A20; } .tok-ns { color: #1D5C6E; } .tok-fn { color: #2D4F9A; } .tok-op { color: #4E5B5D; }
.cm-tooltip { border: 1px solid var(--line) !important; background: var(--surface) !important; border-radius: var(--r); font-family: var(--f-code); font-size: 13px; }
.cm-tooltip-autocomplete ul li[aria-selected] { background: var(--accent) !important; color: #fff; }
.cm-diagnostic { font-family: var(--f-display); }
.cm-lintRange-error { background-image: none !important; text-decoration: wavy underline var(--bad) 1.5px; text-underline-offset: 3px; }

/* ---------- questions ---------- */
.questions { display: grid; gap: 22px; }
.question { border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 0; display: grid; gap: 12px; background: var(--surface); }
.question legend { padding: 0 6px; font-weight: 600; font-size: 16px; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt { text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); cursor: pointer; font-family: var(--f-code); font-size: 14px; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.opt.wrong { background: var(--bad-soft); border-color: #E2B4AE; color: var(--bad); text-decoration: line-through; }
.opt:disabled { cursor: default; }
.explain { margin: 0; font: 16px/1.5 var(--f-read); }
.explain.ok { color: var(--ok); } .explain.bad { color: var(--bad); }

/* ---------- IDE ---------- */
.ide { display: grid; gap: 18px; max-width: 980px; }
.ide-tabs { display: none; }
.panel { min-width: 0; }
.brief { display: grid; gap: 12px; }
.brief > * { margin: 0; }
.brief-head { display: flex; gap: 8px; flex-wrap: wrap; }
.level { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; padding: 3px 8px; border-radius: 3px; background: var(--accent-soft); color: var(--accent); }
.level-mastery { background: var(--signal-soft); color: var(--signal); } .level-debugging { background: var(--bad-soft); color: var(--bad); }
.level-note { background: transparent; color: var(--ink-2); padding-inline: 0; }
.level-pass { background: var(--ok-soft); color: var(--ok); }
.goal { font: 17px/1.5 var(--f-read); }
.rules { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; display: grid; gap: 4px; }
.hints { display: grid; gap: 8px; }
.hint { padding: 10px 12px; border-radius: var(--r); background: var(--accent-soft); }
.hint-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.hint p { margin: 2px 0 0; font: 15px/1.45 var(--f-read); }
.hint-row { display: flex; gap: 4px; flex-wrap: wrap; margin-left: -8px !important; }
.confirm { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: grid; gap: 10px; }
.confirm p { margin: 0; font-size: 14px; } .confirm div { display: flex; gap: 8px; flex-wrap: wrap; }

.code { display: grid; gap: 10px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.editor-host { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.editor .cm-editor { min-height: 220px; max-height: 52vh; }
.editor .cm-scroller { min-height: 220px; }
.keybar { display: none; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.keybar button { flex: none; min-width: 44px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font: 15px var(--f-code); }
.stdin { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.stdin input { font: 15px var(--f-code); padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); min-width: 0; }

.output { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.console-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--line-2); font-size: 13px; font-weight: 600; }
.console-head .muted { font-weight: 400; font-size: 12.5px; }
#out-status.ok { color: var(--ok); } #out-status.bad { color: var(--bad); } #out-status.busy { color: var(--signal); }
.console-body { padding: 14px; display: grid; gap: 10px; min-height: 90px; }
.console-body > * { margin: 0; }
pre.console { margin: 0; padding: 10px 12px; background: #F4F6F5; border-radius: 4px; font: 13.5px/1.55 var(--f-code); white-space: pre-wrap; word-break: break-word; overflow-x: auto; }
pre.console.in { background: var(--accent-soft); } pre.console.err { background: var(--bad-soft); color: var(--bad); }
pre.console.small { font-size: 13px; }
.diag-list, .tests { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.diag { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 10px 12px; border-radius: var(--r); background: var(--bad-soft); }
.diag.warning { background: var(--signal-soft); }
.diag-loc { font: 12px var(--f-code); padding: 3px 7px; border: 1px solid currentColor; border-radius: 4px; background: var(--surface); color: var(--bad); cursor: pointer; align-self: start; white-space: nowrap; }
.diag.warning .diag-loc { color: var(--signal); }
.diag-msg { margin: 0; font: 13.5px/1.5 var(--f-code); word-break: break-word; }
.diag-msg b { text-transform: uppercase; font-size: 11px; letter-spacing: .06em; margin-right: 4px; }
.diag-ex { margin: 4px 0 0; font: 15.5px/1.45 var(--f-read); }
.raw summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.raw pre { margin-top: 8px; }
.ok-line { display: flex; gap: 8px; align-items: center; color: var(--ok); font-weight: 600; }
.ok-line svg { width: 16px; height: 16px; }
.score { font-weight: 700; font-size: 16px; } .score.ok { color: var(--ok); } .score.bad { color: var(--bad); }
.test { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.test p { margin: 0; }
.t-icon svg { width: 18px; height: 18px; } .test.pass .t-icon { color: var(--ok); } .test.fail .t-icon { color: var(--bad); }
.t-name { font-weight: 600; } .t-why { font: 15.5px/1.45 var(--f-read); margin: 2px 0 8px !important; }
.diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.win { padding: 14px 16px; border-radius: var(--r); background: var(--signal-soft); border: 1px solid #F0DDB0; }
.win p { margin: 0; } .win-title { font-weight: 700; font-size: 17px; color: var(--signal); }
.tab-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; }

/* ---------- recap ---------- */
.table-wrap { overflow-x: auto; }
table.results { border-collapse: collapse; width: 100%; font-size: 14px; }
.results th, .results td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.results thead th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.results .num { text-align: right; font-variant-numeric: tabular-nums; }
.next-card { padding: 18px; border: 1px dashed var(--line); border-radius: var(--r); display: grid; gap: 4px; }
.next-card p { margin: 0; } .next-title { font-weight: 700; font-size: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- title screen ---------- */
#title-screen { position: fixed; inset: 0; z-index: 50; background: var(--paper); overflow-y: auto; display: grid; place-items: center; padding: 24px 16px; }
.title-card { width: min(980px, 100%); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 36px; align-items: center; }
.title-card .scene { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.title-text { display: grid; gap: 16px; }
.title-text > * { margin: 0; }
.game-title { font-size: clamp(44px, 7vw, 84px); line-height: .92; letter-spacing: -0.045em; font-weight: 700; }
.game-title span { color: var(--signal); }
.title-text .lede { font-size: 18px; }
.title-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.title-actions .btn-primary { min-height: 48px; padding-inline: 22px; font-size: 15px; }
.fine { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
body.titled .topbar, body.titled .stage { visibility: hidden; }

/* ---------- settings ---------- */
#settings { position: fixed; z-index: 40; right: 16px; top: calc(var(--topbar) + 8px + env(safe-area-inset-top, 0px)); width: min(340px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(23,32,34,.12); padding: 16px; display: grid; gap: 14px; }
#settings h2 { margin: 0; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.set { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.set input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.set input[type=range] { accent-color: var(--accent); width: 130px; }
.set-note { display: block; font-size: 12px; color: var(--ink-2); line-height: 1.35; margin-top: 2px; }
.preview-tag { color: var(--signal); }
#rate-val { font-variant-numeric: tabular-nums; width: 3.5em; text-align: right; }


/* ---------- more scene materials ---------- */
.scene .panel-strip { fill: #DDE3E1; stroke: #9AA6A4; }
.scene .led-on { fill: #4CC27A; } .scene .led-off { fill: #9AA6A4; }
.scene .star { fill: #FFFFFF; }
.scene .dome { fill: #E3E8E6; stroke: #9AA6A4; } .scene .dome-slit { fill: #24343A; }
.scene .metal { fill: #B9C3C0; stroke: #6C7876; stroke-width: 1.2; } .scene .arm { transition: transform .8s; }
.scene .rack { fill: #3A4648; } .scene .rack-unit { fill: #4D5A5C; }
.scene .pipe { stroke: #9AA6A4; stroke-width: 4; fill: none; }
.scene .note-card { fill: #FFFFFF; stroke: #B9C3C0; } .scene .note-card.done { fill: var(--signal-soft); stroke: var(--signal); }
.scene .win-on { fill: var(--signal-glow); }

/* ---------- views ---------- */
body[data-view="map"] .stage, body[data-view="map"] #beats, body[data-view="map"] #beat-count, body[data-view="map"] .where { display: none; }
.brand { border: 0; background: none; padding: 0; cursor: pointer; font-family: var(--f-display); }
.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }

/* ---------- course map ---------- */
#map { padding: 28px 16px 64px; }
.map-wrap { max-width: 1120px; margin: 0 auto; display: grid; gap: 32px; }
.map-head { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; align-items: end; }
.map-head > div:first-child { display: grid; gap: 10px; max-width: 34em; } .map-head p, .map-head h1 { margin: 0; }
.map-title { font-size: clamp(38px, 6vw, 64px); line-height: .95; letter-spacing: -0.04em; font-weight: 700; }
.map-progress { display: flex; gap: 20px; align-items: center; }
.ring { --p: 0; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--signal) calc(var(--p) * 1%), var(--line-2) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--paper); }
.ring span { position: relative; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; } .ring small { font-size: 13px; }
.map-progress dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 4px 14px; font-size: 14px; }
.map-progress dt { color: var(--ink-2); } .map-progress dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.map-dash { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.dash-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.dash-card > * { margin: 0; }
.dash-card.next { background: var(--signal-soft); border-color: #F0DDB0; }
.dash-big { font: 18px/1.4 var(--f-read); }
.dash-card .btn { justify-self: start; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
ul.plain li { display: flex; justify-content: space-between; gap: 10px; } ul.plain li span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.plain .ok { color: var(--ok); } ul.plain .bad { color: var(--bad); } ul.plain .num { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.skills { display: flex; flex-wrap: wrap; gap: 6px; } .skills span { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.level-block { display: grid; gap: 10px; }
.level-title { margin: 0; font-size: 20px; letter-spacing: -0.01em; display: flex; gap: 12px; align-items: baseline; }
.level-title span { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--signal); }
.chapter-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.chapter-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.ch-no { font-size: 22px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.st-complete .ch-no, .st-mastered .ch-no { color: var(--signal); }
.ch-main { display: grid; gap: 2px; min-width: 0; } .ch-main p { margin: 0; }
.ch-name { font-weight: 700; font-size: 17px; } .ch-mod { font-size: 13px; color: var(--ink-2); } .ch-topics { font: 13px/1.4 var(--f-code); color: var(--ink-2); }
.ch-side { display: grid; justify-items: end; gap: 6px; text-align: right; }
.ch-status { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.st-mastered .ch-status { color: var(--signal); } .st-complete .ch-status { color: var(--ok); }
.pips { display: flex; gap: 3px; } .pips i { width: 8px; height: 8px; border-radius: 1px; background: var(--line); transform: rotate(45deg); } .pips i.on { background: var(--signal-glow); }
.st-locked { opacity: .62; } .st-locked .ch-side .fine { max-width: 22em; }

/* ---------- multi-file editor, lessons ---------- */
.file-tabs { display: flex; overflow-x: auto; background: var(--line-2); border-bottom: 1px solid var(--line); }
.file-tabs .file-tab { border: 0; border-right: 1px solid var(--line); border-bottom: 0; background: transparent; cursor: pointer; white-space: nowrap; }
.file-tabs .file-tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.file-tab small { font-family: var(--f-display); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--signal); }
.code-blocks { display: grid; gap: 12px; }
.note.illustrative { padding: 10px 12px; border-radius: var(--r); background: var(--accent-soft); color: var(--ink); font-size: 15px; }
.takeaways { margin: 0; padding-left: 18px; display: grid; gap: 6px; font: 16px/1.5 var(--f-read); }
.opts.wide { grid-template-columns: minmax(0, 1fr); }
.stdin textarea { font: 14px var(--f-code); padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); resize: vertical; min-width: 0; }
.dlg-end .row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 959px) {
  .map-dash { grid-template-columns: minmax(0, 1fr); }
  .chapter-row { grid-template-columns: 32px minmax(0, 1fr); }
  .ch-side { grid-column: 2; justify-items: start; text-align: left; }
}

/* ---------- phones and tablets ---------- */
@media (max-width: 959px) {
  html, body { height: auto; }
  .topbar { gap: 10px; }
  .where .ch, #beats { display: none; }
  #beat-count { margin-left: auto; }
  .chip { padding: 4px 8px; font-size: 11px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .stage { display: block; height: auto; }
  .scene-col { border-right: 0; border-bottom: 1px solid var(--line); }
  #dialogue { padding: 16px; }
  .dlg-text { font-size: 17.5px; }
  .work-col { overflow: visible; padding: 22px 16px 40px; }
  .title-card { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline li:nth-child(2)::after { display: none; }
  .opts, .diff { grid-template-columns: minmax(0, 1fr); }
  body[data-kind="mission"] .scene { aspect-ratio: 800 / 300; }
  body[data-kind="mission"] .scene svg { height: 100%; }
  .ide-tabs { display: grid; grid-template-columns: repeat(3, 1fr); position: sticky; top: calc(var(--topbar) + env(safe-area-inset-top, 0px)); z-index: 5; background: var(--paper); border-bottom: 1px solid var(--line); margin-inline: -16px; padding-inline: 16px; }
  .ide-tabs button { padding: 12px 0; border: 0; border-bottom: 2px solid transparent; background: none; font-weight: 600; color: var(--ink-2); }
  .ide-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
  .ide .panel { display: none; }
  .ide[data-tab="brief"] .brief, .ide[data-tab="code"] .code, .ide[data-tab="output"] .output { display: grid; }
  .ide[data-tab="output"] .output { display: block; }
  .keybar { display: flex; }
  .editor .cm-editor { max-height: none; }
  .toolbar .btn-quiet { padding-inline: 6px; }
}
@media (max-width: 420px) { .brand { font-size: 15px; } .where { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }