:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body {
  --bg: #0f1519;
  --panel: #161e23;
  --panel-hi: #1d282f;
  --ink: #e9eef0;
  --muted: #9fb0b8;
  --line: #2b3840;
  --accent: #83ead6;
  --link: #83ead6;
  --on-accent: #102320;
  --heading: "Segoe UI", system-ui, sans-serif;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
main { flex: 1; }
body[data-theme="alchemy"] {
  --bg: #0d1217; --panel: #141b22; --panel-hi: #1b252e; --ink: #e8eef2; --muted: #9eadb9;
  --line: #29353f; --accent: #8fe6dc; --link: #8fe6dc; --on-accent: #0d2220;
  --heading: "Bahnschrift", "Segoe UI", system-ui, sans-serif;
}
body[data-theme="desperation"] {
  color-scheme: light;
  --bg: #faf7ee; --panel: #f2ecdc; --panel-hi: #e9e0c8; --ink: #1c2230;
  --muted: #555c66; --line: #d6ccb2; --accent: #c9302c; --link: #1f4f9c; --on-accent: #fff;
  --heading: "Trebuchet MS", "Segoe UI", sans-serif;
}
body[data-theme="overboard"] {
  --bg: #0a1a22; --panel: #10242e; --panel-hi: #163039; --ink: #f1ece0;
  --muted: #a9bcc0; --line: #263f4a; --accent: #e9b46b; --link: #f0c27f; --on-accent: #272013;
  --heading: Georgia, "Times New Roman", serif;
}
body[data-theme="grimwilds"] {
  --bg: #13170f; --panel: #1a1f15; --panel-hi: #22291c; --ink: #ebe8d6;
  --muted: #b3b79e; --line: #343d2b; --accent: #b6c77c; --link: #c7d88c; --on-accent: #18220e;
  --heading: Georgia, "Times New Roman", serif;
}
body[data-theme="hollowfied"] {
  --bg: #121013; --panel: #1b171c; --panel-hi: #251f26; --ink: #eee8e7;
  --muted: #bcaeb5; --line: #3a2f37; --accent: #e8898d; --link: #f0a1a4; --on-accent: #301318;
  --heading: "Segoe UI", system-ui, sans-serif;
}

::selection { color: var(--on-accent); background: var(--accent); }
a { color: var(--link); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--heading); line-height: 1.2; margin: 0; font-weight: 700; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.5rem); letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
figcaption, .caption { font-size: .8125rem; color: var(--muted); }
kbd { font-family: inherit; font-size: .75rem; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--muted); }
[hidden] { display: none !important; }
section[id], h2[id] { scroll-margin-top: 72px; }
.wrap { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.narrow > * { max-width: 760px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.skip { position: fixed; top: 8px; left: 8px; z-index: 20; padding: .5rem .8rem; background: var(--accent); color: var(--on-accent); transform: translateY(-160%); }
.skip:focus { transform: none; }

/* Header */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-top: 3px solid var(--accent); border-bottom: 1px solid var(--line); }
.header-row { height: 54px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; gap: 9px; align-items: center; color: var(--ink); text-decoration: none; font-family: var(--heading); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }
.main-nav { display: flex; gap: 2px; }
.main-nav a { padding: .35rem .65rem; color: var(--muted); text-decoration: none; font-size: .9375rem; border-radius: 4px; }
.main-nav a:hover { color: var(--ink); background: var(--panel); }
.main-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.search-toggle { display: flex; align-items: center; gap: 8px; margin-left: auto; width: 280px; height: 34px; padding: 0 8px 0 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--muted); font-size: .875rem; text-align: left; }
.search-toggle:hover { border-color: var(--muted); }
.search-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-icon { width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 50%; position: relative; flex: none; }
.search-icon::after { content: ""; position: absolute; background: currentColor; height: 2px; width: 6px; bottom: -3px; right: -5px; transform: rotate(45deg); }
.menu-toggle { display: none; height: 34px; padding: 0 .7rem; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); font-size: .875rem; }

/* Shared text */
.crumbs { padding: 14px 0 10px; font-size: .8125rem; color: var(--muted); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.crumbs a { color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; opacity: .6; }
.lead { font-size: 1.0625rem; }
.kicker { font-size: .875rem; color: var(--muted); margin-bottom: .3rem; }
main h2 { padding-bottom: .3rem; margin: 2rem 0 .75rem; border-bottom: 1px solid var(--line); }
main section > p + p, main .prose p + p { margin-top: .75rem; }

/* Home */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto 1fr; grid-template-areas: "intro side" "main side"; column-gap: 40px; padding: 28px 0 56px; }
.intro { grid-area: intro; }
.intro h1 { margin-bottom: .6rem; }
.intro .start { margin-top: .7rem; color: var(--muted); }
.side { grid-area: side; display: grid; gap: 18px; align-content: start; }
.home-main { grid-area: main; min-width: 0; }
.infobox { border: 1px solid var(--line); background: var(--panel); font-size: .875rem; }
.infobox-title { padding: .45rem .75rem; background: var(--panel-hi); font-family: var(--heading); font-weight: 700; font-size: 1.05rem; text-align: center; }
.infobox figure { padding: 10px 10px 6px; }
.infobox img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.infobox figcaption { margin-top: 4px; text-align: center; font-size: .75rem; }
.infobox table { width: 100%; border-collapse: collapse; }
.infobox th, .infobox td { padding: .4rem .75rem; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.infobox th { width: 42%; color: var(--muted); font-weight: 600; }
.infobox-links { display: flex; gap: 14px; padding: .5rem .75rem; border-top: 1px solid var(--line); }
body[data-theme="grimwilds"] .infobox img { aspect-ratio: 1; image-rendering: pixelated; }
.side-box { padding: .8rem .9rem; border: 1px solid var(--line); font-size: .9rem; }
.side-box h2 { margin: 0 0 .35rem; padding: 0; border: 0; font-size: 1rem; }
.side-box p + p { margin-top: .4rem; }

.guide-list { list-style: none; margin: 0; padding: 0; }
.guide-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.guide-list li:first-child { padding-top: .2rem; }
.guide-list a { font-weight: 600; }
.guide-topic { font-size: .8125rem; color: var(--muted); }
.guide-list p { grid-column: 1 / -1; color: var(--muted); font-size: .9375rem; }
.loop, .steps, .see-also { margin: .6rem 0 0; padding-left: 1.4rem; }
.loop li, .steps li, .see-also li { margin-top: .4rem; padding-left: .2rem; }

.video { position: relative; margin-top: .8rem; aspect-ratio: 16/9; background: #000; overflow: hidden; }
.video img, .video iframe { width: 100%; height: 100%; object-fit: cover; border: 0; }
.video-button { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 8px; padding: .4rem .75rem; border: 0; border-radius: 4px; background: #000c; color: #fff; font-size: .875rem; font-weight: 600; }
.video-button:hover { background: #000; }
.play-icon { border: solid transparent; border-width: 6px 0 6px 10px; border-left-color: currentColor; }
.caption { margin-top: .4rem; }

.refs ol { margin: .4rem 0 0; padding-left: 1.6rem; font-size: .875rem; }
.refs li { margin-top: .3rem; }
.refs span { color: var(--muted); }
.refs span::before { content: "— "; }

/* Guides index */
.narrow > .crumbs + h1 { margin-top: 4px; }
.narrow .lead { margin-top: .5rem; color: var(--muted); }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 22px 0 6px; font-size: .875rem; }
.filter-bar span { margin-right: 4px; color: var(--muted); }
.filter-bar button { padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 3px; background: none; }
.filter-bar button:hover { border-color: var(--muted); }
.filter-bar button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
[data-guide-index] .guide-list { margin-top: 10px; border-top: 1px solid var(--line); }
[data-guide-index] .guide-list li:first-child { padding-top: .6rem; }
.aside-note { margin: 22px 0 56px; color: var(--muted); }

/* Article */
.article-page { padding-bottom: 56px; }
.article-grid { display: grid; grid-template-columns: minmax(0, 740px) 260px; justify-content: space-between; gap: 48px; }
.article-head { margin: 4px 0 14px; }
.byline { margin-top: .5rem; font-size: .875rem; color: var(--muted); }
.article-figure { margin-top: 18px; padding: 6px; border: 1px solid var(--line); background: var(--panel); }
.article-figure img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.article-figure figcaption { margin-top: 4px; font-size: .75rem; }
body[data-theme="grimwilds"] .article-figure img { image-rendering: pixelated; }
.prose { min-width: 0; }
.prose section > p, .prose .lead + section { margin-top: .6rem; }
.table-scroll { margin-top: .8rem; overflow-x: auto; }
table { border-collapse: collapse; font-size: .9375rem; }
.prose table { width: 100%; }
.prose th, .prose td { padding: .45rem .65rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose thead th { background: var(--panel-hi); font-weight: 600; }
.prose tbody th { font-weight: 600; background: var(--panel); }
.note { margin-top: .9rem; padding: .6rem .85rem; border-left: 3px solid var(--accent); background: var(--panel); font-size: .9375rem; }
.qa h3 { margin-top: 1rem; }
.qa h3 + p { margin-top: .25rem; }
.see-also li { font-size: .9375rem; color: var(--muted); }
.toc nav { position: sticky; top: 72px; padding-top: 22px; font-size: .875rem; }
.toc h2 { margin: 0 0 .4rem; padding: 0; border: 0; font-family: inherit; font-size: .875rem; font-weight: 700; }
.toc ol { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.toc a { display: block; margin-left: -1px; padding: .2rem 0 .2rem .75rem; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--ink); }
.toc a.is-active { color: var(--ink); border-left-color: var(--accent); }

/* Static pages */
.standalone { padding: 32px 0 64px; }
.standalone h1 { margin-bottom: .5rem; }
.standalone .lead { color: var(--muted); }
.standalone p { margin-top: .75rem; }
.linklike { padding: 0; border: 0; background: none; color: var(--link); text-decoration: underline; text-underline-offset: .15em; }

/* Buttons (dialogs, privacy page) */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: .8rem; }
.button { display: inline-block; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 4px; font-size: .9375rem; font-weight: 600; text-decoration: none; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.secondary { background: var(--panel); color: var(--ink); }
.secondary:hover { border-color: var(--muted); }
.primary:hover { filter: brightness(1.08); }

/* Footer */
.footer { border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: .875rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-block: 20px 26px; }
.footer-inner p { max-width: 60ch; }
.footer strong { color: var(--ink); }
.footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; }
.footer nav a, .footer nav button { color: var(--muted); padding: 0; border: 0; background: none; text-decoration: underline; text-underline-offset: .15em; }
.footer nav a:hover, .footer nav button:hover { color: var(--ink); }

/* Dialogs */
.dialog { color: var(--ink); background: var(--bg); width: min(600px, calc(100% - 24px)); max-height: 84dvh; border: 1px solid var(--line); border-radius: 6px; padding: 18px; box-shadow: 0 20px 60px #0008; }
.dialog::backdrop { background: #0009; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.dialog h2 { margin: 0; padding: 0; border: 0; font-size: 1.1rem; }
.quiet { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 4px; background: none; font-size: .875rem; }
.quiet:hover { border-color: var(--muted); }
.dialog input { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.dialog input:focus-visible { outline: none; border-color: var(--accent); }
.dialog .muted { margin-top: .5rem; font-size: .8125rem; }
.search-list { list-style: none; margin: .3rem 0 0; padding: 0; max-height: 52dvh; overflow-y: auto; }
.search-list a { display: block; padding: .5rem .6rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.search-list a:hover, .search-list a:focus-visible, .search-list a.is-active { outline: none; background: var(--panel-hi); }
.search-title { font-weight: 600; }
.search-title em { font-style: normal; font-weight: 400; font-size: .8125rem; color: var(--muted); }
.search-list small { display: block; font-size: .8125rem; color: var(--muted); }
.settings-dialog > p:not(.muted) { color: var(--muted); }
.settings-dialog > a { display: inline-block; margin-top: .8rem; }

@media (max-width: 900px) {
  .home { grid-template-columns: minmax(0, 1fr) 260px; column-gap: 28px; }
  .article-grid { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 720px) {
  .wrap { width: calc(100% - 28px); }
  .header-row { gap: 8px; }
  .main-nav { position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; padding: 6px 10px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .main-nav a { padding: .55rem .6rem; }
  body.js .main-nav { display: none; }
  body.js .main-nav.is-open { display: flex; }
  body:not(.js) .main-nav { position: static; flex-direction: row; padding: 0; border: 0; }
  body.js .menu-toggle { display: block; }
  .search-toggle { width: auto; margin-left: auto; }
  .search-text, .search-toggle kbd { display: none; }
  .home { display: block; padding-top: 20px; }
  .side { margin-top: 18px; }
  .infobox img { aspect-ratio: 16/9; }
  .footer-inner { flex-direction: column; }
  .footer nav { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
