:root {
  color-scheme: light;
  --bg: #eef1ed;
  --ink: #18201d;
  --muted: #59635e;
  --panel: #fbfcf8;
  --line: #ccd5ce;
  --accent: #0d766d;
  --accent-strong: #095c54;
  --accent-rgb: 13,118,109;
  --accent-bg: #d9f0ed;
  --accent-bg-strong: #c5e8e4;
  --warn: #a64c16;
  --blue: #246a9b;
  --rose: #a13d63;
  --shadow: 0 18px 50px rgba(28, 42, 34, 0.14);
  --cover-opacity: 0.70;   /* controlled by the slider */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb),0.08), transparent 34%),
    linear-gradient(180deg, #f8faf6, var(--bg));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select, input { font: inherit; }

/* ── Mobile panel toggle (hidden on desktop) ───────────────── */
.mobile-panel-toggle {
  display: none;
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(var(--accent-rgb),0.35);
}

/* ── Layout ─────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.workspace,
.clinical-panel {
  background: rgba(251, 252, 248, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: visible;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 8px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(1.2rem, 1.8vw, 1.8rem); line-height: 1.1; }
h2 { font-size: 1.25rem; }
h3 { font-size: 0.95rem; }

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-strip span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 7px 11px;
}

/* ── Stage ──────────────────────────────────────────────────── */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  align-content: start;
  gap: 8px;
  padding: 10px 16px 12px;
  overflow: visible;
}

.head-frame {
  position: relative;
  width: min(900px, 100%);
  min-height: 340px;
  display: grid;
  place-items: center;
  padding: 20px 16px 16px;
  border: 1px solid #bdc9c1;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,0.88), transparent 22%),
    linear-gradient(180deg, #e6d3c3 0%, #d0a98f 100%);
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.head-frame::before {
  display: none;
}

.gaze-target-dot {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: 18px;
  aspect-ratio: 1;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 0 2px rgba(85,31,48,0.34), 0 8px 18px rgba(40,18,28,0.24);
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.head-frame.tracking .gaze-target-dot { opacity: 1; }

/* ── Eye pair ────────────────────────────────────────────────── */
.eye-pair {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 280px));
  gap: clamp(28px, 8vw, 90px);
  align-items: center;
  justify-content: center;
}

.patient-right { order: 1; }
.patient-left  { order: 2; }

.eye-unit {
  display: grid;
  gap: 4px;
  justify-items: center;
  position: relative;
}

.axis-readout-shared {
  min-height: 24px;
  color: #4b342a;
  font-size: 0.88rem;
  font-weight: 750;
}

/* .axis-readout main rules are at bottom of file — do not add here */

.eye-label {
  /* legacy — hidden; labels now live in .eye-labels-bar above head-frame */
  display: none;
}

/* ── Eye label bar (sits above head-frame, outside it) ─────── */
.eye-labels-bar {
  width: min(900px, 100%);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 20px;
  margin-bottom: 4px;
  position: relative;
  overflow: visible;
}

.eye-label-tag {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(75,52,42,0.22);
  border-radius: 3px;
  padding: 3px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #4b342a;
  letter-spacing: 0.01em;
}

/* ── Iris colour picker — far left, unobtrusive ─────────────── */
.iris-color-picker {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.iris-color-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(75,52,42,0.22);
  border-radius: 4px;
  padding: 3px 10px 3px 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  color: #4b342a;
  transition: border-color 0.15s, background 0.15s;
}
.iris-color-btn:hover {
  border-color: var(--accent);
  background: rgba(255,255,255,1);
}

.iris-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.2);
  display: inline-block;
  flex-shrink: 0;
}

.iris-color-menu {
  position: fixed;
  background: #fff;
  border: 1px solid rgba(75,52,42,0.22);
  border-radius: 6px;
  padding: 6px;
  display: flex;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  z-index: 9999;
}
.iris-color-menu.hidden { display: none; }

.iris-swatch-opt {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  padding: 0;
}
.iris-swatch-opt:hover {
  transform: scale(1.15);
  border-color: rgba(0,0,0,0.3);
}
.iris-swatch-opt.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb),0.3);
}

.eye {
  position: relative;
  width: min(26vw, 260px);
  min-width: 160px;
  aspect-ratio: 2.1 / 1;
  border-radius: 50%;
  background:
    /* Subtle vascular pinkish tinge toward canthi */
    radial-gradient(ellipse 80% 40% at 10% 50%, rgba(220,160,140,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 80% 40% at 90% 50%, rgba(220,160,140,0.18) 0%, transparent 60%),
    /* Depth shadow toward limbus */
    radial-gradient(circle at 50% 50%, #fffefa 0%, #f8f5ef 55%, #ede5d8 85%, #e0d0bc 100%);
  border: none;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px #c59472,
    0 0 0 3px #dbbea9,
    0 0 10px 5px #dbbea9,
    inset 0 -18px 30px rgba(53,28,20,0.12),
    inset 0 0 20px rgba(53,28,20,0.06);
  transform: scale(var(--retraction-scale, 1));
  margin-top: 0;
}

/* Chemosis overlay — conjunctival oedema: yellowish-pink gelatinous appearance */
/* z-index: 3 — intentionally below lids-svg (z:4) so lid skin masks the overlay naturally */
.chemosis-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  background: transparent;
  transition: background 0.3s ease;
}

/* Globe retraction dark overlay — cheap absolute div, no box-shadow spread */
.retraction-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
  background: transparent;
}
.lids-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}
.lid-path {
  fill: #d2ab91;
}
.lid-upper-path {
  stroke: rgba(82, 52, 38, 0.30);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}
.lid-lower-path {
  stroke: rgba(82, 52, 38, 0.22);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
}

/* ── Cover overlay ───────────────────────────────────────────── */
.cover-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  /* semi-transparent so the eye's dissociated movement is still visible */
  background: rgba(18, 26, 22, var(--cover-opacity, 0.70));
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.cover-overlay.cover-active {
  opacity: 1;
}


/* ── Limbus / iris / pupil ───────────────────────────────────── */
.limbus {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: transform 60ms linear;
  /* Corneal dome shadow — darkens iris edge, adds depth */
  filter: drop-shadow(0px 1.5px 2px rgba(0,0,0,0.35));
}

.iris {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 38% 32% at 34% 28%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.15) 45%, transparent 70%),
    radial-gradient(circle at 68% 72%, rgba(255,255,255,0.12) 0%, transparent 35%),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.04) 0%, transparent 60%),
    radial-gradient(circle at 50% 50%, transparent 28%, var(--iris-collarette, rgba(100,200,190,0.25)) 29%, var(--iris-collarette, rgba(100,200,190,0.10)) 38%, transparent 39%),
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(4,30,28,0.65) 75%, rgba(2,18,16,0.90) 100%),
    radial-gradient(circle at 50% 50%, var(--iris-light, #2a9d8f) 0%, var(--iris-mid, #1d796e) 35%, var(--iris-dark, #0c594f) 60%, var(--iris-edge, #072f2c) 100%);
  border: 1.5px solid #041a18;
  box-shadow:
    inset 0 -3px 6px rgba(0,0,0,0.40),
    inset 0 2px 4px rgba(255,255,255,0.08);
  overflow: hidden;
}

/* Iris texture layer — conic radial spokes */
.iris::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255,255,255,0.03) 0deg 6deg,
    transparent 6deg 12deg
  );
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* Corneal dome highlight overlay — sits above iris */
.iris::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    ellipse 55% 45% at 36% 30%,
    rgba(255,255,255,0.22) 0%,
    rgba(255,255,255,0.06) 50%,
    transparent 70%
  );
  pointer-events: none;
}

.pupil {
  width: var(--pupil-size, 36%);
  aspect-ratio: 1;
  border-radius: 50%;
  /* Deep pupil with subtle depth — not flat black */
  background: radial-gradient(circle at 42% 38%, #1a1a1a 0%, #050807 40%, #000 100%);
  box-shadow:
    inset 0 0 4px 2px rgba(0,0,0,0.8),
    0 0 2px rgba(0,0,0,0.5);
  transition: width 180ms ease;
  position: relative;
  z-index: 1;
}

.catchlight {
  position: absolute;
  top: var(--cl-y, 18%);
  left: var(--cl-x, 24%);
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, rgba(255,255,255,0.85) 50%, rgba(255,255,255,0.4) 100%);
  pointer-events: none;
  z-index: 2;
  transition: top 60ms linear, left 60ms linear, width 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

/* Hirschberg torch mode: small warm-yellow reflex — convex cornea forms a diminished image */
.catchlight.purkinje-active {
  width: 11%;
  background: radial-gradient(circle at 40% 35%, #fff 0%, #ffe97a 40%, #ffd000 100%);
  box-shadow:
    0 0 3px 1px rgba(255, 220, 0, 0.95),
    0 0 8px 3px rgba(255, 200, 0, 0.50);
}

/* ── Kappa slider group ──────────────────────────────────────── */
.kappa-group {
  margin-top: 2px;
  padding: 4px 6px 4px;
  background: rgba(var(--accent-rgb),0.06);
  border: 1px solid rgba(var(--accent-rgb),0.18);
  border-radius: 6px;
}
.kappa-group.hidden { display: none; }

.kappa-slider-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.kappa-btn {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.kappa-btn:hover { border-color: var(--accent); color: var(--accent); }
.kappa-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.kappa-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.kappa-label {
  font-size: 0.70rem;
  font-weight: 600;
  color: var(--text-dim, #888);
  letter-spacing: 0.01em;
}
.kappa-val {
  font-size: 0.70rem;
  font-weight: 700;
  color: var(--accent, #0d766d);
  min-width: 32px;
  text-align: right;
}
.kappa-slider {
  width: 100%;
  accent-color: var(--accent, #0d766d);
  cursor: pointer;
  height: 14px;
}
.kappa-hint {
  font-size: 0.62rem;
  color: var(--text-dim, #aaa);
  margin-top: 2px;
  line-height: 1.3;
}

/* ── Torsion ────────────────────────────────────────────────── */
.torsion-overlay {
  position: absolute;
  inset: -36%;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.torsion-overlay.visible { opacity: 1; }

.meridian {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 1.5px;
  height: 82%;
  background: rgba(207, 72, 20, 0.62);
  border-radius: 1px;
  transform-origin: 50% 50%;
}

.m0   { transform: translate(-50%, -50%) rotate(0deg);   }
.m45  { transform: translate(-50%, -50%) rotate(45deg);  }
.m90  { transform: translate(-50%, -50%) rotate(90deg);  }
.m135 { transform: translate(-50%, -50%) rotate(135deg); }

.torsion-svg {
  position: absolute;
  z-index: 3;
  inset: 0;
  color: rgba(0, 79, 143, 0.88);
  overflow: visible;
  filter: drop-shadow(0 1px 2px rgba(235,248,255,0.80));
}

.torsion-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.arrow-head-shape { fill: currentColor; }

.torsion-overlay.counter .torsion-svg { transform: scaleX(-1); }

/* ── Brows ──────────────────────────────────────────────────── */
.brow {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 84px;
  margin: 0 auto 10px auto;
  background: linear-gradient(
    to right,
    rgba(42, 24, 10, 0.88) 0%,
    rgba(55, 32, 12, 0.92) 20%,
    rgba(58, 34, 14, 0.86) 50%,
    rgba(50, 29, 11, 0.52) 80%,
    rgba(44, 25, 10, 0.12) 100%
  );
  border-radius: 0;
  clip-path: polygon(
    0.0%  19.3%,
    3.8%  18.6%,
    7.7%  17.8%,
    11.5%  16.9%,
    15.4%  16.1%,
    19.2%  15.3%,
    23.1%  14.8%,
    26.9%  14.5%,
    30.8%  14.5%,
    34.6%  14.9%,
    38.5%  15.8%,
    42.3%  17.1%,
    46.2%  18.8%,
    50.0%  21.1%,
    53.8%  23.9%,
    57.7%  27.2%,
    61.5%  30.9%,
    65.4%  35.1%,
    69.2%  39.6%,
    73.1%  44.2%,
    76.9%  48.7%,
    80.8%  52.9%,
    84.6%  56.7%,
    88.5%  60.1%,
    92.3%  63.1%,
    96.2%  65.8%,
    100.0%  68.1%,
    100.0%  75.8%,
    96.2%  73.8%,
    92.3%  71.5%,
    88.5%  69.1%,
    84.6%  66.6%,
    80.8%  63.8%,
    76.9%  61.0%,
    73.1%  58.1%,
    69.2%  55.4%,
    65.4%  52.9%,
    61.5%  50.7%,
    57.7%  48.8%,
    53.8%  47.1%,
    50.0%  45.6%,
    46.2%  44.3%,
    42.3%  43.3%,
    38.5%  42.5%,
    34.6%  42.0%,
    30.8%  41.9%,
    26.9%  42.1%,
    23.1%  42.5%,
    19.2%  43.1%,
    15.4%  43.9%,
    11.5%  44.8%,
    7.7%  45.7%,
    3.8%  46.5%,
    0.0%  47.3%
  );
  transition: transform 180ms ease;
}

.brow-left {
  transform: rotate(-1deg) translateY(var(--brow-drop-left, 0));
}
.brow-right {
  transform: rotate(1deg) translateY(var(--brow-drop-right, 0)) scaleX(-1);
}

/* ── Stage controls ─────────────────────────────────────────── */
.stage-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  justify-content: stretch;
  width: 100%;
}

.target-pad {
  align-self: start;
  display: grid;
  grid-template-columns: repeat(3, 42px);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(var(--accent-rgb),0.28);
  background: rgba(255,255,255,0.84);
  backdrop-filter: blur(12px);
}

.target {
  width: 42px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 800;
}

.target:hover,
.target:focus-visible,
.target.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  outline: none;
}


.ino-near-hint {
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--accent);
  background: rgba(var(--accent-rgb),0.08);
  border: 1px solid rgba(var(--accent-rgb),0.35);
  border-radius: 3px;
  font-weight: 600;
}

.controls {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(0, auto);
  grid-template-rows: auto auto;
  gap: 12px 16px;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(var(--accent-rgb),0.28);
  background: rgba(255,255,255,0.84);
  width: 100%;
  box-sizing: border-box;
}

.control-group.disabled .sev-btn { opacity: 0.45; cursor: default; }

/* ── R/E L/E B/E laterality buttons ─────────────────────────── */
.laterality-group {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.lat-btn {
  flex: 1;
  padding: 4px 0;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.lat-btn:hover {
  border-color: var(--accent);
  background: var(--hover, #f0faf8);
}
.lat-btn.lat-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.lat-btn.hidden { display: none; }
.control-group.disabled input { cursor: default; pointer-events: none; }
.control-group { display: grid; gap: 8px; min-width: 0; }
.control-group > label { text-align: center; }
.control-group > label #severityPDInline { color: var(--accent); font-weight: 700; white-space: nowrap; }

label {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

select {
  width: 100%;
  max-width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* ── Custom dropdown ─────────────────────────────────────────── */
.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;       /* prevent grid blowout — allows text truncation on button */
}

.custom-select-btn {
  width: 100%;
  max-width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.90rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  gap: 8px;
  overflow: hidden;          /* prevent button from expanding */
  transition: border-color 0.15s;
}
.custom-select-btn:hover,
.custom-select.open .custom-select-btn {
  border-color: var(--accent);
}
.custom-select-arrow {
  flex-shrink: 0;
  color: var(--ink);
  opacity: 0.5;
  transition: transform 0.2s;
}
.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}
#patternSelectLabel {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.custom-select-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 3px);  /* opens UPWARD — keeps lat buttons below unobstructed */
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
  z-index: 999;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
}
.custom-select.open .custom-select-dropdown {
  display: block;
}

.custom-select-group-label {
  display: block;
  padding: 8px 12px 4px;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
  background: #f5faf9;
  border-top: 1px solid var(--line);
  margin-top: 2px;
}
.custom-select-group-label:first-child {
  border-top: none;
  margin-top: 0;
}

.custom-select-option {
  display: block;
  width: 100%;
  padding: 7px 12px 7px 20px;
  font-size: 0.90rem;
  font-weight: 400;
  color: var(--ink);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s;
  white-space: nowrap;      /* keep on one line */
  overflow: visible;        /* show full text in open list */
  text-overflow: clip;
}
.custom-select-option:hover {
  background: var(--hover, #f0faf8);
  color: var(--accent-strong);
}
.custom-select-option.selected {
  background: #e6f4f2;
  color: var(--accent-strong);
  font-weight: 600;
}

input[type="range"] {
  accent-color: var(--accent);
  height: 42px;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ── Six-toggle 2-column grid (Pupil/Lid/Cyclotorsion/Muscle/Lift/Blink) ── */
.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 8px;
  align-items: stretch;
}

.toggle-grid .check {
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  justify-content: flex-start;
}


.check {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
}

.check input { accent-color: var(--accent); }

.inline-notes {
  grid-column: 1 / -1;
  border: 1.5px solid var(--accent);
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.04) 0%, rgba(var(--accent-rgb),0.02) 100%);
  border-radius: 0 5px 5px 0;
  padding: 10px 14px 12px;
  min-height: 80px;
}

.inline-notes > span {
  display: block;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

#inlineNotesText {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notes-line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--ink);
  font-size: 0.93rem;
  line-height: 1.55;
}

.notes-bullet {
  color: var(--accent);
  font-size: 0.60rem;
  margin-top: 0.42em;
  flex-shrink: 0;
  opacity: 0.80;
}

/* ── Clinical panel ─────────────────────────────────────────── */
.clinical-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px 16px 16px;
  overflow-y: auto;
}

.clinical-panel p {
  color: var(--muted);
  line-height: 1.52;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-grid > div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 13px;
}

.metric-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-grid strong {
  display: block;
  font-size: 0.92rem;
  line-height: 1.25;
}

/* ── Cover test panel ───────────────────────────────────────── */
.cover-test-panel {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.cover-test-panel .eyebrow { margin: 0; }

.cover-step-label {
  margin: 0;
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.4;
  min-height: 2.2em;
}

.cover-start-btn {
  height: 40px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0 16px;
  font-size: 0.88rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 120ms;
  text-align: left;
}

.cover-start-btn:hover { background: var(--accent-strong); }

/* Three cover action buttons in a row */
.cover-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
}

.cover-eye-btn {
  padding: 9px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
  transition: background 100ms, border-color 100ms;
  line-height: 1.3;
}

.cover-eye-btn strong { display: block; font-size: 0.95rem; }

.cover-eye-btn:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.cover-eye-btn.cover-btn-active {
  border-color: var(--accent);
  background: var(--accent-bg-strong);
  color: var(--accent-strong);
  font-weight: 700;
}

/* Opacity row */
.cover-opacity-row {
  display: grid;
  gap: 4px;
}

.cover-opacity-row label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cover-opacity-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 32px;
}

.cover-end-btn {
  height: 34px;
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  justify-self: start;
  transition: background 120ms;
}

.cover-end-btn:hover { background: #fdf0e8; }

.cover-result {
  font-size: 0.82rem;
  color: var(--ink);
  line-height: 1.5;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  min-height: 1em;
}

/* ── Muscle table ───────────────────────────────────────────── */
.muscle-table {
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.table-head, .muscle-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 10px;
  align-items: center;
}

.table-head {
  padding: 10px 12px;
  background: #e7eeea;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.muscle-row {
  padding: 10px 12px;
  border-top: 1px solid #edf1ee;
  font-size: 0.88rem;
}

.signal {
  height: 8px;
  border-radius: 999px;
  background: #e5ebe7;
  overflow: hidden;
}

.signal span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--bar, var(--accent));
  transition: width 80ms ease;
}

/* !important ensures .hidden overrides any display:flex/grid on same element */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: minmax(0,1fr) 340px;
  }
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-bottom: 72px; /* room for fab */
  }

  .mobile-panel-toggle {
    display: block;
  }

  .clinical-panel {
    display: none;
    grid-template-columns: repeat(2, minmax(0,1fr));
    position: fixed;
    inset: auto 0 0 0;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 50;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 32px rgba(28,42,34,0.22);
    padding: 20px 18px 28px;
  }

  .clinical-panel.panel-open {
    display: grid;
  }

  .clinical-panel > :first-child,
  .muscle-table,
  .cover-test-panel {
    grid-column: 1 / -1;
  }

  .stage-controls {
    grid-template-columns: auto minmax(340px, 1fr);
    align-items: stretch;
  }

  .controls {
    width: 100%;
    grid-template-columns: minmax(170px, 1fr) minmax(140px, 0.7fr);
  }

  .toggle-row,
  .toggle-grid,
  .inline-notes {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell { padding: 10px; }

  .topbar, .controls { padding-inline: 16px; }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage {
    padding: 10px 14px 16px;
    place-items: start center;
  }

  .head-frame {
    min-height: 360px;
    padding: 32px 12px 18px;
  }

  .brow { display: none; }

  .eye-pair {
    grid-template-columns: repeat(2, minmax(126px, 1fr));
    gap: 10px;
    width: 100%;
  }

  .eye {
    width: min(36vw, 190px);
    min-width: 128px;
  }

  .clinical-panel {
    grid-template-columns: 1fr;
    max-height: 80vh;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stage-controls {
    grid-template-columns: auto minmax(310px, 1fr);
    justify-items: stretch;
  }

  .toggle-row { align-items: stretch; }
  .toggle-grid { grid-template-columns: 1fr 1fr; }
  .check { flex: 1 1 150px; }
}

@media (max-width: 520px) {
  .stage-controls {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .toggle-row,
  .toggle-grid,
  .inline-notes {
    grid-column: auto;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}

/* ── DVD Fusion Panel ───────────────────────────────────────── */
.dvd-fusion-panel {
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.dvd-fusion-controls {
  display: flex;
  gap: 8px;
  margin: 10px 0 8px;
}

.dvd-fusion-btn {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.dvd-fusion-btn:hover {
  background: var(--accent);
  color: #fff;
}

.dvd-restore-btn {
  border-color: var(--warn);
  color: var(--warn);
}

.dvd-restore-btn:hover {
  background: var(--warn);
  color: #fff;
}

.dvd-status {
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.2em;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

/* ── IOOA Panel ─────────────────────────────────────────────── */
.iooa-row {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.iooa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.iooa-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.iooa-hint {
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
}

.iooa-severity {
  margin-top: 10px;
}

.iooa-severity label {
  font-size: 0.80rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 6px;
}

.iooa-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.iooa-slider-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
}

.iooa-tick {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}

.iooa-grade-label {
  margin-top: 5px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-strong);
  text-align: center;
}

/* ── Head tilt (Bielschowsky) controls ──────────────────────── */
.head-tilt-row {
  display: flex;
  gap: 6px;
  margin: 8px 0 6px;
}

.tilt-btn {
  flex: 1;
  padding: 8px 6px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tilt-btn:hover { border-color: var(--accent); color: var(--accent); }

.tilt-btn.tilt-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── MG fatigue controls ────────────────────────────────────── */
.mg-fatigue-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 6px;
}

.mg-btn {
  flex: 1;
  padding: 9px 10px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mg-btn:hover { background: var(--accent); color: #fff; }

.mg-reset-btn { border-color: var(--warn); color: var(--warn); }
.mg-reset-btn:hover { background: var(--warn); color: #fff; }

.mg-fatigue-bar-wrap {
  margin-top: 6px;
  background: var(--line);
  border-radius: 3px;
  height: 8px;
  overflow: hidden;
  position: relative;
}

.mg-fatigue-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--warn));
  transition: width 0.3s;
  border-radius: 3px;
}

.mg-fatigue-label {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 3px;
}

.mg-preset-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  width: 100%;
  margin-top: 4px;
  margin-bottom: 4px;
  display: block;
}


/* ── Oblique overaction panel ───────────────────────────────── */
.oblique-panel {
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.oblique-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 6px 0 4px;
}

.oblique-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.oblique-toggle-btn {
  width: 100%;
  padding: 7px 8px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  font-size: 0.80rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
  transition: all 0.15s;
  white-space: nowrap;
}

.oblique-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.oblique-toggle-btn.oblique-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.oblique-sub {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.82;
  display: block;
}

.oblique-grade {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
}

.oblique-grade input[type=range] {
  flex: 1;
  accent-color: var(--accent);
}

.oblique-grade span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-strong);
  min-width: 20px;
  text-align: right;
}

.oblique-context-hint {
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
  min-height: 1.1em;
  margin: 2px 0 0;
}

/* ── Axis readout — spans full eye width, three equal blocks ──── */
.axis-readout {
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  flex-wrap: nowrap;
  width: min(26vw, 260px);
  min-width: 160px;
  padding: 3px 0;
  background: transparent;
  border: none;
  overflow: hidden;
}

.ro-ortho {
  font-size: 0.62rem;
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0.02em;
  align-self: center;
}

.ro-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex: 1;                  /* equal thirds — aligns with eye laterally */
  padding: 4px 6px;
  border-right: 1px solid var(--line);
}
.ro-block:last-child { border-right: none; }

/* Row 1: axis + value + unit + dir */
.ro-row1 {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* Row 2: degrees (hidden by default) */
.ro-row2 {
  display: none;
  justify-content: center;
}
.show-degrees .ro-row2 { display: flex; }

/* Axis label — prominent, larger, bold */
.ro-axis {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent-strong);
  letter-spacing: 0.05em;
  margin-right: 5px;
}

/* Numeric value — same size as axis, italic */
.ro-val {
  font-size: 0.82rem;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-right: 1px;
}

/* Unit — same size, muted, not italic */
.ro-unit {
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
  margin-right: 4px;
}

/* Direction */
.ro-dir {
  font-size: 0.65rem;
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 20px;
  text-align: left;
}
.ro-dir-empty {
  visibility: hidden;
  font-size: 0.65rem;
  min-width: 0;
}

/* Degrees in parens */
.ro-deg {
  font-size: 0.72rem;
  font-weight: 700;
  color: #4a5e58;
}

/* ── Oblique laterality buttons ─────────────────────────────── */
.oblique-lat {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.lat-btn {
  flex: 1;
  padding: 5px 4px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
}

.lat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lat-btn.lat-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Clinical Notes — cover test section ───────────────────── */
.notes-glossary {
  display: block;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--ink-faint, #888);
  font-style: italic;
  line-height: 1.6;
}
.notes-glossary em {
  font-style: normal;
  font-weight: 700;
  color: var(--ink-mid, #666);
}

.notes-section-head {
  display: block;
  margin-top: 10px;
  margin-bottom: 5px;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-strong);   /* same as main Clinical Notes header */
}

.notes-line-cover {
  color: var(--ink);             /* same as main notes text */
  font-size: 0.93rem;            /* same size */
  line-height: 1.55;
}

.notes-bullet-cover {
  color: var(--accent);          /* same bullet colour */
  font-size: 0.60rem;
  margin-top: 0.42em;
  flex-shrink: 0;
  opacity: 0.80;
}

/* ── Target pad wrap + degrees toggle ───────────────────────── */
.target-pad-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  align-self: start;
  width: 154px;        /* exactly the gaze pad width — nothing can widen this column */
  flex-shrink: 0;
}

.deg-toggle-label {
  /* inherits from .check — no override needed */
}

/* ── Dominance control ──────────────────────────────────────── */
.dominance-row {
  display: flex;
  gap: 6px;
}

.dom-btn {
  flex: 1;
  padding: 7px 8px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  font-size: 0.80rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.dom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.dom-btn.dom-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* ── Severity slider bubble ─────────────────────────────────── */
.slider-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.slider-wrap input[type=range] {
  width: 100%;
}

.slider-bubble {
  position: absolute;
  top: -28px;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.slider-wrap:hover .slider-bubble,
.slider-wrap.dragging .slider-bubble {
  opacity: 1;
}

.slider-bubble.hidden { opacity: 0 !important; }

.slider-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--accent);
}

/* ── Dominance under gaze pad ───────────────────────────────── */
.dom-pad-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
}

/* Distance / Near fixation toggle — same layout as dom-pad-group */
.dist-near-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  margin-top: 4px;
}

/* AC/A ratio slider */
.aca-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px dashed rgba(var(--accent-rgb),0.35);
  transition: opacity 0.2s;
}

/* AC/A slider greyed when distance is active — effect is near-only */
.aca-group.aca-dist-inactive {
  opacity: 0.38;
  pointer-events: none;
}

.aca-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aca-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}

.aca-qual {
  font-size: 0.70rem;
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
  margin-left: 3px;
}

.dom-pad-label {
  font-size: 0.70rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mg-title-label {
  display: block;
  text-align: center;
  width: 100%;
}

.dom-pad-group .dominance-row {
  width: 100%;
}

.dom-pad-group .dom-btn {
  font-size: 0.70rem;
  padding: 3px 5px;
}

/* ── Bidirectional oblique slider panel ─────────────────────── */
.oblique-muscle-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-strong);
  margin-bottom: 4px;
  text-align: center;
  min-height: 1.1em;
}

.oblique-grade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 2px;
}

.oblique-range-hint {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.oblique-grade-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 48px;
  text-align: center;
}

/* ── Alternate Cover Test ────────────────────────────────────── */
.act-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.act-settings {
  display: flex;
  gap: 12px;
  align-items: center;
}

.act-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.act-label select {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.78rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.act-start-btn {
  width: 100%;
  padding: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.02em;
}

.act-start-btn:hover { background: var(--accent-strong); }
.act-start-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.act-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.act-bar-wrap {
  width: 100%;
  height: 5px;
  background: rgba(var(--accent-rgb),0.15);
  border-radius: 99px;
  overflow: hidden;
}

.act-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s linear;
  width: 0%;
}

.act-status {
  font-size: 0.76rem;
  color: var(--accent-strong);
  font-weight: 600;
  text-align: center;
}

/* ── Bielschowsky SVG head ──────────────────────────────────── */
#headTiltGroup {
  grid-column: 1 / -1;
}

.biel-layout {
  display: grid;
  grid-template-columns: 96px 1fr 1fr;  /* face | buttons | hint */
  align-items: center;
  gap: 14px;
  width: 100%;
}

/* Doll's head layout — wider, uses spare white space for notes */
.dolls-layout {
  display: grid;
  grid-template-columns: 96px 120px 1fr;   /* face | buttons | notes */
  align-items: center;
  gap: 16px;
  width: 100%;
}

.dolls-notes-panel {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.06) 0%, rgba(var(--accent-rgb),0.02) 100%);
  border: 1.5px solid rgba(var(--accent-rgb),0.22);
  border-left: 3px solid var(--accent);
  border-radius: 0 5px 5px 0;
  padding: 10px 14px;
  min-height: 80px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}

.dolls-notes-panel:empty {
  background: rgba(var(--accent-rgb),0.02);
  border-color: rgba(var(--accent-rgb),0.10);
  border-left-color: rgba(var(--accent-rgb),0.15);
}

.dolls-notes-panel .biel-hint-line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.55;
}

.dolls-notes-panel .biel-hint-bullet {
  color: var(--accent);
  font-size: 0.60rem;
  margin-top: 0.42em;
  flex-shrink: 0;
  opacity: 0.80;
}

.biel-head-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.biel-head-svg {
  width: 96px;
  height: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.15));
}

.biel-tilt-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin: 0;
  white-space: nowrap;
}

.biel-right-col {
  display: contents;  /* children participate directly in parent grid */
}

.head-tilt-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: center;
}

.tilt-btn {
  width: 100%;
}

.tilt-hint {
  font-size: 0.78rem;
  color: var(--accent-strong);
  margin: 0;
  font-style: italic;
  line-height: 1.55;
  align-self: center;
}

/* ── Chronicity slider ──────────────────────────────────────── */
.chronicity-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chronicity-row input[type=range] {
  flex: 1;
}

.chron-label {
  font-size: 0.70rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chron-hint {
  font-size: 0.74rem;
  color: var(--accent-strong);
  margin: 4px 0 0;
  font-style: italic;
  line-height: 1.3;
}

/* ── Primary / Secondary deviation ─────────────────────────── */
.prim-sec-row {
  display: flex;
  gap: 6px;
}

.prim-sec-btn {
  flex: 1;
  padding: 7px 6px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  transition: all 0.15s;
}

.prim-sec-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.prim-sec-btn.prim-sec-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.prim-sec-sub {
  display: block;
  font-size: 0.66rem;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}

/* Chronicity spans full controls grid width */
.chron-full {
  grid-column: 1 / -1;
}

/* ── Chronicity in left panel (compact) ─────────────────────── */
.chron-pad-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
}

.chron-pad-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.chron-pad-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chron-pad-slider {
  flex: 1;
  min-width: 0;
}

.chron-pad-hint {
  font-size: 0.60rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  margin-top: 1px;
}

/* ── Bielschowsky hint bullets ──────────────────────────────── */
.biel-hint-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--accent-strong);
  font-style: italic;
  line-height: 1.5;
}

.biel-hint-bullet {
  color: var(--accent);
  font-size: 0.55rem;
  flex-shrink: 0;
  margin-top: 0.35em;
  font-style: normal;
}

/* ── Severity slider with inc/dec buttons ───────────────────── */
.slider-with-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-with-btns .slider-wrap {
  flex: 1;
}

.sev-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 5px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  line-height: 1;
  padding: 0;
}

.sev-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb),0.06);
}

.sev-btn:active:not(:disabled) {
  background: rgba(var(--accent-rgb),0.12);
}

.sev-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.severity-pd-display {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  margin-left: 8px;
  background: rgba(var(--accent-rgb),0.08);
  padding: 1px 7px;
  border-radius: 10px;
}

/* ── Deviation PD labels (paretic patterns) ─────────────────── */
.dev-label {
  position: absolute;
  top: calc(100% + 2px);   /* just below the eye-unit's last in-flow child */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}
.dev-label.hidden { display: none; }

.dev-label-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 8px;
  background: rgba(var(--accent-rgb),0.07);
  border: 1px solid rgba(var(--accent-rgb),0.18);
}
.dev-label-row.dev-primary {
  color: var(--accent, #0d766d);
  background: rgba(var(--accent-rgb),0.10);
  border-color: rgba(var(--accent-rgb),0.30);
}
.dev-label-row.dev-secondary {
  color: #4a2800;
  background: rgba(74,40,0,0.12);
  border-color: rgba(74,40,0,0.40);
}
.dev-label-row.dev-paretic {
  color: #7b3fa0;
  background: rgba(123,63,160,0.07);
  border-color: rgba(123,63,160,0.25);
}
.dev-label-tag {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.80;
}
.dev-label-val {
  font-size: 0.85rem;
  font-weight: 700;
}
.dev-label-unit {
  font-size: 0.72rem;
  font-weight: 400;
  margin-left: 1px;
}
.dev-label-sep {
  opacity: 0.35;
  font-size: 0.80rem;
}

/* ── Blink check — fits inside .check same as other toggles ─── */
.blink-check {
  gap: 6px;
  cursor: default;
  width: 100%;
  box-sizing: border-box;
}
.blink-check-label {
  font-size: 0.82rem;
  white-space: nowrap;
  color: var(--ink);
}
.blink-check-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}
.blink-rate-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
  flex-shrink: 0;
}
.blink-rate-btn:hover { background: var(--hover); border-color: var(--accent); }
.blink-rate-btn:disabled { opacity: 0.35; cursor: default; }
.blink-rate-display {
  min-width: 42px;
  padding: 1px 4px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  text-align: center;
  transition: background 120ms;
}
.blink-rate-display:hover { background: var(--hover); }

/* ── Compact toggle row (Show degrees + Hirschberg) ─────────── */
.toggle-row-compact { margin-bottom: 2px; flex-wrap: nowrap; }
.check-hirschberg { min-width: 148px; width: 100%; box-sizing: border-box; }

/* ── App footer ──────────────────────────────────────────────── */
.app-footer {
  grid-column: 1 / -1;
  width: 100%;
  text-align: center;
  padding: 8px 16px 10px;
  font-size: 0.80rem;
  font-weight: 700;
  color: #1e3a36;
  border-top: 1px solid var(--line);
  background: rgba(245,250,248,0.95);
  letter-spacing: 0.01em;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.footer-beta {
  font-size: 0.70rem;
  font-weight: 400;
  color: var(--muted);
  font-style: italic;
}

.footer-beta a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-beta a:hover {
  text-decoration: underline;
}

/* ── Title copyright superscript ────────────────────────────── */
.title-copyright {
  font-size: 0.5em;
  vertical-align: super;
  font-weight: 700;
  color: var(--accent);
  opacity: 1;
  letter-spacing: 0;
}

/* ── Fullscreen button ───────────────────────────────────────── */
.fullscreen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,0.7);
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.fullscreen-btn:hover {
  background: rgba(255,255,255,1);
  border-color: var(--accent);
}
