/* ==========================================================================
   Messiah Ledger. A campaign codex: ink sidebar, warm paper or deep-space
   content, one colour per Messiah. Tokens first; themes swap tokens only.
   ========================================================================== */
:root {
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius-lg: 16px; --radius: 12px; --radius-sm: 8px; --radius-xs: 6px;
  --sidebar-w: 268px; --topbar-h: 64px;

  /* light: warm paper */
  --bg: #f4f2ee;
  --bg-glow-1: rgba(124, 92, 255, .10);
  --bg-glow-2: rgba(245, 158, 11, .08);
  --surface: #ffffff;
  --surface-2: #f7f5f1;
  --surface-3: #eeebe5;
  --raised: #ffffff;
  --line: #e6e2da;
  --line-strong: #d3cdc2;
  --ink: #18171d;
  --ink-2: #4b4855;
  --ink-3: #7a7684;
  --accent: #6d4aff;
  --accent-ink: #5534e6;
  --accent-soft: #efeaff;
  --accent-line: #c9bcff;
  --gold: #b7791f;
  --gold-soft: #fbf1dc;
  --ok: #15803d; --ok-soft: #e5f5ea;
  --warn: #b45309; --warn-soft: #fdf1df;
  --danger: #c2261d; --danger-soft: #fde9e7;
  --hatch: repeating-linear-gradient(135deg, transparent 0 7px, rgba(24, 23, 29, .04) 7px 14px);
  --shadow-sm: 0 1px 2px rgba(24, 23, 29, .06);
  --shadow: 0 1px 2px rgba(24, 23, 29, .05), 0 4px 16px -4px rgba(24, 23, 29, .08);
  --shadow-lg: 0 28px 70px -18px rgba(24, 23, 29, .35), 0 2px 6px rgba(24, 23, 29, .06);
  --focus: 0 0 0 3px rgba(109, 74, 255, .28);

  /* the sidebar is ink in both themes */
  --side-bg: #101118;
  --side-bg-2: #171823;
  --side-ink: #e9e7f2;
  --side-ink-2: #a6a3b8;
  --side-line: #262838;
  --side-active: rgba(167, 139, 250, .14);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0c12;
  --bg-glow-1: rgba(124, 92, 255, .16);
  --bg-glow-2: rgba(245, 158, 11, .07);
  --surface: #13141c;
  --surface-2: #181a24;
  --surface-3: #20222e;
  --raised: #1a1c26;
  --line: #262838;
  --line-strong: #353849;
  --ink: #ecebf3;
  --ink-2: #b9b6c8;
  --ink-3: #8a879b;
  --accent: #a78bfa;
  --accent-ink: #c4b5fd;
  --accent-soft: rgba(167, 139, 250, .14);
  --accent-line: rgba(167, 139, 250, .45);
  --gold: #f5b544;
  --gold-soft: rgba(245, 181, 68, .13);
  --ok: #4ade80; --ok-soft: rgba(74, 222, 128, .12);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
  --danger: #f87171; --danger-soft: rgba(248, 113, 113, .13);
  --hatch: repeating-linear-gradient(135deg, transparent 0 7px, rgba(255, 255, 255, .035) 7px 14px);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .04);
  --focus: 0 0 0 3px rgba(167, 139, 250, .35);
  --side-bg: #0a0b10;
  --side-bg-2: #12131b;
  --side-line: #1f2130;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-xs); }
::selection { background: var(--accent-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar {
  background: linear-gradient(180deg, var(--side-bg-2), var(--side-bg) 40%);
  color: var(--side-ink);
  border-right: 1px solid var(--side-line);
  display: flex; flex-direction: column; min-height: 0;
  padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: inherit; text-decoration: none; }
.sigil {
  width: 38px; height: 38px; border-radius: 12px; flex: none; position: relative;
  background: radial-gradient(circle at 30% 25%, #2a2340, #12111a 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 6px 18px -6px rgba(167,139,250,.6);
  display: grid; place-items: center;
}
.sigil::before { content: ''; width: 20px; height: 20px; border-radius: 50%; border: 3px solid transparent;
  background: linear-gradient(135deg, #c4b5fd, #f59e0b) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.sigil span { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, #ddd6fe, #fbbf24); box-shadow: 0 0 10px #fbbf24; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font: 800 17px/1.1 var(--font-display); letter-spacing: -.01em; }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-ink-2); margin-top: 3px; }
#nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--side-ink-2); opacity: .75; padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: var(--side-ink-2); text-decoration: none; font-weight: 520; position: relative;
  transition: background .15s, color .15s;
}
.nav-item svg.i { width: 17px; height: 17px; }
.nav-item:hover { background: rgba(255,255,255,.05); color: var(--side-ink); }
.nav-item.active { background: var(--side-active); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; left: -4px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: linear-gradient(#c4b5fd, #f59e0b); }
.nav-item .count { margin-left: auto; font: 500 11.5px var(--font-mono); color: var(--side-ink-2); opacity: .8; }
.nav-item .pill { margin-left: auto; font: 700 11px var(--font-mono); padding: 1px 7px; border-radius: 99px; background: rgba(251,191,36,.16); color: #fbbf24; }
.sidebar-foot { border-top: 1px solid var(--side-line); margin-top: 10px; padding: 12px 8px 2px; font-size: 12px; color: var(--side-ink-2); display: flex; flex-direction: column; gap: 8px; }
.mode-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; color: var(--side-ink); }
.mode-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.mode-badge.dm .dot { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }

.column { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  position: relative; z-index: 30;
}
.topbar-spacer { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; height: 38px; min-width: 0; width: min(420px, 40vw); padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-3); cursor: pointer;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger .label { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd { font: 600 11px var(--font-mono); padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--ink-3); background: var(--surface-2); }
.save-status { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.save-status.saving { color: var(--ink-2); }
.save-status.saving::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.save-status.saved { color: var(--ok); }
.save-status.error { color: var(--danger); font-weight: 650; cursor: pointer; }
@keyframes pulse { 50% { opacity: .3; } }
.main { flex: 1; overflow: auto; padding: 28px 30px 60px; min-width: 0; scroll-padding-top: 20px; }
.scrim { display: none; }
.only-mobile { display: none !important; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(5, 5, 10, .5); z-index: 55; backdrop-filter: blur(2px); }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 0 12px; gap: 6px; }
  .search-trigger { width: auto; flex: 1; }
  .main { padding: 18px 16px 48px; }
  .hide-narrow { display: none !important; }
}
@media (max-width: 560px) {
  .search-trigger { flex: 0 0 auto; width: 38px; padding: 0; justify-content: center; }
  .search-trigger .label, .search-trigger .kbd, .save-status .label { display: none; }
  #switchViewBtn .label, #undoBtn .label { display: none; }
}

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
:root[data-theme="dark"] .btn.primary { color: #120d24; }
.btn.primary:hover:not(:disabled) { background: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.on { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.input, .select, textarea.input {
  height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  min-width: 0; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); outline: none; box-shadow: var(--focus); }
.input::placeholder, textarea.input::placeholder { color: var(--ink-3); }
.select { padding-right: 32px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.select.sm, .input.sm { height: 30px; font-size: 12.5px; border-radius: 8px; }
.search { position: relative; flex: 1 1 260px; min-width: 180px; max-width: 460px; }
.search .input { width: 100%; padding-left: 36px; }
.search svg { position: absolute; left: 12px; top: 11px; color: var(--ink-3); }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-3); gap: 2px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 11px; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; font-weight: 550; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ------------------------------------------------------------------ page header & toolbar */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font: 800 30px/1.05 var(--font-display); letter-spacing: -.025em; margin: 0; }
.page-head .sub { color: var(--ink-3); font-size: 13.5px; margin-top: 6px; display: flex; gap: 6px 14px; flex-wrap: wrap; }
.page-head .sub b { color: var(--ink-2); font-weight: 650; font-family: var(--font-mono); font-size: 12.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.filter-summary { font-size: 12.5px; color: var(--ink-3); margin: 2px 0 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-height: 24px; }
.chip-filter { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 600; }
.chip-filter button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 4px; font-size: 15px; line-height: 1; border-radius: 99px; }
.edit-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; font-weight: 550;
  background: linear-gradient(90deg, var(--gold-soft), transparent); color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent);
}

/* ------------------------------------------------------------------ the powers grid */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: auto; max-height: calc(100dvh - var(--topbar-h) - 210px); box-shadow: var(--shadow); position: relative; }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 11px 12px; text-align: left; vertical-align: top; background: var(--surface); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid th {
  position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap; border-bottom: 1px solid var(--line-strong); padding-top: 12px; padding-bottom: 10px;
}
.grid th.sortable { cursor: pointer; user-select: none; }
.grid th.sortable:hover { color: var(--ink); }
.grid th.c-messiah { box-shadow: inset 0 3px 0 var(--mc, var(--line-strong)); }
.grid th .mh { display: flex; align-items: center; gap: 8px; }
.grid th .mh .n { font: 600 10.5px var(--font-mono); color: var(--ink-3); background: var(--surface-3); padding: 1px 6px; border-radius: 99px; letter-spacing: 0; }
.grid .c-num { position: sticky; left: 0; z-index: 2; width: 64px; min-width: 64px; }
.grid .c-power { position: sticky; left: 64px; z-index: 2; width: 320px; min-width: 260px; max-width: 320px; border-right: 1px solid var(--line); box-shadow: 10px 0 14px -12px rgba(0,0,0,.18); }
.grid th.c-num, .grid th.c-power { z-index: 4; }
.grid td.c-messiah { min-width: 210px; max-width: 290px; }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); }
.grid tr.is-hidden td.c-power, .grid tr.is-hidden td.c-num { background-image: var(--hatch); }
.power-no { font: 700 12.5px var(--font-mono); color: var(--ink-3); letter-spacing: -.02em; }
.power-no.none { font-weight: 500; opacity: .6; }
.power-name { font: 650 14.5px/1.3 var(--font-display); letter-spacing: -.005em; color: var(--ink); cursor: pointer; border: 0; background: none; padding: 0; text-align: left; display: inline; }
.power-name:hover { color: var(--accent-ink); }
.power-name.unknown { color: var(--ink-3); font-style: italic; font-weight: 500; }
.power-desc { color: var(--ink-3); font-size: 12.8px; line-height: 1.45; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.num-cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.holders { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.holder {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; border-radius: 99px; padding: 2px 8px 2px 2px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; line-height: 1.25; transition: border-color .15s, background .15s;
}
.holder:hover { border-color: var(--line-strong); background: var(--surface); }
.holder .hn { cursor: pointer; border: 0; background: none; padding: 0; text-align: left; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.holder .hn:hover { color: var(--accent-ink); }
.holder .rn { color: var(--ink-3); font-weight: 450; }
.holder.is-hidden { background-image: var(--hatch); border-style: dashed; }
.holder.match { border-color: var(--accent); box-shadow: var(--focus); }
.avatar {
  --c: var(--accent);
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font: 700 9.5px/1 var(--font-ui); letter-spacing: .02em; color: #fff;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.avatar.lg { width: 56px; height: 56px; font-size: 19px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--c) 55%, transparent); }
.avatar.md { width: 34px; height: 34px; font-size: 12px; }
.role { font: 700 9.5px/1.5 var(--font-ui); text-transform: uppercase; letter-spacing: .07em; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.role.primary { background: var(--ok-soft); color: var(--ok); }
.role.secondary { background: var(--accent-soft); color: var(--accent-ink); }
.role.lost { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; }
.role.undecided { background: var(--warn-soft); color: var(--warn); }
.role.acquired { background: color-mix(in srgb, #d946ef 15%, transparent); color: #c026d3; }
:root[data-theme="dark"] .role.acquired { color: #f0abfc; }
.status-chip { display: inline-flex; align-items: center; gap: 4px; font: 700 10.5px/1.6 var(--font-ui); letter-spacing: .08em; padding: 1px 8px; border-radius: 99px; border: 1px dashed var(--line-strong); color: var(--ink-3); }
.status-chip.note { font-weight: 450; letter-spacing: 0; font-style: italic; max-width: 260px; white-space: normal; text-align: left; border-radius: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font: 650 11px/1.6 var(--font-ui); padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge svg.i { width: 12px; height: 12px; }
.eye { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; padding: 0; flex: none; transition: background .15s, color .15s; }
.eye:hover { background: var(--surface-3); color: var(--ink); }
.eye.on { color: var(--ok); }
.eye.static { cursor: default; }
.eye.static:hover { background: transparent; }
.eye svg.i { width: 15px; height: 15px; }
.cell-add { border: 1px dashed var(--line-strong); background: transparent; color: var(--ink-3); border-radius: 99px; height: 24px; padding: 0 10px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.cell-add:hover { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.x-btn { border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 0 3px; font-size: 15px; line-height: 1; border-radius: 99px; }
.x-btn:hover { color: var(--danger); background: var(--danger-soft); }
.inline-input { width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font: 650 14px var(--font-display); }
.inline-input:focus { border-color: var(--accent); outline: none; box-shadow: var(--focus); }
.inline-input.num { width: 56px; font: 600 12.5px var(--font-mono); }
.empty-state { padding: 56px 20px; text-align: center; color: var(--ink-3); }
.empty-state h3 { color: var(--ink); margin: 0 0 6px; font: 700 18px var(--font-display); }

/* ------------------------------------------------------------------ cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.card.is-hidden { background-image: var(--hatch); }
.card .band { position: absolute; inset: 0 0 auto 0; height: 4px; display: flex; }
.card .band span { flex: 1; }
.card-head { display: flex; gap: 10px; align-items: flex-start; }
.card-head .title { flex: 1; min-width: 0; }
.card .desc { color: var(--ink-2); font-size: 13px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .mrow { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.card .mrow .mname { flex: none; width: 96px; color: var(--ink-3); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); align-items: center; }
.card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.char-card { flex-direction: row; gap: 14px; }
.char-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

/* Messiah / universe cards */
.mcard { padding: 0; gap: 0; }
.mcard .glow { height: 92px; position: relative; background:
  radial-gradient(120% 140% at 15% 0%, color-mix(in srgb, var(--c) 55%, transparent), transparent 60%),
  linear-gradient(135deg, color-mix(in srgb, var(--c) 22%, var(--surface-2)), var(--surface-2)); }
.mcard .glow .emblem { position: absolute; left: 18px; bottom: -22px; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 75%, #fff), var(--c)); color: #fff; font: 800 18px var(--font-display);
  box-shadow: 0 0 0 4px var(--surface), 0 10px 24px -8px var(--c); }
.mcard .glow .state { position: absolute; right: 14px; top: 14px; }
.mcard .inner { padding: 32px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.mcard h3 { margin: 0; font: 800 20px/1.15 var(--font-display); letter-spacing: -.015em; }
.mcard .mech { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.mstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mstats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.mstats b { display: block; font: 700 17px var(--font-mono); }
.mstats span { font-size: 11px; color: var(--ink-3); }

/* ------------------------------------------------------------------ lists (characters, history...) */
table.list { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); }
.list th, .list td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.list tbody tr:last-child td { border-bottom: 0; }
.list th { position: sticky; top: 0; background: var(--surface-2); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; z-index: 2; white-space: nowrap; }
.list tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); }
.list .clickable { cursor: pointer; }
.list .sticky-col { position: sticky; left: 0; z-index: 1; }
.list th.sticky-col { z-index: 3; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .names { display: flex; flex-direction: column; min-width: 0; }
.who .names .rn { font-size: 12px; color: var(--ink-3); }
.pw-list { display: flex; flex-wrap: wrap; gap: 5px; }
.pw { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 2px 8px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; transition: border-color .15s; }
.pw:hover { border-color: var(--accent); }
.pw .num { font-size: 11px; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 99px; background: color-mix(in srgb, var(--c, var(--ink-3)) 13%, transparent); color: color-mix(in srgb, var(--c, var(--ink-3)) 75%, var(--ink)); white-space: nowrap; }
.mchip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.color-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c, var(--ink-3)); }

/* ------------------------------------------------------------------ dialogs */
.modal-back { position: fixed; inset: 0; background: rgba(8, 8, 14, .55); display: grid; place-items: center; padding: 24px; z-index: 100; animation: fade .14s ease; backdrop-filter: blur(3px); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); width: min(780px, 100%); max-height: min(90dvh, 960px); display: flex; flex-direction: column; animation: rise .18s cubic-bezier(.2,.8,.2,1); border: 1px solid var(--line); overflow: hidden; }
.modal.sm { width: min(480px, 100%); }
.modal.lg { width: min(1000px, 100%); }
.modal:focus { outline: none; }
.modal-head { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line);
  background: radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--hc, var(--accent)) 20%, transparent), transparent 55%), var(--surface); }
.modal-head .head-main { flex: 1; min-width: 0; }
.modal-head h2 { margin: 0; font: 800 23px/1.15 var(--font-display); letter-spacing: -.02em; overflow-wrap: anywhere; }
.modal-head .kicker { font: 700 11px/1.4 var(--font-mono); color: color-mix(in srgb, var(--hc, var(--accent)) 80%, var(--ink)); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 4px; }
.modal-head .head-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.modal-body { padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .modal-back { padding: 0; place-items: end stretch; }
  .modal, .modal.sm, .modal.lg { width: 100%; max-height: 94dvh; border-radius: 20px 20px 0 0; }
  .modal-head h2 { font-size: 20px; }
}
.section h3 { font: 700 11.5px/1.4 var(--font-ui); margin: 0 0 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; display: flex; align-items: center; gap: 8px; }
.section h3 .actions { margin-left: auto; text-transform: none; letter-spacing: 0; display: flex; gap: 6px; align-items: center; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--ink-3); font-weight: 450; }
.field .input, .field .select { width: 100%; }
.ro-value { padding: 2px 0; overflow-wrap: anywhere; font-size: 14px; }
.ro-value.empty { color: var(--ink-3); font-style: italic; }
.rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.rows > .row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rows > .row:last-child { border-bottom: 0; }
.rows > .row.is-hidden { background-image: var(--hatch); }
.rows .row .grow { flex: 1; min-width: 160px; }
.group-label { font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; box-shadow: inset 3px 0 0 var(--c, var(--line-strong)); }
.callout { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.callout.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.flag { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.flag:last-child { border-bottom: 0; }
.flag .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.5; }
.flag .raw { font: 12px var(--font-mono); color: var(--ink-3); margin-top: 3px; }
.fork-grid { display: grid; grid-template-columns: 1fr repeat(3, 64px); gap: 8px 6px; align-items: center; }
.fork-grid .h { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--ink-3); text-transform: uppercase; text-align: center; }
.fork-grid label { display: grid; place-items: center; }
.fork-grid input { width: 18px; height: 18px; accent-color: var(--accent); }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.tl-item .tl-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 650; }
.combo { position: relative; }
.combo .input { width: 100%; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 20; padding: 4px; }
.combo-list button { display: flex; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; cursor: pointer; align-items: baseline; border-radius: 8px; }
.combo-list button:hover, .combo-list button.active { background: var(--accent-soft); }
.combo-list .sub { color: var(--ink-3); font-size: 12px; margin-left: auto; white-space: nowrap; }
.combo-list .empty { padding: 8px 10px; color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------------ popover */
.popover { position: fixed; z-index: 90; width: min(360px, calc(100vw - 24px)); background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px; display: flex; flex-direction: column; gap: 12px; animation: rise .14s ease; }
.popover h4 { margin: 0; font: 700 14px var(--font-display); }

/* ------------------------------------------------------------------ search palette */
.palette-back { position: fixed; inset: 0; z-index: 120; background: rgba(8, 8, 14, .5); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; animation: fade .12s; }
.palette { width: min(640px, 100%); background: var(--raised); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; animation: rise .16s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; max-height: 70vh; }
.palette .p-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette .p-input svg.i { width: 18px; height: 18px; color: var(--ink-3); }
.palette input { flex: 1; height: 56px; border: 0; background: transparent; font-size: 16px; outline: none; }
.palette .p-results { overflow-y: auto; padding: 6px; }
.palette .p-group { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); padding: 10px 10px 4px; }
.palette .p-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: left; }
.palette .p-item.active { background: var(--accent-soft); }
.palette .p-item .t { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette .p-item .s { margin-left: auto; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.palette .p-empty { padding: 26px; text-align: center; color: var(--ink-3); }
.palette .p-foot { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 12px; color: var(--ink-3); display: flex; gap: 14px; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 16px; border-radius: 14px; background: #17161f; color: #f2f1f7; box-shadow: 0 18px 40px -12px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.07); font-size: 13.5px; animation: rise .16s ease; }
.toast.error { background: #3a0f12; }
.toast .msg { flex: 1; }
.toast button { background: rgba(255,255,255,.08); border: 0; color: inherit; border-radius: 8px; padding: 5px 10px; cursor: pointer; font-weight: 650; }
.toast button:hover { background: rgba(255,255,255,.16); }

/* ------------------------------------------------------------------ pages */
.stack { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow); }
.panel h2 { font: 750 17px var(--font-display); margin: 0 0 12px; letter-spacing: -.01em; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius-lg); padding: 36px 18px; text-align: center; color: var(--ink-2); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font: 700 16px var(--font-display); margin-top: 8px; color: var(--ink); }
.dropzone svg.i { width: 28px; height: 28px; color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font: 700 22px var(--font-mono); letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--ink-3); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .2s; }
details.group { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.group + details.group { margin-top: 10px; }
details.group > summary { cursor: pointer; padding: 12px 14px; font-weight: 650; display: flex; gap: 10px; align-items: center; list-style: none; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); transition: transform .15s; flex: none; }
details.group[open] > summary::before { transform: rotate(45deg); }
details.group .items { border-top: 1px solid var(--line); max-height: 440px; overflow: auto; }
.item-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.item-row:last-child { border-bottom: 0; }
.item-row input { margin-top: 3px; accent-color: var(--accent); }
.item-row .diff { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.item-row .diff del { color: var(--danger); }
.item-row .diff ins { color: var(--ok); text-decoration: none; }
mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ------------------------------------------------------------------ phones */
@media (max-width: 680px) {
  .page-head h1 { font-size: 25px; }
  .grid .c-num { width: 44px; min-width: 44px; padding-left: 10px; padding-right: 4px; }
  .grid .c-power { left: 44px; width: 150px; min-width: 150px; max-width: 150px; padding-left: 6px; padding-right: 8px; }
  .grid .c-power .power-desc { display: none; }
  .grid td.c-messiah { min-width: 170px; max-width: 220px; }
  .grid th, .grid td { padding-top: 9px; padding-bottom: 9px; }
  .table-wrap { max-height: calc(100dvh - var(--topbar-h) - 170px); }
  .grid .inline-input.num { width: 36px; padding: 0 3px; }
  .holder .hn { max-width: 130px; }
}

/* Filters fold away behind a button on phones */
.toolbar .more { display: contents; }
.filter-toggle { display: none !important; }
@media (max-width: 680px) {
  .filter-toggle { display: inline-flex !important; }
  .toolbar .more { display: none; }
  .toolbar.open .more { display: contents; }
  .toolbar .search { flex: 1 1 160px; }
  .toolbar .grow { display: none; }
}

/* ------------------------------------------------------------------ touch screens (phones and tablets)
   16px fields so iOS does not zoom in on tap; finger-sized targets (about 36-44px). */
@media (pointer: coarse) {
  .input, .select, textarea.input, .inline-input, .palette input, .combo .input { font-size: 16px; }
  .input, .select { height: 42px; }
  .search svg { top: 13px; }
  .select.sm, .input.sm { height: 40px; font-size: 16px; }
  .btn { height: 42px; }
  .btn.sm { height: 38px; padding: 0 12px; }
  .seg button { height: 38px; min-width: 42px; justify-content: center; }
  .eye { width: 38px; height: 38px; }
  .icon-btn.sm { width: 38px; height: 38px; }
  .x-btn { padding: 8px 9px; margin: -6px -4px; }
  .holder { min-height: 36px; }
  .holder .hn { padding: 10px 0; margin: -10px 0; }
  .power-name { padding: 7px 0; margin: -7px 0; }
  .pw { min-height: 34px; padding: 4px 10px; }
  .cell-add { height: 36px; padding: 0 12px; }
  .chip-filter button { padding: 6px 8px; }
  .nav-item { padding: 12px 12px; }
  .check input { width: 20px; height: 20px; }
  .fork-grid input { width: 22px; height: 22px; }
}

/* ------------------------------------------------------------------ phone layouts */
@media (max-width: 680px) {
  /* page header: title left, icon-only actions right */
  .page-head { flex-wrap: nowrap; align-items: flex-start; margin-bottom: 12px; }
  .page-head > div:first-child { min-width: 0; }
  .page-head .sub { font-size: 12.5px; gap: 2px 10px; }
  .page-head .actions { flex-wrap: nowrap; gap: 6px; }
  .page-head .actions .label { display: none; }
  .page-head .actions .btn:has(> .label) { width: 44px; padding: 0; }
  /* dialogs as bottom sheets: compact head and foot, fields full width */
  .modal-head { padding: 16px 16px 12px; }
  .modal-body { padding: 16px; gap: 18px; }
  .modal-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot .stamp { display: none; }
  .section h3 { flex-wrap: wrap; row-gap: 8px; }
  .section h3 .actions { max-width: 100%; min-width: 0; }
  .section h3 .actions .select { max-width: 100%; min-width: 0; }
  .section h3 .actions:has(> .select) { margin-left: 0; width: 100%; }
  .section h3 .actions > .select { width: 100% !important; }
  .id-row > .id-avatar { display: none; }
  .rows > .row { padding: 10px; }
  .rows .row .grow { min-width: 0; flex-basis: 100%; }
  .fork-grid { grid-template-columns: 1fr repeat(3, 52px); }
}

/* Narrow phones: the filter button turns into an icon so search, filters and the view switch share one row */
@media (max-width: 560px) {
  .toolbar .search { flex: 1 1 100px; min-width: 0; }
  .filter-toggle .label { display: none; }
  .filter-toggle { width: 44px; padding: 0; }
}

/* ------------------------------------------------------------------ random grant */
.grant { display: flex; flex-direction: column; gap: 16px; max-width: 1040px; }
.grant-controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.grant-controls > .field:first-child { min-width: min(320px, 100%); }
.grant-options { display: flex; flex-direction: column; gap: 6px; padding-bottom: 6px; }
.grant-pool { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--ink-2); }
.grant-pool p { margin: 0; }
.pool-details summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; font-size: 13px; width: fit-content; }
.pool-list { max-height: 280px; overflow: auto; display: flex; flex-wrap: wrap; gap: 5px; padding-top: 10px; }
.draw-btn { height: 44px; padding: 0 20px; font-size: 15px; }
.grant-draws { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.draw-card { border: 1px solid var(--line); border-top: 3px solid var(--c, var(--accent)); border-radius: var(--radius-lg); background: var(--surface);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); }
.draw-card.fresh { animation: draw-in .28s ease both; }
.grant-controls .ro-value { height: 38px; display: flex; align-items: center; }
@media (pointer: coarse) { .grant-controls .ro-value { height: 42px; } }
@keyframes draw-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.draw-card .num { font: 700 12px var(--font-mono); color: var(--ink-3); }
.draw-card h4 { margin: 0; font: 700 17px/1.25 var(--font-display); letter-spacing: -.01em; }
.draw-card .desc { font-size: 13px; color: var(--ink-2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.draw-card .row-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
.grant-give { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-2); }
.grant-give h3 { margin: 0; font: 700 11.5px/1.4 var(--font-ui); color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; }
.grant-give p { margin: 0; }
.grant-target .combo { max-width: 460px; }
.target-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-weight: 600; max-width: 100%; }

/* ------------------------------------------------------------------ DM files and Claude's readings */
.files-page { display: flex; flex-direction: column; gap: 16px; max-width: 1040px; }
.dropzone { display: grid; justify-items: center; gap: 6px; padding: 26px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
  background: var(--surface); text-align: center; cursor: pointer; color: var(--ink-2); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone svg.i { width: 22px; height: 22px; color: var(--accent-ink); }
.upload-progress { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.upload-progress:empty { display: none; }
.up-row { display: flex; justify-content: space-between; gap: 12px; }
.up-row.bad span:last-child { color: var(--danger); }
.list-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.list-table { width: 100%; border-collapse: collapse; }
.list-table th { text-align: left; font: 700 11px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.list-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list-table tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.claude-panel textarea { width: 100%; margin: 4px 0 12px; }
.claude-panel p { margin-top: 0; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.proposals .proposal { align-items: flex-start; cursor: pointer; flex-wrap: nowrap; }
.proposals .proposal input { margin-top: 3px; flex: none; }
.proposal .kind { font: 700 11px var(--font-ui); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.proposal .what { margin-top: 3px; font-weight: 600; overflow-wrap: anywhere; }
.proposal blockquote { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--line-strong); color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
.proposal cite { display: block; font-style: normal; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.proposal.bad { opacity: .75; cursor: default; }
.conf { font: 700 11px var(--font-ui); padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); }
.conf.certain { background: var(--ok-soft); color: var(--ok); }
.conf.unsure { background: var(--warn-soft); color: var(--warn); }
.small.danger { color: var(--danger); }
.file-text { white-space: pre-wrap; font: 12.5px/1.6 var(--font-mono); max-height: 65vh; overflow: auto; margin: 0; padding: 14px; background: var(--surface-2); border-radius: var(--radius); }

/* ==========================================================================
   Design pass (9.11.2026). One ink accent; colour only where it carries data
   (each Messiah's colour); no gradients, glows or coloured shadows; a serif for
   headings, IBM Plex for everything you scan.
   ========================================================================== */
:root {
  --font-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --accent: #23262f; --accent-ink: #23262f; --accent-soft: #ebe8e1; --accent-line: #bdb6a8; --accent-contrast: #ffffff;
  --focus: 0 0 0 3px rgba(35, 38, 47, .2);
  --bg-glow-1: transparent; --bg-glow-2: transparent;
}
:root[data-theme="dark"] {
  --accent: #ebe7dd; --accent-ink: #f3f0e8; --accent-soft: rgba(235, 231, 221, .09); --accent-line: rgba(235, 231, 221, .32); --accent-contrast: #15161c;
  --focus: 0 0 0 3px rgba(235, 231, 221, .22);
  --bg-glow-1: transparent; --bg-glow-2: transparent;
}
body { background: var(--bg); }
.btn.primary, :root[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); box-shadow: none; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.18); }
:root[data-theme="dark"] .btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.sidebar { background: var(--side-bg); }
.sigil { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(233, 228, 216, .5); border-radius: 10px; }
.sigil::before { background: none; -webkit-mask: none; mask: none; border: 2px solid #e9e4d8; width: 18px; height: 18px; }
.sigil span { background: #e9e4d8; box-shadow: none; width: 6px; height: 6px; }
.nav-item.active::before { background: #e9e4d8; }
.brand-name { font: 600 19px/1.1 var(--font-display); letter-spacing: 0; }
.page-head h1 { font: 600 36px/1.05 var(--font-display); letter-spacing: -.015em; }
.panel h2, .empty-state h3 { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: 0; }
.modal-head { background: var(--surface); border-top: 4px solid var(--hc, var(--line-strong)); }
.modal-head h2 { font: 600 27px/1.15 var(--font-display); letter-spacing: -.01em; }
.power-name { font-family: var(--font-ui); font-weight: 600; letter-spacing: 0; }
.popover h4, .draw-card h4 { font-family: var(--font-ui); font-weight: 650; }
.draw-card h4 { font-size: 16px; }
.avatar { background: var(--c); box-shadow: none; }
.avatar.lg { box-shadow: none; }
.edit-banner { background: var(--gold-soft); }
.progress > div { background: var(--accent); }
.mcard { border-top: 3px solid var(--c); }
.mcard .glow { height: auto; background: none; display: flex; align-items: center; gap: 12px; padding: 16px 18px 0; }
.mcard .glow .emblem { position: static; width: 34px; height: 34px; border-radius: 9px; background: var(--c); box-shadow: none; font: 700 15px var(--font-ui); }
.mcard .glow .state { position: static; margin-left: auto; }
.mcard .inner { padding: 12px 18px 18px; }
.mcard h3 { font: 600 23px/1.15 var(--font-display); letter-spacing: -.005em; }
.mstats div { border-radius: 8px; }
@media (max-width: 680px) { .page-head h1 { font-size: 30px; } .modal-head h2 { font-size: 23px; } }

/* "New since your last visit" (players), and the copy-link button in dialogs */
.new-badge { display: inline-block; font: 700 10px/1.7 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; padding: 0 6px; border-radius: 4px;
  background: var(--gold-soft); color: var(--gold); vertical-align: 2px; }
.new-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px;
  border-radius: var(--radius); background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); font-size: 14px; }
.copy-link { margin-left: auto; }
