/* Touch-phone portrait overrides only. Desktop and landscape styles stay intact. */
@media (max-width: 767px) and (orientation: portrait) and (hover: none) and (pointer: coarse) {
  html { scroll-padding-top: 132px; }
  .container { width: calc(100% - 32px); }
  .topbar { padding: 10px 16px 6px; gap: 4px 12px; }
  .topbar #theme-toggle { min-height: 44px; }
  .topbar nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 8px; }
  .topbar nav a { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px; }
  .hero { padding-top: 40px; }
  .hero-statement { font-size: 17px; margin-bottom: 24px; }
  .hero-logo { width: min(100%, 430px); margin: 0 auto 24px; }
  .hero h1 { font-size: clamp(22px, 5.5vw, 28px); white-space: normal; text-wrap: balance; line-height: 1.25; letter-spacing: .005em; word-spacing: .025em; }
  .hero-authors { flex-wrap: wrap; justify-content: center; overflow: visible; gap: 8px 14px; font-size: 14px; margin-bottom: 16px; }
  .hero-affiliations { font-size: 13px; line-height: 1.65; }
  .hero-affiliations p + p { margin-top: 6px; }
  .hero-description { font-size: 15px; max-width: 36ch; }
  .hero-description span { display: inline; }
  .resource-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
  .resource-links > .guide-anchor--entry { grid-column: 1 / -1; justify-self: center; margin-bottom: 66px; }
  .resource-links > .button { min-width: 0; justify-content: center; }
  .button { min-height: 44px; padding: 10px 12px; }
  .guide-anchor--entry .tour-guide--entry { left: 50%; transform: translateX(-50%); }
  .guide-dismiss { width: 36px; height: 36px; top: 0; right: 0; }
  .tour-guide { padding-right: 39px; }
  .hero-rule { margin-top: 36px; }
  .section { padding-block: 48px; }
  .section-heading { margin-bottom: 24px; }
  .section-heading h2 { font-size: 24px; line-height: 1.25; text-wrap: balance; }
  .section-heading > p, .problem-grid p, .method-card p, .protocol-note p,
  .diagnostic-evidence figcaption, .evidence-pair figcaption, .coverage-plates figcaption,
  .figure-notes, .reproduce-grid p, .demo-panel > p,
  .paper-artwork figcaption, .evidence-card p,
  .inspector-copy #detail-description, .technical-note p {
    text-align: justify; text-align-last: start; text-justify: inter-word;
    hyphens: auto; overflow-wrap: break-word; text-wrap: wrap;
  }
  .problem-copy, .insight, .method-card { padding: 20px; }
  .problem-grid, .method-grid, .reproduce-grid, .evidence-pair { min-width: 0; gap: 16px; }
  .demo-tabs { flex-wrap: wrap; overflow: visible; gap: 8px; padding: 4px 2px 10px; margin-bottom: 10px; scroll-snap-type: none; }
  .demo-tabs button { flex: 0 0 auto; max-width: 100%; min-height: 44px; white-space: normal; }
  .demo-panel { padding: 14px; border-radius: 16px; }
  .demo-panel video { max-height: 55svh; object-fit: contain; }
  .demo-panel > a { display: inline-flex; min-height: 44px; align-items: center; }
  .video-play { min-height: 52px; white-space: nowrap; font-size: 14px; padding-inline: 16px; }
  .diagnostic-plot-frame { padding: 16px 10px; border-radius: 16px; }
  .diagnostic-panel-grid { gap: 24px 10px; width: 100%; }
  .diagnostic-evidence .diagnostic-panel > figcaption { font-size: 14px; margin-top: 12px; }
  .metric-strip article { padding: 20px; }
  .metric-value { font-size: 28px; }
  .figure-strip { gap: 24px 16px; }
  .figure-strip figcaption { line-height: 1.5; }
  .table-scroll { max-width: 100%; overflow: visible; }
  .table-scroll table { min-width: 0; width: 100%; table-layout: auto; font-size: clamp(10px, 2.8vw, 13px); line-height: 1.4; }
  .table-scroll caption { padding: 10px 8px; border-radius: 11px 11px 0 0; font-size: clamp(12px, 3.2vw, 14px); }
  .table-scroll th, .table-scroll td { padding: 9px clamp(4px, 1.2vw, 8px); white-space: normal; overflow-wrap: anywhere; vertical-align: middle; }
  .table-scroll tbody td strong { white-space: nowrap; }
  .table-scroll tfoot td { font-size: inherit; line-height: 1.5; border-radius: 0 0 11px 11px; }
  .explainer-entry { padding: 16px; gap: 12px; }
  .explainer-entry-arrow { font-size: 20px; }
  .code-heading { padding: 8px 12px; gap: 8px; }
  .code-heading button { min-height: 44px; min-width: 52px; }
  pre { padding: 14px; }
  .footer-links { gap: 6px 20px; }
  .footer-links a, .footer-bottom a { display: inline-flex; align-items: center; min-height: 44px; }
  .evidence-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 24px); border-radius: 16px; }
  .evidence-dialog header { gap: 12px; padding: 12px 14px; }
  .evidence-dialog h2 { font-size: 18px; }
  .evidence-close { width: 44px; height: 44px; }
  .evidence-body { padding: 16px; }
  .evidence-grid { grid-template-columns: minmax(0, 1fr); }
  .evidence-card { min-width: 0; }
  #release-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px; }

  /* Explainer: reachable controls, complete chapter list, locally scrollable detail. */
  .explainer-header { min-height: 60px; height: auto; padding: 8px 12px; gap: 12px; }
  .explainer-header nav { display: flex; margin-left: auto; }
  .explainer-header nav a { display: flex; min-height: 44px; align-items: center; }
  .explainer-header .theme-toggle { min-height: 44px; margin-left: 0; padding-inline: 10px; }
  .explainer-header + main { height: auto; min-height: 0; padding: 10px 8px 20px; }
  .workbench { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; overflow: visible; border-radius: 14px; }
  .chapter-tabs { grid-row: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; padding: 6px; overflow: visible; border-radius: 14px 14px 0 0; }
  .chapter-tabs button, .chapter-tabs button:last-child { display: grid; grid-template-columns: 20px minmax(0, 1fr); min-width: 0; min-height: 46px; padding: 6px; gap: 4px; font-size: 13px; line-height: 1.3; border-radius: 8px; text-align: left; }
  .chapter-tabs button > span { display: inline; font-size: 10px; }
  .chapter-tabs button i { display: none; }
  .playback { grid-row: 2; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; min-height: 0; padding: 8px; position: sticky; top: 0; bottom: auto; z-index: 5; border-bottom: 1px solid var(--line); }
  .playback #play { grid-column: 1 / 4; grid-row: 1; align-self: start; }
  .playback > .guide-anchor { grid-column: 4 / 7; grid-row: 1; min-width: 0; flex-direction: column; align-self: start; }
  .playback .play-button, .playback .narration-button { min-width: 0; width: 100%; min-height: 44px; padding: 8px; font-size: 13px; gap: 6px; }
  .playback #previous { grid-column: 1; grid-row: 2; }
  .playback #next { grid-column: 2; grid-row: 2; }
  .playback .icon-button { min-width: 0; width: 100%; height: 44px; border-radius: 12px; }
  .playback .speed-label { grid-column: 3 / 5; grid-row: 2; }
  .playback .speed-label select { width: 100%; height: 44px; font-size: 16px; padding: 4px 10px; }
  .playback #reset { display: block; grid-column: 5 / 7; grid-row: 2; min-height: 44px; font-size: 13px; }
  .playback .timeline { grid-column: 1 / -1; grid-row: 3; width: 100%; min-width: 0; margin: 0; }
  .playback #tour-seek { height: 28px; }
  .playback .timeline-markers { display: none; }
  .playback .tour-guide--narration { position: relative; inset: auto; width: 100%; max-width: none; margin-top: 8px; padding: 8px 34px 8px 10px; font-size: 11px; }
  .playback .tour-guide--narration::before { display: none; }
  .stage-layout { grid-row: 3; min-width: 0; }
  .stage-canvas { height: 340px; padding-inline: 8px; grid-template-rows: minmax(0, 1fr) auto; }
  #diagram-viewport { min-width: 0; overflow-x: auto; overflow-y: hidden; justify-content: flex-start; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--purple) var(--surface); }
  #diagram-viewport:not(.recorded) #detail-visual { min-width: 600px; }
  #diagram-viewport.recorded #detail-visual { min-width: 0; width: 100%; }
  .candidate-controls { flex-wrap: wrap; gap: 6px; padding-block: 6px; }
  .candidate-controls button { min-width: 40px; height: 40px; }
  .inspector { padding: 20px 16px; border-radius: 0 0 14px 14px; }
  .inspector #detail-title { font-size: 20px; margin: 0 0 12px; }
  .inspector-copy #detail-description { font-size: 14px; line-height: 1.7; }
  .technical-note p { font-size: 13px; }
  .inspector button, .stage-options select, .technical-note summary { min-height: 44px; }
  .inspector input[type=range] { height: 32px; }
  .formula { font-size: 12px; overflow-wrap: anywhere; }
  .model-map-toolbar { padding: 0 4px 8px; }
  .model-map-tabs { width: 100%; }
  .model-map-tabs button, #model-map-close { min-height: 44px; }
  .model-map-canvas { overflow: auto; }
  .narrating .explainer-header { position: sticky; top: 0; z-index: 8; grid-template-columns: minmax(0, 1fr) 44px auto; min-height: 0; padding: 8px 12px; }
  .narrating .explainer-header nav { display: none; }
  .narrating .narration-caption { min-height: 0; padding-block: 8px; text-align: left; }
  .narrating .narration-caption #narration-subtitle { font-size: 17px; line-height: 1.45; }
  .narration-exit { width: 44px; height: 44px; }
  .narrating .playback { position: static; }
  .narrating .playback #narration-mute { grid-column: 1 / 3; grid-row: 2; min-height: 44px; }
  .narrating .playback .narration-mute span { display: inline; }
  #supervision-panel, #validation-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 24px); padding: 48px 18px 22px; overflow-y: auto; }
  .dialog-close { width: 44px; height: 44px; top: 6px; right: 6px; }
  dialog h2 { font-size: 21px; }
  .training-flow { flex-direction: column; align-items: stretch; gap: 8px; }
  .training-flow i { text-align: center; transform: rotate(90deg); }
}
