:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #efe7d8;
  --ink: #2b241c;
  --muted: #74685a;
  --line: #ddd2bf;
  --accent: #8a3b1e;
  --accent-ink: #fff8f0;
  --player: #e9e1d2;
  --good: #3d6b3a;
  --bad: #a33a2a;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.06), 0 4px 16px rgb(60 40 20 / 0.06);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #211d17;
    --surface-2: #2b261e;
    --ink: #ede4d3;
    --muted: #a99c88;
    --line: #3b342a;
    --accent: #d9774a;
    --accent-ink: #1b120c;
    --player: #2e2820;
    --good: #8fc28a;
    --bad: #e58a78;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  display: flex;
  flex-direction: column;
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand {
  font: 700 26px/1 var(--serif); letter-spacing: 0.02em; color: var(--accent);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.campaign-title { flex: 1; font: 600 20px/1.2 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls { display: flex; align-items: center; gap: 14px; }
.user { color: var(--muted); font-size: 13px; }
.mode { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface-2); }
.mode button {
  border: 0; background: none; padding: 4px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 500;
}
.mode button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.mode button:disabled { cursor: not-allowed; opacity: 0.5; }

/* shared */
.panel, .sidebar section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 26px; }
h3 { font-size: 19px; }
.hint { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.optional { color: var(--muted); font-weight: 400; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px;
  padding: 9px 18px; font-weight: 600; cursor: pointer;
}
button.primary:disabled { opacity: 0.5; cursor: progress; }
input, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; resize: vertical;
}
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* lobby */
.lobby {
  flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px;
  padding: 28px 20px; max-width: 1100px; width: 100%; margin: 0 auto; align-content: start;
}
.panel { padding: 22px; }
.worlds { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.worlds li.empty { color: var(--muted); font-style: italic; }
.world {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; display: block;
}
.world:hover { border-color: var(--accent); }
.world strong { font: 700 19px/1.2 var(--serif); display: block; }
.world span { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
form#forge { display: grid; gap: 12px; }
form#forge label { display: grid; gap: 4px; font-weight: 500; }
.progress { margin: 16px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: grid; gap: 2px; }
.progress li.status { color: var(--ink); font-weight: 500; list-style: none; margin-left: -20px; }
.progress li.error { color: var(--bad); list-style: none; margin-left: -20px; }

/* table */
.table {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px;
  padding: 20px; max-width: 1200px; width: 100%; margin: 0 auto;
}
.story { display: flex; flex-direction: column; min-height: 0; }
.transcript {
  flex: 1; overflow-y: auto; padding: 4px 4px 12px; display: flex; flex-direction: column; gap: 14px;
}
.msg { max-width: 46rem; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; font-weight: 500; }
.msg.player { align-self: flex-end; background: var(--player); padding: 8px 13px; border-radius: 12px 12px 2px 12px; }
.msg.gm .body { font: 500 19px/1.5 var(--serif); }
.msg.gm .body p { margin: 0 0 0.6em; }
.msg.gm .body p:last-child { margin-bottom: 0; }
.msg.error { color: var(--bad); font-style: italic; }
.msg.gm.streaming .body::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.activity { color: var(--muted); font-style: italic; font-size: 13px; padding: 4px; }

.speaking-as { display: flex; justify-content: center; padding-top: 10px; border-top: 1px solid var(--line); }
.speaking-as + .composer, .speaking-as ~ .talk { border-top: 0; }
/* Out-of-character exchanges with the GM: plainer and quieter than the story. */
.msg.aside { border-left: 3px solid var(--line); padding-left: 10px; }
.msg.player.aside { border-left: 0; outline: 1px dashed var(--line); background: none; }
.msg.gm.aside .body { font: 400 15px/1.55 var(--sans); color: var(--muted); }
.composer { display: flex; gap: 10px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-height: 44px; max-height: 160px; }
.talk { display: grid; justify-items: center; gap: 4px; padding: 14px 0 4px; border-top: 1px solid var(--line); }
.talk .hint { margin: 0; font-size: 12px; text-align: center; max-width: 34rem; }
#talk-status { color: var(--ink); font-weight: 600; }
.heard { margin: 0; color: var(--muted); font-style: italic; text-align: center; max-width: 40rem; }
.mic {
  display: inline-flex; align-items: center; gap: 10px; padding: 14px 28px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; box-shadow: var(--shadow);
}
.voice-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 13px; }
.voice-picker label { color: var(--muted); font-weight: 500; }
.voice-picker select { max-width: 22rem; padding: 5px 8px; }
.voice-picker button {
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; color: var(--muted);
}
.talk-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.stop-voice {
  display: inline-flex; align-items: center; gap: 8px; padding: 14px 22px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; color: var(--ink);
}
.stop-voice:hover { border-color: var(--accent); }
.stop-square { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.mic-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.mic[aria-pressed="true"] { border-color: var(--bad); }
.mic[aria-pressed="true"] .voice-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 13px; }
.voice-picker label { color: var(--muted); font-weight: 500; }
.voice-picker select { max-width: 22rem; padding: 5px 8px; }
.voice-picker button {
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; color: var(--muted);
}
.talk-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.stop-voice {
  display: inline-flex; align-items: center; gap: 8px; padding: 14px 22px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; color: var(--ink);
}
.stop-voice:hover { border-color: var(--accent); }
.stop-square { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.mic-dot { background: var(--bad); animation: pulse 1.2s ease-in-out infinite; }
.mic:disabled { opacity: 0.5; cursor: progress; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: 0.6; } }

.sidebar { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }
.sidebar section { padding: 14px 16px; }
.party, .log { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.party li { display: grid; gap: 3px; }
.party details summary { list-style: none; cursor: pointer; display: grid; gap: 3px; }
.party details summary::-webkit-details-marker { display: none; }
.party details summary .name::before { content: "▸ "; color: var(--muted); }
.party details[open] summary .name::before { content: "▾ "; }
.sheet { display: grid; gap: 8px; margin: 8px 0 4px; padding: 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin: 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; text-align: center; }
.stats dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats dd { margin: 0; font-weight: 600; font-size: 15px; }
.conditions { display: flex; flex-wrap: wrap; gap: 4px; }
.conditions span { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--bad); color: var(--bg); }
/* abilities on a sheet: click one for details */
.abilities { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.abilities button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left;
  background: none; border: 0; border-bottom: 1px dashed var(--line); padding: 2px 0; cursor: pointer; color: inherit;
}
.abilities li:last-child button { border-bottom: 0; }
.abilities button:hover .ability-name { color: var(--accent); text-decoration: underline; }
.abilities .spent .ability-name { color: var(--muted); text-decoration: line-through; }
.limit { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pips { letter-spacing: 1px; color: var(--accent); }
.pool { display: grid; gap: 2px; font-size: 12px; }
.pool .bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.pool .bar div { height: 100%; background: var(--accent); }
.ability-effect, .ability-limits { margin: 8px 0; }
.ability-limits { color: var(--muted); font-size: 14px; }

/* inventory items and quests: click for details */
.inventory button, .quests button {
  width: 100%; display: flex; justify-content: space-between; gap: 8px; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit;
}
.inventory button:hover span:first-child, .quests button:hover .quest-title { color: var(--accent); text-decoration: underline; }
.inventory .notable span:first-child::after { content: " ✦"; color: var(--accent); font-size: 11px; }
.quests { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.quests li { border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.quests li:last-child { border-bottom: 0; }
.quests button { display: grid; gap: 1px; }
.quest-title { font-weight: 600; }
.quest-meta { font-size: 12px; color: var(--muted); }
.quests .done .quest-title { color: var(--muted); text-decoration: line-through; }
.quests details summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.quest-notes { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.quest-notes .by { color: var(--muted); font-size: 12px; }
#detail-body p { margin: 0 0 8px; }
#detail-note { margin: 10px 0; display: grid; gap: 4px; }
#detail-note input { flex: 1; }

/* character creation card in the transcript */
.creator { border: 1px solid var(--accent); border-radius: 12px; padding: 14px 16px; background: var(--surface); display: grid; gap: 10px; max-width: 46rem; }
.creator h3 { margin: 0; }
.creator .hint { margin: 0; }
.creator fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.creator legend { font-weight: 600; margin-bottom: 4px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.choice {
  text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg);
  cursor: pointer; color: inherit; display: grid; gap: 2px; align-content: start;
}
.choice:hover { border-color: var(--accent); }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--surface-2); }
.choice .choice-name { font-weight: 600; }
.choice .choice-name small { font-weight: 400; color: var(--accent); margin-left: 4px; }
.choice .choice-summary { font-size: 13px; color: var(--muted); }
.choice-detail { border-left: 3px solid var(--accent); padding: 4px 10px; font-size: 14px; }
.choice-detail p { margin: 0 0 6px; }
.choice-detail ul { margin: 0; padding-left: 18px; }
.creator .row input { flex: 1 1 200px; }
.inventory-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.inventory { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.inventory li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--line); padding-bottom: 2px; }
.inventory li:last-child { border-bottom: 0; }
.inventory .qty { color: var(--muted); font-variant-numeric: tabular-nums; }
.party .name { font-weight: 600; }
.party .meta { color: var(--muted); font-size: 12px; }
.hp { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.hp > div { height: 100%; background: var(--good); }
.party .down .hp > div { background: var(--bad); }
.log { max-height: 40vh; overflow-y: auto; }
.log li { color: var(--muted); border-left: 2px solid var(--line); padding-left: 8px; }
.log li.fresh { border-left-color: var(--accent); color: var(--ink); }
.log li { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.log .undo {
  flex: none; background: none; border: 1px solid transparent; border-radius: 6px; color: var(--muted);
  cursor: pointer; padding: 0 5px; font-size: 13px; line-height: 1.4; opacity: 0;
}
.log li:hover .undo, .log .undo:focus-visible { opacity: 1; border-color: var(--line); }
.log .undo:hover { color: var(--accent); border-color: var(--accent); }
@media (hover: none) { .log .undo { opacity: 0.7; } }
.table-actions button {
  width: 100%; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px; cursor: pointer; color: var(--muted);
}

/* admin */
.admin-link, .pill-button {
  background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; color: var(--muted); font-weight: 500;
}
.pill-button:hover { color: var(--ink); border-color: var(--accent); }
.admin-link[aria-pressed="true"], .pill-button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.admin {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px;
  padding: 20px; max-width: 1400px; width: 100%; margin: 0 auto;
}
.admin-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.admin-main .panel { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px 8px 0 0; padding: 6px 16px; cursor: pointer; color: var(--muted); font-weight: 500;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); border-bottom-color: var(--surface); }
#sql { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row .hint { flex: 1; margin: 0; font-size: 12px; }
.row input { flex: 1 1 260px; width: auto; }
select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; color: inherit; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.check input { width: auto; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples button {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--muted);
}
.result .status { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.result .error { color: var(--bad); white-space: pre-wrap; font: 13px/1.5 ui-monospace, Menlo, monospace; }
.grid-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 8px; }
table.grid { border-collapse: collapse; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 100%; }
table.grid th, table.grid td { padding: 5px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; }
table.grid td { max-width: 36rem; white-space: pre-wrap; word-break: break-word; }
table.grid td.null { color: var(--muted); font-style: italic; }
.hits { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hits li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.hits .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.hits .title { font: 700 18px/1.2 var(--serif); }
.hits .meta { color: var(--muted); font-size: 12px; }
.hits .score { margin-left: auto; font: 600 12px ui-monospace, Menlo, monospace; }
.hits .bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin: 6px 0; overflow: hidden; }
.hits .bar > div { height: 100%; background: var(--accent); }
.hits p { margin: 0; font-size: 14px; }
.schema { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.schema details summary { cursor: pointer; font-weight: 600; }
.schema details summary span { color: var(--muted); font-weight: 400; }
.schema code { display: block; font: 12px/1.6 ui-monospace, Menlo, monospace; color: var(--muted); padding-left: 12px; }
.schema li.meta { color: var(--muted); }

.world-admin { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; background: var(--bg); }
#worlds-admin { display: grid; gap: 12px; }
.world-admin .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.world-admin .head strong { font: 700 20px/1.2 var(--serif); }
.world-admin .head .meta { color: var(--muted); font-size: 12px; flex: 1; }
.small-button {
  background: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 12px; color: var(--ink);
}
.small-button:hover { border-color: var(--accent); }
.small-button.danger { color: var(--bad); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-right: 6px; }
.dot.on { background: var(--good); }
.usage-totals { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.usage-totals div { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--bg); }
.usage-totals dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.usage-totals dd { margin: 0; font: 600 18px/1.3 var(--sans); font-variant-numeric: tabular-nums; }
#add-user-form { margin-bottom: 10px; }
.new-password { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface-2); }
.new-password code { font-size: 15px; user-select: all; }
.new-password button { margin-left: 8px; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 18px 20px; width: min(520px, calc(100% - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
dialog .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
dialog label { display: grid; gap: 3px; font-size: 13px; font-weight: 500; }
dialog .error { color: var(--bad); margin: 0 0 8px; }
dialog .row.end { justify-content: flex-end; }
dialog .row.end .push-left { margin-right: auto; }
dialog button.danger { color: var(--bad); }
dialog button:not(.primary) { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }

body.login { align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 32px 28px; width: min(380px, 100%); display: grid; gap: 10px; text-align: center;
}
.login-card h1 { font: 700 44px/1 var(--serif); color: var(--accent); margin: 0; }
.login-card .error { color: var(--bad); margin: 0; }
.login-options { display: grid; gap: 10px; margin-top: 10px; }
.login-options a { display: block; padding: 11px 16px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.login-options a.primary { background: var(--accent); color: var(--accent-ink); }
.login-options a.secondary { border: 1px solid var(--line); color: var(--ink); }
.user-menu { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 0; }
.user-menu:hover { color: var(--ink); text-decoration: underline; }

.dice { display: grid; gap: 6px; margin-top: 8px; }
.dice-quick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dice-quick button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 5px 0; cursor: pointer;
  font: 600 12px var(--sans); color: var(--ink);
}
.dice-quick button:hover { border-color: var(--accent); }
.dice-custom { display: flex; gap: 6px; }
.dice-custom input, .dice-custom select { flex: 1; min-width: 0; padding: 6px 8px; font-size: 13px; }
.dice-custom button { padding: 6px 14px; }
.roll-card {
  align-self: center; display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; max-width: 40rem;
}
.roll-card .total {
  font: 700 24px/1 var(--serif); min-width: 2.2ch; text-align: center; color: var(--accent);
  animation: tumble 0.6s ease-out;
}
.roll-card .faces { color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes tumble { 0% { transform: rotate(-200deg) scale(0.3); opacity: 0; } 100% { transform: none; opacity: 1; } }

.npc-line { font-style: italic; }
.health { border-radius: 10px; padding: 10px 14px; font-size: 14px; border: 1px solid; }
.health.bad { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); border-color: var(--bad); }
.health.warn { background: color-mix(in srgb, #fab219 14%, var(--surface)); border-color: #c98500; }
.health .hint { margin: 4px 0 0; display: inline-block; }
.lore-actions { display: flex; gap: 6px; margin-top: 6px; }
dialog .fields .wide { grid-column: 1 / -1; }
#merge-dialog label { display: grid; gap: 4px; margin: 10px 0; }
.npc-voices { display: grid; gap: 6px; }
.npc-voices select { width: 100%; padding: 4px 6px; font-size: 12px; }
.npc-name {
  font: 600 11px/1 var(--sans); font-style: normal; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); margin-right: 6px; vertical-align: 2px;
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 10;
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .campaign-title { order: 3; flex-basis: 100%; }
  .lobby { padding: 16px; }
  .table { grid-template-columns: 1fr; padding: 12px 16px; }
  .sidebar { max-height: 30vh; }
  .admin { grid-template-columns: 1fr; padding: 12px 16px; }
  .row:not(.wrap) { flex-wrap: wrap; }
}
