#mobileNav, .mobile-brand, .mobile-quick, .mobile-select { display: none; }

@media screen and (max-width: 720px), screen and (max-width: 925px) and (pointer: coarse) {
  :root {
    --mobile-gutter: clamp(12px, 4vw, 24px);
    --mobile-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    scroll-padding-bottom: calc(var(--mobile-bottom) + 14px);
  }
  body { -webkit-tap-highlight-color: transparent; }
  .workspace { margin-left: 0; }
  .workspace main {
    max-width: 760px;
    padding: 15px max(var(--mobile-gutter), env(safe-area-inset-right, 0px)) calc(var(--mobile-bottom) + 25px) max(var(--mobile-gutter), env(safe-area-inset-left, 0px));
  }
  button, a, summary, select, label { touch-action: manipulation; }
  #top {
    min-height: calc(55px + env(safe-area-inset-top, 0px));
    height: auto;
    padding: env(safe-area-inset-top, 0px) max(var(--mobile-gutter), env(safe-area-inset-right, 0px)) 0 max(var(--mobile-gutter), env(safe-area-inset-left, 0px));
    gap: 9px;
  }
  .top .mobilebtn, .top .searchTrigger, #side .drawerClose, .searchtop .close {
    display: inline-grid; place-items: center; inline-size: 44px; block-size: 44px;
    flex: 0 0 44px; padding: 0; border: 0; background: transparent;
  }
  .top .mobilebtn { margin-inline-start: -7px; }
  .top .searchTrigger { margin: 0 -7px 0 auto; }
  .top .searchTrigger .icon { width: 20px; height: 20px; }
  .top .searchTrigger span, .top .searchTrigger kbd, .top .profile, .crumb>a, .crumb>span, .crumb>.icon { display: none; }
  .top .crumb { min-width: 0; color: var(--text); font-size: 16px; }
  .top .crumb b { overflow-wrap: anywhere; }
  .mobile-brand { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; font-size: 17px; font-weight: 750; letter-spacing: .01em; }
  .mobile-brand img { display: block; border-radius: 6px; }
  .mobile-brand+.crumb { display: none; }

  #mobileNav {
    position: fixed; z-index: 4; inset: auto 0 0;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: var(--mobile-bottom);
    padding: 4px max(6px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    border-top: 1px solid #303b43;
    background: #111820; box-shadow: 0 -4px 18px #080d121f;
  }
  #mobileNav a { display: grid; justify-items: center; align-content: center; grid-template-rows: 24px auto; gap: 1px; min-height: 49px; color: #a9b7c2; font-size: 12px; line-height: 1.55; font-weight: 600; }
  #mobileNav svg, .mobile-quick svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
  #mobileNav svg { align-self: center; }
  #mobileNav a[aria-current] { color: var(--lime); }
  #mobileNav a[aria-current] svg { fill: #b5f58a17; stroke-width: 1.95; }
  #mobileNav a:active, .mobile-quick a:active { background: #26332d; border-radius: 8px; }
  body:has(dialog[open]) #mobileNav, .navopen #mobileNav { visibility: hidden; }
  body:has(input:not([type=checkbox]):not([type=radio]):focus,textarea:focus) #mobileNav { display: none; }
  #toast { bottom: calc(var(--mobile-bottom) + 9px); max-width: calc(100% - 24px); width: max-content; font-size: 14px; text-align: center; }

  #side { position: fixed; z-index: 6; width: min(310px, calc(100% - 44px)); padding: env(safe-area-inset-top, 0px) 14px max(18px, env(safe-area-inset-bottom, 0px)); visibility: hidden; transform: translateX(-105%); }
  .navopen { overflow: hidden; }
  .navopen #side { visibility: visible; transform: none; }
  .navopen #shade { display: block; position: fixed; z-index: 5; inset: 0; width: 100%; border: 0; background: #03090bd9; }
  #side .drawerClose { position: absolute; right: 10px; top: calc(13px + env(safe-area-inset-top, 0px)); border-radius: 8px; }
  #side .brand { min-height: 70px; margin-bottom: 5px; }
  #side .navlink { min-height: 44px; }

  .hero { display: block; min-height: 0; border-radius: 13px; }
  .heroBody { max-width: none; padding: 21px clamp(16px, 4.5vw, 24px) 0; }
  .hero h1 { position: relative; width: fit-content; margin: 10px 0 7px; font-size: clamp(30px, 7.55vw, 42px); letter-spacing: -.06em; line-height: 1.22; }
  .heroBody>p { position: relative; z-index: 1; max-width: 18em; font-size: 14px; line-height: 1.65; color: #d0dbd2; }
  .heroBody .eyebrow { font-size: 10px; }
  .heroBody .actions { margin: 15px 0 17px; }
  .hero .actions .btn.primary { min-height: 44px; padding-inline: 16px; font-size: 15px; }
  .hero .actions .btn.ghost { display: none; }
  .heroArt { width: 58%; height: 70%; inset: auto -8% 17% auto; transform: none; opacity: .92; mask-image: linear-gradient(to right, transparent, #000 22%); }
  .heroArt canvas { object-fit: contain; }
  .heroMeta { position: relative; margin: 0; min-height: 39px; gap: 5px; font-size: 12px; border-top: 1px solid #49604c; }
  .heroMeta b { font-size: 14px; }
  .heroMeta i { margin: 0 5px; }
  .mobile-quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 10px 0 0; border: 1px solid var(--edge); border-radius: 10px; background: var(--panel); }
  .mobile-quick a { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 50px; font-size: 14px; font-weight: 620; }
  .mobile-quick a+a { border-left: 1px solid var(--edge); }
  .mobile-quick svg { flex: 0 0 18px; width: 18px; height: 18px; color: #aab8b6; }
  .section { margin-top: 23px; }
  .sectionHead { margin-bottom: 8px; gap: 8px; }
  .sectionHead h2, .banktitle h2 { font-size: 21px; }
  .sectionHead .textlink, .pagehead .back, .subjectstrip .textlink, .paging a { min-height: 44px; align-items: center; }
  .cardgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cardgrid .cardart { height: clamp(52px, 16vw, 100px); }
  .cardgrid .cardtext { padding: 10px 11px 12px; }
  .cardgrid .eng { display: none; }
  .cardgrid .cardtext h3 { font-size: clamp(15px, 4.15vw, 20px); line-height: 1.4; letter-spacing: -.035em; }
  .cardgrid .cardtext p { margin-top: 4px; font-size: 12px; }
  .cardgrid .cardtext p span { margin-inline: 2px; }

  .pagehead { margin: 0 0 17px; }
  .pagehead h1 { font-size: clamp(26px, 6.8vw, 34px); line-height: 1.35; overflow-wrap: anywhere; }
  .pagehead>p { margin-top: 6px; font-size: 15px; line-height: 1.7; }
  .pagehead .back { margin: -5px 0 3px; }
  .btn, .btn.mini, .modes a, .past-tabs a { min-height: 44px; }
  .modes a, .past-tabs a { display: inline-flex; align-items: center; gap: 3px; }
  .chapter summary, .past-written-row summary { min-height: 52px; }
  .chapter .rowlink { min-height: 49px; padding: 10px 14px; font-size: 15px; line-height: 1.65; }
  .lessonBody, .quiz { padding: clamp(15px, 4vw, 23px); }
  .lessonBody p, .analysis p, .subqs li { font-size: 16px; line-height: 1.85; }
  .readActions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .readActions .btn { min-width: 0; padding-inline: 7px; font-size: 14px; text-align: center; }
  .paging { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .paging a { display: flex; line-height: 1.6; overflow-wrap: anywhere; }
  .paging a:last-child { justify-content: flex-end; }
  .options { gap: 8px; }
  .option { min-height: 50px; padding: 10px 12px; font-size: 16px; line-height: 1.6; }
  .option b { flex: 0 0 26px; }
  .quiz>[data-action=submit] { width: 100%; min-height: 47px; }
  .actions.v3-entries, .past-tools { gap: 8px; }
  .actions.v3-entries .btn { flex: 1 1 auto; font-size: 14px; }
  .past-tabs { gap: 0 12px; justify-content: space-between; margin-block: 12px 16px; }
  .past-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .past-yearnav:has(.mobile-select) { padding: 9px 13px; }
  .past-yearnav:has(.mobile-select)>h2, .past-yearnav:has(.mobile-select)>div, .filterbar:has(.mobile-select)>a { display: none; }
  .mobile-select { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; color: var(--text); font-size: 14px; font-weight: 600; }
  .mobile-select select { min-width: 0; max-width: 75%; min-height: 44px; padding: 5px 8px; font: 500 16px var(--sans); color: var(--text); background: #131c24; border: 1px solid #394650; border-radius: 6px; }
  .filterbar:has(.mobile-select) { padding: 8px 12px; border: 1px solid var(--edge); border-radius: 8px; }
  .past-out, .past-practice, .v3-source .textlink, .paperSource a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
  .past-qa-links, .past-written-inside .past-tools { gap: 0 12px; }
  .v3-evidence summary, .past-format summary { min-height: 44px; align-content: center; }
  .paperNumbers { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); }
  .paperNumbers button { min-height: 44px; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 16px; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, .ac-shell button { min-height: 44px; }
  textarea { max-width: 100%; }
  dialog { max-height: min(78dvh, 640px); }
  #matches .rowlink { min-height: 48px; }
}

@media screen and (max-width: 355px) {
  .mobile-quick a { gap: 4px; font-size: 13px; }
  .mobile-quick svg { flex-basis: 16px; width: 16px; }
  .readActions { grid-template-columns: 1fr; }
  .past-tabs a { font-size: 13px; }
}
@media screen and (max-height: 480px) and (orientation: landscape) and (pointer: coarse) {
  :root { --mobile-bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
  #mobileNav { min-height: var(--mobile-bottom); padding-top: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  #mobileNav a { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 47px; }
}
@media print {
  #mobileNav, .mobile-quick, .mobile-brand, .mobile-select { display: none !important; }
}
