/* ════════════════════════════════════════════════════════
   ANTI-DOOMSCROLL — Complete Styles
   ════════════════════════════════════════════════════════ */

/* ─── Theme Variables ─── */
:root, [data-theme="midnight"] {
  --bg: #0a0a14;
  --bg2: #111122;
  --bg3: #1a1a2e;
  --surface: #16162a;
  --surface2: #1e1e36;
  --text: #e8e8f0;
  --text2: #9898b0;
  --text3: #6868a0;
  --accent: #7c5cfc;
  --accent2: #5c3cfc;
  --accent-glow: rgba(124, 92, 252, 0.25);
  --border: #2a2a44;
  --shadow: rgba(0,0,0,0.5);
  --hero-from: rgba(124,92,252,0.15);
  --hero-to: rgba(10,10,20,0);
  --card-bg: #1a1a32;
  --card-hover: #222244;
  --scrollbar: #2a2a44;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #eab308;
  --reader-width: min(720px, 100%);
}

[data-theme="sepia"] {
  --bg: #f4e8c7;
  --bg2: #ece0b8;
  --bg3: #e4d4a8;
  --surface: #f0e4c0;
  --surface2: #e8d8b0;
  --text: #3a2a1a;
  --text2: #6a5a4a;
  --text3: #9a8a7a;
  --accent: #b8860b;
  --accent2: #8b6508;
  --accent-glow: rgba(184, 134, 11, 0.2);
  --border: #d4c4a0;
  --shadow: rgba(0,0,0,0.1);
  --hero-from: rgba(184,134,11,0.12);
  --hero-to: rgba(244,232,199,0);
  --card-bg: #e8dcb8;
  --card-hover: #e0d0a8;
  --scrollbar: #c4b490;
}

[data-theme="pureblack"] {
  --bg: #000000;
  --bg2: #050505;
  --bg3: #0a0a0a;
  --surface: #080808;
  --surface2: #111111;
  --text: #d0d0d0;
  --text2: #707070;
  --text3: #404040;
  --accent: #7c5cfc;
  --accent2: #5c3cfc;
  --accent-glow: rgba(124, 92, 252, 0.15);
  --border: #1a1a1a;
  --shadow: rgba(0,0,0,0.8);
  --hero-from: rgba(124,92,252,0.08);
  --hero-to: rgba(0,0,0,0);
  --card-bg: #060606;
  --card-hover: #0c0c0c;
  --scrollbar: #1a1a1a;
}

[data-theme="warmpaper"] {
  --bg: #faf6ee;
  --bg2: #f0ece0;
  --bg3: #e8e0d0;
  --surface: #f4f0e4;
  --surface2: #ece4d4;
  --text: #2c2416;
  --text2: #6a5a4a;
  --text3: #a09080;
  --accent: #c0392b;
  --accent2: #962d22;
  --accent-glow: rgba(192, 57, 43, 0.15);
  --border: #d8ccb8;
  --shadow: rgba(0,0,0,0.06);
  --hero-from: rgba(192,57,43,0.1);
  --hero-to: rgba(250,246,238,0);
  --card-bg: #ece4d4;
  --card-hover: #e4d8c4;
  --scrollbar: #c8bca8;
}

/* ─── Reader Font Variables ─── */
[data-reader-font="sans"]    { --reader-font: 'Inter', system-ui, sans-serif; }
[data-reader-font="serif"]   { --reader-font: 'Lora', Georgia, serif; }
[data-reader-font="playfair"]{ --reader-font: 'Playfair Display', Georgia, serif; }

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--reader-font, 'Inter', system-ui, sans-serif);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.4s, color 0.4s;
}
::-webkit-scrollbar { width: 4px; background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::selection { background: var(--accent-glow); color: var(--text); }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; font-size: inherit; }
input { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ─── View System ─── */
.view { display: none; height: 100dvh; width: 100%; overflow: hidden; position: fixed; top: 0; left: 0; }
.view.active { display: flex; flex-direction: column; }
.home-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }

/* ─── Typography ─── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; }
p { line-height: 1.7; }

/* ════════════════════════════════════════════════════════
   HERO SECTION
════════════════════════════════════════════════════════ */
.hero {
  position: relative;
  padding: 48px 20px 40px;
  text-align: center;
  overflow: hidden;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-bg {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--hero-from) 0%, var(--hero-to) 100%);
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 500px; }
.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #e8e8f0 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  letter-spacing: -1px;
}
[data-theme="sepia"] .hero-title,
[data-theme="warmpaper"] .hero-title {
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 50%, var(--text) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-sub { color: var(--text2); font-size: 0.95rem; margin-bottom: 20px; line-height: 1.5; }
.hero-sub strong { color: var(--text); }

.hero-stats { display: flex; justify-content: center; gap: 24px; margin-bottom: 24px; }
.hero-stat { display: flex; flex-direction: column; align-items: center; }
.hero-stat-num { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.hero-stat-lbl { font-size: 0.7rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }

.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 12px;
  font-size: 0.9rem; font-weight: 600; transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: white; box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 30px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--card-hover); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }

/* ─── Section ─── */
.section { padding: 0 16px; margin-bottom: 28px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 1.1rem; font-weight: 700; }
.section-link { font-size: 0.8rem; color: var(--accent); cursor: pointer; }

/* ════════════════════════════════════════════════════════
   STREAK BAR
════════════════════════════════════════════════════════ */
.streak-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; margin: 0 16px 16px;
  background: var(--surface); border-radius: 14px; border: 1px solid var(--border);
}
.streak-fire { font-size: 1.2rem; }
.streak-info { display: flex; align-items: baseline; gap: 4px; }
.streak-count { font-size: 1.1rem; font-weight: 700; color: var(--warning); }
.streak-lbl { font-size: 0.75rem; color: var(--text2); }
.streak-divider { width: 1px; height: 24px; background: var(--border); }
.streak-xp { display: flex; align-items: baseline; gap: 4px; }
.xp-amount { font-size: 1rem; font-weight: 600; color: var(--accent); }
.xp-lbl { font-size: 0.75rem; color: var(--text2); }
.streak-level { flex-shrink: 0; }
.level-badge { font-size: 0.75rem; color: var(--text2); }
.streak-spacer { flex: 1; }
.streak-btn { font-size: 1.1rem; padding: 4px; opacity: 0.6; }
.streak-btn:hover { opacity: 1; }

/* ─── Search ─── */
.search-section { padding: 0 16px; margin-bottom: 20px; }
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0 12px; transition: border-color 0.2s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { font-size: 0.9rem; opacity: 0.5; flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none; color: var(--text);
  padding: 12px 0; font-size: 0.95rem;
}
.search-input::placeholder { color: var(--text3); }
.search-clear { display: none; font-size: 1rem; opacity: 0.5; padding: 4px; }
.search-wrap.has-value .search-clear { display: block; }
.search-clear:hover { opacity: 1; }

/* ════════════════════════════════════════════════════════
   FEATURED CARD
════════════════════════════════════════════════════════ */
.featured-card {
  display: flex; gap: 14px; padding: 14px; border-radius: 14px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
}
.featured-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.featured-cover {
  width: 80px; height: 120px; border-radius: 8px; flex-shrink: 0;
  background: var(--bg3); overflow: hidden; position: relative;
}
.featured-cover img { width: 100%; height: 100%; object-fit: cover; }
.featured-cover-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
}
.featured-info { flex: 1; min-width: 0; }
.featured-badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--accent-glow); color: var(--accent); font-size: 0.65rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.featured-title { font-size: 1rem; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.featured-author { font-size: 0.8rem; color: var(--text2); margin-bottom: 6px; }
.featured-desc { font-size: 0.78rem; color: var(--text2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.featured-meta { display: flex; gap: 6px; font-size: 0.7rem; color: var(--text3); margin-top: 4px; align-items: center; }

/* ─── Continue Reading ─── */
.continue-card {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.continue-card:hover { border-color: var(--accent); }
.continue-cover {
  width: 44px; height: 66px; border-radius: 6px; flex-shrink: 0; overflow: hidden;
  background: var(--bg3);
}
.continue-cover img { width: 100%; height: 100%; object-fit: cover; }
.continue-info { flex: 1; min-width: 0; }
.continue-label { font-size: 0.65rem; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.continue-title { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-sub { font-size: 0.75rem; color: var(--text2); }
.continue-progress { height: 3px; background: var(--bg3); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.continue-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }
.continue-arrow { font-size: 1.2rem; color: var(--text3); }

/* ════════════════════════════════════════════════════════
   TRENDING SCROLL
════════════════════════════════════════════════════════ */
.trending-scroll {
  display: flex; gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory; padding-bottom: 4px;
}
.trending-scroll::-webkit-scrollbar { height: 2px; }
.trending-card {
  flex-shrink: 0; width: 140px; border-radius: 12px; padding: 10px;
  background: var(--surface); border: 1px solid var(--border);
  scroll-snap-align: start; cursor: pointer; transition: all 0.2s;
}
.trending-card:hover { border-color: var(--accent); }
.trending-cover { width: 100%; aspect-ratio: 2/3; border-radius: 6px; margin-bottom: 8px; overflow: hidden; background: var(--bg3); }
.trending-cover img { width: 100%; height: 100%; object-fit: cover; }
.trending-cover-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.trending-card-title { font-size: 0.78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trending-card-author { font-size: 0.68rem; color: var(--text3); }

/* ════════════════════════════════════════════════════════
   COMMUNITY QUOTES
════════════════════════════════════════════════════════ */
.quote-featured {
  padding: 16px; border-radius: 14px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.2s; margin-bottom: 12px;
}
.quote-featured:hover { border-color: var(--accent); }
.quote-featured-text {
  font-size: 1.05rem; line-height: 1.7; font-style: italic;
  font-family: var(--reader-font, 'Lora', serif);
  color: var(--text); margin-bottom: 10px;
}
.quote-featured-text::before { content: '\201C'; font-size: 2rem; color: var(--accent); opacity: 0.4; line-height: 0; vertical-align: -0.4em; margin-right: 2px; }
.quote-featured-footer {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.8rem; color: var(--text2);
}
.quote-featured-source { flex: 1; }
.quote-featured-likes { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--text2); }
.quote-heart { cursor: pointer; transition: transform 0.15s; font-size: 1.1rem; }
.quote-heart:hover { transform: scale(1.2); }
.quote-heart.liked { animation: heartPop 0.3s ease; }
@keyframes heartPop { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }

.quote-comments { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.quote-comments-list { max-height: 120px; overflow-y: auto; margin-bottom: 8px; }
.quote-comment-item {
  display: flex; gap: 8px; align-items: flex-start; padding: 6px 0;
  font-size: 0.8rem; border-bottom: 1px solid var(--border);
  animation: fadeUp 0.2s both;
}
.quote-comment-item:last-child { border-bottom: none; }
.quote-comment-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
}
.quote-comment-body { flex: 1; min-width: 0; }
.quote-comment-name { font-weight: 600; font-size: 0.72rem; }
.quote-comment-text { font-size: 0.78rem; color: var(--text2); font-style: normal; word-wrap: break-word; }
.quote-comment-time { font-size: 0.6rem; color: var(--text3); margin-left: 4px; }

.quote-add-comment { display: flex; gap: 6px; }
.quote-comment-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 0.78rem;
  color: var(--text); outline: none; transition: border-color 0.2s;
}
.quote-comment-input:focus { border-color: var(--accent); }
.quote-comment-input::placeholder { color: var(--text3); }
.quote-comment-send {
  padding: 8px 14px; border-radius: 8px; background: var(--accent);
  color: white; font-size: 0.75rem; font-weight: 600;
  transition: opacity 0.2s; opacity: 0.7;
}
.quote-comment-send:hover { opacity: 1; }
.quote-comment-send:disabled { opacity: 0.3; cursor: default; }

.quote-scroll {
  display: flex; gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory; padding-bottom: 4px;
}
.quote-scroll::-webkit-scrollbar { height: 2px; }
.quote-card {
  flex-shrink: 0; width: 200px; border-radius: 12px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border);
  scroll-snap-align: start; cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column;
}
.quote-card:hover { border-color: var(--accent); }
.quote-card-text {
  font-size: 0.82rem; line-height: 1.5; font-style: italic;
  font-family: var(--reader-font, 'Lora', serif);
  flex: 1; margin-bottom: 8px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.quote-card-footer { display: flex; align-items: center; gap: 8px; font-size: 0.7rem; color: var(--text3); }
.quote-card-source { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote-card-likes { display: flex; align-items: center; gap: 2px; }

@media (max-width: 480px) {
  .quote-featured-text { font-size: 0.95rem; }
  .quote-card { width: 170px; }
}

/* ════════════════════════════════════════════════════════
   BOOK GRID
════════════════════════════════════════════════════════ */
.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.book-card {
  border-radius: 12px; padding: 10px; background: var(--card-bg);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
  animation: fadeUp 0.3s both;
}
.book-card:hover { background: var(--card-hover); border-color: var(--accent); transform: translateY(-2px); }
.book-card:active { transform: translateY(0); }
.book-cover-wrap {
  width: 100%; aspect-ratio: 2/3; border-radius: 6px; overflow: hidden;
  background: var(--bg3); margin-bottom: 8px; position: relative;
}
.book-cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.book-card h3 { font-size: 0.82rem; font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.book-card .author { font-size: 0.7rem; color: var(--text2); margin-bottom: 6px; }
.book-card .subjects { font-size: 0.65rem; color: var(--text3); margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.book-card .meta { display: flex; gap: 8px; font-size: 0.65rem; color: var(--text3); }
.resume-badge { font-size: 0.6rem; background: var(--accent); color: white; padding: 1px 6px; border-radius: 4px; font-weight: 600; }

/* ─── Error Banner ─── */
.error-banner { display: none; padding: 10px 14px; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: 10px; font-size: 0.85rem; color: var(--danger); margin-bottom: 12px; }
.error-banner.visible { display: block; }

/* ─── Grid Footer ─── */
.grid-footer { text-align: center; padding: 16px; }
.load-more-btn {
  padding: 10px 24px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); font-size: 0.85rem;
  font-weight: 500; transition: all 0.2s;
}
.load-more-btn:hover { border-color: var(--accent); background: var(--card-hover); }

/* ─── Skeleton ─── */
.skeleton-card { border-radius: 12px; padding: 10px; background: var(--card-bg); border: 1px solid var(--border); }
.skeleton-cover { width: 100%; aspect-ratio: 2/3; border-radius: 6px; background: var(--bg3); margin-bottom: 8px; animation: shimmer 1.5s infinite; }
.skeleton-line { height: 10px; border-radius: 4px; background: var(--bg3); margin-bottom: 6px; animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0% { opacity: 0.5; } 50% { opacity: 0.8; } 100% { opacity: 0.5; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Grid Empty ─── */
.grid-empty { text-align: center; padding: 40px 20px; grid-column: 1 / -1; }
.grid-empty .icon { font-size: 2rem; display: block; margin-bottom: 12px; }
.grid-empty p { font-size: 0.9rem; color: var(--text2); }

/* ════════════════════════════════════════════════════════
   READER — TOP BAR
════════════════════════════════════════════════════════ */
.reader-topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
.topbar-btn { font-size: 1.2rem; padding: 6px 8px; border-radius: 8px; transition: background 0.2s; }
.topbar-btn:hover { background: var(--surface); }
.topbar-info { flex: 1; min-width: 0; }
.topbar-title { font-size: 0.83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-chapter { font-size: 0.7rem; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Progress Bar ─── */
.reader-progress-wrap {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px;
  flex-shrink: 0; background: var(--bg);
}
.reader-progress-track { flex: 1; height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.reader-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }
.reader-progress-text { font-size: 0.65rem; color: var(--text3); min-width: 30px; text-align: right; }

/* ════════════════════════════════════════════════════════
   READER — LAYOUT SYSTEM
════════════════════════════════════════════════════════ */
.reader-layout { display: none; flex: 1; overflow: hidden; position: relative; }
.reader-layout.active { display: flex; }

/* ─── TikTok Layout ─── */
.tiktok-feed {
  flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}
.ttk-chunk {
  height: 100dvh; scroll-snap-align: start; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: center;
  padding: 56px 20px 80px; position: relative;
  animation: ttkFadeIn 0.4s ease;
}
@keyframes ttkFadeIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
.ttk-chapter-label {
  position: absolute; top: 20px; left: 20px; right: 20px;
  font-size: 0.7rem; color: var(--text3); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 600;
}
.ttk-content {
  font-size: calc(var(--reader-font-size, 1rem) * 1.05);
  line-height: var(--line-spacing, 1.8);
  color: var(--text);
  max-width: var(--reader-width);
  margin: 0 auto;
  width: 100%;
}
.ttk-content p { margin-bottom: 12px; }
.ttk-progress {
  position: fixed; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; z-index: 5; margin-top: -20px;
}
.ttk-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--border);
  transition: all 0.2s;
}
.ttk-dot.active { width: 8px; height: 8px; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }

/* ─── Instagram Layout ─── */
.ig-feed {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 12px 80px;
}
.ig-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  margin-bottom: 12px; overflow: hidden; animation: fadeUp 0.3s both;
  transition: all 0.2s;
}
.ig-card-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.ig-card-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.ig-card-user { font-size: 0.8rem; font-weight: 600; flex: 1; min-width: 0; }
.ig-card-user-sub { font-size: 0.65rem; color: var(--text3); }
.ig-card-content { padding: 14px; }
.ig-card-content p { font-size: calc(var(--reader-font-size, 1rem) * 0.95); line-height: var(--line-spacing, 1.7); margin-bottom: 8px; }
.ig-card-footer {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  border-top: 1px solid var(--border); font-size: 0.8rem;
}
.ig-card-actions { display: flex; gap: 14px; }
.ig-card-action { font-size: 0.85rem; cursor: pointer; opacity: 0.6; transition: all 0.15s; display: flex; align-items: center; gap: 4px; }
.ig-card-action:hover { opacity: 1; }
.ig-card-action.liked { opacity: 1; color: var(--danger); }
.ig-card-likes { font-size: 0.8rem; color: var(--text2); margin-left: auto; }

/* Double-tap heart animation */
.ig-heart-burst {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 4rem; pointer-events: none; z-index: 5;
  animation: heartBurst 0.6s ease forwards;
}
@keyframes heartBurst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8) translateY(-30px); }
}

/* ─── Classic Layout ─── */
.classic-feed {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 24px 16px 80px; max-width: min(740px, 100%); margin: 0 auto;
}
.classic-chapter {
  margin-bottom: 32px;
}
.classic-chapter-title {
  font-size: 1.6rem; font-weight: 700; font-family: var(--reader-font);
  text-align: center; margin-bottom: 8px; padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.classic-chapter-number {
  font-size: 0.75rem; color: var(--text3); text-transform: uppercase;
  letter-spacing: 1px; text-align: center; margin-bottom: 4px;
}
.classic-chunk {
  margin-bottom: 24px; line-height: var(--line-spacing, 1.8);
  font-size: calc(var(--reader-font-size, 1rem) * 1.05);
}
.classic-chunk p { margin-bottom: 14px; text-indent: 1.5em; }
.classic-chunk p:first-child { text-indent: 0; }

/* ════════════════════════════════════════════════════════
   READER — BOTTOM BAR
════════════════════════════════════════════════════════ */
.reader-bottombar {
  display: flex; align-items: center; gap: 2px; padding: 4px 8px;
  background: var(--bg); border-top: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
.bottombar-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 10px; border-radius: 8px; font-size: 0.6rem; color: var(--text3);
  transition: all 0.2s; min-width: 0;
}
.bottombar-btn:hover { color: var(--text2); background: var(--surface); }
.bottombar-btn.active { color: var(--accent); }
.bottombar-btn svg { width: 18px; height: 18px; }
.bottombar-spacer { flex: 1; }

/* ════════════════════════════════════════════════════════
   SETTINGS OVERLAY
════════════════════════════════════════════════════════ */
.settings-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; justify-content: flex-end;
  pointer-events: none; opacity: 0;
  transition: opacity 0.3s;
}
.settings-overlay.open { pointer-events: auto; opacity: 1; }
.settings-overlay::before {
  content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.5);
}
.settings-panel {
  position: relative; width: min(340px, 85%); height: 100dvh;
  background: var(--bg2); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.3s ease;
  display: flex; flex-direction: column; overflow: hidden;
}
.settings-overlay.open .settings-panel { transform: translateX(0); }
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.settings-header h3 { font-size: 1rem; }
.settings-close { font-size: 1.2rem; padding: 4px; opacity: 0.6; }
.settings-close:hover { opacity: 1; }
.settings-body { flex: 1; overflow-y: auto; padding: 16px; }
.settings-group { margin-bottom: 20px; }
.settings-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 8px; }

/* ─── Theme Grid ─── */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-btn {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  font-size: 0.78rem; font-weight: 500; transition: all 0.2s; color: var(--text2);
}
.theme-btn:hover { border-color: var(--text3); }
.theme-btn.active { border-color: var(--accent); color: var(--text); background: var(--accent-glow); }
.theme-swatch { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.swatch-midnight { background: #0a0a14; border: 1px solid #2a2a44; }
.swatch-sepia { background: #f4e8c7; border: 1px solid #d4c4a0; }
.swatch-pureblack { background: #000; border: 1px solid #333; }
.swatch-warmpaper { background: #faf6ee; border: 1px solid #d8ccb8; }

/* ─── Font Btns ─── */
.font-btns { display: flex; gap: 8px; }
.font-btn {
  padding: 8px 16px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); font-size: 0.82rem; font-weight: 500;
  transition: all 0.2s; color: var(--text2);
}
.font-btn:hover { border-color: var(--text3); }
.font-btn.active { border-color: var(--accent); color: var(--text); background: var(--accent-glow); }

/* ─── Font Slider ─── */
.font-slider {
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--bg3); border-radius: 2px; outline: none; cursor: pointer;
}
.font-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ─── Focus Btns ─── */
.focus-btns { display: flex; gap: 8px; }
.focus-btn {
  padding: 8px 12px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); font-size: 0.78rem; font-weight: 500;
  transition: all 0.2s; color: var(--text2);
}
.focus-btn:hover { border-color: var(--text3); }

/* ─── Ambient Btns ─── */
.ambient-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ambient-btn {
  padding: 10px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); font-size: 0.82rem; font-weight: 500;
  transition: all 0.2s; color: var(--text2);
}
.ambient-btn:hover { border-color: var(--text3); }
.ambient-btn.active { border-color: var(--accent); color: var(--text); background: var(--accent-glow); }

/* ════════════════════════════════════════════════════════
   MODAL
════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex;
  align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity 0.3s;
}
.modal-overlay.open { pointer-events: auto; opacity: 1; }
.modal-overlay::before {
  content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.6);
}
.modal {
  position: relative; width: min(420px, 92%); max-height: 80dvh;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; transform: scale(0.95); transition: transform 0.3s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-sm { width: min(360px, 92%); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close { font-size: 1.2rem; opacity: 0.6; padding: 4px; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 16px; overflow-y: auto; max-height: calc(80dvh - 56px); }

/* ─── Stats Grid ─── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat-card { text-align: center; padding: 12px; background: var(--surface); border-radius: 12px; border: 1px solid var(--border); }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.65rem; color: var(--text3); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.stats-badges h4 { font-size: 0.9rem; margin-bottom: 10px; }
.badges-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-item {
  padding: 6px 12px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); font-size: 0.8rem; display: flex;
  align-items: center; gap: 6px;
}
.badge-item.locked { opacity: 0.4; }

/* ─── Quote Card (modal) ─── */
.quote-modal-card {
  padding: 20px; border-radius: 12px; background: var(--surface);
  border-left: 4px solid var(--accent); margin-bottom: 12px;
  font-size: 1.05rem; line-height: 1.7; font-family: var(--reader-font);
}
.quote-modal-card .quote-text {
  font-style: italic; margin-bottom: 8px;
}
.quote-modal-card .quote-text::before { content: '\201C'; font-size: 2rem; color: var(--accent); opacity: 0.4; line-height: 0; vertical-align: -0.4em; margin-right: 2px; }
.quote-modal-card .quote-source { font-size: 0.8rem; color: var(--text3); font-style: normal; margin-top: 4px; text-align: right; }
.quote-modal-card .quote-actions-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; margin-top: 8px; border-top: 1px solid var(--border);
  font-size: 0.85rem;
}
.quote-modal-card .quote-like-count { font-size: 0.78rem; color: var(--text2); }
.quote-modal-card .quote-comments-section {
  border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px;
}
.quote-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ════════════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface2); color: var(--text); padding: 10px 20px;
  border-radius: 12px; border: 1px solid var(--border); font-size: 0.85rem;
  z-index: 100; pointer-events: none; opacity: 0;
  transition: all 0.3s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ════════════════════════════════════════════════════════
   OFFLINE BANNER
════════════════════════════════════════════════════════ */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  background: var(--warning); color: #000; text-align: center;
  padding: 6px; font-size: 0.78rem; font-weight: 500;
  transform: translateY(-100%); transition: transform 0.3s;
}
.offline-banner.visible { transform: translateY(0); }

/* ════════════════════════════════════════════════════════
   DAILY GOAL
════════════════════════════════════════════════════════ */
.daily-goal {
  position: fixed; bottom: 60px; right: 12px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 12px;
  transform: translateY(80px); opacity: 0;
  transition: all 0.4s;
}
.daily-goal.visible { transform: translateY(0); opacity: 1; }
.daily-goal-icon { font-size: 1.2rem; }
.daily-goal-info { min-width: 100px; }
.daily-goal-title { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); }
.daily-goal-progress { height: 3px; background: var(--bg3); border-radius: 2px; margin: 4px 0; overflow: hidden; }
.daily-goal-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }
.daily-goal-text { font-size: 0.65rem; color: var(--text3); }

/* ════════════════════════════════════════════════════════
   CHUNK LOADING SPINNER
════════════════════════════════════════════════════════ */
.chunk-loading { text-align: center; padding: 24px; }
.chunk-spinner {
  display: inline-block; width: 24px; height: 24px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── End Screen ─── */
.chunk-end { text-align: center; padding: 40px 20px; }
.chunk-end h2 { font-size: 1.3rem; margin-bottom: 8px; }
.chunk-end p { font-size: 0.9rem; color: var(--text2); margin-bottom: 16px; }
.end-btn { padding: 10px 24px; border-radius: 10px; background: var(--accent); color: white; font-weight: 600; font-size: 0.9rem; }

/* ════════════════════════════════════════════════════════
   THEME-ADAPTIVE OVERRIDES
════════════════════════════════════════════════════════ */
[data-theme="pureblack"] .streak-bar,
[data-theme="pureblack"] .featured-card,
[data-theme="pureblack"] .continue-card,
[data-theme="pureblack"] .ig-card,
[data-theme="pureblack"] .settings-panel,
[data-theme="pureblack"] .modal { border-color: #1a1a1a; }

[data-theme="sepia"] .reader-topbar { border-bottom-color: #d4c4a0; }
[data-theme="sepia"] .reader-bottombar { border-top-color: #d4c4a0; }

[data-theme="warmpaper"] .reader-topbar { border-bottom-color: #d8ccb8; }
[data-theme="warmpaper"] .reader-bottombar { border-top-color: #d8ccb8; }

/* ════════════════════════════════════════════════════════
   FOCUS MODES
════════════════════════════════════════════════════════ */
body.focus-greyscale { filter: grayscale(1) !important; }
body.focus-narrow { --reader-width: min(480px, 100%); }

/* ════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .hero-title { font-size: 1.8rem; }
  .hero { padding: 32px 16px 28px; min-height: auto; }
  .hero-stats { gap: 16px; }
  .hero-stat-num { font-size: 1.1rem; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .settings-panel { width: 100%; }
  .trending-card { width: 120px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .reader-bottombar { padding: 4px 4px; }
  .bottombar-btn { padding: 6px 8px; font-size: 0.55rem; }
  .bottombar-btn svg { width: 16px; height: 16px; }
}

@media (min-width: 768px) {
  .hero-title { font-size: 3.2rem; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .trending-card { width: 150px; }
  .ttk-content { max-width: 600px; }
}

/* ─── Highlight color ─── */
::highlight(selected) { background: var(--accent-glow); }
.highlight-marker { background: var(--accent-glow); cursor: pointer; border-radius: 2px; }

/* ════════════════════════════════════════════════════════
   ANIMATIONS — LAYOUT TRANSITIONS
════════════════════════════════════════════════════════ */
.layout-enter { animation: layoutEnter 0.3s ease; }
@keyframes layoutEnter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ════════════════════════════════════════════════════════
   AMBIENT SOUND INDICATOR
════════════════════════════════════════════════════════ */
.sound-indicator {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 3rem; pointer-events: none; z-index: 40;
  animation: soundFade 1.5s ease forwards;
}
@keyframes soundFade { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2) translateY(-20px); } }

/* ─── Replace Feed Button pulse ─── */
@keyframes pulse-glow { 0%, 100% { box-shadow: 0 0 20px var(--accent-glow); } 50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px var(--accent-glow); } }
.btn-primary { animation: pulse-glow 3s ease infinite; }

/* ════════════════════════════════════════════════════════
   SCROLLBAR HIDE FOR TIKTOK
════════════════════════════════════════════════════════ */
.tiktok-feed::-webkit-scrollbar { width: 0; background: transparent; }

/* ════════════════════════════════════════════════════════
   THEME TRANSITION
════════════════════════════════════════════════════════ */
.theme-transitioning * { transition: background 0.4s, color 0.4s, border-color 0.4s !important; }