:root {
  color-scheme: dark;
  --bg: #080b10;
  --surface: #101722;
  --surface-strong: #172231;
  --text: #edf4ff;
  --muted: #9fb0c4;
  --line: rgba(196, 216, 238, 0.16);
  --accent: #6ee7c8;
  --accent-strong: #ffcf66;
  --danger: #ff7a8a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  --mandelbrot-bg: #02040a;
  --mandelbrot-sheen: rgba(255, 255, 255, 0.05);
  --radius: 8px;
  --max: 1180px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-strong: #e9eef4;
  --text: #101722;
  --muted: #526173;
  --line: rgba(28, 42, 58, 0.14);
  --accent: #007f68;
  --accent-strong: #a65f00;
  --shadow: 0 24px 70px rgba(30, 46, 64, 0.16);
  --mandelbrot-bg: #ecf2ef;
  --mandelbrot-sheen: rgba(0, 127, 104, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(110, 231, 200, 0.13), transparent 30rem),
    linear-gradient(135deg, rgba(255, 207, 102, 0.05), transparent 26rem),
    var(--bg);
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  padding: 0.6rem 0.8rem;
  color: var(--bg);
  background: var(--accent);
  border-radius: var(--radius);
  transform: translateY(-160%);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(18px);
  transition: border-color 180ms ease, background 180ms ease;
}

.site-header[data-elevated="true"] {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-color: var(--line);
}

.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max);
  min-height: 72px;
  padding: 0 1.25rem;
  margin: 0 auto;
  gap: 1rem;
}

.brand,
.nav-links,
.nav-actions,
.hero-actions,
.link-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface), var(--surface-strong));
  box-shadow: inset 0 0 22px rgba(110, 231, 200, 0.16);
}

.brand-mark__iris {
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.brand-text {
  font-size: 1.05rem;
}

.nav-links {
  gap: 0.35rem;
}

.nav-links a,
.link-row a,
.link-row span {
  min-height: 40px;
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.nav-links a:hover,
.link-row a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  border-color: var(--line);
}

.link-row span {
  cursor: default;
  opacity: 0.74;
}

.nav-actions {
  gap: 0.55rem;
}

.icon-button {
  display: grid;
  min-width: 42px;
  min-height: 42px;
  padding: 0 0.55rem;
  place-items: center;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button:hover {
  background: var(--surface-strong);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  transform: translateY(-1px);
}

.theme-icon {
  font-size: 1.18rem;
  line-height: 1;
}

.nav-menu-button {
  display: none;
}

.section-band {
  scroll-margin-top: 72px;
  padding: 6rem 1.25rem;
}

.hero {
  min-height: calc(100vh - 72px);
  display: grid;
  align-items: center;
  padding-top: 4rem;
}

.hero-grid,
.section-heading,
.category-grid,
.content-grid,
.timeline,
.about-grid,
.contact-panel,
.site-footer {
  width: min(100%, var(--max));
  margin: 0 auto;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(320px, 0.72fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}

.eyebrow {
  margin: 0 0 0.9rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  max-width: 9ch;
  font-size: clamp(4rem, 16vw, 9.5rem);
}

h2 {
  max-width: 14ch;
  font-size: clamp(2.2rem, 6vw, 4.5rem);
}

h3 {
  font-size: 1.25rem;
}

.hero-lede {
  max-width: 64ch;
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.hero-actions {
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  color: #04100d;
  background: var(--accent);
  border-color: transparent;
}

.button-secondary {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.place-panel {
  display: grid;
  min-height: 520px;
  padding: 1rem;
  align-content: space-between;
  gap: 1rem;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--surface) 86%, transparent), color-mix(in srgb, var(--surface-strong) 86%, transparent));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.place-panel__header,
.content-card__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.place-panel__header {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.place-panel__feature {
  display: grid;
  gap: 0.8rem;
  padding: clamp(1rem, 3vw, 1.35rem);
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.place-panel__feature h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.place-panel__feature p:not(.eyebrow) {
  max-width: 42ch;
  margin: 0;
  color: var(--muted);
}

.place-panel__feature .button {
  width: fit-content;
}

.place-panel__stats {
  display: grid;
  gap: 0.65rem;
  padding: 0;
  margin: 0;
}

.place-panel__stats div {
  min-width: 0;
  padding: 0.8rem 0.9rem;
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.place-panel__stats dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.place-panel__stats dd {
  margin: 0.25rem 0 0;
  font-weight: 800;
}

.categories-band,
.timeline-band {
  background: color-mix(in srgb, var(--surface) 28%, transparent);
  border-block: 1px solid var(--line);
}

.section-heading {
  margin-bottom: 2rem;
}

.archive-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.search-box {
  width: min(100%, 360px);
}

.search-box input {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.category-grid,
.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.category-tile,
.content-card,
.timeline-item,
.contact-panel {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.category-tile {
  min-height: 120px;
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.category-tile:hover,
.category-tile.is-active {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 56%, var(--line));
  transform: translateY(-2px);
}

.category-tile span {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.category-tile small {
  display: block;
  margin-top: 0.55rem;
  color: var(--muted);
}

.content-card {
  display: flex;
  min-height: 260px;
  padding: 1.1rem;
  flex-direction: column;
  gap: 1rem;
  transition: transform 180ms ease, border-color 180ms ease, opacity 180ms ease;
}

.content-card:hover {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
  transform: translateY(-4px);
}

.content-card--featured {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, transparent), transparent 58%),
    color-mix(in srgb, var(--surface) 88%, transparent);
}

.content-card[hidden] {
  display: none;
}

.content-card__meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.content-card p,
.about-copy p,
.timeline-item p {
  color: var(--muted);
}

.content-card a {
  width: fit-content;
  margin-top: auto;
  color: var(--accent);
  font-weight: 800;
}

.content-card__status {
  width: fit-content;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.empty-state {
  width: min(100%, var(--max));
  padding: 1rem;
  margin: 1rem auto 0;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.science-lab-band {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 30%, transparent), transparent 68%),
    color-mix(in srgb, var(--bg) 96%, var(--surface));
}

.mandelbrot-lab {
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1.65fr);
  grid-template-areas:
    "copy stage"
    "controls stage";
  gap: 1rem;
  width: min(100%, var(--max));
  margin: 0 auto;
}

.boids-lab {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1.65fr);
  grid-template-areas:
    "copy stage"
    "controls stage";
  gap: 1rem;
  width: min(100%, var(--max));
  scroll-margin-top: 88px;
  margin: 3.5rem auto 0;
  padding-top: 3.5rem;
}

.life-lab,
.three-body-lab {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1.65fr);
  grid-template-areas:
    "copy stage"
    "controls stage";
  gap: 1rem;
  width: min(100%, var(--max));
  scroll-margin-top: 88px;
  margin: 3.5rem auto 0;
  padding-top: 3.5rem;
}

.boids-lab::before,
.life-lab::before,
.three-body-lab::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.mandelbrot-copy,
.mandelbrot-controls,
.mandelbrot-stage,
.boids-copy,
.boids-controls,
.boids-stage,
.life-copy,
.life-controls,
.life-stage,
.three-body-copy,
.three-body-controls,
.three-body-stage {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.mandelbrot-copy {
  grid-area: copy;
  padding: 1.1rem;
}

.boids-copy {
  grid-area: copy;
  padding: 1.1rem;
}

.life-copy,
.three-body-copy {
  grid-area: copy;
  padding: 1.1rem;
}

.mandelbrot-copy h3,
.boids-copy h3,
.life-copy h3,
.three-body-copy h3 {
  margin-top: 0.8rem;
}

.mandelbrot-copy p,
.boids-copy p,
.life-copy p,
.three-body-copy p {
  color: var(--muted);
}

.boids-copy .boids-instrument-note {
  padding-top: 0.8rem;
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.three-body-copy .three-body-instrument-note {
  padding-top: 0.8rem;
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.mandelbrot-copy a,
.boids-copy a,
.life-copy a {
  display: inline-flex;
  margin-top: 0.7rem;
  color: var(--accent);
  font-weight: 800;
}

.mandelbrot-copy__links,
.boids-copy__links,
.life-copy__links,
.three-body-copy__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.9rem;
}

.mandelbrot-copy__links a,
.boids-copy__links a,
.life-copy__links a,
.three-body-copy__links a {
  margin-top: 0;
}

.mandelbrot-stage {
  position: relative;
  grid-area: stage;
  align-self: stretch;
  min-height: 620px;
  overflow: hidden;
  overscroll-behavior: contain;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background:
    linear-gradient(180deg, var(--mandelbrot-sheen), transparent),
    var(--mandelbrot-bg);
}

.boids-stage {
  position: relative;
  grid-area: stage;
  align-self: stretch;
  min-height: 560px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(circle at 18% 18%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 18rem),
    linear-gradient(180deg, var(--mandelbrot-sheen), transparent),
    color-mix(in srgb, var(--surface-strong) 64%, var(--bg));
}

.life-stage {
  position: relative;
  grid-area: stage;
  align-self: stretch;
  min-height: 560px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  background: var(--mandelbrot-bg);
}

.three-body-stage {
  position: relative;
  grid-area: stage;
  align-self: stretch;
  min-height: 560px;
  overflow: hidden;
  user-select: none;
  background:
    radial-gradient(circle at center, color-mix(in srgb, var(--accent) 8%, transparent), transparent 45%),
    var(--mandelbrot-bg);
}

.mandelbrot-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.boids-stage canvas,
.life-stage canvas,
.three-body-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.mandelbrot-stage.is-dragging,
.mandelbrot-stage.is-dragging canvas {
  cursor: grabbing;
}

.mandelbrot-status {
  position: absolute;
  inset: 1rem;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.boids-status {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.7rem;
  margin: 0;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 800;
}

.life-status {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.7rem;
  margin: 0;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 800;
  pointer-events: none;
}

.three-body-status {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.7rem;
  margin: 0;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 800;
  pointer-events: none;
}

.mandelbrot-controls {
  grid-area: controls;
  display: grid;
  gap: 0.95rem;
  padding: 1.1rem;
}

.boids-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
  padding: 1.1rem;
}

.life-controls,
.three-body-controls {
  grid-area: controls;
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
}

.mandelbrot-controls label,
.boids-controls label,
.life-controls label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 0.75rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.three-body-controls label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 0.75rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.mandelbrot-controls input[type="range"],
.boids-controls input[type="range"],
.life-controls input[type="range"],
.three-body-controls input[type="range"] {
  grid-column: 1 / -1;
  accent-color: var(--accent);
}

.mandelbrot-controls output,
.boids-controls output,
.life-controls output,
.three-body-controls output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.boids-controls select {
  grid-column: 1 / -1;
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.mandelbrot-actions,
.boids-actions,
.life-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.three-body-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.three-body-actions .button {
  min-height: 42px;
  padding: 0.65rem 0.85rem;
}

.three-body-actions .is-active {
  color: #04100d;
  background: var(--accent);
  border-color: transparent;
}

.three-body-controls .three-body-toggle {
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 42px;
  padding: 0.6rem 0.7rem;
  background: color-mix(in srgb, var(--surface-strong) 58%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.three-body-toggle input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
}

.boids-actions {
  grid-column: 1 / -1;
}

.mandelbrot-actions .button,
.boids-actions .button,
.life-actions .button {
  min-height: 42px;
  padding: 0.65rem 0.85rem;
}

.life-rule {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.life-rule strong {
  color: var(--accent);
}

.boids-actions .is-active {
  color: #04100d;
  background: var(--accent);
  border-color: transparent;
}

.boids-lab--deep {
  grid-template-columns: 1fr;
  grid-template-areas:
    "toolbar"
    "stage"
    "controls";
  gap: 1rem;
  padding: 1rem;
  margin-top: 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.three-body-lab--deep {
  grid-template-columns: 1fr;
  grid-template-areas:
    "toolbar"
    "stage"
    "controls";
  gap: 1rem;
  padding: 1rem;
  margin-top: 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.three-body-lab--deep .three-body-stage {
  min-height: 680px;
}

.three-body-controls--deep {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-body-controls--deep .three-body-actions {
  grid-column: 1 / -1;
}

.rtbp-equation {
  margin: 1rem 0 1.2rem;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.rtbp-equation mjx-container {
  margin: 0.35rem 0 !important;
}

.rtbp-example-list {
  display: grid;
  gap: 0.8rem;
  padding-left: 1.25rem;
  color: var(--muted);
}

.rtbp-example-list strong {
  color: var(--text);
}

.deep-lab-toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text);
}

.deep-lab-toolbar h2 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.3rem, 3vw, 2rem);
}

.deep-lab-toolbar > div > p:not(.eyebrow) {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
}

.deep-lab-toolbar .boids-instrument-note {
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.deep-fullscreen-button {
  min-height: 38px;
  padding: 0.55rem 0.8rem;
  white-space: nowrap;
}

.boids-lab--deep::before {
  content: none;
}

.boids-lab--deep .boids-copy h2 {
  max-width: 12ch;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.boids-stage--deep {
  min-height: min(72vh, 760px);
}

.boids-controls--deep {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.life-lab--deep {
  grid-template-columns: 1fr;
  grid-template-areas:
    "toolbar"
    "stage"
    "controls";
  gap: 1rem;
  padding: 1rem;
  margin-top: 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.life-lab--deep::before {
  content: none;
}

.life-stage--deep {
  min-height: min(72vh, 760px);
  aspect-ratio: auto;
  align-self: stretch;
}

.life-visuals {
  grid-area: stage;
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.life-visuals .life-stage {
  grid-area: auto;
}

.life-visuals .life-stage--deep canvas {
  min-height: 0;
}

.life-population {
  display: grid;
  grid-template-rows: auto minmax(110px, 1fr);
  min-width: 0;
  height: 190px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.life-population__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.9rem 0;
}

.life-population__header h3,
.life-population__header p {
  margin: 0;
}

.life-population__header p {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.life-population canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.war-factions {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  max-height: 430px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.war-side-panels {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.war-population {
  height: 240px;
}

.war-population .life-population__header {
  align-items: flex-start;
}

.war-population__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem 0.65rem;
  max-width: 58%;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.war-population__legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.war-population__legend i {
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.war-rule-guide {
  padding: 1rem;
  margin: 1.4rem 0;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.war-rule-guide h3 {
  margin-top: 0;
}

.war-rule-guide ol {
  display: grid;
  gap: 0.7rem;
  padding-left: 1.25rem;
}

.war-rule-guide p,
.war-rule-guide li {
  color: var(--muted);
}

.war-factions__header,
.war-faction__header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.war-factions__header {
  justify-content: space-between;
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.war-factions__header h3,
.war-factions__header p,
.war-faction__shorthand {
  margin: 0;
}

.war-factions__header p {
  color: var(--muted);
  font-size: 0.78rem;
}

.war-factions__tools {
  display: flex;
  gap: 0.5rem;
}

.war-factions__tools .button,
.war-place,
.war-remove {
  min-height: 36px;
  padding: 0.45rem 0.7rem;
}

.war-remove {
  color: #ff8f8f;
  border-color: color-mix(in srgb, #ff6b6b 55%, var(--line));
}

.war-remove:hover {
  color: var(--bg);
  background: #ff6b6b;
  border-color: #ff6b6b;
}

.war-add {
  min-width: 38px;
  font-size: 1.2rem;
}

.war-factions__list {
  display: grid;
  align-content: start;
  gap: 0.7rem;
  min-height: 0;
  padding: 0.8rem;
  overflow: auto;
  overscroll-behavior: contain;
}

.war-faction {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.war-faction__header,
.war-faction__rule-summary {
  grid-column: 1 / -1;
}

.war-faction__rule-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.war-rule-reset {
  min-height: 32px;
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
}

.war-spontaneous {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  align-items: center;
  padding: 0.65rem 0.7rem;
  background: color-mix(in srgb, var(--surface) 58%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.war-spontaneous label {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.war-spontaneous input[type="checkbox"] {
  accent-color: var(--accent);
}

.war-spontaneous input[type="number"] {
  width: 7.5rem;
  padding: 0.38rem 0.5rem;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.war-spontaneous input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.war-faction__id,
.war-faction__shorthand {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.war-faction__population {
  flex: 0 0 auto;
  padding: 0.28rem 0.48rem;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.war-faction__name {
  min-width: 80px;
  flex: 1;
  padding: 0.5rem 0.6rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-weight: 800;
}

.war-faction__colour {
  width: 42px;
  height: 36px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.war-rule-picker {
  display: grid;
  grid-template-columns: repeat(9, minmax(22px, 1fr));
  gap: 0.25rem;
  min-width: 0;
  padding: 0;
  border: 0;
}

.war-rule-picker legend {
  padding: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.war-rule-picker label {
  display: grid;
  place-items: center;
  gap: 0.18rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.war-rule-picker input {
  margin: 0;
  accent-color: var(--accent);
}

.war-relationships {
  display: grid;
  grid-column: 1 / -1;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.7rem;
  background: color-mix(in srgb, var(--surface) 58%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.war-relationships legend {
  padding: 0 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.war-relationships > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.war-relationships label {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(150px, auto);
  gap: 0.6rem;
  align-items: center;
}

.war-relationships label > span {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 800;
}

.war-relationships i {
  flex: 0 0 auto;
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.war-relationships b {
  font: inherit;
}

.war-relationships select {
  min-width: 0;
  padding: 0.42rem 0.5rem;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.75rem;
}

.war-factions [aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.conway-war-callout {
  display: grid;
  justify-items: start;
  gap: 0.7rem;
  margin-bottom: 2rem;
}

.conway-war-callout h3,
.conway-war-callout p {
  margin: 0;
}

.life-controls--deep {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  align-items: end;
}

.life-controls--deep .life-actions,
.life-controls--deep .life-rule {
  grid-column: 1 / -1;
}

.war-fast-forward {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: end;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.war-fast-forward label {
  min-width: min(100%, 220px);
  flex: 0 1 260px;
}

.war-fast-forward input[type="number"] {
  grid-column: 1 / -1;
  min-height: 42px;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.war-fast-forward .button {
  min-height: 42px;
}

.life-controls select {
  min-width: 0;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mandelbrot-formula {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.mandelbrot-formula var,
.deep-equation var {
  color: var(--text);
  font-style: italic;
  font-weight: 800;
}

.mandelbrot-formula sub,
.mandelbrot-formula sup,
.deep-equation sub,
.deep-equation sup {
  line-height: 0;
}

.timeline {
  position: relative;
  display: flex;
  gap: 1rem;
  width: min(100%, var(--max));
  padding: 1.75rem 0 0.35rem;
  margin: 0 auto;
  overflow-x: auto;
  overflow-y: hidden;
  list-style: none;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-color: var(--accent) transparent;
}

.timeline::before {
  position: absolute;
  top: 0.48rem;
  right: 0;
  left: 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.timeline-item {
  position: relative;
  display: flex;
  min-height: 220px;
  padding: 1rem;
  flex: 1 0 245px;
  flex-direction: column;
  gap: 0.85rem;
  scroll-snap-align: start;
}

.timeline-item::before {
  position: absolute;
  top: -1.38rem;
  left: 1rem;
  width: 0.72rem;
  height: 0.72rem;
  content: "";
  background: var(--accent);
  border: 3px solid var(--bg);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

.timeline-item time {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline-item p {
  max-width: none;
  margin-bottom: 0;
}

.about-grid {
  display: grid;
  grid-template-columns: 0.8fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
}

.about-copy {
  font-size: 1.08rem;
}

.contact-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
}

.link-row {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 1.25rem 3rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.site-footer a {
  color: var(--accent);
  font-weight: 800;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .nav-menu-button {
    display: grid;
  }

  .nav-links {
    position: absolute;
    top: 72px;
    right: 1rem;
    display: none;
    width: min(280px, calc(100vw - 2rem));
    padding: 0.5rem;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .nav-links.is-open {
    display: flex;
  }

  .hero-grid,
  .about-grid,
  .place-panel,
  .boids-lab,
  .mandelbrot-lab,
  .life-lab,
  .three-body-lab {
    grid-template-columns: 1fr;
  }

  .boids-lab {
    grid-template-areas:
      "copy"
      "stage"
      "controls";
  }

  .boids-lab--deep {
    grid-template-areas:
      "toolbar"
      "stage"
      "controls";
  }

  .life-lab {
    grid-template-areas:
      "copy"
      "stage"
      "controls";
  }

  .three-body-lab {
    grid-template-areas:
      "copy"
      "stage"
      "controls";
  }

  .life-lab--deep {
    grid-template-areas:
      "toolbar"
      "stage"
      "controls";
  }

  .mandelbrot-lab {
    grid-template-areas:
      "copy"
      "stage"
      "controls";
  }

  .mandelbrot-stage,
  .mandelbrot-stage canvas,
  .boids-stage,
  .boids-stage canvas,
  .life-stage,
  .life-stage canvas,
  .three-body-stage,
  .three-body-stage canvas {
    min-height: 520px;
  }

  .hero {
    min-height: auto;
  }

  .place-panel {
    min-height: 420px;
  }

  .archive-heading,
  .contact-panel,
  .site-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .category-grid,
  .content-grid,
  .boids-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .link-row {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  .section-band {
    padding: 4rem 1rem;
  }

  .nav-shell {
    padding-inline: 1rem;
  }

  .brand-text {
    max-width: 9rem;
  }

  .category-grid,
  .content-grid,
  .boids-controls {
    grid-template-columns: 1fr;
  }

  .place-panel__feature .button {
    width: 100%;
  }

  .mandelbrot-stage,
  .mandelbrot-stage canvas,
  .boids-stage,
  .boids-stage canvas,
  .life-stage,
  .life-stage canvas,
  .three-body-stage,
  .three-body-stage canvas {
    min-height: 380px;
  }

  .mandelbrot-actions .button,
  .boids-actions .button,
  .life-actions .button {
    width: 100%;
  }

  .three-body-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

.deep-page {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 18%, transparent), transparent 32rem),
    var(--bg);
}

.deep-hero {
  min-height: auto;
  padding-top: 4rem;
}

.deep-hero__copy {
  width: min(100%, var(--max));
  margin: 0 auto 2rem;
}

.deep-hero__copy h1 {
  max-width: 980px;
  font-size: clamp(3.2rem, 8vw, 6.5rem);
}

.deep-hero__copy p {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
}

.deep-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.18fr);
  gap: 1rem;
  width: min(100%, var(--max));
  margin: 0 auto;
  align-items: start;
}

.deep-article,
.deep-explorer {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

.deep-article {
  padding: clamp(1.1rem, 2.4vw, 1.7rem);
}

.deep-article h2 {
  margin-top: 0.55rem;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.deep-article p,
.deep-note p {
  color: var(--muted);
}

.deep-note {
  padding: 1rem;
  margin: 1.4rem 0;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.reference-list {
  display: grid;
  gap: 0.55rem;
  padding-left: 1.2rem;
  color: var(--muted);
}

.reference-list a {
  color: var(--accent);
  font-weight: 800;
}

.deep-explorer {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.is-experimental-deep .deep-explorer {
  border-color: color-mix(in srgb, var(--accent-strong) 72%, var(--line));
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.12),
    0 0 0 1px color-mix(in srgb, var(--accent-strong) 34%, transparent),
    0 0 44px color-mix(in srgb, var(--accent-strong) 16%, transparent);
}

.deep-explorer__header {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
}

.deep-explorer__header h2 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.3rem, 3vw, 2rem);
}

.deep-status {
  padding: 0.35rem 0.55rem;
  color: var(--bg);
  background: var(--accent);
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.deep-progress {
  width: 100%;
  height: 0.58rem;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.deep-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent-strong) 72%, var(--accent)));
  border-radius: inherit;
  transition: width 120ms linear;
}

.is-experimental-deep .deep-status {
  color: #180f00;
  background: var(--accent-strong);
}

.is-experimental-deep .deep-progress {
  border-color: color-mix(in srgb, var(--accent-strong) 62%, var(--line));
}

.is-experimental-deep .deep-progress span {
  background: linear-gradient(90deg, var(--accent-strong), color-mix(in srgb, var(--danger) 42%, var(--accent-strong)));
}

.deep-experimental-warning {
  padding: 0.8rem 0.9rem;
  margin: 0;
  color: var(--text);
  background: color-mix(in srgb, var(--accent-strong) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent-strong) 62%, var(--line));
  border-radius: var(--radius);
  font-size: 0.92rem;
}

.deep-explorer__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.deep-handoff-note {
  padding: 0.7rem 0.85rem;
  margin: 0;
  color: var(--muted);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.deep-equation {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  align-items: baseline;
  padding: 0.8rem 0.9rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.deep-equation span {
  color: var(--muted);
  font-size: 0.86em;
}

.deep-canvas-shell {
  min-height: 620px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background:
    linear-gradient(180deg, var(--mandelbrot-sheen), transparent),
    var(--mandelbrot-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overscroll-behavior: contain;
}

.deep-canvas-shell.is-dragging {
  cursor: grabbing;
}

.deep-canvas-shell canvas {
  display: block;
  width: 100%;
  height: 620px;
}

.deep-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

.deep-controls .button,
.deep-controls select {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.7rem;
}

.has-maximized-lab {
  overflow: hidden;
}

[data-deep-lab]:is(:fullscreen, .is-maximized) {
  z-index: 1000;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0.75rem;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

[data-deep-lab].is-maximized {
  position: fixed;
  inset: 0;
}

.deep-explorer:is(:fullscreen, .is-maximized) {
  position: fixed;
  top: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 0.65rem;
}

.deep-explorer:is(:fullscreen, .is-maximized) .deep-canvas-shell {
  min-height: 0;
  height: 100%;
}

.deep-explorer:is(:fullscreen, .is-maximized) .deep-canvas-shell canvas {
  height: 100%;
}

.deep-explorer:is(:fullscreen, .is-maximized) .deep-controls {
  grid-template-columns: repeat(5, minmax(110px, 1fr));
}

.deep-explorer:is(:fullscreen, .is-maximized) .deep-equation,
.deep-explorer:is(:fullscreen, .is-maximized) .deep-readout,
.deep-explorer:is(:fullscreen, .is-maximized) .deep-experimental-warning,
.deep-explorer:is(:fullscreen, .is-maximized) .deep-handoff-note {
  display: none !important;
}

.boids-lab--deep:is(:fullscreen, .is-maximized),
.life-lab--deep:is(:fullscreen, .is-maximized),
.three-body-lab--deep:is(:fullscreen, .is-maximized) {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "toolbar"
    "stage"
    "controls";
  gap: 0.65rem;
}

.boids-lab--deep:is(:fullscreen, .is-maximized) .boids-copy,
.life-lab--deep:is(:fullscreen, .is-maximized) .life-copy {
  display: none;
}

.boids-lab--deep:is(:fullscreen, .is-maximized) .deep-lab-toolbar > div > p:not(.eyebrow),
.life-lab--deep:is(:fullscreen, .is-maximized) .deep-lab-toolbar > div > p:not(.eyebrow),
.three-body-lab--deep:is(:fullscreen, .is-maximized) .deep-lab-toolbar > div > p:not(.eyebrow) {
  display: none;
}

.boids-lab--deep:is(:fullscreen, .is-maximized) .boids-stage,
.life-lab--deep:is(:fullscreen, .is-maximized) .life-stage,
.three-body-lab--deep:is(:fullscreen, .is-maximized) .three-body-stage {
  min-height: 0;
  height: 100%;
}

.life-lab--deep:is(:fullscreen, .is-maximized) .life-visuals {
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1.3fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.life-lab--deep:is(:fullscreen, .is-maximized) .life-stage,
.life-lab--deep:is(:fullscreen, .is-maximized) .life-population,
.life-lab--deep:is(:fullscreen, .is-maximized) .war-factions {
  min-height: 0;
  height: auto;
}

.life-lab--deep:is(:fullscreen, .is-maximized) .war-factions {
  max-height: none;
}

.life-lab--deep:is(:fullscreen, .is-maximized) .war-side-panels {
  grid-template-rows: minmax(0, 1fr) minmax(150px, 0.55fr);
  min-height: 0;
}

.life-lab--deep:is(:fullscreen, .is-maximized) .war-population {
  min-height: 0;
  height: auto;
}

.life-lab--deep:is(:fullscreen, .is-maximized) .life-stage {
  aspect-ratio: auto;
  align-self: stretch;
  height: 100%;
}

.boids-lab--deep:is(:fullscreen, .is-maximized) .boids-controls,
.life-lab--deep:is(:fullscreen, .is-maximized) .life-controls,
.three-body-lab--deep:is(:fullscreen, .is-maximized) .three-body-controls {
  max-height: 31vh;
  overflow: auto;
  overscroll-behavior: contain;
}

.boids-lab--deep:is(:fullscreen, .is-maximized) .boids-controls {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.three-body-lab--deep:is(:fullscreen, .is-maximized) .three-body-controls {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.deep-controls label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.deep-mode-toggle {
  position: relative;
  min-height: 72px;
  padding: 0.85rem 1rem;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text) !important;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  line-height: 1.25;
  text-transform: none !important;
}

.deep-mode-toggle strong,
.deep-mode-toggle small {
  display: block;
}

.deep-mode-toggle strong {
  font-size: 0.98rem;
}

.deep-mode-toggle small {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.deep-mode-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.deep-mode-toggle__track {
  position: relative;
  width: 3.25rem;
  height: 1.8rem;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-strong) 42%, var(--line));
  border-radius: 999px;
  transition: background 160ms ease, border-color 160ms ease;
}

.deep-mode-toggle__thumb {
  position: absolute;
  top: 50%;
  left: 0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--accent-strong);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: transform 160ms ease;
}

.deep-mode-toggle input:checked + .deep-mode-toggle__track {
  background: color-mix(in srgb, var(--accent-strong) 34%, var(--surface));
  border-color: color-mix(in srgb, var(--accent-strong) 82%, var(--line));
}

.deep-mode-toggle input:checked + .deep-mode-toggle__track .deep-mode-toggle__thumb {
  transform: translate(1.45rem, -50%);
}

.deep-mode-toggle:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent-strong) 72%, var(--line));
}

.deep-controls select {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.deep-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0;
}

.deep-readout div {
  padding: 0.75rem;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.deep-readout dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.deep-readout dd {
  margin: 0.22rem 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

@media (max-width: 980px) {
  .deep-layout {
    grid-template-columns: 1fr;
  }

  .deep-explorer {
    position: static;
  }

}

@media (max-width: 700px) {
  .deep-canvas-shell,
  .deep-canvas-shell canvas {
    min-height: 430px;
    height: 430px;
  }

  .deep-controls,
  .deep-readout,
  .boids-controls--deep,
  .life-controls--deep,
  .three-body-controls--deep {
    grid-template-columns: 1fr;
  }

  .deep-explorer__header {
    flex-direction: column;
  }

  .life-population__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
  }

  .war-faction {
    grid-template-columns: 1fr;
  }

  .war-faction__header,
  .war-faction__rule-summary,
  .war-spontaneous {
    grid-column: 1;
  }

  .war-rule-picker {
    grid-template-columns: repeat(9, minmax(18px, 1fr));
  }

  .war-relationships label {
    grid-template-columns: 1fr;
  }

  .war-population__legend {
    justify-content: flex-start;
    max-width: none;
  }

  .deep-explorer:is(:fullscreen, .is-maximized) .deep-controls,
  .boids-lab--deep:is(:fullscreen, .is-maximized) .boids-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .life-lab--deep:is(:fullscreen, .is-maximized) .life-controls {
    grid-template-columns: 1fr;
  }

  .three-body-lab--deep:is(:fullscreen, .is-maximized) .three-body-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .life-lab--deep:is(:fullscreen, .is-maximized) .life-visuals {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(260px, 0.8fr);
  }
}
