/* Grimwar — base UI; skins: Dungeon (dark), Parchment (light), Grimoire (css/grimoire.css). */
:root, [data-theme="dark"] {
  --bg: #12110f;
  --bg-2: #181614;
  --panel: #1d1b18;
  --panel-2: #24211d;
  --panel-3: #2c2823;
  --line: #36312a;
  --line-2: #4a4339;
  --text: #ece5d8;
  --text-2: #c9c0b0;
  --muted: #968c7c;
  --accent: #d4a24c;
  --accent-ink: #1b1508;
  --accent-soft: rgba(212, 162, 76, .14);
  --good: #79b36f;
  --bad: #d9614b;
  --warn: #dba845;
  --info: #6f9ad6;
  --magic: #9b7be0;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 10px;
  --radius-s: 7px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #ece6da;
  --bg-2: #e4ddcf;
  --panel: #faf7f1;
  --panel-2: #f2ede3;
  --panel-3: #e8e1d3;
  --line: #d8cfbe;
  --line-2: #c4b9a5;
  --text: #241f18;
  --text-2: #3d362c;
  --muted: #7a705f;
  --accent: #9a6a12;
  --accent-ink: #fff;
  --accent-soft: rgba(154, 106, 18, .12);
  --good: #3f8a3a;
  --bad: #b8402b;
  --warn: #a9790f;
  --info: #3b6fb5;
  --shadow: 0 10px 30px rgba(60, 45, 20, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3, h4, h5 { font-family: var(--serif); font-weight: 600; margin: 0 0 .4em; line-height: 1.2; }
h2 { font-size: 1.45rem; } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; } h5 { font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-family: var(--font); }
p { margin: 0 0 .6em; }
code { font-family: var(--mono); font-size: .9em; background: var(--panel-3); padding: .05em .35em; border-radius: 4px; }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--panel-2); }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.center { text-align: center; justify-content: center; }
.pad { padding: 12px; }
.pad-x { padding: 0 2px; margin-top: 8px; }
.row { display: flex; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.gap-s { gap: 6px; }
.spacer { flex: 1; }
.mono { font-family: var(--mono); font-size: 13px; }

/* ---------- Controls ---------- */
.input {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 7px 10px; font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { padding: 5px 8px; font-size: 13px; }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { cursor: pointer; }
.title-input { font: 600 1.25rem var(--serif); padding: 4px 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 5px; justify-content: center; white-space: nowrap;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--radius-s);
  padding: 7px 12px; font: 500 13px var(--font); cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--panel-3); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn.xs { padding: 3px 7px; font-size: 12px; border-radius: 6px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger.primary { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.good { color: var(--good); }
.btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 5px; border-radius: 6px;
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer; font: 600 13px var(--font);
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.xs { min-width: 22px; height: 22px; font-size: 11px; }
.icon-btn.big { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.check-label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text-2); }
.check-label.xs { font-size: 11.5px; color: var(--muted); }
input[type="checkbox"] { accent-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }
.vol { width: 80px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-s); overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--text-2); padding: 5px 10px; font: 500 12.5px var(--font); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.active { background: var(--accent-soft); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2);
  border-radius: 999px; padding: 2px 9px; font: 500 12px var(--font); cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip.on { border-color: var(--c, var(--accent)); color: var(--c, var(--accent)); background: var(--accent-soft); }
.chip.add { padding: 2px 8px; color: var(--muted); border-style: dashed; }
.chip.cond { border-color: rgba(217, 97, 75, .5); color: #f0a08f; background: rgba(217, 97, 75, .1); }
[data-theme="light"] .chip.cond { color: var(--bad); }
.chip.conc { border-color: rgba(155, 123, 224, .6); color: var(--magic); background: rgba(155, 123, 224, .12); }
.chip.alt { border-style: dashed; }
.chip small { opacity: .8; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--panel-3); color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.tag.pc { background: rgba(111, 154, 214, .18); color: var(--info); }
.tag.ally { background: rgba(121, 179, 111, .16); color: var(--good); }

.form-grid { display: grid; gap: 10px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid .check-label { display: inline-flex; color: var(--text-2); font-size: 13px; }
.form-grid .span-2 { grid-column: span 2; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 12px; cursor: pointer; font: 500 13px var(--font); }
.tab.active { color: var(--accent); border-color: var(--accent); }

.empty { padding: 20px; text-align: center; display: grid; gap: 6px; justify-items: center; align-content: center; height: 100%; }
.empty.small { padding: 12px; }
.empty .row { justify-content: center; }

/* Roll buttons (inline anywhere) */
.roll {
  display: inline; border: 0; border-bottom: 1px dashed var(--accent); background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; padding: 0 4px; font: inherit; font-weight: 600; cursor: pointer;
}
.roll:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 7px; font: 600 16px var(--serif); color: var(--accent); letter-spacing: .02em; white-space: nowrap; }
.campaign { display: flex; align-items: center; gap: 2px; }
.campaign select { max-width: 220px; font-weight: 600; }
.search-btn {
  display: flex; align-items: center; gap: 8px; min-width: 240px; background: var(--bg-2); color: var(--muted); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 6px 10px; cursor: pointer; font: 13px var(--font);
}
.search-btn span { flex: 1; text-align: left; }
.search-btn:hover { border-color: var(--line-2); color: var(--text-2); }
.quick-roll input { width: 120px; }
.layout-ctl { display: flex; align-items: center; gap: 4px; }
.layout-ctl select { width: 140px; }
@media (max-width: 1100px) { .search-btn span, .search-btn kbd { display: none; } .search-btn { min-width: 0; } }
@media (max-width: 760px) { .brand span, .quick-roll { display: none; } .topbar { flex-wrap: wrap; } }

/* ---------- Grid & panels ---------- */
.grid {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: var(--row, 52px); grid-auto-flow: row dense;
  gap: 10px; padding: 10px 14px 40px;
}
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } .grid .panel { grid-column: 1 / -1 !important; } }
.empty-grid { grid-column: 1 / -1; grid-row: span 6; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); }

.panel {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset;
}
.panel.dragging { opacity: .45; }
.panel.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }
.panel.flash { animation: flash .9s ease; }
@keyframes flash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px var(--accent); } }
.panel.maxed { position: fixed; inset: 58px 14px 14px; z-index: 25; box-shadow: var(--shadow); }
body.has-max .grid > .panel:not(.maxed) { visibility: hidden; }
.panel-head {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; min-height: 38px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); cursor: grab; user-select: none;
}
.panel-head:active { cursor: grabbing; }
.ptitle { display: flex; align-items: center; gap: 7px; font: 600 13.5px var(--serif); letter-spacing: .02em; white-space: nowrap; color: var(--text); }
.ptitle .ic { color: var(--accent); }
.panel-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: nowrap; overflow: hidden; }
.panel-tools > * { flex-shrink: 0; }
.panel-ctl { display: flex; gap: 1px; opacity: .5; transition: opacity .15s; }
.panel:hover .panel-ctl { opacity: 1; }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; container-type: inline-size; }
.resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; z-index: 2; }
.resize::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 7px; height: 7px; border-right: 2px solid var(--line-2); border-bottom: 2px solid var(--line-2); }
.panel:hover .resize::after { border-color: var(--accent); }
.panel.resizing { outline: 1px solid var(--accent); }
.round { font-size: 12px; color: var(--muted); margin-right: 2px; white-space: nowrap; }
.round b { color: var(--accent); font-size: 14px; }

/* ---------- Popovers, modals, toasts, drawer, palette ---------- */
.popover {
  position: fixed; z-index: 60; min-width: 220px; max-width: 340px; max-height: 70vh; overflow: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow);
}
.pop-title { font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px 4px; }
.pop-hint { padding: 6px 8px; }
.pop-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 0; background: none; color: var(--text);
  padding: 7px 9px; border-radius: 6px; cursor: pointer; font: 13px var(--font);
}
.pop-item:hover { background: var(--panel-3); }
.pop-item .ic { color: var(--accent); flex-shrink: 0; }
.pop-item span { display: grid; }
.pop-item small { color: var(--muted); font-size: 11.5px; }
.pop-item.danger, .pop-item.danger .ic { color: var(--bad); }
.hp-pop { display: grid; gap: 8px; padding: 10px; min-width: 260px; }
.cond-pop { display: grid; gap: 8px; padding: 10px; max-width: 330px; }
.cond-grid { display: flex; flex-wrap: wrap; gap: 4px; }

.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .55); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); }
.modal.wide { width: min(760px, 100%); }
.modal { animation: modal-in .18s cubic-bezier(.21, 1.02, .73, 1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-wrap { transition: opacity .14s ease; }
.modal-wrap.closing { opacity: 0; pointer-events: none; }
.modal-wrap.closing .modal { transform: scale(.98); transition: transform .14s ease; }
@media (prefers-reduced-motion: reduce) { .modal, .modal-wrap { animation: none; transition: none; } }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal header h2 { margin: 0; font-size: 1.2rem; }
.modal-body { padding: 8px 16px 12px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal footer .btn.danger:first-child { margin-right: auto; }

/* ---------- Toasts (Sonner-style stack; logic in js/toast.js) ---------- */
#toasts.toaster {
  --toast-w: 372px;
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 80;
  width: min(var(--toast-w), calc(100vw - 32px)); height: 0; margin: 0; padding: 0; list-style: none;
  transition: height .4s cubic-bezier(.21, 1.02, .73, 1);
}
/* Fill the gaps between fanned-out cards so the pointer never "falls through" and collapses the stack. */
#toasts.toaster.expanded::before { content: ""; position: absolute; inset: -12px -8px; }
/* Look (low specificity, so the classic, Grimoire and Modern skins can restyle it). */
.toast {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; line-height: 1.4;
}
/* Mechanics. */
.toaster .toast {
  --y: 0px; --s: 1; --sx: 0px; --so: 1;
  position: absolute; right: 0; bottom: 0; width: 100%; max-width: none; box-sizing: border-box; overflow: hidden; margin: 0;
  pointer-events: auto; touch-action: pan-y; user-select: text;
  transform-origin: 50% 100%;
  transform: translate3d(var(--sx), var(--y), 0) scale(var(--s));
  opacity: var(--so);
  transition: transform .4s cubic-bezier(.21, 1.02, .73, 1), opacity .4s, height .4s cubic-bezier(.21, 1.02, .73, 1), box-shadow .2s;
  animation: none;
}
.toaster .toast[data-mounted="false"] { transform: translate3d(0, 110%, 0) scale(1); opacity: 0; transition: none; }
.toaster .toast[data-behind="true"] { opacity: 0; pointer-events: none; }
.toaster .toast[data-removed="true"] { transform: translate3d(0, calc(var(--y) + 40%), 0) scale(calc(var(--s) - .04)); opacity: 0; pointer-events: none; }
.toaster .toast[data-removed="swipe"] { opacity: 0; pointer-events: none; transition: transform .25s ease-out, opacity .25s; }
.toaster .toast[data-swiping] { transition: none; cursor: grabbing; user-select: none; }

/* Cards behind the front one are just edges of paper until the stack opens. */
.toaster:not(.expanded) .toast[data-front="false"] > .toast-content { opacity: 0; }
.toast-content { display: flex; align-items: flex-start; gap: 10px; transition: opacity .3s; }
.toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; }
.toast-body .btn, .toast-body button.roll { margin-left: 4px; vertical-align: 1px; }
.toast-desc { color: var(--muted); margin-top: 3px; font-size: 12.5px; }
.toast .small { color: var(--muted); margin-top: 2px; }
.toast-action { flex-shrink: 0; align-self: center; margin-right: 18px; }

.toast-icon { flex-shrink: 0; display: grid; place-items: center; width: 18px; height: 18px; margin-top: 0; color: var(--info); }
.toast[data-kind="good"] .toast-icon { color: var(--good); }
.toast[data-kind="bad"] .toast-icon { color: var(--bad); }
.toast[data-kind="warn"] .toast-icon { color: var(--warn); }
.toast[data-kind="info"] .toast-icon { color: var(--muted); }

/* Close: a small round button in the top-right corner, shown on hover/focus like Sonner. */
.toast-close {
  position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 20px; height: 20px; padding: 0;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--panel); color: var(--muted); cursor: pointer;
  opacity: 0; transform: scale(.85); transition: opacity .15s, transform .15s, color .15s;
}
.toast-close svg { width: 11px; height: 11px; }
.toast:hover .toast-close, .toast:focus-within .toast-close { opacity: 1; transform: none; }
.toast-close:hover { color: var(--text); }
.toast:hover .toast-body, .toast:focus-within .toast-body { padding-right: 14px; }
@media (hover: none) { .toast-close { opacity: .8; transform: none; } .toast-body { padding-right: 14px; } }

/* Roll results keep their big number instead of an icon. */
.toast.roll .toast-body > b { font: 700 22px var(--serif); color: var(--accent); margin-right: 6px; vertical-align: -2px; }
.toast.roll.good .toast-body > b { color: var(--good); }
.toast.roll.bad .toast-body > b { color: var(--bad); }

/* Loading spinner: twelve fading bars, Sonner's signature. */
.toast-spinner { position: relative; display: block; width: 16px; height: 16px; }
.toast-spinner i {
  position: absolute; left: 46.5%; top: 37%; width: 7%; height: 26%; border-radius: 6px; background: var(--muted);
  transform: rotate(calc(var(--i) * 30deg)) translate(0, -146%); animation: toast-spin 1.2s linear infinite; animation-delay: calc(var(--i) * .1s - 1.2s);
}
@keyframes toast-spin { 0% { opacity: 1; } 100% { opacity: .15; } }
.toast[data-kind="loading"] .toast-icon { color: var(--muted); }

@media (max-width: 600px) {
  #toasts.toaster { right: 12px; left: 12px; width: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .toaster .toast, #toasts.toaster { transition: opacity .15s !important; }
  .toast-spinner i { animation-duration: 2.4s; }
}
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }

.drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 40; background: var(--panel);
  border-left: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .2s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.drawer-body { flex: 1; overflow: auto; padding: 14px 16px; }

.palette-wrap { position: fixed; inset: 0; z-index: 75; background: rgba(0, 0, 0, .45); display: flex; justify-content: center; padding-top: 12vh; }
.palette { width: min(640px, 94vw); max-height: 68vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.pal-in input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font: 16px var(--font); }
.pal-list { overflow: auto; padding: 6px; }
.pal-item { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; color: var(--text); text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; font: 13.5px var(--font); }
.pal-item small { margin-left: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.pal-item.sel, .pal-item:hover { background: var(--accent-soft); }
.pal-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 66px; flex-shrink: 0; }
.pal-foot { padding: 8px 14px; border-top: 1px solid var(--line); }

/* ---------- Prose (markdown) ---------- */
.prose { line-height: 1.6; color: var(--text); }
.prose h2, .prose h3, .prose h4 { margin-top: 1em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 .7em; }
.prose li { margin: .15em 0; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose table { border-collapse: collapse; margin: .4em 0 .9em; font-size: 13px; width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.prose th { background: var(--panel-2); font-weight: 600; }
.prose pre { background: var(--bg-2); padding: 10px; border-radius: 8px; overflow: auto; }
.prose .check { color: var(--muted); }
.prose .check.on { color: var(--good); }
.prose a.wiki { text-decoration: none; border-bottom: 1px solid var(--accent); font-weight: 500; }
.prose a.wiki.missing { color: var(--muted); border-bottom-style: dashed; border-color: var(--muted); }
blockquote.read-aloud {
  margin: .6em 0 1em; padding: 10px 14px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, var(--accent-soft), transparent); font-family: var(--serif); font-size: 1.04em; font-style: italic;
}
blockquote.read-aloud p:last-child { margin: 0; }

/* ---------- Notes ---------- */
.notes { display: grid; grid-template-columns: 190px 1fr; gap: 12px; height: 100%; }
.notes-nav { display: flex; flex-direction: column; gap: 6px; min-height: 0; border-right: 1px solid var(--line); padding-right: 10px; }
.notes-list { overflow: auto; display: grid; gap: 1px; align-content: start; }
.note-link { display: flex; align-items: center; gap: 6px; text-align: left; border: 0; background: none; color: var(--text-2); padding: 5px 7px; border-radius: 6px; cursor: pointer; font: 13px var(--font); }
.note-link span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-link small { font-size: 10.5px; }
.note-link:hover { background: var(--panel-2); }
.note-link.active { background: var(--accent-soft); color: var(--accent); }
.note-link.chapter { font-weight: 600; margin-top: 6px; color: var(--text); }
.note-link.chapter:first-child { margin-top: 0; }
.note-link.session { padding-left: 14px; }
.note-link .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); flex-shrink: 0; }
.notes-main { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.note-head h2 { margin: 0; }
.note-head { display: grid; gap: 6px; }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.md-toolbar span { margin-left: auto; }
.note-editor { flex: 1; min-height: 260px; }
.note-foot { display: flex; gap: 6px; justify-content: flex-end; padding-top: 6px; margin-top: auto; border-top: 1px solid var(--line); }
@container (max-width: 520px) {
  .notes { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .notes-nav { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 6px; max-height: 120px; }
}

/* ---------- Party ---------- */
.party-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.pc { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; display: grid; gap: 7px; cursor: pointer; }
.pc:hover { border-color: var(--line-2); }
.pc.is-down { border-color: rgba(217, 97, 75, .55); background: color-mix(in srgb, var(--bad) 7%, var(--panel-2)); }
.pc-top { display: flex; align-items: center; gap: 9px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--panel-3); border: 1px solid var(--line-2); }
.avatar.ph { display: grid; place-items: center; font: 600 16px var(--serif); color: var(--accent); }
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.pc-name { flex: 1; min-width: 0; display: grid; }
.pc-name b { font: 600 14.5px var(--serif); }
.pc-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.insp { color: var(--accent); }
.pc-ac, .cb-ac { position: relative; display: grid; place-items: center; color: var(--line-2); flex-shrink: 0; }
.pc-ac b, .cb-ac b { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); font: 700 13px var(--font); padding-bottom: 2px; }
.pc-hp { display: grid; gap: 3px; border: 0; background: none; color: var(--text); padding: 0; cursor: pointer; text-align: left; font: 13px var(--font); }
.pc-hp b { font-size: 16px; }
.hpbar { position: relative; height: 7px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.hpbar > div { height: 100%; background: var(--good); border-radius: 4px; transition: width .3s ease; }
.hpbar.low > div { background: var(--warn); }
.hpbar.crit > div { background: var(--bad); }
.hpbar.down > div { background: transparent; }
.hpbar .temp { position: absolute; top: 0; right: 0; height: 100%; background: var(--info); opacity: .8; }
.temp-txt { color: var(--info); font-weight: 600; }
.ds { font-size: 12px; letter-spacing: .05em; }
.pc-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.pc-stats span { display: grid; line-height: 1.2; }
.pc-stats small { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pc-detail { grid-column: 1 / -1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px; display: grid; gap: 6px; }
.abil-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; text-align: center; }
.abil-row div { display: grid; gap: 2px; justify-items: center; }
.abil-row small { color: var(--muted); font-size: 10.5px; letter-spacing: .05em; }
.abil-row .roll.save { font-size: 11px; font-weight: 500; }

/* ---------- Combat ---------- */
.cb-list { display: grid; gap: 4px; }
.cb {
  display: grid; grid-template-columns: 46px minmax(140px, 1fr) 34px 96px 150px auto; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; position: relative;
}
.cb.monster { border-left: 3px solid rgba(217, 97, 75, .55); }
.cb.pc { border-left: 3px solid rgba(111, 154, 214, .6); }
.cb.npc { border-left: 3px solid rgba(121, 179, 111, .6); }
.cb.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 18px var(--accent-soft); background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }
.cb.current::before { content: '▶'; position: absolute; left: -14px; color: var(--accent); font-size: 11px; }
.cb.out { opacity: .5; }
.cb.out .cb-name b { text-decoration: line-through; }
.cb.hidden-cb { background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(255, 255, 255, .02) 8px 16px); }
.init { width: 46px; text-align: center; font: 700 16px var(--font); background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; color: var(--text); padding: 4px 2px; -moz-appearance: textfield; }
.init::-webkit-inner-spin-button { display: none; }
.cb-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cb-name { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.cb-name .link { border: 0; background: none; color: var(--text); padding: 0; cursor: pointer; font: 600 14px var(--serif); text-align: left; }
.cb-name .link:hover { color: var(--accent); }
.cb-conds { display: flex; flex-wrap: wrap; gap: 3px; width: 100%; }
.cb-conds .chip { padding: 0 7px; font-size: 11px; }
.cb-hp { display: grid; gap: 3px; font-size: 13px; }
.cb-hp b { font-size: 15px; }
.cb-dmg { display: flex; gap: 3px; }
.cb-dmg input { width: 64px; }
.cb-icons { display: flex; gap: 1px; }
.cb-open { margin: -2px 0 4px 54px; padding: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; display: grid; gap: 8px; }
.cb-log { margin-top: 10px; font-size: 12px; color: var(--text-2); }
.cb-log summary { cursor: pointer; color: var(--muted); }
.cb-log div { padding: 2px 0; border-bottom: 1px solid var(--line); }
@container (max-width: 640px) {
  .cb { grid-template-columns: 42px 1fr 30px 84px; }
  .cb-dmg { grid-column: 2 / 4; }
  .cb-icons { grid-column: 4; justify-content: flex-end; }
  .cb-open { margin-left: 0; }
}
.mon-list { display: grid; gap: 4px; margin: 10px 0; max-height: 50vh; overflow: auto; }
.mon-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.mon-item > span { flex: 1; }

/* Stat block */
.statblock { font-size: 13px; display: grid; gap: 5px; }
.sb-top { display: flex; gap: 10px; align-items: center; }
.sb-top img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.sb-name { font: 600 16px var(--serif); color: var(--accent); }
.sb-line { padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.sb-abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.roll.abil { display: grid; justify-items: center; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 3px 0; border-radius: 6px; font-weight: 400; }
.roll.abil span { font-size: 10px; color: var(--muted); letter-spacing: .05em; }
.roll.abil small { color: var(--accent); font-weight: 600; }
.roll.abil:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.statblock h5 { margin: 6px 0 2px; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.statblock p { margin: 0 0 4px; }
.sb-html p { margin: 0 0 4px; }

/* ---------- Dice ---------- */
.dice { display: grid; gap: 8px; }
.dice .seg { justify-self: start; }
.dice-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 5px; }
.die { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 8px 0; font: 600 13px var(--font); cursor: pointer; }
.die:hover { border-color: var(--accent); color: var(--accent); }
.die:active { transform: scale(.96); }
.macros { display: flex; flex-wrap: wrap; gap: 4px; }
.dice-log { display: grid; gap: 3px; }
.log-row { display: flex; align-items: center; gap: 9px; padding: 4px 6px; border-radius: 7px; background: var(--panel-2); font-size: 12.5px; }
.log-row > div { flex: 1; min-width: 0; display: grid; }
.log-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row s { opacity: .6; }
.total { font: 700 18px var(--serif); min-width: 34px; text-align: center; color: var(--accent); }
.log-row.crit .total { color: var(--good); }
.log-row.fumble .total { color: var(--bad); }

/* ---------- Audio ---------- */
.audio { display: grid; gap: 8px; }
.now { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.mixbar { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 8px 0; color: var(--muted); }
.mixbar label { display: flex; align-items: center; gap: 6px; }
.mixbar .vol { width: 110px; }
.now.playing { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.now-title { flex: 1; min-width: 0; display: grid; }
.now-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eq { display: flex; gap: 2px; align-items: end; height: 14px; }
.eq i { width: 3px; background: var(--accent); animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 14px; } }
.tracks { display: grid; gap: 2px; }
.track { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 7px; }
.track:hover { background: var(--panel-2); }
.track.active { background: var(--accent-soft); }
.track-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Hidden YouTube players (music and sound effects). Kept rendered off-screen, not display:none. */
.yt-hidden { position: fixed; left: -10000px; top: 0; width: 320px; pointer-events: none; opacity: 0; }
#yt-sfx { display: flex; flex-wrap: wrap; width: 2200px; }
#yt-music.shown { left: 14px; top: auto; bottom: 14px; opacity: 1; pointer-events: auto; z-index: 45; background: #000; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.yt-mini-bar { display: none; }
#yt-music.shown .yt-mini-bar { display: flex; align-items: center; justify-content: space-between; padding: 3px 4px 3px 10px; font-size: 11.5px; color: #ccc; background: #111; }
#yt-music iframe { display: block; }

/* ---------- Soundboard ---------- */
.sfx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.sfx {
  position: relative; min-height: 54px; padding: 8px 6px; border-radius: 9px; cursor: pointer; color: var(--text);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 26%, var(--panel-2)), color-mix(in srgb, var(--c) 12%, var(--panel-2)));
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line)); font: 600 12.5px var(--font); line-height: 1.2;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 30%, #000); transition: transform .05s;
}
.sfx:hover { filter: brightness(1.12); }
.sfx:active, .sfx.hit { transform: translateY(2px); box-shadow: none; }
.sfx.hit { animation: hit .35s ease; }
@keyframes hit { 0% { box-shadow: 0 0 0 0 var(--c); } 100% { box-shadow: 0 0 0 10px transparent; } }
.sfx kbd { position: absolute; top: 3px; left: 4px; font-size: 9px; padding: 0 3px; }
.sfx-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--bad); color: #fff; }

/* Soundboard as pictures: one drawing per sound, its name on hover (js/data/sfxicons.js). */
.sfx-grid.ico { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 7px; }
.sfx-grid.ico.named { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
.sfx.ico {
  display: grid; place-items: center; align-content: center; gap: 4px; aspect-ratio: 1; min-height: 0; padding: 6px 4px;
  color: color-mix(in srgb, var(--c) 62%, #fff);
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 26%, transparent), transparent 72%), var(--panel-2);
  border: 1px solid color-mix(in srgb, var(--c) 38%, var(--line)); border-radius: 12px; box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 25%, #000);
  transition: transform .12s, filter .15s, box-shadow .2s, border-color .2s;
}
.sfx-grid.ico.named .sfx.ico { aspect-ratio: auto; min-height: 70px; }
[data-theme="light"] .sfx.ico { color: color-mix(in srgb, var(--c) 75%, #000); }
.sfx.ico:hover { transform: translateY(-1px); filter: brightness(1.15); }
.sfx.ico:active, .sfx.ico.hit { transform: translateY(1px) scale(.96); }
.sfx-ic { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--c) 55%, transparent)); transition: transform .2s; }
.sfx.ico:hover .sfx-ic { transform: scale(1.08); }
.sfx.ico.hit .sfx-ic { animation: sfx-pop .35s ease; }
@keyframes sfx-pop { 40% { transform: scale(1.22) rotate(-6deg); } }
.sfx-name { font: 600 10.5px/1.15 var(--font); color: var(--text-2); text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sfx.ico.synth { border-style: dashed; }
.sfx.ico kbd { top: 3px; left: 3px; }
.sfx-tip {
  position: fixed; z-index: 90; left: 0; top: 0; display: grid; gap: 1px; max-width: 220px; padding: 6px 10px; pointer-events: none;
  background: var(--tip-bg, var(--panel-2)); color: var(--text); border: 1px solid var(--tip-line, var(--line-2)); border-radius: 8px;
  box-shadow: var(--shadow); font: 600 12.5px/1.3 var(--font); text-align: center;
  opacity: 0; translate: 0 4px; transition: opacity .12s, translate .12s;
}
.sfx-tip.below { translate: 0 -4px; }
.sfx-tip.on { opacity: 1; translate: 0 0; }
.sfx-tip small { font-weight: 500; font-size: 11px; color: var(--muted); }
.sfx-tip::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; border-radius: 8px 8px 0 0; background: var(--c, var(--accent)); opacity: .8; }
html.fantasy .sfx-tip { font-family: var(--caps); font-weight: 400; letter-spacing: .04em; border-color: var(--frame-hi); background: linear-gradient(180deg, #1a1f38, #0e1123); }
html.fantasy .sfx-tip small { font-family: var(--font); letter-spacing: 0; }
@media (prefers-reduced-motion: reduce) { .sfx.ico, .sfx-ic, .sfx-tip { transition: none; } .sfx.ico.hit .sfx-ic { animation: none; } }

/* ---------- Rules ---------- */
.rules { display: grid; gap: 8px; }
.rule { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.rule summary { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; cursor: pointer; list-style: none; }
.rule summary::-webkit-details-marker { display: none; }
.rule summary b { font-family: var(--serif); }
.rule[open] summary { border-bottom: 1px solid var(--line); }
.rule .prose { padding: 8px 12px 4px; font-size: 13.5px; }
.rule-list { display: grid; gap: 4px; }

/* ---------- Directory & entries ---------- */
.dir { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 12px; height: 100%; }
.dir-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.dir-search { display: flex; gap: 5px; }
/* Only the list shrinks and scrolls: the search, source switch and filters keep their size however
   long the list gets (a big imported book used to squash them flat). */
.dir-side > :not(.dir-list) { flex-shrink: 0; }
.dir-list { overflow: auto; display: grid; gap: 2px; align-content: start; flex: 1 1 auto; min-height: 0; }
.dir-detail { min-height: 0; overflow: auto; border-left: 1px solid var(--line); padding-left: 12px; }
@container (max-width: 640px) {
  .dir { grid-template-columns: 1fr; }
  .dir.has-sel .dir-side { display: none; }
  .dir:not(.has-sel) .dir-detail { display: none; }
  .dir-detail { border: 0; padding: 0; }
}
.answer { display: flex; gap: 7px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 13px; }
.answer span { flex: 1; }
.answer .ic { margin-top: 2px; color: var(--accent); flex-shrink: 0; }
.entry-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px; border: 0; background: none; color: var(--text); text-align: left; border-radius: 8px; cursor: pointer; font: 13px var(--font); }
.entry-row:hover { background: var(--panel-2); }
.entry-row.active { background: var(--accent-soft); }
.entry-row img { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; flex-shrink: 0; }
.entry-dot { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; font: 600 14px var(--serif); color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.entry-main { flex: 1; min-width: 0; display: grid; }
.entry-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revealed { color: var(--good); }
.type-badge { display: inline-block; font: 600 10px var(--font); letter-spacing: .05em; text-transform: uppercase; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); padding: 1px 6px; border-radius: 4px; vertical-align: 1px; }
.entry { display: grid; gap: 10px; }
.entry-head { display: flex; align-items: flex-start; gap: 8px; }
.entry-title { flex: 1; min-width: 0; display: grid; gap: 4px; }
.entry-title h3 { margin: 0; font-size: 1.35rem; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.entry-meta .input { width: auto; flex: 1; min-width: 110px; }
.drawer .entry-head { padding-right: 34px; }
.entry-body { display: grid; gap: 12px; }
.entry-body section { display: grid; gap: 4px; }
.entry-body h4 { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-2); font-size: .92rem; }
.entry-body h4 small { font: 11px var(--font); }
.entry-img img { max-width: 100%; max-height: 260px; border-radius: 10px; display: block; margin-bottom: 6px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.fields > div, .fields > label { display: grid; gap: 1px; font-size: 13px; }
.fields span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.player-sec { background: color-mix(in srgb, var(--good) 6%, transparent); border: 1px dashed color-mix(in srgb, var(--good) 35%, transparent); padding: 8px 10px; border-radius: 9px; }
.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; }
.links li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.links a { font-weight: 600; text-decoration: none; }
.entry-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- NPC generator & dialogue ---------- */
.npcgen, .dialogue, .loot { display: grid; gap: 10px; align-content: start; }
.opts select { width: auto; flex: 1; min-width: 100px; }
.npc-head { display: grid; gap: 2px; }
.npc-top { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.npc-top .npc-head { flex: 1; min-width: 0; }
.npc-face { position: relative; flex: none; width: 96px; margin: 0; border-radius: 10px; overflow: hidden; background: var(--panel-2); box-shadow: 0 0 0 1px var(--line); }
.npc-face img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.npc-face.locked { box-shadow: 0 0 0 2px var(--accent); }
.npc-face .npc-ctl { position: absolute; right: 3px; bottom: 3px; gap: 2px; opacity: 0; transition: opacity .15s; }
.npc-face .npc-ctl .icon-btn { background: rgba(0,0,0,.6); color: #fff; }
.npc-face:hover .npc-ctl, .npc-face:focus-within .npc-ctl, .npc-face.locked .npc-ctl { opacity: 1; }
@media (hover: none) { .npc-face .npc-ctl { opacity: 1; } }
.npc-fields { margin: 0; display: grid; gap: 2px; }
.npc-fields > div { display: grid; grid-template-columns: 100px 1fr auto; gap: 8px; padding: 4px 6px; border-radius: 6px; align-items: start; }
.npc-fields > div:hover { background: var(--panel-2); }
.npc-fields > div.locked { background: var(--accent-soft); }
.npc-fields dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 2px; }
.npc-fields dd { margin: 0; outline: none; border-radius: 4px; }
.npc-fields dd:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.npc-ctl { display: flex; opacity: .35; }
.npc-fields > div:hover .npc-ctl, .npc-fields > div.locked .npc-ctl { opacity: 1; }
.dlg-out { display: grid; gap: 6px; }
.say { padding: 7px 10px; border-radius: 8px; background: var(--panel-2); font-family: var(--serif); font-size: 14.5px; cursor: copy; border: 1px solid transparent; }
.say:hover { border-color: var(--line-2); }
.say.copied { border-color: var(--good); }
.say.greet { border-left: 3px solid var(--accent); }
.say.rumor { border-left: 3px solid var(--magic); }
.lines { margin: 0; padding-left: 1.4em; display: grid; gap: 5px; }
.lines li { list-style: decimal; }
.say-meta { font-size: 13px; color: var(--text-2); padding: 0 4px; }
.voice-tip { font-size: 13px; color: var(--muted); font-style: italic; }

/* ---------- Player screen control ---------- */
.bc { display: grid; gap: 14px; }
.bc section { display: grid; gap: 6px; }
.bc h4 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .95rem; }
.bc-share { background: var(--panel-2); border-radius: 9px; padding: 8px 10px; }
.copyable { cursor: copy; }
.bc-compose { background: var(--panel-2); border-radius: 9px; padding: 10px; border: 1px dashed var(--line-2); }
.panel-body.dropping .bc-compose { border-color: var(--accent); background: var(--accent-soft); }
.bc-compose .seg { justify-self: start; }
.bc-now { display: flex; align-items: center; gap: 10px; position: relative; }
.bc-now img { width: 120px; height: 72px; object-fit: cover; border-radius: 8px; }
.pins { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.pin { position: relative; display: grid; gap: 3px; }
.pin img, .note-thumb { width: 100%; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.note-thumb { background: var(--panel-2); padding: 6px; overflow: hidden; font-size: 11px; }
.note-thumb p { margin: 0; color: var(--muted); }
.pin small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-ctl { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; background: rgba(0, 0, 0, .65); border-radius: 6px; opacity: 0; transition: opacity .15s; }
.pin:hover .pin-ctl { opacity: 1; }
.pin-ctl .icon-btn { color: #fff; }
.yt-badge { position: absolute; left: 50%; top: 36px; transform: translate(-50%, -50%); background: rgba(0, 0, 0, .7); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-size: 11px; }
.bc-now .yt-badge { left: 60px; }
.reminders { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.reminders li { display: flex; gap: 4px; }

/* ---------- Settings & login ---------- */
.settings { display: grid; gap: 18px; }
.settings section { display: grid; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.settings section:last-child { border: 0; }
.settings h3 { margin: 0; }
.settings ol { margin: 6px 0; padding-left: 1.3em; display: grid; gap: 3px; }
.settings details summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: min(360px, 92vw); display: grid; gap: 12px; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.login-card h1 { color: var(--accent); margin: 0; }
.cb-name > .tag { align-self: center; line-height: 1.5; }

/* Party: inactive players and status chips */
.pc-bench { margin-left: -4px; align-self: flex-start; opacity: .45; }
.pc:hover .pc-bench { opacity: 1; }
.pc-items { margin-left: -4px; align-self: flex-start; opacity: .45; }
.pc:hover .pc-items { opacity: 1; }
.chip.cond.ddb { cursor: default; border-style: dashed; }
.bench { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.bench-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); cursor: pointer; font: 500 12.5px var(--font); }
.bench-chip:hover { color: var(--text); border-color: var(--accent); }
.bench-chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; filter: grayscale(1); }
.switch { width: 26px; height: 15px; border-radius: 999px; background: var(--line-2); position: relative; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; left: 2px; top: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--muted); transition: left .15s; }
.bench-chip:hover .switch::after { left: 13px; background: var(--accent); }

/* Music player scenes */
.audio-tabs { justify-self: start; }
.scenes { display: grid; gap: 8px; }
.scene-group h5 { margin: 6px 0 5px; }
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 5px; }
.scene { display: flex; align-items: stretch; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); overflow: hidden; }
.scene:hover { border-color: var(--accent); }
.scene-play { flex: 1; display: flex; align-items: center; gap: 6px; text-align: left; padding: 7px 8px 7px 10px; border: 0; background: none; color: var(--text); cursor: pointer; font: 500 12.5px var(--font); min-width: 0; }
.scene-play .ic { color: var(--muted); flex-shrink: 0; }
.scene-play:hover { color: var(--accent); }
.scene-more { border: 0; border-left: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; padding: 0 7px; }
.scene-more:hover { color: var(--text); background: var(--panel-3); }
.scene.active { border-color: var(--accent); background: var(--accent-soft); }
.scene.active .scene-play, .scene.active .scene-play .ic { color: var(--accent); }
.scene.custom .scene-play::after { content: '•'; color: var(--accent); margin-left: auto; }

.sfx.loading { opacity: .7; }
.sfx.synth { border-style: dashed; }
.sfx.lib, .sfx.synth { position: relative; }
.grid-tight { display: grid; gap: 6px; margin-top: 8px; }
.now-title a { color: inherit; text-decoration: underline dotted; }

/* Ask: a conversation with the campaign, the rules reference and the Grimwar guide */
.ask { display: grid; grid-template-rows: auto 1fr auto; gap: 10px; padding-right: 30px; height: 100%; min-height: 0; }
.ask-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ask-top h3 { margin: 0; display: flex; align-items: center; gap: 6px; font-family: var(--serif); }
.ask-top .ask-scope { margin-left: auto; }
.ask-log { overflow-y: auto; display: grid; align-content: start; gap: 8px; padding: 2px 2px 6px; min-height: 0; }
.ask-empty { display: grid; gap: 10px; color: var(--text-2); font-size: 13.5px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-chips .chip { cursor: pointer; font: 500 12.5px var(--font); padding: 4px 10px; }
.ask-q { justify-self: end; max-width: 85%; padding: 7px 11px; border-radius: 12px 12px 4px 12px; background: var(--panel-3); border: 1px solid var(--line); font-size: 13.5px; white-space: pre-wrap; }
.ask-a { display: grid; gap: 7px; padding: 11px 13px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.5; }
.ask-a.nf { border-style: dashed; }
.ask-a p { margin: 0; }
.ask-a h5.ask-part { margin: 8px 0 0; padding-top: 7px; border-top: 1px solid var(--line); font: 600 14px var(--serif); color: var(--text); }
.ask-a h5.ask-part:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.ask-pv { border-color: color-mix(in srgb, var(--good) 55%, transparent); color: var(--good); }
.ask-pvt { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); }
.ask-a h6 { margin: 4px 0 0; font: 600 11.5px var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ask-a-head { display: flex; align-items: center; gap: 6px; }
.ask-layer { font: 600 10.5px var(--font); letter-spacing: .05em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); }
.ask-busy { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.ask-quote { margin: 0; padding: 4px 10px; border-left: 3px solid var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 0 8px 8px 0; }
.ask-rule { padding: 6px 10px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); }
.ask-rule > :last-child { margin-bottom: 0; }
.ask-list, .ask-steps { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.ask-secret { color: var(--muted); }
.ask-secret::after { content: ' (secret)'; font-size: 11.5px; }
.ask-table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.ask-table th, .ask-table td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; vertical-align: top; }
.ask-table thead th { background: var(--panel-3); }
.ask-table.plain th { width: 34%; color: var(--muted); font-weight: 500; }
.ask-cite-line { text-align: right; margin-top: -4px !important; }
.ask-note { display: flex; gap: 7px; align-items: flex-start; padding: 7px 10px; border-radius: 9px; font-size: 12.5px; border: 1px solid var(--line); color: var(--text-2); }
.ask-note .ic { margin-top: 2px; flex-shrink: 0; }
.ask-note.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 9%, transparent); color: var(--text); }
.ask-note.warn .ic { color: var(--warn); }
.ask-note.player .ic { color: var(--good); }
.ask-passage p { margin-top: 2px; color: var(--text-2); }
.ask-ent { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.ask-widen { display: flex; gap: 6px; }
.ask-sources { font-size: 12px; }
.ask-sources summary { cursor: pointer; color: var(--muted); }
.ask-sources[open] summary { margin-bottom: 5px; }
.ask-sources { display: grid; gap: 4px; }
.ask-src { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 5px 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); cursor: pointer; font: 12.5px var(--font); margin-top: 4px; }
.ask-src:hover { border-color: var(--accent); color: var(--text); }
.ask-searched { color: var(--muted); font-size: 11.5px; margin: 0; }
.ask-form { display: flex; gap: 6px; align-items: flex-end; }
.ask-form textarea { flex: 1; resize: none; min-height: 36px; line-height: 1.4; font: 13.5px var(--font); }
.ask-n, .cite { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font: 700 11px var(--font); flex-shrink: 0; }
.cite { border: 0; cursor: pointer; vertical-align: 1px; margin: 0 1px; }
mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }



.input.masked { -webkit-text-security: disc; }

/* Small number boxes leave room for two digits beside the browser's spinner ("22", not "2"). */
input.input.xs[type="number"] { min-width: 56px; }

.modal-wrap.top { place-items: start center; padding-top: max(16px, 6vh); }
.modal-wrap.top .modal { max-height: calc(100vh - max(16px, 6vh) - 16px); }

.mon-item .tag { display: inline-block; font: 600 10px system-ui, sans-serif; padding: 1px 5px; border-radius: 4px; background: var(--accent); color: #111; vertical-align: 1px; }
.mon-item .tag.old { background: var(--muted); }

/* Stat block editor */
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.se-abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 8px 0; }
.se-abil label { font-size: 11px; text-align: center; }
.se-sec { display: block; margin-top: 8px; font-weight: 600; }
.se-sec textarea { width: 100%; font: 13px/1.4 system-ui, sans-serif; margin-top: 3px; }
.se-sec .input.xs { width: 48px; display: inline-block; min-width: 48px; }
.se-h { margin: 12px 0 4px; }
.se-got { margin: 0; padding-left: 18px; font-size: 13px; }
.se-got li { margin: 2px 0; }
@media (max-width: 640px) { .form-grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .se-abil { grid-template-columns: repeat(3, 1fr); } }
.bench-rm { margin-left: -4px; opacity: .55; } .bench-rm:hover { opacity: 1; color: var(--bad); }

/* ---------- Loading placeholders (util.skeleton) ---------- */
.skeleton { display: grid; gap: 9px; padding: 4px 0; }
.sk-caption { margin: 0 0 2px; }
.sk-line { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-3) 0%, color-mix(in srgb, var(--panel-3) 55%, var(--text) 12%) 45%, var(--panel-3) 90%); background-size: 220% 100%; animation: sk-shimmer 1.4s ease-in-out infinite; }
.sk-line:nth-child(3n + 2) { height: 16px; }
@keyframes sk-shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk-line { animation: none; } }
.palette { animation: modal-in .16s cubic-bezier(.21, 1.02, .73, 1); }

/* "About the art" notes beside AI-made stand-in portraits */
.art-note { margin: 8px 0 0; font-size: 12px; line-height: 1.45; }
.npc-head .art-note { display: block; margin-top: 4px; }
.art-note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Top-bar Whispers and Music (3.38.0, js/topmenus.js) ---------- */
.tm-btns { display: inline-flex; gap: 4px; align-items: center; }
.tm-btn { position: relative; }
.tm-badge { position: absolute; top: -3px; right: -4px; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font: 700 10px/15px var(--font); min-width: 15px; padding: 0 4px; text-align: center; pointer-events: none; }
.tm-btn .tm-eq { display: none; position: absolute; bottom: 2px; right: 3px; gap: 1px; align-items: end; height: 7px; }
.tm-btn .tm-eq i { width: 2px; background: var(--accent); animation: tmEq .9s ease-in-out infinite; }
.tm-btn .tm-eq i:nth-child(2) { animation-delay: -.3s; } .tm-btn .tm-eq i:nth-child(3) { animation-delay: -.6s; }
.tm-btn.playing { color: var(--accent); }
.tm-btn.playing .tm-eq { display: flex; }
@keyframes tmEq { 0%, 100% { height: 2px; } 50% { height: 7px; } }

.tm-pop { position: fixed; z-index: 900; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); animation: tmIn .16s var(--ease, ease-out); }
.tm-pop.closing { opacity: 0; transform: translateY(-4px) scale(.98); transition: opacity .12s, transform .12s; }
@keyframes tmIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.tm-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 6px; flex-wrap: wrap; }
.tm-head small { flex-basis: 100%; }
.tm-whispers { width: min(400px, calc(100vw - 16px)); height: min(520px, calc(100vh - 80px)); display: flex; flex-direction: column; }
.tm-whispers .tm-host { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 10px 10px; }
.tm-whispers .tm-ptools:empty { display: none; }
.tm-whispers .tm-pbody { flex: 1; min-height: 0; overflow: auto; }

.tm-music { padding: 10px 12px 12px; width: max-content; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto; }
.tm-radial { position: relative; width: var(--size); height: var(--size); margin: 0 auto; }
.tm-radial::before { content: ''; position: absolute; inset: 34px; border-radius: 50%; border: 1px dashed var(--line-2); }
.tm-spoke { position: absolute; left: 50%; top: 50%; width: 74px; height: 74px; margin: -37px 0 0 -37px; transform: translate(var(--x), var(--y)); }
.tm-music.fresh .tm-spoke { animation: tmSpoke .28s var(--spring, ease-out) both; animation-delay: calc(var(--i) * 18ms); }
@keyframes tmSpoke { from { transform: translate(0, 0) scale(.3); opacity: 0; } to { transform: translate(var(--x), var(--y)); opacity: 1; } }
.tm-bub { width: 100%; height: 100%; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-3); color: var(--text-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px; cursor: pointer; font: 600 11px/1.15 var(--font); text-align: center; transition: border-color .12s, background .12s, color .12s, transform .12s; }
.tm-bub span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 62px; word-break: break-word; }
.tm-bub .ic { color: var(--accent); flex-shrink: 0; }
.tm-bub:hover, .tm-bub:focus-visible { border-color: var(--accent-line); color: var(--text); background: var(--hover), var(--panel-3); transform: scale(1.06); outline: none; }
.tm-spoke.theme .tm-bub { background: var(--panel); }
.tm-spoke.active .tm-bub { border-color: var(--accent); color: var(--accent-hi); background: var(--accent-soft); }
.tm-spoke.on .tm-bub { color: var(--accent); border-color: var(--accent-line); }
.tm-spoke.accent .tm-bub { border-color: var(--accent-line); color: var(--text); }
.tm-spoke.fav .tm-bub .ic, .tm-spoke.faved .tm-bub::after { color: var(--warn); }
.tm-spoke.faved .tm-bub { position: relative; }
.tm-spoke.faved .tm-bub::after { content: '★'; position: absolute; top: 4px; right: 10px; font-size: 10px; }
.tm-deeper { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); font-size: 11px; cursor: pointer; display: grid; place-items: center; }
.tm-deeper:hover { color: var(--accent); border-color: var(--accent-line); }
.tm-hub { position: absolute; left: 50%; top: 50%; width: 118px; height: 118px; margin: -59px 0 0 -59px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; padding: 8px; }
.tm-hub > b { font: 400 17px/1.05 var(--display); color: var(--text); max-width: 96px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tm-hub > small { font-size: 10.5px; max-width: 96px; display: flex; gap: 4px; align-items: center; justify-content: center; }
.tm-hub > .ic { color: var(--accent); }
.tm-hub .eq { height: 9px; } .tm-hub .eq i { width: 2px; }
.tm-back { position: absolute; left: 4px; top: 50%; margin-top: -13px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.tm-back:hover { color: var(--text); background: var(--hover); }
.tm-star { border: 0; background: transparent; color: var(--faint); cursor: pointer; padding: 2px 6px; border-radius: 999px; }
.tm-star:hover { color: var(--warn); }
.tm-star.on { color: var(--warn); }
.tm-star.on .ic { fill: currentColor; }
.tm-play { width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; display: grid; place-items: center; transition: transform .12s; }
.tm-play:hover { transform: scale(1.06); }
.tm-play .ic { fill: currentColor; }
.tm-now-name { font: 400 14px/1.1 var(--display) !important; }
.tm-card { display: grid; gap: 6px; margin: 8px auto 0; max-width: 300px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel); }
.tm-slider { display: grid; grid-template-columns: 16px 64px 1fr; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.tm-slider .ic { color: var(--muted); }
.tm-credit a { color: inherit; }
.tm-favs { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; justify-content: center; margin: 10px auto 0; max-width: 320px; }
.tm-favs > span .ic { color: var(--warn); }
.tm-hint { text-align: center; margin: 10px auto 0; max-width: 280px; }
.tm-hint .ic { color: var(--warn); }
.tm-foot { display: flex; justify-content: center; margin-top: 8px; }
.tm-libhost .tm-ptools { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; }
.tm-libhost .tm-pbody { max-height: 70vh; overflow: auto; }
@media (prefers-reduced-motion: reduce) { .tm-pop, .tm-music.fresh .tm-spoke { animation: none; } .tm-bub:hover { transform: none; } }
@media (max-width: 700px) { .tm-spoke { width: 62px; height: 62px; margin: -31px 0 0 -31px; } .tm-bub span { max-width: 52px; font-size: 10px; } }
/* NPC Generator: their life */
.npc-life { margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.npc-life.locked { background: var(--accent-soft); }
.npc-life > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.npc-life > summary .npc-ctl { margin-left: auto; opacity: 1; }
.npc-life h6 { margin: 10px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.npc-life .life-facts { margin: 6px 0 0; display: grid; gap: 2px; }
.npc-life .life-facts > div { display: grid; grid-template-columns: 100px 1fr; gap: 8px; }
.npc-life .life-facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 2px; }
.npc-life .life-facts dd { margin: 0; }
.npc-life ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.npc-life .life-people li .say { margin-top: 1px; }
.npc-life .life-people li.secret { opacity: .85; }
.npc-life .link { cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); }
.npc-life .lvl { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 10.5px; background: var(--panel-2); color: var(--muted); }
.npc-life .lvl.secret { background: rgba(140, 50, 45, .25); color: #d89a90; }
.npc-life .lvl.close { background: rgba(163, 181, 122, .16); color: #a3b57a; }
.npc-life .feel { margin-left: 6px; font-size: 11px; color: var(--muted); }
.npc-life .feel.f0, .npc-life .feel.f1 { color: #c26b5a; }
.npc-life .feel.f3, .npc-life .feel.f4 { color: #a3b57a; }
.npc-life .stale { background: var(--panel-2); padding: 6px 8px; border-radius: 9px; }
.npc-life .life-day { display: grid; gap: 1px; }
.npc-life .life-day small { display: inline-block; min-width: 72px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.npc-life .when { margin-right: 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.npc-life .life-now dd[contenteditable] { border-radius: 6px; padding: 0 4px; margin-left: -4px; }
.npc-life .life-now dd[contenteditable]:hover, .npc-life .life-now dd[contenteditable]:focus { background: var(--panel-2); outline: none; }
.npc-life .rel-why { margin-left: 6px; }
/* Directory categories: groups, then the open group's categories */
.dir-top { display: flex; gap: 6px; align-items: center; min-width: 0; }
.dir-top .dir-search { flex: 1 1 auto; min-width: 0; }
.dir-top .dir-search .input { min-width: 0; }
.dir-top .dir-book { flex: 0 1 38%; min-width: 84px; width: auto; max-width: 40%; align-self: stretch; }
.dir-ask { padding-left: 8px; padding-right: 8px; }
/* Groups are tabs (one level); the open group's categories are pills under them (the next level). */
.dir-cats { display: flex; flex-direction: column; gap: 8px; }
.dir-tabs { display: flex; border-bottom: 1px solid var(--line-2); }
.dir-tab { flex: 1 1 auto; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 6px 4px; color: var(--muted); font: 600 12.5px var(--font); cursor: pointer; white-space: nowrap; }
.dir-tab:hover:not(:disabled) { color: var(--text); }
.dir-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.dir-tab:disabled { opacity: .35; cursor: default; }
.dir-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.dir-pill { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--text-2); padding: 2px 10px; font: 500 12px var(--font); cursor: pointer; white-space: nowrap; }
.dir-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }
.dir-pill:hover { border-color: var(--muted); color: var(--text); }
.dir-pill.on { border-color: var(--c, var(--accent)); color: var(--c, var(--accent)); background: var(--accent-soft); }
.dir-pill small { opacity: .65; font-variant-numeric: tabular-nums; }

/* Confirming ownership before a book or map upload */
.own-check { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line, rgba(255,255,255,.14)); border-radius: 9px; cursor: pointer; }
.own-check input { margin-top: 3px; }

/* Lite (no account): one table, two screens. The campaign picker, search, layout editing and the
   separate player tab have no place here; the Invite players button replaces them. */
html.lite #campaign-select, html.lite #campaign-menu, html.lite #palette-btn, html.lite #add-panel,
html.lite #layout-menu, html.lite .topbar a[href="/player"], html.lite [data-fs-search] { display: none !important; }
/* No sidebar and one screen: the screens bar goes too; the logo and Settings sit in the top bar. */
html.lite .layout-rail { display: none !important; }
/* The top bar's soundboard (3.60.0): the Music pop-up's ring, with sound pictures and a star on each. */
.tm-sfx .tm-bub .sfx-ic { color: var(--c, var(--accent)); flex-shrink: 0; }
.tm-sfx .tm-hub > .sfx-ic { color: var(--accent); }
.tm-sfx .tm-spoke.sfx-spoke.faved .tm-bub::after { content: none; }
.tm-sfx .tm-sfav { font-size: 12px; }
.tm-sfx .tm-sfav.on { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.tm-sfx .tm-bub.hit { animation: tmSfxHit .35s ease-out; }
.tm-sfx .tm-slider > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-sfx .tm-slider .row { display: flex; align-items: center; gap: 4px; }
.tm-sfx .tm-slider .row input { flex: 1; min-width: 0; }
.tm-sfx-btn.hit { animation: tmSfxFlash .5s ease-out; }
@keyframes tmSfxHit { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c, var(--accent)) 60%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes tmSfxFlash { 0% { color: var(--accent); background: var(--accent-soft); } 100% { color: inherit; background: transparent; } }
@media (prefers-reduced-motion: reduce) { .tm-sfx .tm-bub.hit, .tm-sfx-btn.hit { animation: none; } }
.tm-sfx .tm-slider > input.vol { width: 100%; }
