@media (max-width: 760px) {
  :root { --header-h: 58px; }
  .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; }
  .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; }

  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; height: var(--bottomnav-h);
    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);
  }
  .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) + 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); }
  .search { max-width: none; }
  #search-input { height: 40px; padding-left: 38px; }
}

@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;
  }
}
