:root {
  --navy: #082b43;
  --navy-2: #124968;
  --blue: #086bd8;
  --cyan: #19b9cb;
  --teal: #168c83;
  --ink: #0c263a;
  --muted: #667b8c;
  --line: #cbdbe5;
  --soft: #f3f8fb;
  --white: #fff;
  --warm: #fff6df;
  --green: #e8f7ef;
  --orange: #ffead9;
  --shadow: 0 18px 48px rgba(8, 43, 67, .1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, select, input { font: inherit; }
button { cursor: pointer; }

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  padding: .65rem .85rem;
  color: white;
  background: var(--navy);
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.lab-hero {
  position: relative;
  overflow: hidden;
  padding: 2.1rem clamp(1.25rem, 4vw, 4rem);
  color: white;
  background:
    radial-gradient(circle at 82% 20%, rgba(25, 185, 203, .34), transparent 28%),
    linear-gradient(135deg, #06273e, #14516e);
}
.lab-hero::after {
  content: "";
  position: absolute;
  right: -9rem;
  bottom: -13rem;
  width: 31rem;
  height: 31rem;
  border: 4rem solid rgba(255,255,255,.045);
  border-radius: 50%;
}
.hero-content { position: relative; z-index: 1; max-width: 960px; }
.eyebrow, .small-label {
  margin: 0;
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.eyebrow { color: #9ddfeb; }
.lab-hero h1 {
  margin: .45rem 0 .5rem;
  font-size: clamp(2.35rem, 6vw, 5.5rem);
  line-height: .93;
  letter-spacing: -.05em;
}
.lab-hero .subtitle {
  max-width: 780px;
  margin: 0;
  color: #d9ebf2;
  font-size: clamp(.98rem, 1.6vw, 1.2rem);
  line-height: 1.55;
}
.lab-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  max-width: 1800px;
  margin: 0 auto;
  min-height: calc(100vh - 190px);
}
.journey {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 1.5rem 1rem;
  color: white;
  background: var(--navy);
}
.journey-heading { display: grid; gap: .25rem; padding: 0 .5rem 1rem; }
.journey-heading .small-label { color: #9fc0d2; }
.journey-heading strong { font-size: 1.2rem; }
.point-navigation { display: grid; gap: .22rem; }
.point-button {
  display: grid;
  grid-template-columns: 2.1rem minmax(0,1fr);
  gap: .45rem;
  align-items: center;
  width: 100%;
  min-height: 2.4rem;
  padding: .4rem .55rem;
  border: 0;
  border-radius: .55rem;
  color: #dbe9ef;
  background: transparent;
  text-align: left;
}
.point-button:hover, .point-button:focus-visible { background: rgba(255,255,255,.1); }
.point-button.active { color: var(--navy); background: white; }
.point-number { font-weight: 900; }
.point-name { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.progress-area { margin-top: 1.2rem; padding: 0 .5rem; }
.progress-meta { display: flex; justify-content: space-between; color: #b7d0dc; font-size: .72rem; }
.progress-track { height: .3rem; margin-top: .45rem; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.16); }
.progress-bar { width: 5%; 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 h2 {
  margin: .35rem 0 0;
  font-size: clamp(1.8rem, 4vw, 3.7rem);
  line-height: 1;
  letter-spacing: -.045em;
}
.navigation-buttons { display: flex; gap: .5rem; }
.navigation-buttons button, .review-bar button, .action-button {
  min-height: 2.65rem;
  padding: .58rem .85rem;
  border: 1px solid var(--line);
  border-radius: .62rem;
  color: var(--ink);
  background: white;
  font-weight: 750;
}
.navigation-buttons .primary-button, .action-button.primary {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, .72fr);
  gap: 1rem;
}
.experiment-pane, .interpretation-pane, .review-bar, .review-answer, .code-companion {
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
}
.experiment-pane, .interpretation-pane { overflow: hidden; border-radius: 1.1rem; }
.question-block { padding: 1.35rem 1.5rem; border-bottom: 1px solid var(--line); }
.question-block .small-label, .reasoning-block .small-label, .review-bar .small-label, .code-companion .small-label { color: var(--blue); }
.question-block h3 { margin: .45rem 0 0; font-size: clamp(1.25rem, 2.4vw, 2.05rem); line-height: 1.14; }
.experiment-content { min-height: 470px; padding: 1.35rem; }
.interpretation-pane { align-self: start; }
.reasoning-block { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.reasoning-block:last-child { border-bottom: 0; }
.reasoning-block p { margin: .42rem 0 0; color: #4c6170; line-height: 1.48; }
.decision-block { background: var(--green); }
.connection-block { background: var(--warm); }

.simulator { display: grid; gap: 1rem; }
.surface-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.surface-head h4 { margin: .25rem 0 0; font-size: 1.2rem; }
.state-badge {
  flex: none;
  padding: .36rem .55rem;
  border: 1px solid #e3a03f;
  border-radius: 999px;
  color: #8b4c00;
  background: #fff4db;
  font-size: .66rem;
  font-weight: 900;
  letter-spacing: .09em;
}
.controls { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: .7rem; }
.controls label { display: grid; gap: .35rem; color: var(--muted); font-size: .7rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.controls select, .controls input[type="range"] { width: 100%; }
.controls select { min-height: 2.55rem; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: .55rem; background: white; }
.control-value { color: var(--ink); font-size: .8rem; letter-spacing: 0; text-transform: none; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: .55rem; }
.metric { min-width: 0; padding: .8rem; border-radius: .7rem; background: #edf4f7; }
.metric span { display: block; color: var(--muted); font-size: .68rem; }
.metric strong { display: block; margin-top: .25rem; font-size: 1.2rem; overflow-wrap: anywhere; }
.plot-frame { overflow: hidden; border: 1px solid var(--line); border-radius: .8rem; background: #fbfdfe; }
.plot-frame svg { display: block; width: 100%; height: auto; min-height: 270px; }
.plot-grid { stroke: #e7eef2; stroke-width: 1; }
.plot-axis { stroke: #92a8b5; stroke-width: 1.2; }
.plot-point { transition: cx 180ms ease, cy 180ms ease; }
.surface-note { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }

.gridworld { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(190px, .55fr); gap: .8rem; }
.world-grid { display: grid; grid-template-columns: repeat(5, 1fr); aspect-ratio: 1; border: 1px solid var(--line); border-radius: .8rem; overflow: hidden; }
.world-cell { display: grid; place-items: center; min-width: 0; border: 1px solid #e3edf2; color: var(--muted); background: #fbfdfe; font-size: .7rem; }
.world-cell.goal { background: #dff6e9; }
.world-cell.hazard { background: #ffe6de; }
.world-cell.agent { outline: 3px solid var(--blue); outline-offset: -4px; color: var(--navy); font-size: 1rem; font-weight: 900; background: #e3f1ff; }
.world-controls { display: grid; gap: .55rem; align-content: start; }
.policy-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.policy-actions button:nth-child(1) { grid-column: 2; }
.policy-actions button:nth-child(2) { grid-row: 2; grid-column: 1; }
.policy-actions button:nth-child(3) { grid-row: 2; grid-column: 2; }
.policy-actions button:nth-child(4) { grid-row: 2; grid-column: 3; }

.review-bar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-top: 1rem; padding: 1rem 1.15rem; border-radius: .9rem; }
.review-bar p { margin: .35rem 0 0; }
.review-answer { margin-top: .5rem; padding: 1rem 1.15rem; border-radius: .75rem; color: #4d6372; }
.code-companion { margin-top: 1rem; border-radius: .9rem; overflow: hidden; }
.code-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); }
.code-head h3 { margin: .3rem 0 0; }
.code-boundary { color: var(--muted); font-size: .72rem; }
.code-companion pre { margin: 0; padding: 1.15rem; overflow: auto; color: #d9edf6; background: #071f31; font: .82rem/1.58 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.lab-footer { padding: 1.15rem; color: #bfd4df; background: var(--navy); text-align: center; font-size: .78rem; }

@media (max-width: 1080px) {
  .lab-shell { grid-template-columns: 1fr; }
  .journey { position: static; min-height: auto; }
  .point-navigation { grid-template-columns: repeat(5, minmax(0,1fr)); }
  .point-button { display: block; text-align: center; }
  .point-name { display: none; }
  .content-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .lab-hero { padding: 1.5rem 1.1rem; }
  .presentation { padding: .85rem; }
  .presentation-header, .review-bar, .surface-head { display: block; }
  .navigation-buttons { margin-top: .9rem; }
  .navigation-buttons button { flex: 1; }
  .point-navigation { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .controls, .metric-grid, .gridworld { grid-template-columns: 1fr; }
  .state-badge { display: inline-block; margin-top: .7rem; }
  .experiment-content, .question-block { padding: 1rem; }
  .world-grid { max-width: 420px; width: 100%; justify-self: center; }
  .code-head { align-items: start; flex-direction: column; }
}

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

/* === VIEWPORT-STABLE JOURNEY RAIL · 2026-09-02 ===
   Keep long desktop curricula within the viewport; the existing compact
   layout below 1081px remains unchanged. */
@media (min-width:1081px){
  .lab-shell > .journey{
    max-height:100vh;
    overflow:hidden;
    overscroll-behavior:contain;
  }

  .lab-shell > .journey .point-navigation{
    max-height:calc(100vh - 210px);
    overflow-y:auto;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
  }
}


/* === ZOOM-STABLE ML REFLOW · 2026-09-02 ===
   Preserve the desktop journey rail while stacking the evidence panes before
   browser zoom makes either pane too narrow. */
.presentation,
.experiment-content{
  overflow-anchor:none;
}

.presentation img,
.presentation svg,
.presentation canvas,
.presentation video,
.presentation input,
.presentation select,
.presentation textarea{
  max-width:100%;
}

@media (min-width:1081px) and (max-width:1180px){
  .content-layout{
    grid-template-columns:minmax(0,1fr);
  }
}
/* === /ZOOM-STABLE ML REFLOW · 2026-09-02 === */
