/* Shared interaction layer; chapter-specific components keep their own styles. */
.scene-stage { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#experience > :not(.scene-stage) { z-index: 1; }
#world { pointer-events: auto; }
#world:focus-visible { outline: 2px solid var(--jade); outline-offset: -4px; }
.vignette, .grain { z-index: 1; }
.scene-tools { display: none; }
.utility, .text-button, .dialog-close { min-height: 44px; }
dialog { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
dialog .dialog-close { min-width: 44px; }
dialog .dialog-close { position: sticky; top: 0; float: right; z-index: 2; margin: -12px -12px 0 0; background: var(--bg); }
/* Native tracks differ in Gecko/WebKit: put the track inside a full touch target. */
input[type=range]:not(#lock-level) { appearance: none; -webkit-appearance: none; height: 44px; margin: 0; background: transparent; touch-action: pan-y; }
input[type=range]:not(#lock-level)::-webkit-slider-runnable-track { height: 3px; background: var(--line); }
input[type=range]:not(#lock-level)::-webkit-slider-thumb { -webkit-appearance: none; margin-top: -7px; width: 17px; height: 17px; border: 0; border-radius: 50%; background: var(--gold); }
input[type=range]:not(#lock-level)::-moz-range-track { height: 3px; background: var(--line); }
input[type=range]:not(#lock-level)::-moz-range-thumb { width: 17px; height: 17px; border: 0; border-radius: 50%; background: var(--gold); }
.scene-loading { position: fixed; right: 40px; top: 120px; color: var(--gold); font-size: 12px; z-index: 4; }
.scene-loading[hidden] { display: none; }
#webgl-fallback { z-index: 3; }

/* A short desktop still needs separate space for editorial copy and telemetry. */
@media (min-width: 761px) and (max-height: 850px) {
  #experience .editorial { top: 24px; }
  #experience h1 { font-size: clamp(56px, 10vh, 84px); line-height: 1.18; margin-bottom: 18px; }
  #experience .eyebrow { margin-bottom: 18px; }
  #experience .intro { margin-bottom: 20px; }
  #experience .chapter-footnote { margin-top: 24px; }
}
@media (min-width: 1001px) and (max-height: 700px) {
  #experience .editorial { top: 18px; }
  #experience h1 { font-size: clamp(44px, 8vh, 56px); letter-spacing: 5px; }
  #experience h1 span { display: inline; }
  #experience .chapter-footnote { margin-top: 18px; }
}

@media (max-width: 760px), (max-height: 600px) and (max-width: 1000px) {
  html { scroll-padding-top: 90px; }
  body { overflow-x: clip; overflow-y: auto; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .masthead { left: 0; right: 0; height: calc(72px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); background: rgba(7,19,17,.97); gap: 8px; }
  .brand { min-width: 0; gap: 9px; }
  .brand-word { font-size: 17px; letter-spacing: 3px; }
  .brand-word small { font-size: 6px; letter-spacing: 1.4px; }
  .brand-seal { width: 28px; height: 34px; font-size: 23px; line-height: 31px; }
  .theme-label, .utility-label { display: none; }
  .utilities { gap: 4px; flex-shrink: 0; }
  .utility { min-width: 44px; justify-content: center; padding: 8px; font-size: 11px; }
  /* Keep the shell authoritative when chapter stylesheets load asynchronously. */
  body[data-chapter] main#experience { display: block; position: relative; inset: auto; margin: calc(72px + env(safe-area-inset-top)) 0 0; padding: 26px 22px 20px; min-width: 0; min-height: 0; }
  .chapter-rail, .chapter-footnote, .scene-compass, .orbit-hint { display: none; }
  body[data-chapter] #experience .editorial { position: relative; inset: auto; max-width: none; }
  .eyebrow { font-size: 10px; line-height: 1.8; letter-spacing: 1.5px; margin-bottom: 12px; }
  body[data-chapter] #experience h1 { font-size: clamp(34px, 9.8vw, 56px); letter-spacing: 4px; line-height: 1.45; margin: 0 0 10px; white-space: normal; }
  #headline span { display: inline; }
  #headline span::after { width: 4px; height: 4px; margin-left: 6px; vertical-align: 7px; }
  body[data-chapter] #experience .intro { max-width: none; font-size: 12px; line-height: 2; letter-spacing: .4px; margin-bottom: 16px; }
  .primary-action { min-height: 44px; font-size: 12px; padding: 12px 18px; }
  body[data-chapter] #experience .scene-caption { position: relative; inset: auto; margin-top: 24px; font-size: 10px; letter-spacing: 1px; }
  .scene-caption small { display: none; }
  #experience > .scene-stage { position: relative; inset: auto; height: 350px; height: clamp(280px, 44svh, 420px); margin: 8px -22px 20px; isolation: isolate; }
  #world { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y pinch-zoom; }
  .city-labels { position: absolute; inset: 0; }
  .city-label { font-size: 11px; min-height: 44px; padding: 10px; }
  .city-label small { font-size: 7px; }
  .scene-tools { position: absolute; inset: auto 18px 0; display: flex; justify-content: space-between; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; letter-spacing: .4px; }
  .scene-tools > div { display: flex; gap: 6px; }
  .scene-tools button { pointer-events: auto; width: 44px; height: 44px; font-size: 22px; color: var(--gold); border: 1px solid var(--line); background: rgba(7,19,17,.9); }
  /* #detail-panel is stable; chapters may add .divide-panel or .future-panel. */
  body[data-chapter] #experience #detail-panel { position: relative; inset: auto; width: 100%; max-width: none; max-height: none; overflow: visible; padding: 20px 0; margin: 0; border-left: 0; border-right: 0; background: var(--bg); }
  body[data-chapter] main#experience button, body[data-chapter] main#experience summary { min-height: 44px; }
  #experience .origin-route { position: relative; inset: auto; margin: 20px 0 0; }
  #experience .origin-scene-note, #experience .origin-key-hint { display: none; }
  #experience .panel-kicker { font-size: 10px; line-height: 1.8; letter-spacing: 1.3px; }
  #experience .detail-panel h2 { font-size: 23px; line-height: 1.65; letter-spacing: 2px; margin: 12px 0; }
  #experience .detail-panel p { font-size: 12px; line-height: 2; margin: 10px 0 16px; }
  #experience .detail-meta, #experience .slider-label { font-size: 11px; line-height: 1.8; }
  #experience .text-button { font-size: 11px; line-height: 1.8; padding: 10px 0; }
  #experience .panel-action { min-height: 46px; font-size: 12px; }
  #experience textarea { font-size: 16px; line-height: 1.8; min-height: 100px; scroll-margin: 100px 0 140px; }
  .input-caption, .learning-checks { font-size: 10px; line-height: 1.8; }
  .split-readings { padding: 12px 0; }
  .split-readings strong { font-size: 30px; }
  .telemetry { position: relative; inset: auto; margin-top: 12px; font-size: 9px; }
  .telemetry-bars, #particle-count { display: none; }
  /* Beat late chapter themes: scrolled controls must never show through this bar. */
  html body[data-chapter] .bottom-nav { left: 0; right: 0; z-index: 20; height: calc(76px + env(safe-area-inset-bottom)); padding: 0 max(14px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(14px, env(safe-area-inset-left)); gap: 0; background: var(--bg); }
  .journey-label, .edition { display: none; }
  .bottom-nav nav { min-width: 0; width: 100%; gap: 0; }
  .chapter-link { min-width: 0; justify-content: center; padding: 0 3px; gap: 4px; }
  .chapter-link > span:nth-child(2) { font-size: 16px; letter-spacing: 2px; }
  .chapter-link small { font-size: 9px; letter-spacing: 1px; margin-top: 5px; }
  .chapter-index, .chapter-arrow { display: none; }
  .scene-message { position: fixed; top: calc(84px + env(safe-area-inset-top)); bottom: auto; left: 18px; right: 18px; max-width: none; transform: none; font-size: 12px; line-height: 1.8; z-index: 6; }
  dialog { width: calc(100% - 24px); max-width: 600px; padding: 24px; }
  dialog h2 { font-size: 28px; }
  .guide-grid { grid-template-columns: 1fr; gap: 10px; }
  .guide-grid p, .study-context, .guide-note { font-size: 12px; }
  .dialog-close { top: 8px; right: 8px; }
  .scene-loading { top: calc(80px + env(safe-area-inset-top)); right: 18px; font-size: 10px; }
  #webgl-fallback { position: absolute; inset: 35px 22px 55px; padding: 18px; background: var(--bg); overflow: auto; }
  #webgl-fallback h2 { font-size: 22px; }
  #webgl-fallback p { font-size: 12px; line-height: 2; }
  .vignette { display: none; }
}

/* Keep the first action above the fixed navigation on a short landscape phone. */
@media (min-width: 761px) and (max-width: 1000px) and (max-height: 500px) {
  body[data-chapter] main#experience { padding-top: 16px; }
  #experience .eyebrow { margin-bottom: 8px; }
  body[data-chapter] #experience h1 { font-size: 44px; line-height: 1.25; margin-bottom: 8px; }
  body[data-chapter] #experience .intro { line-height: 1.8; margin-bottom: 12px; }
}
