/* ═══════════════════════════════════════════════════════════════════════════
   STORY SKELETON — Dark Fantasy Library
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Core palette */
  --deep: #0a0d1a;
  --base: #0f172a;
  --surface: #1e293b;
  --surface-light: #283548;
  --border: rgba(255,255,255,0.06);
  --border-glow: rgba(59,130,246,0.25);

  /* Accents */
  --blue: #3b82f6;
  --blue-dim: #2563eb;
  --blue-glow: rgba(59,130,246,0.12);
  --orange: #f97316;
  --orange-glow: rgba(249,115,22,0.12);
  --purple: #8b5cf6;
  --gold: #d4a842;
  --gold-glow: rgba(212,168,66,0.1);

  /* Text */
  --text: #f1f5f9;
  --text-mid: #94a3b8;
  --text-dim: #64748b;
  --text-faint: #475569;

  /* Type */
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;

  /* Spacing */
  --section-pad: clamp(80px, 10vw, 140px);
}

html {
  font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--deep);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: rgba(59,130,246,0.35); color: #fff; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--deep); }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 3px; }

a { color: var(--blue); text-decoration: none; transition: color 0.2s; }
a:hover { color: #60a5fa; }

img { max-width: 100%; display: block; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: center; }
.text-center { text-align: center; }

/* ─── Nav ──────────────────────────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  padding: 0 24px; height: 64px;
  display: flex; align-items: center;
  background: rgba(10,13,26,0.75);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  transition: all 0.3s;
}
.nav.scrolled { background: rgba(10,13,26,0.92); }
.nav-inner {
  max-width: 1140px; margin: 0 auto; width: 100%;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 600;
  color: var(--text); letter-spacing: 0.01em;
}
.nav-brand img { width: 30px; height: 30px; filter: drop-shadow(0 0 8px rgba(212,168,66,0.3)); }
.nav-center {
  display: flex; align-items: center; gap: 4px;
  position: absolute; left: 50%; transform: translateX(-50%);
}
.nav-link {
  padding: 7px 14px; border-radius: 6px; font-size: 0.8125rem; font-weight: 500;
  color: var(--text-mid); background: none; border: none; cursor: pointer;
  font-family: var(--font-body); transition: all 0.2s; white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-right { display: flex; align-items: center; gap: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: 8px; font-size: 0.875rem; font-weight: 600;
  font-family: var(--font-body); cursor: pointer; transition: all 0.25s;
  border: none; white-space: nowrap; text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--orange) 0%, #ea580c 100%);
  color: #fff; box-shadow: 0 2px 16px rgba(249,115,22,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(249,115,22,0.4); color: #fff; }
.btn-ghost {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  color: var(--text-mid);
}
.btn-ghost:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.12); color: var(--text); }
.btn-blue {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dim) 100%);
  color: #fff; box-shadow: 0 2px 16px rgba(59,130,246,0.3);
}
.btn-blue:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(59,130,246,0.4); color: #fff; }
.btn-lg { padding: 14px 32px; font-size: 1rem; border-radius: 10px; }
.btn-sm { padding: 7px 16px; font-size: 0.8125rem; }
.btn svg, .btn img { flex-shrink: 0; }

/* User pill */
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 14px 3px 3px; border-radius: 100px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer; transition: all 0.2s; font-size: 0.8125rem; color: var(--text-mid);
  font-family: var(--font-body);
}
.user-pill:hover { border-color: var(--border-glow); }
.user-pill img { width: 28px; height: 28px; border-radius: 50%; }
.user-pill .fallback {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.7rem; font-weight: 700;
}

/* User menu */
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 5px; min-width: 170px; z-index: 200;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: fadeScale 0.15s ease-out;
}
.menu-item {
  display: block; width: 100%; padding: 9px 14px; border-radius: 6px;
  font-size: 0.8125rem; color: var(--text-mid); background: none; border: none;
  text-align: left; cursor: pointer; font-family: var(--font-body); transition: all 0.15s;
}
.menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.menu-item.danger { color: #ef4444; }
.menu-item.danger:hover { background: rgba(239,68,68,0.08); }

/* ─── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  min-height: 100vh; display: flex; align-items: center;
  padding: 100px 24px 80px; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 900px 700px at 25% 35%, rgba(59,130,246,0.07), transparent),
    radial-gradient(ellipse 600px 500px at 75% 55%, rgba(139,92,246,0.05), transparent),
    radial-gradient(ellipse 500px 400px at 50% 80%, rgba(249,115,22,0.04), transparent);
}
/* Subtle grid pattern */
.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.03;
  background-image:
    linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 60px 60px;
}
.hero-content { position: relative; z-index: 1; max-width: 1140px; margin: 0 auto; width: 100%; }
.hero-text { max-width: 640px; }

.hero h1 {
  font-family: var(--font-display); font-size: clamp(2.5rem, 5.5vw, 3.75rem);
  font-weight: 700; line-height: 1.12; letter-spacing: -0.02em;
  margin-bottom: 20px;
  animation: fadeUp 0.7s ease-out;
}
.hero h1 .accent {
  background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 60%, var(--orange) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-sub {
  font-size: 1.125rem; color: var(--text-mid); line-height: 1.7; max-width: 520px;
  margin-bottom: 32px;
  animation: fadeUp 0.7s ease-out 0.1s both;
}
.hero-bullets {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 36px;
  animation: fadeUp 0.7s ease-out 0.15s both;
}
.hero-bullet {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.9375rem; color: var(--text-mid);
}
.hero-bullet .dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.hero-bullet:nth-child(1) .dot { background: var(--blue); color: var(--blue); }
.hero-bullet:nth-child(2) .dot { background: var(--purple); color: var(--purple); }
.hero-bullet:nth-child(3) .dot { background: var(--orange); color: var(--orange); }
.hero-bullet:nth-child(4) .dot { background: var(--gold); color: var(--gold); }

.hero-cta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  animation: fadeUp 0.7s ease-out 0.2s both;
}

.hero-visual {
  position: absolute; right: -40px; top: 50%; transform: translateY(-50%);
  width: 480px; opacity: 0.12; pointer-events: none;
  animation: floatSlow 20s ease-in-out infinite;
}

/* ─── Section Common ───────────────────────────────────────────────────────── */
.section { padding: var(--section-pad) 24px; position: relative; }
.section-divider {
  width: 80px; height: 1px; margin: 0 auto 16px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
}
.section-label {
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--blue); text-align: center; margin-bottom: 10px;
}
.section-title {
  font-family: var(--font-display); font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 600; text-align: center; margin-bottom: 16px;
  line-height: 1.25; letter-spacing: -0.01em;
}
.section-desc {
  text-align: center; color: var(--text-mid); max-width: 560px;
  margin: 0 auto 56px; font-size: 0.9375rem; line-height: 1.7;
}

/* ─── Features Grid ────────────────────────────────────────────────────────── */
.features-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  max-width: 1140px; margin: 0 auto;
}
.feature-card {
  padding: 30px 26px; border-radius: 14px;
  background: linear-gradient(145deg, rgba(30,41,59,0.7), rgba(15,23,42,0.9));
  border: 1px solid var(--border);
  transition: all 0.35s; position: relative; overflow: hidden;
}
.feature-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  opacity: 0; transition: opacity 0.35s;
}
.feature-card:hover { border-color: var(--border-glow); transform: translateY(-3px); }
.feature-card:hover::before { opacity: 1; }
.feature-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; font-size: 1.25rem;
}
.feature-icon.blue { background: var(--blue-glow); color: var(--blue); }
.feature-icon.purple { background: rgba(139,92,246,0.1); color: var(--purple); }
.feature-icon.orange { background: var(--orange-glow); color: var(--orange); }
.feature-icon.gold { background: var(--gold-glow); color: var(--gold); }
.feature-card h3 {
  font-family: var(--font-display); font-size: 1.125rem; font-weight: 600;
  margin-bottom: 8px;
}
.feature-card p { font-size: 0.8375rem; color: var(--text-mid); line-height: 1.6; }
.feature-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 0.625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  background: rgba(249,115,22,0.1); color: var(--orange); margin-left: 8px;
  vertical-align: middle;
}

/* ─── Comparison ───────────────────────────────────────────────────────────── */
.comparison-table {
  width: 100%; border-collapse: collapse; margin: 0 auto;
  background: rgba(30,41,59,0.4); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
}
.comparison-table th, .comparison-table td {
  padding: 14px 18px; text-align: center; font-size: 0.8375rem;
  border-bottom: 1px solid var(--border);
}
.comparison-table th {
  background: rgba(15,23,42,0.8); color: var(--text-dim);
  font-weight: 600; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.08em;
}
.comparison-table th:first-child, .comparison-table td:first-child {
  text-align: left; font-weight: 500; color: var(--text);
}
.comparison-table tr:last-child td { border-bottom: none; }
.comparison-table td { color: var(--text-mid); }
.check { color: var(--blue); font-weight: 700; }
.partial { color: var(--text-faint); }
.highlight-col { background: rgba(59,130,246,0.04); }

/* ─── How It Works ─────────────────────────────────────────────────────────── */
.steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
  max-width: 900px; margin: 0 auto;
}
.step {
  text-align: center; padding: 24px 20px; position: relative;
}
.step-num {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  background: var(--blue-glow); color: var(--blue); border: 1px solid rgba(59,130,246,0.2);
}
.step h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 6px; }
.step p { font-size: 0.8125rem; color: var(--text-dim); line-height: 1.55; }

/* ─── CTA Banner ───────────────────────────────────────────────────────────── */
.cta-banner {
  padding: 64px 24px; text-align: center;
  background: linear-gradient(135deg, rgba(59,130,246,0.06), rgba(139,92,246,0.04), rgba(249,115,22,0.03));
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.cta-banner h2 {
  font-family: var(--font-display); font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 600; margin-bottom: 12px;
}
.cta-banner p { color: var(--text-mid); margin-bottom: 28px; font-size: 0.9375rem; }
.cta-buttons { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }

/* ─── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  padding: 40px 24px; text-align: center;
  font-size: 0.75rem; color: var(--text-faint);
  border-top: 1px solid var(--border);
}
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--text); }
.footer-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 12px; }

/* ─── Dashboard ────────────────────────────────────────────────────────────── */
.dashboard { padding: 96px 24px 60px; min-height: 100vh; }
.dash-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.dash-header h1 { font-family: var(--font-display); font-size: 1.75rem; font-weight: 500; }
.dash-header h1 span { color: var(--text-faint); font-weight: 300; }

/* Toolbar: search + view toggle */
.dash-toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.dash-search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px;
  transition: border-color 0.2s;
}
.dash-search:focus-within { border-color: var(--border-glow); }
.dash-search svg { flex-shrink: 0; color: var(--text-faint); }
.dash-search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 0.875rem; font-family: var(--font-body);
}
.dash-search input::placeholder { color: var(--text-faint); }
.dash-controls { display: flex; gap: 2px; }
.dash-view-btn {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); cursor: pointer;
  color: var(--text-faint); transition: all 0.15s;
}
.dash-view-btn:hover { color: var(--text-mid); border-color: rgba(255,255,255,0.1); }
.dash-view-btn.active { color: var(--blue); background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.2); }

/* List view */
.list-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px;
}
.list-card {
  display: flex; align-items: stretch; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  overflow: hidden; cursor: pointer; transition: all 0.2s; position: relative;
}
.list-card:hover { border-color: var(--border-glow); transform: translateY(-2px); }
.list-cover {
  width: 110px; min-height: 140px; object-fit: cover; flex-shrink: 0;
  border-right: 1px solid var(--border);
}
.list-cover-empty {
  width: 110px; min-height: 140px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59,130,246,0.06); border-right: 1px solid var(--border);
  font-family: var(--font-display); font-size: 2rem; color: var(--text-faint); font-weight: 300;
}
.list-info { flex: 1; padding: 16px 18px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.list-info h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.list-stats {
  display: flex; gap: 16px; margin-bottom: 8px;
  font-size: 0.75rem; color: var(--text-faint);
}
.list-stats strong { color: var(--blue); font-weight: 700; margin-right: 3px; }
.list-date { font-size: 0.75rem; color: var(--text-faint); }

/* Covers view */
.covers-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px;
}
.covers-card {
  cursor: pointer; transition: all 0.25s; text-align: center;
}
.covers-card:hover { transform: translateY(-4px); }
.covers-img {
  width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: box-shadow 0.25s;
}
.covers-card:hover .covers-img { box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.covers-placeholder {
  width: 100%; aspect-ratio: 2/3; border-radius: 10px;
  background: linear-gradient(145deg, var(--surface), rgba(59,130,246,0.08));
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 2.5rem; color: var(--text-faint); font-weight: 300;
}
.covers-name {
  margin-top: 8px; font-size: 0.8125rem; font-weight: 500;
  color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.share-tag {
  font-size: 0.625rem; padding: 2px 8px; border-radius: 100px;
  background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.15);
  color: var(--blue); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}

/* ─── Project Detail ───────────────────────────────────────────────────────── */
.project-view { padding: 96px 24px 60px; min-height: 100vh; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.875rem; color: var(--text-dim); margin-bottom: 20px;
  cursor: pointer; transition: color 0.2s;
}
.back-link:hover { color: var(--blue); }
.proj-header { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 36px; }
.proj-header h1 { font-family: var(--font-display); font-size: 1.75rem; font-weight: 500; margin-bottom: 4px; }
.share-controls { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.btn-share { padding: 7px 16px; border-radius: 7px; font-size: 0.8125rem; font-weight: 600; cursor: pointer; font-family: var(--font-body); }
.btn-share-on { background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.2); color: var(--blue); }
.btn-share-off { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.2); color: #ef4444; }
.share-url {
  font-size: 0.75rem; color: var(--text-faint); background: rgba(0,0,0,0.3);
  padding: 5px 10px; border-radius: 5px; font-family: monospace; cursor: pointer;
}
.share-url:hover { color: var(--blue); }

.node-list { display: flex; flex-direction: column; gap: 10px; }
.node-card { border-radius: 10px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.node-card:hover { border-color: rgba(255,255,255,0.08); }
.node-head {
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.node-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1rem; font-weight: 600; }
.node-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.node-count { color: var(--text-faint); font-size: 0.8125rem; font-weight: 400; font-family: var(--font-body); }
.node-toggle { color: var(--text-faint); transition: transform 0.2s; }
.node-toggle.open { transform: rotate(90deg); }
.chapter-list { padding: 0 18px 14px; }
.chapter-item {
  padding: 12px 14px; border-radius: 7px; margin-bottom: 6px;
  background: rgba(0,0,0,0.25); cursor: pointer; transition: background 0.15s;
}
.chapter-item:hover { background: rgba(0,0,0,0.4); }
.chapter-item h4 { font-size: 0.9rem; font-weight: 500; margin-bottom: 2px; }
.chapter-item .preview { font-size: 0.8rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* (Reader is now immersive full-page — see Immersive Reader section) */
/* Sign-in modal reuses reader-overlay */
.reader-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  backdrop-filter: blur(10px); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s;
}
.reader {
  background: var(--base); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 44px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: fadeScale 0.25s ease-out;
}

/* ─── Shared View ──────────────────────────────────────────────────────────── */
.shared-view { padding: 64px 24px; min-height: 100vh; }
.shared-header { text-align: center; margin-bottom: 44px; }
.shared-tag {
  display: inline-block; padding: 4px 14px; border-radius: 100px;
  font-size: 0.625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--blue); border: 1px solid rgba(59,130,246,0.2);
  background: rgba(59,130,246,0.05); margin-bottom: 14px;
}
.shared-header h1 { font-family: var(--font-display); font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 500; }
.shared-header .author { color: var(--text-dim); font-size: 0.9375rem; margin-top: 4px; }

/* ─── Empty / Loading ──────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 80px 24px;
  color: var(--text-faint); font-size: 0.9375rem;
}
.empty p { margin-bottom: 8px; }
.loading-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: var(--text-faint); font-size: 0.875rem;
}
.spinner {
  width: 28px; height: 28px; border: 2px solid var(--border);
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Book covers in project/shared header */
.proj-header { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 36px; }
.proj-covers { display: flex; gap: 10px; flex-shrink: 0; }
.proj-cover-img {
  width: 120px; height: 170px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.proj-info { flex: 1; min-width: 0; }
.shared-covers { justify-content: center; margin-bottom: 16px; }

/* ─── Immersive Reader ─────────────────────────────────────────────────────── */
.ir-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; background: #0a0c14;
  animation: fadeIn 0.25s;
}

/* Sidebar */
.ir-sidebar {
  width: 280px; flex-shrink: 0; display: flex; flex-direction: column;
  background: #0e1220; border-right: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}
.ir-sidebar-head {
  padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
  text-align: center;
}
.ir-sidebar-cover {
  width: 80px; height: 112px; object-fit: cover; border-radius: 6px;
  margin: 0 auto 12px; display: block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.ir-sidebar-title {
  font-family: var(--font-display); font-size: 1rem; font-weight: 600;
  margin-bottom: 2px;
}
.ir-sidebar-meta { font-size: 0.75rem; color: var(--text-faint); }
.ir-toc {
  flex: 1; overflow-y: auto; padding: 8px;
}
.ir-toc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  transition: all 0.15s; margin-bottom: 2px;
}
.ir-toc-item:hover { background: rgba(255,255,255,0.04); }
.ir-toc-item.active { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.15); }
.ir-toc-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.ir-toc-text { display: flex; flex-direction: column; min-width: 0; }
.ir-toc-node { font-size: 0.625rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.ir-toc-ch { font-size: 0.8125rem; color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ir-toc-item.active .ir-toc-ch { color: var(--text); }
.ir-sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); }

/* Main reading area */
.ir-main {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  scroll-behavior: smooth;
}
.ir-topbar {
  position: sticky; top: 0; z-index: 10; padding: 0 24px; height: 48px;
  display: flex; align-items: center; gap: 14px;
  background: rgba(10,12,20,0.85); backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ir-menu-btn {
  display: none; background: none; border: none; color: var(--text-mid);
  font-size: 1.25rem; cursor: pointer; padding: 4px 8px;
}
.ir-topbar-title {
  font-size: 0.8125rem; color: var(--text-faint); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-display);
}
.ir-progress-wrap {
  width: 120px; height: 3px; border-radius: 2px;
  background: rgba(255,255,255,0.06); overflow: hidden; flex-shrink: 0;
}
.ir-progress-bar {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width 0.3s;
}
.ir-close-btn {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 6px; border-radius: 6px; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.ir-close-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }

/* Chapter content */
.ir-content {
  max-width: 680px; margin: 0 auto; width: 100%;
  padding: 48px 32px 80px; flex: 1;
}
.ir-chapter-head { text-align: center; margin-bottom: 48px; padding-bottom: 32px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.ir-chapter-node { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); margin-bottom: 12px; }
.ir-ch-dot { width: 8px; height: 8px; border-radius: 3px; }
.ir-chapter-title { font-family: var(--font-display); font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 500; line-height: 1.3; margin-bottom: 8px; }
.ir-chapter-meta { font-size: 0.8125rem; color: var(--text-faint); }
.ir-chapter-body {
  font-family: var(--font-display); font-size: 1.0625rem; line-height: 2;
  color: rgba(241,245,249,0.82); white-space: pre-wrap; word-wrap: break-word;
}
.ir-chapter-body p { margin-bottom: 1.2em; }
.ir-chapter-body h1, .ir-chapter-body h2, .ir-chapter-body h3 {
  font-weight: 600; margin: 1.5em 0 0.5em; color: var(--text);
}
.ir-chapter-body em { font-style: italic; color: rgba(241,245,249,0.65); }
.ir-chapter-body strong { font-weight: 700; color: var(--text); }
.ir-chapter-body blockquote {
  border-left: 3px solid rgba(59,130,246,0.3); padding-left: 18px;
  margin: 1.5em 0; color: rgba(241,245,249,0.6); font-style: italic;
}

/* Navigation at bottom of chapter */
.ir-chapter-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 40px 0 20px; margin-top: 48px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.ir-end-msg {
  font-family: var(--font-display); font-style: italic;
  color: var(--text-faint); font-size: 0.9375rem;
}

/* Chapter transition */
.ir-content { transition: opacity 0.2s ease; }
.ir-fade-out { opacity: 0; transition: opacity 0.2s ease; }
.ir-fade-in { animation: irFadeIn 0.35s ease-out; }
@keyframes irFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile sidebar backdrop */
.ir-backdrop {
  display: none; position: fixed; inset: 0; z-index: 25;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  animation: fadeIn 0.2s;
}
@media (max-width: 900px) {
  .ir-backdrop { display: block; }
}

/* ─── Animations ───────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeScale { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floatSlow {
  0%, 100% { transform: translateY(-50%) rotate(0deg); }
  50% { transform: translateY(-52%) rotate(2deg); }
}


/* ─── Responsive ───────────────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 900px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: 1fr 1fr; max-width: 600px; }
  .grid-2 { grid-template-columns: 1fr; }
  .nav-center { display: none; }
  .hero-visual { display: none; }
  .hero-text { max-width: 100%; }
  .hero h1 { font-size: clamp(2rem, 5vw, 3rem); }
  .hero-sub { max-width: 100%; }
  .comparison-table { font-size: 0.75rem; }
  .comparison-table th, .comparison-table td { padding: 10px 8px; }

  /* Reader sidebar off-canvas on tablet */
  .ir-sidebar {
    position: fixed; left: -300px; top: 0; bottom: 0; z-index: 20;
    transition: left 0.3s ease; box-shadow: 8px 0 32px rgba(0,0,0,0.5);
  }
  .ir-sidebar.open { left: 0; }
  .ir-menu-btn { display: block; }

  /* Project header stack */
  .proj-header { flex-direction: column; }
  .proj-covers { justify-content: flex-start; }
  .proj-cover-img { width: 100px; height: 140px; }
  .list-grid { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 640px) {
  /* Nav */
  .nav { padding: 0 12px; height: 56px; }
  .nav-brand { font-size: 1rem; gap: 7px; }
  .nav-brand img { width: 22px; height: 22px; }
  .nav-right { gap: 5px; }
  .nav-right .btn-sm { padding: 5px 8px; font-size: 0.7rem; gap: 4px; }
  .nav-right .btn-sm svg { width: 12px; height: 12px; }
  .user-pill { padding: 2px 8px 2px 2px; font-size: 0.7rem; gap: 5px; }
  .user-pill img, .user-pill .fallback { width: 22px; height: 22px; }
  .user-menu { min-width: 140px; right: -4px; }

  /* Hero */
  .hero { min-height: auto; padding: 76px 16px 44px; }
  .hero h1 { font-size: 1.75rem; line-height: 1.2; margin-bottom: 14px; }
  .hero-sub { font-size: 0.875rem; margin-bottom: 20px; line-height: 1.6; }
  .hero-bullets { gap: 7px; margin-bottom: 24px; }
  .hero-bullet { font-size: 0.8125rem; }
  .hero-cta { flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-cta .btn { justify-content: center; }
  .hero-cta .btn-lg { padding: 12px 20px; font-size: 0.875rem; }

  /* Sections */
  .section { padding: 48px 16px; }
  .section-title { font-size: 1.3rem; }
  .section-desc { font-size: 0.8125rem; margin-bottom: 32px; }
  .section-label { font-size: 0.625rem; }
  .container { padding: 0 16px; }

  /* Features */
  .features-grid { grid-template-columns: 1fr; gap: 10px; }
  .feature-card { padding: 20px 18px; }
  .feature-card h3 { font-size: 0.95rem; }
  .feature-card p { font-size: 0.8rem; }
  .feature-icon { width: 38px; height: 38px; font-size: 1.1rem; margin-bottom: 12px; }

  /* Comparison */
  .comparison-table { font-size: 0.6rem; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .comparison-table th, .comparison-table td { padding: 7px 5px; white-space: nowrap; }

  /* Steps */
  .steps { grid-template-columns: 1fr; max-width: 100%; gap: 12px; }
  .step { padding: 14px 10px; }
  .step-num { width: 36px; height: 36px; font-size: 0.875rem; }
  .step h3 { font-size: 0.875rem; }
  .step p { font-size: 0.75rem; }

  /* CTA */
  .cta-banner { padding: 40px 16px; }
  .cta-banner h2 { font-size: 1.2rem; }
  .cta-banner p { font-size: 0.8125rem; }
  .cta-buttons { flex-direction: column; gap: 10px; }
  .cta-buttons .btn { width: 100%; justify-content: center; }

  /* Dashboard */
  .dashboard { padding: 72px 12px 36px; }
  .dash-header { margin-bottom: 16px; }
  .dash-header h1 { font-size: 1.25rem; }
  .dash-toolbar { flex-wrap: nowrap; gap: 8px; margin-bottom: 16px; }
  .dash-search { padding: 8px 12px; }
  .dash-search input { font-size: 0.8125rem; }
  .dash-view-btn { width: 36px; height: 36px; }
  .list-grid { grid-template-columns: 1fr; gap: 10px; }
  .list-card { border-radius: 10px; }
  .list-cover, .list-cover-empty { width: 80px; min-height: 110px; }
  .list-info { padding: 12px 14px; }
  .list-info h3 { font-size: 0.9rem; margin-bottom: 6px; }
  .list-stats { gap: 8px; font-size: 0.65rem; }
  .list-date { font-size: 0.65rem; }
  .covers-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .covers-name { font-size: 0.7rem; margin-top: 6px; }
  .covers-placeholder { font-size: 2rem; }

  /* Project view */
  .project-view { padding: 72px 12px 36px; }
  .proj-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .proj-header h1 { font-size: 1.25rem; }
  .proj-covers { flex-wrap: wrap; gap: 8px; }
  .proj-cover-img { width: 72px; height: 100px; border-radius: 6px; }
  .share-controls { flex-direction: column; align-items: flex-start; gap: 6px; }
  .share-url { font-size: 0.625rem; word-break: break-all; }
  .node-card { border-radius: 8px; }
  .node-head { padding: 12px 14px; }
  .node-title { font-size: 0.9rem; gap: 8px; }
  .node-dot { width: 8px; height: 8px; }
  .chapter-item { padding: 10px 12px; }
  .chapter-item h4 { font-size: 0.8125rem; }
  .chapter-item .preview { font-size: 0.75rem; }

  /* Shared */
  .shared-view { padding: 44px 12px; }
  .shared-header { margin-bottom: 32px; }
  .shared-header h1 { font-size: 1.3rem; }
  .shared-covers { justify-content: center; }
  .shared-covers .proj-cover-img { width: 80px; height: 112px; }

  /* ─── IMMERSIVE READER MOBILE ─── */
  .ir-overlay { flex-direction: column; }

  .ir-sidebar {
    position: fixed; left: -280px; top: 0; bottom: 0; z-index: 30;
    width: 260px; transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 8px 0 40px rgba(0,0,0,0.6);
  }
  .ir-sidebar.open { left: 0; }
  .ir-sidebar-head { padding: 16px; }
  .ir-sidebar-cover { width: 60px; height: 84px; margin-bottom: 10px; }
  .ir-sidebar-title { font-size: 0.875rem; }
  .ir-sidebar-meta { font-size: 0.6875rem; }
  .ir-toc { padding: 6px; }
  .ir-toc-item { padding: 8px 10px; gap: 8px; }
  .ir-toc-ch { font-size: 0.75rem; }
  .ir-toc-node { font-size: 0.5625rem; }
  .ir-sidebar-foot { padding: 10px; }
  .ir-sidebar-foot .btn { font-size: 0.75rem; }

  .ir-menu-btn { display: block; font-size: 1.2rem; padding: 6px 10px; min-width: 44px; min-height: 44px; }

  .ir-topbar { padding: 0 12px; height: 48px; gap: 10px; }
  .ir-topbar-title { font-size: 0.75rem; }
  .ir-progress-wrap { width: 48px; }
  .ir-close-btn { min-width: 44px; min-height: 44px; }
  .ir-close-btn svg { width: 14px; height: 14px; }

  .ir-main { width: 100%; }

  .ir-content {
    padding: 24px 18px 56px; max-width: 100%;
  }
  .ir-chapter-head { margin-bottom: 32px; padding-bottom: 24px; }
  .ir-chapter-node { font-size: 0.5625rem; gap: 6px; margin-bottom: 10px; }
  .ir-ch-dot { width: 6px; height: 6px; }
  .ir-chapter-title { font-size: 1.25rem; line-height: 1.35; }
  .ir-chapter-meta { font-size: 0.75rem; }

  .ir-chapter-body {
    font-size: 0.9375rem; line-height: 1.8;
    letter-spacing: 0.01em;
  }
  .ir-chapter-body blockquote { padding-left: 14px; margin: 1.2em 0; }

  .ir-chapter-nav {
    flex-direction: column; gap: 10px; align-items: stretch;
    padding: 28px 0 16px; margin-top: 36px;
  }
  .ir-chapter-nav .btn {
    justify-content: center; width: 100%;
    padding: 12px 20px; font-size: 0.875rem;
  }
  .ir-end-msg { text-align: center; font-size: 0.8125rem; padding: 8px 0; }

  /* Footer */
  .footer { padding: 24px 12px; }
  .footer-links { gap: 12px; font-size: 0.6875rem; }
  .footer p { font-size: 0.6875rem; }
}

/* Extra small phones */
@media (max-width: 380px) {
  .hero h1 { font-size: 1.5rem; }
  .hero-sub { font-size: 0.8125rem; }
  .hero-bullet { font-size: 0.75rem; }
  .nav-brand { font-size: 0.9rem; }
  .nav-right .btn-sm { padding: 4px 6px; font-size: 0.65rem; }
  .covers-grid { grid-template-columns: repeat(2, 1fr); }
  .list-cover, .list-cover-empty { width: 70px; min-height: 100px; }
  .ir-content { padding: 20px 14px 48px; }
  .ir-chapter-title { font-size: 1.1rem; }
  .ir-chapter-body { font-size: 0.875rem; line-height: 1.75; }
}
