/* ──────────────────────────────────────────────────────────────────────────
   Dollhouse Video Lab — page shell on top of the RMCflow tokens in /static/styles.css.
   The 3D viewport leads; controls stay quiet, mono-labelled and 2px-cornered.
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --dh-scene-ground: #e6e0d6;   /* matches the Three.js scene background */
  --dh-card-height: min(76vh, 900px);
  --dh-hairline: rgba(43, 41, 38, 0.1);
  --dh-tap: 44px;
}

.dh-body { min-width: 0; }
.dh-body .button, .dh-body .icon-button { min-height: 44px; min-width: 44px; }
.dh-body .nav-link { min-width: 44px; justify-content: center; }
.dh-body :is(#dh-preview, #dh-controls, #dh-camera-section, #dh-capture-section, #dh-help) { scroll-margin-top: 76px; }
.dh-skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.dh-skip-link:focus { position: fixed; top: 12px; left: 12px; z-index: 20; padding: 14px 20px; background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-md); }

.dh-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

fieldset.dh-field, fieldset.dh-options { border: 0; margin: 0; padding: 0; min-width: 0; }

/* ── Header ── */
.dh-header { gap: 20px; }
.dh-labs-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  white-space: nowrap;
}
.dh-labs-mark { width: 6px; height: 6px; background: var(--primary); transform: rotate(45deg); flex-shrink: 0; }

/* ── Heading ── */
.dh-main { padding-bottom: 56px; }
.dh-heading { margin: 30px 0 24px; gap: 32px; }
.dh-heading h1 { margin-top: 6px; }
.dh-subtitle { margin-top: 6px; font-size: 14px; line-height: 1.6; color: var(--text-muted); }
.dh-spec { display: flex; margin: 0 0 4px; border-left: 1px solid var(--border); }
.dh-spec > div { padding: 2px 18px; border-right: 1px solid var(--border); }
.dh-spec dt, .dh-spec dd { margin: 0; font-family: var(--font-label); white-space: nowrap; }
.dh-spec dt { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.dh-spec dd { margin-top: 5px; font-size: 12px; color: var(--text); }
.dh-workspace-nav { position: sticky; top: 0; z-index: 7; height: auto; display: flex; gap: 0; margin: 0 0 20px; border: 1px solid var(--border); border-radius: var(--card-radius); background: var(--bg-card); box-shadow: var(--shadow-sm); }
.dh-workspace-nav a { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 8px 22px; min-height: 52px; font-size: 13px; font-weight: 500; }
.dh-workspace-nav a + a { border-left: 1px solid var(--border); }
.dh-workspace-nav a:last-child { margin-left: auto; color: var(--primary); }
.dh-workspace-nav a:hover { background: var(--bg-subtle); }
.dh-workspace-nav a > span:first-child { font: 10px var(--font-label); color: var(--text-muted); }

/* ── Layout ── */
.dh-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.dh-viewport-card {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  height: var(--dh-card-height);
  min-height: 620px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
}
.dh-topline { gap: 16px; }
.dh-scene-meta { font-family: var(--font-label); letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dh-view-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.dh-view-actions-end { display: flex; gap: 4px; }
.dh-view-actions .button { padding: 8px 12px; gap: 8px; font-size: 12px; }
.dh-view-guidance { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--border); background: var(--bg-subtle); }
.dh-view-guidance p { font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.dh-view-guidance a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; flex-shrink: 0; font-size: 12px; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.dh-view-guidance .dh-status { color: var(--text); margin-top: 4px; }
.dh-view-guidance .dh-status.is-error { color: var(--danger); }

/* The viewport is a drafting-sheet ground; the stage inside it is what the camera frames. */
.dh-viewport {
  position: relative;
  min-height: 0;
  background-color: var(--bg-subtle);
  background-image:
    linear-gradient(var(--dh-hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--dh-hairline) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  overflow: hidden;
}
.dh-viewport:fullscreen { background-color: var(--text); background-image: none; width: 100vw; height: 100vh; aspect-ratio: auto; margin: 0; }
.dh-viewport:-webkit-full-screen { background-color: var(--text); background-image: none; width: 100vw; height: 100vh; aspect-ratio: auto; margin: 0; }

.dh-stage {
  position: absolute;
  inset: 0;
  margin: auto;
  background: var(--dh-scene-ground);
  overflow: hidden;
  isolation: isolate;
  contain: layout paint;
}
.dh-stage[data-aspect="vertical"] {
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  box-shadow: 0 0 0 1px rgba(43, 41, 38, 0.14), 0 18px 40px -24px rgba(43, 41, 38, 0.45);
}
/* Registration marks frame the vertical export area; they are DOM, so never captured. */
.dh-stage[data-aspect="vertical"]::before,
.dh-stage[data-aspect="vertical"]::after {
  content: '';
  position: absolute;
  z-index: 4;
  width: 14px;
  height: 14px;
  pointer-events: none;
  border-color: rgba(43, 41, 38, 0.45);
  border-style: solid;
}
.dh-stage[data-aspect="vertical"]::before { top: 10px; left: 10px; border-width: 1px 0 0 1px; }
.dh-stage[data-aspect="vertical"]::after { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; }

.dh-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  opacity: 0;
  transition: opacity .45s ease;
  touch-action: pan-y;
}
.dh-stage.is-ready .dh-canvas { opacity: 1; }
.dh-canvas.is-pickable { cursor: pointer; }
.dh-canvas.is-explore { cursor: grab; }
.dh-canvas.is-explore:active { cursor: grabbing; }
.dh-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }

/* ── Viewport overlays ── */
.dh-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 45%, #f4f0e9, var(--dh-scene-ground) 72%);
}
.dh-overlay h2 { font-size: 24px; max-width: 420px; line-height: 1.25; }
.dh-overlay .text-link { margin-top: 8px; }
.dh-overlay-art { width: 150px; height: 104px; color: #ad9e8d; margin-bottom: 6px; }
.dh-overlay-text { max-width: 380px; font-size: 13px; line-height: 1.7; color: var(--text-muted); }
.dh-overlay-reason {
  max-width: 420px;
  font-family: var(--font-label);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.dh-error .dh-overlay-reason { color: var(--danger); }
.dh-overlay-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px; margin-top: 8px; }
.dh-overlay-actions .text-link { margin-top: 0; }
.dh-loading { transition: opacity .35s ease, visibility .35s; }
.dh-loading .spinner { margin: 4px 0 6px; }
.dh-loading.is-leaving { opacity: 0; visibility: hidden; pointer-events: none; }

.dh-perf {
  position: static;
  margin: 0;
  padding: 3px 6px;
  font-family: var(--font-label);
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-radius: var(--radius);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  white-space: normal;
  overflow-wrap: anywhere;
}
.dh-stage[data-aspect="vertical"] .dh-perf { top: 30px; }

/* Room labels: anchored chips written by room-labels.js via transform only. */
.dh-room-labels { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.dh-room-labels[hidden] { display: none !important; }
.dh-room-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 3px 7px 2px;
  font-family: var(--font-label);
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(43, 41, 38, 0.74);
  background: rgba(250, 247, 242, 0.7);
  border: 1px solid rgba(43, 41, 38, 0.1);
  border-radius: var(--radius);
  will-change: transform;
  transition: opacity .2s ease;
}
.dh-room-label.is-offscreen { opacity: 0; }

/* Bottom-centre: the inspector is closed while recording, and the perf readout keeps the top-left corner. */
.dh-rec-chip {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #fff;
  background: rgba(31, 29, 26, 0.82);
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.dh-stage[data-aspect="vertical"] .dh-rec-chip { bottom: 32px; }
.dh-rec-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: dh-pulse 1.2s ease-in-out infinite; }
.dh-rec-time { font-weight: 500; }
.dh-rec-bar { position: relative; width: 56px; height: 2px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.dh-rec-bar i { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
@keyframes dh-pulse { 50% { opacity: .35; } }

/* Inspector card */
.dh-inspector {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  width: min(300px, calc(100% - 24px));
  padding: 12px 14px 14px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-left: 2px solid var(--primary);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-md);
  animation: dh-rise .22s ease-out;
}
@keyframes dh-rise { from { opacity: 0; transform: translateY(6px); } }
.dh-inspector-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -6px 0 0; }
.dh-inspector-head .eyebrow { font-size: 10px; }
.dh-inspector-close { width: 44px; height: 44px; font-size: 22px; }
.dh-inspector-name { font-size: 17px; line-height: 1.3; margin: 2px 0 10px; outline: none; }
.dh-inspector-facts { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--border); }
.dh-inspector-facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.dh-inspector-facts dt { font-family: var(--font-label); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.dh-inspector-facts dd { margin: 0; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dh-inspector-facts dd[data-field="product"] { font-family: var(--font-label); font-size: 11px; }
.dh-inspector-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.dh-inspector-actions .button { min-height: 32px; padding: 6px 11px; font-size: 11px; flex-shrink: 0; }
.dh-demo-note { font-size: 12px; line-height: 1.5; color: var(--text-muted); }

/* ── Transport ── */
.dh-transport {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  min-width: 0;
}
.dh-icon { width: 14px; height: 14px; flex-shrink: 0; }
.dh-play { gap: 8px; min-width: 92px; justify-content: flex-start; padding-inline: 13px 15px; }
.dh-play .dh-icon-pause { display: none; }
.dh-play[aria-pressed="true"] .dh-icon-pause { display: block; }
.dh-play[aria-pressed="true"] .dh-icon-play { display: none; }
.dh-restart { gap: 7px; }
.dh-scrub { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.dh-timecode { font-family: var(--font-label); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.dh-timecode-total { color: var(--text-muted); }

.dh-scrubber {
  --dh-progress: 0%;
  flex: 1;
  min-width: 80px;
  height: 44px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.dh-scrubber:disabled { cursor: not-allowed; opacity: .5; }
.dh-scrubber::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, var(--text) var(--dh-progress), var(--border) var(--dh-progress));
}
.dh-scrubber::-moz-range-track { height: 2px; background: var(--border); }
.dh-scrubber::-moz-range-progress { height: 2px; background: var(--text); }
.dh-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.dh-scrubber::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.dh-scrubber:focus-visible { outline: none; }
.dh-scrubber:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--primary), 0 0 0 5px rgba(194, 58, 18, 0.22); }
.dh-scrubber:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--primary), 0 0 0 5px rgba(194, 58, 18, 0.22); }

/* ── Segmented controls (native radios, visually replaced) ── */
.dh-segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--pill-radius);
  background: var(--surface-inset);
  box-shadow: var(--shadow-inset);
}
.dh-segmented label { position: relative; display: block; margin: 0; cursor: pointer; }
.dh-segmented input,
.dh-options input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
.dh-segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-muted);
  border-radius: var(--pill-radius);
  transition: background .15s, color .15s, box-shadow .15s;
}
.dh-segmented label:hover span { color: var(--text); }
.dh-segmented input:checked + span { background: var(--selection-bg); color: var(--selection-text); font-weight: 600; box-shadow: var(--shadow-sm); }
.dh-segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.dh-field:disabled label, .dh-field:disabled input { cursor: not-allowed; }
.dh-field:disabled .dh-segmented span { opacity: .5; }
.dh-speed span { font-family: var(--font-label); font-size: 11px; padding: 0 9px; min-width: 44px; }

/* ── Panel ── */
.dh-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.dh-section { padding: 20px; min-width: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--card-radius); box-shadow: var(--shadow-sm); }
.dh-section-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 44px; cursor: pointer; list-style: none; scroll-margin-top: 76px; }
.dh-section-summary::-webkit-details-marker { display: none; }
.dh-summary-title { display: block; font: 600 17px/1.4 var(--font-display); letter-spacing: -.02em; }
.dh-section-summary .eyebrow { display: block; margin-bottom: 6px; }
.dh-summary-note { display: block; font-size: 12px; color: var(--text-muted); line-height: 1.6; margin-top: 4px; }
.dh-disclosure-icon { font: 22px var(--font-body); color: var(--text-muted); flex-shrink: 0; }
.dh-section[open] > summary .dh-disclosure-icon { transform: rotate(45deg); }
.dh-section-content { padding-top: 14px; }
.dh-section-intro { font-size: 13px; line-height: 1.65; color: var(--text-muted); margin-bottom: 14px; }
.dh-capture-section { border-top: 3px solid var(--primary); }
.dh-capture-section .dh-section-title { font-size: 21px; margin-top: 7px; margin-bottom: 6px; }
.dh-export-summary { font-size: 12px; color: var(--text-muted); line-height: 1.6; margin: 0 0 14px; }
.dh-export-details { margin-top: 12px; border-top: 1px solid var(--border); }
.dh-export-details summary { min-height: 44px; padding: 12px 0; cursor: pointer; font-size: 12px; color: var(--text-muted); }
.dh-export-details .dh-note:first-of-type { margin-top: 0; }
.dh-capture-progress { display: block; width: 100%; height: 8px; border: 0; margin-top: 14px; accent-color: var(--primary); border-radius: var(--control-radius); background: var(--border); }
.dh-capture-progress::-webkit-progress-bar { background: var(--border); }
.dh-capture-progress::-webkit-progress-value { background: var(--primary); }
.dh-capture-progress::-moz-progress-bar { background: var(--primary); }
.dh-shortcuts { margin: 0; }
.dh-shortcuts > div { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.6; }
.dh-shortcuts dt { font-weight: 500; }
.dh-shortcuts dd { margin: 0; color: var(--text-muted); }
.dh-shortcuts kbd { padding: 1px 4px; border: 1px solid var(--border-strong); border-radius: var(--control-radius); background: var(--bg-subtle); color: var(--text); font: 11px var(--font-label); }
.dh-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.dh-section-index { font-family: var(--font-label); font-size: 10px; font-weight: 500; letter-spacing: 0.1em; color: var(--primary); }
.dh-field-label {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.dh-field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dh-field-pair .dh-segmented { display: grid; width: 100%; }
.dh-field { min-width: 0; }
.dh-note { margin-top: 8px; font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.dh-aspect-note { display: none; }
.dh-status { margin-top: 10px; font-size: 12px; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }
.dh-status:empty { display: none; }
.dh-status.is-error { color: var(--danger); }

/* Camera option list */
.dh-options { display: grid; gap: 6px; }
.dh-option { position: relative; display: block; margin: 0; cursor: pointer; border: 1px solid var(--border); border-radius: var(--control-radius); overflow: hidden; }
.dh-option-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 11px 10px 11px 12px;
  min-height: 58px;
  border-left: 2px solid transparent;
  transition: background .15s, border-color .15s;
}
.dh-option-body::after {
  content: '';
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-card);
  transition: border-color .15s, box-shadow .15s;
}
.dh-option-name { font-size: 13px; font-weight: 500; color: var(--text); }
.dh-option-hint { grid-column: 1; font-size: 11px; line-height: 1.45; color: var(--text-muted); }
.dh-option:hover .dh-option-body { background: var(--bg-subtle); }
.dh-option input:checked + .dh-option-body { border-left-color: var(--primary); background: var(--bg-card-hover); }
.dh-option input:checked + .dh-option-body .dh-option-name { font-weight: 600; }
.dh-option input:checked + .dh-option-body::after { border-color: var(--primary); box-shadow: inset 0 0 0 3px var(--bg-card), inset 0 0 0 6px var(--primary); }
.dh-option input:focus-visible + .dh-option-body { outline: 2px solid var(--primary); outline-offset: -2px; }
.dh-options:disabled .dh-option { cursor: not-allowed; }
.dh-options:disabled .dh-option-body { opacity: .5; }
.dh-options:disabled input { cursor: not-allowed; }

/* Switches (button role="switch") */
.dh-switch-list { display: grid; border-top: 1px solid var(--border); margin-top: 16px; }
.dh-switch-list .dh-switch { border-bottom: 1px solid var(--border); }
.dh-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: var(--dh-tap);
  padding: 0 2px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--control-radius);
}
.dh-switch-track {
  position: relative;
  width: 30px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 8px;
  /* Off state at ≥ 3:1 against the panel so the track and its white knob stay visible. */
  background: var(--border-strong);
  transition: background .18s;
}
.dh-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(43, 41, 38, 0.25);
  transition: transform .18s;
}
.dh-switch[aria-checked="true"] .dh-switch-track { background: var(--primary); }
.dh-switch[aria-checked="true"] .dh-switch-track::after { transform: translateX(14px); }
.dh-switch:hover:not(:disabled) .dh-switch-label { color: var(--primary-hover); }
.dh-switch-compact { width: auto; padding: 0 4px; gap: 8px; font-size: 12px; }

/* Capture */
.dh-capture-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.dh-capture-row .button { gap: 8px; }
.dh-body .dh-select { margin-bottom: 10px; text-transform: none; min-height: 44px; font-size: 14px; border-color: var(--border-strong); }
.dh-record { gap: 10px; }
.dh-record-mark { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.dh-record.is-recording { background: var(--text); }
.dh-record.is-recording:hover { background: var(--text-muted); }
.dh-record.is-recording .dh-record-mark { border-radius: 1px; background: var(--accent); }

.dh-footer { margin-top: 0; }

/* ── Responsive ── */
@media (min-width: 1001px) and (min-height: 760px) {
  .dh-viewport-card { position: sticky; top: 72px; }
}
@media (max-width: 1280px) {
  .dh-spec > div:nth-child(2) { display: none; }
}

/* Below this the one-row transport leaves the scrubber too short (it overlapped the Loop switch under 1160 px), so the
   scrubber and timecode take a row of their own. */
@media (max-width: 1320px) {
  .dh-transport { flex-wrap: wrap; row-gap: 8px; }
  .dh-scrub { order: -1; flex-basis: 100%; }
  .dh-transport .dh-speed { margin-left: auto; }
}

@media (max-width: 1000px) {
  :root { --dh-tap: 44px; }
  .dh-heading { flex-direction: column; align-items: flex-start; gap: 18px; margin: 26px 0 20px; }
  .dh-spec { display: none; }
  .dh-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .dh-viewport-card { height: auto; min-height: 0; grid-template-rows: repeat(5, auto); }
  .dh-viewport-card { container-type: inline-size; }
  /* One column: the stage is always a vertical 9:16 frame, as tall as the card width allows (≤ 82svh). */
  .dh-viewport { height: min(82svh, calc(100cqw * 16 / 9)); }
  .dh-stage, .dh-stage[data-aspect] { width: auto; height: 100%; max-width: 100%; aspect-ratio: 9 / 16; }
  .dh-stage[data-aspect] .dh-perf { top: 10px; }
  .dh-stage[data-aspect] .dh-rec-chip { bottom: 12px; }
  .dh-stage[data-aspect]::before, .dh-stage[data-aspect]::after { display: none; }
  .dh-transport { padding: 10px 12px 12px; }
  .dh-scrubber { height: 44px; }
  .dh-transport .button, .dh-segmented span { min-height: 44px; }
  .dh-aspect-note { display: block; }
  .dh-panel { grid-template-columns: 1fr 1fr; align-items: start; }
  .dh-camera-section { grid-row: span 2; }
  .dh-capture-quick .dh-capture-row { margin-bottom: 0; }
  .dh-option-body { min-height: 44px; }
  .dh-capture-row .button, .dh-record, .dh-select { min-height: 44px; }
  .dh-inspector-close { width: 44px; height: 44px; margin: -6px -8px -6px 0; }
}

@media (max-width: 640px) {
  /* The shared page navigation needs the header width on phones. */
  .dh-header .dh-labs-badge { display: none; }
  .dh-heading h1 { font-size: 30px; }
  .dh-subtitle { font-size: 13px; }
  .dh-topline { padding: 0 12px; }
  .dh-scene-meta { display: none; }
  .dh-panel { grid-template-columns: minmax(0, 1fr); }
  .dh-camera-section { grid-row: auto; }
  .dh-capture-quick .dh-capture-row { margin-bottom: 14px; }
  .dh-section { padding: 16px; }
  .dh-workspace-nav { margin-bottom: 16px; }
  .dh-workspace-nav a { flex: 1; padding: 8px 6px; gap: 5px; font-size: 12px; min-height: 48px; white-space: nowrap; }
  .dh-workspace-nav a > span:first-child { display: none; }
  .dh-workspace-nav a:last-child { margin-left: 0; }
  .dh-view-actions { padding: 6px; gap: 0; }
  .dh-view-actions-end { gap: 0; }
  .dh-view-actions .button { padding-inline: 8px; font-size: 11px; gap: 5px; }
  .dh-view-guidance { align-items: flex-start; flex-direction: column; gap: 0; padding: 10px 12px 4px; }
  .dh-body .dh-select { font-size: 16px; }
  .dh-transport { gap: 6px; padding-inline: 10px; }
  .dh-play { min-width: 0; padding-inline: 12px 14px; }
  .dh-restart { padding-inline: 8px; min-width: 44px; }
  .dh-restart span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dh-switch-compact { padding: 0 2px; gap: 6px; }
  /* Speed gets a full-width row of three equal segments rather than a stray right-aligned group. */
  .dh-transport .dh-speed { flex-basis: 100%; margin-left: 0; }
  .dh-speed .dh-segmented { display: grid; width: 100%; }
  .dh-speed span { padding: 0 2px; }
  /* Compact inspector: facts in one row so the card covers less of the vertical stage. */
  .dh-inspector { left: 8px; bottom: 8px; width: calc(100% - 16px); padding: 8px 12px 10px; }
  .dh-inspector-name { font-size: 15px; margin: 0 0 6px; }
  .dh-inspector-facts { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) minmax(0, 1.3fr); column-gap: 10px; border-bottom: 1px solid var(--border); }
  .dh-inspector-facts > div { display: block; border-bottom: 0; padding: 6px 0; }
  .dh-inspector-facts dt { font-size: 9px; }
  .dh-inspector-facts dd { margin-top: 2px; text-align: left; font-size: 11px; }
  .dh-inspector-facts dd[data-field="product"] { font-size: 10px; }
  .dh-inspector-actions { margin-top: 8px; }
  .dh-inspector-actions .button { min-height: 36px; }
  .dh-demo-detail { display: none; }
  .dh-room-label { font-size: 8.5px; padding: 2px 5px 1px; letter-spacing: 0.1em; }
  .dh-footer > p { display: none; }
}

@media (max-width: 380px) {
  .dh-header { gap: 10px; }
}

@media (pointer: coarse) {
  :root { --dh-tap: 44px; }
  .dh-transport .button, .dh-segmented span, .dh-capture-row .button, .dh-record, .dh-select, .dh-option-body { min-height: 44px; }
}

/* Phones and touch screens: short speed labels ("1×") would be narrower than a fingertip, so they centre in 44 px. */
@media (max-width: 640px), (pointer: coarse) {
  .dh-speed span { min-width: 44px; }
}

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