/* ==========================================================================
   INSIGNIA — design tokens
   Three reading modes share one system:
     shell  → Nothing-style frames, dot-matrix type, frosted containers
     reader → Medium-style long-form typography (novel chapters, pages)
     wiki   → Wikipedia-style encyclopedia (the Archive)
   Change colours and fonts here; everything else reads these variables.
   ========================================================================== */

@font-face {
  font-family: "Font-Lambda-Italic";
  src: url("/fonts/lambda/Lambda-Italic.otf") format("otf");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Shell (Nothing) */
  --bg: #f4f4f4;
  --surface: #ffffff;
  --frost: rgba(255, 255, 255, 0.8);
  --ink: #000000;
  --ink-2: #4a4a4a;
  --ink-3: #8a8a8a;
  --line: #e4e4e4;
  --line-strong: #cdcdcd;
  --dot: rgba(0, 0, 0, 0.2);
  --hover: rgba(0, 0, 0, 0.05);
  --accent: #d71921;               /* Nothing red — use sparingly */
  --btn-bg: #040404;
  --btn-ink: #ffffff;

  /* Reader (Medium) */
  --reader-bg: #ffffff;
  --reader-ink: #242424;
  --reader-ink-2: #6b6b6b;
  --reader-line: #f2f2f2;

  /* Archive (Wikipedia) */
  --wiki-bg: #ffffff;
  --wiki-ink: #202122;
  --wiki-ink-2: #54595d;
  --wiki-link: #3366cc;
  --wiki-link-visited: #6b4ba1;
  --wiki-new: #d73333;
  --wiki-border: #a2a9b1;
  --wiki-border-soft: #c8ccd1;
  --wiki-box: #f8f9fa;
  --wiki-head: #eaecf0;
  --mp-green: #cef2e0;
  --mp-green-edge: #a3bfb1;
  --mp-blue: #cedff2;
  --mp-blue-edge: #a3b0bf;
  --navbox-title: #ccccff;
  --navbox-group: #ddddff;

  /* Type */
  --f-dot: "Doto", "Geist Mono", ui-monospace, monospace;
  --f-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans KR", monospace;
  --f-sans: "Geist", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-serif: "Source Serif 4", "Noto Serif KR", Georgia, Cambria, "Times New Roman", serif;
  --f-wiki-serif: "Linux Libertine", "Georgia", "Times", "Source Serif 4", "Noto Serif KR", serif;
  --f-wiki-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, "Liberation Sans", "Noto Sans KR", sans-serif;

  /* Shape & motion */
  --r-sm: 6px;
  --r: 8px;
  --gutter: 8px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #000000;
  --surface: #111111;
  --frost: rgba(26, 26, 26, 0.78);
  --ink: #ffffff;
  --ink-2: #bdbdbd;
  --ink-3: #7d7d7d;
  --line: #242424;
  --line-strong: #3a3a3a;
  --dot: rgba(255, 255, 255, 0.2);
  --hover: rgba(255, 255, 255, 0.07);
  --btn-bg: #ffffff;
  --btn-ink: #000000;

  --reader-bg: #0f0f0f;
  --reader-ink: #e6e6e6;
  --reader-ink-2: #9a9a9a;
  --reader-line: #262626;

  --wiki-bg: #101418;
  --wiki-ink: #eaecf0;
  --wiki-ink-2: #a2a9b1;
  --wiki-link: #88a3e8;
  --wiki-link-visited: #a799cd;
  --wiki-new: #fd7865;
  --wiki-border: #54595d;
  --wiki-border-soft: #3a3f45;
  --wiki-box: #1a1d21;
  --wiki-head: #27292d;
  --mp-green: #1b2f27;
  --mp-green-edge: #3a5a4b;
  --mp-blue: #1a2839;
  --mp-blue-edge: #3b4f69;
  --navbox-title: #2a2a48;
  --navbox-group: #222238;
}

/* ==========================================================================
   Base, utilities and shared components
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }

img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
code { font-family: var(--f-mono); font-size: 0.88em; }
::selection { background: var(--accent); color: #fff; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; }

.skip {
  position: absolute; left: 8px; top: -100px; z-index: 200;
  padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--btn-bg); color: var(--btn-ink);
}
.skip:focus { top: 8px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.container { width: 100%; max-width: 1216px; margin: 0 auto; padding: 0 var(--gutter); }
.stack { display: grid; gap: var(--gutter); }
.stack-row { display: flex; flex-wrap: wrap; gap: 8px; }
.empty { padding: 48px 16px; color: var(--ink-3); text-align: center; }

/* ── Type roles ─────────────────────────────────────────────────────────── */

/* Small uppercase mono — Nothing's "callout" labels */
.label {
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.label a { text-decoration: none; }
.label a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* Dot-matrix name — "ear ( 3a )" */
.dot-label {
  font-family: var(--f-dot);
  font-variation-settings: "ROND" 100;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.01em;
  margin: 0;
}

/* Light serif headline */
.headline {
  display: block;
  margin: 0;
  font-family: var(--f-serif);
  font-weight: 300;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.headline--lg { font-size: clamp(26px, 2.6vw, 34px); line-height: 1.15; }
.headline--xl { font-size: clamp(32px, 4.4vw, 56px); line-height: 1.05; letter-spacing: -0.02em; }

/* ── Frost & panels ─────────────────────────────────────────────────────── */

.frost {
  background: var(--frost);
  -webkit-backdrop-filter: blur(45px);
  backdrop-filter: blur(45px);
  border-radius: var(--r);
}

.panel {
  background: var(--surface);
  border-radius: var(--r);
  padding: 24px;
}

.dotgrid {
  background-image: radial-gradient(circle at center, var(--dot) 1px, transparent 1.6px);
  background-size: 32px 32px;
  background-position: 16px 16px;
}

/* ── Buttons & chips ────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 20px;
  border: 0; border-radius: var(--r-sm);
  background: var(--btn-bg); color: var(--btn-ink);
  font-family: var(--f-mono); font-size: 11px; line-height: 1; letter-spacing: 0.02em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover { opacity: 0.84; }
.btn:active { transform: scale(0.98); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: none;
  color: inherit; cursor: pointer; text-decoration: none;
  transition: background-color 0.2s var(--ease);
}
.icon-btn:hover { background: var(--hover); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: transparent;
  color: inherit; font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.chip:hover { border-color: currentColor; }
.chip.is-active { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); }

/* ── Definition facts ───────────────────────────────────────────────────── */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin: 0; }
.facts div { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; font-size: 15px; }

/* ==========================================================================
   Shell — header, footer, home, section pages (Nothing-inspired)
   ========================================================================== */

/* ── Floating header ────────────────────────────────────────────────────── */

.site-header {
  position: fixed; inset: 0 0 auto; z-index: 50;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px;
  pointer-events: none;
  transition: transform 0.4s var(--ease);
}
.site-header > * { pointer-events: auto; width: 100%; max-width: 1200px; margin: 0 auto; }
.site-header.is-hidden { transform: translateY(calc(-100% - 8px)); }

.header-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 48px; padding: 0 4px 0 16px;
}
.mode-reader .header-bar,
.mode-wiki .header-bar { box-shadow: 0 0 0 1px var(--line); }

.logo {
  justify-self: start;
  font-family: var(--f-dot); font-variation-settings: "ROND" 100; font-weight: 800;
  font-size: 20px; letter-spacing: 0.04em; line-height: 1; text-decoration: none;
}

.header-nav { display: flex; gap: 2px; }
.header-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.header-nav a:hover { color: var(--ink); background: var(--hover); text-decoration: none; }
.header-nav a.is-active { color: var(--ink); }
.header-nav a.is-active::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}

.header-tools { justify-self: end; display: flex; gap: 2px; }
.menu-btn { display: none; }

.mobile-nav { display: none; }

@media (max-width: 800px) {
  .header-bar { grid-template-columns: 1fr auto; }
  .header-nav { display: none; }
  .menu-btn { display: inline-grid; }
  .mobile-nav:not([hidden]) { display: flex; flex-direction: column; padding: 4px 16px; }
  .mobile-nav a {
    display: flex; align-items: baseline; gap: 14px;
    padding: 16px 0; border-bottom: 1px solid var(--line);
    font-family: var(--f-serif); font-weight: 300; font-size: 24px; text-decoration: none;
  }
  .mobile-nav a:last-child { border-bottom: 0; }
  .mobile-nav a .label { color: var(--ink-3); }
  .mobile-nav a.is-active .label { color: var(--accent); }
}

/* Reading progress (chapters) */
.progress {
  position: fixed; inset: 0 0 auto; z-index: 60; height: 2px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  margin-top: 96px; padding: 64px 16px 16px;
  background: #000; color: #fff;
  border-top: 1px solid #1f1f1f;
}
.mode-wiki .site-footer { margin-top: 48px; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: grid; gap: 56px; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 32px; }
.footer-cols h2 { margin: 0 0 12px; color: #8a8a8a; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; }
.footer-cols a {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 0;
  font-family: var(--f-serif); font-weight: 300; font-size: 19px; text-decoration: none;
}
.footer-cols a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.footer-cols a .icon { width: 14px; height: 14px; }
.footer-about p { margin: 0; color: #bdbdbd; font-size: 14px; line-height: 1.55; max-width: 34ch; }
.footer-mark {
  margin: 0;
  font-family: var(--f-dot); font-variation-settings: "ROND" 100; font-weight: 800;
  font-size: clamp(56px, 16.5vw, 212px); line-height: 0.85; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden;
}
.footer-legal {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  padding-top: 16px; border-top: 1px solid #262626; color: #8a8a8a;
}

/* ── Sections ───────────────────────────────────────────────────────────── */

.section { padding-top: 96px; }
.section--tight { padding-top: 48px; }
.section-head { display: grid; gap: 12px; margin: 0 0 20px; padding: 0 8px; }
.section-head .label { color: var(--ink-3); }
.section-title {
  margin: 0;
  font-family: var(--f-serif); font-weight: 300;
  font-size: clamp(32px, 4vw, 48px); line-height: 1.08; letter-spacing: -0.02em;
}

/* ── Home hero ──────────────────────────────────────────────────────────── */

.hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; align-content: center; justify-items: center;
  padding: 104px 8px 24px;
  background: #000; color: #fff;
}
.hero-art { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.hero-shade {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, transparent 0%, rgba(0, 0, 0, 0.45) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.25), transparent 30%);
}
.hero-inner { display: grid; justify-items: center; gap: 22px; width: min(100%, 1200px); text-align: center; }
.hero-kicker { color: rgba(255, 255, 255, 0.72); }
.hero-mark {
  display: grid; justify-items: center; gap: clamp(12px, 2vw, 24px);
  width: 100%; padding: clamp(28px, 4vw, 56px) 12px clamp(20px, 3vw, 40px);
  background: var(--accent); color: #fff;
}
.hero-title {
  margin: 0;
  font-family: "Font-Lambda-Italic", var(--f-sans); font-weight: 600;
  font-size: clamp(40px, 19.5vw, 260px); line-height: 0.85; letter-spacing: 0.02em;
  white-space: nowrap;
}
.hero-tagline {
  margin: 0; max-width: 34ch;
  font-family: var(--f-serif); font-weight: 300; font-size: clamp(20px, 2.4vw, 28px); line-height: 1.3;
  color: rgba(255, 255, 255, 0.86);
}
.home-books { padding-top: 8px; }

.card-copy { display: grid; gap: 12px; padding: 0 8px; }
.card-sub { font-size: 14px; color: var(--ink-2); line-height: 1.45; }

/* ── Tiles ──────────────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gutter); }
.tile {
  position: relative; isolation: isolate; overflow: hidden;
  display: block; aspect-ratio: 4 / 5;
  border-radius: var(--r); background: #0b0b0b;
  color: var(--ink); text-decoration: none;
}
.tile-art {
  position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover;
  transition: transform 1s var(--ease);
}
.tile:hover .tile-art { transform: scale(1.035); }
.tile-card {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  display: grid; gap: 16px; padding: 16px 8px 8px;
}
@media (max-width: 760px) {
  .tiles { grid-template-columns: 1fr; }
}

/* ── Feed & featured entry ──────────────────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--gutter); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.panel-head { display: grid; gap: 12px; margin-bottom: 20px; }
.panel-head .label { color: var(--ink-3); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed a {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 16px; align-items: baseline;
  padding: 16px 0; border-top: 1px solid var(--line); text-decoration: none;
}
.feed-date, .feed-kind { color: var(--ink-3); }
.feed-title { font-family: var(--f-serif); font-size: 20px; line-height: 1.3; }
.feed-sub { display: block; margin-top: 3px; font-family: var(--f-sans); font-size: 13px; color: var(--ink-3); }
.feed a:hover .feed-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
@media (max-width: 560px) {
  .feed a { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .feed-date { grid-column: 1; }
  .feed-kind { grid-column: 2; grid-row: 1; }
  .feed-title { grid-column: 1 / -1; }
}

.entry-card { display: grid; gap: 14px; justify-items: start; text-decoration: none; }
.entry-card .label { color: var(--ink-3); }
.entry-art { width: 100%; aspect-ratio: 1; border-radius: 4px; overflow: hidden; background: var(--bg); }
.entry-art img { width: 100%; height: 100%; object-fit: cover; transition: transform 1s var(--ease); }
.entry-card:hover .entry-art img { transform: scale(1.03); }
.entry-summary { font-family: var(--f-serif); font-size: 17px; line-height: 1.55; color: var(--ink-2); }

/* ── Section page head ──────────────────────────────────────────────────── */

.page-head { padding: clamp(116px, 15vw, 176px) 0 clamp(40px, 6vw, 72px); }
.page-head--compact { padding: 104px 0 16px; background-size: 32px 32px; }
.page-head--compact .label { color: var(--ink-3); }
.page-head--center { text-align: center; min-height: 70svh; display: grid; align-content: center; }
.page-head--center .page-intro { margin-inline: auto; }
.page-head--center .stack-row { justify-content: center; margin-top: 32px; }
.page-head .label { color: var(--ink-2); }
.page-title {
  margin: 18px 0 0;
  font-family: var(--f-dot); font-variation-settings: "ROND" 100; font-weight: 800;
  font-size: clamp(56px, 12vw, 164px); line-height: 0.88; letter-spacing: 0.02em; text-transform: uppercase;
}
.page-title--gallery {
  font-family: "Font-Lambda-Italic", var(--f-sans); font-weight: 400;
  font-variation-settings: normal; line-height: 1; letter-spacing: 0;
}
.page-intro {
  max-width: 34em; margin: 26px 0 0;
  font-family: var(--f-serif); font-weight: 300; font-size: clamp(20px, 2.1vw, 26px); line-height: 1.35;
  color: var(--ink-2);
}

/* ── Novel: book list, book page, contents ──────────────────────────────── */

.section-head--books { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 20px; }
.section-head--books > div { display: grid; gap: 12px; }
.section-head--books p { margin: 0; }
.book-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px;
  list-style: none; margin: 0; padding: 0;
}
.book-grid > li { min-width: 0; }
.book-card { display: grid; grid-template-rows: auto 1fr; gap: 18px; height: 100%; text-decoration: none; }
.book-card-cover { display: block; aspect-ratio: 2 / 3; overflow: hidden; border-radius: var(--r); background: #080808; }
.book-card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.book-card:hover .book-card-cover img { transform: scale(1.035); }
.book-card-body { display: grid; grid-template-rows: auto 1fr auto auto; gap: 12px; padding: 0 4px; }
.book-card-number, .book-card-meta { color: var(--ink-3); }
.book-card-genres { display: block; margin-bottom: 8px; font-family: var(--f-sans); font-size: 13px; line-height: 1.5; text-transform: none; color: var(--ink-2); }
.book-card-title { margin: 0; font-family: var(--f-serif); font-weight: 300; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.2; overflow-wrap: anywhere; }
.book-card-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; }
.book-card-action > span { font-size: 18px; }
.book-card:hover .book-card-action { color: var(--accent); }
.book-coming-soon { display: grid; gap: 16px; justify-items: start; }
.book-coming-soon > p { margin: 0; }
@media (max-width: 900px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 20px; }
}
@media (max-width: 480px) {
  .book-grid { gap: 28px 12px; }
  .book-card { gap: 14px; }
  .book-card-title { font-size: 22px; }
  .book-card-number, .book-card-meta { font-size: 10px; }
}

.book-row {
  display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 32px;
  padding: 8px; text-decoration: none;
}
.book-row-cover { aspect-ratio: 2 / 3; border-radius: 4px; overflow: hidden; background: #000; }
.book-row-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 1s var(--ease); }
.book-row:hover .book-row-cover img { transform: scale(1.03); }
.book-row-body { display: grid; gap: 18px; align-content: center; justify-items: start; padding: 24px 24px 24px 0; }
.book-row-synopsis { font-family: var(--f-serif); font-size: 18px; line-height: 1.6; color: var(--ink-2); max-width: 40em; }
.book-row-meta { color: var(--ink-3); }
@media (max-width: 700px) {
  .book-row { grid-template-columns: 1fr; gap: 0; }
  .book-row-body { padding: 24px 12px 12px; }
}

.book { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: var(--gutter); align-items: stretch; }
.book-cover { aspect-ratio: 2 / 3; border-radius: var(--r); overflow: hidden; background: #000; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-info { display: grid; gap: 22px; align-content: center; justify-items: start; padding: clamp(24px, 4vw, 48px); }
.book-title {
  margin: 0;
  font-family: var(--f-serif); font-weight: 300; font-size: clamp(40px, 5.4vw, 72px); line-height: 1; letter-spacing: -0.025em;
}
.book-synopsis { font-family: var(--f-serif); font-size: 19px; line-height: 1.6; color: var(--ink-2); max-width: 36em; }
.book-synopsis p { margin: 0 0 0.8em; }
.book-synopsis p:last-child { margin-bottom: 0; }
.book .facts { width: 100%; }
.book-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 800px) {
  .book { grid-template-columns: 1fr; }
  .book-cover { max-height: 70svh; aspect-ratio: 4 / 5; }
}

.chapter-list { list-style: none; margin: 0; padding: 4px 24px; }
.chapter-list a {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 22px 0; border-top: 1px solid var(--line); text-decoration: none;
}
.chapter-list li:first-child a { border-top: 0; }
.ch-num {
  font-family: var(--f-dot); font-variation-settings: "ROND" 100; font-weight: 800; font-size: 30px; line-height: 1;
  color: var(--ink-3); transition: color 0.2s var(--ease);
}
.chapter-list a:hover .ch-num { color: var(--accent); }
.ch-title { display: block; font-family: var(--f-serif); font-size: 23px; line-height: 1.25; }
.ch-alternate-title { display: block; margin-top: 4px; font-family: var(--f-serif); font-size: 15px; line-height: 1.4; color: var(--ink-2); }
.ch-sub { display: block; margin-top: 5px; font-size: 14px; line-height: 1.45; color: var(--ink-3); }
.ch-meta { color: var(--ink-3); white-space: nowrap; }
@media (max-width: 600px) {
  .chapter-list { padding: 4px 16px; }
  .chapter-list a { grid-template-columns: 44px minmax(0, 1fr); }
  .ch-meta { grid-column: 2; }
}

/* ==========================================================================
   Reader — long-form typography for chapters and pages (Medium-inspired)
   680px measure · 20/32 serif body · sans headings · quiet chrome
   ========================================================================== */

body.mode-reader { background: var(--reader-bg); color: var(--reader-ink); }
.mode-reader .frost { --frost: color-mix(in srgb, var(--reader-bg) 82%, transparent); }

.reader {
  width: 100%; max-width: 728px; margin: 0 auto;
  padding: 128px 24px 0;
}

/* ── Head ───────────────────────────────────────────────────────────────── */

.reader-kicker { margin: 0 0 20px; color: var(--reader-ink-2); }
.reader-title {
  margin: 0;
  font-family: var(--f-sans); font-weight: 700;
  font-size: 42px; line-height: 52px; letter-spacing: -0.011em;
  color: var(--reader-ink); text-wrap: balance;
}
.reader-alternate-title {
  margin: 6px 0 0;
  font-family: var(--f-serif); font-size: 18px; line-height: 26px;
  color: var(--reader-ink-2);
}
.reader-subtitle {
  margin: 10px 0 0;
  font-family: var(--f-sans); font-weight: 400;
  font-size: 22px; line-height: 30px; letter-spacing: -0.005em;
  color: var(--reader-ink-2);
}

.byline { display: flex; align-items: center; gap: 12px; margin-top: 32px; font-size: 14px; line-height: 20px; }
.avatar {
  flex: none; position: relative; width: 44px; height: 44px; border-radius: 50%;
  background: #000;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.55) 1px, transparent 1.5px);
  background-size: 6px 6px;
}
.avatar span {
  position: absolute; inset: 0; margin: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
.byline-text { display: grid; }
.byline-name { font-weight: 500; }
.byline-meta { color: var(--reader-ink-2); }

.actionbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 28px; padding: 3px 0 3px 4px; min-height: 48px;
  border-block: 1px solid var(--reader-line);
  color: var(--reader-ink-2);
}
.actionbar-right { display: flex; gap: 2px; }
.actionbar .icon-btn { color: var(--reader-ink-2); }
.actionbar .icon-btn:hover { color: var(--reader-ink); }
.icon-btn.is-done { color: var(--accent) !important; }

/* ── Body ───────────────────────────────────────────────────────────────── */

.prose {
  margin-top: 40px;
  font-family: var(--f-serif);
  font-size: 20px; line-height: 32px; letter-spacing: -0.003em;
  color: var(--reader-ink);
  overflow-wrap: break-word;
  font-optical-sizing: auto;
}
.prose > * { margin: 0; }
.prose > * + * { margin-top: 1.56em; }
/* A new line in the Markdown file is a new line on the page (places, dates, verse) */
.prose p { white-space: pre-line; }

.prose h2, .prose h3, .prose h4 {
  font-family: var(--f-sans); font-weight: 700; color: var(--reader-ink); letter-spacing: -0.016em;
}
.prose h2 { font-size: 24px; line-height: 30px; margin-top: 2.2em; }
.prose h3 { font-size: 20px; line-height: 24px; margin-top: 2em; }
.prose h4 { font-size: 17px; line-height: 22px; margin-top: 1.8em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0.6em; }

.prose a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a.wikilink { text-decoration-style: dotted; text-decoration-color: var(--reader-ink-2); }
.prose a.wikilink:hover { text-decoration-style: solid; text-decoration-color: var(--accent); }
.prose a.wikilink.new { text-decoration: none; cursor: text; }

.prose strong { font-weight: 700; }
.prose em { font-style: italic; }

.prose ul, .prose ol { padding-left: 30px; }
.prose li { padding-left: 4px; }
.prose li + li { margin-top: 0.7em; }

.prose blockquote {
  padding-left: 20px; margin-left: -23px;
  box-shadow: inset 3px 0 0 0 var(--reader-ink);
  font-style: italic;
}
.prose blockquote p + p { margin-top: 1.2em; }
.prose blockquote p { margin: 0; }
/* > text {.pull} → large pull quote */
.prose blockquote:has(> p.pull) { box-shadow: none; margin-left: 0; padding-left: 30px; }
.prose p.pull { font-size: 28px; line-height: 40px; color: var(--reader-ink-2); }

.prose hr {
  border: 0; height: auto; margin-block: 2.6em !important; text-align: center; overflow: visible;
}
.prose hr::before {
  content: "···"; display: inline-block;
  font-family: var(--f-serif); font-size: 30px; line-height: 1; letter-spacing: 0.6em; padding-left: 0.6em;
  color: var(--reader-ink);
}

.prose code { padding: 2px 4px; border-radius: 3px; background: var(--reader-line); font-size: 15px; }
.prose pre { padding: 20px; border-radius: 4px; background: var(--reader-line); overflow-x: auto; font-size: 15px; line-height: 1.5; }
.prose pre code { padding: 0; background: none; }

.prose table { width: 100%; border-collapse: collapse; font-family: var(--f-sans); font-size: 15px; line-height: 1.5; }
.prose th, .prose td { padding: 10px 12px; border-bottom: 1px solid var(--reader-line); text-align: left; }

/* Drop cap in dot-matrix — the Nothing accent inside the Medium page */
.prose.dropcap > p:first-of-type::first-letter {
  float: left;
  margin: 7px 12px 0 -2px;
  font-family: var(--f-dot); font-variation-settings: "ROND" 100; font-weight: 900;
  font-size: 100px; line-height: 0.7;
  color: var(--reader-ink);
}

/* Figures: ![alt](src "caption"){.wide} / {.full} */
.prose figure { margin-top: 2.2em; margin-bottom: 0.4em; }
.prose figure + * { margin-top: 2em; }
.prose figure img { width: 100%; }
.prose figcaption {
  margin-top: 10px; text-align: center;
  font-family: var(--f-sans); font-size: 14px; line-height: 20px; color: var(--reader-ink-2);
}
.prose figure.wide { width: min(1040px, 100vw - 48px); margin-left: 50%; transform: translateX(-50%); }
.prose figure.full { width: 100vw; margin-left: 50%; transform: translateX(-50%); }
.prose figure.full figcaption { padding-inline: 24px; }
.prose figure.yt .yt-embed { border-radius: 2px; }

/* ── Notes & end matter ─────────────────────────────────────────────────── */

.reader-notes {
  margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--reader-line);
  font-family: var(--f-sans); font-size: 14px; line-height: 1.6; color: var(--reader-ink-2);
}
.reader-notes h2 { margin: 0 0 8px; }
.reader-notes ol { padding-left: 20px; margin: 0; }
.reader-notes li p { margin: 0; }
.reader-notes a { color: inherit; }
.prose sup a.footnote-ref { color: var(--accent); text-decoration: none; font-family: var(--f-sans); font-size: 12px; padding: 0 1px; }

.reader-end { width: 100%; max-width: 728px; margin: 0 auto; padding: 56px 24px 0; display: grid; gap: 40px; }
.reader-entries { padding-top: 32px; border-top: 1px solid var(--reader-line); }
.reader-entries h2 { margin: 0 0 8px; color: var(--reader-ink-2); }
.reader-entries-intro { margin: 0 0 16px; font-size: 15px; color: var(--reader-ink-2); }
.mode-reader .chip { border-color: var(--reader-line); background: var(--reader-line); }
.mode-reader .chip:hover { border-color: var(--reader-ink); }

.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gutter); }
.chapter-nav-link {
  display: grid; gap: 12px; align-content: start; min-height: 132px;
  background: var(--bg); color: var(--ink); text-decoration: none;
  transition: background-color 0.2s var(--ease);
}
.mode-reader .chapter-nav-link { background: color-mix(in srgb, var(--reader-ink) 4%, var(--reader-bg)); color: var(--reader-ink); }
.chapter-nav-link .label { display: inline-flex; align-items: center; gap: 6px; color: var(--reader-ink-2); }
.chapter-nav-link .label .icon { width: 14px; height: 14px; }
.chapter-nav-link--next { text-align: right; justify-items: end; }
.chapter-alternate-title { font-family: var(--f-serif); font-size: 15px; line-height: 1.4; color: var(--reader-ink-2); }
.chapter-nav-link:hover .headline { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }

@media (max-width: 728px) {
  .reader { padding-top: 104px; }
  .reader-title { font-size: 32px; line-height: 40px; }
  .reader-subtitle { font-size: 20px; line-height: 28px; }
  .prose { font-size: 18px; line-height: 28px; }
  .prose blockquote { margin-left: 0; }
  .prose p.pull { font-size: 24px; line-height: 34px; }
  .prose.dropcap > p:first-of-type::first-letter { font-size: 74px; }
  .chapter-nav { grid-template-columns: 1fr; }
}

/* ==========================================================================
   The Archive — encyclopedia layout (Wikipedia / Vector 2022-inspired)
   ========================================================================== */

body.mode-wiki { background: var(--wiki-bg); color: var(--wiki-ink); }
.mode-wiki .frost { --frost: color-mix(in srgb, var(--wiki-bg) 84%, transparent); }

/* ── Archive header ─────────────────────────────────────────────────────── */

.wiki-top { padding: 72px 0 0; }
.wiki-top-inner {
  max-width: 1400px; margin: 0 auto; padding: 12px 24px;
  display: grid; grid-template-columns: auto minmax(0, 560px) 1fr; align-items: center; gap: 12px 32px;
}
.wiki-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--wiki-ink); }
.wiki-brand-mark {
  flex: none; position: relative; width: 44px; height: 44px; border-radius: 50%;
  background-color: var(--wiki-ink);
  background-image: radial-gradient(circle, color-mix(in srgb, var(--wiki-bg) 60%, transparent) 1px, transparent 1.5px);
  background-size: 6px 6px;
}
.wiki-brand-mark::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
.wiki-brand-text { display: grid; line-height: 1.15; }
.wiki-brand-name {
  font-family: var(--f-wiki-serif); font-size: 21px; letter-spacing: 0.08em; font-variant: small-caps; text-transform: lowercase;
}
.wiki-brand-name::first-letter { text-transform: uppercase; }
.wiki-brand-tag { font-family: var(--f-wiki-serif); font-size: 12.5px; color: var(--wiki-ink-2); }

.wiki-search { display: flex; min-width: 0; }
.wiki-search-field { position: relative; flex: 1; min-width: 0; }
.wiki-search-field .icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--wiki-ink-2);
  pointer-events: none;
}
.wiki-search input {
  width: 100%; height: 36px; padding: 0 10px 0 36px;
  border: 1px solid var(--wiki-border); border-right: 0; border-radius: 2px 0 0 2px;
  background: var(--wiki-bg); color: var(--wiki-ink);
  font-family: var(--f-wiki-sans); font-size: 14px;
}
.wiki-search input:focus { outline: 0; border-color: var(--wiki-link); box-shadow: inset 0 0 0 1px var(--wiki-link); }
.wiki-btn {
  height: 36px; padding: 0 14px;
  border: 1px solid var(--wiki-border); border-radius: 0 2px 2px 0;
  background: var(--wiki-box); color: var(--wiki-ink);
  font-family: var(--f-wiki-sans); font-size: 14px; font-weight: 700; cursor: pointer;
}
.wiki-btn:hover { background: var(--wiki-bg); }

.wiki-suggest {
  position: absolute; left: 0; right: -70px; top: calc(100% + 2px); z-index: 30;
  list-style: none; margin: 0; padding: 0;
  background: var(--wiki-bg); border: 1px solid var(--wiki-border); border-radius: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.wiki-suggest a {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 2px 10px; align-items: center;
  padding: 8px 12px; text-decoration: none; color: var(--wiki-ink);
}
.wiki-suggest a[aria-selected="true"], .wiki-suggest a:hover { background: var(--wiki-head); }
.wiki-suggest .sg-thumb {
  grid-row: span 2; width: 36px; height: 36px; border-radius: 2px; overflow: hidden;
  background: var(--wiki-box); border: 1px solid var(--wiki-border-soft);
}
.wiki-suggest .sg-thumb img { width: 100%; height: 100%; object-fit: cover; }
.wiki-suggest .sg-title { font-weight: 700; font-size: 14px; }
.wiki-suggest .sg-desc { font-size: 12.5px; color: var(--wiki-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-suggest .sg-empty { padding: 10px 12px; font-size: 13px; color: var(--wiki-ink-2); }

.wiki-top-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; font-family: var(--f-wiki-sans); font-size: 14px; }
.wiki-top-links a { color: var(--wiki-link); text-decoration: none; }
.wiki-top-links a:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .wiki-top-inner { grid-template-columns: auto minmax(0, 1fr); }
  .wiki-top-links { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 640px) {
  .wiki-top-inner { grid-template-columns: 1fr; padding: 8px 16px; }
  .wiki-suggest { right: 0; }
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.wiki-layout {
  max-width: 1400px; margin: 0 auto; padding: 8px 24px 0;
  display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); column-gap: 32px;
  font-family: var(--f-wiki-sans);
}
.wiki-layout--full { grid-template-columns: minmax(0, 1fr); }

/* Contents sidebar */
.wiki-toc {
  position: sticky; top: 72px; align-self: start;
  max-height: calc(100svh - 88px); overflow: auto;
  padding: 18px 0 24px; font-size: 14px;
}
.wiki-toc summary {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--wiki-border-soft);
  font-weight: 700; cursor: pointer; list-style: none;
}
.wiki-toc summary::-webkit-details-marker { display: none; }
.wiki-toc summary::after { content: "hide"; font-weight: 400; color: var(--wiki-link); font-size: 13px; }
.wiki-toc:not([open]) summary::after { content: "show"; }
.wiki-toc ul { list-style: none; margin: 0; padding: 0; }
.wiki-toc ul ul { padding-left: 12px; }
.wiki-toc a {
  display: block; padding: 4px 0 4px 8px; margin-left: -8px; border-left: 2px solid transparent;
  color: var(--wiki-link); text-decoration: none; line-height: 1.4;
}
.wiki-toc a:hover { text-decoration: underline; }
.wiki-toc a.is-active { color: var(--wiki-ink); font-weight: 700; border-left-color: var(--wiki-ink); }

@media (max-width: 1000px) {
  .wiki-layout { grid-template-columns: minmax(0, 1fr); }
  .wiki-toc {
    position: static; max-height: none; order: 2;
    margin: 12px 0 0; padding: 10px 14px;
    border: 1px solid var(--wiki-border-soft); border-radius: 2px; background: var(--wiki-box);
  }
  .wiki-toc:not([open]) summary { border-bottom: 0; margin: 0; padding: 0; }
  .wiki-main { display: contents; }
  .wiki-head { order: 1; }
  .wiki-body { order: 3; }
  .wiki-foot { order: 4; }
}

/* ── Title & tabs ───────────────────────────────────────────────────────── */

.wiki-main { min-width: 0; }
.wiki-head { padding-top: 16px; }
.wiki-h1 {
  margin: 0; padding-bottom: 6px;
  font-family: var(--f-wiki-serif); font-weight: 400;
  font-size: 1.8em; line-height: 1.375; color: var(--wiki-ink);
  border-bottom: 1px solid var(--wiki-border);
}
.wiki-ns { color: var(--wiki-ink-2); }
.wiki-tabs {
  display: flex; justify-content: space-between; gap: 16px;
  font-size: 14px; border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-tabs-group { display: flex; gap: 2px; }
.wiki-tabs a, .wiki-tabs span.is-selected {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 8px 8px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--wiki-link); text-decoration: none;
}
.wiki-tabs a:hover { border-bottom-color: var(--wiki-link); }
.wiki-tabs .is-selected { color: var(--wiki-ink) !important; border-bottom-color: var(--wiki-ink) !important; }
.wiki-count {
  padding: 1px 6px; border-radius: 10px; background: var(--wiki-head); color: var(--wiki-ink-2); font-size: 12px;
}

/* ── Body text ──────────────────────────────────────────────────────────── */

.wiki-body {
  font-size: 14px; line-height: 1.6; color: var(--wiki-ink);
  padding-top: 8px;
}
.wiki-body::after { content: ""; display: block; clear: both; }
.wiki-body p { margin: 0.5em 0 0.9em; }
.wiki-tagline { margin: 0 0 4px !important; font-size: 12.8px; color: var(--wiki-ink-2); }
.wiki-shortdesc { display: none; }
.hatnote { margin: 0 0 0.6em; padding-left: 1.6em; font-style: italic; }
.hatnote a { font-style: normal; }

.wiki-body a { color: var(--wiki-link); text-decoration: none; }
.wiki-body a:visited { color: var(--wiki-link-visited); }
.wiki-body a:hover { text-decoration: underline; }
.wiki-body a.new, .wiki-body a.new:visited { color: var(--wiki-new); cursor: help; }
.wiki-body .selflink { font-weight: 700; }

.wiki-body h2, .wiki-body h3, .wiki-body h4 { color: var(--wiki-ink); overflow: hidden; }
.wiki-body h2 {
  margin: 1.1em 0 0.25em; padding: 0 0 2px;
  font-family: var(--f-wiki-serif); font-weight: 400; font-size: 1.5em; line-height: 1.375;
  border-bottom: 1px solid var(--wiki-border);
}
.wiki-body h3 { margin: 0.9em 0 0.3em; font-size: 1.2em; font-weight: 700; line-height: 1.6; }
.wiki-body h4 { margin: 0.8em 0 0.3em; font-size: 1em; font-weight: 700; }

.wiki-body ul, .wiki-body ol { margin: 0.3em 0 0.8em 1.6em; padding: 0; }
.wiki-body ul { list-style: square; }
.wiki-body li { margin-bottom: 0.1em; }
.wiki-body li::marker { color: var(--wiki-ink-2); }
.wiki-body dl { margin: 0.3em 0 0.8em; }
.wiki-body dt { font-weight: 700; }
.wiki-body dd { margin-left: 1.6em; margin-bottom: 0.2em; }
.wiki-body blockquote {
  margin: 1em 0; padding: 0 1.6em; border-left: 4px solid var(--wiki-border-soft);
  font-family: var(--f-wiki-serif); font-size: 1.05em;
}
.wiki-body code { padding: 1px 4px; border: 1px solid var(--wiki-border-soft); border-radius: 2px; background: var(--wiki-box); }
.wiki-body hr { border: 0; border-top: 1px solid var(--wiki-border); margin: 1em 0; }

/* "wikitable" — any Markdown table */
.wiki-body table:not(.infobox):not(.navbox) {
  margin: 1em 0; border-collapse: collapse; border: 1px solid var(--wiki-border);
  background: var(--wiki-box); color: var(--wiki-ink);
}
.wiki-body table:not(.infobox):not(.navbox) th,
.wiki-body table:not(.infobox):not(.navbox) td { padding: 0.2em 0.4em; border: 1px solid var(--wiki-border); }
.wiki-body table:not(.infobox):not(.navbox) th { background: var(--wiki-head); text-align: center; }

/* ── Infobox ────────────────────────────────────────────────────────────── */

.infobox {
  float: right; clear: right; width: 22em;
  margin: 0.5em 0 1em 1.4em; padding: 0.2em;
  border: 1px solid var(--wiki-border); border-spacing: 3px;
  background: var(--wiki-box); color: var(--wiki-ink);
  font-size: 88%; line-height: 1.5em;
}
.infobox-title { padding: 0.2em; font-size: 125%; font-weight: 700; text-align: center; line-height: 1.3; }
.infobox-subtitle { display: block; font-size: 80%; font-weight: 400; color: var(--wiki-ink-2); }
.infobox-image { padding: 0.2em 0 0.4em; text-align: center; }
.infobox-image img { margin: 0 auto; max-width: 100%; }
.infobox-caption { padding-top: 0.3em; font-size: 95%; line-height: 1.4; }
.infobox-header {
  padding: 0.2em 0.4em; text-align: center; font-weight: 700;
  background: var(--ib, var(--mp-blue));
}
:root[data-theme="dark"] .infobox-header { background: color-mix(in srgb, var(--ib, #cedff2) 22%, var(--wiki-bg)); }
.infobox-label { padding: 0.1em 0.6em 0.1em 0.1em; text-align: left; vertical-align: top; font-weight: 700; white-space: nowrap; }
.infobox-data { padding: 0.1em; vertical-align: top; }
.infobox-full { text-align: center; }

/* ── Thumbnails (images in the Archive float right like Wikipedia) ─────── */

.wiki-body figure.thumb {
  float: right; clear: right; width: 222px;
  margin: 0.5em 0 1.3em 1.4em; padding: 3px;
  border: 1px solid var(--wiki-border-soft); background: var(--wiki-box);
}
.wiki-body figure.thumb img { width: 100%; border: 1px solid var(--wiki-border-soft); background: var(--wiki-bg); }
.wiki-body figure.thumb figcaption { padding: 4px 3px 2px; font-size: 12.5px; line-height: 1.4; }
.wiki-body figure.thumb.left { float: left; clear: left; margin: 0.5em 1.4em 1.3em 0; }
.wiki-body figure.thumb.upright { width: 172px; }
.wiki-body figure.thumb.large { width: 322px; }
.wiki-body figure.thumb.center, .wiki-body figure.thumb.wide { float: none; clear: both; margin: 1em auto; }
.wiki-body figure.thumb.center { width: fit-content; max-width: 100%; }
.wiki-body figure.thumb.wide { width: 100%; }
.wiki-body figure.yt { clear: both; max-width: 640px; margin: 1em 0 1.3em; padding: 3px; border: 1px solid var(--wiki-border-soft); background: var(--wiki-box); }
.wiki-body figure.yt figcaption { padding: 4px 3px 2px; font-size: 12.5px; }
.wiki-body figure.yt .yt-embed { border-radius: 0; }

@media (max-width: 720px) {
  .infobox { float: none; width: 100%; margin: 0.5em 0 1em; }
  .wiki-body figure.thumb, .wiki-body figure.thumb.left { float: none; width: 100%; margin: 1em 0; }
}

/* ── References ─────────────────────────────────────────────────────────── */

.wiki-body sup { line-height: 1; }
.wiki-body a.footnote-ref { font-size: 0.8em; white-space: nowrap; }
.wiki-body a.footnote-ref::before { content: "["; }
.wiki-body a.footnote-ref::after { content: "]"; }
.reflist { font-size: 90%; }
.reflist ol { margin-left: 2.2em; list-style: decimal; }
.reflist li p { margin: 0; }
.reflist li:target { background: color-mix(in srgb, var(--wiki-link) 14%, transparent); }
.reflist .footnote-backref { font-weight: 700; }

/* ── Appearances, navbox, categories ────────────────────────────────────── */

.appearances { list-style: none !important; margin-left: 0 !important; }
.appearances li { padding: 2px 0; }
.ap-kind {
  display: inline-block; min-width: 64px; margin-right: 6px; padding: 0 6px;
  border: 1px solid var(--wiki-border-soft); border-radius: 2px; background: var(--wiki-box);
  font-size: 11.5px; text-align: center; color: var(--wiki-ink-2);
}
.ap-context { color: var(--wiki-ink-2); }
.wiki-linkshere { font-size: 92%; color: var(--wiki-ink-2); }

.hlist { display: inline; list-style: none !important; margin: 0 !important; padding: 0; }
.hlist li { display: inline; margin: 0 !important; }
.hlist li:not(:last-child)::after { content: " · "; font-weight: 700; }
.hlist--bar li:not(:last-child)::after { content: " | "; font-weight: 400; color: var(--wiki-ink-2); }
.hlist--dot li { white-space: nowrap; }

.navbox {
  clear: both; width: 100%; margin: 1.6em 0 0;
  border: 1px solid var(--wiki-border); border-spacing: 2px; padding: 2px;
  background: var(--wiki-bg); font-size: 88%; line-height: 1.6;
}
.navbox + .navbox { margin-top: -1px; }
.navbox-title { padding: 0.25em 1em; background: var(--navbox-title); text-align: center; font-size: 114%; }
.navbox-group { width: 1%; padding: 0.25em 1em; background: var(--navbox-group); text-align: right; white-space: nowrap; }
.navbox-list { padding: 0.25em 0.5em; background: var(--wiki-bg); }
.navbox tr:nth-child(odd) .navbox-list { background: var(--wiki-box); }

.catlinks {
  clear: both; margin-top: 1em; padding: 5px 8px;
  border: 1px solid var(--wiki-border); background: var(--wiki-box); font-size: 88%;
}

.wiki-foot {
  clear: both; margin-top: 24px; padding: 12px 0; border-top: 1px solid var(--wiki-border-soft);
  font-size: 12px; color: var(--wiki-ink-2);
}
.wiki-foot p { margin: 0.2em 0; }

/* ── Main page ──────────────────────────────────────────────────────────── */

.mp-welcome {
  margin: 12px 0 10px; padding: 16px 20px 18px;
  border: 1px solid var(--wiki-border); background: var(--wiki-box); text-align: center;
}
.mp-welcome-title { margin: 0 !important; padding: 0 !important; border: 0 !important; font-size: 28px !important; font-family: var(--f-wiki-serif); font-weight: 400 !important; }
.mp-welcome-sub { margin: 2px 0 8px !important; font-size: 15px; }
.mp-welcome-count { margin: 0 !important; font-size: 13px; color: var(--wiki-ink-2); }

.mp-cols { display: grid; grid-template-columns: minmax(0, 55fr) minmax(0, 45fr); gap: 10px; align-items: start; }
.mp-col { display: grid; gap: 10px; }
@media (max-width: 900px) { .mp-cols { grid-template-columns: 1fr; } }

.mp-box { border: 1px solid var(--edge); background: var(--wiki-bg); }
.mp-box--green { --head: var(--mp-green); --edge: var(--mp-green-edge); }
.mp-box--blue { --head: var(--mp-blue); --edge: var(--mp-blue-edge); }
.mp-box--grey { --head: var(--wiki-head); --edge: var(--wiki-border); margin-top: 10px; }
.mp-h2 {
  margin: 3px !important; padding: 0.2em 0.4em !important;
  border: 1px solid var(--edge) !important; background: var(--head);
  font-family: var(--f-wiki-serif) !important; font-size: 120% !important; font-weight: 700 !important; line-height: 1.4 !important;
}
.mp-box-body { padding: 0.2em 0.6em 0.4em; }
.mp-box-body::after { content: ""; display: block; clear: both; }
.mp-box-body ul { margin: 0.4em 0 0.4em 1.4em; }
.mp-box-body li { margin-bottom: 0.3em; }
.mp-thumb { float: left; width: 120px; margin: 0.5em 0.9em 0.4em 0; border: 1px solid var(--wiki-border-soft); }
.mp-thumb img { width: 100%; }
.mp-date { color: var(--wiki-ink-2); font-size: 92%; }
.mp-elsewhere { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; padding: 0.6em; }
.mp-elsewhere a { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--wiki-border-soft); background: var(--wiki-box); }
.mp-elsewhere span { color: var(--wiki-ink-2); font-size: 13px; }

/* ── Index & category pages ─────────────────────────────────────────────── */

.mw-category { columns: 3 18em; column-gap: 2em; margin-top: 1em; }
.mw-category-group { break-inside: avoid; margin-bottom: 1em; }
.mw-category-group h3 { margin: 0 0 0.2em !important; font-size: 1.1em !important; }
.mw-category-group ul { list-style: square; margin: 0 0 0 1.4em; }
.mw-desc { color: var(--wiki-ink-2); font-size: 92%; }
.mw-catlist { columns: 2 16em; }

/* ==========================================================================
   Media — gallery, lightbox, films, YouTube embeds, search, link previews
   ========================================================================== */

/* ── Gallery ────────────────────────────────────────────────────────────── */

.masonry { columns: 3 300px; column-gap: var(--gutter); list-style: none; margin: 16px 0 0; padding: 0; }
.work { break-inside: avoid; margin: 0 0 var(--gutter); padding: 8px; border-radius: var(--r); background: var(--surface); }
.work[hidden] { display: none; }
.work-btn {
  display: block; width: 100%; padding: 0; border: 0; border-radius: 4px; overflow: hidden;
  background: var(--bg); cursor: zoom-in;
}
.work-btn img { width: 100%; transition: transform 0.8s var(--ease); }
.work-btn:hover img { transform: scale(1.025); }
.work-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: baseline; padding: 14px 6px 6px; }
.work-id { color: var(--ink-3); }
.work-title { font-family: var(--f-serif); font-size: 18px; line-height: 1.25; }
.work-medium { grid-column: 2; color: var(--ink-3); }

/* ── Lightbox ───────────────────────────────────────────────────────────── */

.lightbox {
  width: 100vw; height: 100svh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(8, 8, 8, 0.96); color: #fff;
}
.lightbox::backdrop { background: rgba(0, 0, 0, 0.5); }
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.lb-stage { display: grid; place-items: center; min-height: 0; padding: 64px 72px 16px; }
.lb-stage img { max-width: 100%; max-height: calc(100svh - 300px); width: auto; height: auto; object-fit: contain; border-radius: 4px; }
.lb-panel {
  --frost: rgba(34, 34, 34, 0.82); --ink: #fff; --ink-2: #c9c9c9; --ink-3: #8a8a8a; --line-strong: #444;
  width: min(760px, calc(100% - 16px)); margin: 0 auto 8px; padding: 18px 16px 16px;
  display: grid; gap: 10px;
  background: var(--frost); -webkit-backdrop-filter: blur(45px); backdrop-filter: blur(45px); border-radius: var(--r);
}
.lb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.lb-count, .lb-meta { margin: 0; color: var(--ink-3); }
.lb-desc { font-family: var(--f-serif); font-size: 16px; line-height: 1.55; color: var(--ink-2); max-height: 7.5em; overflow: auto; }
.lb-desc p { margin: 0 0 0.6em; }
.lb-desc a { color: #fff; }
.lb-btn { position: absolute; color: #fff; background: rgba(40, 40, 40, 0.7); }
.lb-btn:hover { background: rgba(70, 70, 70, 0.9); }
.lb-close { top: 12px; right: 12px; }
.lb-prev, .lb-next { top: calc(50% - 120px); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
@media (max-width: 700px) {
  .lb-stage { padding: 56px 8px 8px; }
  .lb-prev, .lb-next { top: auto; bottom: 12px; }
  .lb-panel { margin-bottom: 64px; }
}

/* ── Films ──────────────────────────────────────────────────────────────── */

.films { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gutter); }
.film { display: grid; gap: 4px; align-content: start; padding: 8px; border-radius: var(--r); background: var(--surface); }
.film--feature { grid-column: 1 / -1; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px; }
.film-card { display: grid; gap: 12px; align-content: start; justify-items: start; padding: 16px 12px 12px; }
.film--feature .film-card { padding: 20px 16px; }
.film-meta { margin: 0; color: var(--ink-3); }
.film-desc { font-family: var(--f-serif); font-size: 16.5px; line-height: 1.6; color: var(--ink-2); }
.film-desc p { margin: 0 0 0.7em; }
.film-desc p:last-child { margin: 0; }
.film-desc a { color: var(--ink); }
@media (max-width: 860px) {
  .films { grid-template-columns: 1fr; }
  .film--feature { grid-template-columns: 1fr; }
}

/* Click-to-load YouTube (no YouTube request until play) */
.yt-embed { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 4px; background: #000; }
.yt-embed img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s var(--ease), opacity 0.3s; }
.yt-embed:hover img { transform: scale(1.02); opacity: 0.9; }
.yt-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-play {
  position: absolute; inset: 0; margin: auto; width: max-content; height: 44px;
  display: inline-flex; align-items: center; gap: 10px; padding: 0 18px 0 16px;
  border: 0; border-radius: var(--r-sm); cursor: pointer;
  background: rgba(255, 255, 255, 0.82); color: #000;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  transition: background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.yt-embed:hover .yt-play { background: #fff; transform: scale(1.04); }
.yt-play .rec { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

/* ── Search overlay ─────────────────────────────────────────────────────── */

.search-dlg {
  width: min(640px, calc(100% - 16px)); max-width: none; max-height: calc(100svh - 96px);
  margin: 72px auto auto; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible;
}
.search-dlg::backdrop { background: rgba(0, 0, 0, 0.32); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.search-panel {
  padding: 6px; border-radius: var(--r);
  background: var(--surface); box-shadow: 0 24px 80px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--line);
  font-family: var(--f-sans);
}
.search-row { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--line); }
.search-row .icon { color: var(--ink-3); }
.search-row input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font-family: var(--f-serif); font-weight: 300; font-size: 22px; color: var(--ink);
}
.search-row input::-webkit-search-cancel-button { display: none; }
.search-esc { padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: none; color: var(--ink-3); cursor: pointer; }
.search-results { list-style: none; margin: 0; padding: 6px 0; max-height: min(58svh, 520px); overflow: auto; }
.search-results:empty { display: none; }
.search-results a {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 4px 12px; align-items: baseline;
  padding: 12px 12px; border-radius: var(--r-sm); text-decoration: none;
}
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--hover); }
.sr-kind { color: var(--ink-3); }
.sr-title { font-family: var(--f-serif); font-size: 19px; line-height: 1.3; }
.sr-desc {
  grid-column: 2; font-size: 13px; line-height: 1.45; color: var(--ink-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-empty { padding: 20px 14px; color: var(--ink-3); font-size: 14px; }
.search-hint { margin: 0; padding: 10px 14px 8px; color: var(--ink-3); border-top: 1px solid var(--line); }

/* ── Link previews (hover a [[link]]) ───────────────────────────────────── */

.preview {
  position: absolute; z-index: 80; width: 340px; overflow: hidden;
  border-radius: var(--r); background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--line);
  font-family: var(--f-sans); text-align: left;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
}
.preview.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.preview-img { display: block; height: 150px; background: #000; }
.preview-img img { width: 100%; height: 100%; object-fit: cover; }
.preview-body { display: grid; gap: 8px; padding: 16px 16px 14px; }
.preview-kind { color: var(--ink-3); }
.preview-title { font-family: var(--f-serif); font-size: 21px; line-height: 1.2; }
.preview-text {
  margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
}
.preview-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-top: 1px solid var(--line); color: var(--ink-3); text-decoration: none;
}
.preview-foot:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
