@media (max-width: 760px) {
  /* The desktop cap (95vw) left a dead strip down both sides of a phone screen, and the
     full-bleed heroes stopped short of the edges because of it. */
  :root { --header-h: 58px; --maxw: 100%; }
  .top-nav { display: none; }
  .search { margin: 0; }
  /* Sidebar → hidden on mobile; the bottom tab bar takes over. Brand returns to the header. */
  .sidebar { display: none; }
  .main-col { margin-left: 0; }
  .app-shell { --rail: 0px; }
  .brand-mobile { display: flex; align-items: center; }
  .brand-mobile .brand-name { display: inline; }
  /* Room for the fixed bottom nav (incl. notch safe-area) so nothing hides behind it.
     The padding lives on .app (the content container) — body is height-capped, so
     padding there would not extend the scrollable area. */
  body { padding-bottom: 0; }

  /* The safe-area padding is ADDED to the bar's height. It used to come out of it, so
     on an iPhone with a home indicator the icons were squeezed into ~28px. */
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
    background: rgba(12,12,20,0.94); backdrop-filter: blur(14px); border-top: 1px solid var(--border-soft);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  }
  .bottomnav a, .bottomnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; color: var(--faint); font-size: 11px; font-weight: 600;
    transition: color 0.18s, transform 0.18s var(--ease), background 0.18s;
  }
  .bottomnav svg { width: 24px; height: 24px; }
  .bottomnav a:hover, .bottomnav button:hover { transform: translateY(-2px); }
  .bottomnav .active { color: #fff; background: rgba(139,92,246,0.14); }
  /* read2gether — highlighted so it stands apart from the grey items */
  .bottomnav .r2g-bottom { color: #a78bfa; }
  .bottomnav .r2g-bottom span { font-size: 9.5px; white-space: nowrap; }
  .bottomnav .r2g-bottom:hover { transform: none; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; }
  .series-top { gap: 14px; }
  .toast { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 14px); }
  /* The watch page has no bottom bar of its own to clear. */
  body.watching .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); }

  /* iOS zooms the whole page into any field whose text is under 16px the moment it is
     tapped — and does not zoom back out. Every input gets 16px on phones. */
  input, select, textarea, .field, .comment-input, .ep-search-input, .pv-ep-search,
  .cselect-search, .filter-select, .season-select, #search-input { font-size: 16px; }

  /* Button rows wrap instead of running off the right edge (the Owner's three rank
     buttons, "Save" + its message, …). */
  .field-row { flex-wrap: wrap; }
  .field-row .inline-msg { flex: 1 1 100%; }

  /* Popups: dvh follows the phone's collapsing address bar, so the bottom of a picker
     is never hidden underneath it. */
  .modal { max-height: 92vh; max-height: 92dvh; width: 100%; }
  .modal-overlay { padding: 10px; }
  .modal-head { padding: 14px 16px; }
  .modal-scroll, .avatar-body { padding-left: 14px; padding-right: 14px; }
  .picker-search { padding: 10px 14px; }
  .auth-overlay { padding: 24px 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .auth-card { padding: 26px 20px; }

  .settings-card { padding: 18px 16px; }
  .banner-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .comment { padding: 11px 12px; gap: 10px; }
  .social-body { padding: 14px; }
  .series-actions { width: 100%; }
  .series-actions .btn-primary { flex: 1; }
  .app { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 28px); }

  /* Reader on small screens: tighter bars, bigger touch targets */
  .reader-bar.top { padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; }
  .reader-tools { gap: 4px; }
  .rtool, .reader-back { width: 38px; height: 38px; }
  .reader-nav { gap: 8px; }
  .reader-nav .btn { padding: 10px 12px; }
  .reader-slider { height: 8px; }
  .reader-slider::-webkit-slider-thumb { width: 22px; height: 22px; }
  .rt-chapter { font-size: 14px; }
  .modal { max-height: 92vh; }
  .chapter-row { align-items: flex-start; }
  .chapter-row .ch-date { margin-left: auto; white-space: nowrap; }

  /* Chapter toolbar: sort + filter share the full row, filter grows to fit */
  .chapters-head { gap: 10px; }
  .chapters-tools { width: 100%; }
  .ch-search { flex: 1; min-width: 0; }
  .ch-search input { width: auto; flex: 1; min-width: 0; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .search { max-width: none; }
  #search-input { height: 40px; padding-left: 38px; }
  .card-title { font-size: 12.5px; }
  .card-score { top: 6px; right: 6px; padding: 2px 5px; font-size: 10px; }
  .card-badge { top: 6px; left: 6px; padding: 2px 7px; font-size: 10px; }
}
/* The smallest phones (iPhone SE, older Androids): two columns keep covers legible. */
@media (max-width: 340px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .bottomnav a, .bottomnav button { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Phone: the catalogue filters are the main way to browse here, and at 35px tall they
   were a fiddly target. (This lives in responsive.css on purpose — home.css declares
   .filter-select *after* its own media block, so an override there never applied.) */
@media (max-width: 700px) {
  .filter-select { padding: 12px 34px 12px 15px; font-size: 14px; flex: 1 1 46%; }
  .filter-bar { gap: 8px; }
}
@media (max-width: 720px) {
  .ep-mark { width: 34px; height: 34px; padding: 8px; }
}
