/* Phone layout: one readable column, a dedicated figure, and touch controls. */
@media (max-width: 767px), (min-width: 768px) and (max-width: 950px) and (max-height: 500px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: clip; }
  .single-stage-site {
    --site-gutter: 20px;
    --site-header-height: 100px;
    --mobile-dock-height: 64px;
    --mobile-footer-height: 60px;
  }
  .site-header {
    grid-template-columns: 1fr auto;
    grid-template-rows: 48px 44px;
    align-content: start;
    gap: 0 12px;
    background: linear-gradient(#000 65%, #000d);
  }
  .site-header .brand { grid-area: 1 / 1; font-size: 22px; letter-spacing: -1px; }
  .site-header .site-independence { display: block; grid-area: 1 / 2; font-size: 8px; }
  .site-header .site-independence > span { margin-right: 4px; }
  .site-header nav { grid-area: 2 / 1 / 3 / 3; width: 100%; justify-content: space-between; gap: 8px; font-size: 11px; }
  .site-header nav a, .site-header nav a:nth-child(2) { display: inline-flex; align-items: center; min-height: 44px; padding: 0; }
  .site-header nav a span { display: none; }
  .software-stage, .stage, .reading.closing-study > .closing-stage { min-height: 0; height: 100svh; }
  .software-copy {
    left: var(--site-gutter); right: var(--site-gutter); top: 112px; bottom: auto;
    width: auto; max-width: none; height: calc(52svh - 124px);
    display: block; align-content: start; overflow-y: auto; overscroll-behavior-y: auto; pointer-events: auto;
    scrollbar-width: thin; scrollbar-color: #34494e transparent;
  }
  .software-chapter:not(.active), .intro-beat:not(.active), .overview-beat:not(.active), .company-model-beat:not(.active) { display: none; }
  .software-chapter h1, .software-chapter h2 { font-size: 34px; line-height: 1.08; margin-bottom: 12px; }
  .software-eyebrow { font-size: 8px; letter-spacing: .7px; margin-bottom: 12px; }
  .software-body, .software-overview .software-body { max-width: none; font-size: 14px; line-height: 1.65; }
  .software-aside { font-size: 11px; line-height: 1.6; margin-top: 12px; }
  .software-options { margin-top: 12px; gap: 6px; min-height: 44px; }
  .single-stage-site .software-options button { min-height: 44px; padding: 9px 11px; font-size: 11px; }
  .overview-beat-nav { margin-top: 10px; gap: 18px; }
  .overview-beat-nav button, .intro-beat-nav button { min-height: 44px; }
  .software-explore, .software-research-link { min-height: 44px; margin-top: 9px; font-size: 11px; }
  .company-model-nav { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 10px; }
  .company-model-nav button { min-height: 44px; gap: 5px; font-size: 10px; }
  .company-model-hint { margin-top: 8px; font-size: 9px; }
  .software-visual { left: 8px; right: 8px; top: 52svh; bottom: calc(130px + env(safe-area-inset-bottom)); }
  .software-figure-label { left: 12px; right: 12px; top: 0; font-size: 8px; line-height: 1.6; }
  .software-figure-label span:last-child { display: none; }
  .software-stage[data-chapter="0"] .software-copy {
    inset: 112px var(--site-gutter) calc(130px + env(safe-area-inset-bottom));
    height: auto; display: grid; align-content: safe center; text-align: center;
  }
  .software-hello .intro-story { height: auto; min-height: 200px; }
  .software-hello h1, .software-hello h2 { font-size: clamp(42px, 11vw, 62px); margin-bottom: 22px; }
  .software-hello .hello-word h1 { font-size: clamp(150px, 47vw, 210px); }
  .software-hello .software-body { font-size: 14px; line-height: 1.7; max-width: 350px; }
  .software-hello .intro-beat-nav { margin-top: 14px; }
  .hello-continue { min-height: 44px; margin-top: 24px; font-size: 11px; }
  .software-footer {
    left: var(--site-gutter); right: var(--site-gutter);
    bottom: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom)); padding-bottom: 0;
  }
  .software-caption, .software-scroll-label, .software-stage-count { display: none; }
  .software-footer-line { height: var(--mobile-footer-height); padding: 4px 0 0; gap: 0; }
  .software-chapter-nav, .chapter-nav, .closing-nav { width: 100%; gap: 6px; }
  .single-stage-site :is(.software-chapter-nav, .chapter-nav, .closing-nav) select {
    width: 0; max-width: none; flex: 1; min-width: 0; min-height: 44px;
    font-size: 12px; padding: 12px 25px 12px 8px; background-position: calc(100% - 15px) 19px, calc(100% - 11px) 19px;
  }
  .software-chapter-nav button, .chapter-nav button, .closing-nav button { flex: 0 0 44px; min-width: 44px; min-height: 44px; padding: 8px; justify-content: center; font-size: 18px; }
  .frame { padding-inline: var(--site-gutter); }
  .content { display: block; position: relative; }
  .story {
    position: absolute; top: 12px; left: 0; right: 0; bottom: auto;
    width: auto; max-width: none; height: calc(50svh - 124px); padding: 0;
    display: block; align-content: start; overflow-y: auto; pointer-events: auto; scrollbar-width: thin;
  }
  .chapter:not(.active) { display: none; }
  .chapter h2 { font-size: 34px; line-height: 1.08; margin-bottom: 12px; }
  .chapter .overline { font-size: 8px; letter-spacing: .7px; margin-bottom: 12px; }
  .chapter .body-copy { max-width: none; font-size: 14px; line-height: 1.65; }
  .chapter .body-copy.secondary { font-size: 12px; }
  .single-stage-site .chapter .annotation { max-width: none; font-size: 11px; line-height: 1.65; margin-top: 12px; }
  .chapter .inline-link, .chapter .data-link { min-height: 44px; display: inline-flex; align-items: center; font-size: 11px; margin-top: 5px; }
  .chapter .title-star { left: auto; right: 8px; }
  .figure-area { position: absolute; top: calc(50svh - var(--site-header-height)); bottom: 0; left: 0; right: 0; width: auto; height: auto; min-height: 0; max-height: none; }
  .figure-top { font-size: 8px; }
  .vignette { background: linear-gradient(#000 0%, #000f 44%, #0000 54%, #0000 79%, #000 91%); }
  .foot { padding-bottom: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom)); }
  .foot .caption, .foot .scroll-cue, .foot .coordinate { display: none; }
  .foot .bottom { height: var(--mobile-footer-height); padding: 4px 0 0; }
  .anime-dial-host { left: var(--site-gutter, 20px); right: var(--site-gutter, 20px); width: auto; bottom: max(8px, env(safe-area-inset-bottom)); }
  .anime-dial-panel { display: flex; height: 48px; padding: 0 12px; gap: 12px; border-radius: 8px; }
  .anime-dial-label { flex: 0 0 auto; font-size: 9px; }
  .anime-dial-readout { order: 3; min-width: 31px; font-size: 10px; text-align: right; }
  .anime-dial-range { flex: 1; min-width: 0; width: auto; height: 44px; touch-action: pan-y; }
  .function-detail-marker { width: 44px; height: 44px; opacity: .8; cursor: pointer; }
  .function-detail-tooltip { width: min(300px, calc(100% - 20px)); padding: 14px; max-height: calc(48svh - 144px); overflow-y: auto; }
  .function-detail-tooltip strong { font-size: 15px; }
  .function-detail-tooltip p { font-size: 12px; line-height: 1.6; margin-block: 8px; }
  .function-detail-hint { font-size: 9px; }
  .chapter h2[tabindex="-1"]:focus-visible, .closing-chapter h2[tabindex="-1"]:focus-visible { outline: 1px solid #a7dce066; outline-offset: 4px; }
  .software-stage[data-function="contracts"] .software-figure-label,
  .software-stage[data-function="contracts"] .function-details { display: none !important; }
  .software-legal-host { display: block; overflow: auto; padding: 8px 12px 20px; scrollbar-width: thin; }
  .software-legal-host .legal-scene { max-height: none; }
  .legal-heading { display: block; margin-bottom: 14px; }
  .legal-heading h3 { font-size: 20px; line-height: 1.3; }
  .legal-versions { margin-top: 12px; width: fit-content; }
  .legal-versions button { min-height: 44px; padding: 9px 16px; font-size: 12px; }
  .legal-pair { grid-template-columns: 1fr; gap: 14px; }
  .legal-source-link { display: none; }
  .legal-clause { font-size: 20px; line-height: 1.5; margin: 16px; }
  .legal-anchor, .legal-change { margin-inline: 16px; font-size: 11px; }
  .legal-author { margin-inline: 16px; font-size: 11px; }
  .legal-model pre { font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
  .legal-route { flex-direction: column; gap: 16px; }
  .legal-route li:not(:last-child)::after { display: none; }
  .legal-route strong { font-size: 13px; }
  .legal-route span, .legal-model-note, .legal-bottom { font-size: 11px; }
  body.single-stage-site[data-anime-band] .anime-familiar {
    width: 48px !important; height: 64px !important;
    top: auto; bottom: calc(130px + env(safe-area-inset-bottom)); right: -8px;
  }
}

@media (min-width: 568px) and (max-width: 950px) and (max-height: 500px) {
  .single-stage-site { --site-header-height: 80px; --mobile-dock-height: 56px; --mobile-footer-height: 56px; }
  .site-header { grid-template-rows: 36px 44px; }
  .site-header nav { justify-content: start; gap: 32px; }
  .software-copy { top: 92px; left: 20px; right: auto; width: 43%; height: calc(100svh - 168px); }
  .software-chapter h1, .software-chapter h2, .chapter h2 { font-size: 28px; }
  .software-visual { top: 88px; left: 48%; right: 12px; bottom: 72px; }
  .software-stage[data-chapter="0"] .software-copy { inset: 82px 20px 72px; height: auto; }
  .software-hello .intro-story { min-height: 0; }
  .software-hello h1, .software-hello h2 { font-size: 38px; margin-bottom: 12px; }
  .software-hello .hello-word h1 { font-size: 100px; }
  .hello-continue { margin-top: 6px; }
  .software-hello .intro-beat-nav { margin-top: 0; }
  .software-footer { bottom: 8px; right: 280px; }
  .foot { padding-bottom: 8px; padding-right: 260px; }
  .story { top: 12px; width: 43%; height: calc(100svh - 164px); right: auto; }
  .figure-area { top: 8px; bottom: 4px; left: 48%; right: 0; }
  .vignette { background: linear-gradient(90deg, #000 0%, #000e 43%, #0000 51%); }
  .anime-dial-host { left: auto; right: 20px; width: 240px; bottom: 8px; }
  .anime-dial-panel { gap: 8px; }
  .anime-dial-label { font-size: 8px; }
  .function-detail-tooltip { max-height: calc(100svh - 192px); }
  body.single-stage-site[data-anime-band] .anime-familiar { bottom: 76px; }
}
