/* Quillsheet: dark sheet with crimson accents. Everything is local so it works offline. */
:root {
    --bg: #121015;
    --bg-art: radial-gradient(1200px 600px at 70% -10%, #2b2230 0%, transparent 60%), radial-gradient(900px 500px at 0% 100%, #22161a 0%, transparent 55%);
    --panel: #1d1a21;
    --panel-2: #26222b;
    --line: #a3202b;
    --line-soft: #4a3a44;
    --accent: #c8323d;
    --accent-2: #e04b55;
    --gold: #d6a84e;
    --text: #efe8dd;
    --muted: #a59b92;
    --good: #46b26b;
    --bad: #e05561;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-cond: "Roboto Condensed", "Arial Narrow", "Segoe UI", system-ui, sans-serif;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    background-image: var(--bg-art);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--accent-2); }
h1, h2, h3, h4 { font-family: var(--font-cond); margin: 0 0 .4em; letter-spacing: .01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
button { font: inherit; color: inherit; }
input, select, textarea {
    font: inherit;
    color: var(--text);
    background: #141217;
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    padding: .4rem .5rem;
    min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
textarea { width: 100%; resize: vertical; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.hidden-input { display: none; }
.error { background: #3a1418; border: 1px solid var(--bad); color: #ffd6d9; padding: .6rem .8rem; border-radius: 8px; margin: .6rem 0; }

/* ----- Buttons ----- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .5rem .9rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text);
    font-family: var(--font-cond);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: .82rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: #33293a; }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn.accent:hover { background: var(--accent-2); }
.btn.small { padding: .3rem .6rem; font-size: .75rem; }
.btn.block { width: 100%; margin-top: .6rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.heal { border-color: var(--good); color: #9fe0b4; }
.btn.damage { border-color: var(--bad); color: #ffb3b9; }
.link { background: none; border: none; color: var(--accent-2); cursor: pointer; padding: 0 .2rem; text-decoration: underline; }
.link.danger { color: var(--bad); }
.chip {
    border: 1px solid var(--line-soft); background: var(--panel-2); border-radius: 999px;
    padding: .2rem .7rem; font-size: .8rem; cursor: pointer; font-family: var(--font-cond); font-weight: 700; text-transform: uppercase;
}
.chip.on { background: var(--accent); border-color: var(--accent); }
.chip-x { background: none; border: none; cursor: pointer; padding: 0 0 0 .3rem; font-size: 1rem; line-height: 1; }

/* ----- Shell ----- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top));
    background: #0c0b0e; border-bottom: 1px solid #2a2330;
    position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-family: var(--font-cond); font-weight: 800; font-size: 1.2rem; letter-spacing: .04em; text-transform: uppercase; }
.brand svg { width: 26px; height: 26px; color: var(--accent); }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { color: var(--muted); text-decoration: none; font-family: var(--font-cond); font-weight: 700; text-transform: uppercase; font-size: .85rem; white-space: nowrap; }
.topbar nav a:hover { color: var(--text); }
.topbar nav { align-items: center; }
.icon-btn { background: none; border: 0; padding: .15rem; color: var(--muted); cursor: pointer; display: inline-flex; }
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.banner { background: #2b2210; border-bottom: 1px solid var(--gold); padding: .5rem 1rem; display: flex; gap: .8rem; align-items: center; justify-content: center; }
.content { max-width: 1400px; margin: 0 auto; padding: 1rem 16px 6rem; }

.page-head { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions.bottom { margin-top: 1rem; }
.footnote { margin-top: 2rem; }
.prose { max-width: 70ch; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .3rem; }

/* ----- Character list ----- */
.character-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.character-list li { display: flex; align-items: center; gap: .5rem; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: .6rem .8rem; }
.character-card { flex: 1; display: flex; gap: .8rem; align-items: center; color: var(--text); text-decoration: none; }
.character-card strong { display: block; font-size: 1.1rem; }
.initial, .portrait {
    width: 48px; height: 48px; flex: none; border-radius: 8px; display: grid; place-items: center;
    background: linear-gradient(135deg, #3b1c22, #1b1418); border: 2px solid var(--line); font-family: var(--font-cond); font-weight: 800; font-size: 1.4rem; color: var(--gold);
}
.empty { text-align: center; padding: 3rem 1rem; background: var(--panel); border: 1px dashed var(--line-soft); border-radius: var(--radius); }

/* ----- Boxes ----- */
.box {
    position: relative;
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: var(--radius);
    padding: .7rem .8rem 1.6rem;
    box-shadow: inset 0 0 0 1px #00000060, 0 2px 10px #0006;
}
.box-title {
    position: absolute; left: 0; right: 0; bottom: .35rem; text-align: center;
    font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .78rem; letter-spacing: .05em;
}
.box-title.top { position: static; margin-bottom: .1rem; font-size: .72rem; }
.mini-title { font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; margin-bottom: .2rem; }
.small-note { color: var(--muted); font-size: .82rem; margin: .5rem 0 0; }
.big { font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.big small { font-size: .9rem; color: var(--muted); }
.pill {
    display: inline-grid; place-items: center; min-width: 2.6rem; padding: .1rem .4rem;
    border: 1px solid var(--line-soft); border-radius: 6px; background: #141217; font-weight: 600;
}
.pill.big { font-size: 1.15rem; min-width: 2.4rem; }
.flag { font-weight: 800; font-family: var(--font-cond); text-transform: uppercase; }
.flag.good { color: var(--good); }
.flag.bad { color: var(--bad); }

/* ----- Sheet header ----- */
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.sheet-head .portrait { width: 64px; height: 64px; font-size: 2rem; }
.identity { flex: 1; min-width: 200px; }
.identity h1 { margin: 0; font-size: 1.9rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ----- Top row ----- */
.top-row { display: grid; gap: .6rem; grid-template-columns: minmax(0, 6fr) repeat(3, minmax(84px, .8fr)) minmax(250px, 2.4fr); align-items: stretch; margin-bottom: .8rem; }
.abilities { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; }
.ability {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
    background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: .4rem .2rem 1.4rem; cursor: pointer;
    box-shadow: 0 2px 10px #0006;
}
.ability:hover, .save:hover, .skill:hover, .stat.initiative:hover { background: #2b2230; }
.ability-name { font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .66rem; letter-spacing: .03em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ability-mod { font-size: 1.8rem; font-weight: 600; border: 1px solid var(--line-soft); border-radius: 6px; padding: 0 .5rem; margin: .15rem 0; background: #141217; min-width: 3.2rem; text-align: center; }
.ability-score { position: absolute; bottom: -.7rem; background: var(--panel); border: 2px solid var(--line); border-radius: 999px; padding: 0 .6rem; font-weight: 700; }
.stat { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: .5rem .4rem 1.6rem; }
button.stat { cursor: pointer; color: var(--text); font: inherit; }
.inspiration .insp-mark { font-size: 2rem; color: var(--gold); min-height: 2.4rem; }
.inspiration.on { box-shadow: 0 0 18px #d6a84e55; }

/* HP */
.hp { display: flex; flex-direction: column; gap: .4rem; }
.hp-controls { display: flex; gap: .3rem; align-items: center; }
.hp-controls input { width: 4.2rem; text-align: center; }
.hp-values { display: flex; align-items: flex-end; gap: .5rem; justify-content: center; text-align: center; }
.hp-values label { display: block; font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .7rem; color: var(--muted); }
.hp-values .big { font-size: 2.1rem; }
.hp-values .big.down { color: var(--bad); }
.hp-values .slash { font-size: 1.6rem; color: var(--muted); padding-bottom: .2rem; }
.hp-values .temp input { width: 3.6rem; text-align: center; font-size: 1.2rem; }
.death-saves { border-top: 1px solid var(--line-soft); padding-top: .4rem; display: grid; gap: .3rem; justify-items: center; }
.ds-row { display: flex; gap: .6rem; align-items: center; font-size: .8rem; font-family: var(--font-cond); text-transform: uppercase; font-weight: 700; }
.pips { display: inline-flex; gap: .25rem; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-soft); }
.pip.good { background: var(--good); border-color: var(--good); }
.pip.bad { background: var(--bad); border-color: var(--bad); }

/* ----- Main grid ----- */
.main-grid { display: grid; gap: .8rem; grid-template-columns: minmax(250px, 1fr) minmax(270px, 1.05fr) minmax(0, 2.6fr); align-items: start; }
.col-left, .col-mid, .col-right { display: grid; gap: .8rem; min-width: 0; }

.save-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.save, .skill { display: flex; align-items: center; gap: .45rem; background: none; border: none; cursor: pointer; padding: .25rem .3rem; border-radius: 6px; text-align: left; }
.save { border: 1px solid var(--line-soft); }
.save-name { flex: 1; font-family: var(--font-cond); font-weight: 800; }
.prof-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; }
.prof-dot.on { background: var(--text); border-color: var(--text); }
.prof-dot.expertise { box-shadow: 0 0 0 2.5px var(--panel), 0 0 0 4px var(--text); }
.prof-dot.half { background: linear-gradient(90deg, var(--text) 50%, transparent 50%); }
.passive { display: flex; gap: .6rem; align-items: center; margin-bottom: .35rem; font-family: var(--font-cond); font-weight: 700; text-transform: uppercase; font-size: .8rem; }
.profs dl { margin: 0; }
.profs dt { font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; color: var(--muted); font-size: .8rem; margin-top: .4rem; }
.profs dd { margin: 0 0 .3rem; border-bottom: 1px solid var(--line-soft); padding-bottom: .4rem; }

.skills { padding-top: .5rem; }
.skill-head { display: grid; grid-template-columns: 2.2rem 2.6rem 1fr auto; font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .68rem; color: var(--muted); padding: 0 .3rem .3rem; }
.skill { display: grid; grid-template-columns: 2.2rem 2.6rem 1fr auto; width: 100%; border-bottom: 1px solid #ffffff10; border-radius: 0; }
.skill .prof-dot { justify-self: center; }
.skill-mod { color: var(--muted); font-size: .75rem; font-weight: 700; }

/* Combat strip */
.combat-strip { display: grid; grid-template-columns: 110px 110px minmax(0, 1fr); gap: .6rem; }
.ac { padding: 0; display: grid; place-items: center; }
.ac .shield { position: absolute; width: 72px; height: 84px; fill: #141217; stroke: var(--line); stroke-width: 3; }
.ac-inner { position: relative; display: flex; flex-direction: column; align-items: center; line-height: 1; padding: .6rem 0; }
.ac-inner small { font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .62rem; }
.defenses { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding-bottom: .7rem; }
.def-col + .def-col { border-left: 1px solid var(--line-soft); padding-left: .6rem; }
.conditions { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.add-condition { padding: .15rem .3rem; font-size: .8rem; }

/* Tabs */
.tabs-box { padding: 0; min-width: 0; }
.tabs { display: flex; gap: .2rem; overflow-x: auto; border-bottom: 1px solid var(--line-soft); padding: .4rem .5rem 0; scrollbar-width: none; }
.tabs button { background: none; border: none; border-bottom: 3px solid transparent; padding: .5rem .6rem; font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .85rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding: .8rem; max-height: none; }
.filters { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.section-title { color: var(--accent-2); text-transform: uppercase; font-size: .95rem; margin: 1rem 0 .4rem; border-bottom: 1px solid var(--line-soft); padding-bottom: .2rem; }
.section-title small { color: var(--text); text-transform: none; font-weight: 400; }

.attacks, .inventory { width: 100%; border-collapse: collapse; }
.attacks th, .inventory th { text-align: left; font-family: var(--font-cond); text-transform: uppercase; font-size: .72rem; color: var(--muted); padding: .2rem .3rem; }
.attacks td, .inventory td { padding: .4rem .3rem; border-top: 1px solid #ffffff12; vertical-align: middle; }
.atk-name { font-weight: 600; }
.roll-btn {
    background: #141217; border: 1px solid var(--line-soft); border-radius: 6px; padding: .3rem .55rem; font-weight: 700; font-size: 1.05rem; cursor: pointer; min-width: 2.8rem;
}
.roll-btn:hover { border-color: var(--accent); background: #2b2230; }
.roll-btn.wide { font-size: .95rem; }

.combat-actions { margin-bottom: .6rem; background: #ffffff06; border-radius: 8px; padding: .4rem .6rem; }
.combat-actions summary { cursor: pointer; }
.combat-actions dt { font-weight: 700; margin-top: .4rem; }
.combat-actions dd { margin: 0; color: var(--muted); font-size: .88rem; }

.feature { border-bottom: 1px solid #ffffff10; padding: .5rem 0; }
.feature header { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.feature h4 { margin: 0; font-size: 1rem; }
.feature .source { color: var(--muted); font-size: .75rem; }
.feature .meta { color: var(--gold); font-size: .82rem; margin-top: .2rem; }
.feature .desc { margin: .3rem 0 0; white-space: pre-line; color: #d9d1c6; font-size: .92rem; }
.uses { display: flex; gap: .3rem; align-items: center; margin-top: .3rem; }
.uses input { width: 18px; height: 18px; accent-color: var(--accent); }

.currency { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; margin-bottom: .8rem; }
.coin { display: flex; flex-direction: column; font-family: var(--font-cond); font-weight: 800; font-size: .75rem; }
.coin input { text-align: center; }
.inventory .num { text-align: right; white-space: nowrap; }
.inventory .qty { white-space: nowrap; }
.inventory .qty span { display: inline-block; min-width: 2rem; text-align: center; }
.step { background: #141217; border: 1px solid var(--line-soft); border-radius: 4px; width: 1.6rem; height: 1.6rem; cursor: pointer; }
input.plain { background: transparent; border-color: transparent; width: 100%; padding: .2rem; }
input.plain:hover { border-color: var(--line-soft); }
.add-item { display: flex; gap: .4rem; margin-top: .4rem; }
.add-item input:first-child { flex: 1; }
.add-item input[type=number] { width: 5rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.facts dt { font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; color: var(--muted); font-size: .8rem; }
.facts dd { margin: 0; }
.text-block { display: block; margin-bottom: .8rem; }

/* Roll history */
.history-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-bottom: .8rem; }
.history-stats div { background: #141217; border: 1px solid var(--line-soft); border-radius: 8px; padding: .4rem; text-align: center; }
.history-stats strong { display: block; font-size: 1.4rem; }
.history-stats span { color: var(--muted); font-size: .75rem; text-transform: uppercase; font-family: var(--font-cond); font-weight: 700; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 3rem 3rem 1fr; gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid #ffffff10; }
.history li.nat20 .h-total { color: var(--gold); }
.history li.nat1 .h-total { color: var(--bad); }
.h-time { color: var(--muted); font-size: .8rem; }
.h-total { font-size: 1.5rem; font-weight: 800; text-align: center; }
.h-dice { display: block; margin-top: .15rem; font-size: .82rem; }
.h-note { display: block; color: var(--gold); font-size: .8rem; }
.voice-settings { display: grid; gap: .4rem; margin: -.3rem 0 .6rem 1.4rem; }
.voice-settings label { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); }
.voice-settings select { width: 100%; }
.voice-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

/* ----- Modal ----- */
.modal-backdrop { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: 1.2rem; width: min(460px, 100%); box-shadow: 0 10px 40px #000; }
.modal .actions { margin-top: 1rem; }

/* ----- Import review ----- */
.review { margin-top: 1rem; }
.review-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .4rem; margin: .6rem 0; }
.review-grid div { display: flex; flex-direction: column; align-items: center; background: #141217; border-radius: 8px; padding: .3rem; }
.review-grid strong { font-size: 1.3rem; }
.warnings li { color: #f3d58f; }

/* ----- Edit ----- */
.edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: .8rem; }
.form { padding-bottom: .9rem; }
.form.wide { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .55rem; font-size: .85rem; color: var(--muted); flex: 1; }
.form label input, .form label select, .form label textarea { color: var(--text); }
.form label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); flex: none; }
.form label.narrow { flex: 0 0 5.5rem; }
.form .row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.score-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.score-grid input { text-align: center; font-size: 1.2rem; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-bottom: .6rem; }
.skill-edit label { flex-direction: row; align-items: center; justify-content: space-between; color: var(--text); margin-bottom: .3rem; }
.skill-edit label > span:first-child { flex: 1; }
.list-edit { border: 1px solid var(--line-soft); border-radius: 8px; padding: .6rem; margin-bottom: .6rem; background: #ffffff04; }

/* ----- Dice tray ----- */
#dice-overlay { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .3s; }
#dice-overlay.visible { opacity: 1; }
#dice-overlay canvas { width: 100% !important; height: 100% !important; }

.tray { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; }
.tray-button {
    position: relative; width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--accent); background: #1a1418; color: var(--accent-2);
    display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 18px #000a;
}
.tray-button svg { width: 34px; height: 34px; }
.tray-button .badge { position: absolute; top: -6px; right: -6px; background: var(--gold); color: #1a1418; font-size: .65rem; font-weight: 800; border-radius: 999px; padding: .1rem .35rem; }
.tray-panel { width: min(360px, calc(100vw - 32px)); max-height: min(70vh, 640px); overflow-y: auto; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: 0 10px 40px #000; }
.tray-head, .log-head { display: flex; justify-content: space-between; align-items: center; }
.close { background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 .2rem; }
.mode-row { display: flex; gap: .4rem; margin: .6rem 0; }
.quick-dice { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .3rem; }
.die-btn { background: #141217; border: 1px solid var(--line-soft); border-radius: 6px; padding: .45rem 0; cursor: pointer; font-weight: 700; font-size: .85rem; }
.die-btn:hover { border-color: var(--accent); }
.custom-roll { display: flex; gap: .4rem; margin-top: .5rem; }
.custom-roll input { flex: 1; }
.toggle { display: flex; gap: .4rem; align-items: center; margin: .7rem 0; font-size: .88rem; }
.log { list-style: none; padding: 0; margin: .4rem 0 0; display: grid; gap: .3rem; }
.log li { display: grid; grid-template-columns: 2.6rem 1fr; gap: 0 .5rem; background: #ffffff06; border-radius: 6px; padding: .3rem .4rem; }
.log li.muted { display: block; }
.log-total { grid-row: span 2; font-size: 1.4rem; font-weight: 700; text-align: center; align-self: center; }
.log-label small { color: var(--muted); }
.log-detail { font-size: .8rem; }

.roll-toast {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: max(90px, calc(env(safe-area-inset-bottom) + 80px)); z-index: 70;
    width: min(380px, calc(100vw - 32px)); background: #1a1418f2; border: 2px solid var(--line); border-radius: 14px; padding: .7rem .9rem;
    box-shadow: 0 10px 40px #000; animation: pop .18s ease-out;
}
.roll-toast.nat20 { border-color: var(--gold); box-shadow: 0 0 30px #d6a84e66; }
.roll-toast.nat1 { border-color: var(--bad); }
.roll-toast .close { position: absolute; top: .3rem; right: .5rem; }
.roll-label { font-family: var(--font-cond); font-weight: 800; text-transform: uppercase; font-size: .9rem; padding-right: 1.5rem; }
.roll-kind { color: var(--muted); font-weight: 600; text-transform: none; }
.roll-main { display: flex; gap: .9rem; align-items: center; }
.roll-total { font-size: 3rem; font-weight: 800; line-height: 1; min-width: 3.5rem; text-align: center; }
.roll-breakdown .note { color: var(--gold); font-size: .82rem; }
.breakdown { display: inline-flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.die { display: inline-flex; align-items: baseline; gap: 1px; background: #141217; border: 1px solid var(--line-soft); border-radius: 5px; padding: 0 .3rem; font-weight: 700; }
.die small { color: var(--muted); font-size: .65rem; font-weight: 500; }
.die.dropped { opacity: .4; text-decoration: line-through; }
.die.max { border-color: var(--gold); color: var(--gold); }
.die.min { border-color: var(--bad); color: var(--bad); }
.mod { font-weight: 700; color: var(--muted); }
@keyframes pop { from { transform: translateX(-50%) scale(.92); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ----- Responsive ----- */
@media (max-width: 1250px) {
    .top-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .abilities { grid-column: 1 / -1; }
    .hp { grid-column: 1 / -1; }
    .main-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .col-right { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
    html, body { font-size: 14px; }
    .abilities { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 1rem; }
    .main-grid { grid-template-columns: minmax(0, 1fr); }
    .combat-strip { grid-template-columns: 1fr 1fr; }
    .defenses { grid-column: 1 / -1; grid-template-columns: 1fr; }
    .def-col + .def-col { border-left: none; padding-left: 0; border-top: 1px solid var(--line-soft); padding-top: .4rem; }
    .hide-sm { display: none; }
    .identity h1 { font-size: 1.5rem; }
    .currency { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .history-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .review-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .edit-grid { grid-template-columns: minmax(0, 1fr); }
    .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ----- Blazor boot and errors ----- */
.boot { min-height: 60vh; }
#blazor-error-ui {
    background: #3a1418; color: #ffd6d9; bottom: 0; box-sizing: border-box; display: none;
    left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; border-top: 1px solid var(--bad);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.loading-progress { position: absolute; display: block; width: 6rem; height: 6rem; inset: 20vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: #2a2330; stroke-width: .6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 2.4rem) 0 auto .2rem; color: var(--muted); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

/* ----- Table Talk ----- */
.talk-status { display: flex; align-items: center; gap: .7rem; margin: 0 0 1rem; }
.rec-dot { width: .8rem; height: .8rem; border-radius: 50%; background: var(--muted); flex: none; }
.rec-dot.on { background: var(--bad); animation: rec-pulse 1.4s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .35; } }
.talk-meter { width: min(220px, 40vw); height: .5rem; background: var(--panel-2); border-radius: 99px; overflow: hidden; flex: none; }
.talk-meter > div { height: 100%; width: 0; background: var(--muted); transition: width .08s linear; }
.talk-meter > div.speaking { background: var(--good); }
.talk-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.talk-box { padding-bottom: .9rem; }
.talk-side { display: flex; flex-direction: column; gap: 1rem; }
.talk-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; }
.talk-title { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .05em; font-size: .9rem; margin: 0 0 .6rem; }
.talk-lines { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.talk-lines li { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: .2rem .6rem; align-items: baseline; padding: .45rem .2rem; border-bottom: 1px solid var(--line-soft); }
.talk-lines li.empty { display: block; border: 0; }
.t-time { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.t-who { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--who); cursor: pointer; white-space: nowrap; }
.t-who:hover { text-decoration: underline; }
.t-who-select { max-width: 9rem; }
.t-text { overflow-wrap: anywhere; }
.t-del { opacity: .35; font-size: 1.1rem; }
.talk-lines li:hover .t-del { opacity: 1; }
.talk-people { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.talk-people li { display: flex; align-items: center; gap: .5rem; }
.talk-people input { flex: 1; min-width: 0; }
.talk-people .dot { width: .75rem; height: .75rem; border-radius: 50%; background: var(--who); flex: none; }
.talk-settings summary { cursor: pointer; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .05em; font-size: .9rem; }
.talk-field { display: flex; flex-direction: column; gap: .25rem; margin: .7rem 0; font-size: .85rem; color: var(--muted); }
.topbar nav .live::after { content: ""; display: inline-block; width: .45rem; height: .45rem; margin-left: .3rem; border-radius: 50%; background: var(--bad); vertical-align: middle; }
@media (max-width: 800px) {
    .talk-layout { grid-template-columns: 1fr; }
    .talk-lines li { grid-template-columns: auto minmax(0, 1fr) auto; }
    .talk-lines .t-time { display: none; }
}
@media (max-width: 480px) {
    .topbar nav { gap: .7rem; }
    .brand span { display: none; }
}
