:root,
[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elev: #141824;
  --bg-card: #1a1f2e;
  --line: #2a3145;
  --text: #e8ecf7;
  --muted: #9aa3b8;
  --accent: #7c5cff;
  --accent-2: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --topbar-bg: rgba(11, 13, 18, 0.82);
  --footer-bg: rgba(0, 0, 0, 0.2);
  --badge-bg: rgba(124, 92, 255, 0.18);
  --badge-fg: #c4b5fd;
  --badge-bd: rgba(124, 92, 255, 0.35);
  --badge-green-bg: rgba(52, 211, 153, 0.15);
  --badge-green-fg: #6ee7b7;
  --badge-green-bd: rgba(52, 211, 153, 0.35);
  --link-hover: #c4b5fd;
  --reader-fg: #dbe2f3;
  --hero-glow-1: rgba(124, 92, 255, 0.18);
  --hero-glow-2: rgba(52, 211, 153, 0.12);
  --cover-g1: #312e81;
  --cover-g2: #0f172a;
  --brand-mark-fg: #0b0d12;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --line: #d7dde8;
  --text: #1a2233;
  --muted: #5b657a;
  --accent: #5b45e0;
  --accent-2: #059669;
  --danger: #dc2626;
  --shadow: 0 10px 28px rgba(26, 34, 51, 0.08);
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --footer-bg: rgba(255, 255, 255, 0.65);
  --badge-bg: rgba(91, 69, 224, 0.1);
  --badge-fg: #4c3ab8;
  --badge-bd: rgba(91, 69, 224, 0.28);
  --badge-green-bg: rgba(5, 150, 105, 0.1);
  --badge-green-fg: #047857;
  --badge-green-bd: rgba(5, 150, 105, 0.28);
  --link-hover: #5b45e0;
  --reader-fg: #243044;
  --hero-glow-1: rgba(91, 69, 224, 0.12);
  --hero-glow-2: rgba(5, 150, 105, 0.08);
  --cover-g1: #6366f1;
  --cover-g2: #312e81;
  --brand-mark-fg: #ffffff;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--hero-glow-1), transparent 60%),
    radial-gradient(900px 400px at 90% 0%, var(--hero-glow-2), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--link-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  color: var(--brand-mark-fg);
  font-size: 0.85rem;
  font-weight: 800;
  object-fit: cover;
  flex-shrink: 0;
}
img.brand-mark {
  background: transparent;
  padding: 0;
}
.nav-toggle {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  place-items: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 1.05rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
.topbar.is-nav-open .nav-toggle-bars { background: transparent; }
.topbar.is-nav-open .nav-toggle-bars::before { top: 0; transform: rotate(45deg); }
.topbar.is-nav-open .nav-toggle-bars::after { top: 0; transform: rotate(-45deg); }

.nav {
  display: flex;
  gap: 1rem;
  margin-left: 0.5rem;
}
.nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.15rem;
  -webkit-tap-highlight-color: transparent;
}
.nav a:hover, .nav a.active { color: var(--text); }
.search {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
.search input {
  width: min(260px, 42vw);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  min-height: 2.5rem;
}
.search button, .btn {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  min-height: 2.5rem;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn.danger { background: var(--danger); }

.prefs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.prefs select,
.prefs-btn {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}
.prefs select {
  max-width: 9.5rem;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) calc(50% - 2px), calc(100% - 7px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 1.4rem;
}
html[dir="rtl"] .prefs select {
  background-position: 12px calc(50% - 2px), 7px calc(50% - 2px);
  padding-inline-end: 0.7rem;
  padding-inline-start: 1.4rem;
}
.prefs-btn {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1rem;
}
.prefs-btn:hover,
.prefs select:hover {
  border-color: var(--accent);
}

/* Header App download — always visible (desktop + mobile) */
.app-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 2.5rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--badge-bd);
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.app-dl:hover,
.app-dl.active {
  color: var(--text);
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.28), rgba(52, 211, 153, 0.12));
}

/* —— Download stage (tech signal / ink + teal) —— */
.page-download main.container {
  width: min(1120px, calc(100% - 1.25rem));
  padding-top: 0.5rem;
  padding-bottom: 2.5rem;
}
.dl-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(125, 211, 201, 0.14);
  background:
    linear-gradient(165deg, rgba(10, 18, 24, 0.92), rgba(7, 11, 18, 0.96));
  min-height: min(78vh, 720px);
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 4vw, 3.25rem) clamp(1.1rem, 3vw, 2.5rem);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
[data-theme="light"] .dl-stage {
  background:
    linear-gradient(165deg, rgba(246, 250, 252, 0.96), rgba(232, 240, 244, 0.98));
  border-color: rgba(15, 118, 110, 0.16);
  box-shadow: 0 24px 60px rgba(15, 40, 48, 0.08);
}
.dl-atmosphere {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.dl-grid {
  position: absolute;
  inset: -20%;
  background-image:
    linear-gradient(rgba(94, 234, 212, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 234, 212, 0.07) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(700px) rotateX(58deg) scale(1.35);
  transform-origin: center 18%;
  mask-image: radial-gradient(ellipse at center, #000 28%, transparent 72%);
  animation: dl-grid-drift 18s linear infinite;
  opacity: 0.55;
}
[data-theme="light"] .dl-grid {
  background-image:
    linear-gradient(rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px);
  opacity: 0.45;
}
.dl-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
}
.dl-orb-a {
  width: 280px;
  height: 280px;
  left: -60px;
  top: -40px;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.45), transparent 68%);
  animation: dl-orb-float 9s ease-in-out infinite;
}
.dl-orb-b {
  width: 320px;
  height: 320px;
  right: -80px;
  bottom: -70px;
  background: radial-gradient(circle, rgba(232, 168, 124, 0.28), transparent 70%);
  animation: dl-orb-float 11s ease-in-out infinite reverse;
}
.dl-scan {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 1px;
  top: 18%;
  background: linear-gradient(90deg, transparent, rgba(94, 234, 212, 0.55), transparent);
  animation: dl-scan 7.5s ease-in-out infinite;
  opacity: 0.65;
}
.dl-hero {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  text-align: center;
  font-family: "Manrope", var(--font);
  animation: dl-rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.dl-brand {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  margin-bottom: 1.35rem;
}
.dl-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow:
    0 0 0 1px rgba(94, 234, 212, 0.28),
    0 18px 40px rgba(0, 0, 0, 0.35);
}
.dl-brand-name {
  margin: 0;
  font-family: "Syne", "Manrope", sans-serif;
  font-weight: 800;
  font-size: clamp(1.85rem, 5vw, 2.55rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
  background: linear-gradient(120deg, #f4fbf9 10%, #5eead4 48%, #e8a87c 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="light"] .dl-brand-name {
  background: linear-gradient(120deg, #0f172a 8%, #0f766e 52%, #b45309 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.dl-kicker {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #5eead4;
}
[data-theme="light"] .dl-kicker { color: #0f766e; }
.dl-title {
  margin: 0 0 0.75rem;
  font-family: "Syne", "Manrope", sans-serif;
  font-weight: 700;
  font-size: clamp(1.55rem, 4.2vw, 2.15rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}
.dl-lead {
  margin: 0 auto 1.55rem;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}
.dl-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 0.85rem;
}
.dl-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.15rem;
  padding: 0.85rem 1.7rem;
  border-radius: 999px;
  border: 1px solid rgba(94, 234, 212, 0.45);
  background: linear-gradient(135deg, #134e4a, #0f766e 45%, #115e59);
  color: #ecfeff !important;
  font-family: "Syne", "Manrope", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  box-shadow:
    0 14px 36px rgba(15, 118, 110, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.dl-cta:hover {
  transform: translateY(-2px);
  border-color: rgba(153, 246, 228, 0.7);
  color: #fff !important;
  box-shadow:
    0 18px 44px rgba(15, 118, 110, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.dl-cta-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 48%, transparent 66%);
  transform: translateX(-120%);
  animation: dl-shine 4.8s ease-in-out infinite;
}
.dl-cta-label { position: relative; z-index: 1; }
.dl-status {
  margin: 0 0 1.35rem;
  min-height: 1.4em;
  font-size: 0.9rem;
  color: var(--muted);
}
.dl-meta { display: none; }
.dl-features {
  list-style: none;
  margin: 0 0 1.35rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
}
.dl-features li {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(94, 234, 212, 0.2);
  background: rgba(15, 118, 110, 0.12);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}
[data-theme="light"] .dl-features li {
  background: rgba(15, 118, 110, 0.08);
  border-color: rgba(15, 118, 110, 0.18);
}
.dl-notes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: left;
}
.dl-notes li {
  position: relative;
  padding-left: 1.1rem;
}
.dl-notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #5eead4;
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.15);
}
@keyframes dl-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dl-grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 48px, 48px 0; }
}
@keyframes dl-orb-float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(18px, 12px); }
}
@keyframes dl-scan {
  0%, 100% { transform: translateY(0); opacity: 0.2; }
  50% { transform: translateY(220px); opacity: 0.75; }
}
@keyframes dl-shine {
  0%, 55% { transform: translateX(-120%); }
  75%, 100% { transform: translateX(120%); }
}
@media (prefers-reduced-motion: reduce) {
  .dl-grid, .dl-orb, .dl-scan, .dl-cta-glow, .dl-hero { animation: none; }
}

main.container { padding: 1.5rem 0 3rem; }
.loading, .empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.hero-card, .panel, .novel-card, .chapter-row, .reader {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card {
  padding: 1.5rem;
  min-height: 280px;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.25rem;
  align-items: start;
}
.cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  object-fit: cover;
  background: linear-gradient(160deg, var(--cover-g1), var(--cover-g2));
}
.cover-lg { width: 180px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0; }
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-fg);
  border: 1px solid var(--badge-bd);
}
.badge.green {
  background: var(--badge-green-bg);
  color: var(--badge-green-fg);
  border-color: var(--badge-green-bd);
}
.muted { color: var(--muted); }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 1.75rem 0 0.9rem;
}
.section-head h2 { margin: 0; font-size: 1.35rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
}
.novel-card {
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.novel-card:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 92, 255, 0.55);
}
.novel-card .body { padding: 0.85rem; }
.novel-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.meta { font-size: 0.82rem; color: var(--muted); }

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.filters label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.filters select, .filters input, .field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.novel-detail {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
}
.novel-detail h1 { margin: 0 0 0.4rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.chapter-list { margin-top: 1.5rem; }
.chapter-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.55rem;
}
.chapter-row:hover { border-color: rgba(124, 92, 255, 0.45); }

.reader {
  padding: 1.5rem;
  max-width: 820px;
  margin: 0 auto;
}
.reader h1 { margin-top: 0; }
.reader-content {
  font-size: 1.08rem;
  line-height: 1.85;
  white-space: pre-wrap;
  color: var(--reader-fg);
}
.reader-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.genre-card {
  padding: 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.genre-card h3 { margin: 0 0 0.4rem; }
.genre-card .child-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.65rem; }
.genre-card .child-tags a { font-size: 0.82rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.btn.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.cover-lg { width: 200px; }
.empty, .loading {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}
.panel { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); }
.hidden { display: none !important; }

.footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0;
  color: var(--muted);
  background: var(--footer-bg);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* —— Tablet / narrow desktop —— */
@media (max-width: 900px) {
  .container {
    width: min(1180px, calc(100% - 1.25rem));
  }
  .hero, .hero-card, .novel-detail, .filters {
    grid-template-columns: 1fr;
  }
  .hero-card {
    min-height: 0;
    padding: 1.15rem;
  }
  .hero-card .cover,
  .novel-detail .cover-lg {
    width: min(160px, 42vw);
    margin: 0 auto;
  }
  .hero-card {
    justify-items: center;
    text-align: center;
  }
  .hero-card .badge-row,
  .hero-card .actions {
    justify-content: center;
  }
  .novel-detail {
    justify-items: center;
    text-align: center;
    padding: 1.15rem;
  }
  .novel-detail .actions { justify-content: center; }
  .novel-detail h1 { font-size: 1.45rem; line-height: 1.25; }

  .nav-toggle { display: grid; order: 2; }
  .app-dl {
    order: 3;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    min-height: 2.5rem;
  }
  .prefs { order: 4; }
  .nav {
    display: none;
    order: 5;
    width: 100%;
    margin: 0;
    padding: 0.35rem 0 0.55rem;
    gap: 0.35rem;
    flex-direction: column;
    border-top: 1px solid var(--line);
  }
  .topbar.is-nav-open .nav { display: flex; }
  .nav a {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.55rem 0.85rem;
    border-radius: 12px;
    background: var(--bg-elev);
    border: 1px solid transparent;
    justify-content: flex-start;
  }
  .nav a.active,
  .nav a:hover {
    border-color: var(--badge-bd);
    background: var(--badge-bg);
    color: var(--text);
  }
  .topbar-inner {
    flex-wrap: wrap;
    padding: 0.55rem 0;
    gap: 0.65rem;
    min-height: 0;
  }
  .brand { max-width: calc(100% - 9.5rem); }
  .brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .search {
    width: 100%;
    margin-left: 0;
    order: 6;
  }
  .search input { flex: 1; width: auto; min-width: 0; }
  .filters {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    padding: 0.85rem;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }
  .genre-grid {
    grid-template-columns: 1fr;
  }
  .section-head {
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    align-items: center;
  }
  .section-head h2 { font-size: 1.2rem; }
  .chapter-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.95rem 1rem;
    min-height: 3rem;
  }
  .reader {
    padding: 1.1rem;
    border-radius: 12px;
  }
  .reader h1 { font-size: 1.25rem; line-height: 1.3; }
  .reader-content {
    font-size: 1.05rem;
    line-height: 1.8;
  }
  .reader-nav {
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    bottom: env(safe-area-inset-bottom);
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding: 0.65rem 0 calc(0.35rem + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, var(--bg-card) 28%);
  }
  .reader-nav .btn,
  .reader-nav .btn.secondary {
    flex: 1 1 42%;
    min-height: 2.75rem;
  }
  .footer {
    padding: 1.5rem 0 calc(1.5rem + env(safe-area-inset-bottom));
  }
  .footer-inner { flex-direction: column; }
  main.container { padding: 1rem 0 2.25rem; }
}

/* —— Phone —— */
@media (max-width: 640px) {
  .container {
    width: calc(100% - 1rem);
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .brand-text { font-size: 0.95rem; }
  .filters {
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
  .novel-card .body { padding: 0.65rem; }
  .novel-card h3 {
    font-size: 0.9rem;
    min-height: 2.4em;
  }
  .hero-card .cover,
  .novel-detail .cover-lg {
    width: min(148px, 48vw);
  }
  .prefs select { max-width: 7.5rem; font-size: 0.78rem; }
  .search button { padding-inline: 0.85rem; }
  .app-dl {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    max-width: 6.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .dl-stage { border-radius: 20px; min-height: auto; }
  .dl-cta { width: 100%; }
  .dl-brand-name { font-size: 1.7rem; }
  .dl-title { font-size: 1.4rem; }
  .reader-content {
    font-size: 1.06rem;
    line-height: 1.82;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .actions .btn,
  .actions .btn.secondary {
    width: 100%;
  }
}

/* —— Very small / landscape phones —— */
@media (max-width: 380px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .brand-text { max-width: 7.5rem; }
  .prefs select { max-width: 6.2rem; }
}

@media (hover: none) and (pointer: coarse) {
  .novel-card:hover { transform: none; }
  a, button { -webkit-tap-highlight-color: transparent; }
}
