/* Julecraft Panel - a calm, dense work tool. Dark by default; the only festive touches are the brand mark
   (pine + a gold star dot), gold for coins/calendar and a thin snow-white edge on top of the sidebar.
   Red means danger and nothing else. Tokens first, then base, layout, components, legacy aliases. */

@font-face {
  font-family: "Silkscreen";
  src: url("/fonts/silkscreen-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* ================================================================== tokens */
:root {
  color-scheme: dark;
  --bg: #0b0f15;
  --bg-raised: #10151d;
  --card: #151b25;
  --control: #1b2230;
  --control-2: #222a3a;
  --control-3: #2a3345;
  --line: #1f2733;
  --line-strong: #2c3545;
  --line-hover: #3b465a;
  --text: #e9eef5;
  --text-2: #a4afc0;
  --text-3: #7a8699;
  --accent: #3ecf8e; --accent-hover: #5fdca3; --on-accent: #06140d;
  --danger: #f26b6b; --danger-solid: #c6373e;
  --warn: #f2b84b;
  --info: #62aef5;
  --gold: #f6c453;
  --purple: #b39af7;
  --snow: #e9eef5;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 14%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 14%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 14%, transparent);
  --gold-soft: color-mix(in srgb, var(--gold) 14%, transparent);
  --purple-soft: color-mix(in srgb, var(--purple) 16%, transparent);
  --neutral-soft: color-mix(in srgb, var(--text-2) 12%, transparent);
  --r-sm: 6px; --r: 8px; --r-lg: 12px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --fs-xs: 11px; --fs-sm: 12px; --fs: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 24px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --pixel: "Silkscreen", var(--font);
  --shadow-pop: 0 8px 24px rgb(0 0 0 / .45), 0 0 0 1px var(--line-strong);
  --shadow-modal: 0 24px 64px rgb(0 0 0 / .6);
  --ctl-h: 32px; --ctl-h-sm: 26px; --row-h: 36px; --icon: 16px;
  --sidebar-w: 232px; --rail-w: 56px; --topbar-h: 48px;
  --dur: 120ms; --ease: cubic-bezier(.2, .8, .2, 1);
  /* old names, so view CSS written before the redesign keeps working */
  --surface: var(--bg-raised); --card-2: var(--control-2); --border: var(--line); --border-2: var(--line-strong);
  --muted: var(--text-2); --dim: var(--text-3); --accent-2: var(--accent); --red: var(--danger); --orange: var(--warn);
  --blue: var(--info); --radius: var(--r-lg); --sans: var(--font); --dirt: #866043;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9; --bg-raised: #fbfbfc; --card: #ffffff; --control: #f1f3f6; --control-2: #e8ebf0; --control-3: #dde2e9;
  --line: #e4e7ec; --line-strong: #d3d8e0; --line-hover: #b9c0cc;
  --text: #141a23; --text-2: #4f5b6d; --text-3: #6b7688;
  --accent: #127a50; --accent-hover: #0f6a45; --on-accent: #fff;
  --danger: #c9343c; --danger-solid: #c6373e; --warn: #9a6200; --info: #1f6fbf; --gold: #8a6100; --purple: #6a4fc9;
  --shadow-pop: 0 8px 24px rgb(16 24 40 / .12), 0 0 0 1px var(--line-strong);
}
@media (prefers-reduced-motion: reduce) { :root { --dur: 0ms; } }

/* ================================================================== base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: var(--fs-md)/1.5 var(--font); min-height: 100vh;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
body.modal-open { overflow: hidden; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
h1 { font-size: var(--fs-xl); font-weight: 650; margin: 0; letter-spacing: -0.01em; line-height: 1.25; }
h2 { font-size: var(--fs-md); font-weight: 600; margin: 0; color: var(--text); }
h3 { font-size: var(--fs-sm); font-weight: 600; margin: 24px 0 8px; color: var(--text-2); }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--control); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px;
  font: 500 var(--fs-xs)/1 var(--mono); color: var(--text-2); background: var(--control);
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; white-space: nowrap;
}
kbd + kbd { margin-left: 3px; }
svg.icon {
  width: var(--icon); height: var(--icon); flex: 0 0 auto; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px;
}
svg.icon.filled { width: 15px; height: 15px; }
svg.icon.sm { width: 14px; height: 14px; }
svg.icon.lg { width: 20px; height: 20px; }
img.head { image-rendering: pixelated; width: 20px; height: 20px; vertical-align: middle; border-radius: 4px; background: var(--dirt); flex: 0 0 auto; }
img.head.big { width: 64px; height: 64px; border-radius: var(--r); box-shadow: 0 0 0 3px var(--control-2); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ================================================================== utilities */
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.ok-text { color: var(--accent); }
.danger-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.gold-text { color: var(--gold); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.small-text { font-size: var(--fs-sm); }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.stack.lg { gap: var(--s4); }
.narrow { max-width: 760px; }
.warn-line { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--warn); margin: 4px 0 8px; }
.warn-line.danger { color: var(--danger); }
.warn-line .icon { width: 14px; height: 14px; }

/* ================================================================== layout: sidebar + content */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--bg-raised); border-right: 1px solid var(--line); border-top: 3px solid var(--snow);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; min-width: 0; z-index: 20;
}
.side-top { display: flex; align-items: center; gap: 4px; padding: 12px 10px 8px 14px; height: 52px; flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex: 1; min-width: 0; text-decoration: none !important; }
.brand-mark { position: relative; display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center;
  border-radius: var(--r); background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }
.brand-mark .icon { width: 18px; height: 18px; }
.brand-star { position: absolute; top: 2px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--gold); }
.brand-name { font-family: var(--pixel); font-weight: 700; font-size: 13px; letter-spacing: .02em; line-height: 1; white-space: nowrap; }
.rail-pin { display: none; }
nav.nav { display: flex; flex-direction: column; padding: 4px 8px 12px; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.nav-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; padding: 14px 10px 4px; white-space: nowrap; }
nav a.nav-item {
  display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 8px 0 10px; border-radius: var(--r); margin: 1px 0;
  color: var(--text-2); font-size: var(--fs); font-weight: 500; position: relative; text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
nav a.nav-item:hover { background: var(--control); color: var(--text); }
nav a.nav-item.active { background: var(--control-2); color: var(--text); }
nav a.nav-item.active .icon { color: var(--accent); }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger-solid); color: #fff; font-size: var(--fs-xs); font-weight: 700; line-height: 1;
}
.count.ok { background: var(--accent-soft); color: var(--accent); }
.count.neutral { background: var(--control-3); color: var(--text-2); }
.side-foot { border-top: 1px solid var(--line); padding: 10px 10px 10px 12px; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.me { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.me img.head { width: 24px; height: 24px; }
.me-text { min-width: 0; line-height: 1.25; }
.me-name { font-size: var(--fs); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .pill { height: 16px; font-size: 10px; padding: 0 6px; }
.side-foot .icon-btn { flex: 0 0 auto; }
.scrim { display: none; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: var(--s3);
  height: var(--topbar-h); padding: 0 var(--s5); background: var(--bg-raised); border-bottom: 1px solid var(--line);
}
.menu-btn { display: none !important; }
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); font-size: var(--fs); font-weight: 600; }
.crumb .icon { color: var(--text-2); }
.crumb-icon { display: inline-flex; }
.crumb-icon:empty { display: none; }
.crumb-root { color: var(--text-3); font-weight: 500; }
.crumb-sep { color: var(--line-hover); }
.crumb-page { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-strip { display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; }
.status-strip a.pill { text-decoration: none; }
.status-strip a.pill:hover { filter: brightness(1.15); }
.search-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 10px; min-width: 150px;
  background: var(--control); border: 1px solid var(--line-strong); border-radius: var(--r); color: var(--text-3);
  font: 500 var(--fs) var(--font); cursor: pointer;
}
.search-btn:hover { border-color: var(--line-hover); color: var(--text-2); background: var(--control); }
.search-btn .spacer { flex: 1; }
main { padding: var(--s5) var(--s5) 80px; width: 100%; max-width: 1448px; margin: 0 auto; min-width: 0; flex: 1; }

/* 900-1199: a 56 px icon rail, pinnable to full width */
@media (min-width: 900px) and (max-width: 1199px) {
  .layout:not(.pinned) { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .layout:not(.pinned) .side-top { flex-direction: column; height: auto; padding: 12px 0 6px; gap: 8px; }
  .layout:not(.pinned) .brand { flex: 0 0 auto; }
  .layout:not(.pinned) .brand-name,
  .layout:not(.pinned) .me-text,
  .layout:not(.pinned) .nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .layout:not(.pinned) .nav-label { height: 1px; padding: 0; margin: 10px 10px; background: var(--line); font-size: 0; }
  .layout:not(.pinned) nav a.nav-item { justify-content: center; padding: 0; width: 38px; height: 34px; margin: 1px auto; }
  .layout:not(.pinned) nav a.nav-item .count { position: absolute; top: 1px; right: -2px; min-width: 15px; height: 15px; font-size: 9px; padding: 0 3px; }
  .layout:not(.pinned) .side-foot { flex-direction: column; padding: 10px 0; gap: 6px; }
  .layout:not(.pinned) .me { flex: 0 0 auto; }
  .rail-pin { display: inline-flex; }
  .layout:not(.pinned) .side .icon-btn[data-tip]::after { left: calc(100% + 8px); bottom: auto; top: 50%; translate: 0 -50%; }
}
.rail-tip {
  position: fixed; z-index: 70; pointer-events: none; padding: 4px 8px; border-radius: var(--r-sm); white-space: nowrap;
  background: var(--control-2); color: var(--text); font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--shadow-pop);
}
@media (min-width: 1200px), (max-width: 899px) { .rail-tip { display: none; } }

/* < 900: an off-canvas drawer */
@media (max-width: 899px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); height: auto; z-index: 45;
    translate: -100% 0; transition: translate var(--dur) var(--ease); visibility: hidden;
  }
  .side.open { translate: none; visibility: visible; box-shadow: var(--shadow-modal); }
  .scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 44; opacity: 0; pointer-events: none; transition: opacity var(--dur); }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex !important; margin-left: -6px; }
  .topbar { padding: 0 var(--s4); gap: var(--s2); }
  .crumb-root, .crumb-sep, .crumb-icon { display: none; }
  .search-btn { min-width: 0; padding: 0 8px; }
  .search-btn .search-label, .search-btn kbd { display: none; }
  main { padding: var(--s4) var(--s4) 80px; }
}
@media (max-width: 639px) {
  .status-strip .pill-label { display: none; }
  .status-strip .pill { padding: 0 6px; }
}

/* ================================================================== page and section heads */
.page-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); flex-wrap: wrap; min-height: var(--ctl-h); }
.page-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.page-title > .icon { width: 20px; height: 20px; color: var(--text-2); }
.page-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-actions, .page-head > .actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-left: auto; }
.page-head p { margin: 4px 0 0; color: var(--text-2); font-size: var(--fs); }
.sec-head { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin: var(--s5) 0 var(--s2); }
.sec-head:first-child { margin-top: 0; }
.sec-head .icon { width: 14px; height: 14px; }
.sec-count { margin-left: auto; font-weight: 500; color: var(--text-3); }

/* ================================================================== toggletip */
.tip { display: inline-flex; vertical-align: middle; position: relative; }
.tip-btn {
  display: inline-flex !important; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 3px !important; margin: -3px;
  box-sizing: content-box; background: transparent !important; border: 0 !important; border-radius: 50% !important; color: var(--text-3) !important; cursor: pointer;
}
.tip-btn:hover, .tip-btn:focus-visible, .tip-btn[aria-expanded="true"] { color: var(--text) !important; }
.tip-btn .icon { width: 14px; height: 14px; }
.tip-live { display: inline; }
.tip-bubble {
  position: fixed; z-index: 60; max-width: 280px; padding: 8px 10px; border-radius: var(--r);
  background: var(--control-2); color: var(--text); font-size: var(--fs-sm); font-weight: 400; line-height: 1.45;
  box-shadow: var(--shadow-pop); white-space: normal; text-align: left; text-transform: none; letter-spacing: normal;
}
.tip-bubble code { background: var(--control-3); }

/* ================================================================== buttons */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctl-h); padding: 0 12px;
  font: 600 var(--fs) var(--font); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none;
  background: var(--control); border: 1px solid var(--line-strong); border-radius: var(--r);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
button:hover, .btn:hover { background: var(--control-2); border-color: var(--line-hover); text-decoration: none; }
button:active:not(:disabled), .btn:active { background: var(--control-3); }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary, button.green {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.btn.primary:hover:not(:disabled), button.green:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled), button.ghost:hover:not(:disabled) { background: var(--control-2); color: var(--text); border-color: transparent; }
.btn.danger, button.red { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.btn.danger:hover:not(:disabled), button.red:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 24%, transparent); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger.solid { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn.danger.solid:hover:not(:disabled) { background: color-mix(in srgb, var(--danger-solid) 85%, #fff); }
.btn.warn, button.gold { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.btn.warn:hover:not(:disabled), button.gold:hover:not(:disabled) { background: color-mix(in srgb, var(--warn) 22%, transparent); }
.btn.sm, button.small, .btn.small { height: var(--ctl-h-sm); padding: 0 9px; font-size: var(--fs-sm); border-radius: var(--r-sm); gap: 5px; }
.btn.sm .icon, button.small .icon { width: 14px; height: 14px; }
.btn[aria-busy="true"] { cursor: progress; }
.spinner {
  width: 14px; height: 14px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* icon-only buttons with a CSS tooltip */
.icon-btn {
  position: relative; width: 28px; height: 28px; padding: 0; flex: 0 0 auto;
  background: transparent; border-color: transparent; color: var(--text-2); border-radius: var(--r);
}
.icon-btn:hover:not(:disabled) { background: var(--control-2); border-color: transparent; color: var(--text); }
.icon-btn.sm { width: 24px; height: 24px; border-radius: var(--r-sm); }
.icon-btn.danger { background: transparent; border-color: transparent; color: var(--text-2); }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.icon-btn.on { color: var(--accent); }
.icon-btn[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; translate: -50% 0; z-index: 30;
  padding: 3px 7px; border-radius: var(--r-sm); background: var(--control-2); color: var(--text); box-shadow: var(--shadow-pop);
  font: 500 var(--fs-sm)/1.4 var(--font); white-space: nowrap; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease) 0s, visibility 0s linear var(--dur);
}
.icon-btn[data-tip]:hover::after, .icon-btn[data-tip]:focus-visible::after {
  opacity: 1; visibility: visible; transition: opacity var(--dur) var(--ease) 300ms, visibility 0s linear 300ms;
}
.icon-btn.tip-below[data-tip]::after { bottom: auto; top: calc(100% + 6px); }
.icon-btn.tip-left[data-tip]::after { left: auto; right: 0; translate: none; }
.side-foot .icon-btn[data-tip]::after, .topbar .icon-btn[data-tip]::after { bottom: auto; top: calc(100% + 6px); }
.side-foot .icon-btn[data-tip]::after { top: auto; bottom: calc(100% + 6px); }

/* ================================================================== card (and the old .panel) */
.card, .panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: var(--s4); min-width: 0;
}
.card-head, .panel > .panel-head {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px var(--s4); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card-head > .icon { color: var(--text-2); }
.card-head h2, .panel-head h2 { font-size: var(--fs-md); font-weight: 600; }
.card-actions, .card-head > .actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.card-head > .pill:last-child, .card-head > .muted:last-child, .card-head > a:last-child { margin-left: auto; }
.card-head > a { font-size: var(--fs-sm); color: var(--text-2); }
.card-head > a:hover { color: var(--text); }
/* a panel-head given to panel() as its title sits in the card head, not inside it */
.card-head > .panel-head { display: contents; }
.card-head > .panel-head > .actions { margin-left: auto; }
.card-body { padding: var(--s4); min-width: 0; }
.card-body > :last-child { margin-bottom: 0; }
.card.flush > .card-body, .card-body.flush { padding: 0; }
.card-foot { padding: 10px var(--s4); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--text-3); display: flex; align-items: center; gap: 8px; }
/* edge-to-edge content in a padded body */
.card:not(.flush) > .card-body:not(.flush) > :is(.table-wrap, .features, .rules, .set-list) { margin-left: calc(-1 * var(--s4)); margin-right: calc(-1 * var(--s4)); }
.card:not(.flush) > .card-body:not(.flush) > :is(.table-wrap, .features, .rules, .set-list):first-child { margin-top: calc(-1 * var(--s4)); }
.card:not(.flush) > .card-body:not(.flush) > :is(.table-wrap, .features, .rules, .set-list):last-child { margin-bottom: calc(-1 * var(--s4)); }
/* a panel with no head and a single table: no double padding */
.panel.bare > .card-body { padding: var(--s4); }

/* grids */
.grid { display: grid; gap: var(--s4); align-items: start; margin-bottom: var(--s4); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .panel, .grid > .card, .grid > .grid { margin-bottom: 0; }
.grid > .span { grid-column: 1 / -1; }
@media (max-width: 1100px) { .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .grid.two, .grid.split, .grid.three { grid-template-columns: minmax(0, 1fr); } }

/* ================================================================== settings rows */
.set-list { display: flex; flex-direction: column; }
.set-row {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: var(--s3); align-items: center;
  min-height: 52px; padding: 10px var(--s4); border-top: 1px solid var(--line);
}
.set-list > .set-row:first-child, .card-body > .set-row:first-child { border-top: 0; }
.card-body.flush > .set-row:first-child { border-top: 0; }
.set-row.no-icon { grid-template-columns: minmax(0, 1fr) auto; }
.set-ico {
  width: 32px; height: 32px; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center;
  background: var(--control); color: var(--text-2); transition: background var(--dur), color var(--dur);
}
.set-row.on .set-ico { background: var(--accent-soft); color: var(--accent); }
.set-row.locked .set-ico { background: var(--gold-soft); color: var(--gold); }
.set-text { min-width: 0; }
.set-title { display: flex; align-items: center; gap: 6px; font-size: var(--fs-md); font-weight: 500; min-width: 0; }
.set-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.set-hint { font-size: var(--fs-sm); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-ctl { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.set-state { font-size: var(--fs-sm); color: var(--text-3); min-width: 18px; text-align: right; }
.set-more { grid-column: 2 / -1; padding-top: 4px; }
@media (max-width: 639px) {
  .set-row { grid-template-columns: 32px minmax(0, 1fr); }
  .set-ctl { grid-column: 2; justify-content: flex-start; }
}

/* ================================================================== switch (role="switch" button) */
button.switch {
  position: relative; display: inline-flex; width: 36px; height: 20px; padding: 0; flex: 0 0 auto; border-radius: 10px;
  background: var(--control-3); border: 1px solid var(--line-hover); transition: background var(--dur) var(--ease), border-color var(--dur);
}
button.switch:hover:not(:disabled) { background: var(--control-3); border-color: var(--text-3); }
button.switch .switch-knob {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2);
  transition: translate var(--dur) var(--ease), background var(--dur), opacity var(--dur);
}
button.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
button.switch[aria-checked="true"]:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.switch[aria-checked="true"] .switch-knob { translate: 16px 0; background: var(--on-accent); }
button.switch[aria-busy="true"] .switch-knob { opacity: .45; }
button.switch[aria-busy="true"] { cursor: progress; }

/* ================================================================== segmented control */
.seg {
  display: inline-flex; padding: 2px; gap: 2px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r);
  flex-wrap: wrap; max-width: 100%;
}
.seg > button { height: 26px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.seg[role="radiogroup"] > button {
  height: 26px; padding: 0 10px; gap: 5px; font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--text-2);
}
.seg[role="radiogroup"] > button .icon { width: 14px; height: 14px; }
.seg[role="radiogroup"] > button:hover:not(:disabled) { background: var(--control); color: var(--text); border-color: transparent; }
.seg[role="radiogroup"] > button[role="radio"][aria-checked="true"],
.seg[role="radiogroup"] > button[role="radio"][aria-checked="true"]:hover {
  background: var(--control-3); color: var(--text); border-color: var(--line-strong);
}
.seg[role="radiogroup"] > button[aria-checked="true"].on .icon { color: var(--accent); }
.seg[role="radiogroup"] > button[aria-checked="true"].locked .icon { color: var(--gold); }
.seg[role="radiogroup"] > button[aria-checked="true"].off .icon { color: var(--text-3); }
.seg[role="radiogroup"] > button[role="radio"]:disabled { opacity: 1; cursor: default; }
.seg[role="radiogroup"] > button[role="radio"]:disabled[aria-checked="false"] { opacity: .45; }
.seg.sm[role="radiogroup"] > button { height: 22px; padding: 0 8px; }

/* ================================================================== stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat {
  position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px var(--s4);
  color: var(--text); text-decoration: none !important; transition: border-color var(--dur), background var(--dur);
}
a.stat:hover { border-color: var(--line-hover); background: color-mix(in srgb, var(--card) 70%, var(--control)); }
.stat-top { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; min-width: 0; }
.stat-top .icon { width: 14px; height: 14px; }
.stat-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-go { margin-left: auto; opacity: 0; color: var(--text-3); transition: opacity var(--dur); }
a.stat:hover .stat-go, a.stat:focus-visible .stat-go { opacity: 1; }
.stat-value { font-size: var(--fs-2xl); font-weight: 650; line-height: 1.2; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-of { font-size: var(--fs-md); color: var(--text-3); font-weight: 500; margin-left: 2px; }
.stat-sub { font-size: var(--fs-sm); color: var(--text-3); min-height: 20px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat.danger .stat-value { color: var(--danger); }
.stat.warn .stat-value { color: var(--warn); }
.stat.ok .stat-value { color: var(--accent); }
.stat.gold .stat-value { color: var(--gold); }
@media (max-width: 599px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat-value { font-size: 20px; } }

/* the old dashboard tiles (.slots > .slot) */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.slot { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px var(--s4); position: relative; transition: border-color var(--dur); min-width: 0; }
.slot .label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.slot .value { font-size: var(--fs-2xl); font-weight: 650; margin-top: 2px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.slot .sub { color: var(--text-3); font-size: var(--fs-sm); }
.slot.alert .value { color: var(--danger); }
.slot.warn .value { color: var(--warn); }
.slot a { position: absolute; inset: 0; border-radius: var(--r-lg); }
.slot:has(> a):hover { border-color: var(--line-hover); }
.slot:has(> a:focus-visible) { border-color: var(--accent); }
.slot a:focus-visible { outline: none; }
.slots.mini { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.slots.mini .value { font-size: 20px; }
@media (max-width: 599px) { .slots, .slots.mini { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ================================================================== empty state + loading */
.empty { color: var(--text-3); padding: var(--s6) var(--s4); text-align: center; font-size: var(--fs); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--control); color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.empty-ico .icon { width: 18px; height: 18px; }
.empty-title { margin: 0; color: var(--text); font-size: var(--fs-md); font-weight: 500; }
.empty-hint { margin: 0; color: var(--text-3); font-size: var(--fs-sm); }
.empty > .btn { margin-top: 10px; }
.empty.compact { padding: var(--s4); }
.loading { padding: var(--s5) 0; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.skeleton { height: 14px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--control) 0%, var(--control-2) 50%, var(--control) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton.title { height: 22px; width: 220px; margin-bottom: 8px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ================================================================== pills (and the old .tag) */
.pill, .tag {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; white-space: nowrap; vertical-align: middle;
  background: var(--neutral-soft); color: var(--text-2); margin: 1px 4px 1px 0;
}
.pill:last-child, .tag:last-child { margin-right: 0; }
.pill .icon, .tag .icon { width: 12px; height: 12px; vertical-align: 0; }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.pill.ok, .tag.green, .tag.grass { background: var(--accent-soft); color: var(--accent); }
.pill.warn, .tag.orange { background: var(--warn-soft); color: var(--warn); }
.pill.danger, .tag.red { background: var(--danger-soft); color: var(--danger); }
.pill.info, .tag.blue { background: var(--info-soft); color: var(--info); }
.pill.gold, .tag.gold { background: var(--gold-soft); color: var(--gold); }
.pill.role, .tag.purple { background: var(--purple-soft); color: var(--purple); }
.pill.neutral, .tag.gray { background: var(--neutral-soft); color: var(--text-2); }
.pill.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tags > .pill, .tags > .tag { margin: 0; }
.tag .x, .pill .x { background: none; border: 0; color: inherit; padding: 0 0 0 4px; height: auto; cursor: pointer; font-size: 13px; line-height: 1; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--text-3); }

/* ================================================================== tabs (underline) */
.tabs {
  display: flex; gap: 2px; margin-bottom: var(--s4); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.tabs > button {
  height: 36px; padding: 0 10px; margin-bottom: -1px; gap: 6px; border-radius: 0; background: transparent; border: 0;
  border-bottom: 2px solid transparent; color: var(--text-2); font-size: var(--fs); font-weight: 500;
}
.tabs > button:hover:not(:disabled) { background: transparent; color: var(--text); border-color: transparent; border-bottom-color: var(--line-hover); }
.tabs > button.active, .tabs > button[aria-selected="true"], .tabs > button.active:hover { color: var(--text); border-bottom-color: var(--accent); }
.tabs > button .count { background: var(--control-3); color: var(--text-2); }
.tabs > button.active .count { background: var(--accent-soft); color: var(--accent); }
.tabs > button:focus-visible { outline-offset: -2px; border-radius: var(--r-sm); }

/* ================================================================== tables */
.table-wrap { min-width: 0; }
/* below 1200 px tables scroll sideways as a fallback; a scroll box breaks sticky headers, so they go static */
@media (max-width: 1199px) { .table-wrap { overflow-x: auto; } .table-wrap th { position: static; } }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs); }
th {
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-align: left; padding: 0 12px; height: 32px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg-raised);
  position: sticky; top: var(--topbar-h); z-index: 2;
}
.modal th, .pop th { position: static; }
th:first-child, td:first-child { padding-left: var(--s4); }
th:last-child, td:last-child { padding-right: var(--s4); }
td { padding: 6px 12px; height: var(--row-h); border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--control); }
tr.clickable { cursor: pointer; }
tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.selected td { background: var(--accent-soft); }
tr.highlight td, tr.flash td { background: var(--warn-soft) !important; }
tr.highlight td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.msg { max-width: 560px; min-width: 160px; word-break: break-word; }
td.act, th.act { white-space: nowrap; width: 1%; text-align: right; }
td.act .actions { flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }
td.act button { margin: 0; }
td .sub-line { display: block; font-size: var(--fs-sm); color: var(--text-3); }
.row-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; opacity: .4; transition: opacity var(--dur); }
tr:hover .row-actions, tr:focus-within .row-actions, .row-actions:focus-within { opacity: 1; }
@media (hover: none), (max-width: 639px) { .row-actions { opacity: 1; } }
@media (max-width: 639px) { .hide-sm { display: none !important; } }
.player { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; white-space: nowrap; vertical-align: middle; }
a.player:hover { text-decoration: none; color: var(--accent-hover); }
.player .pill-dot { color: var(--accent); }
.coins { white-space: nowrap; font-variant-numeric: tabular-nums; }
.coin {
  display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; margin-left: 0.3em; vertical-align: -0.04em;
  background: radial-gradient(circle at 35% 35%, #ffe7a3, var(--gold) 70%); box-shadow: inset 0 0 0 1.5px rgb(0 0 0 / .25);
}
.plus { color: var(--accent); font-variant-numeric: tabular-nums; }
.minus { color: var(--danger); font-variant-numeric: tabular-nums; }

/* ================================================================== forms */
input, select, textarea {
  font: var(--fs) var(--font); color: var(--text); background: var(--control);
  border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0 10px; min-width: 0; height: var(--ctl-h);
  transition: border-color var(--dur), box-shadow var(--dur);
}
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: var(--line-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; padding: 0; margin: 0; box-shadow: none; }
input[type="color"] { padding: 2px; width: 44px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
select { padding-right: 6px; }
textarea { width: 100%; height: auto; min-height: 90px; resize: vertical; line-height: 1.45; padding: 7px 10px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--s3); min-width: 0; }
label.field { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.field-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.field-hint { margin: 0; font-size: var(--fs-sm); color: var(--text-3); }
.field-err { margin: 0; font-size: var(--fs-sm); color: var(--danger); }
label.check { display: inline-flex; align-items: center; gap: 8px; margin: 4px 16px 8px 0; color: var(--text); font-size: var(--fs); cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.form-row > * { flex: 1 1 170px; }
.form-row > button, .form-row > .btn { flex: 0 0 auto; }
.form-row.compact > * { flex: 0 1 240px; }
.form-row > .field, .form-row > label.field { margin-bottom: 0; }
.form-row.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hint { color: var(--text-3); font-size: var(--fs-sm); margin: 0 0 10px; }
.input-icon { position: relative; display: flex; align-items: center; min-width: 0; }
.input-icon > .icon { position: absolute; left: 9px; color: var(--text-3); pointer-events: none; width: 14px; height: 14px; }
.input-icon > input { padding-left: 30px; width: 100%; }
.input-icon > .icon-btn { position: absolute; right: 3px; width: 26px; height: 26px; }
.input-icon > input[type="search"]::-webkit-search-cancel-button { display: none; }
/* preset chips (durations, reasons) */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  height: 24px; padding: 0 9px; font-size: var(--fs-sm); font-weight: 500; border-radius: 12px;
  background: var(--control); border: 1px solid var(--line-strong); color: var(--text-2);
}
.chip:hover:not(:disabled) { color: var(--text); background: var(--control-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }

/* filter bar above lists */
.filter-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
.filter-bar .input-icon { flex: 1 1 200px; max-width: 320px; }
.filter-count { margin-left: auto; font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; }
.card-head .filter-bar { flex: 1; flex-wrap: nowrap; justify-content: flex-end; }
.card-actions:has(.filter-bar) { flex: 1; justify-content: flex-end; }
.card-head .filter-bar input { height: 28px; }

/* sticky save bar */
.save-bar {
  position: sticky; bottom: var(--s4); z-index: 12; display: flex; align-items: center; gap: var(--s2);
  margin: var(--s4) auto 0; width: fit-content; max-width: 100%; padding: 8px 8px 8px 14px;
  background: var(--control-2); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); font-size: var(--fs); font-weight: 500;
  animation: rise var(--dur) var(--ease);
}
.save-bar .icon { color: var(--warn); }
.save-bar .save-text { margin-right: var(--s3); }
@keyframes rise { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: none; } }

/* misc content */
.meter { height: 6px; background: var(--control-3); border-radius: 99px; overflow: hidden; min-width: 90px; }
.meter .fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.meter.gold .fill { background: var(--gold); }
.meter.warn .fill { background: var(--warn); }
.meter.danger .fill { background: var(--danger); }
.meter.big { height: 10px; margin: 12px 0 8px; }
.dugnad .big { font-size: 17px; font-weight: 700; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: var(--fs); margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; min-width: 0; }
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-head .name { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.profile-head .kv { font-size: 12.5px; gap: 4px 14px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: var(--fs); margin-bottom: 10px; }
.back:hover { color: var(--text); text-decoration: none; }
.answer { background: var(--bg-raised); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-sm); padding: 9px 12px; margin: 5px 0 12px; white-space: pre-wrap; }
.question { color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.chat-line { font-family: var(--mono); font-size: 12.5px; }
.error-box { display: flex; gap: 8px; align-items: flex-start; background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); border-radius: var(--r); padding: 9px 12px; margin: 0 0 12px; font-size: var(--fs); }
.error-box .icon { margin-top: 2px; }

/* ================================================================== toasts */
.toasts, #toasts {
  position: fixed; right: var(--s4); bottom: var(--s4); z-index: 80; display: flex; flex-direction: column-reverse; gap: 8px;
  width: 360px; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; padding: 10px 8px 10px 12px;
  background: var(--control-2); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); font-size: var(--fs);
  animation: rise var(--dur) var(--ease);
}
.toast > .icon { color: var(--info); }
.toast.ok > .icon { color: var(--accent); }
.toast.error > .icon { color: var(--danger); }
.toast.warn > .icon { color: var(--warn); }
.toast-text { flex: 1; min-width: 0; line-height: 1.35; }
.toast-text b { font-weight: 600; }
.toast-text .toast-sub { display: block; color: var(--text-2); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.toast .btn.sm { flex: 0 0 auto; }
@media (max-width: 639px) { .toasts, #toasts { left: var(--s4); right: var(--s4); width: auto; } .toast { min-width: 0; } }

/* ================================================================== modal */
.modal-bg {
  position: fixed; inset: 0; background: rgb(3 5 8 / .6); display: flex; align-items: flex-start; justify-content: center;
  z-index: 50; padding: 12vh 16px 16px; animation: fade-in var(--dur) ease-out; overflow-y: auto;
}
.modal { width: 460px; max-width: 100%; }
.modal.wide { width: 900px; }
.modal > .panel, .modal > .card, .modal-card {
  margin: 0; background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-modal);
  max-height: calc(88vh - 16px); overflow-y: auto; padding: 20px;
}
.modal > .panel > h2, .modal > .card > h2 { font-size: var(--fs-lg); margin-bottom: 12px; }
.modal-head { display: flex; align-items: center; gap: 8px; margin: -4px -6px 14px 0; }
.modal-head h2 { font-size: var(--fs-lg); flex: 1; min-width: 0; margin: 0 !important; }
.modal-head > .icon { color: var(--text-2); width: 18px; height: 18px; }
.modal-text { color: var(--text-2); font-size: var(--fs); margin: -6px 0 14px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: var(--s4); }
.modal-foot .hint { margin: 0 auto 0 0; }
.modal .panel .panel { box-shadow: none; }
@media (min-width: 760px) { .modal.wide .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ================================================================== confirm popover */
.pop {
  position: fixed; z-index: 65; width: 300px; max-width: calc(100vw - 16px); padding: 14px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  animation: fade-in var(--dur) ease-out;
}
.pop h2 { font-size: var(--fs-md); margin: 0 0 4px; }
.pop .pop-text { color: var(--text-2); font-size: var(--fs-sm); margin: 0 0 10px; }
.pop .field { margin-bottom: 10px; }
.pop .modal-foot { margin-top: 12px; }

/* ================================================================== command palette */
.cmdk-bg { position: fixed; inset: 0; z-index: 90; background: rgb(3 5 8 / .55); display: flex; justify-content: center; align-items: flex-start; padding: 15vh 16px 16px; animation: fade-in var(--dur) ease-out; }
.cmdk {
  width: 560px; max-width: 100%; background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-modal); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh;
}
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 48px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.cmdk-input > .icon { color: var(--text-3); }
.cmdk-input input { flex: 1; height: 46px; background: transparent; border: 0; box-shadow: none !important; padding: 0; font-size: var(--fs-md); }
.cmdk-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.cmdk-group { padding: 8px 10px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); }
.cmdk-opt {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r);
  color: var(--text-2); font-size: var(--fs); cursor: pointer; user-select: none;
}
.cmdk-opt[aria-selected="true"] { background: var(--control-2); color: var(--text); }
.cmdk-opt[aria-selected="true"] > .icon { color: var(--accent); }
.cmdk-opt .cmdk-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-opt .cmdk-meta { color: var(--text-3); font-size: var(--fs-sm); }
.cmdk-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: var(--fs); }
.cmdk-foot { display: flex; gap: 14px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--text-3); font-size: var(--fs-xs); flex: 0 0 auto; }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* shortcut overview */
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; font-size: var(--fs); margin: 0; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--text-2); }

/* ================================================================== login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 360px; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--snow);
  border-radius: var(--r-lg); padding: 28px 24px 24px; text-align: center;
}
.login-card .brand-mark { width: 44px; height: 44px; border-radius: var(--r-lg); margin-bottom: 14px; }
.login-card .brand-mark .icon { width: 24px; height: 24px; }
.login-card .brand-star { top: 4px; width: 6px; height: 6px; margin-left: -3px; }
.login-card h1 { font-family: var(--pixel); font-size: 18px; font-weight: 700; margin-bottom: 18px; letter-spacing: .02em; }
.login-step { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-2); font-size: var(--fs-md); margin-bottom: 12px; }
.login-code { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 14px; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: var(--r); }
.login-code code { background: none; border: 0; padding: 0; font-size: 17px; color: var(--accent); }
.login-card .error-box { text-align: left; margin-bottom: 16px; }

/* ---------- small shared fixes from the page work */
.table-wrap { position: relative; }  /* keeps the sr-only "Handlinger" header from widening the page */
.count-inline { font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- player search (playerSearch in core.js) */
.ps { position: relative; min-width: 0; }
.ps > input { width: 100%; }
.ps-list {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  max-height: 264px; overflow-y: auto; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-pop);
}
.ps-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; }
.ps-item .head { width: 22px; height: 22px; border-radius: 4px; flex: 0 0 auto; image-rendering: pixelated; }
.ps-item:hover, .ps-item[aria-selected="true"] { background: var(--control-2); }
.ps-item[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--accent); }
.ps-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-role { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); }
.ps-none { padding: 8px; color: var(--text-3); font-size: var(--fs-sm); }
