:root {
  --bg: #1b2140;        /* Abyss twilight */
  --panel: #252d55;
  --line: #3a447a;
  --text: #ecebf4;
  --muted: #b3b5d0;
  --gold: #e2b857;      /* wing gold: your progress */
  --cyan: #72c6de;      /* aether: links and controls */
  --rose: #d7708f;      /* Asmodian rose: splits and warnings */
  --row: rgba(255, 255, 255, .035);
  --met: rgba(226, 184, 87, .13);
  --shadow: 0 1px 0 rgba(0, 0, 0, .25);
  --head: "Marcellus", Georgia, serif;
  --body: "Commissioner", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef2fa; --panel: #ffffff; --line: #c9d0e6; --text: #1b2140; --muted: #4c557d;
    --gold: #8a6410; --cyan: #1f6f8b; --rose: #a83a5c; --row: rgba(27, 33, 64, .035); --met: rgba(226, 184, 87, .22);
    --shadow: 0 1px 0 rgba(27, 33, 64, .06); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef2fa; --panel: #ffffff; --line: #c9d0e6; --text: #1b2140; --muted: #4c557d;
  --gold: #8a6410; --cyan: #1f6f8b; --rose: #a83a5c; --row: rgba(27, 33, 64, .035); --met: rgba(226, 184, 87, .22);
  --shadow: 0 1px 0 rgba(27, 33, 64, .06); color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 150px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 var(--body); }
a { color: var(--cyan); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
img { max-width: 100%; height: auto; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 24px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font: 22px/1 var(--head); color: var(--text); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--muted); }
.classes { display: flex; gap: 4px; flex-wrap: wrap; }
.classes a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 999px; font-size: 15px; }
.classes a:hover { color: var(--text); background: var(--panel); }
.classes a[aria-current="page"] { color: var(--bg); background: var(--gold); font-weight: 700; }
.search { position: relative; margin-left: auto; width: min(320px, 34vw); }
.search input { width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font: inherit; font-size: 15px; }
.results { position: absolute; right: 0; top: calc(100% + 6px); width: min(520px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); }
.results a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.results a:hover, .results a:focus { background: var(--row); outline: none; box-shadow: inset 3px 0 0 var(--gold); }
.results .r-c { color: var(--gold); font-size: 13px; }
.results .r-t { display: block; font-weight: 700; }
.results .r-s { display: block; color: var(--muted); font-size: 14px; line-height: 1.4; }
.results mark { background: var(--met); color: inherit; }
.results .none { padding: 10px; color: var(--muted); }
.theme { border: 1px solid var(--line); background: var(--panel); color: var(--text); width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; }

/* the item level rail: the one bold element */
.rail { position: sticky; top: 57px; z-index: 15; display: grid; grid-template-columns: auto 110px 1fr; grid-template-rows: auto auto;
  column-gap: 14px; align-items: center; padding: 10px 24px 12px; background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.rail label { font: 17px var(--head); color: var(--gold); }
.rail input { width: 110px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: 700 17px var(--body); font-variant-numeric: tabular-nums; }
.track { position: relative; height: 34px; margin: 0 14px; }
.track .bar { position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 4px; background: var(--line); }
.track .fill { position: absolute; left: 0; top: 9px; height: 4px; border-radius: 4px; background: var(--gold); width: 0; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.track .tick { position: absolute; top: 3px; width: 2px; height: 16px; cursor: help; background: var(--line); transform: translateX(-1px); }
.track .tick.met { background: var(--gold); }
.track .tick.next { background: var(--cyan); height: 20px; top: 1px; width: 3px; }
.track .tl { position: absolute; top: 20px; font-size: 11px; color: var(--muted); transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.status { grid-column: 1 / -1; margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.status strong { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .track .fill { transition: none; } }

/* layout */
.layout { display: grid; grid-template-columns: 1fr; max-width: 1240px; margin: 0 auto; padding: 0 24px; gap: 40px; }
.has-toc .layout { grid-template-columns: 250px minmax(0, 1fr); }
.toc { position: sticky; top: 170px; align-self: start; max-height: calc(100vh - 190px); overflow: auto; padding: 24px 0; font-size: 14px; }
.toc-h { font: 15px var(--head); color: var(--muted); margin: 0 0 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc ol ol { padding-left: 12px; margin: 2px 0 6px; }
.toc a { display: block; padding: 3px 8px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; line-height: 1.35; }
.toc a:hover { color: var(--text); }
.toc a.on { color: var(--text); border-left-color: var(--gold); }
.toc .pdf { margin-top: 16px; }
.toc .pdf a { color: var(--cyan); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: inline-block; }

/* guide body */
.guide { min-width: 0; max-width: 860px; padding: 28px 0 60px; }
.guide-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.guide-head h1 { font: 56px/1.05 var(--head); margin: 0; letter-spacing: .01em; }
.updated { color: var(--muted); margin: 0; }
.intro p { font-size: 19px; line-height: 1.55; max-width: 70ch; }
.guide h2 { font: 32px/1.2 var(--head); margin: 0 0 10px; padding-top: 34px; }
.guide h3 { font: 23px/1.25 var(--head); margin: 28px 0 8px; color: var(--text); }
.guide p, .guide li { max-width: 74ch; }
.guide ul, .guide ol { padding-left: 1.3em; }
.guide li { margin: 4px 0; }
.guide strong { color: var(--text); }
.sec { border-top: 1px solid var(--line); margin-top: 34px; }
.sec:first-of-type { border-top: 0; }
.fig { margin: 14px 0; }
.fig img { border-radius: 8px; border: 1px solid var(--line); background: #0f1430; }
.fig.board img { max-height: 80vh; }

.tbl { overflow-x: auto; margin: 12px 0 16px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
th, td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { position: relative; background: var(--panel); font-weight: 700; white-space: nowrap; cursor: pointer; user-select: none; }
th[aria-sort]::after { content: ""; display: inline-block; margin-left: 6px; border: 4px solid transparent; vertical-align: middle; }
th[aria-sort="ascending"]::after { border-bottom-color: var(--gold); margin-top: -4px; }
th[aria-sort="descending"]::after { border-top-color: var(--gold); margin-top: 4px; }
tbody tr:nth-child(even) td { background: var(--row); }
tbody tr:last-child td { border-bottom: 0; }
table.gates tr.met td { background: var(--met); }
table.gates tr.met td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
table.gates tr.next td:first-child { box-shadow: inset 3px 0 0 var(--cyan); }
table.gates tr.next td:last-child::after { content: " Your next gate"; color: var(--cyan); font-weight: 700; }

/* saved checklists */
ol.check { list-style: none; padding-left: 0; counter-reset: c; }
ol.check li { position: relative; padding-left: 34px; counter-increment: c; }
ol.check input { position: absolute; left: 4px; top: 4px; width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }
ol.check li.done { color: var(--muted); }
ol.check li.done strong { color: var(--muted); }

/* skill rank calculator */
.calc { border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; padding: 14px 16px; margin: 16px 0; background: var(--panel); }
.calc h4 { font: 19px var(--head); margin: 0 0 10px; }
.calc .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; }
.calc label { display: block; font-size: 14px; color: var(--muted); }
.calc input[type=range] { width: 100%; accent-color: var(--gold); }
.calc output { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.calc .total { margin: 12px 0 0; font-size: 17px; }
.calc .total b { font: 28px var(--head); color: var(--gold); vertical-align: -2px; }

/* home */
.home { padding: 48px 0 40px; }
.home-h { font: clamp(36px, 6vw, 68px)/1.04 var(--head); margin: 0 0 16px; max-width: 16ch; }
.home-p { font-size: 19px; color: var(--muted); max-width: 60ch; margin: 0 0 32px; }
.guide .tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0;
  border-top: 1px solid var(--line); }
.tile { display: block; padding: 20px 18px 22px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.tiles li:nth-child(odd) .tile { padding-right: 28px; }
.tile-name { display: block; font: 34px/1.1 var(--head); color: var(--text); }
.tile:hover .tile-name { color: var(--gold); }
.tile-lead { display: block; color: var(--muted); margin-top: 6px; line-height: 1.45; }

.foot { border-top: 1px solid var(--line); padding: 20px 24px 40px; color: var(--muted); font-size: 14px; }
.foot p { max-width: 1240px; margin: 0 auto; }

@media (max-width: 1000px) {
  .has-toc .layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .search { width: 200px; }
}
@media (max-width: 760px) {
  html { scroll-padding-top: 200px; }
  body { font-size: 16px; }
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .classes { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .search { width: auto; flex: 1; }
  .rail { position: static; grid-template-columns: auto 1fr; padding: 10px 16px; }
  .rail input { width: 100%; }
  .track { grid-column: 1 / -1; margin-top: 8px; }
  .track .tl:last-of-type { display: none; }
  .layout { padding: 0 16px; }
  .guide-head h1 { font-size: 42px; }
  .guide h2 { font-size: 27px; }
  .intro p { font-size: 17px; }
}
