/* Jesma Novels — Upgraded Prototype Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,500;1,600&display=swap');

:root {
  --green: #0f2a24;
  --green2: #17483a;
  --green3: #1f5c4a;
  --gold: #d6ad61;
  --gold-soft: #e8c98a;
  --cream: #f5f0e6;
  --paper: #fffdf8;
  --ink: #1f2420;
  --muted: #6b6e64;
  --line: #e6e0d4;
  --rose: #8a4e4a;
  --shadow: 0 18px 50px rgba(15, 42, 36, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 68px;
  --top-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
}

[data-theme="dark"] {
  --cream: #121816;
  --paper: #1a221e;
  --ink: #e8e6df;
  --muted: #9a9e94;
  --line: #2a342f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --green: #0c1f1a;
  --green2: #14352b;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(214, 173, 97, 0.45);
  outline-offset: 2px;
}
.hidden { display: none !important; }

/* Splash */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(165deg, #0c1f1a 0%, #17483a 55%, #1f5c4a 100%);
  color: #f5f0e6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.splash.leaving { opacity: 0; transform: scale(1.03); pointer-events: none; }
.splash-mark {
  width: 92px; height: 92px; border: 1px solid rgba(214,173,97,0.45);
  border-radius: 50%; display: grid; place-items: center; position: relative; margin-bottom: 24px;
}
.mark-book { font: 600 54px var(--font-serif); color: var(--gold); line-height: 1; }
.mark-leaf { position: absolute; top: 8px; right: 14px; color: var(--gold-soft); font-size: 14px; }
.splash-title { font: 600 28px var(--font-serif); letter-spacing: 0.12em; }
.splash-title span { color: var(--gold); }
.splash-tagline { margin: 10px 0 28px; font-size: 12px; letter-spacing: 0.22em; opacity: 0.75; }
.splash-loader { width: 48px; height: 2px; background: rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden; margin-bottom: 28px; }
.splash-loader i { display: block; height: 100%; width: 40%; background: var(--gold); animation: load 1.1s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.splash-enter {
  background: var(--gold); color: #1a1810; font-weight: 600; padding: 14px 28px;
  border-radius: 999px; letter-spacing: 0.02em; transition: transform 0.2s, box-shadow 0.2s;
}
.splash-enter:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(214,173,97,0.35); }
.splash-enter span { margin-left: 6px; }
.splash-demo { margin-top: 22px; font-size: 11px; opacity: 0.5; letter-spacing: 0.06em; }

.startup-error {
  position: fixed; inset: 0; z-index: 1100; background: #1a1810; color: #f5f0e6;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center;
}
.startup-error button { margin-top: 16px; background: var(--gold); color: #1a1810; padding: 12px 24px; border-radius: 999px; font-weight: 600; }

/* App shell */
.app-shell {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: color-mix(in srgb, var(--cream) 92%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.04em; }
.brand-symbol {
  width: 32px; height: 32px; border-radius: 10px; background: var(--green2); color: var(--gold);
  display: grid; place-items: center; font: 600 16px var(--font-serif);
}
.brand small { display: block; font-size: 9px; letter-spacing: 0.18em; opacity: 0.6; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.connection-pill {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px;
}
.connection-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); display: inline-block; }
.icon-button {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink); font-size: 16px;
}
.avatar-button {
  width: 38px; height: 38px; border-radius: 50%; background: var(--green2); color: var(--gold);
  font-weight: 600; font-size: 14px; display: grid; place-items: center;
}

/* Views */
.view { display: none; padding: 8px 16px 32px; animation: fadeIn 0.35s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.eyebrow {
  display: block; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 6px;
}
.eyebrow.gold { color: var(--gold); }
h1 { font: 600 32px/1.15 var(--font-serif); margin: 0 0 10px; }
h1 em { font-style: italic; color: var(--green3); }
[data-theme="dark"] h1 em { color: var(--gold-soft); }
h2 { font: 600 22px/1.25 var(--font-serif); margin: 0; }
h3 { font: 600 17px var(--font-serif); margin: 0 0 6px; }
p { margin: 0; color: var(--muted); }

/* Hero */
.hero {
  display: grid; gap: 20px; margin: 12px 0 28px;
  background: linear-gradient(145deg, var(--green) 0%, var(--green2) 100%);
  color: #f5f0e6; border-radius: 24px; padding: 28px 22px; position: relative; overflow: hidden;
}
.hero p { color: rgba(245,240,230,0.78); }
.hero-copy { position: relative; z-index: 2; max-width: 340px; }
.hero h1 { color: #fff; font-size: 30px; }
.hero h1 em { color: var(--gold); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.hero-art { position: absolute; right: -10px; bottom: -20px; width: 160px; height: 160px; opacity: 0.9; }
.sun { position: absolute; top: 18px; right: 28px; width: 36px; height: 36px; border-radius: 50%; background: var(--gold); opacity: 0.85; }
.art-hill { position: absolute; bottom: 0; border-radius: 50% 50% 0 0; background: rgba(255,255,255,0.06); }
.hill-one { width: 120px; height: 50px; right: 10px; }
.hill-two { width: 90px; height: 36px; right: 60px; }
.book-illustration {
  position: absolute; right: 24px; bottom: 28px; width: 78px; height: 100px;
  background: #f5f0e6; color: var(--green); border-radius: 4px 8px 8px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 600 9px/1.25 var(--font-serif); text-align: center; box-shadow: 4px 6px 0 rgba(0,0,0,0.15);
}
.book-spine { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--gold); border-radius: 4px 0 0 4px; }
.book-illustration small { font-size: 7px; letter-spacing: 0.08em; margin-top: 6px; opacity: 0.7; }
.art-star { position: absolute; top: 50px; right: 110px; color: var(--gold); font-size: 14px; }

/* Buttons */
.primary-button {
  background: var(--gold); color: #1a1810; font-weight: 600; padding: 13px 20px;
  border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(214,173,97,0.3); }
.primary-button.small { padding: 9px 14px; font-size: 13px; }
.gold-button {
  background: linear-gradient(135deg, #d6ad61, #c49a4a); color: #1a1810; font-weight: 600;
  padding: 12px 18px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
}
.outline-button {
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 11px 16px; border-radius: 999px; font-weight: 500;
}
.light-button {
  background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.25);
  padding: 12px 18px; border-radius: 999px; font-weight: 500; backdrop-filter: blur(4px);
}
.text-button { color: var(--green3); font-weight: 600; padding: 8px 4px; }
[data-theme="dark"] .text-button { color: var(--gold-soft); }
.text-button.danger { color: var(--rose); }
.subtle-link { color: var(--muted); font-size: 13px; font-weight: 500; }

/* Premium banner */
.premium-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  background: linear-gradient(120deg, #1a2e28, #243d35); color: #f5f0e6;
  border: 1px solid rgba(214,173,97,0.35); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 28px;
}
.premium-banner p { color: rgba(245,240,230,0.7); font-size: 13px; margin-top: 4px; }
.premium-banner.hidden, .premium-banner.is-member { display: none; }

/* Sections */
.section-heading {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin: 8px 0 14px;
}
.section-heading.compact-heading { margin-top: 28px; }
.genre-strip {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 24px;
  scrollbar-width: none;
}
.genre-strip::-webkit-scrollbar { display: none; }
.genre-strip button {
  flex: 0 0 auto; background: var(--paper); border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.genre-strip button:hover, .genre-strip button.active {
  background: var(--green2); color: #f5f0e6; border-color: var(--green2);
}
.callout {
  background: var(--green2); color: #f5f0e6; border-radius: var(--radius);
  padding: 22px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 16px; margin: 8px 0 28px;
}
.callout p { color: rgba(245,240,230,0.75); margin-top: 6px; max-width: 320px; }

/* Book grid & cards */
.book-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 8px;
}
@media (min-width: 520px) { .book-grid { grid-template-columns: repeat(3, 1fr); } }
.book-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden; cursor: pointer; transition: transform 0.18s, box-shadow 0.18s;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.book-card h3 { font: 600 14px/1.3 var(--font-serif); margin: 10px 12px 2px; }
.book-card .byline { font-size: 12px; color: var(--muted); margin: 0 12px 8px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 12px; }
.tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: color-mix(in srgb, var(--green2) 12%, transparent); color: var(--green3);
  padding: 3px 8px; border-radius: 6px;
}
[data-theme="dark"] .tag { background: rgba(214,173,97,0.12); color: var(--gold-soft); }
.like-mini { font-size: 12px; color: var(--muted); }
.like-mini.liked { color: var(--rose); }
.premium-tag {
  position: absolute; top: 8px; right: 8px; background: var(--gold); color: #1a1810;
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em; padding: 3px 7px; border-radius: 6px;
}
.cover {
  position: relative; isolation: isolate; overflow: hidden;
  aspect-ratio: 3/4; padding: 14px; display: flex; flex-direction: column;
  justify-content: space-between; border-radius: 16px 16px 0 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.13);
}
.cover::before {
  content: ""; position: absolute; z-index: -1; width: 76%; aspect-ratio: 1;
  right: -19%; top: 19%; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.32);
  box-shadow: 0 0 0 13px rgba(255,255,255,.055), 0 0 0 29px rgba(255,255,255,.045),
              0 0 0 48px rgba(255,255,255,.035);
}
.cover::after {
  content: "✦"; position: absolute; z-index: -1; right: 16%; top: 39%;
  color: rgba(255,255,255,.42); font-size: clamp(36px, 8vw, 58px);
  font-family: Georgia, serif; transform: rotate(12deg);
}
.cover strong { max-width: 92%; text-shadow: 0 2px 12px rgba(0,0,0,.16); }
.cover-kicker, .cover-author, .cover-footer { text-shadow: 0 1px 8px rgba(0,0,0,.16); }
.cover-kicker { font-size: 9px; letter-spacing: 0.1em; opacity: 0.8; }
.cover strong { font: 600 15px/1.25 var(--font-serif); margin: 8px 0; }
.cover-author { font-size: 11px; opacity: 0.85; }
.cover-mark { position: absolute; bottom: 36px; right: 12px; opacity: 0.35; font-size: 18px; }
.cover-footer { font-size: 8px; letter-spacing: 0.12em; opacity: 0.55; }
.progress-mini {
  height: 3px; background: rgba(0,0,0,0.12); border-radius: 2px; margin: 0 12px 8px; overflow: hidden;
}
.progress-mini i { display: block; height: 100%; background: var(--gold); border-radius: 2px; }

/* Recent list */
.recent-list { display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  display: flex; align-items: center; gap: 14px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer;
}
.recent-item .mini-cover {
  width: 48px; height: 64px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font: 600 12px var(--font-serif); color: #f5f0e6;
}
.recent-item strong { display: block; font-size: 14px; }
.recent-item span { font-size: 12px; color: var(--muted); }
.recent-item button { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--green3); white-space: nowrap; }

/* Discover */
.page-intro { margin: 12px 0 20px; }
.page-intro p { margin-top: 8px; max-width: 420px; }
.search-row {
  display: flex; align-items: center; gap: 10px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; margin-bottom: 14px;
}
.search-row span { color: var(--muted); font-size: 18px; }
.search-row input {
  flex: 1; border: none; background: transparent; padding: 14px 0; outline: none;
}
.search-row button { color: var(--muted); font-size: 20px; padding: 4px; }
.filter-chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chips button {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; font-size: 13px;
  background: var(--paper); border: 1px solid var(--line); white-space: nowrap;
}
.filter-chips button.active {
  background: var(--green2); color: #f5f0e6; border-color: var(--green2);
}
.results-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--muted); margin-bottom: 14px;
}
.results-meta select {
  border: 1px solid var(--line); background: var(--paper); border-radius: 10px;
  padding: 6px 10px; font-size: 13px;
}

/* Library */
.library-tabs {
  display: flex; gap: 6px; margin-bottom: 16px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 14px; padding: 4px;
}
.library-tabs button {
  flex: 1; padding: 10px 8px; border-radius: 11px; font-size: 13px; font-weight: 500;
  color: var(--muted); transition: background 0.15s, color 0.15s;
}
.library-tabs button.active { background: var(--green2); color: #f5f0e6; }
.library-tabs span {
  display: inline-block; min-width: 18px; text-align: center; font-size: 11px;
  background: rgba(0,0,0,0.08); border-radius: 6px; padding: 1px 5px; margin-left: 4px;
}
.library-tabs button.active span { background: rgba(255,255,255,0.2); }

.empty-state {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty-state span { font-size: 36px; display: block; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }
.empty-state .primary-button { margin-top: 18px; }

/* Community */
.community-compose {
  display: flex; align-items: center; gap: 12px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 16px;
}
.mini-avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--green2); color: var(--gold);
  display: grid; place-items: center; font-weight: 600; flex-shrink: 0;
}
.community-compose p { font-size: 13px; }
.community-tabs {
  display: flex; gap: 6px; margin-bottom: 16px;
}
.community-tabs button {
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  background: var(--paper); border: 1px solid var(--line); color: var(--muted);
}
.community-tabs button.active { background: var(--green2); color: #f5f0e6; border-color: var(--green2); }
.feed { display: flex; flex-direction: column; gap: 12px; }
.feed-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
}
.feed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.feed-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--green3); color: #f5f0e6;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.feed-head strong { display: block; font-size: 14px; }
.feed-head small { font-size: 11px; color: var(--muted); }
.feed-card > p { color: var(--ink); font-size: 14px; line-height: 1.55; margin-bottom: 12px; }
.feed-actions { display: flex; gap: 12px; }
.feed-actions button { font-size: 13px; color: var(--muted); font-weight: 500; }
.feed-actions button.liked { color: var(--rose); }
.comment-item {
  margin-top: 10px; padding: 10px 12px; background: color-mix(in srgb, var(--cream) 70%, transparent);
  border-radius: 10px; font-size: 13px;
}
.comment-item strong { margin-right: 6px; }

/* Author Studio */
.studio-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px;
}
.stat-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; text-align: center;
}
.stat-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; letter-spacing: 0.04em; }
.stat-card strong { font: 600 20px var(--font-serif); }
.gold-stat { border-color: rgba(214,173,97,0.4); background: linear-gradient(160deg, var(--paper), color-mix(in srgb, var(--gold) 8%, var(--paper))); }
.studio-layout { display: grid; gap: 18px; }
@media (min-width: 720px) { .studio-layout { grid-template-columns: 1.4fr 1fr; } }
.editor-card, .side-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.editor-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.draft-indicator {
  font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.draft-indicator i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 14px; }
label input, label textarea, label select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--cream);
}
label textarea { resize: vertical; min-height: 80px; }
.form-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; font-weight: 400; }
.editor-options { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; margin: 0; }
.check-label input { width: auto; margin: 0; }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.drafts-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.draft-item {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.draft-item button { font-size: 12px; color: var(--green3); font-weight: 600; }
.side-note { font-size: 13px; color: var(--muted); margin-top: 10px; }

/* Profile */
.profile-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px;
}
.profile-header { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--green2); color: var(--gold);
  display: grid; place-items: center; font: 600 24px var(--font-serif); flex-shrink: 0;
}
.profile-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.badge {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 20%, transparent); color: #8a6a2a;
}
.badge.soft { background: var(--line); color: var(--muted); }
.profile-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  text-align: center; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.profile-stats strong { display: block; font: 600 18px var(--font-serif); }
.profile-stats span { font-size: 11px; color: var(--muted); }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.profile-section { margin-bottom: 18px; }
.activity-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.activity-item { font-size: 13px; color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--line); }
.activity-item strong { color: var(--ink); }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); display: flex; align-items: stretch;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10px; font-weight: 500; color: var(--muted); transition: color 0.15s;
}
.nav-item.active { color: var(--green3); }
[data-theme="dark"] .nav-item.active { color: var(--gold); }
.nav-icon { font-size: 18px; line-height: 1; }

/* Modals */
.modal {
  position: fixed; inset: 0; z-index: 200; background: rgba(10, 18, 15, 0.55);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  animation: fadeIn 0.25s ease;
}
@media (min-width: 560px) {
  .modal { align-items: center; padding: 24px; }
}
.modal-card {
  background: var(--paper); width: 100%; max-width: 440px; max-height: 90dvh;
  overflow-y: auto; border-radius: 24px 24px 0 0; padding: 24px; position: relative;
  animation: slideUp 0.3s ease;
}
@media (min-width: 560px) { .modal-card { border-radius: 24px; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px;
  border-radius: 50%; background: var(--cream); font-size: 20px; display: grid; place-items: center;
}

/* Reader */
.reader-modal {
  align-items: flex-start;
  background: var(--cream);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.reader-shell {
  width: 100%; max-width: 680px; margin: 0 auto; background: var(--paper);
  min-height: 100dvh; display: flex; flex-direction: column;
}
.reader-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.reader-meta { flex: 1; min-width: 0; }
.reader-meta strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-meta span { font-size: 12px; color: var(--muted); }
.reader-actions { display: flex; gap: 4px; }
.gold-icon { color: var(--gold) !important; }
.reader-progress { height: 3px; background: var(--line); }
#readerProgressBar { height: 100%; width: 0%; background: var(--gold); transition: width 0.15s; }
.reader-controls {
  display: flex; align-items: center; gap: 6px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.chip-btn {
  padding: 6px 10px; border-radius: 8px; font-size: 13px; background: var(--cream);
  border: 1px solid var(--line);
}
.chip-btn.active { background: var(--green2); color: #f5f0e6; border-color: var(--green2); }
#fontFamily {
  margin-left: auto; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; background: var(--cream); font-size: 12px;
}
.reader-body {
  padding: 28px 20px 40px; font-size: 18px; line-height: 1.75; max-width: 42em; margin: 0 auto;
  font-family: var(--font-serif); white-space: pre-wrap;
}
.reader-body.theme-sepia { background: #f4ecd8; color: #3d3426; }
.reader-body.theme-dark { background: #1a1f1c; color: #e0ddd4; }
.reader-body.font-sans { font-family: var(--font-sans); }
.reader-body.font-mono { font-family: ui-monospace, monospace; font-size: 16px; }
.reader-chapters {
  padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap;
}
.reader-chapters button {
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  background: var(--cream); border: 1px solid var(--line);
}
.reader-chapters button.active { background: var(--green2); color: #f5f0e6; }
.premium-gate {
  position: absolute; inset: 0; background: color-mix(in srgb, var(--cream) 92%, transparent);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 5; padding: 24px;
}
.gate-card {
  background: var(--paper); border: 1px solid rgba(214,173,97,0.4); border-radius: 20px;
  padding: 28px; max-width: 340px; text-align: center; box-shadow: var(--shadow);
}
.gate-card p { margin: 10px 0 20px; font-size: 14px; }
.gate-card .gold-button { width: 100%; justify-content: center; margin-bottom: 10px; }
.reader-comments {
  padding: 20px; border-top: 1px solid var(--line); max-width: 42em; margin: 0 auto; width: 100%;
}
.reader-comments h3 { margin-bottom: 12px; }
#commentsList { margin-bottom: 14px; }
.comment-form { display: flex; gap: 10px; align-items: flex-end; }
.comment-form textarea {
  flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: var(--cream); resize: none;
}
.reader-footer-actions {
  display: flex; gap: 10px; padding: 16px 20px 28px; justify-content: center; flex-wrap: wrap;
  border-top: 1px solid var(--line);
}

/* Toast */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%) translateY(20px); background: var(--green); color: #f5f0e6;
  padding: 12px 20px; border-radius: 999px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 300;
  max-width: 90%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Premium modal content helpers */
.premium-plan {
  border: 1.5px solid var(--line); border-radius: 16px; padding: 18px; margin: 12px 0;
  transition: border-color 0.15s;
}
.premium-plan.selected, .premium-plan:hover { border-color: var(--gold); }
.premium-plan h3 { margin-bottom: 4px; }
.premium-plan .price { font: 600 24px var(--font-serif); color: var(--green3); margin: 8px 0; }
[data-theme="dark"] .premium-plan .price { color: var(--gold); }
.premium-plan ul { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.premium-plan ul li { margin-bottom: 4px; }
.demo-note {
  font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--gold) 10%, transparent);
  border-radius: 10px; padding: 10px 12px; margin-top: 14px;
}

/* Utility */
.gold { color: var(--gold); }
