/* Mobile practice navigation and card alignment. Question bodies deliberately
   retain their reading layout; no quiz behaviour or desktop geometry changes. */
@media (max-width: 720px) {
  #main .journey-shell { min-width: 0; text-align: center; }
  #main .journey-shell :is(h1,h2,h3,p,.breadcrumb,.card-title,.card-copy,.card-foot,.card-eyebrow,small,.practice-card-facts,.revision-set-status) {
    text-align: center;
    overflow-wrap: anywhere;
  }
  #main .journey-shell :is(h1,h2,h3,.card-title) { text-wrap: balance; }
  #main .journey-shell :is(.journey-cards,.practice-format-grid,.practice-set-grid) {
    grid-template-columns: minmax(0,1fr);
    min-width: 0;
  }
  #main .journey-shell :is(.journey-card,.practice-mode-card,.practice-card) {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    align-items: center;
    text-align: center;
  }
  #main .journey-shell .card-heading-row {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
  }
  #main .journey-shell .card-heading-row :is(.card-art,.practice-card-orbit) {
    position: static;
    align-self: center;
    margin: 0;
    flex: 0 0 56px;
  }
  #main .journey-shell .card-heading-row .card-title {
    margin: 0;
    max-width: 100%;
  }
  #main .journey-shell :is(.card-copy,.card-foot,.practice-card-facts,.card-eyebrow) {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  #main .journey-shell .welcome-motivation {
    flex-direction: column;
    align-items: center;
  }
  #main .journey-shell .welcome-motivation .card-art { align-self: center; }
  #main .journey-shell :is(.primary,.secondary,.quiet) {
    justify-content: center;
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }
  #main .journey-shell :is(.landing-actions,.revision-actions,.journey-top,.journey-progress) {
    justify-content: center;
    flex-wrap: wrap;
  }
  #main .journey-shell .landing-message :is(h1,p) { margin-inline: auto; }
  #main .journey-shell .landing-feature { justify-content: center; text-align: center; }
  #main .journey-shell :is(.resume-banner,.membership-preview-note) {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
  }
  #main .journey-shell .difficulty-bar {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
  }
  #main .journey-shell .difficulty-toggle {
    width: 100%;
    max-width: 360px;
    box-sizing: border-box;
    align-self: center;
  }
  #main .journey-shell .difficulty-toggle button { flex: 1; min-width: 0; padding-inline: 10px; }

  /* Centre exam chrome without centring scientific statements or options. */
  #main :is(.exam-head,.welcome) {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    gap: 14px;
  }
  #main :is(.exam-head,.welcome) > div:first-child { min-width: 0; width: 100%; }
  #main :is(.exam-head,.welcome) :is(h1,p,.breadcrumb) { text-align: center; overflow-wrap: anywhere; }
  #main .exam-journey-nav { justify-content: center; text-align: center; }
  #main .exam-journey-nav > span { margin-inline: 0; }
  #main .timer-dock { margin-inline: auto; max-width: 100%; }
  #main .question-top { flex-wrap: wrap; justify-content: center; text-align: center; gap: 8px; }
  #main .question-tools { flex-wrap: wrap; justify-content: center; gap: 8px; }
  #main .nav-row { flex-wrap: wrap; justify-content: center; gap: 10px; }
  #main .nav-right { flex-wrap: wrap; justify-content: center; gap: 8px; }
  #main .nav-row button { min-height: 44px; }
  #main .autosave { flex-wrap: wrap; justify-content: center; text-align: center; gap: 8px; }
  #main .palette :is(h3,p) { text-align: center; }
  #main .timer-note { text-align: center; }
  #main .result-hero { text-align: center; }
  #main .result-hero :is(h2,p) { text-align: center; }
  #main .result-hero button { max-width: 100%; min-height: 44px; white-space: normal; margin-block: 5px; }
  #main .revision-actions { justify-content: center; text-align: center; }
  #main .revision-actions button { justify-content: center; }

  /* Shared header only on actual student pages, never policy/admin screens. */
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: 0;
    gap: 8px;
    padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
    text-align: center;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header .brand {
    order: 0; flex: 1 0 100%; min-width: 0; justify-content: center; gap: 10px;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header .brand-name {
    margin-left: 0; font-size: 18px !important;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header .header-journey {
    order: 1; flex: 1 0 100%; min-width: 0; justify-content: center; flex-wrap: wrap; gap: 8px;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header .header-journey .quiet {
    flex: 1 1 76px; max-width: 150px; min-height: 44px; padding: 10px 8px;
    justify-content: center; margin: 0; font-size: 12px; text-align: center;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header > button {
    order: 2; flex: 1 1 108px; min-width: 0; max-width: 180px; min-height: 44px;
    margin: 0; padding: 10px 12px; white-space: normal; overflow-wrap: anywhere; text-align: center; font-size: 12px;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header :is(#loginBtn,#historyBtn) {
    margin: 0; max-width: 180px; white-space: normal; overflow: visible; text-overflow: clip; font-size: 12px;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header #menuBtn {
    flex: 0 0 44px; width: 44px; height: 44px; padding: 10px;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header .avatar { order: 3; }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > header [hidden] { display: none !important; }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > .site-footer { align-items: center; text-align: center; }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > .site-footer nav {
    display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; max-width: 420px; gap: 8px 12px;
  }
  body:has(#main > :is(.journey-shell,.exam-head,.result-hero,.welcome,.revision-workspace)) > .site-footer button {
    min-height: 44px; min-width: 0; padding: 10px 8px; text-align: center; white-space: normal;
  }
}

/* Keep long questions readable and their controls easy to reach on small screens. */
#main :is(.question-number,#questionMapTitle) { scroll-margin-block-start: 6rem; }
#main :is(.question-number,#questionMapTitle):focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}
@media (max-width: 720px) {
  #main .exam-layout > * { min-width: 0; }
  #main .question-panel :is(.option,.text-button) { min-height: 44px; }
  #main .question-panel :is(.option,.text-button) > span { min-width: 0; }
  #main .question-panel .option > span:not(.option-letter) { overflow-wrap: anywhere; }
  #main .exam-journey-nav .exam-map-link { min-height: 44px; }
}
