/* A mobile reading rhythm: chapter → scene → next chapter. */
@media (max-width: 900px) {
  .hero h1,
  .fx-hero h1,
  .uc-hero h1 {
    text-wrap: balance;
  }
  .hero-stack {
    display: grid;
    gap: 16px;
    padding: 24px 0 0;
    perspective: 1000px;
  }
  .hero-recording,
  .hero-log,
  .hero-proof {
    position: relative;
    inset: auto;
    width: 100%;
    margin: 0;
    animation: none;
    transform: none;
  }
  .hero-log {
    width: 94%;
    margin-left: auto;
  }
  .hero-proof {
    width: 94%;
    padding: 20px;
  }
  .hero-rule {
    gap: 16px;
    align-items: start;
    line-height: 1.5;
  }
  .hero-rule > span:last-child {
    white-space: nowrap;
  }
  .visual-caption {
    line-height: 1.5;
  }
  .mobile-story > .fs-sticky,
  .mobile-story .uc-story-pin,
  .assembly.mobile-story .assembly-stage,
  .assembly.mobile-story .assembly-inner > .chapter-controls {
    display: none;
  }
  .mobile-story-flow {
    display: grid;
    gap: 64px;
    width: 100%;
  }
  .mobile-story-step {
    min-width: 0;
    scroll-margin-top: 112px;
  }
  .mobile-story-step + .mobile-story-step {
    padding-top: 32px;
    border-top: 1px solid var(--line);
  }
  .mobile-story-step .fs-chapter,
  .mobile-story-step .uc-chapter {
    margin-bottom: 28px;
    padding: 0;
  }
  .mobile-story-step .fs-chapter p,
  .mobile-story-step .uc-chapter p,
  .uc-hero-bottom > p,
  .uc-outcome p {
    font-size: var(--text-body);
  }
  .mobile-story-step .fs-result,
  .mobile-story-step .uc-takeaway {
    font-size: var(--text-support);
    line-height: 1.5;
  }
  .mobile-story-step .fs-chapter h2,
  .mobile-story-step .uc-chapter h3 {
    font-size: clamp(2rem, 8vw, 2.75rem);
    line-height: 1.13;
  }
  .mobile-story-step .fs-chapter-index {
    margin-bottom: 16px;
  }
  .mobile-scene,
  .mobile-scene > div {
    min-height: 0;
    height: auto;
  }
  .mobile-scene .fs-record-scene,
  .mobile-scene .fs-share-scene {
    padding: 0;
  }
  .mobile-scene .fs-record-window,
  .mobile-scene .fs-share-origin {
    width: 100%;
  }
  .mobile-scene .fs-record-evidence,
  .mobile-scene .fs-record-handoff,
  .mobile-scene .fs-share-team,
  .mobile-scene .fs-share-guest,
  .mobile-scene .fs-mcp-response {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
  .mobile-scene .fs-scene-footnote {
    position: static;
    display: block;
    margin-top: 20px;
  }
  .mobile-scene .fs-mcp-scene,
  .mobile-scene .fs-audio-scene {
    padding: 24px 20px;
  }
  .mobile-scene .fs-mcp-route {
    margin-bottom: 0;
  }
  .mobile-scene .fs-mcp-evidence {
    margin: 0;
  }
  .mobile-scene .fs-mcp-response {
    padding: 0;
  }
  .mobile-scene .fs-audio-resolve {
    margin-top: 0;
  }
  .mobile-scene .uc-scene {
    display: block;
  }
  .mobile-scene .uc-frame {
    position: relative;
    inset: auto;
    width: 100%;
    transform: none;
  }
  .mobile-workflow .chapter-controls {
    display: block;
    margin: 0 0 24px;
  }
  .mobile-workflow .chapter-controls button {
    width: 100%;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .mobile-workflow .chapter-controls button b {
    font-size: 1.75rem;
    line-height: 1.2;
  }
  .mobile-workflow .chapter-controls button small {
    font-size: var(--text-support);
  }
  .mobile-workflow .chapter-controls button > span {
    color: var(--sage);
  }
  .assembly.mobile-story .stage-label {
    display: none;
  }
  .assembly.mobile-story .assembly-inner {
    gap: 40px;
  }
  .mobile-story-step .mobile-scene {
    transform-origin: center top;
  }
  .button,
  .text-link,
  .menu-toggle,
  .fx-selector button {
    min-height: 48px;
  }
  .button,
  .menu-toggle,
  .fx-selector button {
    transition:
      transform 160ms cubic-bezier(0.22, 1, 0.36, 1),
      background-color 160ms;
  }
  .button:active,
  .menu-toggle:active,
  .fx-selector button:active {
    transform: scale(0.97);
  }
  input,
  select,
  textarea {
    font-size: max(1rem, 16px);
  }
  .site-footer {
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
  .mobile-motion .hero-recording {
    opacity: calc(0.35 + var(--mobile-progress, 1) * 0.65);
    transform: translateY(calc((1 - var(--mobile-progress, 1)) * 36px))
      rotateX(calc((1 - var(--mobile-progress, 1)) * 8deg));
  }
  .mobile-motion .hero-log {
    opacity: clamp(0.15, calc(var(--mobile-progress, 1) * 1.5 - 0.2), 1);
    transform: translateY(calc((1 - var(--mobile-progress, 1)) * 64px));
  }
  .mobile-motion .hero-proof {
    opacity: clamp(0.15, calc(var(--mobile-progress, 1) * 2 - 0.6), 1);
    transform: translateY(calc((1 - var(--mobile-progress, 1)) * 88px));
  }
  .mobile-motion #site-nav.is-open {
    animation: mobile-menu 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  @keyframes mobile-menu {
    from {
      opacity: 0;
      transform: translateY(-12px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
@media (max-width: 900px) {
  .site-header {
    background: var(--paper);
  }
  .hero-rule {
    display: flex;
  }
  .mobile-story > .mobile-story-flow {
    padding-block: 24px;
  }
  .mobile-scene .fs-wave-area {
    margin-block: 12px;
  }
}
@media (max-width: 900px) {
  .mobile-story .mobile-story-flow > :is(.fs-chapters, .uc-chapter-buttons) {
    position: sticky;
    top: 84px;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding-block: 8px;
    margin-bottom: -32px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  .mobile-story-flow > :is(.fs-chapters, .uc-chapter-buttons) button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 4px;
    padding: 8px;
    min-height: 64px;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: var(--text-caption);
    line-height: 1.35;
    text-align: left;
    transition:
      color 180ms,
      background-color 180ms;
  }
  .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons)
    button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--accent);
  }
  .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons)
    button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }
  .mobile-story-step {
    scroll-margin-top: 208px;
  }
}

/* Keep visible movement after a touch flick, when Safari coalesces scroll frames. */
@media (max-width: 900px) and (prefers-reduced-motion: no-preference) {
  .mobile-motion .hero-recording,
  .mobile-motion .hero-log,
  .mobile-motion .hero-proof {
    transition:
      transform 580ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 420ms ease-out;
  }
  .mobile-scene-anchor {
    min-width: 0;
    display: flow-root;
  }
}

/* One pinned composition. Scroll brings each new source over the preceding one. */
@media (max-width: 900px) {
  .mobile-chapter-nav {
    display: none;
  }
  .mobile-cinematic .mobile-scroll-track {
    height: 380svh;
    width: 100%;
  }
  .mobile-cinematic .mobile-story-flow {
    position: sticky;
    top: 84px;
    height: calc(100svh - 84px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto var(--caption-height, 200px) minmax(0, 1fr);
    gap: 20px;
    padding: 12px 0 20px !important;
    overflow: clip;
    isolation: isolate;
  }
  .mobile-cinematic .mobile-story-step {
    display: contents;
  }
  .mobile-cinematic
    .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons, .mobile-chapter-nav) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    position: relative;
    top: auto;
    grid-area: 1 / 1;
    margin: 0;
    padding: 0 0 8px;
    gap: 4px;
    z-index: 10;
    background: transparent;
    border-bottom: 1px solid var(--line);
  }
  .mobile-cinematic
    .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons, .mobile-chapter-nav)::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform: scaleX(var(--cinematic-progress));
    transform-origin: left;
  }
  .mobile-cinematic
    .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons, .mobile-chapter-nav)
    button {
    display: block;
    min-height: 48px;
    padding: 6px;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-align: left;
    font: inherit;
    font-size: 16px;
    line-height: 1.3;
  }
  .mobile-cinematic
    .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons, .mobile-chapter-nav)
    button
    > span {
    display: block;
  }
  .mobile-cinematic
    .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons, .mobile-chapter-nav)
    button[aria-pressed="true"] {
    color: var(--accent);
  }
  .mobile-cinematic
    .mobile-story-step
    > :is(.fs-chapter, .uc-chapter, .chapter-controls) {
    grid-area: 2 / 1;
    margin: 0;
    align-self: start;
    min-width: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition:
      opacity 200ms ease-out,
      transform 280ms var(--ease),
      visibility 200ms;
  }
  .mobile-cinematic
    [data-cinematic-chapter="0"]
    [data-mobile-step="0"]
    > :is(.fs-chapter, .uc-chapter, .chapter-controls),
  .mobile-cinematic
    [data-cinematic-chapter="1"]
    [data-mobile-step="1"]
    > :is(.fs-chapter, .uc-chapter, .chapter-controls),
  .mobile-cinematic
    [data-cinematic-chapter="2"]
    [data-mobile-step="2"]
    > :is(.fs-chapter, .uc-chapter, .chapter-controls) {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .mobile-cinematic .mobile-story-step .fs-chapter-index,
  .mobile-cinematic .mobile-story-step .uc-caption,
  .mobile-cinematic .mobile-story-step .fs-result,
  .mobile-cinematic .mobile-story-step .uc-takeaway,
  .mobile-cinematic .mobile-workflow .chapter-controls button > span {
    display: none;
  }
  .mobile-cinematic .mobile-story-step :is(.fs-chapter h2, .uc-chapter h3) {
    font-size: clamp(1.65rem, 6.5vw, 2.25rem);
    margin: 0 0 12px;
    line-height: 1.12;
  }
  .mobile-cinematic .mobile-story-step :is(.fs-chapter p, .uc-chapter p) {
    font-size: 20px;
    line-height: 1.45;
  }
  .mobile-cinematic .mobile-workflow .chapter-controls button b {
    font-size: 2rem;
  }
  .mobile-cinematic .mobile-workflow .chapter-controls button small {
    margin-top: 12px;
  }
  .mobile-cinematic .mobile-scene-anchor {
    grid-area: 3 / 1;
    position: relative;
    min-height: 0;
    height: 100%;
    width: 100%;
    transform-origin: center top;
    align-self: stretch;
    transition: transform 120ms linear;
  }
  .mobile-cinematic .mobile-scene-anchor .mobile-scene {
    position: absolute;
    width: 100%;
    max-width: 520px;
    left: 0;
    right: 0;
    margin: auto;
    top: 0;
    opacity: 1 !important;
    transform: scale(var(--scene-scale, 1)) !important;
    transform-origin: center top;
    transition: none;
    filter: drop-shadow(0 14px 12px rgb(20 36 24 / 0.16));
  }
  .mobile-cinematic [data-mobile-step="0"] .mobile-scene-anchor {
    z-index: 1;
    transform: translateY(calc(var(--recede) * -8px))
      scale(calc(1 - var(--recede) * 0.12)) rotate(calc(var(--recede) * -3deg));
  }
  .mobile-cinematic [data-mobile-step="1"] .mobile-scene-anchor {
    z-index: 2;
    transform: translate(
        calc((1 - var(--arrival)) * -70px),
        calc((1 - var(--arrival)) * var(--lift) + 28px)
      )
      scale(calc(1 - var(--recede) * 0.075))
      rotate(calc((1 - var(--arrival)) * -8deg + var(--recede) * 2deg));
  }
  .mobile-cinematic [data-mobile-step="2"] .mobile-scene-anchor {
    z-index: 3;
    transform: translate(
        calc((1 - var(--arrival)) * 90px),
        calc((1 - var(--arrival)) * var(--lift) + 56px)
      )
      rotate(calc((1 - var(--arrival)) * 8deg));
  }
  .mobile-cinematic .mobile-scene .fs-debug-scene {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 20px;
    border-radius: 12px;
  }
  .mobile-cinematic .mobile-workflow .mobile-chapter-nav button {
    color: var(--sage);
  }
  .mobile-cinematic
    .mobile-workflow
    .mobile-chapter-nav
    button[aria-pressed="true"] {
    color: var(--paper);
  }
  .mobile-cinematic .mobile-workflow .mobile-chapter-nav::after {
    background: var(--sage);
  }
  .mobile-cinematic .hero-stack {
    display: block;
    height: 510px;
    padding-top: 24px;
  }
  .mobile-cinematic .hero-recording {
    width: 96%;
  }
  .mobile-cinematic .hero-log {
    position: absolute;
    top: 190px;
    right: 0;
    width: 88%;
  }
  .mobile-cinematic .hero-proof {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 85%;
  }
  .mobile-cinematic .hero-log .log-line code,
  .mobile-cinematic .hero-log .panel-caption,
  .mobile-cinematic .hero-log .source-row {
    font-size: 16px;
  }
}
@media (max-width: 900px) {
  .mobile-cinematic .mobile-workflow .chapter-controls button {
    display: block;
  }
  .mobile-cinematic .mobile-workflow .chapter-controls button b,
  .mobile-cinematic .mobile-workflow .chapter-controls button small {
    display: block;
    width: 100%;
  }
  .mobile-cinematic .mobile-scene.uc-scene,
  .mobile-cinematic .mobile-scene > .uc-scene {
    padding: 0;
    background: transparent;
  }
  .mobile-cinematic .mobile-scene .uc-frame {
    min-height: 0;
  }
}
@media (max-width: 900px) {
  .mobile-cinematic .fs-mcp [data-mobile-step="2"] .fs-mcp-scene {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--line);
  }
  .mobile-cinematic .fs-mcp [data-mobile-step="2"] .fs-scene-footnote {
    color: var(--muted);
  }
}
@media (max-width: 900px) and (max-height: 650px) {
  .mobile-cinematic .mobile-story-step :is(.fs-chapter p, .uc-chapter p) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .mobile-cinematic .mobile-story-flow {
    gap: 12px;
  }
}
@media (min-width: 600px) and (max-width: 900px) and (max-height: 500px) {
  .mobile-cinematic .mobile-story-flow {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px 24px;
  }
  .mobile-cinematic
    .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons, .mobile-chapter-nav) {
    grid-area: 1 / 1 / 2 / 3;
  }
  .mobile-cinematic
    .mobile-story-step
    > :is(.fs-chapter, .uc-chapter, .chapter-controls) {
    grid-area: 2 / 1;
  }
  .mobile-cinematic .mobile-scene-anchor {
    grid-area: 2 / 2;
  }
  .mobile-cinematic
    .mobile-story-flow
    > :is(.fs-chapters, .uc-chapter-buttons, .mobile-chapter-nav)
    button
    > span {
    display: inline;
    margin-right: 8px;
  }
}
