/* =========================================================
   LUMEN — Cinematic Premium UI
   Presentation only. Class names stay JS-compatible.
   ========================================================= */

:root {
  --bg: #07080B;
  --bg2: #0D0F14;
  --panel: #12151C;
  --elevated: #171A22;
  --ink: #F5F5F7;
  --text2: #B0B5BF;
  --muted: #9CA3AF;
  --line: rgba(255, 255, 255, 0.07);
  --line2: rgba(255, 255, 255, 0.12);
  --primary: #7C3AED;
  --primary-hover: #8B5CF6;
  --primary2: #A855F7;
  --primary-soft: rgba(139, 92, 246, 0.15);
  --radius: 16px;
  --radius-sm: 12px;
  --header-h: 60px;
  --sidebar-w: 220px;
  --bottom-h: 62px;
  --max: 1200px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --touch: 44px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary2); text-decoration: none; }

/* ---- Shell ---- */
.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w) 1fr;
  }
}

.content-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---- Sidebar (desktop) ---- */
.sidebar {
  display: none;
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 18px 14px;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  flex-direction: column;
  gap: 18px;
  z-index: 30;
}
@media (min-width: 1024px) {
  .sidebar { display: flex; }
}

.sidebar-brand { justify-content: flex-start; min-height: auto; }
.side-nav { display: grid; gap: 4px; flex: 1; }
.side-sep { height: 1px; background: var(--line); margin: 8px 4px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}
.side-link:hover { background: rgba(255,255,255,0.04); color: var(--ink); }
.side-link.is-active {
  background: var(--primary-soft);
  color: #E9D5FF;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.25);
}
.side-ico { width: 1.25rem; text-align: center; opacity: 0.9; }
.side-docs { margin-top: auto; font-size: 12px; color: var(--muted); }

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(7, 8, 11, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  width: min(100%, var(--max));
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "brand search"
    "tabs tabs";
  gap: 10px;
  align-items: center;
}
@media (min-width: 900px) {
  .header-inner {
    grid-template-columns: auto 1fr;
    grid-template-areas: "brand search";
    padding: 12px 20px;
  }
  .header-inner .tabs { display: none; }
  .header-brand { display: none; }
}
@media (min-width: 1024px) {
  .header-brand { display: none !important; }
}

.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 0;
  min-height: var(--touch);
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #7C3AED, #A855F7);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}
.brand-name { font-weight: 800; letter-spacing: -0.02em; }
@media (max-width: 360px) { .brand-name { display: none; } }

.search { grid-area: search; position: relative; min-width: 0; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 14px 0 42px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.tabs {
  grid-area: tabs;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-color: transparent;
}

/* ---- Main ---- */
.main {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 14px 14px calc(var(--bottom-h) + 20px);
  flex: 1;
}
@media (min-width: 1024px) {
  .main { padding: 22px 22px 40px; }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.page-title {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.page-sub, .page-meta {
  margin: 4px 0 0;
  color: var(--text2);
  font-size: 13px;
}

/* ---- Buttons ---- */
.btn {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}
.btn:hover { border-color: var(--line2); }
.btn-ghost { background: transparent; }
.btn-primary {
  border: 0;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: #fff;
  box-shadow: 0 10px 24px rgba(139, 92, 246, 0.28);
}
.back-btn { margin-bottom: 12px; position: relative; z-index: 2; }

/* ---- Hero ---- */
.home-hero {
  position: relative;
  min-height: 220px;
  margin-bottom: 18px;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}
@media (min-width: 768px) { .home-hero { min-height: 320px; } }
.home-hero.is-hidden { display: none; }
.home-hero-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center top;
  transform: scale(1.04);
  filter: saturate(1.05);
}
.home-hero-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(7,8,11,0.92) 0%, rgba(7,8,11,0.72) 42%, rgba(7,8,11,0.25) 100%),
    linear-gradient(180deg, rgba(7,8,11,0.15) 0%, rgba(7,8,11,0.85) 100%);
}
.home-hero-body {
  position: relative;
  z-index: 1;
  max-width: 520px;
  padding: 22px 18px;
  display: grid;
  gap: 10px;
}
@media (min-width: 768px) { .home-hero-body { padding: 36px 32px; gap: 12px; } }
.home-hero-kicker {
  font-size: 11px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary2);
}
.home-hero-title {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.home-hero-meta {
  color: var(--text2);
  font-size: 13px;
  font-weight: 650;
}
.home-hero-syn {
  margin: 0;
  color: #c7cbd4;
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ---- Continue ---- */
.continue-banner { margin-bottom: 16px; }
.continue-banner.is-hidden { display: none; }
.continue-card {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(139, 92, 246, 0.22);
  background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(18,21,28,0.9));
}
.continue-cover {
  width: 64px; height: 90px;
  border-radius: 10px;
  object-fit: cover;
  background: #1a1d27;
}
.continue-label {
  font-size: 11px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary2);
}
.continue-title { font-weight: 800; font-size: 15px; margin-top: 2px; }
.continue-meta { color: var(--text2); font-size: 12px; margin-top: 2px; }
.continue-go { color: var(--primary2); font-weight: 800; white-space: nowrap; }

/* ---- Grid / cards ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.card {
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}
.card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.28);
  box-shadow: 0 14px 30px rgba(0,0,0,0.28), 0 0 0 1px rgba(139,92,246,0.08);
}
.card-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: #151822;
}
.card-body {
  padding: 10px 11px 12px;
  display: grid;
  gap: 6px;
  min-width: 0;
}
.card-title {
  font-weight: 750;
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text2);
  font-size: 10px;
  font-weight: 700;
  text-transform: capitalize;
}
.badge--hot { color: #fecaca; border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.1); }
.badge--up { color: #bbf7d0; border-color: rgba(34,197,94,.28); background: rgba(34,197,94,.1); }
.card-chapters {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}
.card-chapters .new { color: #fbbf24; font-weight: 800; }

/* ---- Series cinematic ---- */
.series-stage { position: relative; isolation: isolate; }
.series-backdrop {
  position: absolute;
  inset: -20px -20px auto -20px;
  height: 280px;
  background-size: cover;
  background-position: center top;
  filter: blur(28px) saturate(1.1);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}
.series-backdrop::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(7,8,11,0.2), var(--bg) 90%);
}
@media (min-width: 768px) {
  .series-backdrop { height: 360px; filter: blur(36px); }
}

.series-hero { position: relative; z-index: 1; margin-bottom: 18px; }
.series-hero-inner {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(13, 15, 20, 0.72);
  backdrop-filter: blur(10px);
}
@media (min-width: 640px) {
  .series-hero-inner {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 20px;
    padding: 18px;
  }
}
.series-hero .series-cover {
  width: 120px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 16px 36px rgba(0,0,0,0.45);
}
@media (min-width: 640px) {
  .series-hero .series-cover { width: 190px; }
}
.series-hero-body { min-width: 0; display: grid; gap: 10px; align-content: start; }
.series-title, .series-hero h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3.5vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
}
.series-meta { color: var(--text2); font-size: 13px; font-weight: 650; }
.series-synopsis {
  max-height: 180px;
  overflow: auto;
  color: #c9ced8;
  font-size: 13px;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}
.series-hero-body .btn { justify-self: start; }

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 12px;
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.seg {
  display: inline-flex; gap: 4px; padding: 3px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(0,0,0,.25);
}
.seg-btn {
  min-height: 30px; padding: 4px 10px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 11px; font-weight: 700;
}
.seg-btn.is-active { background: var(--primary-soft); color: #E9D5FF; }

.chapter-list, #chapter-list {
  display: grid; gap: 8px; position: relative; z-index: 1;
}
.ch-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 48px; padding: 11px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(18, 21, 28, 0.85); color: inherit; text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.ch-item:hover {
  border-color: rgba(139,92,246,.3);
  background: rgba(139,92,246,.08);
}
.ch-item .num { font-weight: 800; font-size: 13px; }
.ch-item .time { color: var(--muted); font-size: 11px; font-weight: 600; }

/* Filters */
.filter-bar, .filters {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 34px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.03);
  color: var(--text2); font-size: 12px; font-weight: 700;
}
.chip.is-active {
  color: #fff; background: var(--primary-soft);
  border-color: rgba(139,92,246,.4);
}
.filter-group--genres {
  display: flex; flex-wrap: nowrap; gap: .4rem;
  overflow-x: auto; max-width: 100%;
  padding-bottom: .25rem; -webkit-overflow-scrolling: touch;
}
.filter-group--genres .chip { flex: 0 0 auto; }

.pager {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: center;
  margin-top: 18px;
}
.pager-info { color: var(--text2); font-size: 13px; font-weight: 700; }

/* Bottom nav mobile */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: var(--bottom-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(7, 8, 11, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}
.bottom-link {
  border: 0; background: transparent;
  color: var(--muted);
  display: grid; place-items: center; gap: 2px;
  font-size: 10px; font-weight: 700;
  min-height: var(--touch);
}
.bottom-link span:first-child { font-size: 16px; line-height: 1; }
.bottom-link.is-active { color: #E9D5FF; }

/* Hide chrome in reader */
body:has(#view-reader:not(.is-hidden)) .bottom-nav,
body:has(#view-reader.is-active) .bottom-nav { display: none; }

/* ---- Reader mode: hide site chrome ---- */
body.mode-reader .header,
body.mode-reader #header,
.header.is-hidden,
#header.is-hidden {
  display: none !important;
}
body.mode-reader .sidebar,
body.mode-reader #sidebar {
  display: none !important;
}
body.mode-reader .bottom-nav,
body.mode-reader #bottom-nav {
  display: none !important;
}
body.mode-reader .content-shell {
  min-height: 100dvh;
}
body.mode-reader .main {
  padding: 0 !important;
  max-width: none !important;
  width: 100% !important;
}
body.mode-reader .app-shell {
  grid-template-columns: 1fr !important;
}
body.mode-reader {
  background: #000;
  overflow-x: hidden;
}

/* States */
.state-detail, .empty-state {
  padding: 28px 16px; text-align: center; color: var(--text2);
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
}

/* Skeleton */
.sk {
  background: linear-gradient(90deg, #141821 25%, #1c2230 50%, #141821 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.card-skeleton { pointer-events: none; }
.sk-cover { width: 100%; aspect-ratio: 2/3; border-radius: 0; }
.sk-line { height: 12px; margin: 8px 10px; }
.sk-line-short { width: 55%; }
.sk-line-mid { width: 75%; }
.sk-cover-lg { width: 120px; height: 170px; border-radius: 12px; }
.series-skeleton {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 12px 0;
}

.offline-bar {
  position: sticky; top: var(--header-h); z-index: 35;
  padding: 8px 12px; text-align: center;
  font-size: 12px; font-weight: 700;
  background: rgba(239,68,68,.14); color: #fecaca;
  border-bottom: 1px solid rgba(239,68,68,.25);
}
.offline-bar.is-hidden { display: none; }

.toast, #toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom-h) + 12px);
  transform: translateX(-50%);
  z-index: 80; max-width: 92vw;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(18,21,28,.96); border: 1px solid var(--line2);
  box-shadow: var(--shadow); font-size: 13px; font-weight: 650;
}
@media (min-width: 1024px) {
  .toast, #toast { bottom: 20px; }
}
.toast.is-hidden, #toast.is-hidden { display: none; }

.overlay, #loading {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  background: rgba(7,8,11,.45);
}
.overlay.is-hidden, #loading.is-hidden { display: none; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--primary2);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.view { display: none; }
.view.is-active, .view:not(.is-hidden) { display: block; }
/* prefer is-hidden pattern used by app */
.view.is-hidden { display: none !important; }

.data-badge {
  display: inline-flex; margin-top: 6px; padding: 2px 8px;
  border-radius: 999px; font-size: 10px; font-weight: 700;
}
.data-badge.is-hidden { display: none; }
.data-badge--db { background: rgba(56,189,248,.15); color: #7dd3fc; }
.data-badge--live { background: rgba(34,197,94,.15); color: #86efac; }
.data-badge--fresh { background: rgba(245,158,11,.15); color: #fcd34d; }

@media (max-width: 360px) {
  .main { padding-left: 10px; padding-right: 10px; }
  .home-hero-body { padding: 16px 14px; }
}

/* =========================================================
   MOBILE HOMEPAGE POLISH (≤900px)
   ========================================================= */

html, body {
  max-width: 100%;
  overflow-x: clip;
}

.search-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  place-items: center;
}
.search-close {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.home-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 12px;
}
.home-list-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.btn-filter {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--elevated);
  font-weight: 700;
  font-size: 13px;
}
.btn-icon {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
}
.pager--compact {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  margin: 0;
}
.pager--compact .pager-info {
  min-width: 3.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Filter bottom sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}
.sheet-backdrop.is-hidden,
.sheet.is-hidden { display: none !important; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  max-height: min(82dvh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.4);
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: sheetUp 0.22s ease-out;
}
@keyframes sheetUp {
  from { transform: translateY(12%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  margin: 10px auto 0;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}
.sheet-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}
.sheet-body {
  overflow: auto;
  padding: 4px 16px 16px;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.sheet-section { margin-bottom: 16px; }
.sheet-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.sheet-foot {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: rgba(13, 15, 20, 0.96);
}
.filter-group--genres-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 899px) {
  .header-inner {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "brand spacer searchbtn"
      "tabs tabs tabs"
      "search search search";
    gap: 8px;
    padding: 10px 12px;
  }
  .header-brand { display: inline-flex !important; }
  .search-toggle {
    display: grid;
    grid-area: searchbtn;
    justify-self: end;
  }
  .header-inner::after {
    content: "";
    grid-area: spacer;
  }
  .search {
    grid-area: search;
    display: none;
  }
  .header.is-search-open .search {
    display: block;
  }
  .header.is-search-open .search-close {
    display: grid;
    place-items: center;
  }
  .header.is-search-open .search input {
    padding-right: 40px;
  }
  .header.is-search-open .search-toggle {
    visibility: hidden;
  }

  .tabs {
    grid-area: tabs;
    display: flex !important;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding-bottom: 2px;
    margin: 0 -2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    min-height: 40px;
    padding: 8px 14px;
  }

  /* Hero — never clip */
  .home-hero {
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: 20px;
    margin-bottom: 16px;
    overflow: hidden;
  }
  .home-hero-bg {
    position: absolute;
    inset: 0;
    background-position: center top;
    background-size: cover;
    transform: none;
  }
  .home-hero-shade {
    background:
      linear-gradient(180deg, rgba(7,8,11,0.15) 0%, rgba(7,8,11,0.55) 40%, rgba(7,8,11,0.94) 100%);
  }
  .home-hero-body {
    max-width: none;
    padding: 72px 16px 16px;
    gap: 8px;
  }
  .home-hero-title {
    font-size: clamp(1.25rem, 6vw, 1.65rem);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .home-hero-syn {
    -webkit-line-clamp: 2;
    font-size: 12.5px;
  }
  .home-hero-actions {
    margin-top: 6px;
  }
  .home-hero-actions .btn {
    min-height: 44px;
    border-radius: 12px;
  }

  /* Continue early & compact */
  .continue-banner { margin-bottom: 16px; }
  .continue-card {
    grid-template-columns: 56px 1fr auto;
    padding: 10px;
    gap: 10px;
  }
  .continue-cover {
    width: 56px;
    height: 78px;
  }
  .continue-title { font-size: 14px; }

  /* Hide bulky desktop filters on mobile */
  .filter-bar--desktop { display: none !important; }

  /* 2-col grid only */
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }
  .card-body { padding: 8px 9px 10px; }
  .card-title { font-size: 12.5px; }
  .card-chapters { font-size: 10.5px; }

  .main {
    padding: 12px 12px calc(var(--bottom-h) + 18px + env(safe-area-inset-bottom, 0px));
  }

  .bottom-nav {
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .bottom-link {
    font-size: 9.5px;
    gap: 1px;
  }
  .bottom-link span:first-child {
    font-size: 15px;
  }
}

@media (min-width: 900px) {
  .search-toggle { display: none !important; }
  .search-close { display: none !important; }
  .btn-filter { display: none; }
  .filter-bar--desktop { display: flex; }
  .sheet, .sheet-backdrop { display: none !important; }
}


/* PWA standalone polish */
@media (display-mode: standalone) {
  .header {
    padding-top: env(safe-area-inset-top, 0);
  }
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  body.mode-reader .lumen-reader-header {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }
}


/* === DESIGN POLISH v2 === */
:focus-visible {
  outline: 2px solid #C4B5FD;
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, #7C3AED 0%, #A855F7 100%);
  border: 0;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.36);
}
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  border: 1px solid var(--line2);
  background: rgba(255,255,255,0.03);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
}

/* Cards */
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(167, 139, 250, 0.35);
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}
.card-cover, .card .cover, .card img.cover {
  aspect-ratio: 2 / 3;
  object-fit: cover;
  width: 100%;
  background: var(--elevated);
}
.card-title {
  font-weight: 700;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-chapters, .card-meta {
  color: var(--muted);
  font-size: 12px;
}

/* Hero polish */
.home-hero {
  position: relative;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  isolation: isolate;
}
.home-hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #E9D5FF;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  width: fit-content;
}
.home-hero-title {
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.home-hero-meta {
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
}

/* Section headers */
.page-title {
  letter-spacing: -0.03em;
  font-weight: 800;
}
.page-sub { color: var(--muted); }

/* Chips */
.chip {
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--text2);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  font-size: 12.5px;
  font-weight: 650;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip.is-active {
  background: var(--primary-soft);
  border-color: rgba(167, 139, 250, 0.45);
  color: #E9D5FF;
}

/* Series detail */
.series-hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.series-hero-inner {
  display: grid;
  gap: 16px;
  padding: 16px;
}
@media (min-width: 720px) {
  .series-hero-inner {
    grid-template-columns: 180px 1fr;
    gap: 22px;
    padding: 22px;
  }
}
.series-cover {
  width: 100%;
  max-width: 180px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--elevated);
}
.series-title {
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 8px;
}
.series-synopsis {
  color: #c9ced8;
  font-size: 14px;
  line-height: 1.55;
  max-width: 62ch;
}

/* Chapter list rows */
.chapter-row, .ch-item, .chapter-item {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.chapter-row:hover, .ch-item:hover, .chapter-item:hover {
  border-color: rgba(167, 139, 250, 0.35);
  background: var(--elevated);
}

/* Library empty */
.state-box, .empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  border: 1px dashed var(--line2);
  border-radius: 16px;
  background: rgba(255,255,255,0.02);
}

/* Toast */
.toast {
  border: 1px solid var(--line2);
  background: rgba(17, 19, 28, 0.94);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* Sidebar active */
.side-link.is-active {
  background: var(--primary-soft);
  color: #E9D5FF;
}
.side-docs {
  font-size: 12px;
  opacity: 0.85;
}

/* Bottom nav polish */
.bottom-nav {
  background: rgba(7, 8, 11, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.bottom-link.is-active {
  color: #E9D5FF;
}
.bottom-link.is-active span:first-child {
  text-shadow: 0 0 16px rgba(168, 85, 247, 0.55);
}

/* Loading skeleton */
.sk {
  background: linear-gradient(90deg, var(--elevated) 0%, #1c2030 50%, var(--elevated) 100%);
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes sk {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Desktop content width */
@media (min-width: 1024px) {
  .main {
    max-width: var(--max);
    margin: 0 auto;
    width: 100%;
    padding: 20px 24px 40px;
  }
}

/* Reduce noise on very small phones */
@media (max-width: 360px) {
  .page-title { font-size: 1.15rem; }
  .home-hero-body { padding: 64px 12px 14px; }
}
