/* ==========================================================================
   Nytheria Wiki – stylesheet
   Pixel-art look taken from the pack artwork: gold frames, sky blue,
   lavender, deep night blue, golden yellow and plum.
   Sections: fonts · tokens · base · layout · header · sidebar · content ·
   components · home · mod list · mod page · search · footer · responsive
   ========================================================================== */

/* ---------- Fonts (Pixelify Sans, SIL OFL 1.1 – see ../fonts/PixelifySans-OFL.txt) ---------- */
@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/pixelify-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/pixelify-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Silkscreen (SIL OFL 1.1 – see ../fonts/Silkscreen-OFL.txt): small caps labels and buttons.
   Its digits are hard to read (a "4" looks like a flag), so the unicode-range leaves out
   0-9 (U+0030-0039): digits in Silkscreen text fall back to Pixelify Sans automatically. */
@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/silkscreen-latin.woff2") format("woff2");
  unicode-range: U+0000-002F, U+003A-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: "Silkscreen";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/silkscreen-bold-latin.woff2") format("woff2");
  unicode-range: U+0000-002F, U+003A-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}

/* ---------- Design tokens ---------- */
:root {
  /* brand colours (same in both themes) */
  --gold: #ffd852;
  --gold-2: #e0a324;
  --brown: #92501f;
  --plum: #bc71c2;
  --plum-deep: #7b3148;
  --sky: #74abcc;
  --lavender: #bbcef3;

  --font-pixel: "Pixelify Sans", "Trebuchet MS", system-ui, sans-serif; /* headings */
  --font-label: "Silkscreen", "Pixelify Sans", "Trebuchet MS", monospace; /* small caps labels and buttons (digits come from Pixelify Sans) */
  --font-num: "Pixelify Sans", "Trebuchet MS", system-ui, sans-serif; /* numbers: key figures, counters */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;

  --header-h: 64px;
  --sidebar-w: 272px;
  --toc-w: 224px;
  --article-w: 800px;
  --radius: 0px;
  --px: 2px; /* one "art pixel" */
  --frame: url("frame.svg");

  --notch: polygon(
    var(--px) 0, calc(100% - var(--px)) 0, calc(100% - var(--px)) var(--px), 100% var(--px),
    100% calc(100% - var(--px)), calc(100% - var(--px)) calc(100% - var(--px)),
    calc(100% - var(--px)) 100%, var(--px) 100%, var(--px) calc(100% - var(--px)),
    0 calc(100% - var(--px)), 0 var(--px), var(--px) var(--px));

  /* light theme (default values; dark theme overrides below) */
  color-scheme: light;
  --bg: #eaf0fa;
  --bg-2: #dfe7f5;
  --surface: #fbfcff;
  --surface-2: #eef1fb;
  --surface-3: #e2e7f6;
  --border: #b9c3e0;
  --border-strong: #8190bd;
  --text: #1a1f36;
  --text-2: #3b4263;
  --muted: #535b7d;
  --link: #1d5a8c;
  --link-hover: #6a2c7c;
  --accent: #5b3b9c;
  --accent-soft: #e6defb;
  --heading: #2a2152;
  --title-solid: #4f2463;
  --title-shadow: 2px 2px 0 rgba(188, 113, 194, .35);
  --nav-title: #8a4a12;
  --shadow: #2a2152;
  --hard-shadow: 4px 4px 0 rgba(42, 33, 82, .18);
  --code-bg: #1d2340;
  --code-text: #e6e9f7;
  --inline-code-bg: #e3e6f5;
  --header-bg: rgba(251, 252, 255, .92);
  --overlay: rgba(20, 24, 48, .55);
  --focus: #6a2c7c;
  --mark: #ffe58a;

  --tip: #1f7a5a;     --tip-bg: #e3f5ee;
  --note: #1d5a8c;    --note-bg: #e3eefa;
  --warn: #9a3412;    --warn-bg: #fdeee2;
  --lore-text: #4a3316; --lore-bg: #f8eed6;
  --ny: #6a2c7c;      --ny-bg: #f3e7f7;
}

/* Dark theme: default when the OS prefers dark, unless the reader picked light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1329;
    --bg-2: #141a35;
    --surface: #1a2042;
    --surface-2: #212850;
    --surface-3: #2a3261;
    --border: #36407a;
    --border-strong: #5563a6;
    --text: #e9ecf8;
    --text-2: #c9cfe9;
    --muted: #a7b0d6;
    --link: #9fcdf0;
    --link-hover: #e2c8f7;
    --accent: #c3b2f6;
    --accent-soft: #2e2c5e;
    --heading: #f2eefe;
    --title-solid: #f2cf4a;
    --title-shadow: 3px 3px 0 #7b3148;
    --nav-title: #f0c95a;
    --shadow: #05060f;
    --hard-shadow: 4px 4px 0 rgba(3, 4, 12, .6);
    --code-bg: #0b0e20;
    --code-text: #e6e9f7;
    --inline-code-bg: #262e5a;
    --header-bg: rgba(15, 19, 41, .9);
    --overlay: rgba(4, 6, 16, .7);
    --focus: #ffd852;
    --mark: #6b5310;

    --tip: #7fe0b8;     --tip-bg: #13302e;
    --note: #9fcdf0;    --note-bg: #152a48;
    --warn: #ffb68a;    --warn-bg: #3a1f1c;
    --lore-text: #f3e2bd; --lore-bg: #2b2233;
    --ny: #e6b3ef;      --ny-bg: #2e1f45;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1329;
  --bg-2: #141a35;
  --surface: #1a2042;
  --surface-2: #212850;
  --surface-3: #2a3261;
  --border: #36407a;
  --border-strong: #5563a6;
  --text: #e9ecf8;
  --text-2: #c9cfe9;
  --muted: #a7b0d6;
  --link: #9fcdf0;
  --link-hover: #e2c8f7;
  --accent: #c3b2f6;
  --accent-soft: #2e2c5e;
  --heading: #f2eefe;
  --title-solid: #f2cf4a;
  --title-shadow: 3px 3px 0 #7b3148;
  --nav-title: #f0c95a;
  --shadow: #05060f;
  --hard-shadow: 4px 4px 0 rgba(3, 4, 12, .6);
  --code-bg: #0b0e20;
  --code-text: #e6e9f7;
  --inline-code-bg: #262e5a;
  --header-bg: rgba(15, 19, 41, .9);
  --overlay: rgba(4, 6, 16, .7);
  --focus: #ffd852;
  --mark: #6b5310;

  --tip: #7fe0b8;     --tip-bg: #13302e;
  --note: #9fcdf0;    --note-bg: #152a48;
  --warn: #ffb68a;    --warn-bg: #3a1f1c;
  --lore-text: #f3e2bd; --lore-bg: #2b2233;
  --ny: #e6b3ef;      --ny-bg: #2e1f45;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html:focus-within { scroll-behavior: smooth; }
}
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* faint dithered sky at the top, like the pack artwork */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(116, 171, 204, .16) 1px, transparent 1.5px),
    linear-gradient(180deg, var(--bg-2) 0, var(--bg) 480px);
  background-size: 8px 8px, 100% 100%;
  background-repeat: repeat-x, no-repeat;
  background-attachment: scroll;
  color: var(--text);
  font: 400 1rem/1.7 var(--font-body);
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
img { height: auto; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--plum); color: #fff; }
h1, h2, h3, h4 { font-family: var(--font-pixel); font-weight: 600; line-height: 1.2; color: var(--heading); letter-spacing: .01em; }
code, kbd, pre { font-family: var(--font-mono); }
hr { border: 0; height: 4px; margin: 2.5rem 0; background:
  linear-gradient(90deg, transparent 0 8px, var(--gold-2) 8px 16px, transparent 16px 24px) 0 0 / 24px 4px repeat-x; opacity: .7; }
mark { background: var(--mark); color: inherit; padding: 0 1px; }
.px-icon { display: inline-block; flex: none; vertical-align: -0.15em; image-rendering: pixelated; }
.px-icon.inline { width: 1em; height: 1em; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 16px;
  background: var(--gold); color: #2a1706; font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.empty { color: var(--muted); font-style: italic; }
[hidden] { display: none !important; }
.no-js [data-search-open], .no-js .theme-toggle, .no-js .nav-toggle { display: none !important; }

/* Pixel frame (gold border like the artwork) */
.framed {
  border: 6px solid transparent;
  border-image: var(--frame) 7 / 14px / 0 stretch;
  background-clip: padding-box;
}

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
}
.main { min-width: 0; padding: 28px 32px 64px; outline: none; }
.page {
  display: grid;
  grid-template-columns: minmax(0, var(--article-w)) var(--toc-w);
  gap: 48px;
  justify-content: center;
  align-items: start;
}
.page-mod { grid-template-columns: minmax(0, var(--article-w)) 280px; }
.page.no-toc, .page-wide, .page-home { grid-template-columns: minmax(0, 1fr); }
.page.no-toc { max-width: var(--article-w); margin: 0 auto; }
.page-wide, .page-home { max-width: 1180px; margin: 0 auto; }
.article { min-width: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: var(--header-h);
  padding: 0 20px;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--brown);
  box-shadow: 0 -2px 0 var(--gold-2) inset, 0 2px 0 rgba(0, 0, 0, .12);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--heading); margin-right: 8px; }
.brand-logo { width: 36px; height: 36px; image-rendering: pixelated; box-shadow: 0 0 0 2px var(--brown); }
.brand-text { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-pixel); line-height: 1; }
.brand-name {
  font-size: 1.55rem; font-weight: 700; letter-spacing: .04em;
  background: linear-gradient(180deg, #cf86d4 0%, #bc71c2 38%, #f2cf4a 62%, #ffe27a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(2px 2px 0 #4f1f3d);
}
.brand-sub { font-family: var(--font-label); font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.brand:hover .brand-sub { color: var(--link-hover); }

.search-trigger {
  flex: 1 1 auto; max-width: 440px; margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 10px 0 12px;
  background: var(--surface); color: var(--muted);
  border: 2px solid var(--border); cursor: pointer;
  font: inherit; font-size: .95rem; text-align: left;
  clip-path: var(--notch);
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.search-trigger:focus-visible { outline: none; border-color: var(--focus); box-shadow: inset 0 0 0 2px var(--focus); }
.search-trigger-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-links { display: flex; align-items: center; gap: 4px; }
.header-links a {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px;
  color: var(--text-2); text-decoration: none; font-family: var(--font-label); font-size: .8rem;
}
.header-links a:hover { color: var(--link-hover); background: var(--surface-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  color: var(--text-2); background: transparent; border: 2px solid transparent; cursor: pointer;
  clip-path: var(--notch);
}
.icon-btn:hover { background: var(--surface-2); color: var(--link-hover); }
.icon-btn:focus-visible { outline: none; border-color: var(--focus); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.nav-toggle { display: none; }
.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
  :root:not([data-theme="light"]) .theme-icon-light { display: inline; }
}

.kbd { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px;
  font: 600 .84em/1.45 var(--font-mono); text-align: center; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  box-shadow: 0 2px 0 var(--border-strong);
}
.kbd > span { color: var(--muted); font-size: .8em; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 40px 20px;
  border-right: 2px solid var(--border);
  scrollbar-width: thin;
}
.sidebar-head { display: none; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-group-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 0 10px;
  font: 400 .75rem/1.4 var(--font-label); letter-spacing: .06em; text-transform: uppercase;
  color: var(--nav-title);
}
summary.nav-group-title { list-style: none; cursor: pointer; user-select: none; }
summary.nav-group-title::-webkit-details-marker { display: none; }
summary.nav-group-title::after {
  content: ""; width: 6px; height: 6px; margin-left: auto; margin-right: 4px;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px);
  transition: transform .15s;
}
details.nav-group:not([open]) > summary.nav-group-title::after { transform: rotate(-45deg); }
summary.nav-group-title:hover { color: var(--heading); }
summary.nav-group-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.nav-group-count { display: none; font: 500 .8rem/1 var(--font-num); color: var(--muted); letter-spacing: 0; }
details.nav-group:not([open]) .nav-group-count { display: inline; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav li a {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; margin: 1px 0;
  color: var(--text-2); text-decoration: none; font-size: .95rem; line-height: 1.35;
  border-left: 3px solid transparent;
}
.side-nav li a .px-icon { color: var(--muted); }
.side-nav li a:hover { background: var(--surface-2); color: var(--text); }
.side-nav li a[aria-current="page"] {
  background: var(--accent-soft); color: var(--heading); font-weight: 600;
  border-left-color: var(--gold-2);
}
.side-nav li a[aria-current="page"] .px-icon { color: var(--accent); }
.nav-backdrop { display: none; }

/* ---------- Content ---------- */
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 4px 0; list-style: none; margin: 0 0 18px; padding: 0; font-size: .86rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "\203A"; margin: 0 8px; color: var(--border-strong); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--link-hover); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--text-2); }

.page-header { margin-bottom: 28px; }
.eyebrow {
  display: flex; align-items: center; gap: 6px; margin: 0 0 6px;
  font: 400 .75rem/1.4 var(--font-label); letter-spacing: .06em; text-transform: uppercase; color: var(--nav-title);
}
.page-title {
  margin: 0; font-size: clamp(2rem, 1.4rem + 2.2vw, 2.9rem); font-weight: 700; line-height: 1.1;
  color: var(--title-solid);
  text-shadow: var(--title-shadow);
  overflow-wrap: anywhere;
}
.lead { font-size: 1.14rem; line-height: 1.6; color: var(--text-2); margin: 14px 0 0; }
.page-hero { margin: 22px 0 0; }
.page-hero img { display: block; width: 100%; max-height: 280px; object-fit: cover; image-rendering: pixelated; border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch; }

.prose { font-size: 1.02rem; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 {
  position: relative; margin: 2.6rem 0 1rem; padding-bottom: 8px; font-size: 1.75rem;
  border-bottom: 2px solid var(--border);
}
.prose h2::after { content: ""; position: absolute; left: 0; bottom: -2px; width: 72px; height: 2px; background: var(--gold-2); }
.prose h3 { margin: 2rem 0 .6rem; font-size: 1.35rem; }
.prose h4 { margin: 1.6rem 0 .4rem; font-size: 1.12rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .25rem 0; }
.prose li > ul, .prose li > ol { margin: .25rem 0; }
.prose ul { list-style: none; }
.prose ul > li { position: relative; }
.prose ul > li::before {
  content: ""; position: absolute; left: -1.05rem; top: .72em; width: 6px; height: 6px;
  background: var(--gold-2); box-shadow: 1px 1px 0 var(--brown);
}
.prose ul ul > li::before { background: var(--sky); box-shadow: none; }
.prose ul > li.task::before { display: none; }
.prose li.task { list-style: none; }
.prose li.task input { margin: 0 6px 0 -1.3rem; accent-color: var(--plum); }
.prose ol > li::marker { font-family: var(--font-pixel); color: var(--nav-title); }
.prose img { display: block; margin: 0 auto; }
.prose figure { margin: 1.6rem 0; }
.prose figure img { width: auto; max-width: 100%; height: auto; image-rendering: pixelated; border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch; }
/* Small pixel-art renders (<= 160 px, class added by the generator) show at a crisp 2x. */
.prose figure.figure-small img { width: var(--w); }
.prose figcaption { margin-top: 8px; font-size: .88rem; color: var(--muted); text-align: center; }
.prose blockquote {
  margin: 1.4rem 0; padding: 4px 0 4px 18px; color: var(--text-2);
  border-left: 4px solid var(--lavender);
}
.prose code, .facts code {
  padding: 1px 6px; font-size: .88em; background: var(--inline-code-bg); color: var(--text);
  border: 1px solid var(--border);
}
.break { word-break: break-all; }
.anchor {
  margin-left: .35em; padding: 0 .2em; font-family: var(--font-pixel); color: var(--border-strong);
  text-decoration: none; opacity: 0; transition: opacity .15s;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--link-hover); }

.codeblock { position: relative; margin: 1.3rem 0; background: var(--code-bg); border: 2px solid #2c3566; box-shadow: var(--hard-shadow); }
.codeblock pre { margin: 0; padding: 16px 18px; overflow-x: auto; color: var(--code-text); font-size: .88rem; line-height: 1.6; }
.codeblock code { background: none; border: 0; padding: 0; color: inherit; }
.code-lang {
  position: absolute; top: 0; right: 0; padding: 2px 10px;
  font: 400 .7rem/1.7 var(--font-label); letter-spacing: .04em; text-transform: uppercase;
  color: #2a1706; background: var(--gold-2);
}
.copy-btn {
  position: absolute; bottom: 8px; right: 8px; padding: 3px 10px;
  font: 400 .7rem/1.5 var(--font-label); color: var(--code-text);
  background: #252d57; border: 1px solid #46518f; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.codeblock:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }

.table-wrap { margin: 1.4rem 0; overflow-x: auto; border: 2px solid var(--border); background: var(--surface); box-shadow: var(--hard-shadow); }
.table-wrap:focus-visible { outline-offset: 0; }
.table-wrap.fade-right { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), rgba(0, 0, 0, .25)); mask-image: linear-gradient(90deg, #000 calc(100% - 36px), rgba(0, 0, 0, .25)); }
.table-wrap.fade-left { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 36px), rgba(0, 0, 0, .25)); mask-image: linear-gradient(270deg, #000 calc(100% - 36px), rgba(0, 0, 0, .25)); }
.table-wrap.fade-left.fade-right { -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, .25), #000 36px, #000 calc(100% - 36px), rgba(0, 0, 0, .25)); mask-image: linear-gradient(90deg, rgba(0, 0, 0, .25), #000 36px, #000 calc(100% - 36px), rgba(0, 0, 0, .25)); }
td .kbd { white-space: normal; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-weight: 700; font-size: .92rem; color: var(--heading); background: var(--surface-3); white-space: nowrap; }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
thead th:empty { padding: 0; }
thead:not(:has(th:not(:empty))) { display: none; }

/* Callouts */
.callout {
  position: relative; margin: 1.5rem 0; padding: 14px 18px 4px 18px;
  background: var(--note-bg); border-left: 6px solid var(--note);
  box-shadow: var(--hard-shadow);
}
.callout > :last-child { margin-bottom: 12px; }
.callout-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 6px !important;
  font: 600 1.08rem/1.3 var(--font-pixel); color: var(--note);
}
.callout-tip { background: var(--tip-bg); border-left-color: var(--tip); }
.callout-tip .callout-title { color: var(--tip); }
.callout-warning { background: var(--warn-bg); border-left-color: var(--warn); }
.callout-warning .callout-title { color: var(--warn); }
.callout-nytheria { background: var(--ny-bg); border-left-color: var(--plum); }
.callout-nytheria .callout-title { color: var(--ny); }
.callout-lore {
  padding: 20px 26px 8px; border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch;
  background: var(--lore-bg); background-clip: padding-box; color: var(--lore-text);
  font-family: var(--font-serif); font-style: italic; font-size: 1.1rem; line-height: 1.65;
  box-shadow: none;
}
.callout-lore .callout-title { color: var(--lore-text); font-style: normal; opacity: .9; font-family: var(--font-label); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.callout-lore p:not(.callout-title)::before { content: ""; }
.spoiler {
  margin: 1.5rem 0; background: var(--surface); border: 2px dashed var(--border-strong);
}
.spoiler > summary {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; cursor: pointer;
  font: 600 1.05rem/1.3 var(--font-pixel); color: var(--accent); list-style: none;
}
.spoiler > summary::-webkit-details-marker { display: none; }
.spoiler > summary::after { content: "Show"; margin-left: auto; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.spoiler[open] > summary::after { content: "Hide"; }
.spoiler[open] > summary { border-bottom: 2px dashed var(--border); }
.spoiler-body { padding: 14px 18px 2px; }

/* TOC */
.toc { position: sticky; top: calc(var(--header-h) + 24px); max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto; font-size: .88rem; scrollbar-width: thin; }
.toc-title { margin: 0 0 8px; font: 400 .75rem/1.4 var(--font-label); letter-spacing: .06em; text-transform: uppercase; color: var(--nav-title); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.toc li a { display: block; padding: 4px 0 4px 14px; margin-left: -2px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; line-height: 1.4; }
.toc li.toc-l3 a { padding-left: 28px; font-size: .84rem; }
.toc li a:hover { color: var(--text); }
.toc li a.is-active { color: var(--heading); border-left-color: var(--gold-2); font-weight: 600; }

.page-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 48px; padding-top: 14px; border-top: 2px dashed var(--border); font-size: .84rem; color: var(--muted); }
.page-meta code { font-size: .92em; }

/* ---------- Components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 16px;
  font: 400 1rem/1.2 var(--font-label); letter-spacing: 0; text-decoration: none; cursor: pointer;
  color: var(--text); background: var(--surface-2);
  border: 2px solid var(--border-strong);
  box-shadow: inset -2px -3px 0 rgba(0, 0, 0, .18), inset 2px 2px 0 rgba(255, 255, 255, .14);
  clip-path: var(--notch);
}
.btn:hover { color: var(--text); background: var(--surface-3); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .2); }
.btn:focus-visible { outline: none; border-color: var(--focus); box-shadow: inset 0 0 0 2px var(--focus); }
.btn-primary { color: #2a1706; background: var(--gold); border-color: var(--brown); }
.btn-primary:hover { color: #2a1706; background: #ffe27a; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-small { min-height: 34px; padding: 4px 12px; font-size: .75rem; }
.btn-block { width: 100%; justify-content: flex-start; }

.chip, .badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; font-size: .76rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
  color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border);
}
.badge.cat { color: var(--accent); background: var(--accent-soft); border-color: transparent; text-decoration: none; }
.badge.cat:hover { color: var(--link-hover); border-color: var(--accent); }
.chip.made { color: var(--ny); background: var(--ny-bg); border-color: transparent; }
.chip.key { color: var(--tip); background: var(--tip-bg); border-color: transparent; }
.chip.env-client { color: var(--note); }
.chip.env-server { color: var(--warn); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chip-list li::before { display: none; }
.chip-list a, .chip-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  color: var(--text-2); background: var(--surface); border: 2px solid var(--border); text-decoration: none; font-size: .9rem;
}
.chip-list a:hover, .chip-link:hover { border-color: var(--accent); color: var(--heading); }
.chip-link span { color: var(--muted); font-size: .8rem; }
.soon { color: var(--muted); border-bottom: 1px dotted var(--border-strong); }
.soon small { font-size: .78em; }
.stat-inline { font-weight: 700; color: var(--heading); }

/* Mod links may wrap. The icon sits in the left padding of the first line,
   so it never ends up alone at the end of a line. */
.modref { position: relative; padding-left: 21px; font-weight: 600; }
.modref-icon { position: absolute; left: 0; top: .2em; width: 16px; height: 16px; image-rendering: pixelated; }
span.modref-icon { display: grid; place-items: center; font-size: 10px; line-height: 1; }

.avatar {
  display: grid; place-items: center;
  font-family: var(--font-pixel); font-weight: 700; color: #fff;
  background: hsl(var(--hue, 220) 40% 36%);
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .25), inset 3px 3px 0 rgba(255, 255, 255, .15);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .35);
}
.avatar-fill { width: 100%; height: 100%; font-size: 1.4em; }

.panel { padding: 16px 18px; background: var(--surface); border: 2px solid var(--border); box-shadow: var(--hard-shadow); }
.panel-title { margin: 0 0 10px; font: 400 .75rem/1.4 var(--font-label); letter-spacing: .06em; text-transform: uppercase; color: var(--nav-title); }

.stat-tile {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  padding: 14px 18px; color: var(--text);
  background: var(--surface); border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch;
  background-clip: padding-box;
}
.stat-tile .px-icon { grid-row: span 2; width: 32px; height: 32px; max-width: none; color: var(--gold-2); }
.stat-tile > :not(.px-icon) { min-width: 0; }
.stat-value { font: 700 2.3rem/1 var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--title-solid); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.btn .num { font-weight: 600; font-size: 1.12em; line-height: 1; }
.stat-label { font-size: .86rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.page-mod .article > .prose { margin-top: 1.8rem; }
.fact-note { display: block; margin-top: 4px; font-size: .8rem; line-height: 1.4; color: var(--muted); }

/* credits ({{credits}}) */
.credits-summary { font-size: 1.05rem; color: var(--text-2); }
.credits-summary .num { font-size: 1.3em; font-weight: 700; color: var(--heading); }
.credits-jump ul { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0 0 1.4rem; padding: 0; }
.prose .credits-jump ul { padding: 0; }
.prose .credits-jump li { margin: 0; }
.prose .credits-jump li::before { content: none; display: none; }
.credits-jump a {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px;
  font: 600 1rem/1 var(--font-pixel); text-decoration: none;
  background: var(--surface-2); border: 2px solid var(--border);
}
.credits-jump a:hover { border-color: var(--gold-2); background: var(--surface-3); }
.credits-letter { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 0 12px; padding: 10px 0; border-top: 2px solid var(--border); scroll-margin-top: calc(var(--header-h) + 12px); }
.credits-initial { margin: 0; font: 700 1.9rem/1 var(--font-pixel); color: var(--title-solid); text-shadow: var(--title-shadow); }
.credits-list { margin: 0; columns: 2 300px; column-gap: 28px; }
.credit { break-inside: avoid; padding: 4px 0 8px; }
.credit dt { font-weight: 700; color: var(--heading); overflow-wrap: anywhere; }
.credit .modref { font-weight: 500; }
.credit dd { margin: 2px 0 0; font-size: .9rem; line-height: 1.6; color: var(--muted); }
.credit-n { display: inline-block; margin-left: 4px; padding: 1px 5px; font: 600 .78rem/1.2 var(--font-num); color: #2a1706; background: var(--gold-2); vertical-align: 1px; }
@media (max-width: 480px) {
  .credits-letter { grid-template-columns: minmax(0, 1fr); }
  .credits-initial { font-size: 1.5rem; margin-bottom: 4px; }
}

/* ---------- Home ---------- */
.layout-home { padding-top: 0; }
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  margin: 0 -32px; padding: 48px 32px 56px;
  border-bottom: 4px solid var(--brown);
  box-shadow: 0 -4px 0 var(--gold-2) inset;
}
.hero-bg {
  position: absolute; inset: -3%; z-index: -1;
  background: url("../img/background.webp") center 38% / cover no-repeat;
  image-rendering: pixelated;
}
.hero-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(15, 19, 41, .1) 0%, rgba(15, 19, 41, .35) 60%, rgba(15, 19, 41, .82) 100%);
}
.hero-inner { max-width: 980px; margin: 0 auto; text-align: center; }
.hero-banner {
  display: block; width: 100%; max-width: 860px; margin: 0 auto;
  image-rendering: pixelated;
  filter: drop-shadow(6px 6px 0 rgba(10, 10, 30, .55));
}
.hero-tagline {
  max-width: 680px; margin: 26px auto 0; padding: 12px 20px;
  font-family: var(--font-serif); font-style: italic; font-size: 1.18rem; line-height: 1.55;
  color: #f7f1e3; background: rgba(15, 19, 41, .72);
  border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch; background-clip: padding-box;
  text-shadow: 1px 1px 0 #000;
}
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 24px; }
.hero .btn:not(.btn-primary) { color: #f1f3fb; background: rgba(26, 32, 66, .88); border-color: #6c78b8; }
.hero .btn:not(.btn-primary):hover { background: rgba(42, 50, 97, .95); }
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px;
  max-width: 1180px; margin: -30px auto 36px; position: relative; z-index: 2;
  padding: 0 8px;
}
.stats .stat-tile { box-shadow: var(--hard-shadow); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-bottom: 40px; }
.tile {
  padding: 16px 18px; background: var(--surface); border: 2px solid var(--border);
  box-shadow: var(--hard-shadow); transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tile:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 rgba(42, 33, 82, .22); border-color: var(--gold-2); }
.tile-title { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font: 600 1.3rem/1.2 var(--font-pixel); color: var(--heading); }
.tile-title .px-icon { color: var(--gold-2); }
.tile ul { list-style: none; margin: 0; padding: 0; }
.tile li { padding: 3px 0; border-bottom: 1px dashed var(--border); }
.tile li:last-child { border-bottom: 0; }
.tile li a { text-decoration: none; }
.tile li a:hover { text-decoration: underline; }
.tile li.more { padding: 0; }
.tile li.more summary { padding: 4px 0; color: var(--muted); font-size: .85rem; cursor: pointer; }
.tile li.more summary:hover { color: var(--link-hover); }
.tile li.more details[open] summary { border-bottom: 1px dashed var(--border); }
.page-home .prose { max-width: var(--article-w); }

/* ---------- Mod cards / list ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin: 1.2rem 0; }
.mod-grid.compact { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.mod-card {
  position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 14px; background: var(--surface); border: 2px solid var(--border);
  box-shadow: var(--hard-shadow);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.mod-list .mod-card { content-visibility: auto; contain-intrinsic-size: auto 170px; }
.mod-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 rgba(42, 33, 82, .22); border-color: var(--border-strong); }
.mod-card.is-key { border-color: var(--gold-2); }
.mod-card-link { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--heading); text-decoration: none; }
.mod-card-link::after { content: ""; position: absolute; inset: 0; z-index: 0; }
.mod-card-link:focus-visible { outline: none; }
.mod-card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.mod-card .badge, .mod-card a:not(.mod-card-link) { position: relative; z-index: 1; }
.mod-icon {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px; overflow: hidden;
  background: var(--surface-3); box-shadow: 0 0 0 2px var(--border);
}
.mod-icon img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.mod-icon.avatar { font-size: 1.5rem; box-shadow: 0 0 0 2px var(--border), inset -3px -3px 0 rgba(0,0,0,.25), inset 3px 3px 0 rgba(255,255,255,.15); }
.mod-title { display: flex; flex-direction: column; min-width: 0; }
.mod-name { font: 700 1.02rem/1.25 var(--font-body); overflow-wrap: anywhere; }
.mod-card-link:hover .mod-name { color: var(--link-hover); text-decoration: underline; text-decoration-thickness: 2px; }
.mod-author { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-summary {
  margin: 0; font-size: .9rem; line-height: 1.5; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.mod-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: auto 0 0; }

.filters {
  position: sticky; top: var(--header-h); z-index: 20;
  display: grid; grid-template-columns: minmax(200px, 1.7fr) minmax(190px, 1.4fr) repeat(3, minmax(120px, 1fr)); gap: 10px 12px; align-items: end;
  margin: 0 -10px 18px; padding: 14px 16px;
  background: var(--surface);
  border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch; background-clip: padding-box;
}
.filter-search { position: relative; display: flex; align-items: center; }
.filter-search .px-icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.filters input[type="search"], .filters select {
  width: 100%; height: 40px; padding: 0 10px; font: inherit; font-size: .95rem;
  color: var(--text); background: var(--bg); border: 2px solid var(--border); border-radius: 0;
}
.filters input[type="search"] { padding-left: 36px; }
.filters input:focus-visible, .filters select:focus-visible { outline: none; border-color: var(--focus); box-shadow: inset 0 0 0 1px var(--focus); }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font: 400 .7rem/1.3 var(--font-label); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; font-size: .95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--plum); }
.check .px-icon { color: var(--plum); }
.filter-foot { grid-column: 2 / -1; display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.result-count { margin: 0 auto 0 0; color: var(--muted); font-size: .92rem; }
.result-count strong { font-size: 1.1rem; color: var(--heading); }
.view-switch { display: flex; gap: 4px; }
.mod-list-head { display: none; }

/* Compact row view */
.mod-list.view-rows { grid-template-columns: 1fr; gap: 0; border: 2px solid var(--border); box-shadow: var(--hard-shadow); background: var(--surface); }
.view-rows .mod-card {
  display: grid; grid-template-columns: minmax(200px, 1.1fr) minmax(0, 2fr) minmax(210px, 1.1fr);
  align-items: center; gap: 16px; padding: 8px 14px;
  border: 0; border-bottom: 1px solid var(--border); box-shadow: none; contain-intrinsic-size: auto 56px;
}
.view-rows .mod-card:nth-child(even) { background: var(--surface-2); }
.view-rows .mod-card:hover { transform: none; box-shadow: inset 4px 0 0 var(--gold-2); }
.view-rows .mod-icon { width: 32px; height: 32px; }
.view-rows .mod-icon.avatar { font-size: 1rem; }
.view-rows .mod-name { font-size: .95rem; }
.view-rows .mod-summary { -webkit-line-clamp: 2; font-size: .86rem; }
.view-rows .mod-meta { margin: 0; }
.mod-list-head.is-visible {
  display: grid; grid-template-columns: minmax(200px, 1.1fr) minmax(0, 2fr) minmax(210px, 1.1fr); gap: 16px;
  padding: 8px 16px; font: 400 .72rem/1.3 var(--font-label); letter-spacing: .04em; text-transform: uppercase;
  color: var(--heading); background: var(--surface-3); border: 2px solid var(--border); border-bottom: 0;
}
.mod-list-head.is-visible + .mod-list { margin-top: 0; }

.category-index { margin-top: 56px; }
.category-index h2 { font-size: 1.75rem; }
.category-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; list-style: none; margin: 0; padding: 0; }
.category-tile {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center; height: 100%;
  padding: 12px 14px; color: var(--text); text-decoration: none;
  background: var(--surface); border: 2px solid var(--border);
}
.category-tile:hover { color: var(--text); border-color: var(--gold-2); background: var(--surface-2); }
.category-tile .px-icon { color: var(--gold-2); }
.ct-name { font: 700 1rem/1.25 var(--font-body); color: var(--heading); }
.ct-count { font: 600 .9rem/1 var(--font-num); font-variant-numeric: tabular-nums; color: #2a1706; background: var(--gold-2); padding: 3px 7px; }
.ct-desc { grid-column: 1 / -1; font-size: .84rem; line-height: 1.45; color: var(--muted); }

.category-header { display: flex; gap: 18px; align-items: center; }
.category-icon {
  display: grid; place-items: center; flex: none; width: 76px; height: 76px; color: var(--gold);
  background: var(--surface-2); border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch; background-clip: padding-box;
}
.category-nav { margin-top: 48px; }
.category-nav h2 { font-size: 1.4rem; }

/* ---------- Mod page ---------- */
.mod-hero { display: flex; gap: 22px; align-items: center; margin-bottom: 8px; }
.mod-icon-lg {
  width: 112px; height: 112px; padding: 8px;
  background: var(--surface-2); box-shadow: none;
  border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch; background-clip: padding-box;
}
.mod-icon-lg.avatar { font-size: 3rem; padding: 0; background-clip: padding-box; }
.mod-hero-text { min-width: 0; }
.mod-hero .page-title { font-size: clamp(1.9rem, 1.3rem + 2vw, 2.6rem); }
.mod-authors { margin: 6px 0 8px; color: var(--muted); }
.mod-hero .mod-meta { margin-top: 4px; }
.mod-page-lead { margin-bottom: 16px; }
.official, .mentions, .related { margin-top: 40px; }
.official h2, .mentions h2, .related h2 { font-size: 1.4rem; margin: 0 0 12px; }
.official p { color: var(--text-2); }
.more-link { font-weight: 600; }
.rail { position: sticky; top: calc(var(--header-h) + 24px); display: flex; flex-direction: column; gap: 16px; }
.facts dl { margin: 0 0 16px; }
.facts dl > div { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.facts dt { font: 400 .7rem/1.4 var(--font-label); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dd .chip { margin: 0 2px 2px 0; }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.toc-rail { position: static; max-height: none; margin-top: 18px; }

/* ---------- Quest overview ---------- */
.quest-group { margin: 1.6rem 0 2rem; }
.quest-group-title {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px !important;
  font: 600 1.3rem/1.2 var(--font-pixel); color: var(--heading);
}
.quest-group-title .px-icon { color: var(--gold-2); }
.quest-group-meta { margin-left: auto; font: 400 .86rem var(--font-body); color: var(--muted); }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.chapter-card { padding: 14px 16px; background: var(--surface); border: 2px solid var(--border); box-shadow: var(--hard-shadow); }
.chapter-card header { display: flex; gap: 12px; align-items: flex-start; }
.chapter-no {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px;
  font: 700 1rem/1 var(--font-num); font-variant-numeric: tabular-nums; color: #2a1706; background: var(--gold);
  box-shadow: inset -3px -3px 0 var(--gold-2), 0 0 0 2px var(--brown);
}
.chapter-card header > div { flex: 1; min-width: 0; }
.prose .chapter-title { margin: 0; font: 700 1.02rem/1.3 var(--font-body); }
.chapter-sub { margin: 2px 0 0 !important; font-size: .84rem; color: var(--muted); }
.chapter-count { flex: none; font-size: .8rem; color: var(--muted); text-align: right; line-height: 1.2; }
.chapter-count strong { display: block; font: 700 1.35rem/1.1 var(--font-num); font-variant-numeric: tabular-nums; color: var(--title-solid); }
.prose .chapter-desc { margin: 10px 0 6px; font-size: .88rem; color: var(--text-2); line-height: 1.5; }
.prose .chapter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 6px 0 0; }
.row-label { width: 64px; font: 400 .66rem/1.2 var(--font-label); letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }

/* ---------- Search dialog ---------- */
.search-dialog {
  position: fixed; inset: 0; z-index: 90; display: flex; justify-content: center; align-items: flex-start;
  padding: 10vh 16px 16px; background: var(--overlay);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.search-panel {
  display: flex; flex-direction: column; width: 100%; max-width: 680px; max-height: 76vh;
  background: var(--surface);
  border: 6px solid transparent; border-image: var(--frame) 7 / 14px / 0 stretch; background-clip: padding-box;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, .35);
}
.search-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 2px solid var(--border); }
.search-bar .px-icon { color: var(--gold-2); }
.search-input {
  flex: 1; min-width: 0; height: 44px; padding: 0 4px; font: inherit; font-size: 1.15rem;
  color: var(--text); background: transparent; border: 0; outline: none;
}
.search-input::-webkit-search-cancel-button { display: none; }
.search-close { flex: none; padding: 3px 8px; font: 600 .78rem var(--font-mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-strong); cursor: pointer; }
.search-results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.search-results:empty { display: none; }
.search-results li { margin: 0; }
.search-result {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 2px 12px; align-items: center;
  padding: 9px 10px; color: var(--text); text-decoration: none; border-left: 3px solid transparent;
}
.search-result:hover { background: var(--surface-2); color: var(--text); }
.search-result[aria-selected="true"] { background: var(--accent-soft); border-left-color: var(--gold-2); color: var(--text); }
.search-result:focus-visible { outline-offset: -3px; }
.search-results mark { color: var(--text); }
.sr-icon { grid-row: span 2; display: grid; place-items: center; width: 32px; height: 32px; color: var(--accent); background: var(--surface-3); overflow: hidden; }
.sr-icon img { width: 100%; height: 100%; image-rendering: pixelated; object-fit: contain; }
.sr-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-kind { font: 400 .66rem/1.4 var(--font-label); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sr-sub { grid-column: 2 / -1; font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 18px; color: var(--muted); text-align: center; line-height: 1.6; }
.search-empty strong { color: var(--text); }
.search-hint { margin: 0; padding: 8px 14px; font-size: .78rem; color: var(--muted); border-top: 2px solid var(--border); }
body.search-open { overflow: hidden; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 40px 0; }
.notfound-code {
  margin: 0; font: 700 clamp(5rem, 16vw, 9rem)/1 var(--font-pixel);
  background: linear-gradient(180deg, #cf86d4 0%, #bc71c2 40%, #f2cf4a 60%, #ffe27a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(5px 5px 0 #4f1f3d);
}
.notfound .hero-actions { margin-top: 28px; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 40px; padding: 36px 24px 24px;
  background: var(--bg-2);
  border-top: 2px solid var(--brown);
  box-shadow: 0 2px 0 var(--gold-2) inset;
  font-size: .9rem; color: var(--text-2);
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 32px; justify-content: space-between; max-width: 1180px; margin: 0 auto; }
.footer-brand { display: flex; gap: 14px; align-items: center; align-self: flex-start; }
.footer-brand img { image-rendering: pixelated; box-shadow: 0 0 0 2px var(--brown); }
.footer-brand p { margin: 0; }
.footer-brand strong { font-family: var(--font-pixel); font-size: 1.2rem; color: var(--heading); }
.footer-cols { display: flex; flex-wrap: wrap; gap: 48px; }
.footer-heading { margin: 0 0 6px; font: 400 .75rem/1.4 var(--font-label); letter-spacing: .06em; text-transform: uppercase; color: var(--nav-title); }
.footer-cols ul { list-style: none; margin: 0; padding: 0; }
.footer-cols li { padding: 2px 0; }
.footer-bottom { max-width: 1180px; margin: 26px auto 0; padding-top: 16px; border-top: 2px dashed var(--border); color: var(--muted); font-size: .82rem; }
.footer-bottom p { margin: 4px 0; }

/* External link marker */
.prose a.ext::after, .facts a.ext::after { content: "\2197"; margin-left: 2px; font-size: .8em; }
.facts a.btn.ext::after { content: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1279px) {
  .page, .page-mod { grid-template-columns: minmax(0, var(--article-w)); }
  .page > .toc { display: none; }
  .page > .rail { position: static; }
  .rail .toc-rail { display: none; }
}
@media (max-width: 1100px) {
  .filters { grid-template-columns: 1fr 1fr 1fr; position: static; margin: 0 0 18px; }
  .filter-search { grid-column: 1 / -1; }
  .filter-foot { grid-column: 1 / -1; }
  .view-rows .mod-card, .mod-list-head.is-visible { grid-template-columns: minmax(180px, 1fr) minmax(0, 1.4fr); }
  .view-rows .mod-meta { grid-column: 2; }
  .mod-list-head.is-visible span:last-child { display: none; }
}
@media (max-width: 1023px) {
  :root { --header-h: 58px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-grid; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 80; width: min(86vw, 320px); height: 100%;
    padding-top: 12px; background: var(--bg); border-right: 2px solid var(--brown);
    box-shadow: 6px 0 0 rgba(0, 0, 0, .25);
    transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s;
  }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px 10px; }
  .sidebar-title { font: 600 1.1rem var(--font-pixel); color: var(--heading); }
  .nav-backdrop { position: fixed; inset: 0; z-index: 70; display: block; background: var(--overlay); }
  .nav-group + .nav-group { margin-top: 4px; }
  summary.nav-group-title { min-height: 40px; margin: 0; border-bottom: 1px solid var(--border); }
  details.nav-group[open] > summary.nav-group-title { margin-bottom: 4px; }
  .side-nav li a { min-height: 40px; padding: 8px 10px; }
  .no-js .sidebar { position: static; transform: none; visibility: visible; width: auto; height: auto; border-right: 0; border-bottom: 2px solid var(--border); box-shadow: none; }
  .main { padding: 22px 20px 56px; }
  .hero { margin: 0 -20px; padding: 32px 20px 48px; }
  .search-trigger-kbd { display: none; }
}
@media (max-width: 720px) {
  .header-links { display: none; }
  .brand-sub { display: none; }
  .search-trigger { max-width: none; }
  .filters { grid-template-columns: 1fr 1fr; position: static; margin: 0 0 16px; }
  .check { grid-column: 1 / -1; }
  .filter-foot { flex-wrap: wrap; }
  .view-rows .mod-card { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .view-rows .mod-meta { grid-column: auto; }
  .mod-list-head.is-visible { display: none; }
  .mod-hero { flex-direction: column; align-items: flex-start; gap: 14px; }
  .mod-icon-lg { width: 80px; height: 80px; padding: 4px; }
  .mod-icon-lg.avatar { font-size: 2.2rem; }
  .category-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .category-icon { width: 60px; height: 60px; }
  /* wide tables scroll instead of squeezing every column to a few letters */
  th, td { min-width: 9rem; }
  th:first-child, td:first-child { min-width: 6.5rem; }
  th:empty, td:empty { min-width: 0; }
  .stats { grid-template-columns: 1fr 1fr; margin-top: -24px; gap: 10px; }
  .stat-tile { padding: 10px 12px; }
  .stat-value { font-size: 1.6rem; }
  .stat-tile .px-icon { width: 24px; height: 24px; }
  .search-dialog { padding: 12px 8px; }
  .search-panel { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
  .search-hint { display: none; }
}
@media (max-width: 480px) {
  .site-header { gap: 8px; padding: 0 10px; }
  .brand-logo { width: 32px; height: 32px; }
  .brand-name { font-size: 1.3rem; }
  .search-trigger { flex: 0 0 auto; width: 40px; padding: 0; justify-content: center; margin-left: auto; }
  .search-trigger-text { display: none; }
  .main { padding: 18px 16px 48px; }
  .hero { margin: 0 -16px; padding: 22px 16px 40px; }
  .hero-tagline { font-size: 1.02rem; padding: 10px 12px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 12px; }
  .filters .field:first-of-type, .filters .field:nth-of-type(4) { grid-column: 1 / -1; }
  .filter-foot { gap: 8px; }
  .stat-label { letter-spacing: .04em; }
  .breadcrumbs ol { font-size: .8rem; }
  .mod-grid, .mod-grid.compact, .chapter-grid, .tiles, .category-tiles { grid-template-columns: minmax(0, 1fr); }
  .prose h2 { font-size: 1.5rem; }
  th, td { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  @page { margin: 16mm 14mm; }
  .site-header, .sidebar, .nav-backdrop, .toc, .rail, .site-footer, .filters, .hero-actions, .copy-btn,
  .search-dialog, .skip-link, .anchor, .breadcrumbs, .mod-list-head, .category-nav, .category-index, .related,
  .hero-bg, .page-meta { display: none !important; }
  /* always print the light palette, even when the dark theme is active */
  html:root:root {
    color-scheme: light;
    --bg: #fff; --bg-2: #fff; --surface: #fff; --surface-2: #f2f3f8; --surface-3: #e6e8f1;
    --border: #b9c3e0; --border-strong: #8190bd; --text: #000; --text-2: #222; --muted: #444;
    --link: #000; --accent: #3d2a70; --accent-soft: #ece8f8; --heading: #000; --title-solid: #000; --nav-title: #5a3a10;
    --inline-code-bg: #eef0f6; --mark: #ffe58a;
    --tip: #1f7a5a; --tip-bg: #fff; --note: #1d5a8c; --note-bg: #fff; --warn: #9a3412; --warn-bg: #fff;
    --lore-text: #3a2710; --lore-bg: #fff; --ny: #6a2c7c; --ny-bg: #fff;
  }
  html, body { background: #fff !important; color: #000; font-size: 11pt; }
  .shell, .page, .page-mod { display: block; max-width: none; min-height: 0; }
  .main { padding: 0; }
  .hero { margin: 0; padding: 0 0 12pt; border: 0; box-shadow: none; }
  .hero-tagline { color: #000; background: none; text-shadow: none; }
  .page-title, .credits-initial, .stat-value, .chapter-count strong { color: #000; text-shadow: none; }
  .brand-name, .notfound-code { color: #000; background: none; filter: none; }
  a { color: #000; }
  .prose a.ext[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; word-break: break-all; }
  .table-wrap { overflow: visible; box-shadow: none; -webkit-mask-image: none; mask-image: none; }
  th, td { min-width: 0; }
  .callout, .codeblock, .panel, .tile, .mod-card, .stat-tile, .chapter-card, .credit { box-shadow: none; }
  .codeblock { background: #f4f4f4; border-color: #999; }
  .codeblock pre { color: #000; white-space: pre-wrap; word-break: break-all; }
  h2, h3, h4 { break-after: avoid; page-break-after: avoid; }
  tr, figure, .callout, .codeblock, .mod-card, .chapter-card, .tile, .stat-tile { break-inside: avoid; page-break-inside: avoid; }
  .mod-card, .mod-list .mod-card { content-visibility: visible; }
  .mod-summary { -webkit-line-clamp: unset; display: block; }
  details.spoiler > .spoiler-body { display: block; }
}
