/* Lab layout shared by every lab page: top bar, lesson list, stage, data cards, control panel.
   Desktop: a fixed-height three-column instrument. Below 1100px it becomes one scrolling column. */
body { --med: var(--c-glass); }
@media (min-width: 1100px) {
  body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
}

/* ---------- Top bar ---------- */
.bar { position: relative; flex: none; display: flex; align-items: center; gap: 24px; height: 58px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg); }
.crumb { display: flex; gap: 8px; font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.crumb span { color: var(--ink-4); }
.crumb a:hover { color: var(--ink); }
.crumb b { color: var(--ink); font-weight: 500; }
.stepper { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; }
.stepper button { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 6px; font-size: 13.5px; color: var(--ink-3); transition: color .15s, background-color .15s; }
.stepper button + button::before { content: ""; width: 20px; height: 1px; background: var(--line-2); margin: 0 6px 0 -10px; }
.stepper button:hover { color: var(--ink); }
.s-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 500 11px var(--font-mono); border: 1px solid var(--line-2); }
.stepper .done .s-n { border-color: var(--ok); color: var(--ok); }
.stepper [aria-current="step"] { color: var(--ink); font-weight: 500; }
.stepper [aria-current="step"] .s-n { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.bar > .btn { margin-left: auto; }

.app { flex: 1; min-height: 0; display: grid; grid-template-columns: 232px minmax(0, 1fr) 320px; }

/* ---------- Lesson rail ---------- */
.rail { display: flex; flex-direction: column; padding: 24px 14px 20px; border-right: 1px solid var(--line); overflow-y: auto; }
.rail > .eyebrow { padding: 0 10px 12px; }
.lessons { list-style: none; }
.lessons a { display: flex; gap: 12px; align-items: flex-start; padding: 9px 10px; border-radius: 7px; font-size: 13.5px; color: var(--ink-2); line-height: 1.4; transition: background-color .15s, color .15s; }
.lessons a:hover { background: var(--bg-2); color: var(--ink); }
.lessons small { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.lessons .n { width: 14px; flex: none; text-align: right; font: 12px/1.6 var(--font-mono); color: var(--ink-4); }
.lessons .done .n { color: var(--ok); }
.lessons .on a { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line), inset 2px 0 0 var(--c-waves); }
.lessons .on .n { color: var(--c-waves); }
.lessons .on small { font-weight: 400; }
.lessons .tag { margin-left: auto; }
.tag { font: 500 10.5px var(--font-mono); padding: 1px 5px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--ink-2); white-space: nowrap; }
.mastery { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }
.m-row { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--ink-2); }
.mastery p { margin-top: 14px; line-height: 1.5; }
.mastery b { color: var(--ink); font-weight: 500; }

/* ---------- Stage ---------- */
.center { display: flex; flex-direction: column; gap: 16px; padding: 20px; min-width: 0; min-height: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; font-weight: 500; }
.stage-head .eyebrow { margin-right: 8px; }
.head-read { display: flex; gap: 18px; font-size: 12.5px; color: var(--ink-3); }
.head-read i { font: italic 400 15px var(--font-display); }
.head-read b { font-weight: 500; color: var(--ink); }
.k-i { color: var(--c-ray); }
.k-r { color: var(--med); }
.stage-body { position: relative; flex: 1; min-height: 0; }
.stage-body svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.stage.dragging svg, .stage.dragging #handle { cursor: grabbing; }
.hint { position: absolute; right: 16px; top: 12px; font-size: 12px; color: var(--ink-3); pointer-events: none; }
.stage-tools { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.stage-tools #rec { margin-left: auto; }
.btn-ghost[aria-pressed="true"] { border-color: var(--ink); background: var(--bg-2); }

.fig .medium { fill: color-mix(in srgb, var(--med) 7%, transparent); transition: fill .3s; }
.fig .boundary { stroke: color-mix(in srgb, var(--med) 60%, transparent); stroke-width: 1.25; }
.fig .prot-c { fill: none; stroke: var(--line-2); }
.fig .prot-t { stroke: var(--ink-4); }
.fig .prot-T { stroke: var(--ink-3); }
.fig .ray-i { stroke: var(--c-ray); stroke-width: 2.25; }
.fig .ray-r { stroke: var(--med); stroke-width: 2.25; }
.fig .ray-refl { stroke: var(--c-ray); stroke-width: 1.25; opacity: .35; }
.fig .pulse { stroke: var(--surface); stroke-width: 2.25; }
.fig .wedge-i { fill: color-mix(in srgb, var(--c-ray) 10%, transparent); }
.fig .wedge-r { fill: color-mix(in srgb, var(--med) 10%, transparent); }
.fig .arc-i { fill: none; stroke: var(--c-ray); stroke-width: 1.25; }
.fig .arc-r { fill: none; stroke: var(--med); stroke-width: 1.25; }
.fig .t-i { fill: var(--c-ray); font-size: 12px; font-weight: 500; }
.fig .t-r { fill: var(--med); font-size: 12px; font-weight: 500; }
.fig .laser { fill: var(--ink); }
.fig .laser-tip { fill: var(--c-ray); }
.fig .handle { fill: transparent; stroke: var(--c-ray); stroke-dasharray: 2 3; cursor: grab; }
.fig .t-medium { font: 500 12px var(--font-sans); fill: var(--ink-2); }
.fig .t-medium tspan { font: 11px var(--font-mono); fill: var(--ink-3); }
.fig .wf-i { stroke: var(--c-ray); stroke-width: 1.25; }
.fig .wf-r { stroke: var(--med); stroke-width: 1.25; }

/* ---------- Data ---------- */
.data { flex: none; height: 250px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.data .card { padding: 14px 16px 12px; min-width: 0; display: flex; flex-direction: column; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; }
.card-h h2 { font-size: 13.5px; font-weight: 500; }
.card-h .num { font-size: 12px; color: var(--ink-3); }
.graph svg { flex: 1; min-height: 0; width: 100%; margin-top: 6px; }
.fig .fit { stroke: var(--ink-3); stroke-width: 1.25; stroke-dasharray: 5 4; transition: all .3s; }
.fig .pt { fill: var(--ink); }
.fig .cur { fill: var(--surface); stroke: var(--med); stroke-width: 2; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; font: 500 11px var(--font-sans); color: var(--ink-3); padding: 6px 4px 7px; border-bottom: 1px solid var(--line-2); }
td { padding: 6px 4px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.live td { color: var(--ink); font-weight: 500; }
tr.live td:first-child { box-shadow: inset 2px 0 0 var(--med); padding-left: 8px; }
tr.fresh td { animation: fresh 1.2s var(--ease); }
@keyframes fresh { from { background: color-mix(in srgb, var(--med) 16%, transparent); } }

/* ---------- Control panel ---------- */
.panel { border-left: 1px solid var(--line); overflow-y: auto; background: var(--bg); }
.group { padding: 16px 22px 18px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group > .eyebrow, .g-row { margin-bottom: 11px; }
.g-row { display: flex; justify-content: space-between; align-items: baseline; }
.g-row .eyebrow { margin: 0; }
.prediction { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.prediction b { color: var(--ink); font-weight: 500; }
.verdict { display: inline-block; margin-left: 6px; font: 500 11px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ok); padding: 1px 6px; border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); border-radius: 4px; vertical-align: 1px; }
.big { font: 500 22px var(--font-mono); letter-spacing: -0.02em; }
.rng { position: relative; --c-pos: 49%; }
.rng .crit { position: absolute; left: calc(8px + (100% - 16px) * var(--c-pos) / 100%); top: 4px; width: 1px; height: 14px; background: var(--red); pointer-events: none; }
.scale { position: relative; display: flex; justify-content: space-between; margin-top: 2px; font-size: 11px; color: var(--ink-3); }
.scale .cl { position: absolute; left: calc(8px + (100% - 16px) * var(--c-pos) / 100%); transform: translateX(-50%); color: var(--red); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 13.5px; color: var(--ink-2); }
.checks label { display: flex; gap: 9px; align-items: center; cursor: pointer; }
.checks input { -webkit-appearance: none; appearance: none; width: 15px; height: 15px; margin: 0; border: 1px solid var(--line-2); border-radius: 4px; display: grid; place-items: center; cursor: pointer; transition: background-color .15s, border-color .15s; }
.checks input::after { content: ""; width: 7px; height: 4px; border-left: 1.5px solid var(--bg); border-bottom: 1.5px solid var(--bg); transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.checks input:checked { background: var(--ink); border-color: var(--ink); }
.checks input:checked::after { opacity: 1; }
.formula { font: 400 26px/1.2 var(--font-display); margin-bottom: 6px; }
.formula .k-i, .formula .k-r { font-style: italic; }
.subst { font-size: 12.5px; line-height: 1.75; color: var(--ink-2); }
.subst b { font-weight: 500; color: var(--ink); }
.facts-dl { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-2); font-size: 13px; }
.facts-dl dt { color: var(--ink-2); }
.facts-dl dd { text-align: right; font-size: 12.5px; font-weight: 500; }
.marks ul { list-style: none; display: grid; gap: 6px; }
.marks li { display: flex; gap: 10px; font-size: 13.5px; color: var(--ink-3); }
.marks li::before { content: ""; flex: none; width: 13px; height: 13px; margin-top: 4px; border-radius: 50%; border: 1px solid var(--ink-4); }
.marks li.got { color: var(--ink); }
.marks li.got::before { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 3px var(--bg); }
.ask { display: flex; justify-content: space-between; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-size: 13px; color: var(--ink-3); background: var(--surface); cursor: text; transition: border-color .15s; }
.ask:hover { border-color: var(--ink-4); }
.ask kbd { font: 11px var(--font-mono); }

/* ---------- Narrow screens: one scrolling column ---------- */
@media (max-width: 1099px) {
  .bar { flex-wrap: wrap; height: auto; padding: 12px 20px; gap: 10px 16px; }
  .stepper { position: static; transform: none; order: 5; width: 100%; justify-content: center; padding-top: 4px; }
  .crumb { display: none; }
  .app { display: flex; flex-direction: column; }
  .center { order: 1; padding: 16px; }
  .panel { order: 2; border: 0; border-top: 1px solid var(--line); }
  .rail { order: 3; border: 0; border-top: 1px solid var(--line); padding: 20px 16px 32px; }
  .stage-body { flex: none; aspect-ratio: 800 / 520; }
  .data { height: auto; grid-template-columns: 1fr; }
  .graph svg { flex: none; height: auto; }
  .hint { display: none; }
}
@media (max-width: 560px) {
  .bar .btn { display: none; }
  .stepper button { padding: 6px 6px; font-size: 13px; }
  .stepper button + button::before { width: 12px; margin-left: -4px; }
  .stage-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .stage-tools { flex-wrap: wrap; }
  .group { padding: 16px 20px; }
  /* the stage scales to ~45%, so its labels are drawn larger to stay legible */
  .stage .fig text { font-size: 19px; }
  .stage .fig .t-i, .stage .fig .t-r { font-size: 22px; }
  .stage .fig .t-medium, .stage .fig .t-medium tspan { font-size: 20px; }
}
