/* ─── LibLatch — design system v2 ──────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,300;0,400;0,500;0,600;1,400;1,500&family=Inter:wght@400;500;600;700&family=Source+Serif+4:ital,wght@0,400;0,500;0,600;1,400&family=JetBrains+Mono:wght@400;500&family=Manrope:wght@400;500;600;700&display=swap');

/* ===== THEMES =====
 * data-theme: modern (default) | editorial | indigo | minimal | library
 * data-mode:  light (default)  | dark
 * Every theme defines both modes inline so the user can switch independently.
 */

/* ── MODERN (default) — sans headlines, cream, sparse ──────────────── */
:root, [data-theme="modern"] {
  --font-serif: "Spectral", Georgia, serif;
  --font-reader: "Source Serif 4", "Spectral", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --bg: #fbf9f4;
  --bg-elev: #ffffff;
  --bg-tint: #f5f1e7;
  --bg-deep: #ebe5d4;
  --ink: #181614;
  --ink-2: #3a3631;
  --ink-3: #706a5e;
  --ink-4: #9c958a;
  --rule: #e8e1d0;
  --rule-2: #d4ccba;
  --accent: #8c4a1f;
  --accent-2: #6e3914;
  --accent-soft: #f0e2d2;
  --gold: #b58841;
  --moss: #4f6a3c;
  --burgundy: #6f2a2c;
  --sky: #335778;
  --danger: #a8341c;
  --success: #4a6f3a;
  --reader-bg: #fbf9f4;
  --reader-ink: #181614;
  --display-weight: 600;
  --display-tracking: -0.025em;
  --display-line: 1.08;
  --display-fam: var(--font-display);
  --has-dropcap: 0; /* 0 = no drop cap */
  --has-ornament: 0; /* 0 = subtle scene break */
}
[data-theme="modern"][data-mode="dark"], [data-mode="dark"] {
  --bg: #131210;
  --bg-elev: #1c1a16;
  --bg-tint: #1f1c17;
  --bg-deep: #0e0d0a;
  --ink: #ede5d2;
  --ink-2: #c5bca8;
  --ink-3: #918874;
  --ink-4: #5e574a;
  --rule: #2a2620;
  --rule-2: #3b3429;
  --accent: #d59867;
  --accent-2: #b87c4f;
  --accent-soft: #2c241c;
  --reader-bg: #131210;
  --reader-ink: #ede5d2;
}

/* ── EDITORIAL — current style, slightly toned down ─────────────────── */
[data-theme="editorial"] {
  --font-display: "Spectral", Georgia, serif;
  --bg: #faf7f0; --bg-elev: #ffffff; --bg-tint: #f3eee2; --bg-deep: #e8e0cc;
  --ink: #1a1714; --ink-2: #3d3933; --ink-3: #706a5e; --ink-4: #9a9385;
  --rule: #e6dfcd; --rule-2: #d4cbb3;
  --accent: #8a4a1e; --accent-2: #6d3914; --accent-soft: #efe1d0;
  --reader-bg: #faf7f0; --reader-ink: #1a1714;
  --display-weight: 500;
  --display-tracking: -0.018em;
  --display-line: 1.05;
  --has-dropcap: 1;
  --has-ornament: 1;
}
[data-theme="editorial"][data-mode="dark"] {
  --bg: #14110d; --bg-elev: #1e1a14; --bg-tint: #221d16; --bg-deep: #0e0c09;
  --ink: #ece3d1; --ink-2: #c8c0ae; --ink-3: #948c7e; --ink-4: #65604f;
  --rule: #2d2720; --rule-2: #3c352b;
  --accent: #d59667; --accent-2: #b87c4f; --accent-soft: #2c241a;
  --reader-bg: #14110d; --reader-ink: #ece3d1;
}

/* ── INDIGO — modern dark-blue, Goodreads-ish ───────────────────────── */
[data-theme="indigo"] {
  --font-display: "Manrope", "Inter", sans-serif;
  --bg: #f5f6fa; --bg-elev: #ffffff; --bg-tint: #ebedf5; --bg-deep: #dde0ed;
  --ink: #1a1f3a; --ink-2: #3a4163; --ink-3: #686d8c; --ink-4: #9a9eb3;
  --rule: #e0e3ee; --rule-2: #c8ccdc;
  --accent: #4d4ad8; --accent-2: #3837b4; --accent-soft: #e4e3ff;
  --gold: #d4a52e; --moss: #4a8a6a;
  --reader-bg: #f5f6fa; --reader-ink: #1a1f3a;
  --display-weight: 700;
  --display-tracking: -0.025em;
  --display-line: 1.1;
  --has-dropcap: 0;
}
[data-theme="indigo"][data-mode="dark"] {
  --bg: #0e1027; --bg-elev: #181c3a; --bg-tint: #1e2245; --bg-deep: #0a0c1c;
  --ink: #ebecf5; --ink-2: #c0c4d8; --ink-3: #8a8eaa; --ink-4: #585c75;
  --rule: #262a4c; --rule-2: #353a5e;
  --accent: #7d7bff; --accent-2: #9f9eff; --accent-soft: #1f1f4a;
  --reader-bg: #0e1027; --reader-ink: #ebecf5;
}

/* ── MINIMAL — near monochrome, single accent ───────────────────────── */
[data-theme="minimal"] {
  --font-display: "Inter", system-ui, sans-serif;
  --bg: #fafaf9; --bg-elev: #ffffff; --bg-tint: #f1f0ee; --bg-deep: #e3e2e0;
  --ink: #0a0a0a; --ink-2: #2a2a2a; --ink-3: #5a5a5a; --ink-4: #8a8a8a;
  --rule: #e6e6e4; --rule-2: #d0d0cd;
  --accent: #d24c1c; --accent-2: #a83a14; --accent-soft: #fdebdf;
  --gold: #8a7a30; --moss: #4f6a3c;
  --reader-bg: #fafaf9; --reader-ink: #0a0a0a;
  --display-weight: 700;
  --display-tracking: -0.03em;
  --display-line: 1.05;
  --has-dropcap: 0;
}
[data-theme="minimal"][data-mode="dark"] {
  --bg: #0d0d0d; --bg-elev: #161616; --bg-tint: #1c1c1c; --bg-deep: #080808;
  --ink: #f5f5f5; --ink-2: #c5c5c5; --ink-3: #909090; --ink-4: #606060;
  --rule: #232323; --rule-2: #2f2f2f;
  --accent: #ff7e4a; --accent-2: #e06030; --accent-soft: #261810;
  --reader-bg: #0d0d0d; --reader-ink: #f5f5f5;
}

/* ── LIBRARY — old book / sepia heavy serif ─────────────────────────── */
[data-theme="library"] {
  --font-display: "Spectral", Georgia, serif;
  --font-sans: "Spectral", Georgia, serif;
  --bg: #ede1c2; --bg-elev: #f4e9ce; --bg-tint: #e3d6b3; --bg-deep: #d4c397;
  --ink: #2c1f0e; --ink-2: #4c3a1d; --ink-3: #7b6536; --ink-4: #a89066;
  --rule: #d0bf91; --rule-2: #b8a473;
  --accent: #6f2b13; --accent-2: #54200d; --accent-soft: #ddc9a3;
  --gold: #a07e30; --moss: #4f6a3c;
  --reader-bg: #ede1c2; --reader-ink: #2c1f0e;
  --display-weight: 500;
  --display-tracking: -0.012em;
  --display-line: 1.0;
  --has-dropcap: 1;
  --has-ornament: 1;
}
[data-theme="library"][data-mode="dark"] {
  --bg: #1a1409; --bg-elev: #221b0f; --bg-tint: #2a2114; --bg-deep: #110c06;
  --ink: #f0e3c2; --ink-2: #cabb96; --ink-3: #978966; --ink-4: #62593e;
  --rule: #322714; --rule-2: #443721;
  --accent: #d59667; --accent-2: #e8a877; --accent-soft: #2a1d10;
  --reader-bg: #1a1409; --reader-ink: #f0e3c2;
}

/* ===== UNIVERSAL TOKENS ===== */
:root {
  --shadow-1: 0 1px 2px rgba(40,28,10,.05), 0 1px 1px rgba(40,28,10,.04);
  --shadow-2: 0 4px 14px rgba(40,28,10,.07), 0 2px 4px rgba(40,28,10,.04);
  --shadow-3: 0 22px 52px rgba(40,28,10,.13), 0 6px 18px rgba(40,28,10,.07);
  --r-sm: 4px; --r-md: 8px; --r-lg: 14px; --r-xl: 22px;
  --nav-h: 60px;
  --reader-width: 640px;
}
[data-mode="dark"] {
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 14px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
  --shadow-3: 0 22px 52px rgba(0,0,0,.55), 0 6px 18px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
p { margin: 0 0 1em; }
::selection { background: var(--accent-soft); color: var(--ink); }

/* ── typography ───────────────────────────────────────────────────── */
.display {
  font-family: var(--display-fam, var(--font-display));
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: var(--display-line);
}
.display-xl { font-size: 56px; }
.display-lg { font-size: 42px; }
.h1 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 30px; line-height: 1.15; letter-spacing: var(--display-tracking); margin: 0; }
.h2 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 22px; line-height: 1.2; letter-spacing: var(--display-tracking); margin: 0; }
.h3 { font-family: var(--font-sans); font-weight: 600; font-size: 14px; line-height: 1.3; margin: 0; }
.h4 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 17px; line-height: 1.25; margin: 0; }
.eyebrow { font: 600 10.5px/1 var(--font-sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.faint { color: var(--ink-4); }
.serif { font-family: var(--font-serif); }
.italic-s { font-family: var(--font-serif); font-style: italic; }

/* ── layout shell ─────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topnav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center;
  padding: 0 24px; gap: 22px;
}
.topnav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -.025em;
  cursor: pointer;
  display: flex; align-items: baseline; gap: 1px;
}
[data-theme="editorial"] .topnav-logo, [data-theme="library"] .topnav-logo {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 22px;
}
.topnav-logo .dot { color: var(--accent); font-style: normal; }
.topnav-search { flex: 1; max-width: 380px; position: relative; }
.topnav-search input {
  width: 100%; height: 34px; padding: 0 12px 0 34px;
  background: var(--bg-tint); border: 1px solid transparent;
  border-radius: var(--r-md); font-size: 13px; outline: none;
}
.topnav-search input:focus { background: var(--bg-elev); border-color: var(--rule-2); }
.topnav-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.topnav-links { display: flex; align-items: center; gap: 2px; }
.topnav-link {
  padding: 6px 11px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer;
}
.topnav-link:hover { background: var(--bg-tint); color: var(--ink); }
.topnav-link.active { color: var(--accent); }
.topnav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 28px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ── buttons / chips ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid transparent;
  font: 500 13px/1 var(--font-sans);
  cursor: pointer; transition: background .12s, border-color .12s, color .12s, transform .06s;
  white-space: nowrap;
}
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--ink-2); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-2); }
.btn-outline { background: var(--bg-elev); border-color: var(--rule-2); }
.btn-outline:hover { background: var(--bg-tint); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-tint); color: var(--ink); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  background: var(--bg-tint); color: var(--ink-2);
  font: 500 11px/1 var(--font-sans); letter-spacing: .01em;
  border: 1px solid transparent;
}
.chip-accent { background: var(--accent-soft); color: var(--accent-2); }
.chip-gold { background: color-mix(in oklab, var(--gold) 18%, transparent); color: var(--gold); }
.chip-outline { background: transparent; border-color: var(--rule-2); }
.chip-locked { background: color-mix(in oklab, var(--accent) 12%, transparent); color: var(--accent); }
.chip-success { background: color-mix(in oklab, var(--moss) 18%, transparent); color: var(--moss); }
.chip-warn { background: color-mix(in oklab, var(--gold) 22%, transparent); color: var(--gold); }
.chip-danger { background: color-mix(in oklab, var(--danger) 14%, transparent); color: var(--danger); }

/* ── cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--rule-2); box-shadow: var(--shadow-2); }
.divider { height: 1px; background: var(--rule); border: 0; margin: 24px 0; }

/* ── inputs ───────────────────────────────────────────────────────── */
.input, .textarea, .select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  font-size: 13px;
  outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { min-height: 80px; resize: vertical; line-height: 1.5; font-family: inherit; }
.field-label {
  display: block;
  font: 600 11.5px/1 var(--font-sans);
  color: var(--ink-2); margin-bottom: 6px; letter-spacing: .01em;
}
.field-hint { font-size: 11px; color: var(--ink-4); margin-top: 4px; }

/* ── avatar ───────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-2);
  font: 600 13px/1 var(--font-sans); flex-shrink: 0; overflow: hidden;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }
.avatar.xl { width: 92px; height: 92px; font-size: 34px; }

/* ── cover ────────────────────────────────────────────────────────── */
.cover {
  position: relative; aspect-ratio: 2/3; border-radius: 4px; overflow: hidden;
  box-shadow:
    inset 1px 0 0 rgba(255,255,255,.18),
    inset -1px 0 0 rgba(0,0,0,.16),
    0 1px 2px rgba(40,28,10,.1),
    0 6px 18px rgba(40,28,10,.12);
}
.cover-inner {
  position: absolute; inset: 0; padding: 14px 14px 16px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: var(--cover-fg, #f5efe1);
  background: var(--cover-bg, linear-gradient(155deg, #2d3b46, #1a2229));
}
.cover-inner::before {
  content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px;
  width: 1px; background: rgba(255,255,255,.08);
}
.cover-title { font: 500 16px/1.1 var(--font-serif); letter-spacing: -.01em; text-wrap: balance; }
.cover-author { font: 500 9px/1 var(--font-sans); letter-spacing: .18em; text-transform: uppercase; opacity: .76; }
.cover-mark { align-self: flex-start; font: italic 13px/1 var(--font-serif); opacity: .55; }

/* ── rating ───────────────────────────────────────────────────────── */
.rating { display: inline-flex; align-items: center; gap: 4px; font: 500 12.5px/1 var(--font-sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rating .stars { display: inline-flex; color: var(--gold); gap: 1px; }

/* ── tabs ─────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--rule); }
.tab { position: relative; padding: 11px 0; font: 500 13px/1 var(--font-sans); color: var(--ink-3); cursor: pointer; }
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.tab .count { display: inline-block; margin-left: 6px; color: var(--ink-4); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tabs-spaced { gap: 32px; }

/* ── work cards ──────────────────────────────────────────────────── */
.work-card {
  display: flex; gap: 16px; padding: 16px;
  border-radius: var(--r-lg); cursor: pointer;
  transition: background .14s;
}
.work-card:hover { background: var(--bg-tint); }
.work-card .cover { width: 88px; flex-shrink: 0; }
.work-card .wc-body { flex: 1; min-width: 0; }
.work-card .wc-title { font: var(--display-weight) 18px/1.2 var(--font-display); letter-spacing: var(--display-tracking); margin-bottom: 4px; color: var(--ink); }
.work-card .wc-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.work-card .wc-desc { font-size: 13px; color: var(--ink-2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.work-card .wc-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ── grid helpers ─────────────────────────────────────────────────── */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }

/* ── reader ───────────────────────────────────────────────────────── */
.reader { background: var(--reader-bg); min-height: 100vh; padding: 32px 0 120px; }
.reader-frame { max-width: var(--reader-width); margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }
.reader-progress {
  position: fixed; top: 0; left: 0; height: 3px; background: var(--accent); z-index: 30; transition: width .1s;
  box-shadow: 0 1px 0 var(--bg);
}
.reader-progress::after {
  /* opaque rail behind progress so scrolled text doesn't bleed through */
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; background: var(--bg-tint); z-index: 29;
}
.reader-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 12px; color: var(--ink-3); }
.reader-title { font: var(--display-weight) 36px/1.1 var(--font-display); letter-spacing: var(--display-tracking); color: var(--reader-ink); margin: 0 0 8px; }
.reader-sub { font: italic 400 16px/1.3 var(--font-serif); color: var(--ink-3); margin: 0 0 36px; }
.reader-body { font-family: var(--reader-font, var(--font-reader)); font-size: var(--reader-size, 19px); line-height: 1.72; color: var(--reader-ink); }
.reader-body p { margin: 0 0 1.2em; text-wrap: pretty; }
[data-theme="editorial"] .reader-body p:first-of-type::first-letter,
[data-theme="library"] .reader-body p:first-of-type::first-letter {
  font-family: var(--font-serif); float: left;
  font-size: 4.2em; line-height: .88;
  margin: .04em .08em 0 -.04em; font-weight: 500;
  color: var(--accent);
}
.reader-body .gloss { border-bottom: 1px dashed var(--accent); cursor: pointer; transition: background .1s; }
.reader-body .gloss:hover { background: var(--accent-soft); }
.reader-body em { font-family: var(--font-serif); font-style: italic; }
.reader-body blockquote { border-left: 3px solid var(--accent); margin: 1.4em 0; padding: .3em 0 .3em 1.1em; font-style: italic; color: var(--ink-2); }
.scene-break { text-align: center; margin: 2em 0; color: var(--accent); font-size: 22px; }
[data-theme="modern"] .scene-break, [data-theme="indigo"] .scene-break, [data-theme="minimal"] .scene-break {
  font-size: 14px; letter-spacing: 1em; padding-left: 1em;
}

.reader-end { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--rule); text-align: center; font-family: var(--font-serif); font-style: italic; color: var(--ink-3); }
.reader-end::before { content: "❦"; display: block; font-size: 22px; color: var(--accent); margin-bottom: 12px; }
[data-theme="modern"] .reader-end::before, [data-theme="indigo"] .reader-end::before, [data-theme="minimal"] .reader-end::before { content: "·  ·  ·"; font-size: 14px; letter-spacing: .3em; }

.reader-toolbar {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  background: var(--bg-elev); border: 1px solid var(--rule-2);
  border-radius: 999px; padding: 4px;
  box-shadow: var(--shadow-3); z-index: 40;
}
.reader-toolbar button { width: 34px; height: 34px; border-radius: 50%; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; }
.reader-toolbar button:hover { background: var(--bg-tint); color: var(--ink); }
.reader-toolbar button.active { background: var(--accent-soft); color: var(--accent-2); }
.reader-toolbar .sep { width: 1px; height: 18px; background: var(--rule); margin: 0 4px; }

.paywall { margin: 40px auto; max-width: 520px; text-align: center; background: var(--bg-elev); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 36px 28px; box-shadow: var(--shadow-2); }
.paywall .lock-icon { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 16px; }

/* ── glossary popup ──────────────────────────────────────────────── */
.gloss-pop { position: fixed; z-index: 60; width: 280px; padding: 14px 16px; background: var(--bg-elev); border: 1px solid var(--rule-2); border-radius: var(--r-md); box-shadow: var(--shadow-3); }
.gloss-pop .gp-eyebrow { font: 600 10px/1 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.gloss-pop .gp-title { font: 500 16px/1.2 var(--font-serif); margin-bottom: 6px; }
.gloss-pop .gp-text { font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.gloss-pop .gp-link { margin-top: 10px; font-size: 12px; color: var(--accent); cursor: pointer; font-weight: 500; }

/* ── map ─────────────────────────────────────────────────────────── */
.map-wrap { position: relative; aspect-ratio: 16/10; background: #e8d8b8; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--rule-2); box-shadow: var(--shadow-2); }
[data-mode="dark"] .map-wrap { background: #2a2418; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-pin { cursor: pointer; transition: transform .15s; transform-origin: center bottom; }
.map-pin:hover { transform: scale(1.12); }
.map-popup { position: absolute; pointer-events: auto; background: var(--bg-elev); border: 1px solid var(--rule-2); border-radius: var(--r-md); padding: 12px 14px; width: 240px; box-shadow: var(--shadow-3); z-index: 5; font-size: 12.5px; }
.map-popup .mp-title { font: 500 15px/1.2 var(--font-serif); margin-bottom: 4px; }
.map-popup .mp-kind { font: 600 9.5px/1 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.map-popup .mp-text { color: var(--ink-2); line-height: 1.5; }
.map-controls { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 4; }
.map-panel { background: var(--bg-elev); border: 1px solid var(--rule-2); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.map-zoom { display: flex; flex-direction: column; }
.map-zoom button { width: 32px; height: 32px; color: var(--ink-2); font-size: 16px; display: flex; align-items: center; justify-content: center; }
.map-zoom button:hover { background: var(--bg-tint); }
.map-zoom button + button { border-top: 1px solid var(--rule); }
.map-legend { padding: 12px 14px; width: 200px; font-size: 12px; }
.map-legend .lg-title { font: 600 10.5px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.map-legend label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; color: var(--ink-2); }
.map-legend label:hover { color: var(--ink); }
.map-legend input { accent-color: var(--accent); }

.map-timeline { position: absolute; left: 14px; bottom: 14px; right: 232px; padding: 10px 14px; font-size: 12px; }
.map-timeline-row { display: flex; align-items: center; gap: 12px; }
.map-timeline-bar { flex: 1; position: relative; height: 4px; background: var(--rule); border-radius: 999px; }
.map-timeline-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; }
.map-timeline-handle { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 14px; height: 14px; background: var(--bg-elev); border: 2px solid var(--accent); border-radius: 50%; cursor: pointer; }

/* ── lore wiki ──────────────────────────────────────────────────── */
.wiki-layout { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
.wiki-side { position: sticky; top: calc(var(--nav-h) + 24px); font-size: 13px; }
.wiki-side .ws-group { font: 600 10.5px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 6px; }
.wiki-side .ws-link { display: block; padding: 5px 10px; border-radius: 6px; color: var(--ink-2); cursor: pointer; border-left: 2px solid transparent; margin-left: -2px; }
.wiki-side .ws-link:hover { background: var(--bg-tint); color: var(--ink); }
.wiki-side .ws-link.active { color: var(--accent-2); background: var(--accent-soft); border-left-color: var(--accent); }
.wiki-side .ws-link .locked-dot { color: var(--ink-4); font-size: 10px; margin-left: 4px; }
.wiki-entry { background: var(--bg-elev); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.wiki-hero { height: 180px; position: relative; }
.wiki-body { padding: 28px 32px 32px; display: grid; grid-template-columns: 1fr 220px; gap: 32px; }
.wiki-prose { font-family: var(--font-reader); font-size: 15.5px; line-height: 1.72; color: var(--ink-2); }
.wiki-prose h2 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 22px; margin: 1.4em 0 .5em; color: var(--ink); }
.wiki-prose p { margin: 0 0 1em; }
.wiki-prose .gloss { border-bottom: 1px dashed var(--accent); cursor: pointer; }
.wiki-side-info { background: var(--bg-tint); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 18px; font-family: var(--font-sans); font-size: 12.5px; }
.wiki-side-info dt { font: 600 10px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-top: 12px; }
.wiki-side-info dt:first-of-type { margin-top: 0; }
.wiki-side-info dd { margin: 4px 0 0; color: var(--ink); }

/* ── comments ────────────────────────────────────────────────────── */
.comment { display: flex; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.comment .c-name { font-weight: 600; font-size: 13px; }
.comment .c-time { font-size: 11.5px; color: var(--ink-4); }
.comment .c-author-tag { font: 600 9.5px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding: 2px 6px; border: 1px solid var(--accent); border-radius: 999px; }
.comment .c-text { font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.comment .c-actions { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.comment .c-actions span { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.comment .c-actions span:hover { color: var(--accent); }
.comment.is-author { background: var(--accent-soft); border-radius: var(--r-md); padding: 16px; border: 0; margin-bottom: 4px; }

.rating-bar { display: grid; grid-template-columns: 28px 1fr 36px; gap: 10px; align-items: center; font-size: 12px; color: var(--ink-3); margin: 3px 0; }
.rating-bar .rb-track { height: 6px; background: var(--rule); border-radius: 999px; overflow: hidden; }
.rating-bar .rb-fill { height: 100%; background: var(--gold); border-radius: 999px; }

/* ── modal ───────────────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(20, 14, 6, .42); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadeIn .15s ease-out; }
[data-mode="dark"] .modal-bg { background: rgba(0,0,0,.65); }
.modal { background: var(--bg-elev); border: 1px solid var(--rule); border-radius: var(--r-lg); width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-3); animation: pop .18s ease-out; }
.modal-wide { max-width: 720px; }
.modal-xwide { max-width: 920px; }
.modal-head { padding: 22px 28px 14px; display: flex; justify-content: space-between; align-items: flex-start; }
.modal-body { padding: 0 28px 24px; }
.modal-foot { padding: 16px 28px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg-tint); }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } }

.toast { position: fixed; bottom: 24px; right: 24px; z-index: 200; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--r-md); font-size: 13px; box-shadow: var(--shadow-3); animation: slideIn .2s ease-out; }

/* ── dashboard ───────────────────────────────────────────────────── */
.dash { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - var(--nav-h)); }
.dash-side { background: var(--bg-tint); border-right: 1px solid var(--rule); padding: 22px 14px; position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow-y: auto; }
.dash-side .ds-group { font: 600 10px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 16px 10px 6px; }
.dash-side .ds-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.dash-side .ds-link:hover { background: var(--bg-deep); color: var(--ink); }
.dash-side .ds-link.active { background: var(--bg-elev); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-1); }
.dash-side .ds-link svg { color: var(--ink-3); flex-shrink: 0; }
.dash-side .ds-link.active svg { color: var(--accent); }
.dash-side .ds-link .ds-badge { margin-left: auto; font-size: 10px; padding: 2px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dash-main { padding: 32px 36px; min-width: 0; }

.stat { background: var(--bg-elev); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 18px 20px; }
.stat-label { font: 600 10.5px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.stat-value { font: var(--display-weight) 26px/1.1 var(--font-display); letter-spacing: var(--display-tracking); margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-delta { font: 500 11.5px/1 var(--font-sans); margin-top: 4px; }
.stat-delta.up { color: var(--moss); }
.stat-delta.down { color: var(--danger); }
.stat-delta.flat { color: var(--ink-3); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font: 600 10.5px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.table td { padding: 14px; border-bottom: 1px solid var(--rule); font-size: 13px; vertical-align: middle; }
.table tr:hover td { background: var(--bg-tint); }
.table tr:last-child td { border-bottom: 0; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.dot.pub { background: var(--moss); }
.dot.draft { background: var(--ink-4); }
.dot.early { background: var(--accent); }
.dot.locked { background: var(--gold); }
.dot.live { background: var(--danger); }

/* ── stepper ─────────────────────────────────────────────────────── */
.stepper { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; flex-wrap: wrap; }
.stepper-step { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.stepper-step .num { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-tint); color: var(--ink-3); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px; border: 1px solid var(--rule-2); }
.stepper-step.active { color: var(--ink); }
.stepper-step.active .num { background: var(--accent); color: #fff; border-color: var(--accent); }
.stepper-step.done .num { background: var(--moss); color: #fff; border-color: var(--moss); }
.stepper-line { flex: 1; height: 1px; background: var(--rule); min-width: 20px; }

.option { display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--rule-2); border-radius: var(--r-md); cursor: pointer; transition: border-color .12s, background .12s; }
.option:hover { background: var(--bg-tint); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option .opt-radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--rule-2); flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; justify-content: center; }
.option.selected .opt-radio { border-color: var(--accent); }
.option.selected .opt-radio::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.price-card { border: 1px solid var(--rule-2); border-radius: var(--r-lg); padding: 22px 24px; background: var(--bg-elev); position: relative; transition: border-color .12s, box-shadow .12s; }
.price-card.featured { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.price-card .pc-name { font: var(--display-weight) 18px/1.2 var(--font-display); letter-spacing: var(--display-tracking); margin-bottom: 4px; }
.price-card .pc-price { font: var(--display-weight) 30px/1 var(--font-display); margin: 14px 0 6px; }
.price-card .pc-price small { font-size: 14px; color: var(--ink-3); font-family: var(--font-sans); font-weight: 400; }
.price-card .pc-features { list-style: none; padding: 16px 0 0; margin: 16px 0 0; border-top: 1px solid var(--rule); }
.price-card .pc-features li { display: flex; gap: 8px; padding: 4px 0; font-size: 13px; color: var(--ink-2); }
.price-card .pc-features li svg { color: var(--moss); flex-shrink: 0; margin-top: 2px; }
.price-card .pc-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font: 600 10px/1 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; padding: 5px 12px; border-radius: 999px; }

/* ── hero (work cover area) ──────────────────────────────────────── */
.work-hero { position: relative; background: linear-gradient(180deg, var(--bg-tint) 0%, var(--bg) 100%); padding: 48px 0 32px; border-bottom: 1px solid var(--rule); }
.work-hero-inner { display: grid; grid-template-columns: 200px 1fr; gap: 36px; align-items: start; }
.work-hero .cover { width: 200px; }

/* ── inline editor ──────────────────────────────────────────────── */
.editor-shell { background: var(--bg-elev); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.editor-toolbar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--rule); background: var(--bg-tint); }
.editor-toolbar button { padding: 5px 8px; border-radius: 4px; font-size: 12px; color: var(--ink-2); }
.editor-toolbar button:hover { background: var(--bg-deep); }
.editor-toolbar .sep { width: 1px; height: 18px; background: var(--rule); margin: 0 6px; }
.editor-area { padding: 32px 48px; font-family: var(--font-reader); font-size: 17px; line-height: 1.7; min-height: 480px; color: var(--ink); outline: none; }
.editor-area:empty::before { content: attr(data-placeholder); color: var(--ink-4); }

/* ── empty state ────────────────────────────────────────────────── */
.empty { padding: 56px 24px; text-align: center; color: var(--ink-3); }
.empty .e-icon { width: 56px; height: 56px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; background: var(--bg-tint); border-radius: 50%; color: var(--ink-3); }

/* ── lang switch ────────────────────────────────────────────────── */
.lang-pill { display: inline-flex; gap: 2px; align-items: center; background: var(--bg-tint); border-radius: 999px; padding: 3px; }
.lang-pill button { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.lang-pill button.active { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-1); }

/* ── scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
::-webkit-scrollbar-track { background: transparent; }

/* ── misc ───────────────────────────────────────────────────────── */
.lock { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-size: 12px; font-weight: 500; }

/* ── notification dropdown ──────────────────────────────────────── */
.notif-pop { position: absolute; top: calc(var(--nav-h) + 4px); right: 16px; width: 380px; max-height: 480px; background: var(--bg-elev); border: 1px solid var(--rule-2); border-radius: var(--r-lg); box-shadow: var(--shadow-3); z-index: 70; overflow: hidden; display: flex; flex-direction: column; }
.notif-pop .np-head { padding: 14px 18px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; }
.notif-pop .np-list { flex: 1; overflow-y: auto; }
.notif-pop .np-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--rule); cursor: pointer; transition: background .12s; position: relative; }
.notif-pop .np-item:hover { background: var(--bg-tint); }
.notif-pop .np-item.unread::before { content: ""; position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.notif-pop .np-item .np-icon { width: 32px; height: 32px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-pop .np-item .np-body { flex: 1; min-width: 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.notif-pop .np-item .np-body .np-title { color: var(--ink); }
.notif-pop .np-item .np-time { font-size: 11px; color: var(--ink-4); }
.notif-pop .np-foot { padding: 10px 18px; border-top: 1px solid var(--rule); background: var(--bg-tint); text-align: center; }

/* ── popularity rank ─────────────────────────────────────────────── */
.rank-row { display: grid; grid-template-columns: 36px 60px 1fr 100px 80px 80px; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule); transition: background .12s; cursor: pointer; }
.rank-row:hover { background: var(--bg-tint); }
.rank-row:last-child { border-bottom: 0; }
.rank-row .rk-num { font: var(--display-weight) 22px/1 var(--font-display); color: var(--ink-3); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rank-row .rk-num.top { color: var(--accent); }
.rank-row .rk-change { font-size: 11.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.rank-row .rk-change.up { color: var(--moss); }
.rank-row .rk-change.down { color: var(--danger); }
.rank-row .rk-change.flat { color: var(--ink-4); }

/* ── activity feed ──────────────────────────────────────────────── */
.feed-item { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--r-md); transition: background .12s; }
.feed-item:hover { background: var(--bg-tint); }
.feed-item .fi-icon { width: 28px; height: 28px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.feed-item .fi-time { font-size: 11px; color: var(--ink-4); margin-left: auto; flex-shrink: 0; }

/* ── sparkline ──────────────────────────────────────────────────── */
.sparkline { display: inline-block; }

/* ── chart bar ──────────────────────────────────────────────────── */
.chart-bar { width: 100%; height: 100%; display: flex; align-items: flex-end; gap: 2px; }
.chart-bar > span { flex: 1; background: var(--accent-soft); border-radius: 1px 1px 0 0; min-height: 2px; transition: background .12s; }
.chart-bar > span.h { background: var(--accent); }
