/* Live views keep the visual response beside the controls on compact laptop screens. */
.atlas-view-tabs {
  display: flex;
  gap: 3px;
  padding: 8px 12px 0;
  overflow-x: auto;
  background: #142a31;
  border-bottom: 1px solid #ffffff1a;
  scrollbar-width: thin;
}

.atlas-view-tab {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 3px 3px 0 0;
  background: transparent;
  color: #aebeb8;
  padding: 10px 14px 9px;
  font: 700 11px 'DM Sans', sans-serif;
  letter-spacing: .025em;
  cursor: pointer;
}

.atlas-view-tab:hover { color: #f7f3e8; background: #ffffff10; }
.atlas-view-tab[aria-selected="true"] { color: #f7f3e8; border-bottom-color: #e8b36d; background: #ffffff13; }
.atlas-view-tab:focus-visible { outline: 2px solid #e8b36d; outline-offset: -2px; }
.atlas-view-stage > [hidden] { display: none !important; }

.atlas-view-stage {
  display: block;
  min-height: 0;
  padding: 12px;
  background: #142a31;
}

.atlas-view-stage > .scene-wrap,
.atlas-view-stage > .chart-card,
.atlas-view-stage > .chart-wrap,
.atlas-view-stage > .scatter-wrap {
  margin: 0;
  width: 100%;
  height: clamp(400px, 52vh, 490px);
  min-height: 390px;
}

.atlas-view-stage > .scene-wrap {
  position: relative;
  background: radial-gradient(circle at 45% 45%, #20454b, #0f252d 72%);
}
.chart-card {
  display: flex;
  flex-direction: column;
}
.chart-card > .chart-kicker {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  flex: 0 0 auto;
  padding: 10px 16px 7px;
  background: rgba(14, 33, 40, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  line-height: 1.3;
}
.chart-card > .visual-chart {
  flex: 1 1 auto;
  height: 100% !important;
  min-height: 0 !important;
}
.atlas-view-stage > .chart-card { border: 1px solid #ffffff24; }
.atlas-view-stage > .chart-card .visual-chart { height: 100%; min-height: 0; }
.atlas-view-stage > .chart-wrap,
.atlas-view-stage > .scatter-wrap { display: flex; align-items: center; justify-content: center; background: #f9f7ef; border: 1px solid #d7ded1; }
.atlas-view-stage > .chart-wrap svg,
.atlas-view-stage > .scatter-wrap svg { display: block; max-height: 100%; }
.atlas-view-stage > .atlas-data-view {
  min-height: 360px;
  height: clamp(360px, 46vh, 450px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  border: 1px solid #ffffff24;
  background: linear-gradient(155deg, #1d3940, #173038 67%, #142a31);
}
.atlas-data-caption { color: #d7e5dc; font-size: 11px; letter-spacing: .11em; text-transform: uppercase; }
.atlas-data-view .matrix-four { width: min(100%, 570px); }
.atlas-data-view .matrix-four > div { padding: 20px; }
.atlas-data-view .vote-board { display: grid; width: min(100%, 570px); grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.atlas-data-view .vote-board span { display: grid; place-items: center; min-height: 52px; text-align: center; }

/* 3D stage Orbit & Reset controls */
.scene-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 6px;
}
.scene-ctrl-btn {
  appearance: none;
  cursor: pointer;
  background: rgba(16, 38, 45, 0.84);
  border: 1px solid rgba(168, 207, 192, 0.35);
  border-radius: 4px;
  color: #dff0e5;
  padding: 6px 10px;
  font: 700 10px 'DM Sans', sans-serif;
  letter-spacing: .04em;
  transition: background .15s, color .15s, border-color .15s;
}
.scene-ctrl-btn:hover {
  background: #254850;
  color: #fff;
}
.scene-ctrl-btn.active {
  background: #f2d291;
  color: #152d34;
  border-color: #f2d291;
}

/* Interactive Play / Step / Scrub bar */
.atlas-replay {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #18343d;
  border-bottom: 1px solid #ffffff22;
  color: #e6f1e7;
  min-height: 52px;
}
.atlas-replay button {
  cursor: pointer;
  border: 1px solid #bce6d266;
  border-radius: 4px;
  background: #bfe3cb;
  color: #153338;
  font: 700 11px 'DM Sans', sans-serif;
  padding: 7px 11px;
  white-space: nowrap;
}
.atlas-replay button:hover {
  background: #e2f4d7;
}
.atlas-replay .atlas-replay-step {
  background: #234650;
  color: #e4f2ea;
  border-color: #8ab5a855;
}
.atlas-replay .atlas-replay-step:hover {
  background: #2e5965;
}
.atlas-replay .atlas-replay-reset {
  background: transparent;
  color: #d9ece4;
  padding: 5px 9px;
  font-size: 16px;
}
.atlas-replay-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.atlas-replay-copy strong {
  font: 600 11px 'DM Sans', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.atlas-replay-copy span {
  font: 10px 'DM Sans', sans-serif;
  color: #9dbab5;
}
.atlas-replay-progress {
  height: 6px;
  min-width: 60px;
  flex: 1;
  background: #ffffff26;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
}
.atlas-replay-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7ccbb7, #f2d291);
  transition: width .08s linear;
}
.atlas-replay-time {
  font: 600 10px 'Space Grotesk', sans-serif;
  color: #b7d4cd;
  white-space: nowrap;
}

.related-reading {
  border-top: 1px solid #d8dccf;
  margin-top: 18px;
  padding-top: 14px;
}

.related-reading h4 {
  margin: 0 0 9px;
  color: #7c5d4d;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.related-reading p {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  gap: 7px;
  margin: 0 0 9px;
  color: #536860;
  font-size: 11px;
  line-height: 1.45;
}

.related-reading p::before {
  content: ''; width: 16px; height: 16px; margin-top: 3px; flex: none; background: #ae664b;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M9 7h8v8'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17L17 7M9 7h8v8'/%3E%3C/svg%3E") center / contain no-repeat;
}
.related-reading a { color: #285c57; text-decoration-color: #9dbab0; text-underline-offset: 2px; }
.related-reading a:hover { color: #aa5b42; }

.related-card {
  margin-top: 18px;
  border: 1px solid #cacbbd;
  background: #fffdf7;
  padding: 18px 22px;
}
.related-card .related-reading { margin: 0; padding: 0; border: 0; }
.related-card .related-reading p { display: inline-grid; width: min(48%, 590px); margin-right: 1%; vertical-align: top; }
.under-grid { align-items: start; }

/* Concept architecture diagram: trigger button and dialog */
.atlas-arch-box { margin: 16px 0 12px; }
.atlas-arch-btn {
  width: 100%; display: flex; align-items: center; gap: 14px;
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid #285c57; border-radius: 10px; background: #17363e; color: #f3f8f2;
  padding: 12px 14px; transition: background .15s ease, border-color .15s ease;
}
.atlas-arch-btn:hover { background: #1d4550; border-color: #f2d291; }
.atlas-arch-btn:focus-visible { outline: 2px solid #f2d291; outline-offset: 3px; }
.atlas-arch-btn-icon {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 9px; background: #f2d29122; color: #f2d291;
}
.atlas-arch-btn-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.atlas-arch-btn-text strong { font: 600 15px/1.25 'Space Grotesk', 'DM Sans', sans-serif; color: #f6f2e6; letter-spacing: 0; }
.atlas-arch-btn-text span { font: 13px/1.4 'DM Sans', sans-serif; color: #b8d3cb; }
.atlas-arch-badge { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: #f2d291; border: 1px solid #f2d29155; }

.atlas-arch-overlay {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(8, 20, 25, .82); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden; transition: opacity .16s ease, visibility 0s linear .16s;
}
.atlas-arch-overlay.is-open { opacity: 1; visibility: visible; transition: opacity .16s ease; }
html.atlas-arch-locked { overflow: hidden; }
.atlas-arch-modal {
  width: min(1000px, 96vw); max-height: 92vh; overflow: auto;
  border: 1px solid #f2d29166; border-radius: 14px; background: #112830;
  box-shadow: 0 24px 68px rgba(0, 0, 0, .6); padding: 18px 22px 22px; color: #eef5ec;
}
.atlas-arch-header { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.atlas-arch-header > div { flex: 1; min-width: 0; }
.atlas-arch-header-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; background: #f2d29122; color: #f2d291; }
.atlas-arch-kicker { display: block; font: 500 12.5px 'DM Sans', sans-serif; color: #9fbdb4; }
.atlas-arch-header h3 { margin: 1px 0 0; font: 600 21px/1.2 'Space Grotesk', 'DM Sans', sans-serif; color: #f6f2e6; letter-spacing: -.01em; }
.atlas-arch-close {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 9px; background: transparent; color: #e7efe9;
}
.atlas-arch-close:hover { background: rgba(255, 255, 255, .08); border-color: #f2d291; color: #f2d291; }
.atlas-arch-close:focus-visible { outline: 2px solid #f2d291; outline-offset: 2px; }
.atlas-arch-figure { width: 100%; border-radius: 10px; overflow: hidden; }
.atlas-arch-figure svg { display: block; width: 100%; height: auto; }
.atlas-arch-caption { margin: 14px 0 0; max-width: 72ch; font: 15px/1.6 'DM Sans', sans-serif; color: #c8ded7; }
.atlas-arch-caption strong { color: #f6f2e6; font-weight: 600; }
@media (max-width: 760px) {
  .atlas-arch-overlay { padding: 10px; }
  .atlas-arch-modal { padding: 14px; }
  .atlas-arch-header h3 { font-size: 17px; }
  .atlas-arch-caption { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .atlas-arch-overlay, .atlas-arch-overlay.is-open { transition: none; } }

@media (min-width: 761px) {
  .experiment { grid-template-columns: minmax(0, 1fr) minmax(280px, 320px); align-items: start; }
  .control-sheet { display: block; position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .control-sheet h3,
  .control-sheet > p,
  .control-sheet .readout { grid-column: auto; }
}

@media (max-width: 760px) {
  .experiment { grid-template-columns: 1fr; }
  .atlas-view-stage > .scene-wrap,
  .atlas-view-stage > .chart-card,
  .atlas-view-stage > .chart-wrap,
  .atlas-view-stage > .scatter-wrap { height: 340px; min-height: 340px; }
  .atlas-view-stage > .atlas-data-view { height: 340px; min-height: 340px; }
  .related-card .related-reading p { display: grid; width: 100%; margin-right: 0; }
}

@media (max-width: 600px) {
  .atlas-replay { gap: 6px; padding: 8px; }
  .atlas-replay-copy span, .atlas-replay-time { display: none; }
  .atlas-replay-copy strong { font-size: 10px; }
  .atlas-replay button { padding: 6px 8px; }
}

@media (max-width: 480px) {
  .atlas-view-stage { padding: 8px; }
  .atlas-view-stage > .scene-wrap,
  .atlas-view-stage > .chart-card,
  .atlas-view-stage > .chart-wrap,
  .atlas-view-stage > .scatter-wrap { height: 290px; min-height: 290px; }
  .atlas-view-stage > .atlas-data-view { height: 290px; min-height: 290px; padding: 12px; }
  .atlas-data-view .vote-board { gap: 5px; }
  .atlas-data-view .vote-board span { min-height: 40px; padding: 4px; font-size: 9px; }
  .atlas-view-tab { padding: 9px 11px; font-size: 10px; }
}

/* Teaching canvases (labs 31–100) keep their true 5:3 drawing proportions instead of stretching to the stage. */
.atlas-view-stage > .chart-card:has(> #lab-canvas),
.atlas-view-stage > #output-map-panel {
  height: auto;
  min-height: 0;
  aspect-ratio: 5 / 3;
  max-height: none;
  background: #0f2128;
  border-radius: 8px;
  overflow: hidden;
}
.chart-card > #lab-canvas,
#output-map-panel > canvas {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
}

/* On phones the 1000×600 diagram would shrink its labels to ~4px; keep a readable width and let readers pan. */
@media (max-width: 700px) {
  .atlas-view-stage > .chart-card:has(> #lab-canvas),
  .atlas-view-stage > #output-map-panel {
    display: block;
    aspect-ratio: auto;
    height: auto;
    min-height: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .chart-card > #lab-canvas,
  #output-map-panel > canvas {
    width: 720px;
    height: 432px;
    max-width: none;
  }
  .atlas-view-stage > .chart-card:has(> #lab-canvas)::before {
    content: 'Swipe sideways to see the whole diagram';
    position: sticky;
    left: 0;
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 7px 12px;
    background: #10262b;
    border-bottom: 1px solid #ffffff1a;
    color: #b9d0c8;
    font: 600 11px/1.3 'DM Sans', sans-serif;
  }
  /* Tab strips fade at the edge so readers can tell more views exist. */
  .atlas-view-tabs {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
    padding-right: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .atlas-replay-progress i,
  .tour-panel,
  .tour-focus { transition: none !important; animation: none !important; }
}

/* ---- Icons ---------------------------------------------------------------- */
.atlas-icon { display: block; flex: none; }

/* ---- Step transport (labs that register window.atlasTransport) ------------ */
.atlas-transport {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  min-height: 68px;
}
.atlas-transport .tp-buttons { display: flex; align-items: center; gap: 6px; }
.atlas-transport button { font: 600 12px 'DM Sans', sans-serif; }
.atlas-transport .tp-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border-radius: 10px;
  border: 1px solid #ffffff1f;
  background: #ffffff0d;
  color: #dcebe2;
  transition: background .15s, color .15s, transform .1s;
}
.atlas-transport .tp-btn:hover { background: #ffffff1c; color: #fff; }
.atlas-transport .tp-btn:active { transform: scale(.94); }
.atlas-transport .tp-btn:disabled { opacity: .35; cursor: default; background: #ffffff0d; }
.atlas-transport .tp-play {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px 0 14px;
  border-radius: 22px;
  border: 0;
  background: #f2d291;
  color: #14302f;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 4px 14px #00000033, inset 0 -2px 0 #0000001a;
  transition: background .15s, transform .1s;
}
.atlas-transport .tp-play:hover { background: #f7dfa9; }
.atlas-transport .tp-play:active { transform: scale(.97); }
.atlas-transport .tp-play.is-playing { background: #bfe3cb; }
.atlas-transport .tp-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; min-width: 0; }
.atlas-transport .tp-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.atlas-transport .tp-copy strong { min-width: 0; font: 600 14px 'DM Sans', sans-serif; color: #f2efe2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atlas-transport .tp-count { font: 600 13px 'DM Sans', sans-serif; color: #f2d291; font-variant-numeric: tabular-nums; white-space: nowrap; }
.atlas-transport .tp-track {
  position: relative; height: 22px; cursor: pointer; touch-action: none; border-radius: 11px;
}
.atlas-transport .tp-track::before {
  content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 2px; background: #ffffff1f;
}
.atlas-transport .tp-fill {
  position: absolute; left: 0; top: 9px; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, #7fd3b9, #f2d291);
}
.atlas-transport .tp-ticks i {
  position: absolute; top: 7px; width: 2px; height: 8px; margin-left: -1px; border-radius: 1px; background: #ffffff2e;
}
.atlas-transport .tp-thumb {
  position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%;
  background: #fff6dc; box-shadow: 0 0 0 4px #f2d29140, 0 2px 6px #0006;
}
.atlas-transport .tp-track:focus-visible { outline: 2px solid #f2d291; outline-offset: 3px; }
.atlas-transport .tp-speed {
  display: flex; padding: 3px; gap: 2px; border-radius: 10px; background: #ffffff0f; border: 1px solid #ffffff17;
}
.atlas-transport .tp-speed button {
  min-width: 44px; height: 34px; padding: 0 8px; border: 0; border-radius: 7px;
  background: transparent; color: #b8cdc4;
}
.atlas-transport .tp-speed button:hover { color: #fff; }
.atlas-transport .tp-speed button[aria-checked="true"] { background: #f2efe2; color: #14302f; }
.atlas-transport button:focus-visible { outline: 2px solid #f2d291; outline-offset: 2px; }

/* ---- Tooltips for icon-only buttons -------------------------------------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px);
  padding: 5px 9px; border-radius: 6px; background: #0b1d22; color: #f2efe2;
  font: 600 11px 'DM Sans', sans-serif; letter-spacing: 0; text-transform: none; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; z-index: 20;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* ---- 3D stage: icon toolbar, hint, legend --------------------------------- */
.scene-toolbar {
  top: 14px; right: 14px;
  flex-direction: column; gap: 2px; padding: 4px;
  border-radius: 12px; background: #0c2329d9; border: 1px solid #ffffff1a;
  box-shadow: 0 6px 18px #0004;
  backdrop-filter: blur(6px);
}
.scene-toolbar .scene-ctrl-btn {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 9px; background: transparent; color: #d7e7df;
}
.scene-toolbar .scene-ctrl-btn:hover { background: #ffffff1a; color: #fff; }
.scene-toolbar .scene-ctrl-btn.active { background: #f2d291; color: #14302f; }
.scene-toolbar [data-tip]::after { left: auto; right: calc(100% + 10px); bottom: 50%; transform: translate(4px, 50%); }
.scene-toolbar [data-tip]:hover::after, .scene-toolbar [data-tip]:focus-visible::after { transform: translate(0, 50%); }
.scene-hint {
  position: absolute; right: 16px; bottom: 16px; z-index: 2;
  padding: 6px 12px; border-radius: 999px; background: #0c2329cc; color: #cfe2d9;
  font: 500 12px 'DM Sans', sans-serif; pointer-events: none; transition: opacity .4s;
}
.scene-hint.is-gone { opacity: 0; }
.scene-legend {
  position: absolute; left: 16px; bottom: 14px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 6px 16px; max-width: calc(100% - 32px);
  padding: 8px 14px; border-radius: 10px; background: #0c2329d9; border: 1px solid #ffffff17;
  color: #dbe8e1; font: 500 12px 'DM Sans', sans-serif;
}
.scene-legend span { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.scene-legend i { display: inline-block; flex: none; }
.scene-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; background: #ffe7a3; box-shadow: 0 0 0 3px #ffe7a340; }
.scene-legend .lg-path { width: 18px; height: 3px; border-radius: 2px; background: #f2cf78; }
.scene-legend .lg-arrow { width: 16px; height: 2px; background: #fff1c4; position: relative; }
.scene-legend .lg-arrow::after { content: ""; position: absolute; right: -2px; top: -3px; border: 4px solid transparent; border-left: 6px solid #fff1c4; border-right: 0; }
.scene-legend .lg-ring { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #7fe0c4; }
.control-hint { margin-top: 18px; padding: 10px 12px; border-radius: 8px; background: #e9e4d6; color: #3f4f4b; font-size: 13px; line-height: 1.45; }

/* View tabs with a leading icon */
.atlas-view-tab .atlas-icon { display: inline-block; vertical-align: -3px; margin-right: 7px; opacity: .85; }

@media (max-width: 760px) {
  .atlas-transport { grid-template-columns: 1fr auto; gap: 10px 12px; padding: 10px 12px; }
  .atlas-transport .tp-copy strong { white-space: normal; font-size: 13px; line-height: 1.3; }
  .atlas-transport .tp-track { margin: 0 8px; }
  .scene-toolbar { flex-direction: row; }
  .scene-toolbar .scene-ctrl-btn { width: 34px; height: 34px; }
  .scene-toolbar [data-tip]::after { display: none; }
  .scene-hint { display: none; }
  .pager-next { justify-content: flex-end; }
  .atlas-transport .tp-main { grid-column: 1 / -1; grid-row: 1; }
  .atlas-transport .tp-play span { display: none; }
  .atlas-transport .tp-play { width: 44px; padding: 0; justify-content: center; }
  .scene-legend { font-size: 11px; gap: 4px 10px; padding: 6px 10px; left: 8px; bottom: 8px; }
  .scene-toolbar { top: 8px; right: 8px; }
}
/* The bar sits in a column that can be narrow on a wide screen, so it follows the panel's width:
   below 900px the title and track take their own row, above the buttons and speeds. */
.instrument:has(.atlas-transport) { container: atlas-instrument / inline-size; }
@container atlas-instrument (max-width: 900px) {
  .atlas-transport { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; }
  .atlas-transport .tp-main { grid-column: 1 / -1; grid-row: 1; }
  .atlas-transport .tp-copy strong { white-space: normal; line-height: 1.3; }
  .atlas-transport .tp-track { margin: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .atlas-transport *, .scene-hint, [data-tip]::after { transition: none !important; }
}

/* ---- Chapter pager (scripts/build_pager.py) ------------------------------- */
.topbar:has(.pager) { height: auto; min-height: 82px; gap: 20px; padding: 12px 0; }
.pager { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.pager-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; flex: 1 1 0; min-width: 0;
  padding: 6px 14px; border-radius: 12px; border: 1px solid #cfcabb; background: #fbf9f2;
  color: #1f3b3c; text-decoration: none; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.pager-btn:hover { background: #fff; border-color: #9fb3aa; box-shadow: 0 4px 14px #24403d14; }
.pager-btn:active { transform: translateY(1px); }
.pager-btn:focus-visible, .pager-menu summary:focus-visible { outline: 2px solid #2b6666; outline-offset: 2px; }
.pager-btn .atlas-icon { color: #2b6666; }
.pager-text { display: grid; min-width: 0; line-height: 1.2; }
.pager-next { justify-content: flex-end; }
.pager-next .pager-text { text-align: right; }
.pager-kicker { font: 600 11px 'DM Sans', sans-serif; color: #6a7a74; letter-spacing: .01em; }
.pager-title { font: 600 14px 'DM Sans', sans-serif; color: #1c3536; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager-mid { display: grid; gap: 5px; justify-items: center; min-width: 150px; padding: 0 6px; }
.pager-part { font: 600 11px 'DM Sans', sans-serif; color: #2b6666; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.pager-bar { position: relative; width: 140px; height: 4px; border-radius: 2px; background: #dcd7c8; overflow: hidden; }
.pager-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: linear-gradient(90deg, #2b6666, #c99a4b); }
.pager-count { font: 600 12px 'DM Sans', sans-serif; color: #4b5c57; font-variant-numeric: tabular-nums; }
.pager-menu { position: relative; }
.pager-menu summary {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  list-style: none; background: #1f3b3c; color: #f6f2e6; font: 600 13px 'DM Sans', sans-serif;
}
.pager-menu summary::-webkit-details-marker { display: none; }
.pager-menu summary:hover, .pager-menu[open] summary { background: #2b5050; }
.pager-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(380px, 92vw);
  max-height: min(70vh, 560px); display: grid; grid-template-rows: auto 1fr;
  border-radius: 14px; background: #fbf9f2; border: 1px solid #cfcabb; box-shadow: 0 18px 50px #1d302e38; overflow: hidden;
}
.pager-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #e2ddcf; color: #6a7a74; }
.pager-search input { flex: 1; border: 0; background: transparent; font: 500 14px 'DM Sans', sans-serif; color: #1c3536; outline: none; }
.pager-panel ol { list-style: none; margin: 0; padding: 6px; overflow: auto; }
.pager-group { padding: 12px 10px 4px; font: 700 11px 'DM Sans', sans-serif; color: #2b6666; }
.pager-panel a { display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px; color: #24393a; text-decoration: none; font: 500 13.5px 'DM Sans', sans-serif; }
.pager-panel a span { width: 24px; flex: none; color: #8a968f; font-variant-numeric: tabular-nums; }
.pager-panel a:hover { background: #ece7d9; }
.pager-panel a[aria-current="page"] { background: #1f3b3c; color: #f6f2e6; }
.pager-panel a[aria-current="page"] span { color: #f2d291; }
.pager-foot { display: grid; gap: 18px; padding-top: 26px; }
.pager-foot-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager-foot-nav .pager-btn { min-height: 64px; padding: 10px 18px; }
.pager-foot-nav .pager-title { font-size: 16px; }
.pager-foot > span { color: #62716b; font-size: 12px; }

@media (max-width: 1100px) {
  .pager-mid { display: none; }
}
@media (max-width: 760px) {
  .topbar:has(.pager) { flex-wrap: wrap; }
  .pager { flex-basis: 100%; justify-content: space-between; }
  .pager .pager-title { font-size: 13px; }
  .pager-menu summary span { display: none; }
  .pager-menu summary { padding: 0 13px; }
}
@media (max-width: 460px) {
  .pager .pager-title { display: none; }
  .pager .pager-kicker { font-size: 12px; color: #1c3536; }
}

/* ---- Inline link and button icons ---------------------------------------- */
.link-icon { display: inline-flex; vertical-align: -3px; margin-left: 5px; }
.link-icon .atlas-icon { width: 15px; height: 15px; }
.tour-actions button, .atlas-replay > button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.launchpad #tour-start {
  display: inline-grid; grid-template-columns: auto auto; align-items: center; gap: 12px; text-align: left;
  min-height: 52px; padding: 9px 20px 9px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
  box-shadow: 0 6px 16px #213f4029; transition: background .15s, transform .1s;
}
.launchpad #tour-start:active { transform: scale(.98); }
.tour-start-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #f2d291; color: #213f40; }
.tour-start-icon .atlas-icon { margin-left: 2px; }
.tour-start-text { display: grid; }
.launchpad #tour-start small { margin-top: 2px; font-size: 11px; }
.tour-actions button { font-size: 12px; padding: 8px 12px; border-radius: 8px; }
#tour-exit { margin-left: auto; padding: 8px; }
.tour-actions .atlas-icon { width: 16px; height: 16px; }
.launchpad-arrow .atlas-icon { width: 22px; height: 22px; }
.atlas-replay .atlas-icon { width: 16px; height: 16px; }
.method-icon .atlas-icon { width: 20px; height: 20px; }

/* Orbit camera cursor and touch handling: vertical swipes still scroll the page on phones. */
canvas:has(~ .scene-controls) { cursor: grab; touch-action: pan-y; }
.is-orbiting > canvas { cursor: grabbing; }

/* ---- Orientation gizmo (editor-style X/Y/Z, scene.js) ------------------- */
.scene-gizmo {
  position: absolute; top: 12px; left: 12px; z-index: 3; width: 96px; height: 96px;
  cursor: grab; touch-action: none; user-select: none;
}
.scene-gizmo:active { cursor: grabbing; }
.scene-gizmo .gz-bg { fill: #0a1e2433; stroke: #ffffff14; transition: fill .15s; }
.scene-gizmo:hover .gz-bg { fill: #0a1e24b3; }
.scene-gizmo text { font: 700 10.5px 'DM Sans', Arial, sans-serif; fill: #10262c; pointer-events: none; }
.scene-gizmo .gz-cap { cursor: pointer; }
.scene-gizmo .gz-cap.gz-off { cursor: inherit; }
.scene-gizmo .gz-cap:hover circle, .scene-gizmo .gz-cap:focus-visible circle { stroke: #fff6dc; stroke-width: 2; }
.scene-gizmo .gz-cap:focus { outline: none; }
@media (max-width: 760px) {
  .scene-gizmo { width: 72px; height: 72px; top: 8px; left: 8px; }
}

/* ---- Zoom-aware axis numbers (scene.js) ------------------------------------ */
.scene-ticks { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.scene-ticks .tk {
  position: absolute; left: 0; top: 0; margin: 6px 0 0 0; translate: -50% 0;
  font: 600 11px 'DM Sans', Arial, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap;
  text-shadow: 0 0 3px #0b1d22, 0 0 6px #0b1d22;
}
.scene-ticks .tk-x { color: #f19a86; }
.scene-ticks .tk-z { color: #93c3ec; }
.scene-ticks .tk-y { color: #b1dc9b; margin: -7px 0 0 0; translate: calc(-100% - 8px) 0; }
.scene-ticks .tk-name { font-size: 12.5px; font-weight: 700; margin-top: 0; translate: -50% -50%; }
.scene-ticks .tk-name.tk-y { translate: -50% -50%; }
.scene-legend .lg-proj { width: 16px; height: 3px; border-radius: 2px; }
.scene-legend .lg-break { flex-basis: 100%; height: 0; }
.scene-legend .lg-head { color: #9fb5ad; }

/* Stage captions sit where a legend goes; the legend wins when both exist. */
.scene-wrap:has(.scene-legend) .scene-caption { display: none; }
/* While the orbit hint shows (bottom right), the legend wraps clear of it. */
.scene-wrap:has(.scene-hint:not(.is-gone)) .scene-legend { max-width: calc(100% - 330px); }
@media (max-width: 760px) { .scene-wrap:has(.scene-hint:not(.is-gone)) .scene-legend { max-width: calc(100% - 16px); } }
/* On phones the camera toolbar runs along the top; in-stage lab buttons sit below it. */
@media (max-width: 760px) {
  .opt3d-switcher { top: 58px !important; right: 12px !important; max-width: none !important; }
}
.scene-gizmo[hidden], .scene-ticks[hidden] { display: none !important; }

/* "From the book" card (book-link.js) */
.book-card{margin:22px 0;padding:18px 20px;border-radius:12px;background:#f1ece0;border:1px solid #e0d6c2;border-left:4px solid #a45e39;color:#22363a}
.book-card-head{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:baseline;margin-bottom:8px}
.book-card-kicker{font:700 11px/1.2 "DM Sans",sans-serif;letter-spacing:.16em;text-transform:uppercase;color:#a45e39}
.book-card-ref{font:500 13px/1.3 "DM Sans",sans-serif;color:#4d5c59}
.book-card h3{margin:4px 0 8px;font:700 17px/1.2 "Space Grotesk","DM Sans",sans-serif;color:#163f44}
.book-card-steps{margin:0;padding-left:0;list-style:none;display:grid;gap:8px}
.book-card-steps label{display:flex;gap:10px;align-items:flex-start;cursor:pointer;font:15px/1.45 Georgia,serif}
.book-card-steps input{margin-top:4px;width:18px;height:18px;accent-color:#2d7b81;flex:none}
.book-card-steps input:checked+span{color:#637470;text-decoration:line-through;text-decoration-color:#a45e3966}
.book-card-steps input:focus-visible{outline:2px solid #2d7b81;outline-offset:2px}
.book-card-done{margin:10px 0 0;font:600 13px "DM Sans",sans-serif;color:#2d7b81}
.book-card-note{margin:3px 0 0 28px;font:italic 14px/1.4 Georgia,serif;color:#4d5c59}

/* ---- Phone layout ---------------------------------------------------------- */
/* Gets the lab itself close to the first screen and gives controls finger-sized targets. */
@media (max-width: 600px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  .hero { display: block !important; padding: 18px 0 14px !important; min-height: 0 !important; }
  .hero h1 { font-size: 34px !important; line-height: 1.05 !important; margin: 8px 0 !important; }
  .hero p { font-size: 15px !important; line-height: 1.5 !important; margin: 0 !important; }
  .hero .eyebrow { margin: 0 !important; }
  .hero-mark { display: none !important; }

  .launchpad { display: block !important; padding: 12px !important; margin: 0 0 14px !important; min-height: 0 !important; }
  .launchpad-heading, .launchpad-pair { display: none !important; }
  .launchpad #tour-start { width: 100%; min-height: 48px; margin: 0; justify-content: center; }

  .lab-intro { margin: 0 0 10px !important; padding: 0 !important; }
  .lab-intro h2 { font-size: 22px !important; line-height: 1.2 !important; margin: 0 0 4px !important; }
  .lab-intro p { font-size: 14px !important; margin: 0 !important; }

  .instrument-head { font-size: 11px; }
  .atlas-transport { grid-template-columns: minmax(0, 1fr) auto !important; gap: 8px !important; }
  .atlas-transport > *, .atlas-transport .tp-copy > * { min-width: 0; }
  .atlas-transport .tp-copy { flex-wrap: wrap; gap: 2px 10px; }
  .atlas-transport .tp-buttons { gap: 4px; }
  .atlas-transport .tp-btn, .atlas-transport .tp-play { width: 40px; height: 40px; min-width: 40px; padding: 0; }
  .atlas-transport .tp-speed button { min-height: 36px; padding: 0 8px; }
  .atlas-view-tabs { overflow-x: auto; }
  .atlas-view-tabs button { min-height: 44px; flex: 1 0 auto; }

  .control-sheet { padding: 18px 16px !important; }
  .control-sheet p, .viz-note, .related-reading p, .related-card p { font-size: 14px !important; line-height: 1.5 !important; }
  .control-sheet label { font-size: 13px !important; }
  .control-sheet input[type="range"] { min-height: 36px; }
  .control-sheet button, .control-sheet select { min-height: 44px; }
  /* 16px stops iOS from zooming the page when a field gets focus. */
  .control-sheet input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
  .control-sheet select, .control-sheet textarea { font-size: 16px !important; }

  .read-panel { overflow-x: auto; }
  .pager-foot .pager-title { white-space: normal !important; overflow: visible !important; font-size: 14px !important; line-height: 1.25; }
  .pager-foot-nav .pager-btn { padding: 10px 12px; }
}
