:root {
  color-scheme: light;
  --ink: #0c263a;
  --ink-2: #124968;
  --blue: #086bd8;
  --cyan: #19b9cb;
  --teal: #168c83;
  --gold: #e8a600;
  --coral: #ef694b;
  --paper: #f3f8fb;
  --surface: #ffffff;
  --line: #cbdbe5;
  --muted: #667b8c;
  --soft-blue: #edf5ff;
  --soft-teal: #e8f7ef;
  --soft-gold: #fff6df;
  --shadow: 0 18px 48px rgba(8, 43, 67, 0.1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(36, 95, 168, 0.35);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 8px 12px;
  transform: translateY(-150%);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
}

.skip-link:focus { transform: translateY(0); }

.small-label,
.eyebrow {
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lab-hero {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 2.1rem clamp(1.25rem, 4vw, 4rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 520px);
  gap: clamp(2rem, 6vw, 7rem);
  align-items: center;
  overflow: hidden;
  border-radius: 0;
  background:
    radial-gradient(circle at 82% 20%, rgba(25, 185, 203, 0.34), transparent 28%),
    linear-gradient(135deg, #06273e, #14516e);
  color: #fff;
  box-shadow: none;
}

.lab-hero::after {
  content: "";
  position: absolute;
  right: -9rem;
  bottom: -13rem;
  width: 31rem;
  height: 31rem;
  border: 4rem solid rgba(255, 255, 255, 0.045);
  border-radius: 50%;
}

.hero-content { position: relative; z-index: 1; max-width: 960px; }

.lab-hero .eyebrow { color: #fff; }

.lab-hero h1 {
  margin: 0.45rem 0 0;
  font-size: clamp(2.35rem, 6vw, 5.5rem);
  font-weight: 800;
  line-height: 0.93;
  letter-spacing: -0.05em;
}

.hero-architecture {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.hero-architecture svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.hero-architecture .lane {
  stroke: rgba(198, 229, 244, 0.28);
  stroke-width: 1.5;
}

.hero-architecture .node {
  stroke: rgba(255, 255, 255, 0.86);
  stroke-width: 1.5;
}

.hero-architecture .node--demand { fill: #52c4bd; }
.hero-architecture .node--system { fill: #7e9ff3; }
.hero-architecture .node--earned { fill: #efbd46; }

.hero-progress {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.35rem;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.hero-progress::after {
  content: "";
  width: 88px;
  height: 3px;
  background: linear-gradient(90deg, var(--gold) 0 12%, rgba(255, 255, 255, 0.2) 12% 100%);
}

.lab-shell {
  width: 100%;
  max-width: 1800px;
  min-height: calc(100vh - 190px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

.journey {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  max-height: 100vh;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  background: #082b43;
  color: #fff;
  box-shadow: none;
  overflow: hidden;
}

.journey-heading {
  display: grid;
  gap: 0.25rem;
  grid-template-columns: 1fr auto;
  align-items: start;
  padding: 0 0.5rem 0.9rem;
}

.journey-heading .small-label { color: #9fc0d2; }
.journey-heading strong { max-width: 9rem; color: #b7d0dc; font-size: 0.78rem; line-height: 1.35; text-align: right; }

.stage-picker {
  display: none;
  margin: 15px 0;
}

.stage-picker span { display: block; margin-bottom: 5px; color: #b6cad7; font-size: 0.72rem; }
.stage-picker select { width: 100%; padding: 10px; border: 0; border-radius: 9px; }

.stage-navigation {
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  margin-top: 0;
  padding-right: 0.35rem;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: rgba(255,255,255,.42) transparent;
  scrollbar-width: thin;
}

.stage-navigation::-webkit-scrollbar { width: 6px; }
.stage-navigation::-webkit-scrollbar-track { background: transparent; }
.stage-navigation::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(255,255,255,.34); }

.stage-group { display: grid; gap: 0.18rem; margin: 0 0 0.9rem; }
.stage-group:last-child { margin-bottom: 0.2rem; }
.stage-group h3 {
  margin: 0;
  padding: 0.5rem 0.55rem 0.35rem;
  color: #8eb9ce;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  line-height: 1.35;
  text-transform: uppercase;
}

.stage-button {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.38rem 0.55rem;
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: #dbe9ef;
  text-align: left;
  cursor: pointer;
}

.stage-button:hover { background: rgba(255, 255, 255, 0.06); }

.stage-button.is-active {
  background: #fff;
  color: #082b43;
}

.stage-button .number {
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  font-weight: 850;
}

.stage-button .title { font-size: 0.76rem; font-weight: 740; line-height: 1.18; white-space: normal; }

.progress-area {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0.8rem 0.5rem 0;
}

.progress-area > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #b7d0dc;
  font-size: 0.72rem;
  font-weight: 760;
}

.progress-track {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress-track span { display: block; width: 25%; height: 100%; background: var(--cyan); transition: width 180ms ease; }

.presentation {
  min-width: 0;
  padding: clamp(1rem, 2.4vw, 2rem);
}

.presentation-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.2rem;
  margin-bottom: 1.1rem;
}

.presentation-header .eyebrow { margin: 0 0 4px; }

.presentation-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.7rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.navigation-buttons { display: flex; gap: 8px; }

.navigation-buttons button,
.review-bar button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 780;
  cursor: pointer;
}

.navigation-buttons .primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.navigation-buttons button:disabled { opacity: 0.32; cursor: default; }

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(285px, 0.65fr);
  gap: 1rem;
  align-items: start;
}

.experiment-pane,
.interpretation-pane,
.review-bar,
.review-answer,
.code-companion {
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.experiment-pane,
.interpretation-pane { min-width: 0; overflow: hidden; border-radius: 1.1rem; }

.question-block { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.question-block h3 {
  max-width: 28ch;
  margin: 7px 0 0;
  font-size: clamp(1.25rem, 2.4vw, 2.05rem);
  line-height: 1.14;
  letter-spacing: -0.025em;
}

.predict-block {
  padding: 15px 22px;
  display: grid;
  grid-template-columns: minmax(170px, 0.48fr) minmax(0, 1.52fr);
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(100deg, var(--soft-blue), #f4f9ff 70%);
}

.predict-block strong { display: block; margin-top: 3px; font-size: 0.82rem; }
.prediction-options { display: flex; flex-wrap: wrap; gap: 6px; }

.prediction-option {
  padding: 7px 9px;
  border: 1px solid #b9cbe0;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 760;
  cursor: pointer;
}

.prediction-option.is-selected {
  border-color: var(--blue);
  background: linear-gradient(135deg, #1769c2, #0756a8);
  color: #fff;
  box-shadow: 0 5px 12px rgba(23, 105, 194, 0.18);
}

.experiment-block { padding: 18px 20px 20px; }

.experiment-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
}

.experiment-heading h4 { margin: 3px 0 0; font-size: 1.05rem; }
.experiment-heading p { max-width: 420px; margin: 0; color: var(--muted); font-size: 0.73rem; }

.experiment-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.control-field {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, #fff, var(--soft-blue));
}

.control-field label,
.control-field .control-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 760;
}

.control-field output { color: var(--blue); }
.control-field input[type="range"] { width: 100%; margin: 9px 0 0; accent-color: var(--blue); }
.control-field select { width: 100%; margin-top: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-field input { width: 17px; height: 17px; accent-color: var(--teal); }

.system-board {
  overflow: hidden;
  border: 1px solid #b9cbe0;
  border-radius: 12px;
  background:
    linear-gradient(rgba(36, 95, 168, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 95, 168, 0.04) 1px, transparent 1px),
    #fbfdff;
  background-size: 22px 22px;
}

.system-board > header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #dbe5ee;
  background: rgba(255, 255, 255, 0.86);
}

.system-board > header span,
.system-board > header strong { display: block; }
.system-board > header span { color: var(--muted); font-size: 0.58rem; font-weight: 850; letter-spacing: 0.1em; }
.system-board > header strong { margin-top: 2px; font-size: 0.76rem; }

.decision-state {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--soft-teal);
  color: #06756d;
  font-size: 0.64rem;
  font-weight: 850;
}

.decision-state.is-defer { background: #fff3d7; color: #95640b; }
.decision-state.is-stop { background: #fde9e3; color: #a54831; }

.architecture-flow {
  min-height: 155px;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.architecture-node {
  position: relative;
  min-width: 82px;
  padding: 10px 11px;
  border: 1px solid #adc1d3;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 6px 18px rgba(16, 42, 67, 0.06);
}

.architecture-node strong,
.architecture-node span { display: block; }
.architecture-node strong { font-size: 0.7rem; }
.architecture-node span { margin-top: 2px; color: var(--muted); font-size: 0.56rem; text-transform: uppercase; }

.architecture-node.is-earned {
  border-color: #e8a600;
  background: var(--soft-gold);
  box-shadow: 0 0 0 2px rgba(232, 166, 0, 0.13);
}

.architecture-node.is-gated {
  border-color: var(--teal);
  background: var(--soft-teal);
  box-shadow: 0 0 0 2px rgba(7, 155, 145, 0.1);
}
.flow-arrow { color: #7e9bad; font-size: 0.95rem; }

.architecture-caption {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid #dbe5ee;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.7rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.metric-card {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f1f7fd);
}

.metric-card span,
.metric-card strong { display: block; }
.metric-card span { color: var(--muted); font-size: 0.58rem; font-weight: 790; text-transform: uppercase; }
.metric-card strong { margin-top: 2px; color: var(--ink); font-size: 0.82rem; }
.metric-card.is-good strong { color: #247a70; }
.metric-card.is-warn strong { color: #9a670a; }
.metric-card.is-stop strong { color: #a54831; }

.interpretation-pane { overflow: hidden; }

.interpretation-pane section { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.interpretation-pane section:last-child { border-bottom: 0; }
.interpretation-pane p { margin: 5px 0 0; color: var(--muted); font-size: 0.77rem; line-height: 1.5; }
.interpretation-pane .decision { background: var(--soft-teal); }
.interpretation-pane .decision p { color: #216f67; font-weight: 730; }
.interpretation-pane .connection { background: var(--soft-gold); }

.review-bar {
  margin-top: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.review-bar p { margin: 4px 0 0; font-size: 0.84rem; font-weight: 700; }
.review-bar button { flex: 0 0 auto; border-color: var(--blue); color: var(--blue); }
.review-bar button:hover { background: var(--soft-blue); }

.review-answer {
  margin-top: 7px;
  padding: 13px 16px;
  border-left: 3px solid var(--teal);
  color: var(--muted);
  font-size: 0.78rem;
}

.code-companion { margin-top: 14px; overflow: hidden; }
.code-companion summary {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
  list-style: none;
}

.code-companion summary::-webkit-details-marker { display: none; }
.code-companion summary > span:first-child { display: grid; gap: 2px; }
.code-companion summary strong { font-size: 0.86rem; }

.code-body {
  display: grid;
  grid-template-columns: minmax(200px, 0.38fr) minmax(0, 1.62fr);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: #0c263a;
  color: #dbe9f1;
}

.code-body > p { margin: 0; padding: 18px; background: #14364f; color: #bdd1dd; font-size: 0.74rem; }
.code-wrap { position: relative; min-width: 0; }
.code-wrap button {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 760;
  cursor: pointer;
}

.code-wrap pre { max-height: 360px; margin: 0; padding: 20px; overflow: auto; font: 0.72rem/1.58 ui-monospace, SFMono-Regular, Menlo, monospace; }

.lab-footer { padding: 1.15rem; color: #bfd4df; background: #082b43; font-size: 0.78rem; text-align: center; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  padding: 9px 12px;
  transform: translateY(160%);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.72rem;
  transition: transform 160ms ease;
}
.toast.is-visible { transform: translateY(0); }

@media (max-width: 1080px) {
  .lab-shell { grid-template-columns: 1fr; }
  .journey { position: static; height: auto; min-height: 0; max-height: none; }
  .stage-navigation { max-height: 420px; }
  .stage-button { grid-template-columns: 28px 1fr; }
  .stage-button .complete-dot { display: none; }
  .progress-area { margin-top: 16px; }
  .content-layout { grid-template-columns: 1fr; }
  .interpretation-pane { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .interpretation-pane section { border-right: 1px solid var(--line); }
  .interpretation-pane .connection { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .lab-hero { grid-template-columns: 1fr; gap: 1.2rem; padding: 1.5rem 1.1rem; }
  .hero-architecture { width: min(100%, 420px); }
  .journey { padding: 15px; }
  .stage-picker { display: block; }
  .stage-navigation { display: none; }
  .presentation { padding: 0.85rem; }
  .presentation-header { display: block; }
  .navigation-buttons { margin-top: 14px; }
  .question-block,
  .experiment-block { padding: 17px; }
  .question-block h3 { font-size: clamp(2rem, 10vw, 3rem); }
  .predict-block { grid-template-columns: 1fr; padding: 14px 17px; }
  .experiment-heading { display: block; }
  .experiment-heading p { margin-top: 6px; }
  .experiment-controls,
  .metric-grid,
  .interpretation-pane,
  .code-body { grid-template-columns: 1fr; }
  .interpretation-pane section { border-right: 0; }
  .interpretation-pane .connection { grid-column: auto; }
  .review-bar { display: block; }
  .review-bar button { margin-top: 12px; }
  .architecture-flow { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
