:root {
  --bg: #111518;
  --surface: #191e23;
  --panel: #20262c;
  --ink: #f0f2f4;
  --muted: #a7b3c4;
  --line: #363f47;
  --soft: #2c353d;
  --stripe: #242c33;
  --brand: #101a22;
  --brand-2: #172630;
  --gold: #dfbb61;
  --accent: #d9b678;
  --link: #e0c597;
  --logo-ink: #e4e5df;
  --logo-gold: #dfb343;
  --category-buildings: #cb9b6e;
  --category-units: #ce8180;
  --category-research: #7db0dc;
  --category-council: #a2bba6;
  --category-artifacts: #b69bd8;
  --category-items: #82b6bc;
  --category-ages: #c7ad70;
  --warn: #f0ad80;
  --r1: 6px;
  --r2: 12px;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.875rem;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  --scene-opacity: 0.5;
  --scene: url('/img/ec62ffe7c983.webp');
  --hero-ink: #e7e2d8;
  --hero-muted: #c1c8cc;
  --hero-link: #dcc395;
  --hero-input: rgba(23, 35, 45, 0.93);
  --hero-shade-strong: rgba(13, 19, 26, 0.96);
  --hero-shade-mid: rgba(13, 19, 26, 0.72);
  --hero-shade-clear: rgba(13, 19, 26, 0.16);
  --hero-fade-start: rgba(16, 23, 29, 0.09);
  /* The real height is measured by site.js; this is the no-script fallback. */
  --header-h: 3.5rem;
  --filters-h: 0px; --jump-h: 0px;
  --layer-header: 10; --layer-filters: 7; --layer-jump: 6; --layer-table: 2;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f4f4; --surface: #fafafa; --panel: #ffffff;
  --ink: #263039; --muted: #5d6971; --line: #d4d0c4;
  --soft: #e8ebed; --stripe: #f3f4f4; --link: #78551c;
  --gold: #856313; --accent: #856313; --warn: #98441f;
  --logo-ink: #292e32; --logo-gold: #a67908;
  --shadow: 0 3px 12px rgba(42, 38, 29, 0.06);
  --scene-opacity: 0.11; color-scheme: light;
  --hero-ink: #29343a; --hero-muted: #45545d; --hero-link: #765a2b;
  --hero-input: rgba(255, 253, 248, 0.96);
  --hero-shade-strong: rgba(238, 236, 229, 0.96); --hero-shade-mid: rgba(238, 236, 229, 0.72);
  --hero-shade-clear: rgba(238, 236, 229, 0.08); --hero-fade-start: rgba(238, 236, 229, 0.04);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #f3f4f4; --surface: #fafafa; --panel: #ffffff;
    --ink: #263039; --muted: #5d6971; --line: #d4d0c4;
    --soft: #e8ebed; --stripe: #f3f4f4; --link: #78551c;
    --gold: #856313; --accent: #856313; --warn: #98441f;
    --logo-ink: #292e32; --logo-gold: #a67908;
    --shadow: 0 3px 12px rgba(42, 38, 29, 0.06);
    --scene-opacity: 0.11; color-scheme: light;
    --hero-ink: #29343a; --hero-muted: #45545d; --hero-link: #765a2b;
    --hero-input: rgba(255, 253, 248, 0.96);
    --hero-shade-strong: rgba(238, 236, 229, 0.96); --hero-shade-mid: rgba(238, 236, 229, 0.72);
    --hero-shade-clear: rgba(238, 236, 229, 0.08); --hero-fade-start: rgba(238, 236, 229, 0.04);
  }
}

:root[data-color="blue"] { --accent:#9dc7f1; --gold:#9dc7f1; }
:root[data-color="jade"] { --accent:#91c8b0; --gold:#91c8b0; }
:root[data-theme="light"][data-color="blue"] { --accent:#2d5c88; --gold:#2d5c88; }
:root[data-theme="light"][data-color="jade"] { --accent:#27634d; --gold:#27634d; }
@media(prefers-color-scheme:light){
  :root[data-theme="system"][data-color="blue"] { --accent:#2d5c88; --gold:#2d5c88; }
  :root[data-theme="system"][data-color="jade"] { --accent:#27634d; --gold:#27634d; }
}

* { box-sizing: border-box; }
.research-overview-wrap { max-height: 75vh; overflow: auto; border: 1px solid var(--line); }
.research-overview { min-width: 1020px; width: 100%; font-size: var(--fs-sm); }
.research-overview thead th { position: sticky; top: 0; z-index: var(--layer-table); background: var(--panel); }
.research-overview td, .research-overview th { border-right: 1px solid var(--line); vertical-align: top; white-space: normal; }
.research-overview .research-group { min-width: 95px; max-width: 145px; background: var(--panel); color: var(--muted); }
.research-overview th[scope="row"] { min-width: 160px; max-width: 240px; }
.research-overview .research-effect { min-width: 230px; max-width: 330px; }
.research-overview .research-targets { min-width: 150px; max-width: 230px; }
.research-mobile-context { display: none; }
.research-conditions { margin-top: .6rem; font-weight: normal; }
.research-prerequisites { margin: .3rem 0 .6rem; padding-left: 1.2rem; }
.research-condition { display: inline-block; vertical-align: top; margin: 0 1.5rem .8rem 0; }
.research-condition p { margin: .3rem 0; }
@media (max-width: 700px) {
  .research-overview { min-width: 700px; }
  .research-overview tr > :nth-child(-n+4) { display: none; }
  .research-overview th[scope="row"] { min-width: 180px; max-width: 200px; position: sticky; left: 0; background: var(--panel); z-index: 1; }
  .research-overview thead th:nth-child(5) { left: 0; z-index: 3; }
  .research-mobile-context { display: block; margin-top: .5rem; color: var(--muted); font-weight: normal; line-height: 1.7; }
}
.catalog-tools .merge-toggle { display: flex; flex-direction: row; align-items: center; gap: .4rem; }
.research-effects { margin: 0; padding: 0; list-style: none; }
.research-effects li + li { margin-top: .4rem; }
.research-effects small { display: block; color: var(--muted); }
.research-chapters summary { cursor: pointer; }
.research-chapters summary small { display: block; color: var(--muted); }
.research-chapters[open] summary { margin-bottom: .65rem; }
.entity-data-note { color: var(--muted); font-size: var(--fs-xs); margin: .5rem 0 1rem; }
.coverage-entry { border-bottom: 1px solid var(--line); padding: .55rem 0; }
.coverage-entry summary { cursor: pointer; }
.coverage-entry summary small { margin-left: .5rem; color: var(--muted); }
.coverage-entry section { padding-left: 1rem; }
.entry-preview { position: fixed; z-index: 60; width: 340px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-top: 2px solid var(--accent); border-radius: var(--r1); box-shadow: var(--shadow); padding: 1rem; font-size: var(--fs-sm); }
.entry-preview-head { display: flex; align-items: center; gap: .65rem; padding-right: 1.2rem; }
.entry-preview-head small { display: block; color: var(--muted); margin-top: .25rem; }
.entry-preview p { margin: .7rem 0; }
.entry-preview dl { margin: .7rem 0; }
.entry-preview dl div { display: flex; justify-content: space-between; gap: .5rem; }
.entry-preview dt { color: var(--muted); }
.entry-preview dd { margin: 0; }
.entry-preview [data-preview-close] { position: absolute; top: .25rem; right: .35rem; background: transparent; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Malgun Gothic", sans-serif;
}
/* One decorative scene shared by pages; it fades away before long data tables.
   The official artwork is served locally, with a separate crop for small screens. */
body::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 640px; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, transparent 35%, var(--bg) 100%), var(--scene) center top / auto 640px no-repeat;
  opacity: var(--scene-opacity);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Keyboard focus that stays visible on both the light page and the dark header. */
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.top :focus-visible, .foot :focus-visible { outline-color: var(--gold); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.3; margin: 1.6em 0 0.6em; }
h1 { font-size: var(--fs-xl); margin-top: 0.4em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
/* Anchors and hash links must not land under the sticky header. */
h2, h3, h4, section[id], tr[id], [id^="pool-"] { scroll-margin-top: calc(var(--header-h) + 0.75rem); }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
small, .count, .meta, .note { color: var(--muted); font-size: var(--fs-sm); font-weight: normal; }
[hidden] { display: none !important; }
button, .button {
  font: inherit; font-size: var(--fs-sm); padding: 0.35rem 0.8rem; border-radius: var(--r2); cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); display: inline-block;
}
button:hover, .button:hover { border-color: var(--link); text-decoration: none; }
button:disabled { opacity: 0.45; cursor: default; border-color: var(--line); }
.button { color: var(--link); font-weight: 600; }

/* header */
.skip {
  position: absolute; inset-inline-start: 0.5rem; top: 0.5rem; z-index: 50; padding: 0.45rem 0.8rem;
  border-radius: var(--r2); border: 1px solid var(--line); background: var(--panel); color: var(--link);
  transform: translateY(-250%);
}
.skip:focus { transform: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.top { background: var(--surface); color: var(--ink); position: sticky; top: 0; z-index: var(--layer-header); border-bottom: 1px solid var(--line); box-shadow: 0 3px 16px #0001; }
.top-in {
  max-width: 1180px; margin: auto; padding: 8px 1rem; min-height:60px;
  display: flex; gap: 1rem; align-items: center;
}
.logo { display: flex; flex:none; align-items: center; gap: .5rem; color: var(--ink); font-weight: 700; font-size: 1.2rem; line-height:1.2; }
.brand-mark { display:block; flex:none; }
.logo-atlas { color:var(--accent); }
.logo small { display:block; margin-top:.2rem; font-size:.62rem; letter-spacing:.12em; color:var(--muted); font-weight:500; }
.logo:hover { text-decoration: none; }
.top .search { flex:1; max-width:20rem; min-width:5rem; margin-left:auto; }
.nav { display: flex; flex:none; gap: .15rem; align-items:center; }
.nav a, .nav-menu summary { display:flex; align-items:center; min-height:44px; color:var(--muted); padding:.55rem .65rem; border-radius:var(--r1); white-space:nowrap; font-size:var(--fs-sm); }
.nav a:hover, .nav a[aria-current], .nav-menu summary:hover, .nav-menu summary.current { background:var(--soft); color:var(--ink); text-decoration:none; }
.settings-link { grid-area:settings; display:flex; align-items:center; gap:.4rem; color:var(--muted); min-height:44px; padding:.35rem .5rem; border-radius:var(--r1); font-size:var(--fs-sm); }
.settings-link:hover,.settings-link[aria-current] { color:var(--accent); background:var(--soft); text-decoration:none; }
.settings-link span { display:none; }
.settings-link { flex:none; justify-content:center; width:44px; }
.ui-icon { flex:none; display:block; }
.nav-menu { position:relative; margin:0; padding:0; border:0; background:none; }
.nav-menu summary { cursor:pointer; list-style:none; gap:.35rem; }
.nav-menu summary::-webkit-details-marker { display:none; }
.nav-menu summary::after { content:'▾'; font-size:.7em; opacity:.65; }
.nav-menu > div { display:grid; position:absolute; left:0; top:calc(100% + 8px); padding:.4rem; min-width:12rem; max-width:calc(100vw - 2rem); background:var(--panel); border:1px solid var(--line); border-radius:var(--r2); box-shadow:var(--shadow); z-index:20; }
.nav-menu > div a { white-space:normal; }
.nav-toggle {
  display: none; align-items: center; justify-content: center; gap: 0.4rem; font: inherit; font-size: var(--fs-md); cursor: pointer;
  min-width: 2.75rem; min-height: 2.75rem; padding: 0.2rem 0.6rem; border-radius: var(--r1);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
@media (min-width: 1200px) {
  html[data-wide="1"] main,
  html[data-wide="1"] .top-in { max-width: min(96vw, 1360px); }
}
.prose { margin-inline:auto; }

/* language menu */
.langs { grid-area: lang; position: relative; margin: 0; }
.langs summary {
  list-style: none; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; padding: 0.65rem 0.5rem; cursor:pointer; min-height:44px;
  border-radius: var(--r1); white-space: nowrap;
}
.langs summary::-webkit-details-marker { display: none; }
.language-short { display:none; }
.langs summary::after { content: " ▾"; font-size: var(--fs-xs); }
.langs summary:hover, .langs[open] summary { background: var(--soft); }
.langs ul {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); margin: 0; padding: 0.35rem; list-style: none; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  display: grid; grid-template-columns: repeat(2, minmax(9rem, 1fr)); gap: 0.1rem;
}
.langs ul a { display: block; padding: 0.3rem 0.6rem; border-radius: var(--r1); color: var(--ink); font-size: var(--fs-sm); white-space: nowrap; }
.langs ul a:hover { background: var(--soft); text-decoration: none; }
.langs ul a[aria-current] { font-weight: 700; color: var(--link); }

/* search */
.search { position: relative; }
.search input {
  width: 100%; padding: 0.65rem 2.5rem 0.65rem .9rem; border-radius: var(--r2); font: inherit; font-size: var(--fs-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.search input::placeholder { color: var(--muted); }
.search kbd { position:absolute; right:.8rem; top:50%; transform:translateY(-50%); border:1px solid var(--line); border-radius:4px; padding:0 .35rem; font: .75rem/1.6 ui-monospace,monospace; color:var(--muted); pointer-events:none; }
.search:focus-within kbd { display:none; }
.search input:focus { outline: 2px solid var(--gold); background: #fff; color: #1d242b; }
.search.big input { padding: 0.75rem 1rem; font-size: var(--fs-md); background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.search.big input::placeholder { color: var(--muted); }
.results {
  position: absolute; inset-inline: 0; top: calc(100% + 4px); margin: 0; padding: 0.25rem; list-style: none;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); max-height: 70vh; overflow-y: auto; min-width: 18rem; z-index: 20;
}
.results a { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.5rem; border-radius: var(--r1); color: inherit; }
.results a:hover, .results a.active { background: var(--soft); text-decoration: none; }
.results img, .results .noimg { width: 32px; height: 32px; object-fit: contain; flex: none; }
.results small { display: block; }
.results li.none { padding: 0.5rem; color: var(--muted); }
.results li.all { border-top: 1px solid var(--line); margin-top: 0.2rem; }
.results li.all a { color: var(--link); font-size: var(--fs-sm); }
.search-page .search.big { max-width: 46rem; margin: 1rem 0; }
.search-page .search .results { display: none; }
.search-list { margin-top: 1.25rem; }
.search-list section { margin-top: 1.25rem; }
.search-list h2 { font-size: var(--fs-md); margin: 0 0 0.4rem; }
.search-list ul { list-style: none; margin: 0; padding: 0; }
.search-list li { border-bottom: 1px solid var(--line); }
.search-list a { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.2rem; color: inherit; }
.search-list a:hover { text-decoration: none; background: var(--soft); }
.search-list img, .search-list .noimg { width: 32px; height: 32px; object-fit: contain; flex: none; }
.search-list b { display: block; font-size: var(--fs-sm); }
.search-list small { display: block; font-size: var(--fs-xs); color: var(--muted); }
.search-status { color: var(--muted); font-size: var(--fs-sm); min-height: 1.4em; }

/* layout */
main { max-width: 1180px; margin: auto; padding: 1rem 1rem 3rem; }
.reference-page main { margin-block: 1.5rem 2rem; padding: 1.5rem 1.5rem 3rem; background: var(--surface); border: 1px solid var(--line); border-top: 2px solid var(--accent); border-radius: var(--r2); box-shadow: var(--shadow); }
.reference-page main > h1 { margin-bottom: 0.65rem; }
.reference-page h2, .home-page main > h2 { padding-bottom: 0.55rem; border-bottom: 1px solid var(--line); }
.reference-page .entity-head { padding-bottom: 0.8rem; border-bottom: 1px solid var(--line); }
.entity-head > img { background: radial-gradient(ellipse, var(--soft), transparent 72%); }
.foot { border-top: 1px solid var(--line); padding: 1.5rem 1rem 2.5rem; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.25rem; margin-bottom: 0.5rem; }
/* Footer links are small text; the padding brings them to a comfortable touch height. */
.foot nav a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 0.2rem; }
.foot p { margin: 0.3rem auto; max-width: 46rem; }
.footer-groups { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:2rem; max-width:72rem; margin:0 auto 1.8rem; text-align:start; }
.foot .footer-groups nav { display:flex; flex-direction:column; align-items:flex-start; gap:0; min-width:0; }
.footer-groups h2 { color:var(--ink); font-size:var(--fs-sm); margin:0 0 .6rem; }
.footer-groups a { color:var(--muted); overflow-wrap:anywhere; }
.footer-legal { border-top:1px solid var(--line); padding-top:1rem; }
.version-badge { display:inline-block; padding:.2rem .5rem; margin-inline-start:.8rem; border:1px solid var(--line); border-radius:var(--r1); font-size:.75rem; }
.search-launch { display:flex; align-items:center; gap:.6rem; margin-inline-start:auto; min-width:0; width:clamp(10rem,18vw,18rem); min-height:42px; padding:.45rem .65rem; border:1px solid var(--line); border-radius:var(--r1); color:var(--muted); background:var(--panel); font-size:var(--fs-sm); }
.langs { flex:none; }
.search-launch:hover { color:var(--ink); text-decoration:none; border-color:var(--accent); }
.search-launch span { min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.search-launch kbd { margin-inline-start:auto; }
.search-dialog { inset:12vh auto auto 50%; transform:translateX(-50%); margin:0; padding:1.2rem; width:min(40rem,calc(100vw - 1.5rem)); max-height:78dvh; overflow:auto; background:var(--panel); border:1px solid var(--line); border-radius:var(--r2); color:var(--ink); box-shadow:0 20px 80px #0005; }
.search-dialog::backdrop { background:#080b10b8; backdrop-filter:blur(4px); }
.search-dialog-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:.8rem; }
.search-dialog-head button { font-size:1.5rem; min-width:44px; min-height:44px; }
.search-dialog .search { max-width:none; width:100%; }
.search-dialog .results { position:static; box-shadow:none; border:0; max-height:50dvh; margin-top:.7rem; }
.search-fallback { display:inline-flex; min-height:44px; align-items:center; font-size:var(--fs-sm); margin-top:.5rem; }
@media(max-width:900px) { .hero { width:min(65%,36rem); } .home-tool-list { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:600px) { .hero { width:100%; } .footer-groups { grid-template-columns:1fr; gap:1.2rem; } .foot .footer-groups nav { flex-direction:row; flex-wrap:wrap; gap:0 1rem; } .footer-groups h2 { width:100%; } .search-launch { flex:1; width:auto; } .search-launch kbd { display:none; } .search-dialog { top:1rem; max-height:calc(100dvh - 2rem); } }
.crumbs { font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.4rem; }
.lead { font-size: var(--fs-md); max-width: 46rem; }
/* The lore text of an artifact is folded away by default, so the facts and the upgrade table
   come first. The summary reuses the coverage label ("Description") from the UI strings. */
.entity-description { margin: 0 0 1rem; padding: 0 0.85rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); }
.entity-description > summary { color: var(--muted); font-size: var(--fs-sm); }
.entity-description[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 0.6rem; }
.entity-description > p { max-width: 46rem; }
.entity-description > p:last-child { margin-bottom: 0.85rem; }
.note { margin: 1.5rem 0 0; }

/* A page's own table of contents: a sticky rail on desktop, a fold-out box on a phone.
   The grid row spans the whole page, which is what gives the sticky rail room to travel. */
.page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; grid-template-areas: "main toc"; gap: 1.5rem; align-items: start; }
.page-main { grid-area: main; min-width: 0; }
.page-toc { grid-area: toc; position: sticky; top: calc(var(--header-h) + 1rem); width: 100%; max-width: 100%; margin: 0; }
.page-toc-inner {
  max-height: calc(100dvh - var(--header-h) - 2rem); overflow-y: auto; padding: 0.7rem 0.9rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); font-size: var(--fs-sm);
}
.page-toc p { margin: 0 0 0.4rem; font-weight: 600; }
.page-toc ol { margin: 0; padding-inline-start: 1.1rem; }
.page-toc li { margin: 0.2rem 0; }
.page-toc a.active { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 0.2em; }
.page-toc-mobile { display: none; margin: 0 0 1rem; }
@media (max-width: 899px) {
  .page-grid { display: block; }
  .page-toc { display: none; }
  .page-toc-mobile { display: block; }
  .page-toc-mobile .page-toc-inner { max-height: none; }
}
.to-top {
  position: fixed; inset-inline-end: 1rem; bottom: 1rem; z-index: 9; width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center; padding: 0; border-radius: 999px; font-size: 1.15rem;
  background: var(--panel); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.to-top[hidden] { display: none; }

/* home */
.home-page main { padding-top:0; }
.home-page { --home-height:460px; }
.home-page .langs { margin-left:0; }
.home-page::before { top:var(--header-h); height:var(--home-height); opacity:1; background:linear-gradient(to bottom,transparent 64%,var(--bg) 100%),linear-gradient(90deg,var(--hero-shade-strong) 0%,var(--hero-shade-mid) 30%,transparent 72%),var(--scene) center 42% / cover no-repeat; }
.home-stage { min-height:var(--home-height); display:flex; flex-direction:column; gap:2rem; padding:78px 0 54px; }
.hero { position:relative; z-index:2; color:var(--hero-ink); width:min(52%,40rem); min-width:0; }
.hero h1 { margin:0 0 12px; max-width:46rem; font-family:Georgia,'Noto Serif','Songti SC','Yu Mincho',serif; font-size:clamp(1.8rem,2.7vw,2.4rem); font-weight:600; line-height:1.2; letter-spacing:-.02em; }
.hero-version { color:var(--hero-muted); font-size:.75rem; white-space:nowrap; margin-left:.8rem; }
.hero p { color:var(--hero-muted); margin:0 0 24px; font-size:var(--fs-sm); }
.hero .search { width:100%; max-width:34rem; }
.hero .search.big input { padding:12px 2.5rem 12px .9rem; font-size:1rem; background:var(--hero-input); color:var(--ink); border-color:color-mix(in srgb,var(--ink) 20%,transparent); box-shadow:none; }
.hero .search.big input::placeholder { color: var(--muted); }
.hero .search.big input:focus { border-color: var(--gold); }
.home-catalog { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:.6rem; margin-top:auto; position:relative; z-index:1; }
.home-catalog a { display:flex; align-items:center; justify-content:center; gap:.6rem; min-width:0; min-height:52px; padding:.6rem .4rem; color:var(--ink); background:color-mix(in srgb,var(--panel) 65%,transparent); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); border-radius:var(--r1); font-size:var(--fs-sm); }
.home-catalog span { overflow-wrap:anywhere; }
.home-catalog a:hover { background:var(--soft); text-decoration:none; }
.home-catalog small { color:var(--muted); font-size:.75rem; font-variant-numeric:tabular-nums; }
.home-tools h2, .home-feed h2 { font-size:1.125rem; margin:0 0 .65rem; }
.home-tool-list { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.75rem; }
.home-tool { display:block; min-width:0; padding:1.1rem 1.25rem; color:var(--ink); background:var(--surface); border:1px solid var(--line); border-radius:var(--r1); transition:background .15s ease; }
:root[data-theme="light"] .home-tool { background:var(--surface); }
@media(prefers-color-scheme:light) { :root[data-theme="system"] .home-tool { background:var(--surface); } }
.home-tool:hover { background:var(--soft); text-decoration:none; }
.home-tool b { display:block; font-size:1rem; font-weight:600; }
.home-tool small { display:block; margin-top:.3rem; color:var(--muted); font-size:var(--fs-sm); overflow-wrap:anywhere; }
.home-more-tools { border:0; padding:0; margin:.6rem 0 0; background:none; }
.home-more-tools > summary { width:fit-content; margin-left:auto; min-height:44px; padding:.6rem 0 .6rem 1rem; color:var(--muted); font-size:var(--fs-sm); cursor:pointer; }
.home-more-tools > summary:hover { color:var(--ink); }
.home-more-tools:not([open]) .when-open, .home-more-tools[open] .when-closed { display:none; }
.home-more-tools .home-tool-list { margin-top:.5rem; }
.home-knowledge { display:flex; flex-wrap:wrap; gap:1.4rem; margin-bottom:1rem; }
.home-knowledge a { display:flex; align-items:center; min-height:44px; color:var(--ink); font-size:var(--fs-sm); }
.home-feed { margin-top:2rem; padding-top:1.4rem; border-top:1px solid color-mix(in srgb,var(--ink) 8%,transparent); }
.home-feed .list li { border-color:color-mix(in srgb,var(--ink) 7%,transparent); font-size:var(--fs-sm); padding:.65rem 0; }
.home-feed .list a { color:var(--ink); }
.home-feed .news .tag { color:var(--muted); background:none; border:0; padding:0; }
.home-feed > section > p { font-size:var(--fs-xs); }
.category-buildings { --category-color:var(--category-buildings); }
.category-units { --category-color:var(--category-units); }
.category-research { --category-color:var(--category-research); }
.category-council { --category-color:var(--category-council); }
.category-artifacts { --category-color:var(--category-artifacts); }
.category-items { --category-color:var(--category-items); }
.category-ages { --category-color:var(--category-ages); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.tile, .tool {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 1rem; color: inherit; text-align: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); box-shadow: var(--shadow);
}
.tile:hover, .tool:hover { border-color: var(--link); text-decoration: none; }
.tile img { width: 48px; height: 48px; object-fit: contain; }
.tile span { min-width: 0; }
.tile b, .tile small, .tool b, .tool small { display: block; }
/* Long single words (Russian, German) hyphenate at syllables; Japanese has no spaces, so keep words whole. */
.tile b { hyphens: auto; overflow-wrap: break-word; }
html[lang="ja"] .tile b { word-break: keep-all; }
.tool-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.75rem; }
.tool { flex-direction: column; align-items: flex-start; gap: 0.65rem; padding:1.15rem; }
.tool b { color: var(--ink); font-size:1rem; }
.tool small { font-size:.85rem; line-height:1.7; }
.tool-directory .tool { border-block-start: 2px solid color-mix(in srgb,var(--accent) 55%,var(--line)); }
.tool-directory .tool-action { border-top: 1px solid var(--line); }
.tool-action { display:flex; justify-content:space-between; width:100%; gap:.75rem; margin-top:auto; padding-top:.75rem; font-size:var(--fs-xs); font-weight:600; color:var(--accent); }
.section-heading { display:flex; align-items:baseline; justify-content:space-between; gap:1rem; margin-top:2rem; }
.section-heading h2 { margin:0 0 1rem; }
.section-heading > a { font-size:var(--fs-sm); white-space:nowrap; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 2.5rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.coverage-cat { margin-top: 2rem; }
.coverage-cat details { margin: 0.4rem 0 0.8rem; }
.coverage-cat summary { cursor: pointer; }
.coverage-cat details .list { max-height: 24rem; overflow: auto; }
.coverage-table th:first-child, .coverage-table td:first-child { position: sticky; inset-inline-start: 0; background: var(--panel); }
.list li.news { display: grid; grid-template-columns:6.4rem auto 1fr; gap: .6rem; align-items: start; padding:1rem 0; }
.event-search { margin-inline-start: 0.5rem; font-size: var(--fs-xs); white-space: nowrap; }
.events-table td:first-child, .events-table th:first-child { white-space: nowrap; }
.news time { color: var(--muted); font: .8rem/1.8 ui-monospace,SFMono-Regular,Consolas,monospace; white-space: nowrap; }
.tag { font-size: var(--fs-xs); padding: 0 0.4rem; border-radius: var(--r1); background: var(--soft); color: var(--muted); white-space: nowrap; }
.news .tag { border-radius:999px; font-size:.7rem; padding:.15rem .55rem; background:color-mix(in srgb,var(--tag-color,var(--link)) 13%,var(--panel)); color:var(--ink); border:1px solid color-mix(in srgb,var(--tag-color,var(--link)) 35%,var(--line)); }
.tag-event { --tag-color:#d69a35; }
.tag-version { --tag-color:#4cb78c; }
.tag-news { --tag-color:#549be4; }
.tag-preview { --tag-color:#ac80d0; }
.tag-issue { --tag-color:#d76b68; }

/* All personal display controls share one route and stay out of the footer. */
.settings-page::before { display:none; }
.settings-page main { max-width:68rem; padding:1.5rem 1.5rem 3rem; background:none; border:0; border-radius:0; box-shadow:none; }
.settings-page .lead { color:var(--muted); font-size:var(--fs-sm); }
.settings-form { margin:1.6rem 0; }
.settings-row { display:grid; grid-template-columns:minmax(12rem,1fr) minmax(0,1.5fr); gap:2.5rem; padding:1.4rem 0; border-bottom:1px solid color-mix(in srgb,var(--ink) 8%,transparent); }
.settings-heading > label, .settings-heading h2 { display:block; margin:0; padding:0; border:0; color:var(--ink); font-size:1rem; font-weight:600; line-height:1.5; }
.settings-heading p { margin:.45rem 0 0; color:var(--muted); font-size:var(--fs-sm); max-width:28rem; }
.settings-controls { min-width:0; }
.settings-controls > select { max-width:22rem; }
.settings-pair label { display:block; font-size:var(--fs-sm); color:var(--muted); }
.settings-form select { width:100%; min-height:44px; padding:.55rem .65rem; border:1px solid var(--line); border-radius:var(--r1); background:var(--panel); color:var(--ink); font:inherit; }
.settings-pair select { margin:.4rem 0; }
.settings-pair { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.settings-check { display:flex; align-items:center; gap:.7rem; min-height:44px; font-size:var(--fs-sm); cursor:pointer; }
.settings-check input, .settings-toggle input { flex:none; width:1.1rem; height:1.1rem; margin:0; accent-color:var(--accent); cursor:pointer; }
.settings-toggle { display:flex; align-items:center; width:44px; min-height:44px; cursor:pointer; }
.settings-actions { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; padding:1.25rem 0; }
.settings-status { color:var(--muted); margin:0; font-size:var(--fs-sm); }
.settings-actions button { background:none; border-color:transparent; color:var(--muted); }
.settings-actions button:hover { color:var(--ink); background:var(--surface); }

/* catalog */
.filter, .tool-form input, .tool-form select {
  width: 100%; padding: 0.45rem 0.7rem; font: inherit; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2);
}
/* The dark scheme changes the input background, but the browser's default placeholder can
   stay dark as well. Without an explicit colour the empty filter looks like a stray box. */
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.filter { max-width: 24rem; }
/* A page with one group and no jump nav (Ages) puts the cards straight under the filter. */
.filter + .group { margin-top: 1rem; }
/* The group rail stays under the header while a long catalog scrolls. On a phone it
   becomes one horizontal strip instead of three wrapped rows. */
.jump {
  display: flex; flex-wrap: nowrap; gap: 0.4rem; margin: 0.75rem 0 1rem; padding: 0.45rem 0;
  position: sticky; top: var(--header-h); z-index: var(--layer-jump); overflow-x: auto; overscroll-behavior-x: contain;
  background: var(--bg); scrollbar-width: none;
}
.jump::-webkit-scrollbar { display: none; }
.jump a { flex: none; padding: 0.2rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-sm); background: var(--panel); }
.jump small { margin-inline-start: 0.3rem; }
.jump a[hidden] { display: none; }
.group > .jump { position: static; }
.catalog-tools + .jump { top: calc(var(--header-h) + var(--filters-h)); }
.group { scroll-margin-top: calc(var(--header-h) + var(--filters-h) + var(--jump-h) + 1rem); }
.group h2 { margin-bottom: 0.3rem; }
.catalog-tools { padding: 0.85rem; border: 1px solid var(--line); border-radius: var(--r2); background: var(--panel); }
.reference-page .jump { background: var(--surface); }
.group-jumps {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.5rem;
  margin: 1rem 0 1.5rem; padding: 0;
}
.group-jumps a {
  display: inline-flex; align-items: center; min-height: 2.75rem; max-width: 100%;
  padding: 0.45rem 0.75rem; border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--panel); font-size: var(--fs-sm); line-height: 1.4;
  overflow-wrap: anywhere; text-decoration: none;
}
.group-jumps a:hover { background: var(--soft); border-color: var(--link); }
[id^="reference-"] { scroll-margin-top: calc(var(--header-h) + 0.75rem); }
.card:hover { background: var(--soft); }
.group-note { margin: 0 0 0.75rem; max-width: 46rem; color: var(--muted); font-size: var(--fs-sm); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.5rem; }
/* A group's last row can be a single card. Without a bottom margin the next group's
   heading sits right under it and the two groups read as one. */
.group .cards { margin-bottom: 1.25rem; }
.card {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; color: inherit; min-width: 0; text-align: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2);
}
.card:hover { border-color: var(--link); text-decoration: none; }
.card.limit-hidden { display: none; }
.limit-more { display: block; margin: 0.55rem auto 0.9rem; }
.limit-more[hidden] { display: none; }
.card img, .noimg { width: 40px; height: 40px; object-fit: contain; flex: none; }
.noimg { display: inline-block; border-radius: var(--r1); background: var(--soft); }
.card span { min-width: 0; }
.card b, .card small { display: block; overflow-wrap: break-word; }
.card b { font-weight: 600; font-size: var(--fs-sm); line-height: 1.25; hyphens: auto; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.card small { font-size: var(--fs-xs); }
.card .stat { color: var(--ink); opacity: 0.8; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); }

/* Catalog filters sit in one band above the group rail. */
.catalog-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem 1rem; margin: 0.5rem 0 0; }
.catalog-tools .filter { flex: 1 1 16rem; max-width: 24rem; margin: 0; }
.catalog-tools label { display: grid; gap: 0.2rem; font-size: var(--fs-xs); color: var(--muted); }
.catalog-tools select { font: inherit; font-size: var(--fs-sm); padding: 0.4rem 0.55rem; border-radius: var(--r2); border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.catalog-total { margin-inline-start: auto; color: var(--muted); font-size: var(--fs-sm); align-self: center; }
.level-jump { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-sm); color: var(--muted); }
.level-jump select { font: inherit; font-size: var(--fs-sm); padding: 0.2rem 0.4rem; border-radius: var(--r1); border: 1px solid var(--line); background: var(--panel); color: inherit; }
/* The card catalog and the table are two views of the same rows. The table is its own
   route, so its pages do not double the weight of every catalog page. */
.view-switch {
  display: inline-flex; align-items: center; align-self: end; padding: 0.4rem 0.55rem;
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--panel);
  color: var(--link); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
}
.view-switch:hover { border-color: var(--link); text-decoration: none; }
.table-note { margin: 0.5rem 0 0.75rem; color: var(--muted); font-size: var(--fs-sm); }
.catalog-table-wrap { margin-top: .5rem; max-height: max(12rem, calc(90dvh - var(--header-h) - var(--filters-h))); overflow: auto; }
.catalog-table-wrap .catalog-table thead th { position: sticky; top: 0; z-index: var(--layer-table); background: var(--panel); }
.catalog-table { font-size: var(--fs-sm); }
.catalog-table th button {
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0; border: 0; background: none;
  font: inherit; font-weight: 600; color: inherit; cursor: pointer;
}
.catalog-table th button:hover { color: var(--link); }
.catalog-table th[aria-sort="ascending"] button::after { content: "↑"; }
.catalog-table th[aria-sort="descending"] button::after { content: "↓"; }
.catalog-table th, .catalog-table td { white-space: nowrap; }
.catalog-table td[data-key="effect"], .catalog-table td[data-key="target"], .catalog-table td[data-key="benefit"] {
  white-space: normal; min-width: 12rem; max-width: 24rem;
}
.catalog-table th[data-key="name"] { min-width: 12rem; }
.catalog-table .table-name { display: inline-flex; align-items: center; gap: 0.45rem; }
.catalog-table .table-name img { width: 28px; height: 28px; object-fit: contain; }
.catalog-table small { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.catalog-tools select[data-artifact-effect] { max-width: min(24rem, 100%); }
.catalog-table .artifact-evidence { white-space: normal; min-width: 9rem; max-width: 22rem; }
.artifact-evidence details[open] { width: 20rem; max-width: 65vw; }
@media (max-width: 600px) {
  .catalog-table:has(.artifact-evidence) th[data-key="name"] { min-width: 8rem; }
  .catalog-table:has(.artifact-evidence) th:has([data-sort-key="hall"]),
  .catalog-table:has(.artifact-evidence) th:has([data-sort-key="rarity"]),
  .catalog-table:has(.artifact-evidence) [data-key="hall"],
  .catalog-table:has(.artifact-evidence) [data-key="rarity"],
  .catalog-table[data-effect-selected] th:has([data-sort-key="benefit"]),
  .catalog-table[data-effect-selected] [data-key="benefit"] { display: none; }
  .catalog-table .artifact-evidence { min-width: 5rem; }
}
.catalog-table .pick { width: 2.2rem; text-align: center; }
.catalog-table tr[hidden] { display: none; }
.compare-bar {
  position: sticky; bottom: 0.75rem; z-index: 8; display: flex; align-items: center; gap: 0.6rem;
  width: fit-content; margin: 0.9rem 0 0 auto; padding: 0.45rem 0.7rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); font-size: var(--fs-sm);
}
.compare-bar[hidden] { display: none; }
.compare-bar button {
  padding: 0.25rem 0.65rem; border: 1px solid var(--line); border-radius: var(--r1);
  background: var(--soft); color: var(--ink); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.compare-bar button[disabled] { opacity: 0.5; cursor: default; }
.compare-dialog { width: min(58rem, 94vw); padding: 0; border: 1px solid var(--line); border-radius: var(--r2); }
.compare-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.compare-inner { padding: 1rem; }
.compare-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.compare-head h2 { margin: 0; }
.compare-head button { padding: 0.25rem 0.65rem; border: 1px solid var(--line); border-radius: var(--r1); background: var(--soft); color: var(--ink); font: inherit; font-size: var(--fs-sm); }
.compare-table th, .compare-table td { white-space: nowrap; }
.compare-table td.best { color: var(--link); font-weight: 700; }
/* The real table header can scroll under the site header on a phone or inside a long
   desktop table. A thin legend sticks under the site header and keeps the column names
   on screen; the table header still does the alignment work. */
.table-legend {
  display: flex; flex-wrap: wrap; gap: 0.15rem 0; position: sticky; top: var(--header-h); z-index: 6;
  padding: 0.35rem 0.65rem; margin: 0 0 -1px; background: var(--soft); border: 1px solid var(--line);
  border-bottom: 0; border-radius: var(--r2) var(--r2) 0 0; font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
}
.table-legend span { white-space: nowrap; }
.table-legend span:not([hidden]) ~ span:not([hidden])::before { content: "·"; margin-inline: 0.45rem; color: var(--line); }

/* entity */
.entity-head { display: flex; align-items: center; gap: 1rem; margin-top: 0.75rem; }
.entity-head img { width: 96px; height: 96px; object-fit: contain; flex: none; }
.entity-head h1 { margin: 0; }
.entity-head.artifact-head img { width: 72px; height: 72px; }
.artifact-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem 1.5rem; margin: 1rem 0 0; }
.artifact-summary > div { min-width: 0; }
.artifact-summary dt { color: var(--muted); font-size: var(--fs-xs); }
.artifact-summary dd { margin: 0; font-size: var(--fs-sm); }
.artifact-summary dd small { display: block; color: var(--muted); }
.artifact-summary .cost { display: inline-flex; align-items: center; gap: 0.3rem; }
.artifact-summary img { object-fit: contain; }
.artifact-benefits { margin-top: 1.25rem; }
.artifact-benefits td:nth-child(2) { min-width: 10rem; max-width: 20rem; }
.vip-benefits .table-wrap { width: fit-content; max-width: 100%; }
.vip-benefits th, .vip-benefits td { white-space: normal; overflow-wrap: anywhere; }
.vip-benefits th:first-child, .vip-benefits td:first-child { white-space: nowrap; }
.directive-group, .directive-detail { scroll-margin-top: calc(var(--header-h) + 1rem); }
.directive-index { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,10rem),1fr)); gap:.35rem .75rem; }
.directive-index a, .directive-detail header { display:flex; align-items:center; gap:.65rem; }
.directive-index a { min-width:0; overflow-wrap:anywhere; padding:.2rem 0; }
.directive-index img, .directive-detail header img { flex:none; object-fit:contain; }
.directive-detail { border-top:1px solid var(--line); padding-top:1rem; margin-top:2rem; }
.directive-detail header h2, .directive-detail header p { margin:.1rem 0; }
.directive-levels { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,16rem),1fr)); gap:1rem; }
.directive-levels h3 { color:var(--accent); }
.directive-levels dl > div { display:flex; justify-content:space-between; gap:1rem; border-top:1px solid var(--line); padding:.25rem 0; }
.directive-levels dt { color:var(--muted); }
.directive-levels dd { margin:0; text-align:end; }
.source-notes { margin-top: 1.25rem; border-block: 1px solid var(--line); padding: 0.35rem 0; font-size: var(--fs-sm); }
.source-notes > summary { color: var(--muted); }
.source-notes .data { margin-top: 1rem; }
.source-notes h2, .source-notes h3 { font-size: var(--fs-sm); margin: 1rem 0 0.3rem; }
.source-notes p { margin: 0.4rem 0; }
.source-notes .lead { font-size: inherit; }
.alt { margin: 0; color: var(--muted); }
.facts { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem; margin: 1rem 0; }
.facts div { background: var(--panel); padding: 0.4rem 0.75rem; border: 1px solid var(--line); border-radius: var(--r2); min-width: 8rem; }
.facts .wide { flex: 1 1 18rem; }
.facts dt { font-size: var(--fs-xs); color: var(--muted); }
.facts dd { margin: 0; }
.facts ul { margin: 0; padding-inline-start: 1.1rem; }
.data { margin-top: 2rem; }
.data h2 { margin: 0 0 0.6rem; }
.data .meta { margin: 0.4rem 0 0; font-size: var(--fs-xs); }
.nation-filter { display: inline-flex; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; font-size: var(--fs-sm); }
.nation-filter select { font: inherit; padding: 0.25rem 0.5rem; border-radius: var(--r1); border: 1px solid var(--line); background: var(--panel); color: inherit; }
.sort { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0 0.7rem; font-size: var(--fs-sm); }
.sort select { font: inherit; padding: 0.25rem 0.5rem; border-radius: var(--r1); border: 1px solid var(--line); background: var(--panel); color: inherit; }
.type-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.3rem 0 0.9rem; font-size: var(--fs-sm); }
.type-filter > span { color: var(--muted); }
.type-filter button { padding: 0.2rem 0.65rem; border-radius: 999px; font-size: var(--fs-xs); }
.type-filter button[aria-pressed="true"] { border-color: var(--link); color: var(--link); font-weight: 600; }
.type-filter button small { margin-inline-start: 0.25rem; }
.table-tools { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.table-tools .nation-filter { margin: 0; }
.table-tools[data-row-filter] { flex-wrap: wrap; align-items: end; margin: 0.6rem 0; }
.table-tools[data-row-filter] label { display: grid; gap: 0.25rem; min-width: 0; font-size: var(--fs-sm); }
.table-tools[data-row-filter] label:first-child { flex: 1 1 10rem; }
.table-tools[data-row-filter] input, .table-tools[data-row-filter] select { width: 100%; min-width: 0; box-sizing: border-box; font: inherit; padding: 0.45rem; border: 1px solid var(--line); border-radius: var(--r1); color: var(--ink); background: var(--panel); }
.table-tools[data-row-filter] output { white-space: nowrap; font-size: var(--fs-sm); color: var(--muted); padding-bottom: 0.45rem; }
.cols { position: relative; margin: 0; margin-inline-start: auto; }
.cols summary {
  list-style: none; width: 2rem; height: 2rem; display: grid; place-items: center; padding: 0; font-size: 1.1rem; line-height: 1;
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--panel); color: var(--link);
}
.cols summary::-webkit-details-marker { display: none; }
.cols summary.on { border-color: var(--link); background: var(--soft); }
.cols-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 8; width: max-content; max-width: min(22rem, 90vw);
  max-height: 60vh; overflow-y: auto; padding: 0.5rem 0.75rem; font-size: var(--fs-sm);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.cols-menu .presets { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0 0 0.5rem; }
.cols-menu ul { list-style: none; margin: 0; padding: 0; }
.cols-menu label { display: flex; gap: 0.4rem; align-items: baseline; padding: 0.1rem 0; cursor: pointer; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--panel); }
/* A short table stays as wide as its text instead of stretching across the page. */
.table-wrap.narrow { width: fit-content; max-width: 100%; }
/* Long tables scroll inside a frame so the header row stays visible. */
.table-wrap.long { max-height: min(80vh, 48rem); overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
th, td { padding: 0.4rem 0.65rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--soft); font-weight: 600; white-space: nowrap; position: sticky; top: 0; vertical-align: bottom; }
th small { display: block; font-size: var(--fs-xs); font-weight: 500; }
th.n, td.n { text-align: end; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:nth-child(even) td { background: var(--stripe); }
tbody tr:hover td { background: var(--soft); }
.data td:first-child, .data th:first-child { position: sticky; inset-inline-start: 0; background: var(--panel); font-weight: 600; }
/* A line under the pinned first column so scrolled cells do not appear to touch it. */
.data td:first-child, .data th:first-child { box-shadow: 1px 0 0 var(--line); }
th { z-index: 2; }
.data th:first-child { background: var(--soft); z-index: 3; }
.data td:first-child { z-index: 1; }
.data tbody tr:nth-child(even) td:first-child { background: var(--stripe); }
.data tbody tr:hover td:first-child { background: var(--soft); }
td .cost { display: inline-flex; align-items: center; gap: 0.2rem; white-space: nowrap; }
td .cost + .cost { margin-inline-start: 0.6rem; }
td a { white-space: nowrap; }
.na { color: var(--muted); }
.entity-hero { padding:0 0 1.3rem; border-bottom:1px solid var(--line); margin-bottom:1rem; }
.entity-hero .entity-head { align-items:center; border:0; }
.entity-hero .lead { max-width:70ch; font-size:1rem; }
.entity-summary { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:1px; background:var(--line); border:1px solid var(--line); border-radius:var(--r1); overflow:hidden; margin:1.2rem 0; }
.entity-summary > div { background:var(--surface); padding:.8rem 1rem; min-width:0; }
.entity-summary dt { font-size:var(--fs-xs); color:var(--muted); }
.entity-summary dd { margin:.3rem 0 0; font-size:1.1rem; font-weight:600; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.entity-hero .buttons { margin-bottom:0; }
.entity-tabs { display:flex; gap:.3rem; border-bottom:1px solid var(--line); margin:1.4rem 0; overflow-x:auto; }
.entity-tabs button { flex:1; min-width:0; min-height:48px; padding:.65rem .8rem; border:0; border-bottom:2px solid transparent; border-radius:0; background:none; color:var(--muted); overflow-wrap:anywhere; }
.entity-tabs button[aria-selected="true"] { border-color:var(--accent); color:var(--ink); background:var(--surface); }
.level-explorer { margin:1.4rem 0; padding:1.2rem; background:var(--surface); border:1px solid var(--line); border-radius:var(--r2); }
.level-explorer-heading { display:flex; justify-content:space-between; align-items:center; gap:1rem; }
.level-explorer h2 { font-size:1.15rem; margin:0; }
.level-explorer output { color:var(--accent); font-variant-numeric:tabular-nums; }
.level-controls { display:grid; grid-template-columns:minmax(0,1fr) minmax(4rem,2fr) minmax(0,1fr); gap:1rem; align-items:end; margin:1rem 0; }
.level-controls label { display:grid; gap:.4rem; min-width:0; color:var(--muted); font-size:var(--fs-xs); }
.level-controls select { width:100%; min-width:0; background:var(--panel); color:var(--ink); border:1px solid var(--line); border-radius:var(--r1); padding:.55rem; min-height:42px; font:inherit; font-size:var(--fs-sm); }
.level-controls input[type="range"] { width:100%; min-width:0; margin-block:auto; accent-color:var(--accent); }
.level-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.6rem; }
.level-metric { min-width:0; padding:.8rem; background:var(--panel); border:1px solid var(--line); border-radius:var(--r1); display:flex; flex-direction:column; gap:.3rem; }
.level-metric > span { color:var(--muted); font-size:var(--fs-xs); }
.level-metric strong { font-size:1rem; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.level-metric small { color:var(--muted); font-variant-numeric:tabular-nums; }
.level-metric .cost { display:inline-flex; align-items:center; gap:.3rem; margin-inline-end:.5rem; }
.level-explorer .note { margin-bottom:0; }
.catalog-view { display:flex; align-items:center; gap:.2rem; }
.catalog-view button { min-height:38px; padding:.4rem .55rem; font-size:var(--fs-xs); }
.catalog-view button[aria-pressed="true"] { color:var(--accent); border-color:var(--accent); }
.catalog-tools { position:sticky; top:var(--header-h); z-index:var(--layer-filters); }
.catalog-tools > * { min-width:0; }
.catalog-tools select { max-width:20rem; width:100%; }
main[data-catalog-view="compact"] .cards { display:grid; grid-template-columns:1fr; gap:0; }
main[data-catalog-view="compact"] .card { border-radius:0; border-width:0 0 1px; padding:.5rem .7rem; }
main[data-catalog-view="compact"] .card > span { display:grid; grid-template-columns:minmax(8rem,2fr) minmax(6rem,1fr) minmax(4rem,1fr); gap:1rem; align-items:center; width:100%; }
main[data-catalog-view="compact"] .card .stat { text-align:end; }
.resource-number { font-variant-numeric:tabular-nums; }
.data td.stat-bar { background-image:linear-gradient(90deg,color-mix(in srgb,var(--accent) 11%,transparent) var(--stat-bar),transparent var(--stat-bar)); background-repeat:no-repeat; }
@media(max-width:600px) {
  .entity-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .entity-summary > div { padding:.7rem; }
  .entity-tabs button { font-size:var(--fs-xs); padding:.6rem .4rem; }
  .level-explorer { padding:.8rem; }
  .level-controls { grid-template-columns:repeat(2,minmax(0,1fr)); gap:.7rem; }
  .level-controls input[type="range"] { grid-column:1/-1; grid-row:2; }
  .level-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .catalog-tools, .catalog-tools + .jump, .jump { position:static; }
  .catalog-tools label { max-width:100%; flex:1 1 8rem; }
  .catalog-tools select { max-width:100%; }
  main[data-catalog-view="compact"] .card > span { grid-template-columns:minmax(0,1fr) auto; gap:.2rem .5rem; }
  main[data-catalog-view="compact"] .card > span > small:not(.stat) { grid-column:1; }
  main[data-catalog-view="compact"] .card .stat { grid-column:2; grid-row:1/3; }
  .data .table-wrap th { position:sticky; top:0; }
}
.art { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
.art figure { margin: 0; padding: 0.5rem; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); }
.art img { width: auto; height: auto; max-height: 110px; }
.art figcaption { font-size: var(--fs-xs); color: var(--muted); }
details { margin: 0.5rem 0; }
summary { cursor: pointer; padding: 0.3rem 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding-block: 0.25rem; padding-inline: 0.3rem 0.6rem;
  min-height: 1.75rem; font-size: var(--fs-sm);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: inherit;
}
.chip:hover { border-color: var(--link); text-decoration: none; }
.chip img { width: 24px; height: auto; max-height: 24px; object-fit: contain; }
.chip .noimg { width: 24px; height: 24px; }
.chip small { font-size: var(--fs-xs); }
.related h3 { margin: 1rem 0 0.5rem; }
.affected td:first-child > a { display: inline-flex; align-items: center; gap: 0.35rem; white-space: normal; }
.affected td:first-child img { width: 24px; height: 24px; flex: none; }
/* An empty placeholder only indents the name here. */
.affected .noimg { display: none; }
.affected td:first-child { min-width: 11rem; max-width: 24rem; }
.affected .names { display: flex; flex-wrap: wrap; }
.affected .names a { display: inline-flex; align-items: center; min-height: 1.5rem; }
.affected .names a:not(:last-child)::after { content: ","; color: var(--muted); margin-inline-end: 0.3em; }
.related h4 { margin: 0.8rem 0 0.4rem; font-size: var(--fs-sm); }
.affected td small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; margin: 1rem 0; font-size: var(--fs-sm); }
.pager .count { margin-inline: auto; }
.report { margin-top: 3rem; font-size: var(--fs-sm); }

/* articles */
.prose { max-width: 48rem; }
/* A closing acknowledgement, not part of the reference text above it. */
.prose .thanks { margin-top: 1.6rem; padding-top: 0.9rem; border-top: 1px solid var(--line); color: var(--muted); }
/* Links inside a sentence must not rely on colour alone (WCAG 1.4.1), on any page. */
.prose a, main :is(p, li, dd, dt) a { text-decoration: underline; text-underline-offset: 0.15em; }
.prose h2 { margin-top: 2rem; }
.prose .table-wrap { margin: 1rem 0; }
.prose td, .prose th { min-width: 5.5em; }
.prose li { margin: 0.25rem 0; }
.prose pre { margin: 1rem 0; padding: 0.8rem 1rem; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2); font-size: var(--fs-sm); line-height: 1.5; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.prose :not(pre) > code { padding: 0.1rem 0.3rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r1); font-size: 0.92em; }
.prose pre code { font-family: inherit; }
.articles { list-style: none; padding: 0; margin: 0; }
.articles li { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.articles p { margin: 0.2rem 0 0; color: var(--muted); font-size: var(--fs-sm); }

/* tools */
.tool-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.75rem 1rem; margin: 1.25rem 0; align-items: end; }
.tool-form label { display: grid; gap: 0.25rem; font-size: var(--fs-sm); color: var(--muted); }
.tool-form .wide, .tool-form fieldset { grid-column: 1 / -1; }
.tool-form fieldset {
  margin: 0; padding: 0.6rem 0.9rem 0.9rem; border: 1px solid var(--line); border-radius: var(--r2); background: var(--panel);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.6rem 1rem;
}
.tool-form legend { font-weight: 600; font-size: var(--fs-sm); padding: 0 0.3rem; color: var(--ink); }
/* The scenario preset is one full-width block, not one fieldset cell per paragraph. */
#scenario p, #scenario .scenario-summary { grid-column: 1 / -1; }
#scenario .scenario-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.scenario-summary { display: grid; gap: 0.4rem; }
.tool-form label.check { grid-column: 1 / -1; display: flex; gap: 0.5rem; align-items: baseline; color: var(--ink); }
.tool-form label.check input { width: auto; }
.tool-form p { margin: 0; }
.tool-form .sub { grid-column: 1 / -1; margin: 0.3rem 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
#cut-list { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.35rem 1rem; }
#cut-list label.check { grid-column: auto; }
.tool-form label.pct { color: var(--ink); }
.tool-form label.pct small { color: var(--muted); }
.tool-form .pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.tool-form .pair fieldset { grid-column: auto; grid-template-columns: 1fr; }
/* Growth curves: the checkbox fieldset is one column, the chart is plain SVG. */
.growth-form fieldset { grid-template-columns: 1fr; }
.growth-group { display: grid; gap: 0.3rem; }
.growth-group + .growth-group { margin-top: 0.6rem; }
.growth-picks { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }
.growth-picks .pick { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-sm); color: var(--ink); }
.growth-picks input { width: auto; }
.growth-chart { margin: 1rem 0; }
.growth-plot svg { display: block; width: 100%; height: auto; }
.growth-plot .grid { stroke: var(--line); stroke-width: 1; }
.growth-plot .axis { fill: var(--muted); font-size: 11px; }
.growth-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: var(--fs-sm); }
.growth-legend i { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; margin-inline-end: 0.35rem; vertical-align: -0.05rem; }
#growth-table caption { text-align: start; padding: 0.25rem 0 0.5rem; color: var(--muted); font-size: var(--fs-sm); }
.plan { width: 100%; }
.plan td { vertical-align: middle; }
.plan input { width: 5.5rem; padding: 0.3rem 0.5rem; text-align: end; }
.plan td small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.plan th:first-child { min-width: 12rem; }
button.icon { padding: 0.15rem 0.55rem; line-height: 1.2; font-size: 1.1rem; background: transparent; border: 1px solid var(--line); border-radius: var(--r1); color: var(--muted); cursor: pointer; min-width: 2.5rem; min-height: 2.5rem; }
button.icon:hover { color: var(--ink); border-color: var(--muted); }
/* Touch screens need bigger targets than a mouse needs. */
@media (pointer: coarse) {
  button.icon, .cols summary { min-width: 2.75rem; min-height: 2.75rem; }
}
.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.bonus-table input { min-width: 5rem; padding: 0.3rem 0.5rem; }
.bonus-table th[scope] { white-space: nowrap; }
.tool-result { margin: 1rem 0; }
.tool-result .table-wrap { width: fit-content; max-width: 100%; }
.tool-result .facts dd { font-size: var(--fs-md); font-weight: 600; }
.tool-result .cost { display: inline-flex; align-items: center; gap: 0.2rem; margin-inline-end: 0.6rem; white-space: nowrap; }
.notes { color: var(--muted); font-size: var(--fs-sm); max-width: 50rem; padding-inline-start: 1.2rem; margin-top: 2rem; }
.notes li { margin: 0.3rem 0; }
.warn { color: var(--warn); font-size: var(--fs-sm); }
.pick-list section h3 { margin: 1rem 0 0.4rem; font-size: var(--fs-sm); color: var(--muted); }
.pick-list ul, .setup, .saved { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.pick-list ul { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pick-list li, .setup li {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2);
}
.pick-list li > span { flex: 1; min-width: 0; }
/* Two lines are usually enough for a name and its benefits; the tooltip has the rest. */
.pick-list b, .pick-list small {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  overflow-wrap: break-word; white-space: normal;
}
.pick-list b { font-size: var(--fs-sm); }
.pick-list small { font-size: var(--fs-xs); color: var(--muted); }
.pick-list li > button { flex: none; }
.pick-list img, .setup img, .pick-list .noimg, .setup .noimg { width: 32px; height: 32px; object-fit: contain; flex: none; }
.setup li { flex-wrap: wrap; }
.setup b { flex: 1 1 10rem; font-size: var(--fs-sm); }
.setup-source { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.setup label { font-size: var(--fs-xs); color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; max-width: 100%; }
.setup select { font: inherit; font-size: var(--fs-sm); max-width: 100%; min-width: 0; padding: 0.2rem 0.4rem; border-radius: var(--r1); border: 1px solid var(--line); background: var(--panel); color: inherit; }
.setup .benefit-levels { flex: 1 0 100%; min-width: 0; }
.setup .benefit-levels label { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.setup .benefit-levels select { flex: 0 0 4rem; }
.saved li { display: flex; gap: 0.5rem; align-items: center; }

/* root and 404 */
.gate main { max-width: 34rem; padding-top: 14vh; text-align: center; }
.lang-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.4rem; }
.lang-grid a { display: block; padding: 0.45rem; border: 1px solid var(--line); border-radius: var(--r2); background: var(--panel); }
.root-summary { margin-top:2rem; text-align:left; }
.root-summary nav { display:flex; flex-wrap:wrap; gap:.6rem 1.2rem; }
.root-summary .list p { margin:.2rem 0 .7rem; color:var(--muted); }

@media (max-width: 1320px) {
  .top-in { gap:.5rem; }
  .nav-toggle { display:inline-flex; flex:none; border:0; background:none; }
  .nav { display:none; position:absolute; top:100%; left:1rem; right:1rem; padding:.6rem; background:var(--panel); border:1px solid var(--line); border-radius:var(--r2); box-shadow:var(--shadow); max-height:calc(100dvh - 80px); overflow:auto; }
  .top-in.nav-open .nav { display:flex; flex-direction:column; align-items:stretch; }
  .nav-menu > div { position:static; box-shadow:none; border:0; padding:0 0 0 1rem; }
  .top .search { max-width:24rem; }
  .home-catalog { gap:.4rem; }
  .home-catalog a { flex-wrap:wrap; gap:.2rem .5rem; }
}
@media (max-width: 600px) {
  :root { --header-h:61px; --scene: url('/img/a99d951edaf9.webp'); }
  body::before { height:510px; background-size:auto,auto 510px; }
  .home-page { --home-height:500px; }
  .home-page::before { background-size:auto,auto,auto 500px; background-position:center,center,65% top; }
  .reference-page main { margin: 0; border: 0; border-radius: 0; padding: 1rem 0.85rem 2rem; }
  .home-stage { padding:46px 0 36px; gap:2rem; }
  .hero { width:100%; }
  .hero h1 { font-size:1.6rem; }
  .hero p { font-size:.75rem; }
  .hero-version { font-size:.65rem; margin-left:.5rem; }
  .home-catalog { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .home-catalog a:last-child { grid-column:1/-1; flex-direction:row; }
  .home-catalog a { flex-direction:column; padding:.5rem .3rem; }
  .home-tool-list { grid-template-columns:1fr; gap:.6rem; }
  .home-feed { grid-template-columns:minmax(0,1fr); gap:1.5rem; }
  .settings-row { grid-template-columns:minmax(0,1fr); gap:.8rem; padding:1.1rem 0; }
  .settings-controls > select { max-width:none; }
  .settings-page main { padding:1.2rem 1rem 2rem; }
  .section-heading { align-items:center; }
  .section-heading h2 { margin-bottom:.7rem; }
  .list li.news { grid-template-columns:6.4rem 1fr; gap:.35rem .7rem; }
  .news .tag { justify-self:start; }
  .news > a { grid-column:1/-1; }
  h1 { font-size: var(--fs-lg); }
  .top-in { gap:.2rem; padding:8px .6rem; }
  .logo { font-size:1.05rem; gap:.4rem; }
  .logo .brand-mark { width:34px; height:34px; }
  .logo > span { display:none; }
  .settings-link { width:38px; padding:.4rem; }
  .langs { min-width:0; }
  .langs summary { min-width:44px; max-width:none; padding:.4rem; }
  .language-full { display:none; }
  .language-short { display:inline; }
  .langs ul { position:fixed; top:var(--header-h); left:.6rem; right:.6rem; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .langs ul a { white-space:normal; }
  .top .search { max-width: none; }
  .top .search input { padding-inline:.6rem; }
  .top .search kbd { display:none; }
  .top .results { position:fixed; top:var(--header-h); left:.6rem; right:.6rem; min-width:0; }
  /* Keep a 100-level table from making the page itself thousands of pixels long. The
     legend still sticks under the site header, so the column names stay visible while the
     table scrolls inside its own frame. */
  .table-wrap.long { max-height: min(70vh, 40rem); overscroll-behavior: contain; }
  th { position: static; }
  /* Tables generated by a tool have no separate legend, so their header stays inside
     the scroll frame. Server tables keep the sticky legend added by src/table.mjs. */
  #growth-table th, .tool-result .table-wrap.long th, .tool-form .table-wrap.long th { position: sticky; top: 0; }
  .catalog-total { flex-basis: 100%; margin-inline-start: 0; }
  .catalog-tools { gap: 0.6rem 0.75rem; padding: 0.7rem; }
  .catalog-tools .filter { flex-basis: 100%; max-width: none; }
  .catalog-tools label { flex: 1 1 8rem; min-width: 0; }
  .catalog-tools select { width: 100%; min-width: 0; }
  .compare-bar { width: 100%; margin-inline: 0; justify-content: space-between; }
  .page-toc { margin-bottom: 0.75rem; }
  tr:target td, tr:target th { background: var(--soft); }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  /* Japanese category names are long and have no spaces, so those tiles get a full row. */
  html[lang="ja"] .tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  /* One block per source, with the three fields side by side and labels above them. */
  .bonus-wrap { border: 0; background: none; }
  .bonus-table, .bonus-table tbody, .bonus-table tr, .bonus-table th, .bonus-table td { display: block; }
  .bonus-table thead { display: none; }
  .bonus-table tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.35rem 0.5rem; margin-bottom: 0.5rem;
    padding: 0.5rem 0.6rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r2);
  }
  .bonus-table tr:last-child { margin-bottom: 0; }
  .bonus-table th { grid-column: 1 / -1; position: static; padding: 0; border: 0; background: none; white-space: normal; }
  .bonus-table td { padding: 0; border: 0; }
  .bonus-table td::before { content: attr(data-h); display: block; font-size: var(--fs-xs); color: var(--muted); }
  .bonus-table input { width: 100%; min-width: 0; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .card { gap: 0.4rem; padding: 0.4rem 0.45rem; }
  .card img, .card .noimg { width: 32px; height: 32px; }
  .entity-head img { width: 72px; height: 72px; }
  .entity-head.artifact-head img { width: 56px; height: 56px; }
  .artifact-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem 1rem; }
  .facts div { flex: 1 1 40%; }
  .pick-list { min-height: 4rem; max-height: min(70vh, 40rem); overflow-y: auto; overscroll-behavior: contain; }
}

/* Number lab: the three numbers first, the detail rows after. */
.sim-form { margin-bottom: 1rem; }
.sim-result { margin-top: 1rem; }
.verdict { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 0.75rem 0; }
.verdict-cell { border: 1px solid var(--line); border-radius: var(--r2); padding: 0.5rem 0.65rem; background: var(--panel); }
.verdict-cell .k { display: block; font-size: var(--fs-xs); color: var(--muted); }
.verdict-cell .v { display: block; font-size: var(--fs-lg); font-weight: 600; }
.verdict-cell small { display: block; font-size: var(--fs-xs); color: var(--muted); }
.sim-assumptions { margin-top: 0.75rem; }
.sim-assumptions summary { cursor: pointer; color: var(--muted); }
.sim-assumptions ul { margin: 0.4rem 0 0; padding-inline-start: 1.2rem; }
@media (max-width: 600px) { .verdict { grid-template-columns: 1fr; } }

/* Manufacturing: an icon-led ledger with a pinned name column and explicit totals. */
.mfg-views, .mfg-actions { display:flex; flex-wrap:wrap; gap:.5rem; margin:.8rem 0; }
.mfg-views [aria-pressed="true"] { background:var(--link); color:var(--panel); border-color:var(--link); }
.mfg-controls { display:flex; flex-wrap:wrap; gap:.8rem 1.3rem; align-items:end; padding:1rem; background:var(--panel); border:1px solid var(--line); border-radius:var(--r2); }
.mfg-controls label { display:grid; gap:.3rem; font-size:var(--fs-xs); color:var(--muted); }
.mfg-controls select, .mfg-controls input { font:inherit; font-size:var(--fs-sm); padding:.5rem; border:1px solid var(--line); border-radius:var(--r1); color:var(--ink); background:var(--bg); max-width:100%; }
.mfg-controls > label { flex:1 1 14rem; min-width:0; }
.mfg-target { display:flex; flex-wrap:wrap; gap:.6rem; align-items:end; margin:.6rem 0; }
.mfg-target label { flex:1 1 5rem; }
.mfg-target label:first-child { flex:3 1 15rem; }
.mfg-stock-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:.8rem; margin:1rem 0; }
.mfg-stock-grid label { display:grid; gap:.3rem; min-width:0; }
.mfg-stock-grid input { width:100%; min-width:0; }
#mfg-levels { display:flex; align-items:end; gap:.55rem; }
#mfg-levels > span { align-self:center; }
#mfg-count { width:6rem; }
.mfg-heading { margin:1.25rem 0 .7rem; }
.mfg-heading h2 { display:flex; align-items:center; gap:.6rem; margin:0; }
.mfg-heading h2 img { width:48px; height:48px; object-fit:contain; }
.mfg-heading p { color:var(--muted); margin:.3rem 0; font-variant-numeric:tabular-nums; }
.mfg-scroll { max-height:70vh; overflow:auto; scroll-padding-top:6rem; scroll-padding-bottom:3rem; border:1px solid var(--line); border-radius:var(--r2); }
.mfg-matrix { width:100%; border-collapse:separate; border-spacing:0; font-variant-numeric:tabular-nums; }
.mfg-matrix caption { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.mfg-matrix th, .mfg-matrix td { padding:.55rem .65rem; border-inline-end:1px solid var(--line); }
.mfg-matrix thead th { position:sticky; top:0; z-index:2; background:var(--panel); min-width:5.2rem; vertical-align:bottom; }
.mfg-matrix th:first-child { position:sticky; inset-inline-start:0; z-index:1; background:var(--panel); min-width:7rem; max-width:13rem; }
.mfg-matrix thead th:first-child { z-index:3; }
.mfg-matrix th a, .mfg-matrix th button { display:flex; align-items:center; gap:.45rem; color:inherit; font:inherit; text-align:start; }
.mfg-matrix th button { border:0; background:transparent; padding:0; cursor:pointer; }
.mfg-matrix th button:hover { color:var(--link); }
.mfg-matrix thead a { flex-direction:column; font-size:var(--fs-xs); text-align:center; line-height:1.3; }
.mfg-matrix img { object-fit:contain; flex:none; }
.mfg-matrix td.n { font-size:var(--fs-sm); }
.mfg-matrix .empty { color:var(--muted); opacity:.45; }
.mfg-matrix tbody tr:hover > * { background:var(--soft); }
.mfg-matrix .mfg-stage > * { border-top:2px solid var(--link); }
.mfg-matrix tfoot > tr > * { position:sticky; bottom:0; z-index:2; font-weight:700; background:var(--panel); border-top:2px solid var(--link); }
.mfg-matrix tfoot th:first-child { z-index:3; }
.table-export { margin:.5rem 0; }
.table-export button { font-size:var(--fs-sm); padding:.35rem .65rem; }
.entity-downloads { display:flex; flex-wrap:wrap; gap:.45rem; font-size:var(--fs-sm); }
#spawn-form { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:1rem; }
#spawn-form label { display:flex; flex-direction:column; gap:.35rem; min-width:0; }
#spawn-form input,#spawn-form select { width:100%; min-width:0; }
[data-download-entry] { max-width:100%; }
.mfg-materials { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:.6rem; list-style:none; padding:0; }
.mfg-materials li { padding:.75rem; background:var(--panel); border:1px solid var(--line); border-radius:var(--r2); }
.mfg-materials a { display:flex; align-items:center; gap:.5rem; font-size:var(--fs-sm); color:inherit; }
.mfg-materials strong { display:block; font-size:var(--fs-lg); margin:.5rem 0 0; font-variant-numeric:tabular-nums; }
@media(max-width:600px) { .mfg-controls { padding:.7rem; } #mfg-levels { flex-wrap:wrap; } .mfg-matrix th:first-child { max-width:8.5rem; } .mfg-matrix th:first-child img { display:none; } .mfg-matrix th,.mfg-matrix td { padding:.45rem; } .mfg-materials { grid-template-columns:repeat(2,minmax(0,1fr)); } }
