/* BrightBots panel. The tokens and the rules behind them are documented in DESIGN.md; change a value there
   and here. The palette, the type pair and the restraint are the BrightBots site's (brightdev-web/DESIGN.md):
   warm paper, ink, one marigold accent, Newsreader for display and Instrument Sans for text. Product
   modules use only these tokens, so a product never brings colours of its own. Discord previews are the
   one exception and live in discord.css. */

:root {
  /* Surfaces and text */
  --paper: #f3efe6;
  --paper-sunk: #e9e3d6;
  --surface: #fbf9f4;
  --ink: #1a1917;
  --ink-2: #4c473f;
  --ink-3: #6b655a;
  --rule: #d6cebd;
  --rule-strong: #b9b09d;
  /* Accent */
  --accent: #f2b33d;
  --accent-hover: #e6a52b;
  --on-accent: #1a1917;
  --accent-text: #8a5400;
  --accent-tint: #f6e5bf;
  --focus: #1a1917;
  /* States: text colour and a quiet tint behind it (AA on paper and on the tint) */
  --ok: #1d6b3a;
  --ok-tint: #dfeadb;
  --warn: #8a5400;
  --warn-tint: #f3e3c2;
  --danger: #a3271c;
  --danger-tint: #f4ddd6;
  /* Chart series */
  --series-1: #9a6200;
  --series-1-fill: rgb(242 179 61 / 0.22);
  --series-2: #4f6b7d;
  /* Shadow from one light source above; only menus, dialogs, windows and the save bar use it */
  --shadow: 0 1px 2px rgb(40 32 16 / 0.06), 0 12px 32px -12px rgb(40 32 16 / 0.22);
  --shadow-up: 0 -1px 0 var(--rule), 0 -12px 32px -16px rgb(40 32 16 / 0.18);
  --scrim: rgb(26 25 23 / 0.42);

  --font-display: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-text: 'Instrument Sans', 'Segoe UI', system-ui, sans-serif;
  --font-code: ui-monospace, 'Cascadia Code', Consolas, monospace;

  /* Type scale */
  --step--2: 0.75rem;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.375rem;
  --step-3: clamp(1.75rem, 1.4rem + 1.2vw, 2.375rem);
  --step-4: clamp(2.75rem, 2rem + 2.6vw, 4rem);

  /* Space */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;

  /* Radii */
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --fast: 150ms;
  --base: 220ms;
  --slow: 300ms;

  --sidebar: 248px;
  --gutter: 16px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --paper: #141311;
  --paper-sunk: #1b1a17;
  --surface: #211f1b;
  --ink: #eee9df;
  --ink-2: #c4bcae;
  --ink-3: #9e968a;
  --rule: #34312b;
  --rule-strong: #4a463e;
  --accent: #f2b33d;
  --accent-hover: #f6c25e;
  --on-accent: #1a1917;
  --accent-text: #f4c25e;
  --accent-tint: #3a2f19;
  --focus: #f4c25e;
  --ok: #86cf9c;
  --ok-tint: #1c2b20;
  --warn: #f4c25e;
  --warn-tint: #33291a;
  --danger: #f2907f;
  --danger-tint: #3a1f1a;
  --series-1: #f2b33d;
  --series-1-fill: rgb(242 179 61 / 0.16);
  --series-2: #8fb3c9;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -16px rgb(0 0 0 / 0.6);
  --shadow-up: 0 -1px 0 var(--rule), 0 -16px 40px -16px rgb(0 0 0 / 0.5);
  --scrim: rgb(0 0 0 / 0.55);
  color-scheme: dark;
}

@media (min-width: 768px) { :root { --gutter: 32px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; interpolate-size: allow-keywords; }
body {
  margin: 0; min-height: 100vh; overflow-x: clip;
  background: var(--paper); color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--font-text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p, ul, ol, dl, figure, blockquote { margin: 0; }
h1 { font: 500 var(--step-3)/1.08 var(--font-display); letter-spacing: -0.02em; font-optical-sizing: auto; text-wrap: balance; }
h2 { font-size: var(--step-1); line-height: 1.3; font-weight: 600; letter-spacing: -0.005em; text-wrap: balance; }
h3 { font-size: var(--step-0); line-height: 1.35; font-weight: 600; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .code { font-family: var(--font-code); font-size: 0.875em; }
strong { font-weight: 600; }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: var(--step--1); line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip {
  position: absolute; left: var(--gutter); top: -100px; z-index: 80;
  background: var(--ink); color: var(--paper); padding: var(--space-3) var(--space-4); border-radius: var(--radius-s);
  text-decoration: none; font-weight: 600;
}
.skip:focus { top: var(--space-3); }
.text-link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1.5px; text-underline-offset: 0.2em; transition: text-decoration-color var(--fast) var(--ease); }
.text-link:hover { text-decoration-color: var(--accent); }

/* ---------- Buttons: one marigold primary per view, everything else quiet ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-s);
  border: 1px solid transparent; background: none; color: var(--ink);
  font: 600 var(--step-0)/1.1 var(--font-text); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 -2px 0 rgb(26 25 23 / 0.14); }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-primary:not(:disabled):active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgb(26 25 23 / 0.14); }
.btn-ghost, .btn-quiet { border-color: var(--rule-strong); }
.btn-ghost:not(:disabled):hover, .btn-quiet:not(:disabled):hover { border-color: var(--ink-3); background: var(--surface); }
.btn-danger { border-color: var(--rule-strong); color: var(--danger); }
.btn-danger:not(:disabled):hover { border-color: var(--danger); background: var(--danger-tint); }
.btn-plain { padding: 0 8px; color: var(--ink-2); }
.btn-plain:not(:disabled):hover { color: var(--ink); background: var(--paper-sunk); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--step--1); }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: var(--step-1); }
.btn .icon { width: 16px; height: 16px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: var(--radius-s); border: 1px solid transparent; background: none; color: var(--ink-2); cursor: pointer;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.icon-btn:hover:not(:disabled) { color: var(--ink); background: var(--paper-sunk); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-tint); }
.icon-btn.tiny { width: 24px; height: 24px; }
.icon-btn.tiny .icon { width: 14px; height: 14px; }
.icon-btn.bordered { border-color: var(--rule-strong); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-5);
  padding: var(--space-5) var(--space-3) var(--space-4); overflow-y: auto; overflow-x: hidden;
  background: var(--paper-sunk); border-right: 1px solid var(--rule);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-2); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand-name { font-weight: 600; font-size: var(--step-1); letter-spacing: -0.01em; }
.brand-name span { color: var(--ink-3); font-weight: 500; margin-left: 4px; }
.menu-btn { display: none; }
.nav { display: grid; gap: var(--space-5); align-content: start; }
.nav-list { display: grid; gap: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 var(--space-3);
  border-radius: var(--radius-s); color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-item .icon { width: 17px; height: 17px; color: var(--ink-3); transition: color var(--fast) var(--ease); }
.nav-item:hover { background: rgb(26 25 23 / 0.05); color: var(--ink); }
:root[data-theme='dark'] .nav-item:hover { background: rgb(255 255 255 / 0.05); }
.nav-item[aria-current='page'] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--rule); }
.nav-item[aria-current='page']::before { content: ''; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item[aria-current='page'] .icon { color: var(--accent-text); }
.nav-group { display: grid; gap: 2px; min-width: 0; }
.nav-group .nav-group { margin-top: var(--space-3); }
.nav-heading { display: flex; align-items: center; gap: 8px; padding: 0 var(--space-3) var(--space-1); font-size: var(--step--1); font-weight: 600; color: var(--ink-3); }
.nav-server { display: flex; align-items: center; gap: 10px; min-width: 0; padding: var(--space-2) var(--space-3); border-top: 1px solid var(--rule); padding-top: var(--space-4); }
.nav-server img, .nav-server .guild-icon { width: 28px; height: 28px; }
.nav-server strong { font-size: var(--step-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { margin-top: auto; display: grid; gap: var(--space-3); padding: 0 var(--space-2); }
.demo-note { font-size: var(--step--1); color: var(--ink-2); padding: var(--space-3); border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.demo-note strong { display: block; color: var(--ink); }
.me { display: flex; align-items: center; gap: 10px; padding-top: var(--space-3); border-top: 1px solid var(--rule); }
.me img, .me .avatar { width: 32px; height: 32px; border-radius: 50%; }
.me div { min-width: 0; flex: 1; }
.me strong { display: block; font-size: var(--step--1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { display: block; color: var(--ink-3); font-size: var(--step--2); }
.avatar { display: grid; place-items: center; background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule); }
.prefs { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.lang { display: inline-flex; padding: 2px; border: 1px solid var(--rule-strong); border-radius: var(--radius-s); }
.lang button { border: 0; background: none; padding: 4px 8px; border-radius: 4px; font-size: var(--step--1); font-weight: 600; color: var(--ink-3); cursor: pointer; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.lang button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
/* Six languages: in the 248px sidebar the switch takes the free width and its buttons share it evenly. */
.sidebar .lang { flex: 1 1 auto; min-width: 0; }
.sidebar .lang button { flex: 1 1 0; min-width: 0; padding: 4px 0; text-align: center; }

.main { min-width: 0; padding: var(--space-6) var(--gutter) 140px; outline: none; }
.page { display: grid; gap: var(--space-6); max-width: 1180px; margin: 0 auto; align-content: start; }
.page > *, .settings-body > *, .section > * { min-width: 0; }
.view-enter { animation: view-in var(--base) var(--ease) both; }
@keyframes view-in { from { opacity: 0; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-head > div { display: grid; gap: var(--space-2); min-width: 0; }
.page-head p { color: var(--ink-2); max-width: 70ch; }
.eyebrow-server { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: var(--step--1); font-weight: 500; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: var(--step--1); justify-self: start; }
.back-link:hover { color: var(--ink); }

/* ---------- Sections: a heading over a rule, never a box ---------- */
.section { display: grid; gap: var(--space-4); min-width: 0; align-content: start; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--rule); }
.section-head > div { display: grid; gap: 2px; min-width: 0; }
.section-head p { color: var(--ink-3); font-size: var(--step--1); }
.section-actions { display: flex; gap: var(--space-2); flex: none; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-7); }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); }
.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--space-7); align-items: start; }
.band { background: var(--paper-sunk); border-radius: var(--radius-m); padding: var(--space-5); }
.empty { color: var(--ink-2); padding: var(--space-4) 0; max-width: 60ch; }
.empty.small { padding: var(--space-2) 0; font-size: var(--step--1); color: var(--ink-3); }

/* Empty states that teach the next step */
.teach { display: grid; gap: var(--space-3); justify-items: start; padding: var(--space-5) 0; max-width: 56ch; }
.teach h3 { font: 500 var(--step-2)/1.2 var(--font-display); letter-spacing: -0.01em; }
.teach p { color: var(--ink-2); }

/* ---------- Focal metrics and the dense secondary row ---------- */
.focal { display: grid; gap: var(--space-5); }
.focal-figures { display: flex; flex-wrap: wrap; gap: var(--space-5) var(--space-8); align-items: flex-end; }
.figure { display: grid; gap: 4px; }
.figure-value { font: 500 var(--step-4)/0.95 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: lining-nums tabular-nums; }
.figure-value small { font: 500 var(--step-2)/1 var(--font-display); color: var(--ink-3); margin-left: 6px; letter-spacing: 0; }
.figure-label { font-weight: 600; }
.figure-note { color: var(--ink-3); font-size: var(--step--1); max-width: 40ch; }
.figure.is-quiet .figure-value { font-size: clamp(2rem, 1.6rem + 1.4vw, 2.75rem); color: var(--ink-2); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.metric { display: grid; gap: 2px; padding: var(--space-3) var(--space-4) var(--space-3) 0; min-width: 0; }
.metric + .metric { padding-left: var(--space-4); border-left: 1px solid var(--rule); }
.metric dt { font-size: var(--step--1); color: var(--ink-3); font-weight: 500; }
.metric dd { margin: 0; font-size: var(--step-1); font-weight: 600; }
.metric dd small { font-size: var(--step--1); font-weight: 500; color: var(--ink-3); margin-left: 4px; }

/* ---------- Charts ---------- */
.chart { position: relative; min-width: 0; overflow: hidden; }
.chart svg { display: block; overflow: visible; }
.legend { display: flex; gap: var(--space-4); font-size: var(--step--1); color: var(--ink-2); margin-bottom: var(--space-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.key-s1 { background: var(--series-1); }
.key-s2 { background: var(--series-2); }
.grid { stroke: var(--rule); stroke-width: 1; }
.grid.base { stroke: var(--rule-strong); }
.axis { fill: var(--ink-3); font: 500 11px var(--font-text); font-variant-numeric: tabular-nums; }
.line-s1, .line-s2 { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-s1 { stroke: var(--series-1); }
.line-s2 { stroke: var(--series-2); stroke-dasharray: 4 3; }
.area-s1 { fill: var(--series-1-fill); }
.crosshair { stroke: var(--ink-3); stroke-width: 1; }
.dot-s1, .dot-s2 { stroke: var(--paper); stroke-width: 2; }
.dot-s1 { fill: var(--series-1); }
.dot-s2 { fill: var(--series-2); }
.chart:has(.tooltip) { overflow: visible; }
.tooltip {
  position: absolute; top: 28px; transform: translateX(-50%); pointer-events: none; z-index: 2;
  display: grid; gap: 4px; min-width: 180px; padding: 10px 12px; font-size: var(--step--1);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-s); box-shadow: var(--shadow);
  animation: pop-in var(--fast) var(--ease);
}
.tooltip span { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.tooltip b { margin-left: auto; color: var(--ink); }
.barlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.barlist li { display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr) 44px; align-items: center; gap: 12px; font-size: var(--step--1); }
.barlist-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.barlist-track { height: 8px; border-radius: 4px; background: var(--paper-sunk); overflow: hidden; }
.barlist-bar { display: block; height: 100%; border-radius: 0 4px 4px 0; transition: width var(--slow) var(--ease); }
.bar-s1 { background: var(--series-1); }
.bar-s2 { background: var(--series-2); }
.barlist-value { text-align: right; font-weight: 600; }

/* ---------- Tables and ruled lists ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--step-0); }
.table th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: var(--step--1); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.table td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; white-space: nowrap; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table .num { text-align: right; }
.table .rank { color: var(--ink-3); width: 32px; }
.table td.wrap { white-space: normal; min-width: 220px; }
.table tr.clickable { cursor: pointer; transition: background-color var(--fast) var(--ease); }
.table tr.clickable:hover td { background: var(--paper-sunk); }
.table td.current { font-weight: 700; color: var(--ink); background: var(--accent-tint); }
.table th.current { color: var(--ink); }
.ticket-no { font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; }
.ticket-no:hover { text-decoration-color: var(--accent); }
.rating-cell { display: inline-flex; align-items: center; gap: 8px; font-size: var(--step--1); }
.user { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.user-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-id { font-size: var(--step--1); color: var(--ink-3); }
.stars { display: inline-flex; gap: 1px; }
.star { width: 14px; height: 14px; color: var(--rule-strong); }
.star.on { color: var(--accent-text); fill: var(--accent); }
.badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--radius-pill); font-size: var(--step--1); font-weight: 600; white-space: nowrap; line-height: 1.4; }
.badge .icon { width: 13px; height: 13px; }
.badge-ok { color: var(--ok); background: var(--ok-tint); }
.badge-neutral { color: var(--ink-2); background: var(--paper-sunk); }
.badge-muted { color: var(--ink-3); background: transparent; box-shadow: inset 0 0 0 1px var(--rule); }
.badge-warn { color: var(--warn); background: var(--warn-tint); }
.badge-danger { color: var(--danger); background: var(--danger-tint); }
.badge-gold { color: var(--on-accent); background: var(--accent); }
:root[data-theme='dark'] .badge-gold { color: #1a1917; }

/* ---------- Server list ---------- */
.server-table { width: 100%; border-collapse: collapse; }
.server-table th { text-align: left; font-size: var(--step--1); font-weight: 600; color: var(--ink-3); padding: 0 16px 10px 0; border-bottom: 1px solid var(--rule-strong); }
.server-table td, .server-table tbody th { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; text-align: left; font-weight: inherit; }
.server-table tbody th { width: 40%; }
.server-table tr { transition: background-color var(--fast) var(--ease); }
.server-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.server-name strong { display: block; font-size: var(--step-1); font-weight: 600; overflow-wrap: anywhere; }
.server-name small { display: block; color: var(--ink-3); font-size: var(--step--1); }
.guild-icon { width: 40px; height: 40px; border-radius: 12px; flex: none; object-fit: cover; }
span.guild-icon { display: grid; place-items: center; background: var(--paper-sunk); color: var(--ink-2); font-weight: 600; font-size: var(--step--1); border: 1px solid var(--rule); }
.product-state { display: grid; gap: 6px; justify-items: start; }
.state-line { display: inline-flex; align-items: center; gap: 6px; font-size: var(--step--1); color: var(--ink-2); }
.state-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--rule-strong); }
.state-dot.on { background: var(--ok); }
.state-dot.unknown { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.state-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.server-filter { max-width: 320px; }

/* Popover menus: scale and fade from the edge they open from */
.popover-wrap { position: relative; display: inline-block; }
.popover {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(360px, calc(100vw - 32px));
  display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); box-shadow: var(--shadow);
  transform-origin: top left; animation: pop-in 180ms var(--ease);
}
.popover.align-end { left: auto; right: 0; transform-origin: top right; }
.popover-item { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-s); text-decoration: none; color: var(--ink); transition: background-color var(--fast) var(--ease); }
.popover-item:hover, .popover-item:focus-visible { background: var(--paper-sunk); }
.popover-item strong { display: flex; align-items: center; gap: 8px; }
.popover-item span { color: var(--ink-2); font-size: var(--step--1); }
.popover-note { padding: 8px 12px 6px; border-top: 1px solid var(--rule); margin-top: 4px; color: var(--ink-3); font-size: var(--step--1); }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }

/* ---------- Callouts: a ruled note, not a box ---------- */
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-left: 3px solid var(--rule-strong); background: var(--paper-sunk); border-radius: 0 var(--radius-s) var(--radius-s) 0; font-size: var(--step-0); }
.callout > .icon { margin-top: 2px; color: var(--ink-2); }
.callout > div { display: grid; gap: 6px; justify-items: start; min-width: 0; }
/* Early access: one calm note under the page head (products/shared/early-access.js). */
.early-note .callout { max-width: 72ch; }
.early-link { color: var(--accent-text); font-weight: 600; text-underline-offset: 3px; }
.early-link:hover { text-decoration-thickness: 2px; }
.callout-ok { border-left-color: var(--ok); }
.callout-ok > .icon { color: var(--ok); }
.callout-gold, .callout-info { border-left-color: var(--accent); }
.callout-gold > .icon { color: var(--accent-text); }
.callout-danger { border-left-color: var(--danger); background: var(--danger-tint); }
.callout-danger > .icon { color: var(--danger); }
.callout-warn { border-left-color: var(--warn); background: var(--warn-tint); }
.callout-warn > .icon { color: var(--warn); }
.steps { margin: 2px 0 0; padding-left: 20px; list-style: decimal outside; display: grid; gap: 2px; }
.steps li { padding-left: 2px; }

/* ---------- Loading: skeletons shaped like the content ---------- */
.skeleton { display: grid; gap: var(--space-6); max-width: 1180px; margin: 0 auto; animation: view-in var(--base) var(--ease) 120ms both; }
.sk { display: block; background: var(--paper-sunk); border-radius: 4px; }
:root[data-theme='dark'] .sk { background: #26231f; }
.sk-title { height: 40px; width: min(360px, 70%); }
.sk-line { height: 12px; width: 100%; }
.sk-line.short { width: 45%; }
.sk-figure { height: 64px; width: 120px; }
.sk-chart { height: 220px; width: 100%; border-radius: var(--radius-s); }
.sk-row { display: flex; gap: var(--space-4); align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.sk-dot { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.sk-field { height: 40px; width: 100%; border-radius: var(--radius-s); }
.sk-group { display: grid; gap: var(--space-3); }
.sk-split { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--space-6); }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--ink-3); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: var(--gutter); bottom: 96px; display: grid; gap: 8px; z-index: 70; width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 8px 12px 14px; border-radius: var(--radius-s); background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-size: var(--step--1); animation: toast-in var(--base) var(--ease); }
.toast p { flex: 1; padding-top: 1px; }
.toast > .icon { margin-top: 1px; }
.toast-ok > .icon { color: #86cf9c; }
.toast-danger > .icon { color: #f2907f; }
.toast .icon-btn { width: 26px; height: 26px; color: inherit; opacity: 0.7; }
.toast .icon-btn:hover { background: rgb(255 255 255 / 0.1); opacity: 1; }
:root[data-theme='dark'] .toast .icon-btn:hover { background: rgb(0 0 0 / 0.1); }
:root[data-theme='dark'] .toast-ok > .icon { color: var(--ok-tint); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Dialog ---------- */
.dialog-layer { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: var(--gutter); background: var(--scrim); animation: fade-in var(--base) var(--ease); }
.dialog {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  display: grid; gap: var(--space-4); padding: var(--space-5);
  background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow);
  animation: dialog-in var(--base) var(--ease);
}
.dialog h2 { font: 500 var(--step-2)/1.2 var(--font-display); letter-spacing: -0.01em; }
.dialog p { color: var(--ink-2); }
.dialog-items { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); border-top: 1px solid var(--rule); padding-top: var(--space-3); }
.dialog-items > li { display: grid; gap: 2px; font-size: var(--step--1); }
.dialog-items strong { font-size: var(--step-0); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; padding-top: var(--space-2); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.96); } }

/* ---------- Form ---------- */
input, select, textarea {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 12px;
  color: var(--ink); background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius-s);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b655a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea { resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
input[aria-invalid='true'], textarea[aria-invalid='true'], select[aria-invalid='true'] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
input.code, textarea.code, input.mono, textarea.mono { font-family: var(--font-code); font-size: var(--step--1); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--space-5) var(--space-5); align-items: start; }
.form-grid > .local { grid-column: 1 / -1; }
.form-field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.form-field .label, legend.label { font-weight: 600; font-size: var(--step-0); padding: 0; }
.help { color: var(--ink-3); font-size: var(--step--1); }
.field-errors { display: grid; gap: 4px; }
.field-error { display: flex; gap: 6px; align-items: flex-start; color: var(--danger); font-size: var(--step--1); animation: fade-in var(--fast) var(--ease); }
.field-error .icon { width: 15px; height: 15px; margin-top: 2px; }
.field-error > div { display: grid; gap: 2px; }
.field-error .steps { color: var(--ink-2); }
.local-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.local-input { position: relative; display: block; }
.local-input input, .local-input textarea { padding-left: 44px; }
.lang-tag { position: absolute; left: 8px; top: 9px; font-size: var(--step--2); font-weight: 600; color: var(--ink-2); background: var(--paper-sunk); border-radius: 4px; padding: 2px 5px; pointer-events: none; }
.num-input { max-width: 180px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.toggle-field { align-self: center; }
.switch { display: flex; align-items: center; gap: 12px; border: 0; background: none; color: inherit; padding: 4px 0; cursor: pointer; text-align: left; }
.switch-track { flex: none; width: 40px; height: 24px; border-radius: 12px; background: var(--paper-sunk); box-shadow: inset 0 0 0 1px var(--rule-strong); position: relative; transition: background-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.switch-thumb { position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-3); transition: transform var(--base) var(--ease), background-color var(--fast) var(--ease); }
.switch[aria-checked='true'] .switch-track { background: var(--ink); box-shadow: none; }
.switch[aria-checked='true'] .switch-thumb { transform: translateX(16px); background: var(--accent); }
.switch-text { display: grid; gap: 1px; }
.switch-state { font-size: var(--step--1); color: var(--ink-3); }

/* Lists of entries (categories, panels, menus): ruled rows that expand smoothly */
.stack-lg { display: grid; gap: var(--space-3); }
.item { border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); }
.item > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; border-radius: var(--radius-m); }
.item > summary::-webkit-details-marker { display: none; }
.item > summary:hover { background: var(--paper-sunk); }
.item::details-content { block-size: 0; overflow: clip; transition: block-size var(--base) var(--ease), content-visibility var(--base) allow-discrete; }
.item[open]::details-content { block-size: auto; }
.item-icon { width: 32px; height: 32px; border-radius: var(--radius-s); display: grid; place-items: center; color: var(--ink-2); background: var(--paper-sunk); flex: none; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chev { margin-left: auto; color: var(--ink-3); transition: transform var(--base) var(--ease); }
.item[open] > summary .chev { transform: rotate(90deg); }
.item-body { display: grid; gap: var(--space-5); padding: var(--space-2) 16px var(--space-5); }
.item-flat { padding: 12px 16px; display: grid; gap: var(--space-4); }
.item-foot { display: flex; justify-content: flex-end; gap: 4px; align-items: center; }
.key-chip { font-family: var(--font-code); font-size: var(--step--2); color: var(--ink-3); background: var(--paper-sunk); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.subsection { display: grid; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--rule); }
.subsection > .btn { justify-self: start; }
.question { border-left: 3px solid var(--rule); padding: 4px 0 4px 16px; display: grid; gap: var(--space-3); }
.question-head { display: flex; align-items: center; gap: 10px; }
.row-actions { margin-left: auto; display: flex; gap: 2px; align-items: center; }
.add-key { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding-top: var(--space-2); }
.add-key .form-field { flex: 1 1 260px; }
.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pick-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-s); border: 1px solid var(--rule); background: var(--surface); }
.pick-list li.picked { border-color: var(--rule-strong); }
.pick-list label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-width: 0; }
.pick-list input { width: 17px; height: 17px; min-height: 0; accent-color: var(--ink); flex: none; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 2px 2px 10px; border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--rule-strong); font-size: var(--step--1); animation: pop-in var(--fast) var(--ease); }
.chip-missing { border-color: var(--danger); color: var(--danger); }
.chip-warn { border-color: var(--warn); }
.chip-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }

/* Permission status next to a picked channel or role */
.perm { display: flex; gap: 6px; align-items: flex-start; font-size: var(--step--1); }
.perm .icon { width: 15px; height: 15px; margin-top: 2px; flex: none; }
.perm-ok { color: var(--ok); }
.perm-warn { color: var(--warn); }
.perm-warn > div { display: grid; gap: 2px; }
.perm-warn .steps { color: var(--ink-2); }
.perm-named { display: grid; gap: 2px; font-size: var(--step--1); }

/* Send to channel */
.send-panel { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--paper-sunk); border-radius: var(--radius-s); }
.send-panel > div { display: grid; gap: 2px; min-width: 0; }
.send-state { display: flex; gap: 8px; align-items: center; font-size: var(--step--1); color: var(--ink-2); flex-wrap: wrap; font-weight: 500; }
.send-state a { display: inline-flex; gap: 4px; align-items: center; }
.send-live { color: var(--ok); }

/* Problems and server checks above the form */
.problems { display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-left: 3px solid var(--danger); background: var(--danger-tint); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.problems h2 { display: flex; gap: 10px; align-items: center; color: var(--danger); font-size: var(--step-0); }
.problems > p { color: var(--ink-2); font-size: var(--step--1); }
.problems ul { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-2); }
.problems ul > li { display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: var(--step--1); padding-top: var(--space-2); border-top: 1px solid rgb(163 39 28 / 0.15); }
.problems ul > li > div { display: grid; gap: 2px; }
.problems-checks { border-left-color: var(--warn); background: var(--warn-tint); }
.problems-checks h2 { color: var(--warn); }
.problems-checks ul > li { border-top-color: rgb(138 84 0 / 0.18); }

/* Settings: sticky grouped section nav, the form, and the save bar */
.settings-layout { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: var(--space-7); align-items: start; }
.subnav { position: sticky; top: var(--space-5); display: grid; gap: var(--space-4); max-height: calc(100vh - 48px); overflow-y: auto; padding-bottom: var(--space-4); }
.subnav-group { display: grid; gap: 1px; }
.subnav-heading { font-size: var(--step--1); font-weight: 600; color: var(--ink-3); padding: 0 10px 4px; }
.subnav button { position: relative; display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-s); background: none; color: var(--ink-2); font-weight: 500; cursor: pointer; text-align: left; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.subnav button .icon { width: 16px; height: 16px; color: var(--ink-3); }
.subnav button:hover { background: var(--paper-sunk); color: var(--ink); }
.subnav button[aria-current='true'] { background: var(--paper-sunk); color: var(--ink); font-weight: 600; }
.subnav button[aria-current='true']::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.subnav button[aria-current='true'] .icon { color: var(--accent-text); }
.subnav .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font-size: var(--step--2); font-weight: 700; color: var(--surface); background: var(--danger); }
.subnav .on-dot { margin-left: auto; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.subnav .on-dot + .count { margin-left: 6px; }
.settings-body { display: grid; gap: var(--space-6); min-width: 0; }
.settings-intro { display: grid; gap: var(--space-2); }
.settings-intro h2 { font: 500 var(--step-2)/1.2 var(--font-display); letter-spacing: -0.01em; }
.settings-intro p { color: var(--ink-2); }
.feature-head { display: flex; justify-content: space-between; gap: var(--space-4); align-items: flex-start; padding-bottom: var(--space-4); border-bottom: 1px solid var(--rule); }
.feature-head > div:first-child { display: grid; gap: var(--space-2); }
.feature-head h2 { font: 500 var(--step-2)/1.2 var(--font-display); letter-spacing: -0.01em; }
.feature-head p { color: var(--ink-2); max-width: 64ch; }
.feature-off { color: var(--ink-3); font-size: var(--step--1); }
.savebar {
  position: fixed; left: var(--sidebar); right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); box-shadow: var(--shadow-up);
  transform: translateY(calc(100% + 8px)); visibility: hidden;
  transition: transform var(--base) var(--ease), visibility 0s linear var(--base);
}
.savebar.is-shown { transform: none; visibility: visible; transition: transform var(--base) var(--ease), visibility 0s; }
.savebar-text { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: var(--step-0); min-width: 0; }
.savebar-text > p { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.savebar-text > p::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.savebar-actions { display: flex; gap: var(--space-2); }

/* Previews */
.preview { display: grid; gap: var(--space-3); }
.preview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.preview-head > div { display: grid; gap: 2px; }
.preview-head h3 { display: flex; align-items: center; gap: 8px; }
.preview-head .icon { color: var(--ink-3); }
.preview-note { color: var(--ink-3); font-size: var(--step--1); }
.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius-s); border: 1px solid var(--rule-strong); }
.segmented button { border: 0; background: none; color: var(--ink-2); font-weight: 600; font-size: var(--step--1); padding: 6px 12px; border-radius: 4px; cursor: pointer; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.segmented button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.segmented-langs button { padding: 6px 10px; min-width: 40px; }
.appearance { border: 0; padding: 0; margin: 0; min-width: 0; }
.appearance[disabled] { opacity: 0.6; }
.appearance-layout { display: grid; gap: var(--space-7); grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.appearance-layout .preview { position: sticky; top: var(--space-5); }
.image-preview { display: grid; place-items: center; min-height: 96px; border: 1px dashed var(--rule-strong); border-radius: var(--radius-s); padding: 10px; background: var(--paper-sunk); }
.image-preview img { max-width: 100%; max-height: 160px; border-radius: var(--radius-s); }
.image-avatar img { width: 96px; height: 96px; object-fit: cover; border-radius: 50%; }
.file-btn { cursor: pointer; }

/* Filters on list pages */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.search-field { position: relative; flex: 1 1 280px; display: block; }
.search-field .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search-field input { padding-left: 38px; }
.select-field { flex: 0 1 220px; display: block; }
.result-count { font-size: var(--step--1); color: var(--ink-3); }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; font-size: var(--step--1); color: var(--ink-2); }
.is-loading { opacity: 0.55; transition: opacity var(--fast) var(--ease); }

/* Ticket detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--space-7); align-items: start; }
.detail-main { display: grid; gap: var(--space-6); }
.facts, .answers { margin: 0; display: grid; }
.facts div, .answers div { display: grid; grid-template-columns: minmax(120px, 36%) minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.answers div { grid-template-columns: 1fr; gap: 4px; }
dt { color: var(--ink-3); font-size: var(--step--1); font-weight: 500; }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.stack { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.rating-box { display: flex; gap: 18px; align-items: flex-start; }
.rating-score { display: flex; align-items: baseline; gap: 4px; font-family: var(--font-display); }
.rating-score strong { font-size: 48px; font-weight: 500; line-height: 1; }
.rating-score span { color: var(--ink-3); }
.rating-box > div:last-child { display: grid; gap: 6px; }
blockquote { padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--paper-sunk); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.ev { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; position: relative; padding-bottom: 16px; }
.ev:not(:last-child)::before { content: ''; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 1px; background: var(--rule-strong); }
.ev-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-sunk); color: var(--ink-2); }
.ev-icon .icon { width: 14px; height: 14px; }
.ev-claimed .ev-icon, .ev-helperJoined .ev-icon { color: var(--ok); background: var(--ok-tint); }
.ev-closed .ev-icon, .ev-channelGone .ev-icon { color: var(--danger); background: var(--danger-tint); }
.ev-rated .ev-icon, .ev-warned .ev-icon, .ev-alerted .ev-icon, .ev-priority .ev-icon { color: var(--warn); background: var(--warn-tint); }
.ev p { padding-top: 3px; }

/* Overview lists: recent cases and alerts */
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed > li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.feed-no { font-weight: 600; color: var(--ink-3); font-size: var(--step--1); min-width: 40px; }
.feed-main { display: grid; gap: 2px; min-width: 0; }
.feed-main p { color: var(--ink-2); font-size: var(--step--1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { color: var(--ink-3); font-size: var(--step--1); white-space: nowrap; }
.feed-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.alerts > li { display: grid; gap: 4px; padding: 12px 16px; border-left: 3px solid var(--warn); background: var(--warn-tint); border-radius: 0 var(--radius-s) var(--radius-s) 0; font-size: var(--step--1); }
.alerts > li.is-danger { border-left-color: var(--danger); background: var(--danger-tint); }
.alerts > li > strong { font-size: var(--step-0); }
.alerts > li > .btn { justify-self: start; margin-top: 4px; }
.all-clear { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); padding: 12px 0; }
.all-clear .icon { color: var(--ok); margin-top: 2px; }

/* First-run guide */
.guide { display: grid; gap: var(--space-4); padding: var(--space-5); background: var(--paper-sunk); border-radius: var(--radius-m); }
.guide-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.guide-head > div { display: grid; gap: 4px; }
.guide-head h2 { font: 500 var(--step-2)/1.2 var(--font-display); letter-spacing: -0.01em; }
.guide-head p { color: var(--ink-2); max-width: 60ch; }
.guide-progress { font-size: var(--step--1); color: var(--ink-3); font-weight: 600; }
.guide-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); counter-reset: step; }
.guide-steps li { counter-increment: step; display: grid; gap: var(--space-3); align-content: space-between; padding: var(--space-4); background: var(--surface); border-radius: var(--radius-s); border-top: 3px solid var(--rule-strong); }
.guide-steps li::before { content: counter(step); font: 500 var(--step-2)/1 var(--font-display); color: var(--ink-3); }
.guide-steps li.is-next { border-top-color: var(--accent); }
.guide-steps li.is-done { border-top-color: var(--ok); }
.guide-steps li.is-done::before { content: none; }
.guide-steps li > p { font-weight: 500; }
.guide-steps .done { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: var(--step--1); font-weight: 600; }

/* ---------- Plan page: comparison and prices on the left, one purchase panel on the right ---------- */
.plan-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(300px, 5fr); gap: var(--space-7); align-items: start; }
.plan-grid-single { grid-template-columns: minmax(0, 1fr); }
.plan-main { display: grid; gap: var(--space-6); min-width: 0; }
.page-head > .plan-head-side { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.plan-table th, .plan-table td { white-space: normal; }
.plan-table tbody th { font-weight: 500; color: var(--ink); padding: 12px 12px 12px 0; border-bottom: 1px solid var(--rule); font-size: var(--step-0); }
.plan-table thead th { vertical-align: bottom; }
.plan-table .plan-premium { background: color-mix(in srgb, var(--accent-tint) 60%, transparent); padding-left: 12px; }
.plan-table thead .plan-premium { color: var(--accent-text); }
.plan-table td.is-current { color: var(--ink); font-weight: 600; }
.plan-table th.is-current { color: var(--ink); }
.plan-current { display: block; font-size: var(--step--2); font-weight: 500; color: var(--ink-3); }
.plan-yes { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 600; }
.plan-yes .icon { width: 15px; height: 15px; }
.plan-no { color: var(--ink-3); font-weight: 400; }
.plan-prices th[scope='row'] { font-weight: 500; color: var(--ink); padding: 12px 12px 12px 0; border-bottom: 1px solid var(--rule); font-size: var(--step-0); text-align: left; }
.plan-how { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; color: var(--ink-2); font-size: var(--step--1); max-width: 70ch; }

/* The purchase panel is a sunk band like the first-run guide: one primary button, no shadow. */
.plan-buy { position: sticky; top: var(--space-5); display: grid; gap: var(--space-4); padding: var(--space-5); background: var(--paper-sunk); border-radius: var(--radius-m); min-width: 0; }
.plan-buy-head { display: grid; gap: 4px; }
.plan-buy-head h2 { font: 500 var(--step-2)/1.2 var(--font-display); letter-spacing: -0.01em; }
.plan-buy-head p { color: var(--ink-2); }
.plan-choice, .plan-consent { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--space-2); }
.plan-choice legend, .plan-consent legend { padding: 0; margin-bottom: var(--space-2); font-weight: 600; }
.plan-choice-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-2); }
.plan-option {
  position: relative; display: grid; gap: 2px; align-content: center; min-height: 48px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius-s); cursor: pointer;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.plan-option:hover { border-color: var(--ink-3); }
.plan-option.is-on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.plan-option.is-off { opacity: 0.5; cursor: not-allowed; }
.plan-option input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: inherit; }
.plan-option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.plan-option-label { font-weight: 600; }
.plan-option-note { font-size: var(--step--1); color: var(--ink-2); }
.plan-price { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; padding-top: var(--space-2); border-top: 1px solid var(--rule); }
.plan-amount { font: 500 clamp(2.25rem, 1.8rem + 1.4vw, 2.75rem)/1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: lining-nums tabular-nums; }
.plan-per { color: var(--ink-2); }
.plan-saving { color: var(--accent-text); font-weight: 600; font-size: var(--step--1); }
.plan-terms { color: var(--ink-2); font-size: var(--step--1); }
.plan-consent { gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--rule); }
/* A floated legend sits inside the fieldset, below its top rule, instead of cutting through it. */
.plan-consent legend { float: left; width: 100%; margin-bottom: 0; }
.plan-consent-item { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.plan-consent-item input { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 3px 0 0; flex: none; accent-color: var(--ink); }
.plan-cta { width: 100%; white-space: normal; text-align: center; line-height: 1.25; padding-block: 10px; }
.plan-secure { display: flex; gap: 8px; align-items: flex-start; font-size: var(--step--1); color: var(--ink-3); }
.plan-secure .icon { width: 14px; height: 14px; margin-top: 3px; }
.plan-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.plan-claim { display: grid; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--rule); }
@media (max-width: 1100px) {
  .plan-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
  .plan-buy { position: static; }
}
@media (max-width: 640px) {
  .plan-buy { padding: var(--space-4); }
}

/* ---------- Members: avatar, display name and ID ---------- */
.member { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; }
.member-avatar { width: 22px; height: 22px; border-radius: 50%; flex: none; object-fit: cover; background: var(--paper-sunk); }
span.member-avatar { display: grid; place-items: center; color: var(--ink-3); border: 1px solid var(--rule); }
span.member-avatar .icon { width: 13px; height: 13px; }
.member-text { display: grid; min-width: 0; line-height: 1.25; }
.member-name { font-weight: 500; white-space: normal; overflow-wrap: anywhere; }
.member-left { color: var(--ink-2); }
.member-id { font-family: var(--font-code); font-size: var(--step--2); color: var(--ink-3); overflow-wrap: anywhere; }
.member .sk-line { width: 96px; height: 10px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.login-copy { display: grid; grid-template-rows: auto 1fr auto; gap: var(--space-6); padding: var(--space-5) clamp(24px, 5vw, 72px) var(--space-5); }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.login-top .prefs { gap: var(--space-3); }
.login-main { display: grid; gap: var(--space-5); align-content: center; max-width: 520px; }
.login-main h1 { font-size: clamp(2.25rem, 1.6rem + 2.4vw, 3.5rem); line-height: 1.04; letter-spacing: -0.025em; }
.login-main .lead { font-size: var(--step-1); line-height: 1.55; color: var(--ink-2); }
.login-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); color: var(--ink-2); }
.login-facts li { display: flex; gap: 10px; align-items: flex-start; }
.login-facts .icon { color: var(--accent-text); margin-top: 3px; }
.login-action { display: grid; gap: var(--space-3); justify-items: start; padding-top: var(--space-2); }
.login-foot { color: var(--ink-3); font-size: var(--step--1); max-width: 520px; }
.login-visual { display: grid; align-content: center; justify-items: center; gap: var(--space-4); padding: var(--space-7) clamp(24px, 4vw, 64px); background: var(--paper-sunk); border-left: 1px solid var(--rule); }
.login-visual .dc-window { width: min(560px, 100%); }
.login-visual figcaption { width: min(560px, 100%); color: var(--ink-3); font-size: var(--step--1); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .split, .detail-grid, .cols-3 { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
  .appearance-layout { grid-template-columns: minmax(0, 1fr); }
  .appearance-layout .preview { position: static; }
}
@media (max-width: 1024px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .subnav { position: sticky; top: 56px; z-index: 20; display: flex; gap: 4px; overflow-x: auto; max-height: none; padding: 8px 0; margin: 0 calc(var(--gutter) * -1); padding-inline: var(--gutter); background: var(--paper); border-bottom: 1px solid var(--rule); scrollbar-width: none; }
  .subnav-group { display: flex; gap: 2px; }
  .subnav-heading { display: none; }
  .subnav button { white-space: nowrap; flex: none; }
  .subnav button[aria-current='true']::before { left: 10px; right: 10px; top: auto; bottom: -1px; width: auto; height: 2px; border-radius: 2px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 50; height: 56px; padding: 0 var(--gutter); gap: 0; overflow: visible; border-right: 0; border-bottom: 1px solid var(--rule); justify-content: center; }
  .sidebar-top { padding: 0; }
  .menu-btn { display: inline-grid; }
  .sidebar-sheet { display: none; }
  .nav-open .sidebar-sheet {
    display: flex; flex-direction: column; gap: var(--space-5);
    position: fixed; left: 0; right: 0; top: 56px; bottom: 0; overflow-y: auto; padding: var(--space-5) var(--gutter);
    background: var(--paper-sunk); transform-origin: top center; animation: sheet-in var(--base) var(--ease);
  }
  .nav-item[aria-current='page']::before { left: -8px; }
  .main { padding-top: var(--space-5); }
  .savebar { left: 0; }
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-visual { border-left: 0; border-top: 1px solid var(--rule); padding: var(--space-6) var(--gutter); }
  .login-copy { padding-inline: var(--gutter); }
}
@keyframes sheet-in { from { opacity: 0; transform: scale(0.98); } }
@media (min-width: 901px) { .sidebar-sheet { display: contents; } }
@media (max-width: 760px) {
  .server-table thead { display: none; }
  .server-table, .server-table tbody, .server-table tr, .server-table td, .server-table tbody th { display: block; width: auto; }
  .server-table tr { padding: var(--space-4) 0; border-bottom: 1px solid var(--rule); }
  .server-table td, .server-table tbody th { border: 0; padding: 0; }
  .server-table tbody th ~ td { margin-top: var(--space-3); padding-left: 52px; }
  .server-table td[data-label]::before { content: attr(data-label); display: block; font-size: var(--step--1); font-weight: 600; color: var(--ink-3); margin-bottom: 4px; }
  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; }
  .responsive-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 14px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
  .responsive-table td { padding: 0; border: 0; display: grid; gap: 2px; min-width: 0; align-content: start; white-space: normal; }
  .responsive-table td.wrap { grid-column: 1 / -1; min-width: 0; }
  .responsive-table td::before { content: attr(data-label); font-size: var(--step--2); font-weight: 600; color: var(--ink-3); }
  .responsive-table td > .badge, .responsive-table td > .member { justify-self: start; }
  .responsive-table td.num { text-align: left; }
  .responsive-table tr.clickable:hover td { background: none; }
}
@media (max-width: 640px) {
  .form-grid, .local-pair, .pair { grid-template-columns: minmax(0, 1fr); }
  .filters { flex-direction: column; align-items: stretch; }
  .search-field, .select-field { flex: none; }
  .segmented { display: flex; }
  .segmented button { flex: 1; }
  .facts div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .problems ul > li { flex-direction: column; align-items: flex-start; }
  .savebar { flex-direction: column; align-items: stretch; gap: 10px; }
  .savebar-actions .btn { flex: 1; }
  .barlist li { grid-template-columns: minmax(80px, 36%) minmax(0, 1fr) 36px; gap: 8px; }
  .metric + .metric { border-left: 0; padding-left: 0; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-top: 1px solid var(--rule); padding-left: 0; }
  .metrics .metric:nth-child(-n+2) { border-top: 0; }
  .metrics .metric:nth-child(even) { padding-left: var(--space-4); border-left: 1px solid var(--rule); }
  .feed > li { grid-template-columns: auto minmax(0, 1fr); }
  .feed-time { grid-column: 2; }
  .sk-split { grid-template-columns: minmax(0, 1fr); }
  .item-body { padding-inline: 12px; }
  .send-panel { flex-direction: column; align-items: stretch; }
  .send-panel .btn { justify-self: start; align-self: flex-start; }
  .page { gap: var(--space-5); }
  .guide { padding: var(--space-4); }
}

/* Motion follows the person's setting: states still change in the same order, nothing moves. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
}
