/* Starlight Wardens wiki.
   Warm parchment / ember palette — deliberately no blue or violet.
   Light and dark are both first-class; the system preference picks the start. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f7f2e9;
  --bg-deep: #efe7d8;
  --surface: #fffdf9;
  --surface-2: #f4ede0;
  --surface-3: #e9dfcc;
  --line: #ded2bd;
  --line-strong: #c9b99e;

  /* text */
  --ink: #211b13;
  --ink-2: #5b5040;
  --ink-3: #8a7c66;

  /* accents */
  --accent: #b45309;
  --accent-soft: #d97706;
  --accent-ink: #ffffff;
  --accent-wash: #fdf0dd;
  --accent-line: #f0c48a;
  --jade: #15803d;
  --jade-wash: #e6f4ea;
  --crimson: #b91c1c;

  /* rarity */
  --common: #78716c;
  --rare: #0f766e;
  --epic: #9d174d;
  --legendary: #b45309;
  --mythic: #c81e1e;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-1: 0 1px 2px #211b1314, 0 4px 12px -6px #211b1320;
  --shadow-2: 0 2px 4px #211b1314, 0 18px 40px -20px #211b1333;
  --ring: 0 0 0 3px #b4530926;

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
          "Noto Sans", "Noto Sans SC", "Noto Sans JP", "Hiragino Sans",
          "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
           "Songti SC", "Noto Serif SC", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --side: 276px;
  --topbar: 68px;
}

/* Dark palette: warm charcoal, not navy. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110d;
  --bg-deep: #0e0c09;
  --surface: #1d1914;
  --surface-2: #262019;
  --surface-3: #312a20;
  --line: #362d22;
  --line-strong: #4a3d2d;

  --ink: #f6efe3;
  --ink-2: #bdaf99;
  --ink-3: #8b7d67;

  --accent: #f0a93b;
  --accent-soft: #f5c069;
  --accent-ink: #1a1308;
  --accent-wash: #2b2114;
  --accent-line: #5c452a;
  --jade: #5fd68a;
  --jade-wash: #182a1d;
  --crimson: #f0736a;

  --common: #a3967d;
  --rare: #4fd1b5;
  --epic: #f472b6;
  --legendary: #f0a93b;
  --mythic: #ef4444;

  --shadow-1: 0 1px 2px #0006, 0 6px 16px -8px #0008;
  --shadow-2: 0 2px 6px #0007, 0 24px 50px -24px #000a;
  --ring: 0 0 0 3px #f0a93b33;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17.5px;
  line-height: 1.64;
  -webkit-font-smoothing: antialiased;
}

/* A faint paper grain keeps the flat surfaces from reading as dead space. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .5;
  background-image: radial-gradient(var(--line) .5px, transparent .5px);
  background-size: 4px 4px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 20%, transparent 75%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(1.75rem, 1.1rem + 2.4vw, 2.75rem); letter-spacing: -.035em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .85em; }

::selection { background: var(--accent-line); color: var(--ink); }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 300;
  padding: .6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 650;
}
.skip:focus { left: 0; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; gap: .75rem;
  height: var(--topbar);
  padding: 0 clamp(.75rem, 2vw, 1.5rem);
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--line);
}

.menu-btn {
  display: none; flex: none; cursor: pointer; line-height: 0;
  width: 36px; height: 36px; place-items: center;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.menu-btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }

.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 750; font-size: .98rem; letter-spacing: -.01em; }
.brand-sub { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

.search {
  position: relative; flex: 1 1 auto; max-width: 560px; margin-inline: auto;
  display: flex; align-items: center; gap: .5rem;
  height: 38px; padding: 0 .75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent-line); box-shadow: var(--ring); }
.search svg { width: 16px; height: 16px; stroke: var(--ink-3); stroke-width: 2; fill: none; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  color: var(--ink); font: inherit; font-size: 1rem;
}
.search input::placeholder { color: var(--ink-3); }
.search kbd {
  font: 600 .66rem var(--mono); color: var(--ink-3);
  border: 1px solid var(--line-strong); border-radius: 5px; padding: .05rem .3rem;
}

.search-results {
  position: absolute; top: calc(100% + .4rem); left: 0; right: 0; z-index: 90;
  max-height: min(64vh, 480px); overflow: auto; padding: .35rem;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.search-results a {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .6rem; border-radius: var(--radius-sm); color: var(--ink);
}
.search-results a:hover, .search-results a:focus-visible {
  background: var(--surface-2); text-decoration: none;
}
.sr-kind {
  margin-left: auto; flex: none;
  font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.sr-empty { padding: .9rem; color: var(--ink-3); font-size: .88rem; }

.top-actions { display: flex; align-items: center; gap: .35rem; flex: none; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[hidden] { display: none; }

.lang {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.lang button {
  border: 0; background: none; cursor: pointer; font: inherit;
  font-size: .78rem; color: var(--ink-2); padding: .22rem .5rem; border-radius: 999px;
  transition: background .15s, color .15s;
}
.lang button:hover { color: var(--ink); }
.lang button.on { background: var(--accent); color: var(--accent-ink); font-weight: 650; }

/* ------------------------------------------------------------------ shell */
.sidenav {
  position: fixed; inset: 0 auto 0 0; z-index: 70;
  width: var(--side); padding: calc(var(--topbar) + 1rem) .6rem 2rem;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
}

.nav-group { margin-bottom: 1.35rem; }
.nav-title {
  display: block; padding: 0 .72rem .4rem;
  font-size: .69rem; font-weight: 750; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-3);
}
.sidenav a {
  position: relative; display: flex; align-items: center; gap: .65rem;
  padding: .52rem .75rem; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: .98rem; font-weight: 500;
  transition: background .14s, color .14s;
}
.sidenav a:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.sidenav a.on { background: var(--surface); color: var(--accent); font-weight: 650; }
.sidenav a.on::before {
  content: ""; position: absolute; left: 0; top: 50%; translate: 0 -50%;
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-ico { width: 16px; height: 16px; flex: none; opacity: .75; }
.sidenav a.on .nav-ico { opacity: 1; }

main { margin-left: var(--side); position: relative; z-index: 1; }
.view {
  padding: clamp(1.1rem, 2.4vw, 2.2rem) clamp(.9rem, 2.6vw, 2.6rem) 3.5rem;
  max-width: 1240px; margin-inline: auto;
}

.footer {
  margin-left: var(--side); position: relative; z-index: 1;
  padding: 1.6rem clamp(.9rem, 2.6vw, 2.6rem) calc(2.6rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); color: var(--ink-3); font-size: .8rem;
}
.footer p { margin: 0 0 .35rem; }
.mono { font-family: var(--mono); font-size: .74rem; letter-spacing: -.01em; }

.scrim { position: fixed; inset: 0; z-index: 65; background: #00000059; backdrop-filter: blur(2px); }
.scrim[hidden] { display: none; }

/* ------------------------------------------------------------------- hero */
.hero {
  position: relative; overflow: hidden;
  padding: clamp(1.6rem, 4vw, 3.2rem) clamp(1.1rem, 3vw, 2.6rem);
  margin-bottom: 1.6rem;
  background:
    radial-gradient(120% 130% at 88% -20%, var(--accent-wash) 0%, transparent 55%),
    radial-gradient(90% 120% at 0% 110%, var(--jade-wash) 0%, transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 22%, var(--accent-line) 0 1.5px, transparent 2px),
    radial-gradient(circle at 68% 12%, var(--accent-line) 0 1px, transparent 1.6px),
    radial-gradient(circle at 88% 64%, var(--jade) 0 1px, transparent 1.6px),
    radial-gradient(circle at 42% 82%, var(--accent-line) 0 1px, transparent 1.6px),
    radial-gradient(circle at 26% 58%, var(--accent-soft) 0 1px, transparent 1.6px);
  opacity: .5;
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .68rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .6rem;
}
.hero h1 { margin-bottom: .5rem; max-width: 20ch; }
.hero .lede { max-width: 62ch; color: var(--ink-2); font-size: 1.02rem; margin: 0 0 1.4rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: 999px;
  font: inherit; font-size: .88rem; font-weight: 650; cursor: pointer;
  border: 1px solid transparent; transition: transform .12s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.btn.primary:hover { background: var(--accent-soft); text-decoration: none; }
.btn.ghost {
  background: var(--surface); color: var(--ink); border-color: var(--line-strong);
}
.btn.ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }

/* -------------------------------------------------------------- page heads */
.page-head { margin-bottom: 1.3rem; }
.page-head .eyebrow {
  font-size: .66rem; font-weight: 750; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .3rem;
}
.page-head h1 { margin-bottom: .35rem; }
.page-head .lede { color: var(--ink-2); max-width: 70ch; margin: 0; }

/* ------------------------------------------------------------------- stats */
.stat-grid {
  display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  margin-bottom: 1.6rem;
}
.stat-tile {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .85rem .95rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.stat-tile:hover { text-decoration: none; border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.stat-tile .k { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); font-weight: 650; }
.stat-tile .v { font-size: 1.9rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--accent); }
.stat-tile .s { font-size: .76rem; color: var(--ink-3); }

/* ------------------------------------------------------------------- grids */
.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); align-items: stretch; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.grid.compact { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); }

/* ------------------------------------------------------------------ cards */
.card {
  position: relative; display: flex; flex-direction: column; gap: .7rem;
  height: 100%;
  padding: 1.05rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  transition: transform .16s cubic-bezier(.2,.7,.3,1), border-color .16s, box-shadow .16s;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.card.is-link:hover { text-decoration: none; }

/* rarity/kind edge */
.card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--edge, transparent);
}

.card-top { display: flex; gap: .7rem; align-items: flex-start; }
.card-icon {
  width: 58px; height: 58px; flex: none; padding: 4px; object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
}
.card-icon.lg { width: 96px; height: 96px; padding: 8px; border-radius: var(--radius); }
.card-title { min-width: 0; }
.card-name { font-weight: 650; font-size: 1.1rem; line-height: 1.3; letter-spacing: -.012em; }
.card-sub { color: var(--ink-3); font-size: .84rem; margin-top: .1rem; }

.badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .6rem; border-radius: 6px;
  font-size: .82rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line);
}
a.badge:hover { text-decoration: none; border-color: var(--accent-line); color: var(--ink); }
.badge.solid { color: var(--accent-ink); border-color: transparent; }
.badge.tone { color: var(--tone, var(--ink-2)); border-color: color-mix(in srgb, var(--tone, var(--line)) 45%, transparent);
  background: color-mix(in srgb, var(--tone, var(--surface)) 12%, transparent); }
.swatch { width: .62rem; height: .62rem; border-radius: 3px; flex: none; }

.stat-row {
  margin-top: auto;
  display: grid; gap: .45rem .55rem; margin: 0; padding-top: .65rem;
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  border-top: 1px dashed var(--line);
}
.stat { display: flex; flex-direction: column; gap: .05rem; }
.stat dt { font-size: .68rem; white-space: nowrap; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 650; }
.stat dd { margin: 0; font-size: 1.04rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.desc { color: var(--ink-2); font-size: .97rem; margin: 0; }
.desc.clamp2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ------------------------------------------------------------------ tables */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1);
}
table { width: 100%; border-collapse: collapse; font-size: .98rem; min-width: 480px; }
th, td { padding: .62rem .85rem; text-align: left; border-bottom: 1px solid var(--line); }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--ink-3);
  font-size: .67rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin-bottom: .7rem; }
.toolbar:last-of-type { margin-bottom: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  padding: .38rem .9rem; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .92rem; font-weight: 550;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
  transition: color .14s, border-color .14s, background .14s;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.chip .n { margin-left: .3rem; font-size: .74em; opacity: .65; }

select.sort {
  margin-left: auto; padding: .34rem 2rem .34rem .6rem;
  font: inherit; font-size: .83rem; color: var(--ink);
  background-color: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.count-note { color: var(--ink-3); font-size: .8rem; margin: 0 0 .9rem; }

/* -------------------------------------------------------------- detail page */
.backlink {
  display: inline-flex; align-items: center; gap: .35rem;
  margin-bottom: .9rem; font-size: .83rem; color: var(--ink-3);
}
.backlink:hover { color: var(--accent); text-decoration: none; }

.detail-head {
  display: flex; flex-wrap: wrap; gap: 1.3rem; align-items: flex-start;
  padding: 1.3rem; margin-bottom: 1.2rem;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-wash), transparent 58%),
    var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.detail-icon {
  width: 140px; height: 140px; flex: none; padding: 8px; object-fit: contain;
  border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line);
}
.detail-title { flex: 1 1 300px; min-width: 0; }
.detail-title h1 { margin-bottom: .4rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }

.cols { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); align-items: start; }

.panel {
  padding: 1.05rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.panel > h2 { font-size: 1.02rem; letter-spacing: .01em; display: flex; align-items: center; gap: .5rem; }
.panel > h2::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px; background: var(--accent); flex: none;
}
.panel h2:not(:first-child), .panel h3:not(:first-child) { margin-top: 1.2rem; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .5rem .9rem; margin: 0; font-size: 1rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.stack { display: flex; flex-direction: column; gap: .55rem; }

.callout {
  padding: .8rem .95rem; font-size: .86rem; color: var(--ink-2);
  background: var(--accent-wash); border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
}
.callout strong { color: var(--ink); }

.chip-list { display: flex; flex-wrap: wrap; gap: .3rem; }

/* ------------------------------------------------------------- simulator */
.sim-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.sim-out { display: grid; gap: .45rem; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); max-height: 340px; overflow: auto; }
.pull {
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--edge, var(--line-strong));
  font-size: .78rem;
}
.pull b { display: block; font-size: .82rem; font-weight: 650; }
.pull span { color: var(--ink-3); font-size: .72rem; text-transform: capitalize; }

/* ------------------------------------------------------------------ misc */
.empty {
  padding: 3rem 1rem; text-align: center; color: var(--ink-3);
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.loading { padding: 4rem 1rem; text-align: center; color: var(--ink-3); }
.loading::after {
  content: ""; display: block; width: 22px; height: 22px; margin: 1rem auto 0;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; margin: 1.8rem 0; font-size: .84rem; }
.pager button {
  padding: .4rem .8rem; font: inherit; font-size: .84rem; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.pager button:hover:not([disabled]) { border-color: var(--line-strong); }
.pager button[disabled] { opacity: .4; cursor: default; }

.section-gap { margin-top: 1.6rem; }

/* A small heading used inside lists. */
.section-label {
  display: flex; align-items: center; gap: .5rem;
  margin: 1.4rem 0 .7rem;
  font-size: .7rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .sidenav {
    transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.2,.7,.3,1);
    width: min(85vw, 300px); box-shadow: var(--shadow-2);
  }
  .sidenav.open { transform: none; }
  .menu-btn { display: grid; }
  main, .footer { margin-left: 0; }
  .search { margin-inline: 0; }
}

@media (max-width: 720px) {
  .brand-sub { display: none; }
  .topbar { gap: .5rem; padding-inline: .65rem; }
  .search { flex: 1 1 90px; min-width: 0; }
  .search kbd { display: none; }
  .lang button { padding: .22rem .42rem; font-size: .74rem; }
  .view { padding-inline: .8rem; }
  .footer { padding-inline: .8rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: .65rem; }
  .grid.wide { grid-template-columns: 1fr; }
  .card { padding: .75rem; }
  .card-icon { width: 44px; height: 44px; }
  .card-name { font-size: .9rem; }
  .detail-icon { width: 84px; height: 84px; }
  .detail-head { padding: 1rem; gap: .9rem; }
  h1 { font-size: 1.7rem; }
}

@media (max-width: 520px) {
  /* Language switch drops to its own row rather than squeezing the search. */
  .topbar { flex-wrap: wrap; height: auto; padding-block: .5rem; row-gap: .45rem; }
  .search { order: 3; flex-basis: 100%; }
  .top-actions { margin-left: auto; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-tile .v { font-size: 1.4rem; }
  .toolbar { gap: .4rem; }
  select.sort { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Print: drop chrome, keep the data. */
@media print {
  .topbar, .sidenav, .footer, .scrim, .toolbar, .hero-actions { display: none !important; }
  body::before { display: none; }
  main, .footer { margin: 0; }
  .card, .panel { break-inside: avoid; box-shadow: none; }
}


/* ------------------------------------------------------------- RPG detail */

/* A hairline ornament under section heads, echoing a rule line in a codex. */
.page-head h1 {
  position: relative;
  padding-bottom: .45rem;
}
.page-head h1::after {
  content: "";
  position: absolute; left: 0; bottom: 0; width: 64px; height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft) 60%, transparent);
}

/* Cards: a faint corner notch and a warmer top edge, so they read as
   equipment plates rather than plain boxes. */
.card::after {
  content: "";
  position: absolute; top: 0; right: 0;
  width: 22px; height: 22px;
  background: linear-gradient(225deg, var(--surface-3) 0 50%, transparent 50%);
  opacity: .55;
  border-top-right-radius: var(--radius);
  pointer-events: none;
}
.card:hover::after { opacity: .85; }

/* Rarity plates get a soft glow on hover. */
.card.is-link:hover { box-shadow: var(--shadow-2), 0 0 0 1px var(--edge, var(--line)); }

/* Panels: a small brass rule along the top. */
.panel {
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
  opacity: .7;
}

/* ------------------------------------------------------------- form bits */

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.field > span {
  font-size: .74rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.field-row { display: grid; gap: .7rem; grid-template-columns: 1fr 1fr; }

select.select-wide, .field input[type="text"] {
  width: 100%; padding: .5rem .7rem;
  font: inherit; font-size: .94rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
select.select-wide:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }

.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 999px;
  background: var(--surface-3); outline: none; margin: .3rem 0 .1rem;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: var(--shadow-1); cursor: pointer;
}
.range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); cursor: pointer;
}
.field output {
  align-self: flex-end; font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--accent); font-size: .95rem;
}

.advice { margin: 0; padding-left: 1.1rem; }
.advice li { margin-bottom: .45rem; color: var(--ink-2); font-size: .95rem; }
.advice li::marker { color: var(--accent); }

/* Tools sit in a sticky control column on wide screens. */
@media (min-width: 1100px) {
  #expControls { position: sticky; top: calc(var(--topbar) + 1rem); }
}

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr !important; }
  .field-row { grid-template-columns: 1fr; }
}


/* ------------------------------------------------------------ ornate shell */

/* The hero gets a starfield and a pair of corner filigrees. */
.hero::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 26%, #ffffffcc, transparent),
    radial-gradient(1px 1px at 34% 68%, #ffffff99, transparent),
    radial-gradient(1.5px 1.5px at 58% 18%, #ffffffaa, transparent),
    radial-gradient(1px 1px at 76% 54%, #ffffff88, transparent),
    radial-gradient(1px 1px at 88% 30%, #ffffffbb, transparent),
    radial-gradient(1px 1px at 46% 82%, #ffffff77, transparent),
    radial-gradient(1.5px 1.5px at 22% 44%, #ffffff99, transparent);
  background-size: 260px 220px;
  opacity: .55;
}

/* A thin double border on panels, like a plate edge. */
.panel {
  border-color: var(--line-strong);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--surface) 70%, transparent),
    var(--shadow-1);
}

/* Section labels become centred ornaments with a diamond. */
.section-label { justify-content: center; }
.section-label::before {
  content: "◆";
  font-size: .5rem;
  color: var(--accent);
  margin-right: .1rem;
}
.section-label::after { flex: 1; }

/* Stat tiles: a faint radial sheen and a larger number. */
.stat-tile {
  position: relative;
  background:
    radial-gradient(120% 120% at 100% 0%, var(--accent-wash), transparent 60%),
    var(--surface);
}
.stat-tile .v { font-size: 2.1rem; letter-spacing: -.035em; }

/* Rarity star rows read as engraved. */
.stars { letter-spacing: .12em; color: var(--accent); }

/* Tables inside panels sit flush and lose the outer shadow. */
.panel .table-wrap { box-shadow: none; border-color: var(--line); }

/* Buttons get a subtle bevel. */
.btn.primary {
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff), var(--accent));
  box-shadow: inset 0 1px 0 #ffffff40, var(--shadow-1);
  border: 1px solid color-mix(in srgb, var(--accent) 70%, #000);
}

/* The sidebar brand mark breathes. */
.brand-mark { filter: drop-shadow(0 0 6px var(--accent-wash)); }

/* Bigger controls on the tools. */
select.select-wide { padding: .6rem .8rem; font-size: 1rem; }
.range { height: 8px; }
.range::-webkit-slider-thumb { width: 24px; height: 24px; }
