:root {
  /* Colors and fonts come from the shared design system (/assets/design.css);
     these names keep the rest of this stylesheet unchanged. Scene, particle and
     field colors carry meaning and stay as they were. */
  --brand-accent: var(--accent);
  --brand-accent-strong: var(--accent-hover);
  --bg-color: var(--bg);
  --bg-pattern: var(--bg-grid);
  --text-main: var(--ink);
  --text-secondary: var(--ink-2);
  --brand-primary: var(--accent);
  --scene-accent: #0D9488;
  --scene-accent-strong: #0F766E;
  --card-bg: var(--surface);
  --card-border: var(--line);
  --card-shadow: var(--shadow-1);
  --soft-shadow: var(--shadow-1);
  --muted-bg: var(--surface-3);
  --input-border: var(--line-strong);
  --nav-bg: var(--surface);
  --nav-border: var(--line);
  --viewer-bg: var(--surface-3);
  --overlay-bg: var(--surface);
  --focus: var(--accent);
  /* Physics colors shared by the 3D scene, legend and graphs. */
  --north: #D45132;
  --south: #1675BB;
  --field: #0D9488;
  --current: #E07A10;
  --current-marker: #00C8F0;
  --force: #B5179E;
  --copper: #B8733D;
  --steel: #8E99A4;
  --carbon: #4A5360;
  --neutral: #657481;
  /* Supply polarity in the DC motor: the + and − brushes, their leads, and the half-ring each one touches. */
  --plus: #EAB308;
  --minus: #475569;
  --correct-border: #3F7A55;
  --retry-border: #9E6B27;
}

[data-theme="dark"] {
  --scene-accent: #5EEAD4;
  --scene-accent-strong: #2DD4BF;
  --north: #EF6A48;
  --south: #4BA3E3;
  --field: #2DD4BF;
  --current: #FBA43C;
  --current-marker: #42E8FF;
  --force: #E879F9;
  --copper: #D08A50;
  --steel: #9AA5B0;
  --carbon: #5B6573;
  --neutral: #8C9AA6;
  --plus: #FACC15;
  --minus: #94A3B8;
  --correct-border: #4ADE80;
  --retry-border: #F0A64A;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg-color);
  background-image: radial-gradient(var(--bg-pattern) 1px, transparent 1px);
  background-size: 30px 30px;
  color: var(--text-main);
  font: 16px/1.65 var(--font-body);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; color: inherit; }
a { color: inherit; text-underline-offset: 4px; }
button:focus-visible, a:focus-visible, #viewer:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.mono { font-family: var(--font-mono); }

/* Floating banner */
.banner {
  position: sticky;
  top: var(--standalone-top);
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px max(20px, env(safe-area-inset-right)) 6px max(20px, env(safe-area-inset-left));
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: var(--soft-shadow);
}

/* Apps keep a plain title; one thin spectrum line under the banner marks the app as PanPhy. */
.banner::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--spectrum);
  opacity: 0.85;
  pointer-events: none;
}
.banner-logo { justify-self: start; display: flex; align-items: center; min-height: 48px; line-height: 0; }
.banner-logo img { display: block; width: 38px; height: 38px; object-fit: contain; }
.banner-title {
  justify-self: center;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.banner-actions { justify-self: end; display: flex; gap: 8px; align-items: center; }
#theme-button { --panphy-theme-button-size: 48px; }

main, footer { width: calc(100% - 48px); max-width: 1320px; margin: auto; }
.eyebrow { margin: 0; font-family: var(--font-mono); font-size: .76rem; letter-spacing: .12em; font-weight: 600; color: var(--brand-primary); }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 0 16px; }
.intro p { margin: 0; }
.intro > p { color: var(--text-secondary); font-size: .92rem; border-left: 3px solid var(--card-border); padding-left: 18px; }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.4rem, 2.3vw, 2rem); letter-spacing: -.03em; line-height: 1.1; margin: 6px 0 0; }
h1 span { color: var(--brand-primary); }

/* Mode chooser */
.models { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.models button {
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  gap: 2px;
  min-height: 76px;
  padding: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  text-align: left;
  transition: border-color .15s, background .15s, transform .15s;
}
.models button > span { font-family: var(--font-mono); font-size: .74rem; letter-spacing: .08em; font-weight: 600; color: var(--text-secondary); }
.models strong { font-size: 1.15rem; line-height: 1.25; }
.models small { color: var(--text-secondary); font-size: .85rem; }
.models button:hover { border-color: var(--brand-accent); transform: translateY(-1px); }
.models button[aria-pressed=true] { border-color: var(--brand-accent-strong); background: var(--brand-accent-strong); color: var(--accent-ink); }
[data-theme="dark"] .models button[aria-pressed=true] { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--accent-ink); }
.models button[aria-pressed=true] > span, .models button[aria-pressed=true] small { color: inherit; opacity: .85; }

.lab-strip { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 8px; color: var(--text-secondary); font-size: .8rem; }
.lab-strip b { margin-left: 12px; color: var(--text-main); }

/* Workspace: the 3D view with its study panels on the left, and everything you operate on the right. */
.workspace {
  scroll-margin-top: 72px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  overflow: clip;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}
.viewer-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 400px);
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 12px 16px;
  min-width: 0;
  padding: 16px 20px 20px;
  border-radius: inherit;
  background: var(--viewer-bg);
}
.viewer-heading { grid-column: 1; display: flex; align-items: center; gap: 8px 12px; min-height: 36px; font-family: var(--font-mono); font-size: .76rem; font-weight: 600; letter-spacing: .08em; }
#scene-title { margin-right: auto; }
#fullscreen { --panphy-fs-size: 48px; margin: -6px 0; }

.bench { grid-column: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.view-wrap { position: relative; display: flex; flex-direction: column; min-height: 0; }
/* contain: size keeps the canvas pixel size from feeding back into the viewer height. */
#viewer { position: relative; display: flex; flex-direction: column; flex: none; height: clamp(360px, calc(100vh - 300px), 620px); min-height: 0; contain: size; border-radius: 14px; background: var(--viewer-bg); touch-action: pan-y; overflow: hidden; }
/* Beside the console on the page, the 3D view grows to fill the whole left-hand column. */
.viewer-panel:not(.is-stacked):not(.is-fullscreen) .bench { align-self: stretch; }
.viewer-panel:not(.is-stacked):not(.is-fullscreen) :is(.stage, .view-wrap) { flex: 1 0 auto; }
.viewer-panel:not(.is-stacked):not(.is-fullscreen) #viewer { flex: 1 0 auto; height: auto; min-height: clamp(460px, calc(100vh - 200px), 820px); }
#viewer.is-hovering { cursor: pointer; }
#viewer > canvas { display: block; width: 100%; height: 0; flex: 1; min-height: 0; align-self: stretch; }
#load-status { position: absolute; inset: 30% 10%; margin: 0; text-align: center; color: var(--text-secondary); }

.overlay { position: absolute; z-index: 2; pointer-events: none; font-size: .74rem; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: .74rem; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--overlay-bg); border: 1px solid var(--card-border); }
.legend i { font-style: normal; display: inline-grid; place-items: center; border-radius: 50%; width: 18px; height: 18px; font-size: .72rem; font-weight: 800; color: #fff; }
.gesture { top: 8px; left: 10px; margin: 0; color: var(--text-secondary); }
.scale { top: 8px; right: 10px; margin: 0; padding: 3px 10px; border: 1px solid var(--input-border); border-radius: 999px; background: var(--overlay-bg); color: var(--text-secondary); font-family: var(--font-mono); font-size: .64rem; font-weight: 600; letter-spacing: .08em; white-space: nowrap; }

/* Console: controls first, then what the model shows.
   It fills the right-hand column from the top, so the heading and its fullscreen button sit over the 3D view only.
   Container queries let the same rules serve the page column, a phone and the fullscreen side column. */
.console { grid-column: 2; grid-row: 1 / span 2; container-type: inline-size; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.console > * { flex-shrink: 0; }
.deck, .readouts { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; }
.deck { display: flex; flex-direction: column; gap: 14px; padding: 14px; }
.deck > .experiment-controls, .deck > .section { border-top: 1px solid var(--card-border); padding-top: 14px; }
#action-hint { margin: -4px 0 0; color: var(--text-secondary); font-size: .8rem; line-height: 1.45; text-align: center; }

/* Playback bar under the 3D view */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar button, .speed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--card-bg);
  font-size: .85rem;
  font-weight: 700;
  transition: border-color .15s, background .15s;
}
.toolbar button:hover { border-color: var(--brand-accent); background: var(--muted-bg); }
.toolbar svg { width: 18px; height: 18px; flex: none; fill: currentColor; }
.toolbar svg .stroke { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#motion { min-width: 150px; }
#motion[aria-pressed=false] { border-color: var(--brand-accent-strong); color: var(--brand-accent-strong); }
.speed { padding: 0 6px 0 12px; cursor: pointer; }
.speed select { min-height: 40px; padding: 4px 8px; border: 0; border-radius: 8px; background: var(--muted-bg); color: var(--text-main); font: 600 .85rem var(--font-body); }
.speed select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#home-view { margin-left: auto; }
/* Labels that change keep the width of their widest label, so the bar does not jump. */
.toolbar [data-reserve] { display: inline-grid; justify-items: center; align-content: center; }
.toolbar [data-reserve]::after { content: attr(data-reserve); height: 0; overflow: hidden; visibility: hidden; }
/* The console beside the view is tall, so on screens wide enough for a one-row bar it stays pinned to the bottom of the screen while the view is in sight. */
@media (min-width: 1200px) {
  .viewer-panel:not(.is-stacked):not(.is-fullscreen) .playback { position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 4; margin: 0 -6px; padding: 6px; border-radius: 16px; background: var(--viewer-bg); box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .4); }
}
.playback-note { margin: -4px 0 0; font-size: .72rem; line-height: 1.45; color: var(--text-secondary); }
button:disabled { cursor: default; opacity: 0.9; }

/* The main action first, then the settings, then what to show. */
.fire {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 10px 18px;
  border: 0; border-radius: 14px;
  background: var(--brand-primary); color: var(--accent-ink);
  font-size: 1.02rem; font-weight: 800;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand-primary), transparent 72%);
  transition: filter .15s, transform .1s;
  --fire-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 3v8M7.5 6.5a7 7 0 1 0 9 0'/%3E%3C/svg%3E");
}
.fire::before { content: ''; flex: none; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--fire-icon) center / contain no-repeat; mask: var(--fire-icon) center / contain no-repeat; }
.fire[aria-pressed=true] { background: var(--text-main); color: var(--bg-color); box-shadow: none; }
.fire:hover { filter: brightness(1.07); }
.fire:active { transform: translateY(1px); }
.action {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 8px 14px;
  border: 1px solid color-mix(in srgb, var(--brand-primary), transparent 50%); border-radius: 12px;
  background: var(--card-bg); color: var(--brand-primary);
  font-size: .9rem; font-weight: 700; touch-action: manipulation;
}
.action:hover:not(:disabled):not([aria-pressed=true]) { background: var(--muted-bg); }
.action[hidden] { display: none; }

.experiment-controls { display: flex; flex-direction: column; gap: 16px; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-title { font-family: var(--font-mono); font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-secondary); }
/* Each setting is one row: its name on the left, exact stepping on the right. */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.setting-label { font-size: .88rem; font-weight: 600; line-height: 1.3; }
.stepper { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.stepper button {
  min-width: 48px; min-height: 48px; padding: 8px 0;
  border: 1px solid var(--input-border); border-radius: 12px; background: var(--card-bg);
  font: 700 1.1rem var(--font-body); color: var(--text-main); touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.stepper button:hover:not(:disabled) { border-color: var(--brand-accent); background: var(--muted-bg); }
.stepper input {
  width: 78px; min-height: 48px; padding: 0 4px;
  border: 1px solid var(--input-border); border-radius: 12px; background: var(--card-bg);
  color: var(--text-main); text-align: center; font: 600 1rem var(--font-mono); letter-spacing: 0;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* On/off settings look like switches, so their state is never confused with an action. */
.switch-list { display: flex; flex-direction: column; gap: 6px; }
.switch {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 48px; padding: 6px 10px 6px 14px;
  border: 1px solid var(--input-border); border-radius: 12px; background: var(--card-bg);
  font-size: .88rem; font-weight: 600; text-align: left; cursor: pointer; touch-action: manipulation;
}
.switch:hover { border-color: var(--brand-accent); }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch:has(.switch-input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.switch-track { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--input-border); transition: background .15s; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch[aria-pressed=true] .switch-track, .switch-input:checked + .switch-track { background: var(--brand-accent-strong); }
.switch[aria-pressed=true] .switch-track::after, .switch-input:checked + .switch-track::after { transform: translateX(18px); }

/* What the model is showing: one card, so the readouts read together. */
.readouts { display: grid; grid-template-columns: minmax(0, 1fr); overflow: hidden; border-left: 3px solid var(--brand-accent-strong); }
.observation { padding: 12px 16px; min-height: 96px; }
.observation strong { font-size: .95rem; }
.observation p { font-size: .84rem; line-height: 1.55; color: var(--text-secondary); margin: 4px 0 0; }
.turning-display { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--card-border); }
.turning-display svg { flex: 0 0 64px; width: 64px; height: 64px; }
.turning-display circle { fill: none; stroke: var(--card-border); stroke-width: 2; stroke-dasharray: 3 4; }
#turning-arc { fill: none; stroke: var(--brand-accent-strong); stroke-width: 4; }
#turning-head { fill: var(--brand-accent-strong); }
.turning-display strong { font-size: .85rem; }
.turning-display p { margin: 4px 0 0; font-size: .78rem; color: var(--text-secondary); line-height: 1.5; }
/* Room for three lines, so a longer message does not move the cards below. */
.part-readout { margin: 0; min-height: calc(4.65em + 20px); padding: 10px 16px; border-top: 1px solid var(--card-border); background: var(--muted-bg); color: var(--text-main); font-size: .8rem; line-height: 1.55; }

/* Info boxes: the graphs and the end view float over the 3D view and fold away to a tab, as the star sim's HR inset does. */
.info-dock { position: absolute; inset: 40px 10px 10px; z-index: 3; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; pointer-events: none; }
.info-box { display: flex; flex-direction: column; max-height: 100%; min-width: 0; pointer-events: auto; border: 1px solid var(--card-border); border-radius: 12px; background: var(--overlay-bg); box-shadow: 0 4px 14px -8px rgba(0, 0, 0, .35); }
.info-box[hidden] { display: none; }
.info-box summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; cursor: pointer; font-family: var(--font-mono); font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; list-style: none; white-space: nowrap; }
.info-box summary::-webkit-details-marker { display: none; }
.info-box summary::before { content: ''; width: 6px; height: 6px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-135deg); transition: transform .18s ease; }
.info-box[open] summary::before { transform: translateY(-2px) rotate(45deg); }
.info-box summary:focus-visible, .study-controls input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.info-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 10px 10px; scrollbar-width: thin; }
#measurements { width: clamp(230px, 36%, 300px); }

.equation { font-family: var(--font-mono); font-size: .74rem; line-height: 1.5; }
.equation .row { display: flex; justify-content: space-between; gap: 10px; }
.equation .row span:first-child { color: var(--text-secondary); }
.equation .formula { font-size: .9rem; font-weight: 600; margin-bottom: 2px; }
.equation .sub { color: var(--text-secondary); font-size: .72rem; }
.equation b { font-weight: 600; color: var(--brand-primary); }
.equation .status { margin-top: 4px; font-size: .72rem; font-weight: 600; line-height: 1.5; }
/* The AC status changes as the coil settles; two lines are kept for it so the box never changes height. */
body[data-mode="ac"] .equation .status { min-height: 3em; }
.equation .status.good { color: var(--correct-border); }
.equation .status.warn { color: var(--retry-border); }
.graph canvas { display: block; width: 100%; height: auto; aspect-ratio: 300 / 170; flex: none; min-height: 0; }

/* The end view connects the brushes to the labeled coil sides. */
.endview { width: clamp(210px, 30%, 250px); }
.endview canvas { display: block; width: min(100%, 170px); height: auto; aspect-ratio: 1; flex: none; align-self: center; }
.endview p { margin: 0; font-family: var(--font-mono); font-size: .7rem; line-height: 1.45; color: var(--text-secondary); }
.endview .connection-key { font-family: var(--font-body); font-size: .7rem; }
.endview b { color: var(--text-main); font-weight: 600; }

@container (min-width: 640px) {
  .readouts { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .turning-display { border-top: 0; border-left: 1px solid var(--card-border); }
  .readouts:has(.turning-display[hidden]) .observation { grid-column: 1 / -1; }
  .part-readout { grid-column: 1 / -1; }
}
@container (min-width: 600px) {
  .experiment-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; align-items: start; }
}

/* Stacked (narrow page or portrait fullscreen): one column. The 3D view stays pinned under the banner
   while the controls and readouts scroll beneath it, so the model is always in sight. */
.viewer-panel.is-stacked { display: flex; flex-direction: column; align-items: stretch; --pin-top: calc(var(--standalone-top, 0px) + 61px); }
.is-stacked .bench, .is-stacked .stage { display: contents; }
.is-stacked .view-wrap { position: sticky; top: var(--pin-top); z-index: 5; }
.is-stacked #viewer { height: clamp(230px, 40vh, 420px); border-radius: 0 0 14px 14px; box-shadow: 0 6px 10px -8px rgba(0, 0, 0, .35); }

/* Fullscreen: the 3D view fills the left-hand column without scrolling, and the console beside it scrolls on its own. */
body.viewer-expanded { overflow: hidden; }
.viewer-panel.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100%;
  height: 100%;
  height: 100dvh;
  border-radius: 0;
  --fs-top: max(10px, env(safe-area-inset-top), var(--standalone-top, 0px));
  padding: var(--fs-top) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.viewer-panel.is-fullscreen:not(.is-stacked) { grid-template-columns: minmax(0, 1fr) clamp(320px, 30vw, 420px); grid-template-rows: auto minmax(0, 1fr); align-items: stretch; overflow: hidden; }
.is-fullscreen:not(.is-stacked) .bench { min-height: 0; overflow: hidden; }
.is-fullscreen:not(.is-stacked) .stage, .is-fullscreen:not(.is-stacked) .view-wrap { flex: 1 1 0; min-height: 0; }
.is-fullscreen:not(.is-stacked) #viewer { flex: 1 1 0; height: auto; }
.is-fullscreen:not(.is-stacked) .console { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 4px 4px; margin: 0 -4px; scrollbar-width: thin; }
.viewer-panel.is-fullscreen.is-stacked { overflow-y: auto; overscroll-behavior: contain; padding-top: 0; --pin-top: calc(var(--fs-top) + 48px); }
.is-fullscreen.is-stacked .viewer-heading { position: sticky; top: 0; z-index: 6; flex: none; min-height: calc(var(--fs-top) + 48px); margin-bottom: -12px; padding-top: var(--fs-top); background: var(--viewer-bg); }
.is-fullscreen.is-stacked #fullscreen { margin: 0; }
.is-fullscreen.is-stacked > *, .is-fullscreen.is-stacked .bench > *, .is-fullscreen.is-stacked .stage > * { flex-shrink: 0; }

/* Guide: what the model shows. */
.guide { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 8px 40px; margin-top: 20px; padding: 26px; border: 1px solid var(--card-border); border-radius: 20px; background: var(--card-bg); box-shadow: var(--card-shadow); }
.guide h2 { font-size: 1.35rem; line-height: 1.15; margin: 10px 0 14px; }
.guide p { color: var(--text-secondary); font-size: .92rem; margin: 8px 0 20px; }
h3 { font-size: .88rem; margin: 0; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.idea h3 .icon { color: var(--brand-accent-strong); }
.idea { border-left: 3px solid var(--brand-accent); border-radius: 0 12px 12px 0; padding: 13px 16px; margin: 20px 0 0; background: var(--muted-bg); }
.idea p { margin: 6px 0 0; }
.level { display: inline-block; margin: 0 0 12px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--input-border); font-family: var(--font-mono); font-size: .7rem; letter-spacing: .06em; color: var(--text-secondary); }
.deeper { border: 1px dashed var(--input-border); border-radius: 12px; padding: 12px 16px; margin: 0; }
.deeper p { margin: 6px 0 0; font-size: .88rem; }
.deeper h3 { color: var(--brand-primary); }

.reality { display: flex; gap: 24px; padding: 28px 0; max-width: 1030px; }
.reality > span { font-size: 2rem; color: var(--brand-primary); }
.reality h2 { font-size: 1rem; margin: 0 0 8px; }
.reality p { color: var(--text-secondary); font-size: .9rem; margin: 6px 0; }
footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--card-border); padding: 22px 0 max(30px, env(safe-area-inset-bottom)); color: var(--text-secondary); font-size: .78rem; }
.no-script { padding: 24px; }

@media (max-width: 1100px) {
  .models strong { font-size: 1.05rem; }
}
@media (max-width: 860px) {
  .guide { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  main, footer { width: calc(100% - 28px); }
  .banner { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .banner-title { font-size: 0.95rem; }
  .intro { display: block; padding: 16px 0 14px; }
  .intro > p { margin-top: 12px; font-size: .88rem; }
  .models { gap: 6px; }
  .models button { min-height: 60px; padding: 8px 10px; border-radius: 12px; }
  .models button > span { font-size: .62rem; letter-spacing: .04em; }
  .models strong { font-size: .9rem; }
  .models small { font-size: .68rem; line-height: 1.25; }
  .lab-strip { flex-direction: column; align-items: flex-start; gap: 0; }
  .viewer-panel { padding: 8px 12px 12px; gap: 12px; }
  .viewer-heading { font-size: .7rem; }
  .scale { font-size: .56rem; padding: 2px 8px; }
  .legend { gap: 4px; font-size: .7rem; }
  .gesture { display: none; }
  .deck { padding: 12px; }
  .info-dock { inset: 34px 8px 8px; gap: 8px; }
  .info-box summary { padding: 0 10px; font-size: .62rem; }
  .endview canvas { width: min(100%, 140px); }
  .part-readout { min-height: 72px; }
  .toolbar { gap: 6px; }
  .toolbar button, .speed { flex: 1 1 auto; gap: 6px; padding: 8px 10px; white-space: nowrap; font-size: .82rem; }
  #motion { min-width: 0; }
  #home-view { margin-left: 0; }
  .guide { padding: 20px; }
  .reality { gap: 12px; }
  footer { flex-direction: column; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .models button, .toolbar button, .fire, .switch-track, .switch-track::after, .info-box summary::before { transition: none; }
  .models button:hover { transform: none; }
}

