: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);
  --focus: var(--accent);
  /* Fates, shared by the mass scale, the charts and the stage chips. */
  --fate-wd: #0D9488;
  --fate-ns: #B7791F;
  --fate-bh: #7C3AED;
  --chart-grid: var(--line);
  --chart-band: rgba(13, 148, 136, 0.16);
  --chart-track: #C2410C;
  /* The 3D view is always deep space, in either theme. */
  --space: #08080A;
  --space-text: #EDEBE8;
  --space-muted: #A8A49C;
  --space-panel: rgba(17, 19, 25, 0.94);
  --space-border: rgba(255, 255, 255, 0.14);
  --space-orange: #FB923C;
  --space-teal: #5EEAD4;
}

[data-theme="dark"] {
  --scene-accent: #5EEAD4;
  --scene-accent-strong: #2DD4BF;
  --fate-wd: #2DD4BF;
  --fate-ns: #E0A445;
  --fate-bh: #A78BFA;
  --chart-band: rgba(94, 234, 212, 0.14);
  --chart-track: #FB923C;
}

*, *::before, *::after { box-sizing: border-box; }
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; touch-action: manipulation; }
a { color: inherit; text-underline-offset: 4px; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible, #viewer:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.mono { font-family: var(--font-mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 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); }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2.3rem); letter-spacing: -.03em; line-height: 1.1; margin: 6px 0 0; }
h1 span { color: var(--brand-primary); }
h3 { font-size: .88rem; margin: 0; }

/* Mass chooser */
.mass-panel {
  margin: 26px 0 18px;
  padding: 22px 24px 20px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}
.mass-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.fate { flex: 1 1 320px; max-width: 560px; margin: 0; padding: 10px 16px; border-left: 3px solid var(--fate-color, var(--brand-accent)); border-radius: 0 12px 12px 0; background: var(--muted-bg); font-size: .92rem; line-height: 1.5; }
.fate b { color: var(--fate-color, var(--brand-accent-strong)); }
.mass-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 20px; }
.mass-entry label { display: block; margin-bottom: 4px; font-family: var(--font-mono); font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }
.mass-entry small { display: block; margin-top: 4px; color: var(--text-secondary); font-size: .76rem; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button {
  min-width: 48px; min-height: 48px; padding: 8px 14px;
  border: 1px solid var(--input-border); border-radius: 12px; background: var(--card-bg);
  font: 700 1.2rem var(--font-body); color: var(--text-main);
}
.stepper button:hover:not(:disabled) { border-color: var(--brand-accent); background: var(--muted-bg); }
.stepper input {
  width: 96px; min-height: 48px; padding: 0 8px;
  border: 1px solid var(--input-border); border-radius: 12px; background: var(--card-bg);
  color: var(--text-main); text-align: center; font: 600 1.1rem var(--font-mono);
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { font-weight: 600; color: var(--text-secondary); margin-right: 4px; }
button:disabled { cursor: default; opacity: 0.9; }

.mass-scale { position: relative; padding-top: 2px; }
input[type=range] { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 48px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--input-border); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--input-border); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; border: 3px solid var(--card-bg); background: var(--brand-primary); box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--card-bg); background: var(--brand-primary); box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
/* The band and ticks are inset by half a thumb so they line up with the slider's travel. */
.fate-band { display: flex; gap: 2px; margin: -6px 13px 0; }
.fate-band span { min-width: 0; padding: 6px 8px; border-radius: 8px; color: #fff; font-size: .74rem; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fate-band b, .fate-band i { display: block; font-style: normal; overflow: hidden; text-overflow: ellipsis; }
.fate-band i { opacity: .85; font-size: .68rem; }
.band-wd { background: var(--fate-wd); }
.band-ns { background: var(--fate-ns); }
.band-bh { background: var(--fate-bh); }
[data-theme="dark"] .fate-band span { color: #111110; }
.ticks { position: relative; height: 20px; margin: 4px 13px 0; font-size: .7rem; color: var(--text-secondary); }
.ticks span { position: absolute; transform: translateX(-50%); }
.fate-key { display: none; flex-wrap: wrap; gap: 4px 14px; margin: 6px 13px 0; font-size: .76rem; color: var(--text-secondary); }
.fate-key span { display: inline-flex; align-items: center; gap: 6px; }
.fate-key i { width: 10px; height: 10px; border-radius: 3px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.presets button { min-height: 48px; padding: 6px 14px; border: 1px solid var(--input-border); border-radius: 999px; background: var(--card-bg); font-size: .84rem; color: var(--text-secondary); }
.presets button b { font-family: var(--font-mono); color: var(--text-main); margin-right: 4px; }
.presets button:hover { border-color: var(--brand-accent); }
.presets button[aria-pressed=true] { border-color: var(--brand-accent-strong); background: var(--brand-accent-strong); color: var(--accent-ink); }
.presets button[aria-pressed=true] b { color: inherit; }
[data-theme="dark"] .presets button[aria-pressed=true] { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--accent-ink); }

/* Workspace */
.workspace {
  scroll-margin-top: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}
.viewer-panel { display: flex; flex-direction: column; min-width: 0; padding: 20px; background: var(--viewer-bg); }
.viewer-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: .78rem; font-weight: 600; letter-spacing: .08em; }
#scene-title { margin-right: auto; color: var(--brand-primary); }
.scale { color: var(--text-secondary); font-size: .68rem; border: 1px solid var(--input-border); border-radius: 999px; padding: 4px 10px; }
#fullscreen { --panphy-fs-size: 48px; }
body.viewer-expanded { overflow: hidden; }
.side-controls { display: contents; }
.workspace.is-fullscreen { position: fixed; inset: 0; z-index: 1000; width: 100%; height: 100%; height: 100dvh; display: block; border: 0; border-radius: 0; box-shadow: none; background: var(--viewer-bg); }
.workspace.is-fullscreen aside { display: none; }
.workspace.is-fullscreen .viewer-panel { height: 100%; overflow: auto; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.workspace.is-fullscreen .viewer-panel > :not(#viewer), .workspace.is-fullscreen .side-controls > * { flex-shrink: 0; }
.workspace.is-fullscreen #viewer { flex: 1 0 260px; height: 0; min-height: 260px; }
/* Wide screens: the controls and the stage notes share a right-hand column beside the 3D view. */
@media (min-width: 900px) {
  .workspace.is-fullscreen { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 30vw, 460px); }
  .workspace.is-fullscreen #viewer { margin-bottom: 0; }
  .workspace.is-fullscreen aside { display: block; min-height: 0; overflow: auto; overscroll-behavior: contain; border-top: 0; border-left: 1px solid var(--card-border); padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) 20px; }
  .workspace.is-fullscreen aside .side-controls { display: block; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--card-border); }
  .workspace.is-fullscreen aside .live { background: var(--muted-bg); }
  .workspace.is-fullscreen aside .stages { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace.is-fullscreen aside .toolbar { justify-content: flex-start; }
  .workspace.is-fullscreen aside #reset { margin-left: 0; }
  .workspace.is-fullscreen aside .side-controls p { color: var(--text-main); margin-bottom: 12px; }
}

/* Size containment keeps the canvas pixel size from feeding back into the viewer height. */
/* The 3D view grows with the screen, never below its original 540px. */
#viewer { position: relative; display: flex; flex-direction: column; flex: 1; min-height: clamp(540px, calc(100vh - 300px), 720px); container-type: size; margin: 8px 0 12px; border-radius: 14px; touch-action: none; overflow: hidden; background: var(--space); color: var(--space-text); cursor: grab; }
#viewer:active { cursor: grabbing; }
#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: 40% 10% auto; margin: 0; text-align: center; color: var(--space-muted); }

.overlay { position: absolute; z-index: 2; pointer-events: none; font-size: .74rem; }
.readout { top: 10px; left: 10px; margin: 0; padding: 10px 12px; min-width: 216px; border-radius: 12px; background: var(--space-panel); border: 1px solid var(--space-border); line-height: 1.6; }
.readout div { display: flex; justify-content: space-between; gap: 14px; }
.readout dt { color: var(--space-muted); }
.readout dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; }
.readout div:first-child dd { color: var(--space-orange); }
.balance { left: 10px; bottom: 10px; width: 216px; padding: 8px 12px 9px; border-radius: 12px; background: var(--space-panel); border: 1px solid var(--space-border); }
.balance-labels { display: flex; justify-content: space-between; font-size: .64rem; font-weight: 600; letter-spacing: .08em; }
.balance-labels span:first-child { color: var(--space-orange); }
.balance-labels span:last-child { color: var(--space-teal); }
.balance-track { position: relative; height: 8px; margin: 5px 0 6px; border-radius: 4px; background: linear-gradient(90deg, rgba(251, 146, 60, .35), rgba(255, 255, 255, .1) 50%, rgba(94, 234, 212, .35)); }
.balance-track::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: rgba(255, 255, 255, .5); }
#balance-fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; transition: left .4s, right .4s, background .4s; }
#balance-marker { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: #fff; transition: left .4s; }
.balance p { margin: 0; font-size: .74rem; line-height: 1.35; color: var(--space-text); }
.true-scale, .mini-hr { right: 10px; width: 170px; margin: 0; padding: 6px; border-radius: 12px; background: var(--space-panel); border: 1px solid var(--space-border); }
.true-scale { bottom: 10px; }
.mini-hr { top: 10px; }
.true-scale canvas { display: block; width: 100%; height: auto; aspect-ratio: 300 / 220; flex: none; }
.mini-hr canvas { display: block; width: 100%; height: auto; aspect-ratio: 300 / 230; flex: none; }
.true-scale figcaption, .mini-hr figcaption { margin-top: 2px; font-size: .64rem; line-height: 1.35; text-align: center; color: var(--space-muted); }
.gesture { bottom: 10px; left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap; color: var(--space-muted); }
/* A short viewer (fullscreen on a phone held sideways) has no room for full-size insets. */
@container (max-height: 430px) {
  .true-scale, .mini-hr { width: 104px; }
  .true-scale figcaption, .mini-hr figcaption { display: none; }
}
@container (max-width: 700px) { .gesture { display: none; } }

.live { margin: 0 0 12px; min-height: calc(3.1em + 20px); padding: 10px 14px; border-radius: 12px; border-left: 3px solid var(--brand-accent); background: var(--card-bg); font-size: .84rem; line-height: 1.55; }

/* Fullscreen hides the mass panel, so its stepper, outcome and example stars move to the top of the controls. */
.fs-mass { display: flex; flex-direction: column; gap: 10px; margin: 0 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--card-border); }
.fs-mass .fate { flex: none; max-width: none; font-size: .84rem; }
.fs-mass .presets { margin-top: 0; gap: 6px; }
.fs-mass .presets button { padding: 4px 10px; font-size: .78rem; }

/* Timeline */
.stages { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.stages button {
  position: relative; display: block; width: 100%; height: 100%; min-height: 74px; padding: 7px 7px 10px; overflow: hidden;
  border: 1px solid var(--input-border); border-radius: 10px; background: var(--card-bg); text-align: left; line-height: 1.25;
}
.stages button > span { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: .62rem; font-weight: 600; color: var(--text-secondary); }
.stages button > strong { display: block; font-size: .76rem; font-weight: 700; overflow-wrap: break-word; }
.stages button > i { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--brand-primary); }
.stages button:hover { border-color: var(--brand-accent); }
.stages button[aria-current=step] { border-color: var(--brand-primary); box-shadow: inset 0 0 0 1px var(--brand-primary); }
.stages button.done > i { width: 100% !important; opacity: .45; }
.scrub { padding: 0 2px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.toolbar button {
  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:not(:disabled):not([aria-pressed=true]):not(.play) { 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; }
/* Play is the main action, so it is the one filled button. */
.toolbar button.play { min-width: 128px; border: 0; background: var(--brand-primary); color: var(--accent-ink); font-size: .95rem; font-weight: 800; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand-primary), transparent 72%); }
.toolbar button.play:hover { background: var(--brand-primary); filter: brightness(1.07); }
.toolbar button.play[aria-pressed=true] { background: var(--text-main); color: var(--bg-color); box-shadow: none; }
[data-reserve] { display: inline-grid; justify-items: center; align-content: center; }
[data-reserve]::after { content: attr(data-reserve); height: 0; overflow: hidden; visibility: hidden; }
.stage-nav { display: inline-flex; gap: 4px; }
.speed { display: inline-flex; border: 1px solid var(--input-border); border-radius: 12px; overflow: hidden; background: var(--card-bg); }
.speed button { border: 0; border-radius: 0; min-width: 48px; padding: 8px 10px; font-family: var(--font-mono); }
.speed button + button { border-left: 1px solid var(--input-border); }
.speed button[aria-pressed=true] { background: var(--brand-accent-strong); color: var(--accent-ink); }
[data-theme="dark"] .speed button[aria-pressed=true] { background: var(--brand-accent); color: var(--accent-ink); }
/* On/off settings look like switches, so their state is never confused with an action. */
.toolbar button.switch { gap: 12px; padding: 6px 10px 6px 14px; }
.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 { background: var(--brand-accent-strong); }
.switch[aria-pressed=true] .switch-track::after { transform: translateX(18px); }
.switch.nudge:not([aria-pressed=true]):not(:disabled) { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand-primary), transparent 75%); } }
#reset { margin-left: auto; }
.cutaway-note { margin: 6px 0 0; font-size: .76rem; color: var(--text-secondary); text-align: right; }
button:disabled { cursor: default; opacity: 0.9; }

/* Stage notes */
aside { border-left: 1px solid var(--card-border); padding: 26px; background: var(--card-bg); min-width: 0; }
aside h2 { font-size: 1.4rem; line-height: 1.12; margin: 8px 0 8px; }
aside p { color: var(--text-secondary); font-size: .92rem; margin: 0 0 12px; }
aside p b { color: var(--text-main); }
aside .tagline { color: var(--text-main); font-weight: 600; font-size: 1rem; margin-bottom: 16px; }
aside .note { font-size: .82rem; padding-left: 12px; border-left: 2px solid var(--input-border); }
aside.swap > :not(.side-controls) { animation: notes-in .45s ease both; }
/* Side by side, the 3D view sets the height and the notes scroll inside it, so the page does not jump when the notes change length. */
@media (min-width: 1081px) {
  .workspace:not(.is-fullscreen) aside { contain: size; overflow-y: auto; }
  .workspace:not(.is-fullscreen) aside::after { content: ''; display: block; position: sticky; bottom: -26px; height: 40px; margin-top: -40px; background: linear-gradient(transparent, var(--card-bg)); pointer-events: none; }
}
@keyframes notes-in { from { opacity: 0; transform: translateY(6px); } }
.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 { border-left: 3px solid var(--brand-accent); border-radius: 0 12px 12px 0; padding: 13px 16px; margin: 18px 0; background: var(--muted-bg); }
.idea h3 .icon { color: var(--brand-accent-strong); }
.idea p { margin: 6px 0 0; }
.layers { margin: 18px 0; padding: 14px 16px; border: 1px solid var(--card-border); border-radius: 12px; }
.layers h3 { color: var(--brand-primary); }
.layers-hint { font-size: .82rem; margin: 4px 0 10px; }
.layers ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.layers li button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 12px; border: 1px solid var(--input-border); border-radius: 10px; background: var(--card-bg); text-align: left; font-size: .86rem; font-weight: 600; }
.layers li button:hover { border-color: var(--brand-accent); }
.layers li button[aria-pressed=true] { border-color: var(--brand-primary); background: var(--muted-bg); box-shadow: inset 0 0 0 1px var(--brand-primary); }
.layers li i { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .25); }
.layers li em { margin-left: auto; font: 600 .66rem var(--font-mono); letter-spacing: .06em; color: var(--text-secondary); text-transform: uppercase; white-space: nowrap; }
.layer-info { margin: 10px 0 0; min-height: 3em; color: var(--text-main); font-size: .88rem; }
.deeper { border: 1px dashed var(--input-border); border-radius: 12px; padding: 0 16px; margin: 18px 0 0; }
.deeper summary { min-height: 48px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .88rem; font-weight: 700; color: var(--brand-primary); list-style: none; }
.deeper summary::-webkit-details-marker { display: none; }
.deeper summary::before { content: '+'; font: 600 1.1rem var(--font-mono); width: 1ch; }
.deeper[open] summary::before { content: '−'; }
.deeper p { font-size: .88rem; }

/* Charts */
.charts { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; margin: 18px 0; }
.card { padding: 24px; border: 1px solid var(--card-border); border-radius: 20px; background: var(--card-bg); box-shadow: var(--card-shadow); min-width: 0; }
.card h2 { font-size: 1.15rem; line-height: 1.15; margin: 6px 0 14px; }
.hr-wrap { position: relative; width: 100%; aspect-ratio: 5 / 4; }
.hr-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.caption { margin: 10px 0 0; font-size: .86rem; color: var(--text-secondary); }
.caption b { color: var(--text-main); }
.life-bar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; background: var(--muted-bg); border: 1px solid var(--card-border); }
.life-bar span { min-width: 1px; }
.durations { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: .78rem; }
.durations td { padding: 5px 4px; border-bottom: 1px solid var(--card-border); vertical-align: middle; }
.durations td:first-child { width: 22px; }
.durations td:first-child i { display: block; width: 12px; height: 12px; border-radius: 3px; }
.durations td:nth-child(2) { font-family: var(--font-body); font-weight: 600; }
.durations td:last-child { text-align: right; color: var(--text-secondary); white-space: nowrap; }
.durations tr.current td { color: var(--brand-primary); }
.durations tr.current td:last-child { color: var(--brand-primary); }

.reality { display: flex; gap: 20px; margin: 18px 0 30px; padding: 26px; border: 1px solid var(--card-border); border-radius: 20px; background: var(--card-bg); box-shadow: var(--card-shadow); }
.reality > span { font-size: 1.6rem; line-height: 1; color: var(--brand-primary); }
.reality h2 { font-size: 1.1rem; margin: 0 0 10px; line-height: 1.15; }
.reality p { margin: 0 0 10px; color: var(--text-secondary); font-size: .92rem; }
footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 0 0 max(28px, env(safe-area-inset-bottom)); color: var(--text-secondary); font-size: .82rem; }
footer a { min-height: 48px; display: inline-flex; align-items: center; }
.no-script { text-align: center; padding: 20px; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  aside { border-left: 0; border-top: 1px solid var(--card-border); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  main, footer { width: calc(100% - 24px); }
  .banner-title { font-size: 0.95rem; }
  .mass-panel { padding: 16px; margin-top: 16px; }
  .mass-row { grid-template-columns: 1fr; gap: 12px; }
  .viewer-panel { padding: 12px; }
  #viewer { flex: none; height: 560px; min-height: 560px; }
  .toolbar { gap: 6px; }
  .toolbar button { flex: 1 1 auto; padding: 8px 10px; white-space: nowrap; }
  .stage-nav, .speed { flex: 1 1 auto; }
  .stage-nav button { flex: 1 1 0; }
  .speed button { flex: 1 1 0; }
  #reset { margin-left: 0; }
  .cutaway-note { text-align: left; }
  .scale, .gesture { display: none; }
  .readout { min-width: 0; width: 190px; font-size: .68rem; padding: 8px 10px; }
  .balance { width: 190px; }
  .true-scale, .mini-hr { width: 124px; }
  .stages { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  aside, .card, .reality { padding: 18px; }
  .reality > span { display: none; }
  .fate-band i { display: none; }
}
@media (max-width: 480px) {
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .balance { width: auto; right: 142px; }
  .mini-hr { width: 108px; }
  .fate-band span { min-height: 18px; padding: 0; font-size: 0; }
  .fate-key { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
  .switch.nudge { animation: none; }
  .toolbar button, .switch-track, .switch-track::after { transition: none; }
  aside.swap > :not(.side-controls) { animation: none; }
  #balance-fill, #balance-marker { transition: none; }
}
