:root {
  --bg: #0f1218;
  --bg-2: #151a23;
  --panel: #1a202b;
  --panel-2: #212836;
  --line: #2b3444;
  --text: #e6e9ef;
  --muted: #98a2b3;
  --faint: #6b7586;
  --accent: #e8b13e;
  --accent-ink: #1a1405;
  --blue: #5aaaff;
  --light: #6fc3ff;
  --dark: #ff6b6b;
  --good: #57c98a;
  --warn: #f0a04b;
  --bad: #ff6b6b;
  --chip: #263044;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 56px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f2ee;
  --bg-2: #ece9e3;
  --panel: #ffffff;
  --panel-2: #f7f5f1;
  --line: #ddd8cf;
  --text: #1d2230;
  --muted: #5b6475;
  --faint: #8a92a1;
  --accent: #b7791f;
  --accent-ink: #ffffff;
  --blue: #1f6fd1;
  --light: #1f6fd1;
  --dark: #c0392b;
  --good: #22874f;
  --warn: #b86b12;
  --bad: #c0392b;
  --chip: #efebe4;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(0,0,0,.05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--blue); }
button { font: inherit; color: inherit; }
select, input, textarea { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand img { width: 24px; height: 24px; }
/* D&D Sheet's name: the brand, the game it's for, and Beta for now. */
.brand-name { display: inline-flex; align-items: baseline; gap: 5px; }
.brand-name b { font-size: 15px; letter-spacing: .07em; text-transform: uppercase; }
.brand-name small { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--muted); }
.brand-beta { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; line-height: 1.5;
  padding: 0 6px; border-radius: 6px; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); vertical-align: middle; }
.welcome h1 .welcome-sub { font-size: .55em; letter-spacing: .1em; color: var(--muted); }
.welcome h1 .brand-beta { font-size: 12px; }
.picker select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; min-width: 220px; max-width: 360px;
}
.actions { display: flex; gap: 8px; align-items: center; }
.btn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .6; cursor: progress; }
.status { margin-left: auto; color: var(--muted); font-size: 12.5px; line-height: 1.35; max-width: 40vw; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.status.error { color: var(--bad); }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; padding: 6px; z-index: 30;
  max-height: calc(100vh - 80px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.menu-pop button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-pop button:hover { background: var(--panel-2); }
.menu-pop .danger { color: var(--bad); }
.menu-pop .danger.confirm { background: color-mix(in srgb, var(--bad) 14%, transparent); font-weight: 600; }
.menu-pop [aria-pressed="true"]::after { content: " ✓"; color: var(--good); }
.narrow-only, .mbar-only { display: none !important; }
/* A plain web page can't reach sw5e.com (only the browser extension can): its buttons go. */
html[data-sw5e="off"] .needs-sw5e { display: none !important; }
html[data-sw5e="on"] .no-sw5e { display: none !important; }
html:not([data-server="on"]) .needs-server { display: none !important; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; max-width: 1500px; margin: 0 auto; padding: 16px; }
.sidebar {
  position: sticky; top: calc(var(--topbar-h) + 16px); align-self: start;
  max-height: calc(100vh - var(--topbar-h) - 32px); overflow: auto; padding-right: 4px;
}
.sheet { min-width: 0; }
.sheet:focus { outline: none; }
.ability .row:has([data-roll]), #sec-skills tbody tr { cursor: pointer; }

/* ---------- Sidebar ---------- */
.side-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.side-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.side-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.mini-stat { background: var(--panel-2); border-radius: 8px; padding: 6px 4px; text-align: center; }
.mini-stat b { display: block; font-size: 16px; line-height: 1.2; }
.mini-stat > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini-abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 8px; }
.mini-abil div { text-align: center; background: var(--panel-2); border-radius: 6px; padding: 4px 0; }
.mini-abil div > span { display: block; font-size: 9.5px; color: var(--muted); letter-spacing: .06em; }
.mini-abil b { font-size: 13px; }
.mini-res { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.nav { list-style: none; margin: 0; padding: 4px; }
.nav a {
  display: flex; justify-content: space-between; gap: 8px; padding: 5px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 13.5px; border-left: 2px solid transparent;
}
.nav a:hover { background: var(--panel-2); }
.nav a.active { background: var(--panel-2); border-left-color: var(--accent); color: var(--accent); }
.nav-short { display: none; }
.nav .count { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.side-tools { display: flex; gap: 6px; padding: 8px 4px 0; flex-wrap: wrap; }
.side-tools button { font-size: 12px; padding: 4px 8px; }
.filter-box.no-hits { border-color: var(--bad); }
.filter-box { width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; }

/* ---------- Sections & cards ---------- */
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.section > h2 {
  margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent);
  display: flex; align-items: baseline; gap: 10px;
}
.section > h2 .sub { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12.5px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 10px; }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); align-items: start; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }

.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 12px; color: var(--muted); }

.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.card-head { position: relative; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; cursor: pointer; user-select: none; padding-right: 16px; }
.card-head .title { font-weight: 650; }
.card-head .meta { color: var(--muted); font-size: 12.5px; }
.card-head .spacer { flex: 1; }
.card .desc { margin-top: 6px; color: var(--text); font-size: 13.5px; }
.card .lead { margin-top: 6px; }
.card .lead > :last-child { margin-bottom: 0; }
.card-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.card.filter-hit .desc { display: block; }
.card.filter-hit .facts.collapsible { display: flex; }
.card .desc p { margin: 0 0 6px; }
.card .desc p:last-child { margin-bottom: 0; }
.card .desc ul, .card .desc ol { margin: 4px 0 6px; padding-left: 20px; }
.card .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.card .facts b { color: var(--text); font-weight: 600; }
.card.collapsed .desc, .card.collapsed .facts.collapsible { display: none; }
body.compact .card:not(.expanded) .desc, body.compact .card:not(.expanded) .facts.collapsible { display: none; }
.card-head::after { content: "▾"; position: absolute; right: 0; top: 0; color: var(--muted); font-size: 14px; line-height: 1.3; transition: transform .15s; }
.card.collapsed .card-head::after, body.compact .card:not(.expanded) .card-head::after { transform: rotate(-90deg); }
.card.no-toggle .card-head { cursor: default; padding-right: 0; }
.card.no-toggle .card-head::after { content: none; }

.chip { display: inline-block; background: var(--chip); color: var(--text); border-radius: 12px; padding: 1px 9px; font-size: 12px; line-height: 1.6; white-space: nowrap; }
.chip.accent { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.chip.blue { background: color-mix(in srgb, var(--blue) 18%, transparent); color: var(--blue); }
.chip.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.chip.light { background: color-mix(in srgb, var(--light) 18%, transparent); color: var(--light); }
.chip.dark { background: color-mix(in srgb, var(--dark) 18%, transparent); color: var(--dark); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { max-width: 100%; }
div.chip { width: fit-content; white-space: normal; margin-top: 6px; }
a.chip { text-decoration: none; }
a.chip:hover { text-decoration: underline; }
:is(.chips, .eff-head, .cls-head, .mini-res, .card-head) > .chip, .chips > .rollable > .chip { white-space: normal; overflow-wrap: anywhere; }
.chips > .rollable { max-width: 100%; }
.feat-chosen { font-size: 13px; margin-top: 8px; }
.bd-chosen .chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 0 0 4px; font: inherit; opacity: .7; }
.bd-chosen .chip button:hover { opacity: 1; }
.bd-chosen { display: flex; flex-wrap: wrap; gap: 6px; }
/* Level up panel (Classes & Progression). */
.lvl-bar { margin-bottom: 10px; }
.lvl-panel { border-color: var(--accent); margin-bottom: 14px; }
.lvl-set { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; }
.lvl-set legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.lvl-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.lvl-opt { display: inline-flex; gap: 6px; align-items: center; }
.lvl-hp { width: 64px; }
.lvl-feat { font-size: 13px; max-height: 14em; overflow: auto; margin-top: 6px; }
.lvl-gains { margin-top: 10px; }
.lvl-gains .chips { margin-top: 4px; }
.lvl-changes { margin-top: 4px; font-size: 12.5px; }
/* New character wizard. */
.cr-page { max-width: 900px; }
.cr-steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.cr-body { display: grid; gap: 10px; }
.cr-field { display: grid; gap: 4px; max-width: 520px; }
.cr-field > span { font-weight: 600; font-size: 13px; }
.cr-field input, .cr-field select, .cr-page select, .cr-page input[type=number], .cr-char textarea { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 14px; }
.cr-about { border-left: 3px solid var(--accent); padding: 4px 10px; }
.cr-about .chips { margin-top: 6px; }
.cr-inc { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cr-scores td { vertical-align: middle; }
.cr-base { display: flex; gap: 6px; align-items: center; }
.cr-base input { width: 64px; }
.cr-score { min-width: 2ch; text-align: center; }
.cr-items { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; }
.cr-item { display: inline-flex; gap: 6px; align-items: center; }
.cr-char textarea { width: 100%; box-sizing: border-box; }
.cr-char-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.cr-char-head select { max-width: 320px; }
.cr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.open-choices { margin-top: 10px; font-size: 13px; border-left: 3px solid var(--warn); padding: 4px 10px; }
.open-choices a { color: var(--blue); }
.bd-browse { margin-top: 6px; font-size: 13px; }
.bd-browse > summary { cursor: pointer; color: var(--blue); }
.bd-browse-list { max-height: 26em; overflow: auto; display: grid; gap: 8px; margin-top: 6px; padding-right: 4px; }
.bd-opt { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.bd-opt-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bd-opt-head .btn { margin-left: auto; }
.bd-opt .desc { font-size: 12.5px; }
.ed-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ed-pick select { max-width: 100%; }
.pending-each { margin-top: 4px; font-size: 12.5px; }
.pending-each > summary { cursor: pointer; }
.pending-field { display: inline-flex; gap: 6px; margin-right: 12px; }
.chip .die-x-inline { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 0 0 4px; font: inherit; opacity: .75; }
.chip .die-x-inline:hover { opacity: 1; }
.trk-conds { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.trk-conds .chip small { opacity: .8; }
#trackType { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; font: inherit; font-size: 13px; }
.mstate.cond { color: var(--bad) !important; background: color-mix(in srgb, var(--bad) 16%, transparent); }
.trk-round { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.pw-roll .rollable { color: var(--accent); }
.eff-count { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 13px; }
/* inventory: packs, custom items, base items, notes, selling, debts, credit history, shots */
.add-disc input, .add-from input { width: 64px; }
.add-from input { width: 130px; }
.add-desc { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; font-size: 13px; }
.add-desc textarea { width: 100%; }
.add-base { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; margin-top: 4px; }
.add-base select { max-width: 260px; }
.add-base.inline { margin-left: 6px; }
.add-owe { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: 6px; }
.pack-contents { font-size: 13px; margin-top: 4px; }
.sugg-custom { border-top: 1px solid var(--line); }
.inv-note { font-size: 12.5px; color: var(--muted); font-style: italic; }
.inv-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: 13px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.inv-edit label { display: inline-flex; gap: 4px; align-items: center; }
.inv-edit label.wide { flex: 1 1 100%; }
.inv-edit label.wide input, .inv-edit label.wide textarea { flex: 1; }
.inv-edit input { width: 90px; }
.inv-edit [data-ie="name"], .inv-edit [data-ie="label"] { width: 180px; }
.debts { margin: 4px 0 10px; }
.debt { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; margin: 4px 0; }
.credit-log { margin: 4px 0 10px; font-size: 13px; }
.credit-log ul { margin: 6px 0 0; padding-left: 18px; }

.shots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; margin-top: 4px; }
.w-mods { font-size: 12.5px; margin-top: 3px; max-width: 46em; }
.w-mods summary { cursor: pointer; color: var(--accent); }
.w-mods > div { margin: 3px 0 0 12px; color: var(--muted); }
.good-text { color: var(--good); }
.tw-twin { font-size: 12.5px; font-weight: normal; margin-top: 2px; }
/* Recent messages */
.msg-log { position: fixed; right: 12px; z-index: 60; width: min(460px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; padding: 10px 12px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; }
.msg-log .msg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.msg-log ul { margin: 0; padding-left: 18px; }
.msg-log li { margin: 4px 0; }
.msg-log li.error { color: var(--bad); }
/* The activity history (showMessages). */
.act-log { max-height: min(72vh, 640px); }
.act-tools { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-bottom: 6px; font-size: 12.5px; }
.act-tools .btn.on { background: var(--accent); color: var(--on-accent, #fff); border-color: var(--accent); }
.act-list { list-style: none; padding-left: 0 !important; }
.act-list li { padding: 3px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); font-size: 13px; }
.act-list li.act-day { border: 0; padding-top: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.act-list li.act-undone .act-msg { text-decoration: line-through; opacity: .65; }
.act-list li.act-undo { color: var(--muted); }
.act-who { font-weight: 600; }
.act-chip { font-size: 10.5px; }
#status { cursor: pointer; }
.msg-log.guide ol { margin: 0; padding-left: 20px; }
.msg-log.guide li { margin: 5px 0; }
.msg-log.guide p { font-size: 12.5px; margin: 8px 0 0; }
/* Account (account.js) */
.account-pop h4 { margin: 12px 0 4px; font-size: 13px; }
.account-pop p { font-size: 13px; }
.acct-form { display: grid; gap: 6px; margin: 8px 0; }
.acct-form label { display: grid; gap: 2px; font-size: 12.5px; }
.acct-form input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--text); }
.acct-form .btn { justify-self: start; }
.acct-list, .acct-versions { list-style: none; padding: 0; margin: 4px 0; }
.acct-list > li { padding: 6px 0; border-top: 1px solid var(--line); }
.acct-row-acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.acct-versions li { font-size: 12.5px; margin: 3px 0 0 8px; }
.acct-danger { color: var(--bad); }
.acct-settings { margin: 10px 0; }
.acct-settings summary { cursor: pointer; font-weight: 600; font-size: 13px; }
/* The class table: a list on phones */
.ct-list { display: none; margin: 6px 0 0; }
.ct-list > div { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ct-list dt { flex: 0 0 45%; color: var(--muted); }
.ct-list dd { margin: 0; }
@media (max-width: 560px) { .ct-list { display: block; } .ct-table { display: none; } }
/* The ☰ menu in the phone strip */
.sec-jump { width: 38px; padding: 0; text-align: center; text-align-last: center; appearance: none; -webkit-appearance: none; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-size: 17px; }
@media (max-width: 560px) { #trackType { flex: 0 1 76px; min-width: 0; width: 76px; } }
.ctf-choose, [data-infuse] { font-size: 13px; }
.ctf-choose select { margin-left: 4px; }
.eff-custom { margin-top: 8px; font-size: 13px; }
.eff-custom > summary { cursor: pointer; color: var(--blue); }
.eff-custom input, .eff-custom select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13px; }
.lvl-panel select, .lvl-panel input[type=number] { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13px; }
.exh-note { font-size: 12px; flex-basis: 100%; }
.trk-row.trk-states { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
.trk-states > .trk-label { white-space: nowrap; padding-top: 4px; }
.trk-states > .form-rules { grid-column: 1 / -1; }
.trk-state-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.trk-state-btns .state-ctl { margin: 0; }
.rl-cond.blocked { opacity: .6; }
/* Narrow screens (a phone, or the phone frame on a desktop): play buttons big enough to hit. */
@media (max-width: 600px) { .trk-btns .btn { min-width: 40px; min-height: 34px; } .trk-exh .btn.sm { min-width: 36px; min-height: 34px; } }
/* Rolls inside a counter's note (hit die, Second Wind): a clear target, not helper text. */
.trk-label .rollable { color: var(--accent); font-weight: 600; padding: 3px 4px; text-decoration: underline dotted; text-underline-offset: 3px; }
.mvitals .insp { color: var(--accent); }
.muted { color: var(--muted); }
/* Faint, yet readable (at least 4.5:1 on the panels): between the theme's faint and muted. */
.faint { color: color-mix(in srgb, var(--faint) 45%, var(--muted)); }
.empty { color: var(--faint); font-style: italic; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.center, th.center { text-align: center; }
tr.prof td:first-child { font-weight: 600; }
tr.dim td { color: var(--muted); }
tfoot td { font-weight: 600; border-bottom: 0; }
.md-table { margin: 6px 0; font-size: 12.5px; }

/* ---------- Abilities ---------- */
.abilities { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 1700px) { .abilities { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .abilities { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
table.inv { table-layout: fixed; min-width: 520px; }
.kv dt, .kv dd { overflow-wrap: anywhere; min-width: 0; }
.ability { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.ability .top { display: flex; align-items: center; justify-content: space-between; }
.ability .abbr { font-size: 12px; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.ability .mod { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }
.ability .score { background: var(--chip); border-radius: 999px; padding: 1px 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ability .rows { margin-top: 6px; font-size: 13px; }
.ability .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.ability .row .n { color: var(--muted); }
.ability .row.p .n { color: var(--text); }
.ability .breakdown { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.pip { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--faint); margin-right: 6px; vertical-align: 0; }
.pip.proficient { background: var(--accent); border-color: var(--accent); }
.pip.expertise { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 2px var(--panel-2), 0 0 0 3.5px var(--accent); }
.pip.half { background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); border-color: var(--accent); }

/* ---------- Overview ---------- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
/* A picture keeps its own shape (portrait, landscape or square): only shrunk to fit. */
.portrait { position: relative; display: flex; align-items: center; justify-content: center; max-width: min(240px, 42vw);
  border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; color: var(--faint); }
.portrait img { display: block; max-width: 100%; max-height: 280px; width: auto; height: auto; }
.portrait.mine { min-width: 64px; min-height: 64px; }
.portrait-zoom { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; background: color-mix(in srgb, var(--panel) 85%, transparent); color: var(--text); cursor: pointer;
  padding: 0; opacity: 0; }
.portrait-zoom .ico { width: 16px; height: 16px; }
.portrait:hover .portrait-zoom, .portrait-zoom:focus-visible { opacity: 1; }
@media (hover: none) { .portrait-zoom { opacity: .85; } }
/* The picture as large as the window allows (showPicture). */
.pic-view { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .86); cursor: zoom-out; }
.pic-view img { max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); width: auto; height: auto; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.pic-view-close { position: fixed; top: 12px; right: 12px; }
.portrait.broken { width: 200px; padding: 12px; }
.portrait-msg { font-size: 12.5px; color: var(--muted); text-align: center; display: grid; gap: 8px; justify-items: center; }
@media (max-width: 560px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .portrait { max-width: 100%; justify-self: start; }
  .portrait img { max-height: 240px; }
}
.hero.no-portrait { grid-template-columns: minmax(0, 1fr); }
.hero h1 { margin: 0; font-size: 26px; line-height: 1.15; }
.hero .line { color: var(--muted); margin-top: 4px; }
/* A pill that goes somewhere (chip opts.go): looks like a pill, acts as a link. */
button.chip { font-family: inherit; cursor: pointer; border: 0; margin: 0; }
.chip-go { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
.chip-go:hover, .chip-go:focus-visible { filter: brightness(1.08); text-decoration-color: currentColor; }
/* The card a pill went to, for a moment. */
.card.flash { animation: card-flash 1.6s ease-out; }
@keyframes card-flash { 0%, 30% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .card.flash { animation: none; outline: 3px solid var(--accent); } }
/* Damage: the defenses that may apply (renderDamageAsk). */
.dmg-ask { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--panel)); font-size: 13px; display: grid; gap: 6px; }
.dmg-q { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.dmg-q input { margin-top: 3px; }
.dmg-ask-btns { display: flex; gap: 6px; }
/* The turn: actions, bonus actions, reactions (renderTurn). */
.trk-turn { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.econ-list { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.econ { display: inline-flex; gap: 4px; align-items: center; }
.econ-name { font-size: 12.5px; color: var(--muted); margin-right: 2px; }
button.dot.on.econ-on { background: var(--accent); border-color: var(--accent); }
.econ-plus { padding: 0 6px; line-height: 1.3; }
.econ-more { grid-column: 1 / -1; font-size: 12.5px; }
.econ-more summary { cursor: pointer; color: var(--accent); }
.econ-more ul { margin: 4px 0; padding-left: 18px; }
.dice-err { flex-basis: 100%; margin: 4px 0 0; color: var(--bad); font-size: 12.5px; }
/* On a touch screen, a number to tap is a bigger target than it looks (the layout doesn't move). */
@media (pointer: coarse) {
  .rollable { position: relative; }
  .rollable::after { content: ''; position: absolute; inset: -8px -6px; }
}
.nav.filtering .count { display: none; }
.xp { margin-top: 10px; }
.xp-bar { position: relative; height: 8px; background: var(--panel-2); border-radius: 999px; border: 1px solid var(--line); }
.xp-bar > div { height: 100%; background: var(--accent); border-radius: 999px; }
/* The XP bar's handle: a range input over the bar (drag, or arrow keys), only its handle drawn. */
.xp-range { position: absolute; left: -7px; right: -7px; top: 50%; width: calc(100% + 14px); height: 22px; margin: 0; transform: translateY(-50%);
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.xp-range:focus { outline: none; }
.xp-range::-webkit-slider-runnable-track { background: transparent; height: 22px; }
.xp-range::-moz-range-track { background: transparent; height: 22px; }
.xp-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 18px; margin-top: 2px; border-radius: 4px;
  background: var(--panel); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.xp-range::-moz-range-thumb { width: 10px; height: 14px; border-radius: 4px; background: var(--panel); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.xp-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }
.xp-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }
/* ✎ by the character's name (Overview) */
.name-edit { margin-left: 8px; padding: 2px 4px; border: 0; background: none; color: var(--muted); cursor: pointer; vertical-align: middle; border-radius: 6px; }
.name-edit:hover, .name-edit:focus-visible { color: var(--accent); background: var(--panel-2); }
.xp-label { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; justify-content: space-between; }

.hp-bar { height: 10px; background: var(--panel); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin-top: 6px; }
.hp-bar > div { height: 100%; background: var(--good); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--faint); display: inline-block; }
.dots i.on.good { background: var(--good); border-color: var(--good); }
.dots i.on.bad { background: var(--bad); border-color: var(--bad); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.prose { font-size: 14px; max-width: 80ch; }
.prose p { margin: 0 0 10px; }
.banner { border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; }
.banner.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.welcome { max-width: 760px; margin: 40px auto; text-align: center; }
body.no-char .layout { grid-template-columns: minmax(0, 1fr); }
body.no-char #sidebar { display: none; }
.welcome-paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 18px 0; text-align: left; }
.welcome-path { display: grid; gap: 6px; align-content: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.welcome-path .btn { justify-self: start; }
.welcome-credit { margin-top: 18px; font-size: 12px; }
body.no-char .welcome { padding-bottom: 72px; } /* clear of the round dice button */
.trk-state-btns .chip { white-space: normal; }
.tip-def { margin: 0 0 6px; }
.welcome h1 { font-size: 24px; }
.welcome .btn { margin: 4px; }
pre.json { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 480px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
details > summary { cursor: pointer; color: var(--muted); }
mark { background: color-mix(in srgb, var(--accent) 45%, transparent); color: inherit; border-radius: 2px; }
.hidden-by-filter { display: none !important; }

/* ---------- Version history ---------- */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.history li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history .faint { font-size: 12px; }
.warn-text { color: var(--warn); }

/* ---------- Play tracker ---------- */
.btn.sm { padding: 2px 9px; font-size: 13px; border-radius: 6px; }
.btn.sm:disabled, .tracker .btn:disabled { cursor: not-allowed; opacity: .4; }
.btn.on { background: color-mix(in srgb, var(--good) 18%, transparent); border-color: var(--good); color: var(--good); }
.btn.used { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: var(--bad); color: var(--bad); }
.linklike { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; text-decoration: underline; font-size: inherit; }
.tracker { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.trk-top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.trk-amount { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.trk-amount input { width: 96px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font: inherit; }
.trk-amount input:focus { outline: none; border-color: var(--accent); }
.trk-ds { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.trk-ds .dots { gap: 5px; }
.trk-ds .faint { font-size: 12px; margin-right: 6px; }
button.dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--faint); background: none; padding: 0; cursor: pointer; }
button.dot:hover { border-color: var(--text); }
button.dot.on.good { background: var(--good); border-color: var(--good); }
button.dot.on.bad { background: var(--bad); border-color: var(--bad); }
.trk-rows { display: grid; gap: 6px; }
.card .trk-rows { margin: 2px 0 8px; }
.trk-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; }
.trk-label { font-weight: 600; }
.trk-label .faint { font-weight: 400; font-size: 12px; }
.trk-count { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 52px; text-align: right; }
.trk-count b { color: var(--text); font-size: 16px; }
.trk-btns { display: inline-flex; gap: 4px; }
.trk-btns .btn { min-width: 30px; }
.pips { display: inline-flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; max-width: 180px; }
.pips i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--faint); }
.pips i.on { background: var(--accent); border-color: var(--accent); }
.pool-bar { display: inline-block; width: 120px; max-width: 40vw; height: 10px; border-radius: 5px; border: 1.5px solid var(--faint); overflow: hidden; vertical-align: middle; }
.pool-bar i { display: block; height: 100%; background: var(--accent); }
.trk-misc, .trk-rest { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.trk-exh { display: inline-flex; align-items: center; gap: 6px; }
.trk-exh b { min-width: 12px; text-align: center; }
.trk-src { margin-left: auto; font-size: 12px; }
.mini-stat small { font-size: 11px; color: var(--blue); margin-left: 2px; }
/* field editors + unsaved-changes bar */
.ed-btn { margin-left: auto; font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.editor { background: var(--panel-2); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 12px; }
.ed-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.ed-field.long { grid-column: 1 / -1; }
.ed-field input, .ed-field textarea { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 14px; width: 100%; box-sizing: border-box; }
.ed-field textarea { resize: vertical; line-height: 1.45; }
.ed-field input:focus, .ed-field textarea:focus { outline: none; border-color: var(--accent); }
.ed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.ed-err { color: var(--bad); margin: 8px 0 0; font-size: 13px; }
.add-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.add-item h3 { margin: 0 0 8px; }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add-row select, .add-row input { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 14px; }
.add-name { position: relative; flex: 1 1 220px; min-width: 0; display: flex; }
.add-name input { flex: 1; min-width: 0; }
.sugg { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 15; max-height: 320px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; }
/* A section with an open suggestion list stays above the next one (each section's backdrop blur makes its own layer,
   which would otherwise cover the list's lower part). */
.section:has(.sugg) { position: relative; z-index: 16; }
.sugg-item { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; background: none; border: 0;
  color: var(--text); font: inherit; font-size: 13.5px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.sugg-item .faint { font-size: 12px; white-space: nowrap; }
.sugg-item.hi, .sugg-item:hover { background: var(--panel-2); outline: 1px solid var(--accent); }
.sugg-more { font-size: 12px; padding: 4px 8px; }
.add-qty { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.add-qty input { width: 64px; }
.add-row select:focus, .add-row input:focus { outline: none; border-color: var(--accent); }
.add-detail { margin-top: 10px; font-size: 13.5px; }
.add-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.add-checks label { display: flex; align-items: center; gap: 6px; }
.add-src { font-size: 12px; margin: 8px 0 0; }
.add-pay input[data-add="price"] { width: 80px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13.5px; }
.credits-adj { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.credits-adj input:first-child { flex: 1 1 70px; }
.credits-adj [data-credits-note] { flex: 1 1 100%; order: 3; }
.credits-adj input { width: 100%; min-width: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13px; }
.credits-adj input:focus, .add-pay input:focus { outline: none; border-color: var(--accent); }
.use-menu { display: inline-flex; gap: 4px; }
.class-dice { margin-bottom: 4px; }
.state-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.eff-feats summary { cursor: pointer; list-style: none; }
.eff-feats summary h4 { display: inline; }
/* class choices */
.cls-choices { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.cls-arch select, .cls-add, .cls-note { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13px; max-width: 100%; }
.cls-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cls-picks { display: grid; gap: 4px; margin: 6px 0; }
.cls-pick { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: var(--panel-2); }
.cls-pick summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cls-pick .cls-x { margin-left: auto; }
.cls-note { width: 100%; box-sizing: border-box; margin: 6px 0; }
.feat-note { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.feat-note input, .feat-note textarea { flex: 1; min-width: 0; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13px; }
.feat-note textarea { resize: vertical; field-sizing: content; min-height: 1.9em; max-height: 12em; }
.feat-note.asks input, .feat-note.asks textarea { border-color: var(--warn); }
.cls-convert { border: 1px dashed var(--warn); border-radius: 8px; padding: 8px 10px; }
.slot-problem { color: var(--warn); font-size: 12.5px; margin: 2px 0; }
.slot-problem::before { content: "⚠ "; }
.slot-hint { font-size: 12.5px; margin: 2px 0; color: var(--muted); }
.slot-weapons { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin: 4px 0; }
.slot-weapons label { display: inline-flex; gap: 4px; align-items: center; }
.feat-choices { margin: 0 0 12px; border-top: 0; padding-top: 0; }
.feat-choices h3 { margin: 0; }
.cast-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.cast-ctl select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font: inherit; font-size: 13px; }
.pw-roll { font-size: 13px; margin: 0 0 6px; }
.mod-items { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; margin: 4px 0; }
.mod-items select, .cls-pick label select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font: inherit; font-size: 13px; max-width: 100%; }

.cls-conv-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 4px; }
/* dice roller */
.rollable { cursor: pointer; border-radius: 4px; }
.rollable:hover, .rollable:focus-visible { outline: 1px dashed var(--accent); outline-offset: 2px; }
#dicebtn.on { border-color: var(--accent); color: var(--accent); }
#dice { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: min(400px, calc(100vw - 32px)); max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow: auto; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; }
.dice-head { display: flex; align-items: center; gap: 8px; }
.dice-free { display: flex; gap: 4px; margin-left: auto; }
.dice-free input, .rl-mod input, .rl-ability select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13px; width: 110px; }
.rl-mod input { width: 60px; }
.rl-card { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; display: grid; gap: 8px; }
.rl-title { font-size: 15px; }
.rl-modes { display: flex; gap: 4px; }
.rl-conds { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.rl-cond { display: inline-flex; gap: 4px; align-items: center; }
.rl-dice { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 10px; padding: 8px 2px 0; min-height: 80px; }
.rl-nodice { align-self: center; }
/*
 * Dice: each a polyhedron drawn in 3D on a canvas (dice3d.js), the face toward you holding the number. Every die has
 * the same box, so their numbers sit on one line at one size. The canvas is larger than the box (room to drop in,
 * bounce and cast a shadow) and lets clicks through to the die's button. --die-c: its colour (read by the canvas).
 */
.die { --die-c: var(--muted); position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 1px; padding: 0;
  border: 0; background: none; color: inherit; font: inherit; }
.die-3d { position: relative; display: block; width: 60px; height: 60px; }
.die-cv { display: block; color: var(--die-c); pointer-events: none; }
.die-3d .die-cv { position: absolute; left: -24px; top: -24px; width: 108px; height: 108px; z-index: 1; }
.die small { position: relative; z-index: 2; }
button.die { cursor: pointer; border-radius: 10px; }
button.die:hover .die-cv { filter: drop-shadow(0 0 3px color-mix(in srgb, var(--bad) 75%, transparent)); }
button.die:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A natural 20 or 1 lands with a flash in its colour. */
.die.nat20.landed .die-cv, .die.nat1.landed .die-cv { animation: die-glow 1.2s ease-out; }
@keyframes die-glow {
  0% { filter: drop-shadow(0 0 0 transparent); }
  25% { filter: drop-shadow(0 0 12px var(--die-c)) drop-shadow(0 0 4px var(--die-c)); }
  100% { filter: drop-shadow(0 0 0 transparent); }
}
.rl-total.landed { display: inline-block; animation: total-land .4s cubic-bezier(.2, 1.6, .4, 1); }
/* Dice to pick (the empty dock) and to add to a roll. */
.rl-empty { gap: 6px; }
.rl-empty p { margin: 0; }
.rl-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; padding: 4px 0; }
.die-pick { --die-c: var(--muted); display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px; border: 0; background: none;
  color: var(--muted); font: inherit; font-size: 11.5px; cursor: pointer; border-radius: 8px; }
.die-pick.s20 { --die-c: var(--accent); }
.die-pick .die-cv { width: 42px; height: 42px; transition: filter .2s ease, transform .2s ease; }
.die-pick:hover, .die-pick:focus-visible { color: var(--text); }
.die-pick:hover .die-cv, .die-pick:focus-visible .die-cv { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 70%, transparent)); transform: translateY(-1px); }
.die-pick:active .die-cv { transform: scale(.92); }
.rl-add-dice { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.rl-add .die-pick { flex-direction: row; gap: 2px; }
.rl-add .die-pick .die-cv { width: 24px; height: 24px; }
.rl-add .die-pick span::before { content: '+'; }
@keyframes total-land { 0% { transform: scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
.rl-result.rolling .rl-total { color: var(--faint); }
@media (prefers-reduced-motion: reduce) { .die.landed .die-cv, .rl-total.landed { animation: none; } .die-pick .die-cv { transition: none; } }
.die small { font-size: 10px; color: var(--muted); }
.die.d20 { --die-c: var(--accent); }
.die.dropped { opacity: .45; }
.die.nat20 { --die-c: var(--good); color: var(--good); }
.die.nat1 { --die-c: var(--bad); color: var(--bad); }
.die.maxed { --die-c: var(--warn); color: var(--warn); }
.rl-critmode { display: inline-flex; gap: 4px; align-items: center; font-size: 12.5px; color: var(--muted); margin-left: auto; }
.die-x { position: absolute; top: -4px; right: -4px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 11px; line-height: 16px; text-align: center; display: none; }
.die:hover .die-x, .die:focus-visible .die-x { display: block; }
button.die:hover .die-x { color: var(--bad); border-color: var(--bad); }
@media (hover: none) { .die-x { display: block; } }
.rl-add { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; color: var(--muted); }
.rl-mod { display: inline-flex; gap: 4px; align-items: center; margin-left: 6px; }
.rl-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.rl-total { font-size: 32px; font-weight: 700; color: var(--accent); }
.rl-break { width: 100%; font-size: 12.5px; }
.rl-next, .rl-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rl-next.missed .btn { opacity: .7; }
.rl-critrange { font-size: 12.5px; }
.rl-note.warn { border-left-color: var(--warn); color: var(--warn); }
.rl-note { font-size: 12.5px; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 6px; }
.feat-asks { margin-top: 8px; }
.hist-btns { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.hist-diff { flex-basis: 100%; font-size: 12.5px; margin: 4px 0 2px; }
.hist-diff ul { margin: 2px 0 0 16px; padding: 0; list-style: disc; }
.history .hist-diff li { display: list-item; border: 0; padding: 0; font-size: 12.5px; }
.form-rules { font-size: 12.5px; flex-basis: 100%; }
.state-ctl .form-rules { flex-basis: auto; }
.state-ctl .form-rules[open] { flex-basis: 100%; }
.form-rules summary { cursor: pointer; color: var(--accent); }
.form-rules > div { color: var(--muted); margin-top: 3px; }
.rl-again { margin-left: auto; align-self: center; }
.rl-result:focus { outline: none; }
#dice.min { padding-bottom: 8px; }
.dice-mini { display: block; width: 100%; margin-top: 6px; text-align: left; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 2px 0; }
.dice-log { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; display: grid; gap: 2px; font-size: 13px; }
.log-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; background: none; border: 0; color: var(--text); font: inherit; text-align: left; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.log-row:hover, .log-row.cur { background: var(--panel-2); }
/* A roll changed after it was made: the list of changes (card and log), and the log row's mode and its reason. */
.rl-changes { width: 100%; margin: 2px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--warn); }
.rl-changes li { margin: 1px 0; }
.log-more { grid-column: 1 / -1; font-size: 11.5px; margin-top: -2px; }
span.die { cursor: default; }
@media print { #dice, #dicebtn, .mbar-only { display: none !important; } }
.m-props { display: none; font-size: 12.5px; color: var(--muted); }
.skill-name { white-space: nowrap; }
.ds-lbl { font-size: 13px; font-weight: 700; }
.ds-pair { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.bad-text { color: var(--bad); }
.mvitals .dying { color: var(--bad); }
.mvitals { align-items: center; }
.mvitals a { color: inherit; text-decoration: none; }
.mv-hp { display: inline-flex; align-items: baseline; gap: 6px; }
/* What's active (Rage, a form, concentration…), in the pinned strip. */
.mstate { display: inline-block; max-width: 9em; overflow: hidden; text-overflow: ellipsis; padding: 1px 8px; border-radius: 999px;
  font-weight: 600; color: var(--good) !important; background: color-mix(in srgb, var(--good) 16%, transparent); }
.mstate small { font-weight: 400; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 60; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; }
.use-menu { flex-wrap: wrap; }
.mid-only { display: none !important; }
.ds-lbl.good { color: var(--good); }
.ds-lbl.bad { color: var(--bad); }
.bump { border-bottom: 1px dotted currentColor; cursor: help; }
.prop-tip { border-bottom: 1px dotted var(--faint); cursor: help; }
.tip-prop { font-size: 12.5px; max-height: 40vh; overflow: auto; }
.tip-prop p { margin: 4px 0; }
.bump.up { color: var(--good); }
.bump.down { color: var(--bad); }
.alts { white-space: nowrap; }
.alt.bump { border-bottom: 1px dotted var(--blue); color: var(--blue); font-weight: 600; }
.alt small { font-weight: 400; font-size: .72em; color: var(--muted); }
.stat .value .alts { display: block; font-size: .55em; white-space: normal; line-height: 1.3; }
.stat .value .alts .alt:first-child .sep, .mini-stat .alts .sep, .mini-abil .alts .sep { display: none; }
.mini-stat .alts, .mini-abil .alts { display: block; font-size: 10px; line-height: 1.2; white-space: normal; }
.mini-stat .alts .alt, .mini-abil .alts .alt { display: block; }
#bumpTip { position: absolute; z-index: 50; max-width: min(380px, calc(100vw - 16px)); background: var(--panel); color: var(--text);
  border: 1px solid var(--accent); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); pointer-events: none; }
#bumpTip ul { margin: 6px 0 0; padding-left: 16px; }
#bumpTip li { margin: 2px 0; }
.tip-head { font-size: 12.5px; }
.eff.off { opacity: .65; }
.tweaks-card { margin-bottom: 12px; }
table.tweaks td { vertical-align: middle; }
.tw-vals { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.tw-vals label { display: inline-flex; gap: 4px; align-items: center; font-size: 12.5px; color: var(--muted); }
.tw-vals input, .tw-vals select, .tw-add input, .tw-add select, .tw-reason { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 13px; }
.tw-vals input { width: 64px; }
.tw-reason { width: 100%; min-width: 220px; box-sizing: border-box; }
/* The tweaks table: the reason gets the room (it's what's read later), the adjustment its own. */
table.tweaks th:nth-child(3), table.tweaks td:nth-child(3) { width: 40%; }
.tw-reason.missing { border-color: var(--warn); }
.tw-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.tw-add input[data-twadd="value"] { width: 80px; }
.tw-add .tw-reason { flex: 1 1 200px; width: auto; }
.eff-notes { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.fx-weapon { font-size: 12.5px; color: var(--muted); }
.fx-weapon select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; font: inherit; font-size: 12.5px; }
#sec-combat h4 { margin: 8px 0 6px; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.eff-off summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-top: 8px; }
.eff { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; background: var(--panel-2); }
.eff-head { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.eff-head .btn { margin-left: auto; }
.eff-add { margin-top: 8px; }
.ability .top.boosted .score { color: var(--good); }
.inv-ctl { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.inv-qty { display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; }
.inv-qty b { min-width: 18px; text-align: center; }
.pending-wrap:empty { display: none; }
.banner.pending { box-shadow: none; }
.banner.pending { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: color-mix(in srgb, var(--warn) 12%, var(--panel)); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.pending-btns { display: flex; gap: 8px; margin-left: auto; align-items: center; }
/* Destructive links sit apart from the everyday buttons, smaller. */
.pending-btns .discard, .trk-reset { font-size: 12px; margin-left: 10px; }
.trk-reset { color: var(--muted); }
/* ---------- Tablets and phones ----------
   The top bar scrolls away; the section list becomes a pinned strip (with HP, search and dice),
   the summary card is left out (Overview and Combat & Vitals come first), and messages show as toasts. */
@media (max-width: 900px) {
  .brand { display: none; }
  :root { --navbar-h: 46px; }
  html { scroll-padding-top: calc(var(--navbar-h) + 10px); }
  .topbar { position: static; height: auto; padding: 8px 12px; gap: 8px; backdrop-filter: none; background: var(--bg); }
  .picker { flex: 1; min-width: 0; }
  .picker select { min-width: 0; width: 100%; max-width: none; }
  .actions #dicebtn { display: none; }
  .layout { display: block; padding: 0 12px 12px; }
  .sidebar { position: sticky; top: 0; z-index: 15; max-height: none; overflow: visible; margin: 0 -12px 12px; padding: 0; }
  .side-summary { display: none; }
  .side-nav { display: flex; align-items: center; gap: 6px; margin: 0; padding: 6px 12px; min-height: var(--navbar-h);
    border-radius: 0; border-width: 0 0 1px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
  .side-nav .nav { flex: 1; min-width: 0; display: flex; flex-wrap: nowrap; gap: 4px; padding: 0; overflow-x: auto; scrollbar-width: none; }
  .side-nav .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; border-left: 0; background: var(--panel-2); border-radius: 999px; padding: 5px 12px; }
  .nav a.active { border-left: 0; outline: 1px solid var(--accent); }
  .nav .count, .nav .nav-full:has(+ .nav-short) { display: none; }
  .nav .nav-short { display: inline; }
  .side-tools, .filter-box { display: none; }
  .side-nav.searching .filter-box { display: block; flex: 1; min-width: 0; margin: 0; }
  .side-nav.searching .nav { display: none; }
  .mbar-only { display: inline-flex !important; }
  .mbar-btn { flex: none; align-items: center; justify-content: center; min-width: 34px; height: 32px; padding: 0 8px; }
  .mvitals { flex: none; align-items: baseline; gap: 6px; padding: 4px 9px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
    color: var(--text); text-decoration: none; font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .mvitals .faint { font-size: 11px; }
  .banner.pending { padding: 6px 10px; font-size: 13px; }
  .grid.cards { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  /* Messages: a toast under the pinned strip (the top bar isn't on screen) that goes away by itself. */
  .status { position: fixed; left: 12px; right: 12px; top: calc(var(--navbar-h) + 8px); z-index: 45; max-width: 560px; margin: 0 auto;
    display: block; -webkit-line-clamp: none; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; color: var(--text);
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; }
  .status.error { color: var(--bad); border-color: var(--bad); }
  .status:not(.fresh), .status:empty { display: none; }
}
@media (max-width: 700px) {
  .brand span { display: none; }
  #btnLoad, #btnImport { display: none; }
  .menu-pop .narrow-only { display: block !important; }
  .menu-pop { min-width: min(280px, calc(100vw - 24px)); }
  .table-wrap .col-ability, .table-wrap .col-type { display: none; }
}
@media (max-width: 560px) {
  .layout { padding: 0 8px 8px; }
  .sidebar { margin: 0 -8px 10px; }
  .section { padding: 12px 12px 14px; margin-bottom: 12px; }
  .section > h2 { margin-bottom: 10px; }
  .card { padding: 8px 10px; }
  .grid.cards { gap: 8px; }
  .hero h1 { font-size: 22px; }
  .grid.auto { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .grid.auto .stat.wide { grid-column: span 2; }
  .stat { padding: 8px 10px; }
  .stat .value { font-size: 19px; }
  .stat .label { font-size: 10px; letter-spacing: .06em; }
  .ability { padding: 8px 10px; }
  .ability .mod { font-size: 22px; }
  .ability .row { font-size: 12.5px; }
  .trk-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .trk-row .pips { display: none; }
  .trk-src { margin-left: 0; }
  .trk-hp, .trk-amount { flex: 1 1 100%; }
  .trk-amount { flex-wrap: nowrap; }
  .trk-amount input { flex: 1 1 0; width: 0; min-width: 60px; padding-left: 6px; padding-right: 6px; }
  .trk-amount .btn { padding-left: 8px; padding-right: 8px; }
  table.inv td:nth-child(2):has(.use-menu) { grid-column: 1 / -1; }
  .col-prof, .col-props { display: none; }
  .m-props { display: block !important; }
  th, td { padding: 6px 8px; }
  /* Inventory: one block per item (name, then its buttons, then weight · cost · source). */
  table.inv { min-width: 0; table-layout: auto; }
  table.inv colgroup, table.inv thead { display: none; }
  table.inv tbody { display: block; }
  table.inv tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 4px 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
  table.inv td { display: block; padding: 0; border: 0; }
  table.inv td:nth-child(1) { grid-column: 1 / -1; }
  table.inv td.num, table.inv td:nth-child(5) { font-size: 12px; color: var(--muted); }
  /* Tweaks: stat and × on one line, the values and the reason below. */
  table.tweaks thead { display: none; }
  table.tweaks, table.tweaks tbody { display: block; }
  table.tweaks tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.tweaks td { display: block; padding: 0; border: 0; }
  table.tweaks td:nth-child(2), table.tweaks td:nth-child(3) { grid-column: 1 / -1; }
  table.tweaks td:nth-child(4) { grid-row: 1; grid-column: 2; }
  .tw-add > * { flex: 1 1 120px; }
  #dice { right: 8px; left: 8px; bottom: 8px; width: auto; max-height: 62vh; }
}
@media (max-width: 340px) { .abilities { grid-template-columns: 1fr; } }
@media (max-width: 370px) { .mvitals .ac { display: none; } .mstate { max-width: 5.5em; } }
/* Something active: it takes the AC's place on phones (and the HP maximum's on the smallest). */
@media (max-width: 430px) { .mvitals:has(.mstate) .ac { display: none; } }
@media (max-width: 340px) { .mvitals:has(.mstate) .hpmax { display: none; } }
/* Mid widths: the top bar keeps room for messages (Import moves into More). */
@media (max-width: 1280px) {
  .brand-name small { display: none; }
  #btnImport { display: none; }
  .menu-pop .mid-only { display: block !important; }
  .picker select { min-width: 180px; max-width: 280px; }
}
/* Touch screens: bigger targets for the buttons used during play. */
@media (pointer: coarse) {
  .btn { min-height: 38px; }
  .btn.sm { min-height: 32px; padding: 4px 11px; }
  .trk-btns .btn { min-width: 40px; }
  .trk-amount .btn.sm { padding-left: 8px; padding-right: 8px; }
  button.dot { width: 26px; height: 26px; }
  .nav a { padding: 7px 12px; }
  .cast-ctl select, .cls-add, .cls-arch select, .mod-items select, .add-row select, .add-row input, .tw-vals input, .tw-vals select, .feat-note input, .cls-note { min-height: 34px; }
  .rl-add .btn.sm { min-width: 44px; }
  .rl-add .die-pick { min-height: 40px; min-width: 44px; justify-content: center; }
  .hint-kbd { display: none; }
}
@media print {
  .topbar, .sidebar { display: none; }
  .layout { display: block; padding: 0; }
  .section { break-inside: avoid-page; box-shadow: none; }
  .add-item, .credits-adj, .inv-ctl .btn, .pending-wrap, .ed-btn, .status, .cast-ctl, .state-ctl, .trk-btns, .cls-add { display: none !important; }
  /* Paper: the numbers and the text, not the controls (forms, buttons, dice, the background art). */
  .trk-amount, .trk-hint, .trk-turn, .trk-rest, .trk-misc, .trk-states, .dmg-ask, .xp-range, .name-edit, .portrait-zoom, .pic-chip,
  .welcome, .theme-art, .lvl-row, .cls-pick, .econ-more, .form-rules, .open-choices a, .side-tools, select, button.btn, .linklike { display: none !important; }
  body, .section, .card, .stat { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .chip, .chip-go { border: 1px solid #999; background: none !important; color: #000 !important; text-decoration: none; }
  a { color: inherit; text-decoration: none; }
  /* Compact or collapsed cards print in full. */
  .card .desc { display: block !important; }
  .card .facts.collapsible { display: flex !important; }
  .card-head::after { content: none !important; }
}

/* Defenses & senses (Combat & Vitals) */
.defs { display: grid; gap: 6px; }
.defs-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: baseline; }
.defs-row > .faint { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 520px) { .defs-row { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- Section list: icons, group headings, shortcut keys; look controls; the dice button ---------- */
.ico { flex: none; display: inline-block; vertical-align: -4px; }
.nav-group { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .14em; color: var(--faint); padding: 12px 10px 3px; }
.nav-group:first-child { padding-top: 2px; }
.nav a { align-items: center; justify-content: flex-start; gap: 9px; }
.nav-ico { display: inline-flex; flex: none; color: var(--muted); transition: color .15s; }
.nav-ico .ico { width: 17px; height: 17px; }
.nav a:hover .nav-ico, .nav a.active .nav-ico { color: var(--accent); }
.nav .nav-full, .nav .nav-short { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-key { display: none; }
kbd, .nav-key { font: 600 11px/1.5 var(--mono); padding: 0 5px; min-width: 1.6em; text-align: center; border-radius: 4px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--panel-2); color: var(--text); }
/* Shift held: each section's key shows (in place of its count). */
html.keys-shown .nav .nav-key { display: inline-block; }
html.keys-shown .nav .count { display: none; }
.side-tools button, .side-look button, .welcome-look button { display: inline-flex; align-items: center; gap: 5px; }
.side-tools .ico, .side-look .ico, .welcome-look .ico { width: 15px; height: 15px; }
/* Always in sight at the bottom of the section list, however far the list is scrolled. */
.side-look { position: sticky; bottom: 0; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px -12px -12px; padding: 8px 16px 12px;
  border-top: 1px solid var(--line); background: var(--panel); border-radius: 0 0 var(--radius) var(--radius); }
.side-look button { font-size: 12px; padding: 4px 8px; }
.theme-btn > span { display: inline-flex; align-items: center; gap: 5px; }
:root[data-theme="light"] .when-dark, :root:not([data-theme="light"]) .when-light { display: none !important; }
.welcome-look { display: flex; justify-content: center; gap: 4px; }
.pic-chip { cursor: pointer; border: 0; font: inherit; font-size: 12px; }
.chips > button.chip { border: 0; cursor: pointer; font-family: inherit; }
.pic-chip .ico { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
.trk-hint { display: block; font-size: 11.5px; margin-top: 3px; }

/* The dice: a round button in the corner, always at hand (it hides while the dice are open; ✕ or Shift + D closes them). */
.dice-fab { position: fixed; right: 22px; bottom: 22px; z-index: 35; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .35), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); transition: transform .15s ease, box-shadow .15s ease; }
.dice-fab:hover { transform: rotate(-12deg) scale(1.06); box-shadow: 0 10px 26px rgba(0, 0, 0, .4), 0 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent); }
.dice-fab:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; }
body:has(#dice:not([hidden])) .dice-fab { display: none; }
.sheet { padding-bottom: 64px; }
@media (prefers-reduced-motion: reduce) { .dice-fab, .nav-ico { transition: none; } .dice-fab:hover { transform: none; } }
@media print { .dice-fab, .side-look { display: none !important; } }

/* "?": the keyboard shortcuts. */
.msg-log.keys-pop { top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%); width: min(780px, calc(100vw - 24px)); max-height: 84vh; }
.keys-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.keys-pop h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.msg-log .keys-list { list-style: none; padding: 0; margin: 0; }
.msg-log .keys-list li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: start; margin: 0; padding: 3px 0; }
.msg-log .keys-list li.keys-group { display: block; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .14em; color: var(--faint); padding-top: 8px; }
.keys-list .keys { white-space: nowrap; }
.keys-list li > span:not(.keys) { display: inline-flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.keys-list li > span .ico { width: 15px; height: 15px; align-self: center; color: var(--muted); }
.keys-list li.faint > span { color: var(--faint); }
.keys-list small { display: block; width: 100%; }
@media (max-width: 640px) { .keys-cols { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .nav-group, .side-look, .nav-key, html.keys-shown .nav .nav-key { display: none; }
  .nav a { gap: 6px; }
  .nav-ico .ico { width: 15px; height: 15px; }
  .nav .nav-full, .nav .nav-short { flex: none; overflow: visible; }
  .sheet { padding-bottom: 76px; }
}
@media (max-width: 560px) { .dice-fab { right: 14px; bottom: 14px; width: 52px; height: 52px; } }

/* Settings, Tweaks & Data → Rules options */
.rules-opt { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; cursor: pointer; }
.rules-opt input { margin-top: 3px; }
