:root {
  --bg: #f5efe3; --paper: #fbf7ee; --ink: #231d17; --muted: #6d6252; --line: #d8c9a8; --accent: #7a1d29; --accent-ink: #fff7e6;
  --gold: #b88a2c; --chip: #efe5cf; --good: #2e6b3a; --warn: #8a5a00; --shadow: 0 8px 28px rgba(40, 24, 8, .22);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] { --bg: #16181c; --paper: #202328; --ink: #e9ebef; --muted: #a2a8b3; --line: #353a42; --accent: #e0788c; --accent-ink: #1a0f12;
  --gold: #c9a24a; --chip: #2a2e35; --good: #6fc38a; --warn: #e2b04e; --shadow: 0 8px 28px rgba(0, 0, 0, .55); color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.9rem; margin: .2em 0 .4em; } h2 { font-size: 1.35rem; margin: 1.4em 0 .4em; border-bottom: 1px solid var(--line); padding-bottom: .2em; } h3 { font-size: 1.1rem; margin: 1.1em 0 .3em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.crest { width: 3.2rem; height: 3.2rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 1.7rem var(--serif); border: 3px solid var(--gold); }
.crest.sm { width: 1.9rem; height: 1.9rem; font-size: 1rem; border-width: 2px; }

/* lock screen */
.lock { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.lock-box { width: min(26rem, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; box-shadow: var(--shadow); display: grid; gap: .8rem; justify-items: start; }
.lock-box h1 { margin: 0; }
.field { display: grid; gap: .25rem; width: 100%; font-size: .9rem; color: var(--muted); }
.field input, .searchbox input, .filters input, .filters select { font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); width: 100%; min-width: 0; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .92rem; }
.btn { font: inherit; padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--chip); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.linkish { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }
.msg { margin: 0; min-height: 1.4em; color: var(--accent); font-size: .92rem; }
.icon { font: inherit; width: 2.4rem; height: 2.4rem; border-radius: 8px; border: 1px solid var(--line); background: var(--chip); color: var(--ink); cursor: pointer; }

/* shell */
.top { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; padding: .6rem max(16px, env(safe-area-inset-left)); background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); font: 700 1.05rem var(--serif); }
.mainnav { display: flex; gap: .15rem; overflow-x: auto; flex: 1 1 100%; order: 3; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.mainnav a { padding: .4rem .7rem; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; font-size: .95rem; }
.mainnav a.on { background: var(--accent); color: var(--accent-ink); }
.mainnav a.mine { color: var(--accent); font-weight: 600; } .mainnav a.mine.on { color: var(--accent-ink); }
.tools { display: flex; gap: .5rem; align-items: center; margin-left: auto; flex: 1 1 14rem; max-width: 24rem; }
.search { flex: 1; display: block; } .search input { padding: .45rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; width: 100%; }
@media (min-width: 860px) { .mainnav { flex: 0 1 auto; order: 0; } .top { flex-wrap: nowrap; } }
main { max-width: 62rem; margin: 0 auto; padding: 1rem max(16px, env(safe-area-inset-left)) 3rem; outline: none; }
.foot { max-width: 62rem; margin: 0 auto; padding: 1rem 16px 2rem; color: var(--muted); font-size: .85rem; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: .2rem; } .crumbs a { color: var(--muted); }
.searchbox { position: sticky; top: 3.1rem; z-index: 19; background: var(--paper); border-bottom: 1px solid var(--line); padding: .5rem 16px; max-height: 60vh; overflow: auto; }
.searchbox ul { list-style: none; margin: 0; padding: 0; } .searchbox li a { display: flex; gap: .6rem; padding: .35rem .2rem; text-decoration: none; color: var(--ink); border-radius: 6px; } .searchbox li a:hover { background: var(--chip); }
.kind { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); min-width: 4.6rem; padding-top: .15rem; }

/* content */
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); }
.tile { display: block; text-decoration: none; color: inherit; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: .8rem .9rem; min-width: 0; }
.tile:hover { border-color: var(--accent); } .tile h3 { margin: 0 0 .15rem; font-size: 1.05rem; } .tile p { margin: 0; color: var(--muted); font-size: .9rem; }
.tile .count { font: 700 1.6rem var(--serif); color: var(--accent); }
.chip { display: inline-block; padding: .08rem .55rem; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); font-size: .78rem; color: var(--muted); margin: 0 .25rem .25rem 0; white-space: nowrap; }
.chip.house { border-color: var(--gold); color: var(--gold); } .chip.mine { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } .chip.good { border-color: var(--good); color: var(--good); } .chip.warn { border-color: var(--warn); color: var(--warn); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin: .8rem 0; }
.panel > :first-child { margin-top: 0; } .panel > :last-child { margin-bottom: 0; }
.prose { max-width: 46rem; } .prose table, .tablewrap table { border-collapse: collapse; width: 100%; font-size: .92rem; } .prose th, .prose td, .tablewrap th, .tablewrap td { border: 1px solid var(--line); padding: .3rem .5rem; text-align: left; vertical-align: top; }
.prose th, .tablewrap th { background: var(--chip); } .tablewrap { overflow-x: auto; margin: .6rem 0; } .tablewrap td.num, .tablewrap th.num { text-align: center; }
.prose blockquote { margin: .6rem 0; padding: .2rem .9rem; border-left: 3px solid var(--gold); color: var(--muted); font-style: italic; }
.prose a[data-ref], a.ref { border-bottom: 1px dotted var(--accent); text-decoration: none; cursor: help; }
details.feat { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); margin: .45rem 0; } details.feat > summary { cursor: pointer; padding: .5rem .8rem; font-weight: 600; list-style: none; display: flex; gap: .6rem; align-items: baseline; }
details.feat > summary::-webkit-details-marker { display: none; } details.feat > summary::before { content: "\25B8"; color: var(--accent); } details.feat[open] > summary::before { content: "\25BE"; }
details.feat .lvl { font-size: .78rem; color: var(--muted); font-weight: 400; margin-left: auto; } details.feat > .prose { padding: 0 .9rem .7rem; }
.filters { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); margin: .6rem 0; align-items: end; }
.filters label { display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); } .filters .chk { display: flex; align-items: center; gap: .4rem; padding-bottom: .55rem; }
.lvlbar { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; } .lvlbar button { font: inherit; min-width: 2.2rem; padding: .25rem .5rem; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; } .lvlbar button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rows { display: grid; gap: .35rem; margin: .6rem 0; } .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .8rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .45rem .7rem; text-decoration: none; color: inherit; }
.row:hover { border-color: var(--accent); } .row .nm { font-weight: 600; } .row .meta { font-size: .82rem; color: var(--muted); } .row .tags { grid-column: 1 / -1; }
.stats { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .92rem; margin: .4rem 0; } .stats b { color: var(--accent); }
.note { border-left: 3px solid var(--gold); padding: .4rem .8rem; background: var(--chip); border-radius: 0 8px 8px 0; margin: .6rem 0; font-size: .93rem; }
.empty { padding: 1.2rem; text-align: center; color: var(--muted); }

/* information card */
.card { position: fixed; z-index: 40; width: min(26rem, calc(100vw - 24px)); max-height: min(70vh, 34rem); overflow: auto; background: var(--paper); color: var(--ink); border: 1px solid var(--gold); border-radius: 12px; box-shadow: var(--shadow); padding: .7rem .9rem .8rem; font-size: .93rem; -webkit-overflow-scrolling: touch; }
.card.sheet { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0; width: 100%; max-height: 72vh; border-radius: 16px 16px 0 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.card-handle { display: none; width: 3rem; height: .3rem; border-radius: 4px; background: var(--line); margin: 0 auto .5rem; } .card.sheet .card-handle { display: block; }
.card-close { position: absolute; right: .4rem; top: .25rem; width: 2rem; height: 2rem; border: 0; background: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.card h3 { margin: 0 1.6rem .1rem 0; font-size: 1.1rem; } .card .sub { color: var(--muted); font-size: .82rem; margin-bottom: .4rem; } .card p { margin: .4rem 0; } .card .calc { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; background: var(--chip); padding: .35rem .5rem; border-radius: 6px; margin: .4rem 0; }
.card .open { display: inline-block; margin-top: .4rem; font-size: .86rem; }
.tipable { cursor: help; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.tipbtn { font: inherit; width: 1.5rem; height: 1.5rem; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--chip); color: var(--muted); cursor: pointer; font-size: .8rem; line-height: 1; flex: none; }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; } .top, .foot, .searchbox, .card, .filters, .lvlbar { display: none !important; }
  main { max-width: none; padding: 0; } details.feat { break-inside: avoid; } details.feat > .prose { display: block; }
}
a[data-ref] { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* character */
.portrait { width: 5.2rem; height: 5.2rem; border-radius: 50%; object-fit: cover; object-position: top; border: 3px solid var(--gold); background: var(--chip); flex: none; }
.portrait.ph { display: grid; place-items: center; font: 700 2rem var(--serif); color: var(--muted); }
.ctabs { display: flex; gap: .3rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin: .6rem 0 .8rem; scrollbar-width: none; }
.ctabs a { padding: .5rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; } .ctabs a.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.tiles { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(7.2rem, 1fr)); }
.stat, .ability { text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .3rem; }
.stat:hover, .ability:hover, tr.tipable:hover, .row.tipable:hover { border-color: var(--accent); }
.sl { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); } .sv { font: 700 1.5rem var(--serif); } .ss { font-size: .78rem; color: var(--muted); }
.abilities { display: grid; gap: .5rem; grid-template-columns: repeat(6, 1fr); margin: .7rem 0; } @media (max-width: 640px) { .abilities { grid-template-columns: repeat(3, 1fr); } }
.am { font: 700 1.7rem var(--serif); color: var(--accent); line-height: 1.1; } .as { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 0 .6rem; font-weight: 600; background: var(--bg); }
.two { display: grid; gap: .8rem; grid-template-columns: 1fr 1.4fr; } @media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.ctable { width: 100%; border-collapse: collapse; font-size: .95rem; } .ctable th { font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 400; text-align: left; } .ctable td, .ctable th { padding: .3rem .35rem; border-bottom: 1px solid var(--line); }
.ctable td.num, .ctable th.num { text-align: right; font-weight: 600; } .ctable td.dot { width: 1.2rem; color: var(--accent); } .ctable td.num.muted { font-weight: 400; }
.ctable tr.tipable:focus-visible, .tipable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row.tipable { cursor: help; }
.btn.small { padding: .35rem .7rem; font-size: .88rem; white-space: nowrap; }
.ctable.wi tr.chg td { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.ctable.wi td:first-child { width: 40%; }

/* class colours: --cls and --cls-dark are set on #view from the character's class (or the class page) */
#view { --cls: var(--accent); --cls-dark: #3a0f16; }
.banner { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.1rem; margin: .4rem 0 .9rem; border-radius: 16px; color: #fff7ea;
  background: linear-gradient(120deg, var(--cls-dark) 0%, var(--cls) 160%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.banner h1 { margin: 0; color: #fff7ea; font-size: clamp(1.5rem, 5vw, 2.2rem); } .banner .bsub { color: rgba(255, 247, 234, .85); } .banner .bmain { flex: 1; min-width: 0; }
.banner .portrait { width: 5.6rem; height: 5.6rem; border: 3px solid rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .25); color: #fff; }
.banner .lvl { display: grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: rgba(0, 0, 0, .3); border: 2px solid rgba(255, 255, 255, .5); text-align: center; line-height: 1; flex: none; }
.banner .lvl b { font: 700 1.6rem var(--serif); } .banner .lvl span { font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; opacity: .8; margin-top: -.5rem; }
#view[data-cls] h2 { background: var(--cls); color: #fff7ea; border: 0; border-radius: 8px; padding: .3rem .75rem; font-size: 1.1rem; }
#view[data-cls] h2 .muted { color: rgba(255, 247, 234, .85); }
#view[data-cls] .ctabs a.on { color: var(--cls); border-color: var(--cls); }
#view[data-cls] .stat { border-top: 3px solid var(--cls); } #view[data-cls] .lvlbar button.on { background: var(--cls); border-color: var(--cls); color: #fff7ea; }
#view[data-cls] .stats b, #view[data-cls] .am { color: var(--cls); } #view[data-cls] .tile:hover, #view[data-cls] .row:hover { border-color: var(--cls); }
#view[data-cls] a, #view[data-cls] .crumbs a { color: var(--cls); } #view[data-cls] .btn.primary { background: var(--cls); border-color: var(--cls); color: #fff7ea; }
.hex { width: 4.2rem; height: 3.7rem; margin: .25rem auto; display: grid; place-items: center; font: 700 1.55rem var(--serif); color: #fff7ea; background: var(--cls);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.ability { padding-top: .4rem; }
.ctabs a { border-radius: 8px 8px 0 0; }
#view[data-cls] .ctable td.dot { color: var(--cls); }

.filters .checks { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; align-items: center; padding-bottom: .55rem; grid-column: 1 / -1; }
.filters .checks .chk { padding-bottom: 0; }
.chip.party { background: var(--pc, var(--accent)); border-color: var(--pc, var(--accent)); color: #fff7ea; }
.row.prep { background: color-mix(in srgb, var(--good) 15%, var(--paper)); border-color: var(--good); }
.filters input[type="checkbox"], .check input[type="checkbox"] { width: auto; padding: 0; flex: none; }
.filters { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }

.row.pick { cursor: pointer; }
.row .tipbtn { margin-left: .3rem; vertical-align: middle; }
.xpbar { position: relative; height: 1.1rem; margin-top: .35rem; max-width: 18rem; border-radius: 999px; background: rgba(0, 0, 0, .3); overflow: hidden; }
.xpbar i { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, .35); }
.xpbar span { position: relative; display: block; text-align: center; font-size: .72rem; line-height: 1.1rem; letter-spacing: .04em; }
ul.changes { margin: .2rem 0 0; padding-left: 1.2rem; } ul.changes ul { margin: .1rem 0 .3rem; padding-left: 1.1rem; list-style: circle; }
