/* MRISim browser edition — clinical near-black + medical cyan. Palette retuned to the
   shared "A+C" design system (see theme.css); these vars drive the simulator + splash + tour. */
:root {
  --canvas: #07090c; --panel: #10151b; --raised: #141b23; --header: #0b0f14;
  --chip: #0b0f14; --border: #1e262f; --border-hi: #2a3441;
  --text: #e8edf3; --text-dim: #8b97a6; --text-faint: #5f6b78;
  --accent: #5db0ef; --accent-hi: #7cc0f4; --accent-ink: #04121f;
  /* Sans for prose/labels; a monospace for numeric readouts — scan parameters, metrics
     and timers, the way a real scanner console / DICOM overlay renders them (tabular). */
  --font-sans: "SF Pro Text", "Segoe UI", "Helvetica Neue", Inter, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
/* The [hidden] attribute must always win over element display rules below
   (e.g. #intro/#app/#wrapB/#scoutwrap set display, which would otherwise keep a
   hidden element laid out and intercepting clicks). */
[hidden] { display: none !important; }
/* Screen-reader-only: present to assistive tech, invisible on screen. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas); color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
}

/* Splash */
#splash {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: var(--canvas);
}
.splash-card { text-align: center; width: min(440px, 88vw); }
.splash-card h1 { margin: 14px 0 6px; font-size: 30px; letter-spacing: .5px; }
.splash-card .logo {
  width: 104px; height: 104px; margin: 0 auto 4px; display: block;
  object-fit: contain;
}
#splash-status { color: var(--text-dim); min-height: 1.2em; }
.splash-note { color: var(--text-faint); font-size: 11px; margin-top: 18px; }
.bar { height: 6px; background: #1c2027; border-radius: 2px; overflow: hidden; margin: 12px 0; }
#splash-bar { height: 100%; width: 5%; background: var(--accent); transition: width .3s; }

/* Top bar */
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px;
  background: var(--header); border-bottom: 1px solid #1b222a;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; }
.logo-sm {
  width: 30px; height: 30px; object-fit: contain; display: block;
}
.tag { color: var(--text-faint); font-size: 11px; }
.topchips { display: flex; gap: 18px; margin-left: auto; }
.chip { line-height: 1.2; }
.chip i { display: block; color: var(--text-faint); font-size: 8px; font-style: normal; font-weight: 700; letter-spacing: .04em; }
.chip b { color: var(--accent-hi); font-size: 13px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ghlink { color: var(--text-dim); text-decoration: none; font-size: 13px; }
.ghlink:hover { color: var(--accent-hi); }
/* Protocol-planning call-to-action — a flagship workflow, so it stands out. */
.protocol-cta {
  color: var(--accent-ink); background: var(--accent);
  padding: 4px 10px; border-radius: 2px; font-weight: 600;
}
.protocol-cta:hover { color: var(--accent-ink); background: var(--accent-hi); }

/* Layout */
#app { display: grid; grid-template-columns: 270px 1fr 230px; gap: 10px; padding: 10px; height: calc(100% - 52px); }
.panel { background: var(--panel); border-radius: 2px; padding: 12px; overflow-y: auto; }
.group { border-top: 1px solid #1b222a; padding: 8px 0; }
.group h2 { font-size: 11px; letter-spacing: .6px; color: var(--text-dim); text-transform: uppercase; font-weight: 600; margin: 0; }

/* Collapsible control groups: the <summary> is the clickable header with a chevron. */
details.group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; padding: 2px 0 8px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary h2 { flex: 1; }
details.group > summary::after {
  content: "▸"; color: var(--text-dim); font-size: 10px; margin-left: 6px; transition: transform .15s ease;
}
details.group[open] > summary::after { transform: rotate(90deg); }
details.group > summary:hover h2 { color: var(--text); }
details.group > summary:hover::after { color: var(--accent-hi); }
details.group[data-sec="protocol"] { border-top: none; padding-top: 0; }

/* Control search/filter — a sticky finder at the top of the panel. */
.ctrl-search { position: sticky; top: 0; z-index: 5; background: var(--panel); padding: 0 0 8px; }
#ctrl-find {
  width: 100%; box-sizing: border-box; padding: 7px 26px 7px 10px;
  background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 2px; font-size: 12px;
}
#ctrl-find:focus { border-color: var(--accent); }
#ctrl-find-x {
  position: absolute; right: 6px; top: 5px; width: 22px; height: 26px; line-height: 24px;
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px;
}
#ctrl-find-x:hover { color: var(--text); }
.ctrl-find-empty { color: var(--text-dim); margin: 2px 0 8px; }
@media (max-width: 920px) { .ctrl-search { position: static; } }

label { display: block; color: var(--text-dim); font-size: 11px; margin: 11px 0 0; }
label.check { display: flex; align-items: center; gap: 8px; color: #c4cad2; font-size: 12px; cursor: pointer; }
output { float: right; color: var(--text); font-weight: 700; }

/* Editable numeric value paired with a slider — type or arrow-key an exact value. */
.numval {
  float: right; width: 58px; margin: 0; padding: 1px 5px; text-align: right;
  background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 2px;
  font-weight: 700; font-size: 12px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.numval:focus { border-color: var(--accent); }
.numval::-webkit-outer-spin-button, .numval::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select, input[type=range] { width: 100%; margin-top: 5px; }
select {
  background: var(--raised); color: var(--text); border: 1px solid var(--border);
  border-radius: 2px; padding: 6px 8px;
}
select:focus { border-color: var(--accent); }
/* Suppress the default outline only for pointer focus — keyboard focus keeps the visible
   ring (via the :focus-visible rule below), which the id/class specificity was overriding. */
#ctrl-find:focus:not(:focus-visible), .numval:focus:not(:focus-visible),
select:focus:not(:focus-visible) { outline: none; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }

/* Sliders: a custom, larger thumb so they're easy to grab (mouse and touch) and
   keyboard-operable with a clear focus ring. */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; margin-top: 6px; height: 22px; background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track { height: 5px; border-radius: 2px; background: var(--border); }
input[type=range]::-moz-range-track { height: 5px; border-radius: 2px; background: var(--border); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -8px;
  width: 20px; height: 20px; border-radius: 2px; background: var(--accent); border: 2px solid #0b0f14;
}
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 2px; background: var(--accent); border: 2px solid #0b0f14;
}
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent-hi); }
input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--accent-hi); }

/* Visible keyboard focus on every interactive control (mouse clicks stay clean). */
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-hi); outline-offset: 2px; border-radius: 2px;
}

/* Touch devices: enlarge the hit targets (thumb, checkboxes, buttons). */
@media (pointer: coarse) {
  input[type=range] { height: 34px; }
  input[type=range]::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -12px; }
  input[type=range]::-moz-range-thumb { width: 28px; height: 28px; }
  input[type=checkbox] { width: 22px; height: 22px; }
  .numval { min-height: 32px; width: 66px; }
  .radios button, .btnrow button, select, #measure-clear, .lp-btns button { min-height: 42px; }
  label.check { padding: 4px 0; }
  .lesson-item { padding: 14px 13px; }
}

.radios { display: flex; gap: 5px; margin-top: 5px; }
.radios button {
  flex: 1; background: var(--raised); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 2px; padding: 6px 0; font-size: 11px; font-weight: 700; cursor: pointer;
}
.radios button.on { background: #142231; color: var(--accent-hi); border-color: var(--accent); }

/* Viewport */
.viewport { display: grid; grid-template-rows: 1fr auto auto; gap: 10px; min-width: 0; }
/* Image + vertical slice rail share the top (1fr) row. */
.image-row { display: flex; gap: 8px; min-height: 0; min-width: 0; }
.image-row .images { flex: 1; min-width: 0; }
.slice-rail {
  /* The rail column stretches to the row (image) height via the flex line's
     cross-size; the input is then absolutely positioned to fill it (top/bottom
     give the vertical range a *definite* height, which a percentage / flex-stretch
     does not on a range input). Absolute positioning keeps the input out of flow,
     so it can never grow the row or overlap/intercept the image. */
  position: relative; flex: none; width: 30px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 2px;
}
.slice-rail-input {
  /* Vertical range with the maximum (superior slice) at the top, so dragging up
     scrolls "up" through the stack. writing-mode is the modern path; slider-vertical
     is the Safari/older-Chrome fallback. Height is an explicit length (a 70vh CSS
     fallback, refined to the image area in JS) — a vertical range ignores percentage
     / flex-stretch heights. Absolute → out of flow, so it can't grow the row or
     overlap the image. */
  position: absolute; top: 8px; left: 0; right: 0; margin: 0 auto;
  -webkit-appearance: slider-vertical; appearance: slider-vertical;
  writing-mode: vertical-lr; direction: rtl;
  width: 22px; height: 280px; cursor: ns-resize; accent-color: var(--accent);
}
.slice-rail-input::-webkit-slider-runnable-track { width: 5px; height: auto; background: var(--border); border-radius: 2px; }
.slice-rail-input::-webkit-slider-thumb { -webkit-appearance: auto; margin: 0; width: auto; height: auto; border: none; background: initial; box-shadow: none; }
.slice-rail-input::-moz-range-track { width: 5px; height: auto; background: var(--border); border-radius: 2px; }
.slice-rail-input::-moz-range-thumb { width: 16px; height: 16px; }
@media (pointer: coarse) {
  .slice-rail { width: 42px; }
  .slice-rail-input { width: 32px; }
}
.scoutwrap {
  background: var(--canvas); border: 1px solid var(--border); border-radius: 2px;
  display: grid; place-items: center; overflow: hidden;
  /* Size to the localizer's natural height (capped) rather than a fixed box: a
     percentage height on the image is unreliable inside this grid row and let the
     image overflow a fixed box, clipping the localizer to its top half. */
  height: auto; max-height: 60vh;
}
/* Full-width, natural height: the element equals the displayed image (no
   letterbox), so the scout-drag math in app.js (imgFraction) maps exactly, and
   the whole localizer is visible rather than clipped to its top half. */
#scoutImage { display: block; width: 100%; height: auto; }
.images { display: flex; gap: 10px; min-height: 0; }
.images .imgwrap { flex: 1; min-width: 0; }
.imgwrap, .curvewrap {
  position: relative;
  background: var(--canvas); border: 1px solid var(--border); border-radius: 2px;
  display: grid; place-items: center; overflow: hidden;
}
.imgwrap { min-height: 0; }
/* The curve panel fills the viewport width (it was letterboxed small in a fixed
   220px box); a wide figure keeps it short enough not to crowd the image. */
.curvewrap { padding: 4px; }
/* touch-action:none lets a finger drag window/level, the scout and measurements
   without the browser hijacking the gesture to scroll/zoom the page. */
#mainImage { max-width: 100%; max-height: 100%; image-rendering: auto; cursor: ns-resize;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
#scoutImage { touch-action: none; user-select: none; -webkit-user-drag: none; }
/* On-image measurement overlay (ruler / ROI). Drawn in wrap-pixel coords; never
   intercepts pointer events so the image keeps receiving the drag. */
#measure-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
#measure-svg .m-line { stroke: #ffd24a; stroke-width: 1.6; }
#measure-svg .m-end { fill: #ffd24a; }
#measure-svg .m-roi { fill: rgba(255, 210, 74, 0.12); stroke: #ffd24a; stroke-width: 1.6; }
.imgwrap.measuring #mainImage { cursor: crosshair; }
#measure-clear { margin-top: 6px; background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 2px; padding: 5px 12px; font-weight: 600; cursor: pointer; }
#measure-clear:hover { border-color: var(--accent); }
#measure-readout b { color: var(--accent-hi); }
#mainImageB { max-width: 100%; max-height: 100%; }
#curveImage, #cmapImage, #psdImage { width: 100%; height: auto; display: block; }
/* k-space is square: centre it in a dark panel, capped so it doesn't dominate. */
.kspacewrap {
  background: var(--canvas); border: 1px solid var(--border); border-radius: 2px;
  display: grid; place-items: center; padding: 4px; overflow: hidden;
}
#kspaceImage, #b0mapImage, #gfactorImage { display: block; height: auto; max-width: 100%; max-height: 320px; }
/* 3-D reconstruction panels: triplanar MPR grid + a single MIP/oblique view. */
.reconwrap { background: var(--canvas); border: 1px solid var(--border); border-radius: 2px; padding: 6px; }
/* align-items:start so a thin reformat keeps its true (aspect-derived) height
   instead of being stretched to the tallest panel's row height. */
.reconwrap { position: relative; }
/* Measure overlay positioned over the active recon panel during a drag. */
#recon-measure-svg { position: absolute; pointer-events: none; left: 0; top: 0; width: 0; height: 0; overflow: visible; }
.reconwrap.measuring .recon-tri img:not(#reconOverview) { cursor: crosshair; }
.recon-tri { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; }
.recon-tri img { width: 100%; height: auto; display: block; background: var(--canvas); border-radius: 2px; cursor: crosshair; }
/* The 3D MIP overview is a reference, not a cross panel — no click-to-navigate. */
.recon-tri #reconOverview { cursor: default; }
.recon-single { display: grid; place-items: center; }
.recon-single img { display: block; height: auto; max-width: 100%; max-height: 56vh; }
.recon-modectl { margin-top: 2px; }
@media (max-width: 560px) { .recon-tri { grid-template-columns: 1fr; } }
.mathwrap { background: var(--canvas); border: 1px solid var(--border); border-radius: 2px; padding: 12px 14px; }
.mathbox { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; line-height: 1.7; color: var(--text); }
.mathbox .m-tissue { color: var(--text-dim); font-size: 11px; margin-bottom: 4px; }
.mathbox .m-eq { color: var(--accent-hi); }
.mathbox .m-sub { color: var(--text); }
.mathbox .m-res { margin-top: 4px; }
.mathbox .m-res b { color: var(--accent-hi); }
.mathbox sup { font-size: 0.78em; }
.abtag {
  position: absolute; top: 7px; left: 8px; z-index: 2; font-weight: 800; font-size: 11px;
  color: var(--accent-ink); background: var(--accent-hi); border-radius: 2px; padding: 1px 7px;
}
/* Compare-mode caption: the extras the image doesn't bake in (pathology / +Gd).
   Centred just below the top "A" orientation letter — the one edge zone clear of
   the baked corner annotations (title top-left, region top-right, W/L + FOV + the
   "P" letter along the bottom). Usually empty, so the overlay hides entirely. */
.ab-caption {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  z-index: 2; max-width: calc(100% - 130px); text-align: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  font-weight: 700; font-size: 11px; color: var(--accent-hi);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); pointer-events: none;
}
.probe {
  position: absolute; left: 8px; bottom: 8px; z-index: 3; pointer-events: none;
  background: rgba(5, 8, 11, 0.74); color: var(--accent-hi);
  border: 1px solid var(--border); border-radius: 2px; padding: 3px 9px;
  font-size: 11px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Buttons */
.btnrow { display: flex; gap: 6px; margin-top: 8px; }
.btnrow button {
  flex: 1; background: var(--raised); color: var(--text); border: 1px solid var(--border);
  border-radius: 2px; padding: 6px 4px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.btnrow button:hover { border-color: var(--border-hi); }
.btnrow button.on { background: #142231; color: var(--accent-hi); border-color: var(--accent); }

/* Metrics */
#metrics table { width: 100%; border-collapse: collapse; }
#metrics td { padding: 7px 4px; border-bottom: 1px solid #1b222a; font-size: 12px; }
#metrics td:first-child { color: var(--text-dim); }
#metrics td:last-child { text-align: right; color: var(--accent-hi); font-weight: 700; }
.hint { color: var(--text-faint); font-size: 11px; margin-top: 12px; min-height: 1em; }
.busy #mainImage { opacity: .55; transition: opacity .1s; }

/* Intro / onboarding modal */
#intro, #lesson-picker, #curriculum {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(3, 5, 8, 0.72); padding: 16px;
}
/* Curriculum: progress bar, module cards, completion ticks. */
.cur-progress { height: 7px; background: var(--raised); border-radius: 2px; overflow: hidden; margin: 4px 0 6px; }
.cur-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
#curriculum-list { flex: 1; min-height: 0; overflow-y: auto; margin: 6px 0 12px; }
.cur-module { border-top: 1px solid var(--border); padding: 9px 0 4px; }
.cur-module:first-child { border-top: none; }
.cur-module-h { display: flex; justify-content: space-between; align-items: baseline; color: var(--accent-hi); font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.cur-module-h .cur-count { color: var(--text-faint); font-weight: 600; font-size: 11px; }
.cur-lesson { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; background: none; border: none; color: #c4cad2; font-size: 12px; padding: 5px 6px; border-radius: 2px; cursor: pointer; }
.cur-lesson:hover { background: var(--raised); color: var(--text); }
.cur-lesson .tick { flex: none; width: 16px; height: 16px; border-radius: 2px; border: 1px solid var(--border-hi); display: grid; place-items: center; font-size: 10px; color: var(--canvas); }
.cur-lesson.done .tick { background: var(--accent); border-color: var(--accent); }
.cur-lesson.done { color: var(--text-faint); }
.cur-actions { display: flex; gap: 8px; align-items: center; }
.cur-actions #curriculum-start { background: var(--accent); color: var(--accent-ink); border: none; border-radius: 2px; padding: 8px 16px; font-weight: 800; cursor: pointer; }
.cur-actions .cur-reset { margin-left: auto; background: none; border: 1px solid var(--border); color: var(--text-faint); border-radius: 2px; padding: 7px 11px; cursor: pointer; font-size: 11px; }
.lesson-cur { color: var(--accent-hi); font-size: 11px; font-weight: 700; margin: 0 0 6px; }
.intro-card {
  position: relative; width: min(520px, 94vw); background: var(--panel);
  border: 1px solid var(--border-hi); border-radius: 2px; padding: 22px 24px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  /* Never taller than the viewport — the body scrolls while the title, corner ✕
     and footer button stay pinned (so long dialogs don't lose their controls). */
  display: flex; flex-direction: column; max-height: 90vh; overflow: hidden;
}
.intro-body { flex: 1; min-height: 0; overflow-y: auto; }
.intro-card h2 { padding-right: 30px; }   /* leave room for the corner ✕ */
.intro-card h2 { margin: 0 0 2px; font-size: 22px; }
.intro-sub { color: var(--text-dim); margin: 0 0 14px; }
.intro-card ul { margin: 0 0 18px; padding-left: 18px; }
.intro-card li { margin: 9px 0; color: #c4cad2; line-height: 1.45; }
.intro-card b { color: var(--accent-hi); font-weight: 700; }
.intro-note {
  color: var(--text-faint); font-size: 12px; line-height: 1.45;
  border-top: 1px solid var(--border); padding-top: 12px; margin: 0 0 16px;
}
.intro-note a, .splash-note a { color: var(--accent-hi); }
kbd {
  background: var(--raised); border: 1px solid var(--border-hi); border-bottom-width: 2px;
  border-radius: 2px; padding: 0 6px; font-size: 11px; font-family: inherit; color: var(--text);
}
.intro-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
#intro-tour {
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 2px; padding: 9px 18px; font-weight: 700; font-size: 13px; cursor: pointer;
}
#intro-tour:hover { background: var(--accent-hi); }
#intro-ok {
  background: var(--raised); color: var(--text); border: 1px solid var(--border-hi);
  border-radius: 2px; padding: 9px 16px; font-weight: 600; font-size: 13px; cursor: pointer;
}
#intro-ok:hover { border-color: var(--accent); }

/* Guided feature tour — spotlight coachmarks over the real controls. */
#tour { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#tour-spot {
  position: absolute; border-radius: 2px; border: 2px solid var(--accent-hi);
  box-shadow: 0 0 0 9999px rgba(2, 6, 12, 0.62);
  transition: left .2s, top .2s, width .2s, height .2s; pointer-events: none;
}
#tour-pop {
  position: absolute; max-width: 330px; pointer-events: auto;
  background: var(--panel); border: 1px solid var(--border-hi); border-radius: 2px;
  padding: 13px 15px; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
}
#tour-pop h3 { margin: 0 0 6px; font-size: 13px; color: var(--accent-hi); }
#tour-pop p { margin: 0 0 11px; font-size: 12.5px; color: var(--text); line-height: 1.5; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#tour-progress { font-size: 11px; color: var(--text-dim); }
.tour-btns { display: flex; gap: 6px; }
.tour-btns button {
  background: var(--raised); color: var(--text); border: 1px solid var(--border);
  border-radius: 2px; padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.tour-btns button:hover { border-color: var(--border-hi); }
#tour-prev:disabled { opacity: .4; cursor: default; }
#tour-next { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
#help {
  background: var(--raised); border: 1px solid var(--border); color: var(--text-dim);
  width: 26px; height: 26px; border-radius: 2px; font-weight: 800; cursor: pointer; padding: 0;
}
#help:hover { color: var(--accent-hi); border-color: var(--accent); }
#lessons-btn, #curriculum-btn { background: var(--raised); border: 1px solid var(--border); border-radius: 2px; padding: 4px 12px; cursor: pointer; }
#lessons-btn:hover { color: var(--accent-hi); border-color: var(--accent); }

/* Lesson picker: a height-capped card whose list scrolls internally, with a
   header (title) and footer (Close) that stay put, plus a corner ✕. */
.lesson-card { position: relative; display: flex; flex-direction: column; max-height: 88vh; overflow: hidden; }
.lesson-card h2, .lesson-card .intro-sub { flex: none; }
.lesson-card #lesson-picker-close { flex: none; align-self: flex-start; margin-top: 14px; }
.dialog-x {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  width: 30px; height: 30px; border-radius: 2px; padding: 0; line-height: 1;
  background: var(--raised); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 15px; font-weight: 800; cursor: pointer;
}
.dialog-x:hover { color: var(--accent-hi); border-color: var(--accent); }

/* Lesson picker list */
#lesson-list { display: grid; gap: 8px; margin: 4px 0 0; flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
.lesson-item {
  text-align: left; background: var(--raised); border: 1px solid var(--border); border-radius: 2px;
  padding: 11px 13px; cursor: pointer; color: var(--text);
}
.lesson-item:hover { border-color: var(--accent); }
.lesson-item b { display: block; color: var(--accent-hi); margin-bottom: 2px; }
.lesson-item span { color: var(--text-dim); font-size: 12px; }
.lesson-item.beginner { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 8%, var(--raised)); }
.lesson-section { margin: 10px 2px 2px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.lesson-section:first-child { margin-top: 0; }
#lesson-picker-close { background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 2px; padding: 8px 16px; font-weight: 700; cursor: pointer; }

/* Active-lesson panel */
#lesson-panel {
  position: fixed; left: 16px; bottom: 16px; z-index: 40; width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--accent); border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); padding: 13px 15px;
  /* Cap to the viewport and scroll the step text, so a long step on a short
     screen doesn't push the panel (or its Back/Next buttons) off-screen. */
  display: flex; flex-direction: column; max-height: calc(100vh - 32px);
}
.lp-head, .lp-foot { flex: none; }
#lesson-step { overflow-y: auto; }
.lp-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; color: var(--accent-hi); font-size: 14px; }
.lp-head button { background: none; border: none; color: var(--text-dim); font-size: 15px; cursor: pointer; }
#lesson-step { color: #c4cad2; font-size: 13px; line-height: 1.5; margin: 9px 0 12px; }
/* Reading/concept step (no simulator image to examine) — a small eyebrow so it
   reads as a reading card rather than a "look at the scan" instruction. */
#lesson-panel.reading #lesson-step::before {
  content: "Reading"; display: block; color: var(--text-faint);
  font-size: 10px; letter-spacing: 0.8px; text-transform: uppercase; margin-bottom: 6px;
}
.lp-foot { display: flex; align-items: center; justify-content: space-between; }
#lesson-progress { color: var(--text-faint); font-size: 11px; }
.lp-btns button { background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 2px; padding: 6px 12px; font-weight: 700; cursor: pointer; margin-left: 6px; }
.lp-btns button:hover:not(:disabled) { border-color: var(--accent); }
.lp-btns button:disabled { opacity: 0.4; cursor: default; }

/* Responsive — stack to a single column with the image first on narrow screens. */
@media (max-width: 920px) {
  #app { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .viewport { order: -1; min-height: 52vh; }
  .images { flex-direction: column; }
  .panel { max-height: none; }
  /* More legible controls on tablets/phones. */
  label { font-size: 12px; margin-top: 13px; }
  output { font-size: 13px; }
  .group h2 { font-size: 12px; }
  label.check { font-size: 13px; }
}
@media (max-width: 560px) {
  #topbar { gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
  .topchips { display: none; }     /* the Measurements panel below shows these */
  .tag { display: none; }
  .brand { font-size: 15px; }
  .ghlink { font-size: 13px; }
  .group h2 { margin-top: 2px; }
  .scoutwrap { max-height: 46vh; }
  .viewport { min-height: 46vh; }
}

/* FOV-planning helper text under the localizer toggle */
.tiny { color: var(--text-faint); font-size: 11px; margin: 4px 0 0; line-height: 1.35; }

/* Honour users who prefer reduced motion: drop the splash-bar fill, busy fade
   and any transitions/animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
