/* ============================================================
   VIVID ATOM — LAB
   Interactive demonstration. Shares tokens with the main site.
   ============================================================ */

.lab { background: var(--bg); overflow-x: hidden; }
.lab-main { padding-top: 58px; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Slim header ---------- */
.lab-head {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 58px;
  padding: 0 clamp(18px, 4vw, 42px);
  background: rgba(5, 5, 5, 0.78);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.lab-head .brand-mark { height: 28px; }
.lab-head .brand-name { font-size: 0.92rem; }
.lab-back {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transition: color 0.2s;
}
.lab-back:hover { color: var(--orange-hot); }

/* ---------- Cover ---------- */
.lab-cover {
  position: relative;
  overflow: hidden;
  min-height: calc(100dvh - 58px);
  display: grid;
  align-items: center;
  padding: clamp(50px, 9vw, 110px) 0 clamp(60px, 10vw, 120px);
}
.cover-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 48px);
}
.lab-stamp {
  display: inline-block;
  margin-bottom: 26px;
  padding: 8px 14px;
  border: 1px dashed rgba(255, 95, 15, 0.6);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--orange);
  background: rgba(255, 95, 15, 0.05);
}
.lab-cover h1 {
  font-size: clamp(2.6rem, 8vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin-bottom: 26px;
}
.lab-cover .lead { max-width: 54ch; }
.cover-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 36px;
}
.cover-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.cover-art {
  position: absolute;
  right: clamp(0px, 3vw, 56px);
  top: 50%;
  width: min(36vw, 440px);
  height: auto;
  opacity: 0.55;
  pointer-events: none;
  animation: cover-float 20s ease-in-out infinite;
}
@keyframes cover-float {
  0%, 100% { transform: translateY(-50%) rotate(0deg); }
  50% { transform: translateY(-53%) rotate(2.5deg); }
}

.cover-note {
  margin-top: 34px;
  max-width: 62ch;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.8;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

/* ---------- Step rail ---------- */
.rail {
  position: sticky;
  top: 58px;
  z-index: 40;
  background: rgba(5, 5, 5, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.rail ol {
  display: flex;
  list-style: none;
  gap: clamp(12px, 3vw, 34px);
  padding: 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.rail ol::-webkit-scrollbar { display: none; }
.rail-item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}
.rail-item:hover { color: var(--ink-muted); }
.rail-item.is-active { color: var(--orange-hot); border-bottom-color: var(--orange); }
.rail-item.is-done { color: var(--ink-muted); }
.rail-num { opacity: 0.7; }

/* ---------- Steps ---------- */
.lab-step { padding: clamp(34px, 5vw, 60px) 0 clamp(50px, 7vw, 90px); }
.lab-step[hidden] { display: none; }
.lab-step.is-active { animation: step-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes step-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.step-head { max-width: 68ch; margin-bottom: clamp(24px, 3vw, 36px); }
.lab-step h2:focus,
.lab-step h2:focus-visible { outline: none; }
.lab-step h2 { scroll-margin-top: 140px; }
.step-head h2 { margin-bottom: 14px; }
.step-lead { color: var(--ink-muted); max-width: 62ch; }
.step-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 30px;
}

/* ---------- Binding stage ---------- */
.stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(620px 340px at 68% 34%, rgba(255, 95, 15, 0.09), transparent 68%),
    radial-gradient(420px 300px at 12% 92%, rgba(255, 95, 15, 0.05), transparent 70%),
    #070708;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.stage canvas {
  display: block;
  width: 100%;
  height: clamp(320px, 52vh, 480px);
  touch-action: none;
  cursor: grab;
  outline: none;
}
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible {
  outline: 1px solid rgba(191, 233, 255, 0.5);
  outline-offset: -3px;
}
.stage-hint {
  position: absolute;
  left: 18px;
  bottom: 14px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  pointer-events: none;
  transition: opacity 0.3s;
}
.stage.is-dragging .stage-hint { opacity: 0; }

/* ---------- Readout ---------- */
.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(12, 12, 14, 0.6);
  overflow: hidden;
}
.readout-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border-right: 1px solid var(--line-soft);
}
.readout-row:last-child { border-right: 0; }
.readout-k {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.readout-v {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--ink);
  min-height: 1.4em;
}
.readout-v.is-live { color: var(--orange-hot); text-shadow: 0 0 14px rgba(255, 95, 15, 0.45); }

/* ---------- Budget ---------- */
.budget {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}
.bar-block { margin-bottom: 26px; }
.bar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}
.bar-name {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.bar-total {
  font-size: 1.02rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bar-track {
  display: flex;
  height: 22px;
  border-radius: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-soft);
}
.seg {
  display: block;
  height: 100%;
  width: 0;
  flex: 0 0 auto;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.seg-hcp { background: linear-gradient(90deg, #ff5f0f, #ff7a1a); }
.seg-chair { background: #ffb066; }
.seg-cons { background: #6b676b; }
.bar-sub {
  margin-top: 7px;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 22px 0 0;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; }

.delta {
  margin-top: 26px;
  padding: 24px;
  border: 1px solid rgba(126, 231, 135, 0.28);
  border-radius: 12px;
  background:
    radial-gradient(300px 140px at 20% 0%, rgba(126, 231, 135, 0.1), transparent 70%),
    rgba(8, 10, 8, 0.6);
}
.delta-k {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.delta-big {
  display: block;
  font-size: clamp(1.9rem, 4.2vw, 2.9rem);
  line-height: 1;
  color: #7ee787;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.delta-sub {
  display: block;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.delta-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(126, 231, 135, 0.18);
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.delta-rows b { color: #7ee787; font-weight: 700; }

/* ---------- Controls ---------- */
.budget-controls {
  padding: clamp(20px, 3vw, 28px);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(12, 12, 14, 0.55);
}
.ctrl { margin-bottom: 22px; }
.ctrl:last-of-type { margin-bottom: 0; }
.ctrl-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.ctrl label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.ctrl output {
  font-size: 0.9rem;
  color: var(--orange-hot);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--orange) var(--fill, 0%), rgba(255, 255, 255, 0.14) var(--fill, 0%));
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--orange);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--orange-hot);
  border: 2px solid #0b0b0c;
  box-shadow: 0 0 12px rgba(255, 95, 15, 0.6);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--orange-hot);
  border: 2px solid #0b0b0c;
  box-shadow: 0 0 12px rgba(255, 95, 15, 0.6);
}
input[type="range"]:focus-visible {
  outline: 2px solid var(--orange-hot);
  outline-offset: 4px;
  border-radius: 4px;
}

.assump {
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1.8;
  color: var(--ink-faint);
}

/* ---------- Summary ---------- */
.summary {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}
.summary-card {
  padding: clamp(24px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 95, 15, 0.06), transparent 60%), var(--panel);
}
.summary-h {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 18px;
}
.summary-list { display: grid; gap: 12px; margin-bottom: 26px; }
.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.summary-list dt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.summary-list dd { font-size: 0.92rem; color: var(--ink); text-align: right; }
.summary-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.copy-note {
  margin-top: 14px;
  min-height: 1.2em;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7ee787;
}
.summary-aside p { color: var(--ink-muted); margin-bottom: 16px; }
.summary-back {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange-hot);
}
.summary-back:hover { text-decoration: underline; }

/* ---------- Misc ---------- */
.noscript-note { padding: 40px 0 80px; max-width: 70ch; }
.noscript-note h2 { margin-bottom: 14px; }
.noscript-note p { color: var(--ink-muted); }

.lab-foot {
  border-top: 1px solid var(--line-soft);
  padding: 26px 0 40px;
}
.lab-foot .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.lab-foot a:hover { color: var(--orange-hot); }
.lab-foot.footer-horizon { padding-bottom: var(--horizon-h); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .cover-art { display: none; }
}

@media (max-width: 900px) {
  .budget, .summary { grid-template-columns: 1fr; }
  .budget-bars { order: 1; }
  .budget-controls { order: 2; }
}
@media (max-width: 620px) {
  .readout { grid-template-columns: 1fr; }
  .readout-row { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .readout-row:last-child { border-bottom: 0; }
  .stage canvas { height: clamp(280px, 44vh, 340px); }
  .step-actions .btn { width: 100%; justify-content: center; }
  .cover-actions { gap: 14px; }
  .cover-actions .btn { width: 100%; justify-content: center; }
  .summary-list div { flex-direction: column; gap: 4px; }
  .summary-list dd { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .lab-step.is-active { animation: none; }
  .seg { transition: none; }
  .stage canvas { cursor: default; }
}

/* ---------- Stage HUD (Mission-control chrome) ---------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: var(--font-mono);
  z-index: 2;
}
.hud::before,
.hud::after {
  content: "";
  position: absolute;
  top: 40px;
  bottom: 40px;
  width: 5px;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.14) 0 1px,
    transparent 1px 13px
  );
}
.hud::before { left: 3px; }
.hud::after { right: 3px; }

.hud-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.hud-tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.hud-tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.hud-bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.hud-br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.hud-lab {
  position: absolute;
  font-size: 0.56rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}
.hud-lab b { font-weight: 400; color: rgba(255, 255, 255, 0.5); }
.hud-top-left { top: 13px; left: 34px; }
.hud-top-center {
  top: 13px;
  left: 50%;
  transform: translateX(-50%);
}
.hud-top-right { top: 13px; right: 34px; text-align: right; }
.hud-bot-left { bottom: 13px; left: 34px; }
.hud-bot-right {
  bottom: 13px;
  right: 34px;
  text-align: right;
  transition: color 0.25s, text-shadow 0.25s;
}
.hud-bot-right.is-locked {
  color: #bfe9ff;
  text-shadow: 0 0 14px rgba(191, 233, 255, 0.55);
}
.hud-bot-right.is-lost { color: #ffb066; }

.hud-scale {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 5px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  border-right: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  opacity: 0.5;
}
.hud-sweep {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(191, 233, 255, 0.85), transparent);
  opacity: 0;
}

.stage.is-booting .hud-sweep { animation: hud-sweep 0.95s ease-out 1; }
@keyframes hud-sweep {
  0% { opacity: 0; top: 0; }
  10% { opacity: 1; }
  100% { opacity: 0; top: 100%; }
}

/* ---------- Orientation control ---------- */
.rotor {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.rotor-label { color: var(--ink-faint); }
.rot-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.rot-btn:hover { border-color: var(--orange); color: var(--orange-hot); background: rgba(255, 95, 15, 0.06); }
.rot-btn:active { background: rgba(255, 95, 15, 0.12); }
.rot-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rotor-val { color: var(--ink); font-size: 0.8rem; min-width: 3.4em; text-align: center; }
.rotor-note { margin-left: auto; color: var(--ink-faint); }
.rotor-note.is-near { color: var(--orange-soft); }

/* ---------- Fit meter ---------- */
.readout { grid-template-columns: repeat(4, 1fr); }
.readout-fit { display: flex; align-items: center; gap: 10px; }
.fitbar {
  position: relative;
  display: block;
  width: 62px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.fitbar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #ff5f0f, #ffd7bd);
  transition: width 0.1s linear, background 0.25s;
}
.fitbar i.is-locked { background: linear-gradient(90deg, #7ee787, #c9ffd0); }
.readout-fit em { font-style: normal; font-size: 0.82rem; color: var(--ink); }

@media (max-width: 720px) {
  .rail ol {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 6px 16px;
    padding: 10px 0;
  }
}

@media (max-width: 900px) {
  .readout { grid-template-columns: 1fr 1fr; }
  .readout-row:nth-child(2n) { border-right: 0; }
}
@media (max-width: 620px) {
  .readout { grid-template-columns: 1fr 1fr; }
  .readout-row:nth-child(2n) { border-right: 0; }
  .hud-lab { font-size: 0.52rem; letter-spacing: 0.18em; }
  .hud-top-left, .hud-bot-left { left: 30px; }
  .hud-top-center { display: none; }
  .hud-top-right, .hud-bot-right { right: 30px; }
  .rotor-note { display: none; }
}

/* ---------- Dose–response chart ---------- */
.dose-grid {
  display: grid;
  grid-template-columns: 1.32fr 0.68fr;
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}
.dose-chart {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 10px 4px;
  background:
    radial-gradient(520px 300px at 30% 10%, rgba(255, 95, 15, 0.06), transparent 70%),
    #070708;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
#dose-svg { display: block; width: 100%; height: auto; overflow: visible; }
#dose-svg .grid-line { stroke: rgba(255, 255, 255, 0.06); }
#dose-svg .axis-line { stroke: rgba(255, 255, 255, 0.16); }
#dose-svg .tick {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
}
#dose-svg .axis-title {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
#dose-svg .threshold {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-dasharray: 3 6;
}
#dose-svg .band { fill: rgba(255, 95, 15, 0.09); }
#dose-svg .band-edge { stroke: rgba(255, 95, 15, 0.4); stroke-dasharray: 3 6; stroke-width: 1; }
#dose-svg .curve-a { fill: none; stroke: #ff7a1a; stroke-width: 2.6; stroke-linecap: round; }
#dose-svg .curve-a-glow { fill: none; stroke: #ff5f0f; stroke-width: 10; opacity: 0.16; stroke-linecap: round; }
#dose-svg .curve-b { fill: none; stroke: rgba(191, 233, 255, 0.55); stroke-width: 1.7; stroke-dasharray: 5 5; }
#dose-svg .area-a { fill: url(#grad-area); }
#dose-svg .ec-line { stroke: rgba(255, 95, 15, 0.4); stroke-dasharray: 2 4; }
#dose-svg .handle-ring { fill: none; stroke: rgba(255, 95, 15, 0.55); stroke-width: 1; }
#dose-svg .handle { fill: #fff3ea; stroke: #ff5f0f; stroke-width: 2; cursor: ew-resize; }
#dose-svg .handle-hit { fill: transparent; cursor: ew-resize; touch-action: none; }
#dose-svg .handle-label {
  fill: var(--orange-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
}
#dose-svg.is-hidden-b .curve-b { display: none; }

.dose-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 12px 8px 6px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.dose-legend .key { display: inline-flex; align-items: center; gap: 8px; }
.key-line { display: block; width: 20px; height: 2px; border-radius: 2px; }
.key-a { background: linear-gradient(90deg, #ff5f0f, #ffb066); }
.key-b { background: repeating-linear-gradient(90deg, rgba(191,233,255,.7) 0 4px, transparent 4px 8px); }
.key-swatch {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  background: rgba(255, 95, 15, 0.14);
  border: 1px solid rgba(255, 95, 15, 0.4);
}
.dose-legend .is-off { opacity: 0.35; }

.dose-controls { display: flex; flex-direction: column; gap: 20px; }
.dose-controls .ctrl { margin-bottom: 0; }
.dose-toggle { align-self: flex-start; }
.dose-stats { display: grid; gap: 10px; margin: 0; }
.dose-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}
.dose-stats dt {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.dose-stats dd { margin: 0; font-size: 0.88rem; color: var(--ink); }

@media (max-width: 900px) {
  .dose-grid { grid-template-columns: 1fr; }
  .dose-controls { order: 2; }
}

/* ---------- Patient year timeline ---------- */
.year-grid {
  display: grid;
  grid-template-columns: 1.32fr 0.68fr;
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}
.year-chart {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 10px 4px;
  background:
    radial-gradient(520px 300px at 24% 10%, rgba(255, 95, 15, 0.06), transparent 70%),
    #070708;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
#year-svg { display: block; width: 100%; height: auto; overflow: visible; }
#year-svg .month-line { stroke: rgba(255, 255, 255, 0.055); }
#year-svg .row-line { stroke: rgba(255, 255, 255, 0.09); }
#year-svg .axis-tick { stroke: rgba(255, 255, 255, 0.22); }
#year-svg .axis-line { stroke: rgba(255, 255, 255, 0.16); }
#year-svg .month-label {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-anchor: middle;
}
#year-svg .row-title {
  fill: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
}
#year-svg .row-sub {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}
#year-svg .row-total {
  fill: var(--orange-hot);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.12em;
}
#year-svg .row-total.is-cool { fill: rgba(191, 233, 255, 0.85); }
#year-svg .iv-bar {
  fill: #ff6a1a;
  opacity: 0;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), fill 0.2s;
}
#year-svg .iv-bar:hover { fill: #ffb066; }
#year-svg .sc-dot {
  fill: #bfe9ff;
  opacity: 0;
  transition: fill 0.2s;
}
#year-svg .sc-dot:hover { fill: #fff; }
#year-svg.is-in .iv-bar,
#year-svg.is-in .sc-dot {
  animation: year-in 0.4s ease both;
  animation-delay: calc(var(--i) * 26ms);
}
@keyframes year-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #year-svg.is-in .iv-bar,
  #year-svg.is-in .sc-dot { animation: none; opacity: 1; }
}
.year-caption {
  padding: 10px 6px 6px;
  min-height: 1.4em;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.year-controls { display: flex; flex-direction: column; gap: 20px; }

.seg-toggle {
  display: inline-flex;
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.seg-toggle button {
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg-toggle button + button { border-left: 1px solid var(--line); }
.seg-toggle button:hover { color: var(--ink-muted); }
.seg-toggle button.is-active { background: rgba(255, 95, 15, 0.16); color: var(--orange-hot); }

.year-stats { display: grid; gap: 10px; margin: 0; }
.year-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}
.year-stats dt {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.year-stats dd { margin: 0; font-size: 0.88rem; color: var(--ink); }

@media (max-width: 900px) {
  .year-grid { grid-template-columns: 1fr; }
  .year-controls { order: 2; }
}

/* ---------- Header extras ---------- */
.lab-head-links {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4vw, 28px);
}
.lab-assump-btn {
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.lab-assump-btn:hover {
  color: var(--orange-hot);
  border-bottom-color: var(--orange);
}

/* ---------- Mechanism cascade ---------- */
.mech { display: grid; gap: clamp(24px, 4vw, 44px); }
.mech-flow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(10px, 2vw, 20px);
  padding: 26px 0 10px;
}
.mech-flow::before {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  top: 54px;
  height: 1px;
  background: linear-gradient(90deg,
    rgba(255, 95, 15, 0.05),
    rgba(255, 95, 15, 0.35),
    rgba(255, 95, 15, 0.05));
}
.mech-node {
  position: relative;
  padding: 18px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  opacity: 0.55;
  transition: opacity 0.4s, border-color 0.4s;
}
.mech-node.is-on {
  opacity: 1;
  border-color: rgba(255, 95, 15, 0.35);
}
.mech-node.is-on::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--orange-hot);
  box-shadow: 0 0 14px rgba(255, 95, 15, 0.8);
}
.mech-k {
  display: block;
  min-height: 2.4em;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.mech-v {
  display: block;
  margin: 6px 0 10px;
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: var(--ink);
}
.mech-bar {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.mech-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-hot));
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.mech-sub {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.mech-signal {
  position: absolute;
  top: 51px;
  left: 8%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 12px 2px rgba(255, 95, 15, 0.9);
  opacity: 0;
  pointer-events: none;
}
.mech-flow.is-live .mech-signal {
  animation: mech-run 2.6s linear infinite;
  opacity: 1;
}
@keyframes mech-run {
  0% { left: 8%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { left: 92%; opacity: 0; }
}
.mech-controls { display: grid; gap: 18px; max-width: 640px; }
.mech-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mech-note {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--ink-faint);
}

/* ---------- Assumptions dialog ---------- */
.assump-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  z-index: 100;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b0c0e;
  color: var(--ink);
}
.assump-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.assump-close-form { float: right; margin: -8px -8px 0 0; }
.assump-close {
  background: none;
  border: 0;
  padding: 8px;
  color: var(--ink-faint);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.assump-close:hover { color: var(--orange-hot); }
.assump-dialog h2 { margin: 8px 0 18px; font-size: clamp(1.4rem, 3vw, 2rem); }
.assump-body h3 {
  margin: 18px 0 6px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orange);
}
.assump-body p { color: var(--ink-muted); font-size: 0.92rem; line-height: 1.65; }
.assump-dialog > form:last-child { margin-top: 20px; }

.linkish {
  display: inline-block;
  background: none;
  border: 0;
  padding: 0;
  color: var(--orange-hot);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }
.summary-tools { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.summary-aside .linkish { display: block; margin: 2px 0 14px; }

/* ---------- Mechanism responsive ---------- */
@media (max-width: 900px) {
  .mech-flow { grid-template-columns: repeat(2, 1fr); }
  .mech-flow::before, .mech-signal { display: none; }
}
@media (max-width: 620px) {
  .mech-flow { grid-template-columns: 1fr; }
  .lab-head { gap: 10px; padding: 0 14px; }
  .lab-head .brand-name { font-size: 0.82rem; }
  .lab-head-links { gap: 10px; }
  .lab-assump-btn { font-size: 0.58rem; letter-spacing: 0.08em; }
  .lab-back { font-size: 0.9rem; }
  .lab-back-word { display: none; }
  .step-head .kicker { display: block; max-width: 100%; font-size: 0.62rem; letter-spacing: 0.14em; }
  .step-head .kicker::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mech-flow.is-live .mech-signal { animation: none; opacity: 0; }
  .mech-bar i, .mech-node { transition: none; }
}

/* ---------- Print: summary as a one-pager ---------- */
@media print {
  body.lab { background: #fff; color: #000; }
  .lab-head, .rail, .lab-foot, .lab-cover, .noscript-note,
  .step-actions, .assump-dialog, #open-assumptions,
  .summary-actions, .summary-tools, .summary-back { display: none !important; }
  .lab-main { padding: 0; }
  .lab-step { display: none !important; padding: 0; }
  #step-summary { display: block !important; }
  #step-summary .step-head, .summary { display: block; }
  .summary-card {
    border: 1px solid #999;
    background: #fff;
    color: #000;
  }
  .summary-h, .summary-list dt, .summary-list dd,
  .summary-aside p, .step-lead, .step-head h2 { color: #000 !important; }
  a { color: #000; text-decoration: none; }
}
