/* PDND · Illuminated rulebook · components.
   Load order: fonts.css -> tokens.css -> components.css. Uses tokens only (one exception: the sheet scrim).
   Shape rules: square corners (2px max), no pills, no glow, no gradients, no translucent tinted buttons.
   Gold = labels and structure plus the single primary action. Red = damage/danger only. Green = heal/advantage. */

/* ============ 1. Base ============ */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fw-regular) var(--fs-body)/var(--lh-body) var(--font-body);
  font-variant-numeric: lining-nums; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; border-radius: 0; }
:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }
p { margin: 0 0 var(--space-2); } p:last-child { margin-bottom: 0; }
b, strong { font-weight: var(--fw-semibold); }
.num, .tab-num { font-family: var(--font-num); font-feature-settings: var(--num-features); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: var(--app-max); margin: 0 auto; min-height: 100dvh; background: var(--surface);
  padding-bottom: calc(var(--tabbar-h) + var(--space-4) + env(safe-area-inset-bottom)); }
.app > main, .app main { padding: var(--space-4) var(--gutter) var(--space-6); display: block; }
@media (max-width: 379px) { :root { --gutter: 18px; } }
@media (min-width: 840px) {
  .app { max-width: var(--app-max-wide); }
  .app-head .strip { max-width: 560px; margin-left: auto; margin-right: auto; }
  .split { display: grid; grid-template-columns: 1fr 1fr; column-gap: 56px; align-items: start; }
  .split > * { min-width: 0; }
}

/* Cinzel label: the one small-caps voice for labels, buttons and headings */
.label, .lab, .cz {
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-label);
  letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--text-accent); line-height: 1.3;
}
.muted { color: var(--text-muted); } .faint { color: var(--text-faint); }
.hint, .tiny, .meta, .note { font-size: var(--fs-small); color: var(--text-muted); font-style: italic; line-height: 1.35; }
.hint.center { text-align: center; text-wrap: balance; }
.text-pos { color: var(--positive); } .text-warn { color: var(--warning); } .text-danger, .bad { color: var(--danger); } .text-info { color: var(--info); }

/* ============ 2. Ornaments ============ */
.sigil { display: block; width: 44px; height: 44px; color: var(--ornament); }
.knot-rule { display: flex; align-items: center; gap: var(--space-3); color: var(--ornament); margin: var(--space-5) 0 0; }
.knot-rule::before, .knot-rule::after { content: ""; flex: 1; height: 4px; border-top: 1px solid var(--ornament-dim); border-bottom: 1px solid var(--ornament-dim); }
.knot-rule svg { width: 44px; height: 14px; flex: none; }
/* tapered rule, CSS only (no image, no gradient): a clipped 5px bar */
.taper, hr.taper { display: block; height: 5px; border: 0; margin: var(--space-6) 0 0; background: var(--ornament);
  clip-path: polygon(0 50%, 50% 0, 100% 50%, 50% 100%); }
.fleuron { display: flex; justify-content: center; color: var(--ornament-dim); margin: var(--space-6) 0 0; }
.fleuron svg { width: 120px; height: 14px; }
.lz { display: inline-block; width: 7px; height: 7px; background: var(--ornament-dim); transform: rotate(45deg); flex: none; }

/* ============ 3. App header (sticky) ============ */
/* Two states, same DOM: condensed (default, all tabs) and .is-hero (Glance, scrolled to top).
   JS: header.classList.toggle('is-hero', tab === 'glance' && scrollY < 40). */
.app-head, .app > header {
  position: sticky; top: 0; z-index: 5; background: var(--bg); color: var(--text);
  padding: calc(var(--space-1) + env(safe-area-inset-top)) var(--gutter) 0;
  border-bottom: 3px double var(--ornament-dim);
}
.app-head .toprow { display: grid; grid-template-columns: auto 1fr auto auto; grid-template-areas: "sig name save out";
  align-items: center; column-gap: var(--space-2); min-height: var(--tap); }
.app-head .sigil { grid-area: sig; width: 22px; height: 22px; }
.app-head .kicker { grid-area: name; font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 17px;
  letter-spacing: var(--ls-display); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.app-head .savestate { grid-area: save; font-size: 15px; font-style: italic; color: var(--text-muted); white-space: nowrap; }
.app-head .savestate.offline, .app-head .savestate.error, .app-head .savestate.auth { color: var(--danger); font-style: normal; }
.app-head .toprow form, .app-head .toprow > .out { grid-area: out; margin: 0; }
.app-head .title-line, .app-head #titleLine { display: none; }
.app-head .knot-rule { display: none; }
.app-head.is-hero .toprow { grid-template-columns: 1fr auto auto; grid-template-areas: ". save out" "sig sig sig" "name name name"; }
.app-head.is-hero .sigil { justify-self: center; width: 40px; height: 40px; margin: var(--space-1) 0 var(--space-3); }
.app-head.is-hero .kicker { text-align: center; font-size: var(--fs-h1); white-space: normal; line-height: var(--lh-tight); }
.app-head.is-hero .title-line, .app-head.is-hero #titleLine { display: block; margin: 6px 0 0; text-align: center;
  font: italic var(--fw-regular) 19px/1.3 var(--font-body); color: var(--text-muted); letter-spacing: 0; }
.app-head.is-hero .knot-rule { display: flex; margin-top: var(--space-4); }

/* header counter boxes (old .strip): number over Cinzel label, lozenge separators, no boxes */
.strip { display: grid; grid-template-columns: repeat(4, 1fr); margin: var(--space-1) calc(-1 * var(--space-2)) 0; }
.strip button { position: relative; min-height: 58px; padding: 4px 2px 8px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; color: var(--text); background: none; border: 0; border-radius: 0; }
.strip button + button::before { content: ""; position: absolute; left: -3.5px; top: 40%; width: 7px; height: 7px;
  background: var(--ornament-dim); transform: rotate(45deg); }
.strip b { font-family: var(--font-num); font-weight: var(--fw-medium); font-size: 26px; line-height: 1; font-feature-settings: var(--num-features); }
.strip b small { font-size: 15px; color: var(--text-muted); font-weight: var(--fw-regular); }
.strip span { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-accent); }
.strip .ic { display: none; }                     /* old sprite icons inside the strip: dropped, type does the work */
.strip i.v { font-style: normal; }
.strip .is-bloodied b { color: var(--hp-bloodied); } .strip .is-critical b { color: var(--hp-critical); } .strip .is-down b { color: var(--hp-down); }
.strip button:active { background: var(--surface-hover); }

/* ============ 4. Section heading: Cinzel caps between tapered gold rules ============ */
.sec-head, .card > h3 {
  display: flex; align-items: center; gap: var(--space-3); margin: var(--space-6) 0 var(--space-3);
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-label); letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--text-accent); line-height: 1.2; white-space: nowrap;
}
.sec-head::before, .sec-head::after, .card > h3::before, .card > h3::after {
  content: ""; flex: 1; height: 3px; background: var(--ornament); min-width: 24px;
}
.sec-head::before, .card > h3::before { clip-path: polygon(0 50%, 100% 0, 100% 100%); }
.sec-head::after, .card > h3::after { clip-path: polygon(0 0, 100% 50%, 0 100%); }
.sec-head.left::before { display: none; } .sec-head.left { justify-content: flex-start; }
.sec-head .ic, .card > h3 .ic { width: 18px; height: 18px; color: var(--ornament); flex: none; margin: 0; }
.sec-head:first-child { margin-top: var(--space-2); }
.sec-meta { margin: calc(-1 * var(--space-2)) 0 var(--space-3); text-align: center; font-style: italic; font-size: var(--fs-small); color: var(--text-muted); }

/* ============ 5. Stat line: number over small-caps label, lozenge separators ============ */
.stat-line { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); margin: var(--space-4) calc(-1 * var(--space-2)) 0; }
.stat-line .stat { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  text-align: center; padding: var(--space-2) 2px; min-height: 76px; color: var(--text); }
.stat-line .stat + .stat::before { content: ""; position: absolute; left: -3.5px; top: 30px; width: 7px; height: 7px;
  background: var(--ornament-dim); transform: rotate(45deg); }
.stat-line b { font-family: var(--font-num); font-weight: var(--fw-medium); font-size: var(--fs-num); line-height: 1; font-feature-settings: "lnum" 1; }
.stat-line b small { font-size: 18px; font-style: italic; font-weight: var(--fw-regular); color: var(--text-muted); }
.stat-line .stat > span { margin-top: 7px; font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11px;
  letter-spacing: .12em; line-height: 1.3; text-transform: uppercase; color: var(--text-accent); }

/* ============ 6. Stat block: the six abilities + property lines ============ */
.stat-block { display: grid; grid-template-columns: repeat(6, 1fr); text-align: center; margin: var(--space-2) calc(-1 * var(--space-1)) 0; }
.stat-block .ab { display: flex; flex-direction: column; align-items: center; padding: var(--space-2) 0; min-height: var(--tap); color: var(--text); }
.stat-block .ab-k { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-label); letter-spacing: .12em; color: var(--text-accent); text-transform: uppercase; }
.stat-block .ab-mod { font-family: var(--font-num); font-weight: var(--fw-medium); font-size: var(--fs-num-lg); line-height: 1.15; margin-top: 2px; }
.stat-block .ab-score { font-size: 16px; color: var(--text-muted); font-feature-settings: var(--num-features); }

.props { margin-top: var(--space-3); }
.prop { margin: var(--space-2) 0 0; font-size: var(--fs-body); line-height: 1.45; }
.prop-k { font-weight: var(--fw-bold); font-style: italic; color: var(--text); margin-right: 4px; }
.prop .is-prof { color: var(--text-accent); font-weight: var(--fw-semibold); }
/* row form: label / value / action, 52px tall, hairline separated */
.prop-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1) var(--space-3); min-height: 54px;
  border-bottom: 1px solid var(--border-subtle); padding: 3px 0; }
.prop-row:first-child { border-top: 1px solid var(--border-subtle); }
.prop-row > .prop-k { width: 116px; flex: none; }
.prop-row > .prop-v { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 2px var(--space-2); }
.prop-row > .prop-a { margin-left: auto; }

/* drop cap: once per screen at most */
.drop-cap::first-letter { font-family: var(--font-display); font-weight: var(--fw-semibold); float: left; font-size: 74px;
  line-height: .78; color: var(--ornament); margin: 7px 10px 0 -2px; }
.rules-text { font-size: 19px; line-height: var(--lh-body); }
.rules-text em { color: var(--text-muted); }

/* ============ 7. Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--btn-h); padding: 0 var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; line-height: 1.1;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { background: var(--surface-raised); }
.btn svg, .btn .ic { width: 18px; height: 18px; flex: none; margin: 0; }
.btn-primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); }
.btn-primary:hover, .btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-primary:active, .btn.primary:active { background: var(--brand-pressed); border-color: var(--brand-pressed); }
.btn-secondary { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-danger { background: var(--danger-fill); border-color: var(--danger-fill); color: var(--text-on-danger); }
.btn-danger:hover { background: var(--danger-fill); filter: brightness(1.08); }
.btn-danger:active { background: var(--danger-fill-pressed); border-color: var(--danger-fill-pressed); }
.btn-heal { color: var(--positive); } .btn-temp { color: var(--info); }
.btn-quiet, .btn.ghost {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 var(--space-2); border: 0; background: none;
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-accent);
}
.btn-quiet:hover, .btn.ghost:hover { text-decoration: underline; text-underline-offset: 4px; background: none; }
.btn-block { width: 100%; }
.btn-sm { min-height: var(--tap); padding: 0 var(--space-3); font-size: 12px; }
.btn[disabled], .btn[aria-disabled="true"] { color: var(--text-faint); border-color: var(--border); background: transparent; cursor: not-allowed; }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* ============ 8. Diamonds: pips, death saves, inspiration, any on/off ============ */
/* <button class="dia" role="checkbox" aria-checked="true" aria-label="Ki point 1"></button> (44px target, ~18px mark) */
.dia, .pip { position: relative; display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  background: none; border: 0; border-radius: 0; vertical-align: middle; cursor: pointer; }
.dia::before, .pip::before { content: ""; width: 17px; height: 17px; transform: rotate(45deg); border: 1.5px solid var(--ornament); background: transparent; }
.dia[aria-checked="true"]::before, .dia.on::before, .pip.on::before { background: var(--ornament); }
.dia.lg::before { width: 22px; height: 22px; }
.dia.sm::before { width: 13px; height: 13px; border-color: var(--text-muted); }
.dia.pos::before { border-color: var(--positive); } .dia.pos[aria-checked="true"]::before { background: var(--positive); }
.dia.neg::before { border-color: var(--danger); }   .dia.neg[aria-checked="true"]::before { background: var(--danger); }
.dia-row { display: flex; align-items: center; flex-wrap: nowrap; }
.dia-row > small { font-style: italic; font-size: 15px; color: var(--text-muted); min-width: 72px; }
.dia-count { font-style: italic; color: var(--text-muted); font-size: var(--fs-small); margin-left: var(--space-2); }
/* text toggle with a diamond: Equipped / Attuned / Concentrating */
.tog { display: inline-flex; align-items: center; gap: 9px; min-height: var(--tap); padding: 0 var(--space-3) 0 var(--space-2);
  border: 1px solid var(--border-strong); background: transparent; color: var(--text-muted);
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; }
.tog::before { content: ""; width: 9px; height: 9px; transform: rotate(45deg); border: 1.5px solid currentColor; flex: none; }
.tog.on, .tog[aria-pressed="true"] { color: var(--text-accent); border-color: var(--ornament); background: var(--brand-soft); }
.tog.on::before, .tog[aria-pressed="true"]::before { background: currentColor; }

/* ============ 9. Conditions ============ */
.cond-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-2); }
.cond-list li { display: inline-flex; align-items: center; }
.cond { min-height: var(--tap); padding: 0 2px; font-size: 19px; color: var(--text); text-decoration: underline dotted var(--text-faint);
  text-decoration-thickness: 1.5px; text-underline-offset: 5px; }
.cond-x { width: var(--tap); height: var(--tap); display: grid; place-items: center; color: var(--danger); font-size: 22px; margin-left: -8px; }
.cond-none { font-style: italic; color: var(--text-muted); }
.cond-effect { flex-basis: 100%; margin: -4px 0 6px; font-size: 15.5px; font-style: italic; color: var(--danger); }

/* ============ 10. HP block ============ */
.hp-block { --hp-color: var(--hp-healthy); }
.hp-block[data-state="bloodied"] { --hp-color: var(--hp-bloodied); }
.hp-block[data-state="critical"] { --hp-color: var(--hp-critical); }
.hp-block[data-state="down"] { --hp-color: var(--hp-down); }
.hp-nums { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; }
.hp-side { font-size: 16.5px; font-style: italic; color: var(--text-muted); padding-bottom: 14px; line-height: 1.25; }
.hp-side.r { text-align: right; }
.hp-side b { display: block; font-style: normal; font-weight: var(--fw-medium); font-size: 28px; color: var(--text); line-height: 1.05; font-feature-settings: "lnum" 1; }
.hp-side.temp b { color: var(--temp-hp); }
.hp-cur { font-family: var(--font-num); font-size: var(--fs-num-xl); line-height: .95; font-weight: var(--fw-medium); text-align: center; padding: 0 var(--space-3); color: var(--text); font-feature-settings: "lnum" 1; }
.hp-bar { position: relative; height: 12px; margin: var(--space-2) 0 0; }
.hp-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 5px; border-top: 1px solid var(--ornament-dim); }
.hp-bar i { position: absolute; left: 0; top: 4px; height: 3px; width: var(--hp, 100%); background: var(--hp-color); }
.hp-bar b { position: absolute; left: var(--hp, 100%); top: 1px; width: 9px; height: 9px; margin-left: -4.5px; background: var(--hp-color); transform: rotate(45deg); }
.hp-bar .t { position: absolute; top: 4px; height: 3px; left: var(--hp); width: var(--temp, 0%); background: var(--temp-hp); }
.hp-state { text-align: center; font-style: italic; color: var(--hp-color); font-size: 17px; margin-top: 6px; min-height: 1.3em; }
.hp-act { display: grid; grid-template-columns: 64px 1fr 1fr 1fr; gap: var(--space-2); margin-top: var(--space-3); }
.hp-act .btn { padding: 0 6px; min-width: 0; }
.hp-act .amt { height: var(--btn-h); }

/* ============ 11. Inputs ============ */
.field, input.n, select.n, textarea {
  min-height: var(--btn-h); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-sunken);
  color: var(--text); padding: 0 var(--space-3); font-family: var(--font-body); font-size: 19px;
}
.field:focus, input.n:focus, select.n:focus, textarea:focus { outline: var(--focus-outline); outline-offset: 0; border-color: var(--ornament); }
.field::placeholder, textarea::placeholder { color: var(--text-faint); font-style: italic; }
.field.amt, input.n { width: 64px; text-align: center; font-size: 26px; font-weight: var(--fw-medium); padding: 0; font-feature-settings: var(--num-features); }
.field.wide, .field[type="text"], .field[type="password"], .field[type="search"] { width: 100%; text-align: left; font-size: 19px; }
textarea { width: 100%; min-height: 120px; padding: var(--space-3); line-height: var(--lh-body); }
.field-label { display: block; margin: var(--space-4) 0 6px; }
.qty { display: inline-grid; grid-template-columns: var(--tap) 40px var(--tap); align-items: center; border: 1px solid var(--border-strong); height: var(--tap); }
.qty button { height: 42px; display: grid; place-items: center; color: var(--text-accent); font-size: 22px; line-height: 1; }
.qty button:active { background: var(--surface-hover); }
.qty b { text-align: center; font-weight: var(--fw-medium); font-size: 20px; font-feature-settings: var(--num-features); border-left: 1px solid var(--border); border-right: 1px solid var(--border); line-height: 42px; }
.searchbox { position: relative; }
.searchbox .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-faint); pointer-events: none; }
.searchbox input { padding-left: 40px !important; }

/* segmented choice (roll mode) */
.seg { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); border: 1px solid var(--border-strong); }
.seg button { min-height: var(--btn-h); display: grid; place-items: center; color: var(--text-muted); padding: 0 4px;
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--text-accent); box-shadow: inset 0 0 0 1px var(--ornament); }
.seg button[aria-pressed="true"].dis { color: var(--danger); background: var(--danger-bg); box-shadow: inset 0 0 0 1px var(--danger); }
.seg button[aria-pressed="true"].adv { color: var(--positive); background: var(--positive-bg); box-shadow: inset 0 0 0 1px var(--positive); }
.seg-note { margin-top: 6px; font-size: 16px; font-style: italic; color: var(--text-muted); text-align: center; }
.seg-note b { color: var(--danger); font-weight: var(--fw-semibold); }

/* ============ 12. Combat ============ */
.attack { padding: var(--space-1) 0 0; }
.atk-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.atk-name { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-h2); letter-spacing: .03em; color: var(--text); }
.atk-kind { font-style: italic; font-size: 16px; color: var(--text-muted); white-space: nowrap; }
.atk-meta { margin: 2px 0 0; font-size: 17.5px; color: var(--text-muted); }
.atk-meta b { color: var(--text); font-weight: var(--fw-semibold); }
.atk-acts { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--space-2); margin-top: var(--space-3); }
.roll-log { margin-top: var(--space-3); background: var(--surface-sunken); border: 1px solid var(--border); border-left: 2px solid var(--ornament);
  padding: 10px var(--space-3); font-size: 18px; font-feature-settings: var(--num-features); min-height: var(--tap); display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; }
.roll-log .lab { flex-basis: 100%; margin: 0 0 2px; }
.roll-log .die { font-weight: var(--fw-semibold); }
.roll-log .drop { color: var(--text-faint); text-decoration: line-through; }
.roll-log .res { font-size: 26px; font-weight: var(--fw-semibold); color: var(--text); margin-left: 2px; line-height: 1; }
.roll-log .dis { color: var(--danger); font-style: italic; font-size: 16px; }
.atk-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.atk-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: var(--space-3); min-height: 56px; border-bottom: 1px solid var(--border-subtle); }
.atk-row:first-child { border-top: 1px solid var(--border-subtle); }
.atk-row .nm { font-size: 19px; line-height: 1.2; } .atk-row .nm small { display: block; font-size: 15px; font-style: italic; color: var(--text-muted); }
.atk-row .hit { font-size: 20px; font-weight: var(--fw-semibold); font-feature-settings: var(--num-features); }
.act-list { list-style: none; margin: 0; padding: 0; }
.act-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px var(--space-3); padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.act-item:first-child { border-top: 1px solid var(--border-subtle); }
.act-item .nm { font-weight: var(--fw-bold); font-style: italic; font-size: 19px; }
.act-item .cost { font-family: var(--font-display); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-accent); margin-left: 6px; font-style: normal; font-weight: var(--fw-semibold); }
.act-item p { grid-column: 1; margin: 0; font-size: 16.5px; color: var(--text-muted); line-height: 1.35; }
.act-item .btn { grid-row: 1 / span 2; grid-column: 2; }
.conc { display: flex; align-items: center; gap: var(--space-2); min-height: 56px; }
.conc .what { flex: 1; font-size: 18px; } .conc .what small { display: block; font-size: 15px; font-style: italic; color: var(--text-muted); }

/* ============ 13. Inventory ============ */
.load { margin-top: var(--space-2); }
.load-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 17px; color: var(--text-muted); }
.load-line b { color: var(--text); font-size: 22px; font-weight: var(--fw-medium); font-feature-settings: var(--num-features); }
.load .hp-bar { --hp-color: var(--ornament); margin-top: 4px; }
.purse { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-2); margin-top: var(--space-2); }
.purse label { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.purse .field { width: 100%; padding: 0 2px; text-align: center; font-size: 22px; font-weight: var(--fw-medium); font-feature-settings: var(--num-features); }
.purse label.has .field { border-color: var(--ornament); color: var(--text); }
.attune { display: flex; align-items: center; gap: 0; margin-top: var(--space-1); }
.attune .lbl { flex: 1; font-size: 18px; } .attune .lbl small { display: block; font-size: 15px; font-style: italic; color: var(--text-muted); }
.group-head { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-6) 0 0; padding-bottom: 6px; border-bottom: 1px solid var(--ornament-dim); }
.group-head .ic { width: 20px; height: 20px; color: var(--ornament); flex: none; }
.group-head h3 { margin: 0; flex: 1; font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-accent); }
.group-head small { font-style: italic; font-size: 15px; color: var(--text-muted); }
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list .item { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--space-3); align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.item-name { font-size: 19.5px; line-height: 1.2; color: var(--text); }
.item-name .tag { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-accent); margin-left: 6px; }
.item-meta { display: block; text-wrap: pretty; font-size: 15.5px; font-style: italic; color: var(--text-muted); margin-top: 2px; }
.qty-col { display: flex; flex-direction: column; align-items: center; gap: 3px; align-self: start; }
.qty-col small { font-size: 14.5px; font-style: italic; color: var(--text-muted); }
.item-acts { grid-column: 1 / -1; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.item-list .item.off .item-name { color: var(--text-muted); }
.more-row { display: flex; justify-content: center; margin-top: var(--space-1); }

/* ============ 14. Tab bar ============ */
.tabbar, .app > nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 6; width: min(var(--app-max), 100%);
  display: grid; grid-template-columns: repeat(6, 1fr); background: var(--bg);
  border-top: 3px double var(--ornament-dim); padding: 0 2px env(safe-area-inset-bottom);
}
@media (min-width: 840px) { .tabbar, .app > nav { width: min(var(--app-max-wide), 100%); } }
.tabbar button, .app > nav button { position: relative; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: none; border: 0; color: var(--text-muted);
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.tabbar button.on, .app > nav button.on, .tabbar button[aria-current="page"] { color: var(--text-accent); font-weight: var(--fw-bold); }
.tabbar button.on::before, .app > nav button.on::before { content: ""; position: absolute; top: 9px; left: 50%; width: 6px; height: 6px; margin-left: -3px;
  background: var(--ornament); transform: rotate(45deg); border-radius: 0; right: auto; }
.tabbar .tabic, .app > nav .tabic { display: none; }                 /* default: type only */
.tabbar.with-icons .tabic { display: block; width: 22px; height: 22px; } /* option: icons back, stroke 1.5 */
.tabbar.with-icons button.on::before { top: 3px; }

/* narrow phones (< 380px): tighten the widest rows */
@media (max-width: 379px) {
  .prop-row > .prop-k { width: 96px; }
  .dia-row > small { min-width: 62px; }
  .tabbar button, .app > nav button { font-size: 10px; letter-spacing: .05em; }
  .stat-line .stat > span, .strip span { letter-spacing: .08em; }
}

/* ============ 15. Toast ============ */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: min(400px, calc(100vw - 32px)); background: var(--surface-raised); color: var(--text); border: 1px solid var(--border-strong);
  border-top: 2px solid var(--ornament); padding: 10px var(--space-4); font-size: 18px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s; border-radius: 0; }
.toast.on { opacity: 1; }
.toast.bad { border-top-color: var(--danger); } .toast.good { border-top-color: var(--positive); }

/* ============ 16. Tooltip popover (.tip), maths, info badge, bottom sheet. Same classes as tooltips/tooltip.css ============ */
:root { --tip-w: min(320px, calc(100vw - 24px)); --tip-max-h: 45vh; --tip-gap: 10px; --tip-edge: 8px; --tip-bg: var(--surface-raised); }
.tip { position: fixed; z-index: 30; top: 0; left: 0; width: var(--tip-w); max-height: var(--tip-max-h); display: flex; flex-direction: column;
  background: var(--tip-bg); color: var(--text); border: 1px solid var(--border-strong); border-top: 2px solid var(--ornament); border-radius: 0;
  box-shadow: var(--shadow-pop); font-family: var(--font-body); font-size: var(--fs-body); line-height: 1.38;
  transform-origin: var(--arrow-x, 50%) top; animation: tip-in 120ms ease-out; }
.tip[data-side="top"] { transform-origin: var(--arrow-x, 50%) bottom; border-top: 1px solid var(--border-strong); border-bottom: 2px solid var(--ornament); }
.tip[hidden] { display: none; }
.tip-body { padding: var(--space-3) var(--space-4) var(--space-3); overflow-y: auto; overscroll-behavior: contain; }
.tip::before { content: ""; position: absolute; left: calc(var(--arrow-x, 50%) - 6px); top: -8px; width: 11px; height: 11px;
  background: var(--ornament); transform: rotate(45deg); }          /* the pointer is a gold lozenge */
.tip[data-side="top"]::before { top: auto; bottom: -8px; }
.tip-head, .sheet-head { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
.tip-head svg { display: none; }                                     /* icons dropped in heads: the name does the work */
.tip-name, .sheet-name { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 17px; letter-spacing: .04em; line-height: 1.2;
  color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.src-tag { flex: 0 0 auto; font-size: 14.5px; font-style: italic; color: var(--text-faint); white-space: nowrap; border: 0; padding: 0; background: none; }
.src-tag.pos { color: var(--positive); }
.tip-sum { margin: 6px 0 0; font-size: var(--fs-body); color: var(--text); }
.tip-hint { display: flex; align-items: center; gap: 6px; margin: var(--space-2) 0 0; font-size: 15.5px; font-style: italic; color: var(--text-muted); }
.tip-hint svg { width: 16px; height: 16px; color: var(--ornament); }
.tip-kv { display: grid; grid-template-columns: repeat(4, auto); gap: 2px var(--space-4); justify-content: start; margin: var(--space-2) 0 0; }
.tip-kv div { display: grid; }
.tip-kv dt { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-accent); }
.tip-kv dd { margin: 0; font-size: 20px; font-weight: var(--fw-medium); color: var(--text); font-feature-settings: var(--num-features); }

/* maths: typeset as an equation. Parts unboxed, the total in a gold square */
.tip-nums { margin-top: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--border); display: grid; gap: var(--space-3); }
.calc { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 6px; }
.calc-res { display: inline-flex; align-items: flex-start; gap: 6px; }
.calc-label { width: 100%; font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-accent); }
.part, .total { display: inline-grid; justify-items: center; align-content: start; min-width: 34px; padding: 2px 2px 0; background: none; border: 0; border-radius: 0; }
.part b, .total b { font-family: var(--font-num); font-weight: var(--fw-medium); font-size: 26px; line-height: 1.05; font-feature-settings: var(--num-features); }
.part small, .total small { font-size: 13.5px; font-style: italic; color: var(--text-muted); line-height: 1.15; text-align: center; max-width: 84px; }
.part.neg b { color: var(--danger); }
.part.zero b, .part.zero small { color: var(--text-faint); }
.op { font-family: var(--font-num); font-size: 22px; line-height: 1.25; color: var(--ornament); padding: 2px 0 0; }
.op.eq { color: var(--ornament); }
.total { border: 1px solid var(--ornament); padding: 2px 8px 3px; min-width: 52px; }
.total b { color: var(--text); font-size: 28px; }
.total small { color: var(--text-accent); font-style: normal; font-family: var(--font-display); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.calc-note { flex-basis: 100%; display: flex; align-items: center; gap: 8px; font-size: 16px; font-style: italic; border: 0; padding: 0; background: none; }
.calc-note::before { content: ""; width: 7px; height: 7px; transform: rotate(45deg); background: currentColor; flex: none; }
.calc-note svg { display: none; }
.calc-note.dis { color: var(--danger); } .calc-note.adv { color: var(--positive); } .calc-note.warn { color: var(--warning); }

.tip-more { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: var(--tap); width: 100%;
  padding: 0 var(--space-4); border: 0; border-top: 1px solid var(--border); background: transparent; border-radius: 0; cursor: pointer; text-align: left; flex: 0 0 auto;
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-accent); }
.tip-more::after { content: ""; width: 7px; height: 7px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg); }
.tip-more:active { background: var(--surface-hover); }

/* info badge: an italic "i" in a small outlined lozenge; 44px hit area */
.has-info { position: relative; }
.has-info.badge-pad { padding-right: 36px; }
.info-badge { position: absolute; top: 50%; right: 0; transform: translateY(-50%); width: var(--tap); height: var(--tap); padding: 0; margin: 0;
  border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text-muted); z-index: 1; }
.info-badge.corner { top: -6px; right: -6px; transform: none; }
.info-badge > span { position: relative; width: 18px; height: 18px; display: grid; place-items: center; background: none; box-shadow: none; border-radius: 0;
  font: italic var(--fw-semibold) 14px/1 var(--font-body); color: currentColor; }
.info-badge > span::before { content: ""; position: absolute; inset: 2px; border: 1px solid currentColor; transform: rotate(45deg); }
.info-badge svg { display: none; }
.info-badge > span::after { content: "i"; position: relative; }
.btn-primary .info-badge, .btn.primary .info-badge, .tog.on .info-badge, .is-brand .info-badge { color: var(--text-on-brand); }
.btn-danger .info-badge { color: var(--text-on-danger); }
.is-pos .info-badge { color: var(--positive); } .is-warn .info-badge { color: var(--warning); }
.info-badge:hover > span::before, .info-badge[aria-expanded="true"] > span::before { background: var(--surface-hover); border-color: var(--ornament); }
.info-badge:focus-visible { outline: 0; } .info-badge:focus-visible > span { outline: var(--focus-outline); outline-offset: 4px; }
.info-wrap { position: relative; display: inline-flex; }
.info-wrap > :first-child { padding-right: 40px; }
.info-wrap > .info-badge { right: -2px; }
.info-wrap > .btn-primary + .info-badge { color: var(--text-on-brand); }
.info-wrap > .btn-danger + .info-badge { color: var(--text-on-danger); }

/* display-only info targets */
[data-info].is-info-text { text-decoration: underline dotted var(--text-faint); text-decoration-thickness: 1.5px; text-underline-offset: 5px; cursor: help; }
[data-info].is-info-tile { cursor: help; }
[data-info][aria-expanded="true"] { outline: 1px solid var(--ornament); outline-offset: 2px; }
[data-info].is-info-text[aria-expanded="true"] { outline: 0; text-decoration: underline solid var(--ornament); }

/* bottom sheet: existing #pop / .pop .sheet */
.pop { position: fixed; inset: 0; z-index: 40; display: none; align-items: flex-end; justify-content: center; background: var(--scrim); padding: 0; }
.pop.on { display: flex; animation: scrim-in 180ms ease-out; }
.pop .sheet { width: min(var(--app-max), 100%); max-height: calc(88dvh - env(safe-area-inset-top)); overflow: auto; overscroll-behavior: contain;
  background: var(--surface-raised); color: var(--text); border: 0; border-top: 3px double var(--ornament); border-radius: 0; box-shadow: none;
  padding: var(--space-2) var(--gutter) calc(var(--space-5) + env(safe-area-inset-bottom)); animation: sheet-in 180ms cubic-bezier(.2, .8, .2, 1); }
.sheet-grab { display: block; width: 36px; height: 3px; background: var(--ornament-dim); margin: 2px auto var(--space-2); border-radius: 0; }
.sheet-head { position: sticky; top: calc(-1 * var(--space-2)); background: var(--surface-raised); padding: var(--space-2) 0 var(--space-3);
  margin-bottom: var(--space-1); border-bottom: 1px solid var(--border); z-index: 1; align-items: center; }
.sheet-head svg { display: none; }
.sheet-name { font-size: var(--fs-h2); }
.sheet-sub { display: block; font-style: italic; font-size: 15px; color: var(--text-faint); margin-top: 2px; letter-spacing: 0; font-family: var(--font-body); font-weight: 400; text-transform: none; }
#popClose { width: var(--tap); height: var(--tap); margin-right: -10px; border: 0; background: transparent; color: var(--text-muted); display: grid; place-items: center; flex: 0 0 auto; font-size: 26px; line-height: 1; }
#popClose svg { display: block; width: 22px; height: 22px; }
#popBody { font-size: var(--fs-body-lg); line-height: 1.42; }
#popBody p { margin: var(--space-3) 0 0; }
#popBody h3 { margin: var(--space-5) 0 var(--space-2); display: flex; align-items: center; gap: var(--space-3);
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--text-accent); }
#popBody h3::after { content: ""; flex: 1; height: 3px; background: var(--ornament); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.fx { list-style: none; margin: 0; padding: 0; }
.fx li { display: flex; gap: var(--space-3); align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); background: none; border-radius: 0; }
.fx li:first-child { border-top: 1px solid var(--border-subtle); }
.fx li::before { content: ""; width: 8px; height: 8px; margin-top: 10px; transform: rotate(45deg); background: var(--text-faint); flex: none; }
.fx li.dis::before { background: var(--danger); } .fx li.pos::before { background: var(--positive); } .fx li.warn::before { background: var(--warning); }
.fx li svg { display: none; }
.fx li span { flex: 1; } .fx li small { display: block; font-size: 16px; color: var(--text-muted); font-style: italic; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-5); }
.sheet-attrib { margin-top: var(--space-4); font-size: 14px; font-style: italic; color: var(--text-faint); }

@keyframes tip-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes scrim-in { from { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .tip, .pop.on, .pop .sheet, .toast { animation: none; transition: none; } }

/* ============ 17. Auth pages (login, change password) ============ */
.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: var(--space-6) var(--gutter); max-width: 420px; margin: 0 auto; }
.auth .sigil { width: 64px; height: 64px; margin: 0 auto var(--space-4); }
.auth h1 { margin: 0; text-align: center; font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 34px; letter-spacing: .06em; color: var(--text); }
.auth .field { width: 100%; }
.auth .lede { text-wrap: balance; text-align: center; font-style: italic; color: var(--text-muted); font-size: 19px; margin: 6px 0 0; }
.auth form { margin-top: var(--space-5); }
.auth label { display: block; margin-top: var(--space-4); }
.auth label > span { display: block; margin-bottom: 6px; }
.auth .btn-primary { width: 100%; margin-top: var(--space-5); }
.auth .names { margin-top: var(--space-5); text-align: center; font-style: italic; color: var(--text-faint); font-size: 16px; }
.auth .bad { margin-top: var(--space-4); padding: 10px var(--space-3); border-left: 2px solid var(--danger); background: var(--danger-bg); color: var(--text); font-size: 17px; }

/* ============ 18. Legacy bridge: old sheet.html classes, so PR A can land before the markup changes ============ */
.card { background: none; border: 0; border-radius: 0; padding: 0; margin: 0 0 var(--space-5); }
.card.warn { background: none; border: 0; }
.num { font-family: var(--font-num); font-size: 32px; font-weight: var(--fw-medium); color: var(--text); line-height: 1.1; }
.stat { text-align: center; }
.good { color: var(--text); font-style: italic; font-weight: 400; }       /* trait line: was red despite the name */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3) var(--space-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.skill, .item { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; min-height: 48px; padding: 4px 0; border-bottom: 1px solid var(--border-subtle); font-size: 18px; }
.dot { width: 9px; height: 9px; transform: rotate(45deg); border: 1.5px solid var(--text-faint); display: inline-block; margin-right: 10px; border-radius: 0; background: none; }
.prof { background: none; padding-left: 0; } .prof .dot { background: var(--ornament); border-color: var(--ornament); }
.log { font-family: var(--font-body); font-size: 18px; background: var(--surface-sunken); color: var(--text); border: 1px solid var(--border); border-left: 2px solid var(--ornament); border-radius: 0; padding: 10px 12px; min-height: 44px; font-feature-settings: var(--num-features); }
.chips { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: 4px; }
.chips button { flex: 0 0 auto; min-height: var(--tap); border-radius: 0; border: 1px solid var(--border-strong); background: transparent; color: var(--text-muted); padding: 0 var(--space-3);
  font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; }
.chips button.on { background: var(--brand-soft); color: var(--text-accent); border-color: var(--ornament); }
.advice { background: none; border: 0; border-left: 2px solid var(--ornament); padding-left: var(--space-4); }
.advice h3 { color: var(--text-accent); } .advice p, .advice li { color: var(--text); font-size: 19px; font-weight: 400; }
.step b { background: none; color: var(--text-accent); border: 1px solid var(--ornament); border-radius: 0; font-family: var(--font-display); }
.ic { width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; flex: none; }
.lab .ic { display: none; }
