:root {
  --ground: #e9e8e1; --surface: #f7f6f1; --surface-2: #efeee8; --text: #1c1f26; --muted: #5c5f6a;
  --brass: #9c6f24; --brass-soft: rgba(156,111,36,.14); --rule: #d3d1c7; --shadow: 0 1px 2px rgba(20,22,30,.08);
  --read-bg: #fbf7ea; --read-rule: #d9c48a; --voice-bg: #eef0f5; --voice-rule: #8fa2c9;
  --hearth:#b8963e; --green:#4f8a3c; --ember:#c8562a; --tide:#2f7fb5; --gale:#6f9ac4; --dusk:#8a5a9c; --sea:#4f8078; --under:#4a5d9c; --spire:#8d8a80;
  --bar-h: 100px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ground:#13161c; --surface:#1c2028; --surface-2:#232833; --text:#ece6d8; --muted:#9b968a;
  --brass:#d9a85c; --brass-soft:rgba(217,168,92,.14); --rule:#2d323c; --shadow:0 1px 2px rgba(0,0,0,.4);
  --read-bg:#221f18; --read-rule:#7a6431; --voice-bg:#1b2130; --voice-rule:#5a6f9c;
  --hearth:#c9a648; --green:#5f9a4a; --ember:#d8622b; --tide:#3f8fc4; --gale:#93b7d8; --dusk:#a06bb0; --sea:#5f8f86; --under:#5468a6; --spire:#cbc7bb;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 110px; }
body { margin: 0; overflow-x: hidden; background: var(--ground); color: var(--text); font-family: "Alegreya Sans","Gill Sans","Segoe UI",system-ui,sans-serif; font-size: 17px; line-height: 1.5; padding-bottom: calc(var(--bar-h) + 16px); }
a { color: var(--brass); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { filter: brightness(1.1); }
h1,h2,h3,h4 { font-family: "Marcellus","Cormorant Garamond",Georgia,serif; font-weight: 400; line-height: 1.15; text-wrap: balance; letter-spacing: .01em; }
h1 { font-size: clamp(28px,3.4vw,38px); margin: 0 0 12px; }
h2 { font-size: 26px; margin: 34px 0 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
h3 { font-size: 21px; margin: 24px 0 8px; }
h4 { font-size: 18px; margin: 18px 0 6px; }
p, ul, ol { margin: 0 0 12px; }
li { margin: 4px 0; }
em { color: inherit; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 28px 0; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--surface-2); padding: 12px; border-radius: 6px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 12px 0 18px; font-size: 15.5px; }
.table-wrap { overflow-x: auto; }
th, td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--rule); }
th { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
tr:nth-child(even) td { background: color-mix(in srgb, var(--surface) 60%, transparent); }
blockquote { margin: 14px 0; padding: 12px 18px; background: var(--voice-bg); border-left: 3px solid var(--voice-rule); font-style: italic; font-size: 17.5px; }
blockquote p { margin: 0 0 8px; }
blockquote p:last-child { margin: 0; }
.muted { color: var(--muted); }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--ground); border-bottom: 1px solid var(--rule); }
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--text); line-height: 1; flex: none; }
.brand-name { font-family: "Marcellus", Georgia, serif; font-size: 22px; letter-spacing: .04em; }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); margin-top: 3px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs a { flex: none; text-decoration: none; color: var(--text); font-weight: 500; font-size: 15px; padding: 6px 11px; border-radius: 999px; border: 1px solid transparent; }
.tabs a:hover { background: var(--surface); border-color: var(--rule); }
.tabs a.active { background: var(--text); color: var(--ground); }
.tabs a.players { color: var(--brass); }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.search { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 5px 9px; }
.search svg { width: 16px; height: 16px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; width: 160px; }
.pill { font: inherit; font-size: 13.5px; font-weight: 700; letter-spacing: .04em; color: var(--brass); background: var(--brass-soft); border: 1px solid transparent; border-radius: 999px; padding: 5px 11px; cursor: pointer; }
.pill.player { color: var(--ground); background: var(--brass); }
.icon-btn { font: inherit; background: transparent; border: 1px solid var(--rule); color: var(--text); border-radius: 6px; width: 32px; height: 32px; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.subnav { position: sticky; top: 49px; z-index: 19; display: flex; gap: 2px; overflow-x: auto; padding: 6px 16px; background: var(--ground); border-bottom: 1px solid var(--rule); scrollbar-width: thin; }
.subnav:empty { display: none; }
.subnav a { flex: none; font-size: 14.5px; text-decoration: none; color: var(--muted); padding: 4px 10px; border-radius: 5px; }
.subnav a.active { color: var(--text); background: var(--surface); font-weight: 700; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; min-width: 0; gap: 32px; max-width: 1140px; margin: 0 auto; padding: 26px 16px 40px; }
.content { max-width: 760px; }
.aside { position: sticky; top: 100px; align-self: start; font-size: 14.5px; max-height: calc(100vh - 100px - var(--bar-h)); overflow-y: auto; }
.aside h5 { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.aside ul { list-style: none; margin: 0 0 18px; padding: 0; }
.aside li { margin: 0; }
.aside a { display: block; color: var(--text); text-decoration: none; padding: 3px 0 3px 10px; border-left: 2px solid var(--rule); }
.aside a.h3 { padding-left: 22px; color: var(--muted); }
.aside a:hover, .aside a.active { border-left-color: var(--brass); color: var(--brass); }
.aside .rel a { border-left: 0; padding-left: 0; }
@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 8px 10px; }
  .tabs { order: 3; flex-basis: 100%; }
  .top-right { margin-left: auto; }
  .subnav { top: 93px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 18px; }
  .content { min-width: 0; }
  .aside { position: static; max-height: none; order: -1; border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
  .aside .toc { display: none; }
  .search input { width: 110px; }
}

/* read-aloud and voice */
.read { position: relative; margin: 16px 0 20px; padding: 16px 20px 16px 22px; background: var(--read-bg); border: 1px solid var(--read-rule); border-left-width: 5px; border-radius: 4px; font-family: "Marcellus", Georgia, serif; font-size: 18px; line-height: 1.55; }
.read::before { content: "Read aloud"; position: absolute; top: -9px; left: 14px; font-family: "Alegreya Sans", sans-serif; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); background: var(--read-bg); padding: 0 6px; }
.read p { margin: 0 0 10px; } .read p:last-child { margin: 0; }
.dm-only { border: 1px dashed var(--rule); border-radius: 6px; padding: 10px 14px; margin: 12px 0; font-size: 15.5px; }
.dm-only::before { content: "DM only"; display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* inline buttons */
.mbtn, .sfx { font: inherit; font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; border-radius: 5px; padding: 3px 9px; cursor: pointer; vertical-align: middle; white-space: nowrap; }
.mbtn { color: var(--brass); background: var(--brass-soft); border: 1px solid transparent; }
.mbtn.playing { background: var(--brass); color: var(--ground); }
.sfx { color: var(--text); background: transparent; border: 1px solid var(--rule); }
.sfx:hover, .mbtn:hover { filter: brightness(1.08); }

/* stat blocks */
.stat { background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--brass); border-radius: 6px; padding: 14px 16px; margin: 16px 0 22px; font-size: 15.5px; box-shadow: var(--shadow); }
.stat h3 { margin: 0 0 2px; font-size: 22px; }
.stat .meta { font-style: italic; color: var(--muted); margin-bottom: 8px; }
.stat .line { margin: 2px 0; }
.stat .line b { color: var(--brass); }
.stat .abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 10px 0; text-align: center; font-variant-numeric: tabular-nums; }
.stat .abil div { background: var(--surface-2); border-radius: 4px; padding: 4px 2px; }
.stat .abil b { display: block; font-size: 11px; letter-spacing: .1em; color: var(--muted); }
.stat h4 { font-family: "Alegreya Sans", sans-serif; font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); border-bottom: 1px solid var(--rule); margin: 12px 0 6px; padding-bottom: 2px; }
.stat p { margin: 0 0 6px; }
.stat .note { color: var(--muted); font-style: italic; }

/* refs cards */
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 12px 0 22px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 12px 12px 10px; display: grid; gap: 6px; grid-template-rows: auto auto 1fr auto; box-shadow: var(--shadow); }
.card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; }
.card .top-line { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card h4 { margin: 0; font-family: "Alegreya Sans", sans-serif; font-size: 17px; font-weight: 700; }
.card .game { color: var(--muted); font-size: 13px; text-align: right; }
.card .as { font-size: 14.5px; }
.card .as b { color: var(--brass); }
.card .links { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card a.open { text-decoration: none; font-size: 13px; font-weight: 700; color: var(--brass); background: var(--brass-soft); border-radius: 5px; padding: 4px 9px; }
.card a.open.alt { background: transparent; border: 1px solid var(--rule); color: var(--muted); font-weight: 500; }
.tag { font-size: 11.5px; color: var(--muted); border: 1px dashed var(--rule); border-radius: 4px; padding: 1px 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.chip { font: inherit; font-size: 13.5px; font-weight: 500; background: var(--surface); border: 1px solid var(--rule); color: var(--text); border-radius: 999px; padding: 4px 11px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--ground); border-color: var(--text); }

/* music library */
.mlib h3 { margin-top: 26px; }
.mrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.mrow .t { font-weight: 700; }
.mrow .t small { display: block; font-weight: 400; color: var(--muted); font-size: 13.5px; }
.mrow .alts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* map viewer */
.mapbox { margin: 14px 0 22px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); overflow: hidden; }
.mapbox .bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; font-size: 14px; }
.mapbox .bar .t { font-weight: 700; margin-right: auto; }
.mapbox .bar button, .mapbox .bar a { font: inherit; font-size: 13.5px; background: transparent; border: 1px solid var(--rule); color: var(--text); border-radius: 5px; padding: 3px 9px; cursor: pointer; text-decoration: none; }
.mapbox .view { overflow: auto; max-height: 70vh; background: #efe9dc; }
.mapbox .view svg, .mapbox .view img { display: block; transform-origin: 0 0; }
.mapbox .note { padding: 8px 12px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--rule); }
body.player .dm { display: none !important; }

/* tracker */
.tracker { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 14px 0 22px; }
.tracker .box { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; font-size: 15px; box-shadow: var(--shadow); }
.tracker h4 { margin: 0 0 8px; font-family: "Alegreya Sans", sans-serif; font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); }
.tracker label { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tracker select, .tracker input[type=number], .tracker textarea { font: inherit; font-size: 14.5px; color: var(--text); background: var(--surface-2); border: 1px solid var(--rule); border-radius: 4px; padding: 3px 6px; }
.tracker textarea { width: 100%; min-height: 70px; resize: vertical; }
.tracker .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; }
.tracker .actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.tracker .actions button { font: inherit; font-size: 14px; border: 1px solid var(--rule); background: var(--surface); color: var(--text); border-radius: 5px; padding: 5px 12px; cursor: pointer; }
.tracker .wide { grid-column: 1 / -1; }

/* search results */
.search-results { position: fixed; top: 52px; right: 16px; width: min(520px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 30; padding: 8px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 5px; text-decoration: none; color: var(--text); }
.search-results a:hover { background: var(--surface-2); }
.search-results a b { color: var(--brass); }
.search-results a small { display: block; color: var(--muted); font-size: 13.5px; }
.search-results .none { color: var(--muted); padding: 8px 10px; }

/* music bar */
.musicbar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar-h); z-index: 25; display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--surface); border-top: 1px solid var(--rule); box-shadow: 0 -4px 20px rgba(0,0,0,.15); }
.yt { width: 178px; height: 100px; flex: none; background: #000; overflow: hidden; }
.yt iframe { width: 100%; height: 100%; display: block; }
.yt-sfx { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.now { flex: 1; min-width: 0; }
.now-label { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: flex; align-items: center; gap: 8px; flex: none; }
.ctl { font: inherit; font-size: 14px; font-weight: 700; background: transparent; color: var(--text); border: 1px solid var(--rule); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.ctl.toggle.on { background: var(--brass-soft); color: var(--brass); border-color: transparent; }
#vol { width: 90px; accent-color: var(--brass); }
@media (max-width: 700px) { :root { --bar-h: 76px; } .now-title { display: none; } #vol { display: none; } .yt { width: 120px; height: 68px; } }

.notice { background: var(--brass-soft); border-radius: 6px; padding: 10px 14px; margin: 0 0 16px; font-size: 15px; }
.pagehead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.pagehead .crumb { font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
img.inline { max-width: 100%; border-radius: 6px; }
@media (prefers-reduced-motion: no-preference) { .card { transition: transform 120ms ease; } .card:hover { transform: translateY(-1px); } }
