/* Photon Lab — dark lab-instrument theme. Single dark palette on purpose:
   glowing photons read best on black, and it projects with strong contrast. */
:root {
  --bg: #070a14;
  --panel: #0e1322;
  --panel-2: #141b2e;
  --line: #222b45;
  --line-strong: #33406a;
  --text: #e6ebf7;
  --muted: #8b95b3;
  --accent: #5ce1ff;
  --accent-ink: #04121a;
  --good: #4fd18a;
  --bad: #ff7a7a;
  --warn: #ffb547;
  --phi: #6f7a99;
  --ke: #4fd18a;
  --radius: 12px;
  --base: 16px;
  --sans: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --photon: var(--accent); /* current photon colour, set by app.js */
  color-scheme: dark;
}

html.projector { --base: 20px; }

* { box-sizing: border-box; }
html { font-size: var(--base); }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(92, 225, 255, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.45;
  overflow-x: hidden;
}

a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
b, strong { font-weight: 650; }
sub { font-size: 0.72em; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 20;
  background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px;
}
.skip-link:focus { top: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(7, 10, 20, 0.88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 8px 16px 0;
}
.topbar-row { display: flex; align-items: center; gap: 10px; max-width: 1280px; margin: 0 auto; }
.back-link {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  text-decoration: none; color: var(--muted); border: 1px solid var(--line);
}
.back-link:hover { color: var(--text); border-color: var(--line-strong); }
.wordmark { margin: 0; font-size: 1.05rem; letter-spacing: 0.02em; display: flex; align-items: center; gap: 8px; }
.wordmark-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent), 0 0 22px rgba(92, 225, 255, 0.5);
}
.version { font-family: var(--mono); font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.draft-pill {
  margin-left: auto; font-size: 0.72rem; color: var(--warn); border: 1px solid rgba(255, 181, 71, 0.5);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.tabs { display: flex; gap: 4px; max-width: 1280px; margin: 6px auto 0; overflow-x: auto; scrollbar-width: none; }
.tabs [role="tab"] {
  min-height: 42px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--muted); font-weight: 600; padding: 8px 12px; white-space: nowrap;
}
.tabs [role="tab"], .side-tabs [role="tab"] { position: relative; transition: color 0.15s ease; }
.tabs [role="tab"]::after, .side-tabs [role="tab"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -2px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.side-tabs [role="tab"]::after { bottom: -3px; height: 3px; left: 6px; right: 6px; }
.tabs [role="tab"][aria-selected="true"]::after, .side-tabs [role="tab"][aria-selected="true"]::after { transform: scaleX(1); box-shadow: 0 0 10px rgba(92, 225, 255, 0.6); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); }
.tabs [role="tab"]:hover { color: var(--text); }

/* ---------- buttons ---------- */
button, select, input { font: inherit; color: inherit; }
button {
  min-height: 44px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--panel-2);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.12s ease, box-shadow 0.2s ease;
}
@media (hover: hover) { button:hover:not(:disabled) { border-color: var(--accent); } }
button:active:not(:disabled) { transform: scale(0.97); }
/* Line icons (../assets/icons.svg): same stroke everywhere, sized to the text beside them. */
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:where(button:has(> .ic)), .back-link { display: inline-flex; align-items: center; justify-content: center; gap: 0.45em; }
button[hidden] { display: none !important; } /* author display rules would otherwise beat the hidden attribute */
.fire .ic { width: 1.3em; height: 1.3em; stroke-width: 2; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button[aria-pressed="true"] { background: rgba(92, 225, 255, 0.14); border-color: var(--accent); color: var(--accent); }
.ghost { background: transparent; }
.small { min-height: 36px; padding: 4px 10px; font-size: 0.85rem; }
.tiny { min-height: 30px; padding: 2px 8px; font-size: 0.78rem; border-radius: 7px; }
.fire {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700;
  padding-inline: 20px; box-shadow: 0 0 18px rgba(92, 225, 255, 0.35), 0 0 0 1px var(--photon);
}
.fire:hover:not(:disabled) { background: #8becff; }
/* Fire: a ring of the photon's colour leaves the button and the photon icon darts forward. */
.fire { position: relative; isolation: isolate; }
.fire.launch::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 2px solid var(--photon);
  pointer-events: none; animation: launch 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.fire.launch .ic { animation: dart 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes launch { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(1.12, 1.6); } }
@keyframes dart { 40% { transform: translateX(5px); } }
/* A chosen prediction pops once; a changed reading flashes once; a new result eases in. */
button[data-predict][aria-pressed="true"] { animation: pick 0.3s cubic-bezier(0.22, 1, 0.36, 1); box-shadow: 0 0 14px rgba(92, 225, 255, 0.25); }
@keyframes pick { 0% { transform: scale(0.94); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
.tick { animation: tick 0.6s ease-out; }
@keyframes tick { 0% { color: var(--accent); text-shadow: 0 0 10px rgba(92, 225, 255, 0.7); } 100% { text-shadow: none; } }
.verdict.fresh > * { animation: fresh 0.35s cubic-bezier(0.22, 1, 0.36, 1) both; }
.verdict.fresh > :nth-child(2) { animation-delay: 0.05s; }
.verdict.fresh > :nth-child(3) { animation-delay: 0.1s; }
@keyframes fresh { from { opacity: 0; transform: translateY(4px); } }
#share-copy.done .ic { animation: pick 0.3s cubic-bezier(0.22, 1, 0.36, 1); }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 14px 16px 40px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.workspace.side-collapsed { grid-template-columns: minmax(0, 1fr); }
.workspace.side-collapsed .side { display: none; }
.stage-col { min-width: 0; }
.stage {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background:
    linear-gradient(rgba(92, 225, 255, 0.045) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(92, 225, 255, 0.045) 1px, transparent 1px) 0 0 / 28px 28px,
    #05070f;
}
/* The side panel button sits in the stage's top-right corner, the same place on every page. */
.stage > .side-toggle { position: absolute; top: 5px; right: 8px; z-index: 2; min-height: 32px; padding: 2px 10px; }
.rule {
  margin: 0; padding: 8px 6.5rem 8px 12px; font-size: 0.85rem; color: var(--muted);
  border-bottom: 1px solid var(--line); background: rgba(14, 19, 34, 0.7);
}
.rule-key {
  display: inline-block; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); border: 1px solid rgba(92, 225, 255, 0.4); border-radius: 4px; padding: 0 5px; margin-right: 6px;
}
.formula { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; color: var(--text); font-weight: 600; }
.stage-canvas { display: block; width: 100%; height: clamp(300px, 56vh, 560px); }
.twin { display: grid; grid-template-columns: 1fr 1fr; }
.twin figure { margin: 0; min-width: 0; }
.twin figure + figure { border-left: 1px solid var(--line); }
.stage-canvas.square { height: clamp(300px, 56vh, 560px); }
figcaption { font-size: 0.72rem; color: var(--muted); padding: 0 10px 8px; }
.fig-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fig-row .tiny { min-height: 26px; }

.actionbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0 0;
}
.predict { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.predict-label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.predict button { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }
.fire-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.score { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }

.verdict {
  margin-top: 10px; padding: 12px 14px; border-radius: 10px; background: var(--panel);
  border: 1px solid var(--line); border-left: 4px solid var(--line-strong); min-height: 4.2em;
}
.verdict-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 2px; }
.verdict strong { display: block; font-size: 1.08rem; }
.verdict p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.verdict .tag { display: inline-block; font-family: var(--mono); font-size: 0.75rem; border-radius: 4px; padding: 1px 6px; }
.verdict .tag.right { background: rgba(79, 209, 138, 0.15); color: var(--good); }
.verdict .tag.wrong { background: rgba(255, 122, 122, 0.15); color: var(--bad); }
.verdict.good { border-left-color: var(--good); }
.verdict.good strong { color: var(--good); }
.verdict.bad { border-left-color: var(--bad); }
.verdict.bad strong { color: var(--bad); }
.verdict.warn { border-left-color: var(--warn); }
.verdict.warn strong { color: var(--warn); }
.verdict .tag.skip { background: rgba(255, 181, 71, 0.15); color: var(--warn); }
.verdict .budget {
  display: block; margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: #05070f;
  font-family: var(--mono); font-size: 0.82rem; color: var(--text); white-space: normal; overflow-wrap: anywhere;
}
.status {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 0; padding: 6px 12px;
  border-top: 1px solid var(--line); background: rgba(14, 19, 34, 0.7);
  font-family: var(--mono); font-size: 0.78rem; color: var(--text);
}
.status .illus { color: var(--muted); font-family: var(--sans); font-size: 0.72rem; }
.guide {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(92, 225, 255, 0.35);
  background: rgba(92, 225, 255, 0.06);
}
.guide-head { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.guide-step { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.guide-idea { margin: 6px 0 0; font-size: 0.88rem; color: var(--muted); }
.guide-expect { margin: 6px 0 0; font-size: 0.88rem; color: var(--warn); }
.guide-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.guide-list { display: grid; gap: 6px; }
.guide-start { text-align: left; min-height: 40px; font-size: 0.88rem; }
html.projector .score { display: none; }
/* The class can see a projected screen: keep teacher-only answers off it. */
html.projector .guide-expect { display: none; }
html.projector .field:has(#h-presets) { display: none; } /* the class can see the gaps there */
/* First visit cue: the prediction buttons glow until the first photon is fired (cleared by app.js). */
.predict.cue button[data-predict], .side-toggle.cue { animation: cue 1.8s ease-in-out infinite; }
@keyframes cue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(92, 225, 255, 0); }
  50% { box-shadow: 0 0 0 4px rgba(92, 225, 255, 0.35); }
}
.predict-label { color: var(--text); }

/* ---------- side panel ---------- */
/* Desktop: docked beside the stage and scrolls on its own. Narrow screens: slides in over the page. */
.side {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0;
  position: sticky; top: 104px; max-height: calc(100vh - 118px); display: flex; flex-direction: column;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.side-head h2 { margin: 0; font-size: 0.95rem; }
.side-body { padding: 14px; overflow-y: auto; overscroll-behavior: contain; }
.side-sec { border-top: 1px solid var(--line); padding: 4px 0 10px; }
.side-sec > summary {
  min-height: 42px; display: flex; align-items: center; font-weight: 600; font-size: 0.9rem; list-style-position: inside;
}
.side-sec > summary:hover { color: var(--accent); }
.side-sec > summary { list-style: none; }
.side-sec > summary::-webkit-details-marker { display: none; }
.side-sec > summary::before { content: '▸'; color: var(--muted); width: 1.1em; flex: none; }
.side-sec[open] > summary::before { content: '▾'; }
/* Side panel pages: tabs along the top of the panel, like bookmarks. */
.side-head { padding: 0 8px 0 6px; }
.side-tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.side-tabs [role="tab"] {
  min-height: 46px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 0.9rem; padding: 8px 10px; white-space: nowrap;
}
.side-tabs [role="tab"]:hover { color: var(--text); }
.side-tabs [role="tab"][aria-selected="true"] { color: var(--text); }
.side-page:not([hidden]) { animation: page-in 0.22s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(3px); } }
.side-page[hidden] { display: none; }
.page-sec + .page-sec { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.page-sec h3 { font-size: 0.95rem; margin: 0 0 8px; }
.task-setup { margin: 8px 0 2px; min-height: 38px; }
/* The running comparison, task or quiz demo, docked at the top of the Lessons page. */
.guide-dock .guide { display: block; max-height: none; margin: 0 0 14px; padding: 10px 12px; }
.guide-dock .guide[hidden] { display: none; }
.guide-dock .guide-actions { flex-wrap: wrap; margin-top: 8px; }
.mystery { padding: 10px 12px; border: 1px dashed rgba(201, 184, 232, 0.6); border-radius: 10px; }
.mystery .hint { margin: 0 0 6px; }
.mystery .inline-input { flex-wrap: wrap; }
.mystery-result { margin: 6px 0 0; font-size: 0.88rem; min-height: 1.3em; }
.mystery-result.right { color: var(--good); }
.mystery-result.wrong { color: var(--warn); }
.side-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.55); }
.teach { font-size: 0.86rem; color: var(--muted); }
.teach p { margin: 6px 0 4px; color: var(--text); }
.teach ol, .teach ul { margin: 0 0 8px; padding-left: 1.2em; }
.teach li { margin-bottom: 4px; }

/* ---------- teacher view ---------- */
/* Not security: teacher-only content is only hidden from the student view. */
:root:not([data-role="teacher"]) .teacher-only { display: none !important; }
#teacher-toggle[aria-pressed="true"] { color: var(--warn); border-color: rgba(255, 181, 71, 0.6); }
dialog {
  width: min(380px, calc(100vw - 32px)); padding: 18px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
dialog[open] { animation: dialog-in 0.24s cubic-bezier(0.22, 1, 0.36, 1); }
dialog[open]::backdrop { animation: backdrop-in 0.24s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes backdrop-in { from { opacity: 0; } }
/* Guide: how to use (everyone) + notes for teachers (teacher view). */
dialog.guide-dialog { width: min(760px, calc(100vw - 32px)); max-height: 86vh; padding: 0; display: none; flex-direction: column; }
dialog.guide-dialog[open] { display: flex; }
.guide-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.guide-dialog-head h2 { margin: 0; font-size: 1.1rem; }
.guide-dialog-body { padding: 14px 18px 18px; overflow-y: auto; font-size: 0.95rem; }
.guide-dialog-body h3 { margin: 18px 0 6px; font-size: 1rem; color: var(--warn); }
.guide-dialog-body ul { padding-left: 1.2em; color: var(--muted); font-size: 0.88rem; }
.guide-dialog-body li { margin-bottom: 6px; }
.guide-dialog-head h2 .version { font-size: 0.75rem; }
:root[data-role="teacher"] .student-only { display: none; }
/* Share: link + QR code. "Big QR" fills the screen so a class can scan it off the projector. */
dialog.share-dialog { width: min(640px, calc(100vw - 32px)); padding: 0; }
.share-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; padding: 16px 18px 18px; align-items: start; }
.share-qr { width: 200px; aspect-ratio: 1; background: #fff; border-radius: 8px; overflow: hidden; }
.share-qr svg { display: block; width: 100%; height: 100%; }
.share-lead { margin: 0 0 6px; }
.share-side label { margin-top: 8px; }
.share-side input[readonly] { font-size: 0.85rem; }
.share-side .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.share-side .check input { width: 20px; min-height: 20px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#share-status { min-height: 1.2em; margin: 8px 0 0; color: var(--good); }
dialog.share-dialog.big { width: min(96vw, 96vh); }
.share-dialog.big .share-body { grid-template-columns: 1fr; justify-items: center; }
/* Sized from the modal's own width (the browser caps a modal below 100vw), so the quiet zone is never cut. */
.share-dialog.big .share-qr { width: min(80vh, 100%); }
.share-dialog.big .share-side { width: 100%; }
.share-dialog.big .share-side > :not(.share-actions, #share-status) { display: none; }
#share-status.warn { color: var(--warn); }
@media (max-width: 600px) {
  .share-body { grid-template-columns: 1fr; justify-items: center; }
  .share-side { width: 100%; }
}
.guide-tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); }
.guide-tabs [role="tab"] { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); min-height: 40px; padding: 4px 12px; }
.guide-tabs [aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.guide-dialog-body h3:first-child { margin-top: 0; }
/* a miniature of the real screen, numbered to match the key beside it */
.map-row { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 16px; align-items: start; }
.map {
  display: grid; gap: 4px; aspect-ratio: 16 / 10; font-size: 0.72rem; color: var(--muted);
  grid-template-columns: 1fr 1fr 0.9fr; grid-template-rows: 1fr auto auto;
  grid-template-areas: "stage stage panel" "predict fire panel" "card card panel";
}
.map > div { position: relative; border: 1px solid var(--line-strong); border-radius: 6px; background: #05070f; padding: 4px 6px 4px 24px; display: flex; flex-direction: column; justify-content: center; }
.map i { position: absolute; left: 4px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 700 0.68rem/16px var(--sans); text-align: center; font-style: normal; }
.map-stage { grid-area: stage; }
.map-panel { grid-area: panel; justify-content: flex-start !important; padding-top: 6px !important; }
.map-panel i { top: 14px; }
.map-panel span { margin-top: 3px; padding: 1px 4px; border-radius: 4px; background: var(--panel); font-size: 0.66rem; }
.map-predict { grid-area: predict; }
.map-fire { grid-area: fire; color: var(--accent) !important; }
.map-card { grid-area: card; min-height: 2rem; }
.map-key { margin: 0; padding-left: 1.4em; font-size: 0.9rem; }
.map-key li { margin-bottom: 4px; }
.map-key li::marker { color: var(--accent); font-weight: 700; }
.map-key b { margin-right: 4px; }
/* a round as a strip of steps, each showing the real control it uses */
.flow { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; counter-reset: step; }
.flow li {
  counter-increment: step; position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 2px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.8rem; color: var(--muted);
}
.flow li + li::before { content: "›"; position: absolute; left: -7px; top: 22px; color: var(--accent); font-weight: 700; }
.flow b { color: var(--text); font-size: 0.92rem; }
.flow b::before { content: counter(step) ". "; color: var(--accent); }
.flow-ui { display: flex; gap: 3px; justify-content: center; align-items: center; min-height: 30px; flex-wrap: wrap; }
.mini { display: inline-block; padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); font-size: 0.72rem; white-space: nowrap; }
.chip { border-radius: 999px; }
.fire-chip { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.tag-good { color: var(--good); border-color: rgba(79, 209, 138, 0.5); }
.mini-slider { width: 58px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) 60%, var(--line-strong) 60%); position: relative; }
.mini-slider::after { content: ""; position: absolute; left: 60%; top: 50%; translate: -50% -50%; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }
.flow-again { font-size: 1.2rem; color: var(--accent); line-height: 1; }
.keys { margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; }
.tools { list-style: none; padding: 0 !important; color: var(--text) !important; font-size: 0.9rem !important; }
.tools li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.model-notes { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.model-notes summary { cursor: pointer; color: var(--warn); font-weight: 600; min-height: 32px; }
@media (max-width: 600px) {
  .map-row { grid-template-columns: 1fr; }
  .map { max-width: 16rem; }
  .flow { grid-template-columns: 1fr; }
  .flow li { flex-direction: row; justify-content: flex-start; text-align: left; gap: 8px; }
  .flow li + li::before { content: none; }
  .flow-ui { min-width: 6.5rem; justify-content: flex-start; }
}
dialog h2 { margin: 0 0 6px; }
dialog label { display: block; font-weight: 600; margin: 12px 0 6px; }
dialog input {
  width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: #05070f; font-family: var(--mono);
}
.form-error { min-height: 1.3em; margin: 6px 0 0; color: var(--bad); font-size: 0.85rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.big-readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.2rem, 1fr)); gap: 8px; margin-bottom: 14px; }
.big-readouts > div { background: #05070f; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.big-readouts .label { display: block; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.big-readouts .value { display: block; font-family: var(--mono); font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; }
.big-readouts .value.hidden-value { color: var(--muted); }
.big-readouts .sub { display: block; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }

.field { margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend, .field-title {
  display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; padding: 0;
}
.muted { color: var(--muted); font-weight: 400; }
output { font-family: var(--mono); font-weight: 400; font-size: 0.82rem; color: var(--accent); text-align: right; }
input[type="range"] { width: 100%; min-height: 34px; accent-color: var(--accent); }
.spectrum-hint {
  display: flex; justify-content: space-between; font-size: 0.68rem; padding: 1px 6px; border-radius: 4px;
  background: linear-gradient(90deg, #b48cff 0%, #b48cff 40%, #7b3fff 42.8%, #2952ff 48%, #1fd1ff 53%, #3dff6e 60%, #ffe53d 67%, #ff7a1a 74%, #ff2d2d 80%, #7a1d1d 86%, #3b1010 100%);
}
.spectrum-hint span { color: #fff; text-shadow: 0 1px 2px #000; }
.hint { font-size: 0.8rem; color: var(--muted); margin: 6px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 38px; padding: 5px 10px; font-size: 0.85rem; font-family: var(--mono); }
.inline-input { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); }
.inline-input input, select {
  min-height: 40px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: #05070f;
}
.inline-input input { width: 7em; font-family: var(--mono); }
select { width: 100%; }
.two-col { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.energy-bars { margin: 4px 0 12px; }
.bar-row { display: grid; grid-template-columns: 3.2em 1fr; align-items: center; gap: 8px; margin: 5px 0; font-size: 0.78rem; }
.bar-label { font-family: var(--mono); color: var(--muted); }
.bar-track { display: flex; height: 16px; background: #05070f; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.bar { height: 100%; transition: width 0.25s ease; }
.bar-photon { background: var(--accent); box-shadow: 0 0 10px rgba(92, 225, 255, 0.6); }
.bar-phi { background: var(--phi); }
.bar-phi.short { background: repeating-linear-gradient(45deg, var(--phi) 0 5px, transparent 5px 10px); }
.bar-ke { background: var(--ke); }
.bar-row.concealed .bar-track { opacity: 0.25; }
.bar-legend { font-size: 0.72rem; color: var(--muted); margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.key-phi { background: var(--phi); }
.key-ke { background: var(--ke); }

.readouts { margin: 0; font-size: 0.82rem; }
.readouts div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.readouts dt { color: var(--muted); }
.readouts dd { margin: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.hint-box { font-size: 0.85rem; }
.hint-box summary { cursor: pointer; color: var(--muted); min-height: 40px; display: flex; align-items: center; }
.hint-box summary:hover { color: var(--text); }
.table-wrap { overflow-x: auto; }
.gap-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.gap-table th, .gap-table td { padding: 5px 6px; text-align: left; border-top: 1px solid var(--line); }
.gap-table th { color: var(--muted); font-weight: 500; font-family: var(--sans); }
.gap-table tr.ionise td { color: var(--warn); }
.gap-table tr.match td { background: rgba(92, 225, 255, 0.12); color: var(--accent); }
/* Electron mode: the photon wavelength column means nothing for a colliding electron. */
.gap-table.no-lambda th:nth-child(3), .gap-table.no-lambda td:nth-child(3) { display: none; }
.chips.probe button { font-family: var(--sans); gap: 0.4em; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
h2 { font-size: 1rem; margin: 0 0 10px; }
h2.heading-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.graph { display: block; width: 100%; height: 220px; border-radius: 8px; background: #05070f; }
.graph.short { height: 120px; }
.emitted { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--mono); font-size: 0.75rem; }
.emitted li { padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-strong); display: flex; align-items: center; gap: 6px; }
.swatch { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }
.tasks { padding-left: 1.2em; margin: 0; font-size: 0.92rem; }
.tasks li { margin-bottom: 10px; }
.tasks p { margin: 0 0 2px; }
details summary { cursor: pointer; }
.tasks summary { color: var(--accent); font-size: 0.85rem; min-height: 32px; display: flex; align-items: center; }
.tasks details p { background: #05070f; border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; margin: 4px 0 0; color: var(--muted); }

/* ---------- quiz ---------- */
.recap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.recap > div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; font-size: 0.85rem; color: var(--muted); }
.recap .rule-key { justify-self: start; }
.recap .formula { font-size: 1.1rem; }
.quiz-card { max-width: 860px; }
.quiz-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.quiz-score { margin: 0; font-family: var(--mono); color: var(--accent); }
.quiz { padding-left: 1.4em; }
.quiz > li { margin: 0 0 22px; }
.quiz .question { margin: 0 0 8px; font-weight: 600; }
.quiz .statements { margin: 0 0 8px; padding-left: 0; list-style: none; color: var(--muted); }
.quiz .options { display: grid; gap: 6px; }
.quiz .options button { text-align: left; display: flex; gap: 10px; align-items: flex-start; background: #05070f; }
.quiz .options button .letter { font-family: var(--mono); font-weight: 700; min-width: 1.2em; color: var(--muted); }
.quiz .options button.correct { border-color: var(--good); background: rgba(79, 209, 138, 0.12); }
.quiz .options button.wrong { border-color: var(--bad); background: rgba(255, 122, 122, 0.12); }
.quiz .options button:disabled { opacity: 1; cursor: default; }
.quiz .explain { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: #05070f; border: 1px solid var(--line); font-size: 0.9rem; color: var(--muted); }
.quiz .explain strong { color: var(--text); }
.quiz .explain button { margin-top: 8px; min-height: 36px; font-size: 0.85rem; }


kbd {
  font-family: var(--mono); font-size: 0.85em; padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--line-strong); background: #05070f; color: var(--text);
}
/* A right prediction gets one short glow on the result card. */
.verdict.cheer { animation: cheer 0.9s ease-out; }
@keyframes cheer {
  from { box-shadow: 0 0 0 0 rgba(79, 209, 138, 0.55); }
  to { box-shadow: 0 0 0 14px rgba(79, 209, 138, 0); }
}

/* ---------- desktop: one screen ---------- */
/* Header, stage, action bar and result share exactly one viewport height, so the
   animation and its explanation are always on screen together (laptop to projector). */
@media (min-width: 901px) {
  :root { --base: clamp(16px, 0.4vw + 10.5px, 19px); --bar-h: 3.5rem; }
  html.projector { --base: clamp(19px, 0.6vw + 10.5px, 23px); }

  .topbar { display: flex; align-items: center; gap: 10px; height: var(--bar-h); padding: 0 20px; }
  .topbar-row { display: contents; }
  .back-link { order: 1; }
  .wordmark { order: 2; margin-right: 14px; }
  .tabs { order: 3; margin: 0 auto 0 0; align-self: stretch; max-width: none; }
  .tabs [role="tab"] { min-height: 100%; padding-inline: 14px; border-bottom-width: 3px; }
  .tabs [role="tab"]::after { bottom: -3px; height: 3px; }
  .draft-pill { order: 4; margin-left: 0; }
  #guide-toggle, #share-toggle { order: 5; }
  #projector-toggle { order: 6; }
  #teacher-toggle { order: 7; }

  main { max-width: none; padding: 14px 20px; }
  .workspace {
    grid-template-columns: minmax(0, 1fr) clamp(280px, 23vw, 420px); gap: 16px; align-items: stretch;
    height: min(calc(100vh - var(--bar-h) - 30px), 75vw);
    height: min(calc(100dvh - var(--bar-h) - 30px), 75vw);
  }
  .stage-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
  .stage { flex: 1 1 0; min-height: 11rem; display: flex; flex-direction: column; }
  .canvas-box { position: relative; flex: 1 1 0; min-height: 0; }
  .canvas-box > .stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
  .twin { flex: 1 1 0; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .twin figure { display: flex; flex-direction: column; min-height: 0; }
  .rule { font-size: 0.95rem; }
  .rule .formula { font-size: 1.1em; }

  /* One action row: predict on the left, fire in the middle, quiet extras on the right. */
  .actionbar { padding: 0; gap: 10px 16px; }
  .actionbar button { white-space: nowrap; }
  .fire { min-height: 50px; font-size: 1.05rem; padding-inline: 26px; }
  .score { white-space: nowrap; }
  .side-close { display: none; }

  .guide, .verdict { margin-top: 0; flex: none; }
  .guide { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: center; padding: 8px 12px; }
  .guide[hidden] { display: none; }
  .guide { max-height: 9.5rem; overflow-y: auto; }
  .guide > :not(.guide-actions) { grid-column: 1; }
  .guide-actions { grid-column: 2; grid-row: 1 / span 3; margin: 0; flex-wrap: nowrap; }
  .guide-actions button { min-height: 38px; }
  .guide-idea, .guide-expect { margin-top: 2px; }
  /* Fixed height, so the stage never changes size between the question and the result.
     Head | equation on the first row, a two-line explanation below: every result is written to fit. */
  .verdict {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); column-gap: 20px; row-gap: 4px;
    align-items: center; align-content: start; height: 8.4rem; overflow: hidden; padding: 12px 16px;
  }
  .verdict-head { grid-column: 1; grid-row: 1; }
  .verdict > p { grid-column: 1 / -1; grid-row: 2; }
  .verdict strong { font-size: 1.15rem; }
  .verdict .budget { grid-column: 2; grid-row: 1; margin: 0; max-width: min(34rem, 46vw); padding: 6px 10px; font-size: 0.88rem; border: 1px solid var(--line); }
  .quiz-card, .recap { max-width: 980px; margin-inline: auto; }

  .side { position: static; max-height: none; height: 100%; min-height: 0; }
  .side-body { flex: 1 1 auto; min-height: 0; }
}
/* Small desktops and tablets in landscape: shorter labels so the top bar and panel tabs fit one line. */
@media (min-width: 901px) and (max-width: 1199px) {
  .tab-long, .pill-long { display: none; }
  .topbar button { white-space: nowrap; }
  .tabs [role="tab"] { padding-inline: 10px; }
  .wordmark { margin-right: 6px; }
  .side-tabs [role="tab"] { padding: 8px 6px; font-size: 0.85rem; }
  /* The stage column is too narrow for head | equation side by side: stack head, reason, equation.
     Still a fixed height; scrolling inside the card is only a fallback so no text is ever cut off. */
  .verdict { grid-template-columns: minmax(0, 1fr); height: 9.4rem; overflow-y: auto; padding: 10px 14px; row-gap: 3px; }
  .verdict strong { font-size: 1rem; }
  .verdict > p { font-size: 0.86rem; line-height: 1.35; }
  .verdict .budget { grid-column: 1; grid-row: 3; justify-self: start; max-width: 100%; font-size: 0.8rem; padding: 3px 8px; }
}
/* Equation beside the explanation only when the stage column is wide enough for both. */
@media (min-width: 1200px) {
  .verdict { height: 7.4rem; }
  .verdict .budget { font-size: 0.95rem; padding: 8px 12px; }
  .stage { position: relative; }
  .status { position: absolute; top: 0; right: 3.4rem; border: 0; background: none; padding: 12px 12px 0; pointer-events: none; }
  .status > span:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .rule { padding: 10px 22rem 10px 12px; }
  /* With the panel hidden the toggle reads "⇤ Panel", so the note moves left to clear it. */
  .workspace.side-collapsed .status { right: 6.6rem; }
  .workspace.side-collapsed .rule { padding-right: 25.2rem; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  /* While a guided comparison is open, shorten the stage so stage, steps and result still fit one screen. */
  .stage-col:has(.guide:not([hidden])) .stage-canvas { height: clamp(220px, 34vh, 420px); }
  .workspace, .workspace.side-collapsed { grid-template-columns: 1fr; }
  .recap { grid-template-columns: 1fr; }
  .desktop-only { display: none !important; }
  .workspace .side, .workspace.side-collapsed .side {
    display: flex; position: fixed; top: 0; right: 0; bottom: 0; z-index: 30;
    width: min(380px, 90vw); max-height: none; border-radius: 0; border-width: 0 0 0 1px;
    transform: translateX(105%); visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }
  .workspace .side.open { transform: none; visibility: visible; transition: transform 0.25s ease; }
}
@media (max-width: 600px) {
  main { padding: 10px 12px 32px; }
  .topbar { padding: 6px 12px 0; }
  .draft-pill { font-size: 0.66rem; padding: 2px 8px; }
  .pill-long, .topbar .version { display: none; }
  .topbar-row { gap: 6px; }
  .wordmark { font-size: 0.98rem; }
  .tabs [role="tab"] { padding: 8px 9px; font-size: 0.88rem; }
  .stage-canvas { height: 250px; }
  .twin { grid-template-columns: 1fr; }
  .twin figure + figure { border-left: 0; border-top: 1px solid var(--line); }
  .stage-canvas.square { height: 190px; }
  .twin figure + figure .stage-canvas.square { height: 250px; }
  .tab-long { display: none; }
  /* Keep predict + fire reachable while the tall stage is on screen. */
  .actionbar {
    flex-direction: column; align-items: stretch;
    position: sticky; bottom: 0; z-index: 5; padding: 8px 0 10px;
    background: rgba(7, 10, 20, 0.94); backdrop-filter: blur(6px);
  }
  .predict-label { flex-basis: 100%; }
  .predict button { flex: 1 1 0; min-width: 0; padding: 6px 8px; font-size: 0.85rem; }
  .fire-row .fire { flex: 1; padding-inline: 12px; white-space: nowrap; }
}

/* Phones: the teacher button keeps its words and drops the icon, so the top bar fits 320 px. */
@media (max-width: 600px) { #teacher-toggle .ic { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .bar, button, .workspace .side, .workspace .side.open { transition: none; }
  .verdict.cheer, .predict.cue button[data-predict], .side-toggle.cue { animation: none; }
  button:active:not(:disabled) { transform: none; }
  .fire.launch::after, .fire.launch .ic, button[data-predict][aria-pressed="true"], .tick, .verdict.fresh > *,
  .side-page:not([hidden]), dialog[open], dialog[open]::backdrop, #share-copy.done .ic { animation: none; }
  .tabs [role="tab"]::after, .side-tabs [role="tab"]::after { transition: none; }
}
