:root {
  --bg: #15171c;
  --panel: #1e2229;
  --panel-2: #262b34;
  --line: #353b47;
  --text: #e8e4d9;
  --muted: #9b998f;
  --accent: #d1a954;
  --accent-ink: #1b1508;
  --danger: #b4443c;
  --ok: #6fa873;
  --radius: 8px;
  --serif: Georgia, 'Palatino Linotype', 'Book Antiqua', serif;
  --sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --top: 58px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: normal; line-height: 1.2; }
h1 { color: var(--accent); margin: 0 0 16px; font-size: 30px; }
h2 { margin: 0 0 4px; font-size: 24px; }
h3 { margin: 20px 0 8px; color: var(--accent); font-size: 18px; }
h4 { margin: 14px 0 6px; font-size: 15px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.bad { color: #e2766d; }
hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; width: 100%; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: #0f1114; border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 21px; color: var(--accent); white-space: nowrap; }
.data-status { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; align-items: center; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: none; }
.segmented button { padding: 6px 14px; border: 0; background: var(--panel-2); color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.load-as { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.load-as select { width: auto; padding: 6px 8px; font-size: 13px; }
.asi { display: flex; gap: 16px; flex-wrap: wrap; align-items: end; margin-bottom: 6px; }
.asi .field { margin-bottom: 0; min-width: 180px; }

/* ---------- accounts ---------- */
body.logged-out .topbar { justify-content: space-between; }
.auth-card {
  max-width: 440px; margin: 40px auto; padding: 28px 32px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.auth-card h1 { font-size: 26px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; margin: 6px 0 14px; }
.code-input { text-transform: uppercase; letter-spacing: .12em; font-family: Consolas, monospace; }
.form-error { color: #e2766d; background: #2a1715; border: 1px solid #5c2a25; border-radius: 6px; padding: 8px 12px; }
.narrow-form { max-width: 380px; }
.user-btn { background: none; border: 1px solid transparent; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; padding: 6px 10px; border-radius: 6px; }
.user-btn:hover, .user-btn.active { border-color: var(--line); background: var(--panel-2); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 10px 2px; }
.save-status.saving { color: var(--accent); }
.save-status.error { color: #e2766d; }
code { font-family: Consolas, monospace; background: #11141a; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
code.big { font-size: 17px; }
.copy-row { display: flex; gap: 8px; margin: 8px 0; }
.copy-row input { flex: 1; }
.toolbar select { width: auto; }
.local-load { align-items: center; }

/* ---------- data sources ---------- */
.section-title { color: var(--accent); margin-top: 34px; font-size: 22px; }
.add-source { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.add-source input { flex: 1; min-width: 260px; }
.add-source select { width: auto; }
.remote-picker h3 { margin-top: 0; }
.file-list { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.file-row { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.file-row:hover { background: var(--panel-2); }
.file-row > span:first-of-type { flex: 1; word-break: break-all; }
.remote-summary { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 12px; }
td a { color: var(--accent); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 14px; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 3px 10px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font: inherit; font-size: 12px; }
button.link:hover { color: var(--accent); }

a { color: var(--accent); }
input[type=text], input[type=number], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: #11141a; color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }

/* ---------- layout: top navigation + page ---------- */
main { padding: 22px 32px 60px; max-width: 1560px; margin: 0 auto; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav button {
  padding: 8px 16px; border: 0; border-radius: 6px; background: none; color: var(--muted);
  font: inherit; font-size: 15px; cursor: pointer;
}
.mainnav button:hover { color: var(--text); background: var(--panel-2); }
.mainnav button.active { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.page-head .toolbar { margin: 0; }

/* the character page */
.char-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.char-head .back { font-size: 14px; }
.char-title { flex: 1; min-width: 200px; }
.char-title h1 { margin: 0; font-size: 28px; }
.char-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.char-tabs .tab { border-radius: 6px 6px 0 0; border-bottom: 0; margin-bottom: -1px; }
.char-tabs .tab.active { background: var(--panel); color: var(--accent); border-color: var(--line); font-weight: 600; }
.step-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; }
.step {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--text); font: inherit; font-size: 14px;
}
.step:hover { border-color: var(--accent); }
.step.active { border-color: var(--accent); background: #2b2719; }
.step .num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.step.done .num { background: var(--ok); border-color: var(--ok); color: #0e1a0f; font-weight: bold; }

/* My characters */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 14px; }
.char-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; }
.char-card:hover { border-color: var(--accent); }
.char-card-main { display: flex; flex-direction: column; gap: 3px; padding: 16px 18px 10px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.char-card-main b { font-family: var(--serif); font-size: 20px; font-weight: normal; color: var(--accent); }
.char-card-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 14px; }

/* Compendium-style list + detail */
.comp { display: grid; grid-template-columns: minmax(330px, 440px) minmax(0, 1fr); gap: 18px; align-items: start; }
.comp.wide-detail { grid-template-columns: minmax(260px, 330px) minmax(0, 1fr); }
.comp-list { position: sticky; top: calc(var(--top) + 12px); display: flex; flex-direction: column; max-height: calc(100vh - var(--top) - 24px); min-width: 0; }
.list-tools { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.list-tools .search { flex: 1; min-width: 140px; }
.list-tools select { width: auto; font-size: 13px; padding: 6px 8px; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.comp-list .table-scroll { flex: 1; min-height: 0; }
.list-table { font-size: 13px; }
.list-table th { position: sticky; top: 0; background: var(--panel-2); z-index: 1; white-space: nowrap; }
.list-table th.sortable { cursor: pointer; user-select: none; }
.list-table th.sortable:hover { color: var(--text); }
.list-table td { padding: 5px 10px; border-color: #2c313b; }
.list-table tr[data-action] { cursor: pointer; }
.list-table tbody tr:hover td { background: var(--panel-2); }
.list-table tr.active td { background: #3a3220; }
.list-table td.name { font-weight: 600; }
.ed-badge { display: inline-block; font-size: 10px; padding: 0 5px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); vertical-align: 1px; }
.ed-badge.ed-2024 { border-color: #3d5a80; color: #8fb3e0; }
.ed-badge.ed-2014 { border-color: #5a4b22; color: #c9a454; }
.comp-detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; min-width: 0; }
.comp-detail pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #101317; padding: 10px; border-radius: 6px; max-height: 500px; overflow: auto; }
.detail-head h2 { color: var(--accent); font-size: 28px; }
.detail-head p { margin-bottom: 12px; }
.stat-table { width: auto; min-width: 50%; margin: 6px 0 14px; font-size: 14px; }
.stat-table th { color: var(--muted); font-size: 13px; padding: 5px 16px 5px 0; vertical-align: top; white-space: nowrap; border-bottom: 1px solid #2c313b; }
.stat-table td { padding: 5px 0; border-bottom: 1px solid #2c313b; }
.collapsible-group { margin: 12px 0; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.group-head h3 { margin: 8px 0; }
.choose-box { background: #2b2719; border: 1px solid #5a4b22; border-radius: var(--radius); padding: 12px 16px; margin: 10px 0; }
.choose-box .field { margin-bottom: 6px; }
details.raw { margin-top: 18px; font-size: 13px; color: var(--muted); }
.cat-tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.cat-tabs .more-cats { width: auto; font-size: 14px; padding: 7px 10px; }

/* classes: progression table + features */
.sub-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 12px; }
.chip { padding: 4px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.class-table { font-size: 13px; }
.class-table th { background: var(--panel-2); text-align: center; white-space: nowrap; padding: 5px 8px; border: 1px solid #2c313b; }
.class-table th.group { color: var(--accent); }
.class-table td { text-align: center; padding: 4px 8px; border: 1px solid #2c313b; white-space: nowrap; }
.class-table .features-col { text-align: left; white-space: normal; min-width: 220px; }
.class-table tbody tr:nth-child(even) td { background: #1b1f26; }
.class-table tr.reached td { background: #2b2719 !important; }
.class-table a { color: #8fb3e0; text-decoration: none; }
.class-table a.sub { color: #d9a8e0; font-style: italic; }
.class-table a:hover { text-decoration: underline; }
.class-body { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 24px; margin-top: 18px; align-items: start; }
.core-traits { background: var(--panel-2); border-radius: var(--radius); padding: 4px 16px 12px; font-size: 14px; }
.core-traits .stat-table { width: 100%; }
details.feature { border-bottom: 1px solid var(--line); padding: 8px 0; }
details.feature > summary { cursor: pointer; font-family: var(--serif); font-size: 18px; color: var(--accent); }
details.feature .lvl { font-family: var(--sans); font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; margin-right: 4px; vertical-align: 2px; }
details.feature p { margin: 8px 0; }

/* equipment step */
.equip-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.inventory td { padding: 5px 8px; }
.inventory tr.equipped td { background: #232a1f; }
.inventory input.qty { width: 64px; padding: 4px 6px; }
.ac-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 14px 0; }
.ac-box .big { font-family: var(--serif); font-size: 30px; color: var(--accent); vertical-align: -3px; }
.warn-line { color: #e3a85a; font-size: 13px; }
.warn-line::before { content: '⚠ '; }
.item-search { margin: 8px 0 18px; }
.item-results { margin-bottom: 8px; }
.item-results td { padding: 4px 8px; }
.sheet-inventory li.equipped { font-weight: 600; }

/* starting equipment choices */
.start-source { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.start-source h4 { margin: 2px 0 8px; color: var(--accent); }
.start-fixed { font-size: 14px; }
.start-group { border-top: 1px solid #2c313b; padding: 8px 0; }
.start-opt { display: block; padding: 3px 6px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.start-opt.active { background: #2b2719; }
.start-opt input { vertical-align: -2px; }
.start-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 10px; margin: 6px 0 0 24px; }
.start-picks .field { margin-bottom: 6px; }

/* custom background, rule limits */
.custom-bg-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; margin-bottom: 10px; }
.check-grid .check { white-space: normal; }
.limits { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.counter b { color: var(--accent); }
.counter.done b { color: var(--ok); }
.counter.over b { color: #e2766d; }
.free-choices { display: flex; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); white-space: normal; }
.spell-row.is-full label { opacity: .55; }

.notice { background: #2a2617; border: 1px solid #5a4b22; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--muted); }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.tag.warn { border-color: #8a5a1f; color: #e3a85a; }
.tag.legacy { font-size: 11px; padding: 0 6px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

.step-nav { display: flex; justify-content: space-between; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- picker ---------- */
.picker { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.pick-list .search { margin-bottom: 8px; }
.cards { display: flex; flex-direction: column; gap: 3px; max-height: calc(100vh - 230px); overflow: auto; padding-right: 4px; }
.card {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  text-align: left; cursor: pointer; padding: 8px 12px; border-radius: 6px;
  border: 1px solid transparent; background: var(--panel); color: var(--text); font: inherit;
}
.card:hover { border-color: var(--line); }
.card.active { border-color: var(--accent); background: #2b2719; }
.card small { color: var(--muted); font-size: 11px; }
.pick-detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; min-width: 0; }
.pick-detail pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #101317; padding: 10px; border-radius: 6px; max-height: 500px; overflow: auto; }
.subblock { border-left: 3px solid var(--accent); padding-left: 14px; margin: 10px 0 16px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 14px 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
details.trait { border-bottom: 1px solid var(--line); padding: 6px 0; }
details.trait summary, details summary { cursor: pointer; }
details.trait p { margin: 8px 0 4px 16px; color: #d3cfc4; }

/* ---------- abilities ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 16px; cursor: pointer; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font: inherit; }
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: normal; color: var(--muted); font-size: 13px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.c { text-align: center; }
td.total { font-weight: 600; font-size: 17px; }
table.abil { max-width: 760px; margin-bottom: 12px; }
table.abil select, table.abil input { max-width: 110px; }
input.narrow { max-width: 80px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper b { width: 24px; text-align: center; font-size: 17px; }
table.skills { max-width: 900px; }
table.skills tr.prof td:first-child b { color: var(--accent); }
table.library tr.current td { background: #22201a; }
td.row-actions { text-align: right; }
td.row-actions > .btn { margin: 2px 0 2px 6px; }

/* ---------- equipment / spells ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.two-col.spells { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.filters .search { flex: 1; min-width: 180px; }
.filters select { width: auto; }
.spell-list { max-height: calc(100vh - 280px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.spell-row { padding: 7px 12px; border-bottom: 1px solid var(--line); }
.spell-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.spell-row details { margin-left: 24px; font-size: 13px; color: var(--muted); }
.spell-row details[open] { color: #d3cfc4; }
.spell-meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
ul.chosen { padding-left: 18px; margin: 0; }

/* ---------- data browser ---------- */
.browser { display: grid; grid-template-columns: 210px 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.cat-list { display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 200px); overflow: auto; }
.cat { display: flex; justify-content: space-between; gap: 6px; text-align: left; cursor: pointer; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 14px; }
.cat:hover { background: var(--panel-2); }
.cat.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.cat.other { color: var(--muted); }
.cat .count { color: var(--muted); font-size: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 520px;
  background: #0f1114; border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); font-size: 14px;
}

/* ---------- character sheet (parchment) ---------- */
.sheet-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.sheet {
  background: #f3ead6; color: #2b2217; border-radius: var(--radius); padding: 30px 36px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .45); font-size: 14px;
}
.sheet h1 { color: #6e1f1a; font-size: 34px; margin: 0; }
.sheet h3 { color: #6e1f1a; border-bottom: 1px solid #c9b48a; padding-bottom: 3px; margin-top: 18px; }
.sheet .muted, .sheet small { color: #7a6a52; }
.sheet-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 2px solid #6e1f1a; padding-bottom: 12px; margin-bottom: 16px; }
.sheet-head p { margin: 4px 0 0; font-size: 16px; }
.sheet dl.facts { margin: 0; }
.sheet dl.facts dt { color: #7a6a52; }
.ab-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.ab { border: 2px solid #6e1f1a; border-radius: 10px; text-align: center; padding: 6px 4px; background: #fbf6ea; }
.ab span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.ab b { display: block; font-size: 26px; font-family: var(--serif); line-height: 1.2; }
.ab small { display: inline-block; border: 1px solid #c9b48a; border-radius: 10px; padding: 0 10px; color: #2b2217; }
.stat-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 8px; }
.stat { border: 1px solid #c9b48a; border-radius: 8px; text-align: center; padding: 6px 4px; background: #fbf6ea; }
.stat b { display: block; font-size: 20px; font-family: var(--serif); }
.stat span { font-size: 11px; text-transform: uppercase; color: #7a6a52; }
.sheet-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 30px; }
ul.checklist { list-style: none; padding: 0; margin: 0; columns: 1; }
ul.checklist li { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
ul.checklist i { width: 11px; height: 11px; border: 1.5px solid #6e1f1a; border-radius: 50%; flex: none; }
ul.checklist li.on i { background: #6e1f1a; }
ul.checklist li.on { font-weight: 600; }
.sheet ul { padding-left: 18px; margin: 0 0 8px; }
.sheet table th { color: #7a6a52; border-color: #c9b48a; }
.sheet table td { border-color: #ddd0b2; padding: 4px 10px; }

/* ---------- rolling dice on the sheet ---------- */
.sheet-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.sheet-actions { align-items: center; }
button.rollable { font: inherit; color: inherit; cursor: pointer; }
button.rollable:not(.ab):not(.stat) { background: none; border: 0; padding: 0; text-align: inherit; }
.sheet .rollable:hover { color: #6e1f1a; }
ul.checklist button.rollable { text-decoration: underline dotted #b39a6a; text-underline-offset: 3px; }
button.ab.rollable, button.stat.rollable { width: 100%; text-align: center; transition: transform .08s, box-shadow .08s; }
button.ab.rollable:hover, button.stat.rollable:hover { box-shadow: 0 0 0 2px #c9a454; transform: translateY(-1px); }
button.stat.rollable b { text-decoration: underline dotted #b39a6a; text-underline-offset: 4px; }
.roll-btn {
  font: inherit; font-size: 13px; cursor: pointer; padding: 1px 8px; margin: 1px 0; border-radius: 10px;
  border: 1px solid #c9b48a; background: #fbf6ea; color: #2b2217; white-space: nowrap;
}
.roll-btn:hover { border-color: #6e1f1a; color: #6e1f1a; }
.save-dc { font-size: 13px; white-space: nowrap; color: #6e1f1a; }
.spell-rolls { white-space: normal; }
.small-note { font-size: 12px; }

.dice-tray {
  position: sticky; top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px);
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.tray-head { display: flex; justify-content: space-between; align-items: baseline; }
.tray-head b { font-family: var(--serif); font-weight: normal; font-size: 19px; color: var(--accent); }
.segmented.small { display: flex; }
.segmented.small button { flex: 1; padding: 5px 4px; font-size: 12px; }
.quick-dice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.quick-dice .btn { justify-content: center; }
.custom-roll { display: flex; gap: 6px; }
.custom-roll input { padding: 5px 8px; }
.roll-log { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 60px; }
.roll { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.roll.latest { border-color: var(--accent); }
.roll-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.roll-head b { font-size: 18px; font-family: var(--serif); }
.roll.latest .roll-head b { font-size: 26px; color: var(--accent); }
.roll-detail { color: var(--muted); font-size: 12px; }
.roll-detail s { opacity: .6; }
.roll-note { font-weight: 600; margin-top: 2px; }
.roll.crit { border-color: var(--ok); }
.roll.crit .roll-note, .roll.crit .roll-head b { color: #8fd193; }
.roll.fumble { border-color: var(--danger); }
.roll.fumble .roll-note, .roll.fumble .roll-head b { color: #e2766d; }
.roll .btn { margin-top: 6px; }
.tray-hint { font-size: 11px; color: var(--muted); margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1250px) {
  .sheet-layout { grid-template-columns: 1fr; }
  .dice-tray { position: fixed; right: 12px; bottom: 12px; top: auto; width: 290px; max-height: 55vh; z-index: 30;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
}
@media (max-width: 1100px) {
  .comp, .comp.wide-detail { grid-template-columns: 1fr; }
  .comp-list { position: static; max-height: 45vh; }
  .class-body, .equip-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .two-col, .two-col.spells, .sheet-cols { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; position: static; }
  main { padding: 18px 16px 40px; }
  .ab-row { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- print ---------- */
@media print {
  .no-print, .step-nav { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .sheet { box-shadow: none; border-radius: 0; padding: 0; background: #fff; }
  .ab, .stat { background: #fff; }
  .sheet-cols { grid-template-columns: 1fr 1.4fr; }
  .stat-row { grid-template-columns: repeat(8, 1fr); }
  .ab-row { grid-template-columns: repeat(6, 1fr); }
  .sheet-layout { display: block; }
  ul.checklist button.rollable, button.stat.rollable b { text-decoration: none; }
  .roll-btn { border: 0; background: none; padding: 0; }
}
