/* Castyr SSO design system. Light, quiet and neutral: grey page, white cards, near-black primary
   buttons, one violet accent for links and focus. No inline styles anywhere in the app (the Content
   Security Policy forbids them), so everything lives here. A dark theme follows below the tokens. */
:root {
  color-scheme: light;

  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-panel: #f9fafb;
  --color-border: #e2e5ea;
  --color-border-strong: #cdd2da;
  --color-text: #16181d;
  --color-muted: #5b6270;
  --color-faint: #8b919c;
  --color-primary: #16181d;
  --color-primary-hover: #2f333b;
  --color-on-primary: #ffffff;
  --color-accent: #5b3cc4;
  --color-accent-soft: #f1edfc;
  --color-chart: #5b3cc4; /* single-series chart fill, validated against the card surface */
  --color-ok: #17794b;
  --color-ok-soft: #e7f5ed;
  --color-bad: #b42318;
  --color-bad-soft: #fdeceb;
  --color-warn: #9a5b0b;
  --color-warn-soft: #fdf3e2;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.5rem; --space-6: 2rem;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-card: 0 1px 2px rgba(22, 24, 29, .05), 0 4px 16px rgba(22, 24, 29, .05);

  /* Short aliases */
  --muted: var(--color-muted);
  --bad: var(--color-bad);
  --ok: var(--color-ok);
}

/* Dark theme: follows the device unless the visitor picked one (html[data-theme], set from a
   cookie by the header toggle). The two blocks must stay identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-bg: #0e1014; --color-surface: #161920; --color-panel: #1c2028;
    --color-border: #2a2f3a; --color-border-strong: #3b4150;
    --color-text: #e9ebef; --color-muted: #a2a8b4; --color-faint: #7b8290;
    --color-primary: #e9ebef; --color-primary-hover: #ffffff; --color-on-primary: #0e1014;
    --color-accent: #a592ff; --color-accent-soft: rgba(165, 146, 255, .16); --color-chart: #8f74f5;
    --color-ok: #4fd18b; --color-ok-soft: rgba(79, 209, 139, .13);
    --color-bad: #ff8a80; --color-bad-soft: rgba(255, 138, 128, .13);
    --color-warn: #f3b54a; --color-warn-soft: rgba(243, 181, 74, .14);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0e1014; --color-surface: #161920; --color-panel: #1c2028;
  --color-border: #2a2f3a; --color-border-strong: #3b4150;
  --color-text: #e9ebef; --color-muted: #a2a8b4; --color-faint: #7b8290;
  --color-primary: #e9ebef; --color-primary-hover: #ffffff; --color-on-primary: #0e1014;
  --color-accent: #a592ff; --color-accent-soft: rgba(165, 146, 255, .16); --color-chart: #8f74f5;
  --color-ok: #4fd18b; --color-ok-soft: rgba(79, 209, 139, .13);
  --color-bad: #ff8a80; --color-bad-soft: rgba(255, 138, 128, .13);
  --color-warn: #f3b54a; --color-warn-soft: rgba(243, 181, 74, .14);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
}
:root[data-theme="light"] { color-scheme: light; }

/* Theme toggle: in the header, or pinned top-right on the standalone screens. Hidden without JS. */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 500 .8125rem var(--font-body); color: var(--color-muted); background: var(--color-surface); border: 1px solid var(--color-border); }
.theme-toggle:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.theme-toggle[hidden] { display: none; }
.theme-toggle .ti { display: none; }
.theme-toggle[data-mode="auto"] .ti-auto, .theme-toggle[data-mode="light"] .ti-light, .theme-toggle[data-mode="dark"] .ti-dark { display: block; }
.theme-corner { position: fixed; top: var(--space-4); right: var(--space-4); z-index: 5; }
@media (max-width: 760px) { .topbar .theme-toggle [data-theme-label] { display: none; } .topbar .theme-toggle { padding: 6px; } }

* { box-sizing: border-box; }
html { background: var(--color-bg); }
body { margin: 0; min-height: 100vh; background: var(--color-bg); color: var(--color-text); font: 15px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: var(--font-body); font-weight: 600; letter-spacing: -.01em; color: var(--color-text); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 var(--space-4); }
h2 { font-size: 1rem; margin: var(--space-6) 0 var(--space-3); }
/* Links read as actions, not web-page hypertext: accent colour, no underline until hover. Zero
   specificity (:where) so any component's own link style wins. Long-form docs keep a faint underline
   so links stand out inside paragraphs. */
:where(a) { color: var(--color-accent); text-decoration: none; text-underline-offset: 3px; transition: color .15s; }
:where(a:hover) { text-decoration: underline; }
.docs-content p a, .docs-content li a { text-decoration: underline; text-decoration-color: var(--color-accent-soft); }
.docs-content p a:hover, .docs-content li a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: var(--color-accent-soft); }

/* ---------- Site chrome ---------- */
.topbar { display: flex; align-items: center; gap: var(--space-5); padding: 0 var(--space-6); min-height: 56px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--color-text); text-decoration: none; width: max-content; }
.brand:hover { color: var(--color-text); }
.brand-logo { display: block; width: auto; height: 30px; }
.topbar-section { font-size: .8125rem; color: var(--color-muted); }
.topnav { display: flex; align-items: stretch; gap: var(--space-5); align-self: stretch; }
.topnav a { display: flex; align-items: center; font-size: .875rem; color: var(--color-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.topnav a:hover { color: var(--color-text); }
.topnav a.current { color: var(--color-text); font-weight: 500; border-bottom-color: var(--color-text); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .8125rem; color: var(--color-muted); }
.topbar a.quiet { font-size: .8125rem; color: var(--color-muted); text-decoration: none; white-space: nowrap; }
.topbar a.quiet:hover { color: var(--color-text); text-decoration: underline; }
main { padding: var(--space-6) var(--space-4) 4rem; }
.page { max-width: 46rem; margin: 0 auto; }
.page.admin { max-width: 72rem; }
.card { max-width: 26rem; margin: 6vh auto 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-6); box-shadow: var(--shadow-card); }
.card.wide { max-width: 30rem; margin-top: 3vh; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 0 var(--space-4); padding: var(--space-3) var(--space-4) 0; }
  .topbar-section, .topbar .who { display: none; }
  .topnav { order: 3; flex-basis: 100%; overflow-x: auto; gap: var(--space-4); min-height: 40px; }
  .topnav a { white-space: nowrap; }
}

/* ---------- Page structure (inner pages) ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
.page-sub { margin: 4px 0 0; font-size: .875rem; color: var(--color-muted); }
.lead { margin: calc(-1 * var(--space-3)) 0 var(--space-5); color: var(--color-muted); font-size: .9375rem; }
.section { margin-top: var(--space-6); }
.section h2 { margin: 0 0 var(--space-3); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-3); }
.section-head h2 { margin: 0; }
.section-head a { font-size: .875rem; font-weight: 500; }
.panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }

/* Account health */
.health { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5); }
.health-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--color-ok); background: var(--color-ok-soft); }
.health.attention .health-icon { color: var(--color-warn); background: var(--color-warn-soft); }
.health-main { min-width: 0; flex: 1; }
.health-status { font-weight: 600; font-size: 1rem; }
.health-note { margin: 2px 0 0; font-size: .875rem; color: var(--color-muted); text-wrap: pretty; }
.health-count { flex: none; display: flex; flex-direction: column; align-items: flex-end; padding-left: var(--space-4); border-left: 1px solid var(--color-border); }
.health-number { font: 600 1.75rem/1 var(--font-body); font-variant-numeric: tabular-nums; }
.health.attention .health-number { color: var(--color-warn); }
.health-label { font-size: .75rem; color: var(--color-muted); }

/* Lists of things (devices) */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
.list-row + .list-row { border-top: 1px solid var(--color-border); }
.list-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); color: var(--color-muted); background: var(--color-panel); border: 1px solid var(--color-border); }
/* A device's own image replaces the glyph; if it fails to load, image_fallback.js removes it and the
   has-image class, and the glyph shows again. */
.list-icon.has-image, .device-logo.has-image { position: relative; overflow: hidden; }
.list-icon img, .device-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.has-image > svg { visibility: hidden; }
/* Rows open the device's details page; Sign out stays a separate button. */
.list-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-3); margin: calc(-1 * var(--space-2)); padding: var(--space-2); border-radius: var(--radius-sm); color: inherit; text-decoration: none; }
.list-link:hover { background: var(--color-panel); }
.list-link:hover .list-title { text-decoration: underline; text-underline-offset: 3px; }
.list-chev { flex: none; color: var(--color-faint); }
.list-main { min-width: 0; flex: 1; }
.list-title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-weight: 500; overflow-wrap: anywhere; }
.list-sub { font-size: .8125rem; color: var(--color-muted); overflow-wrap: anywhere; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 500; color: var(--color-warn); background: var(--color-warn-soft); }
.empty { padding: var(--space-6) var(--space-5); text-align: center; }
.empty p { margin: 0 0 var(--space-2); color: var(--color-muted); }
.empty a { font-size: .875rem; font-weight: 500; }

@media (max-width: 560px) {
  .health { flex-wrap: wrap; }
  .health-count { flex-direction: row; align-items: baseline; gap: 6px; padding: var(--space-3) 0 0; border-left: 0; border-top: 1px solid var(--color-border); flex-basis: 100%; }
  .list-row { padding: var(--space-3) var(--space-4); }
}

/* ---------- Standalone screens: sign-in, consent, activation, errors ---------- */
.stage { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-5); padding: var(--space-6) var(--space-4); }
.stage-brand .brand-logo { height: 44px; }
.stage-foot { margin: 0; font-size: .875rem; color: var(--color-muted); }

.login-card, .consent-card { width: 100%; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.login-card { max-width: 400px; padding: var(--space-6); }
.login-main { display: flex; flex-direction: column; gap: var(--space-4); }
.login-head h1 { margin: 0 0 4px; font-size: 1.375rem; }
.login-head p { margin: 0; font-size: .875rem; color: var(--color-muted); }
.field { display: block; }
.field-label { display: block; margin-bottom: 6px; font-size: .8125rem; font-weight: 500; color: var(--color-text); }
.field-row { display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
.field-row:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
/* Higher specificity than the generic input[type=...] rule: the row draws the box, the input is bare. */
.field-row .field-input { flex: 1; min-width: 0; background: transparent; border: none; border-radius: 0; outline: none; box-shadow: none; padding: 10px 0; color: var(--color-text); font: 400 .9375rem var(--font-body); }
.field-row .field-input:focus { box-shadow: none; }
.field-hint { display: inline-block; margin-top: 6px; font-size: .75rem; color: var(--color-faint); }
.reveal { background: none; border: none; cursor: pointer; padding: 4px; font: 500 .75rem var(--font-body); color: var(--color-muted); }
.reveal:hover { color: var(--color-text); }
.remember { display: flex; align-items: center; gap: 8px; font-size: .875rem; font-weight: 400; color: var(--color-text); cursor: pointer; }
.remember input { width: 16px; height: 16px; margin: 0; cursor: pointer; }

.btn-continue { cursor: pointer; border: 1px solid var(--color-primary); text-align: center; background: var(--color-primary); color: var(--color-on-primary);
  font: 500 .9375rem/1 var(--font-body); padding: 12px; border-radius: var(--radius-sm); transition: background .15s; }
.btn-continue:hover { background: var(--color-primary-hover); color: var(--color-on-primary); }
.btn-continue[aria-disabled="true"] { background: var(--color-panel); border-color: var(--color-border); color: var(--color-faint); }
a.btn-continue { display: block; text-decoration: none; }
.btn-cancel { cursor: pointer; text-align: center; text-decoration: none; padding: 12px; border-radius: var(--radius-sm); font: 500 .9375rem/1 var(--font-body); color: var(--color-text);
  background: var(--color-surface); border: 1px solid var(--color-border-strong); transition: background .15s; }
.btn-cancel:hover { background: var(--color-panel); color: var(--color-text); }

.status { padding: 10px 12px; border-radius: var(--radius-sm); font-size: .875rem; color: var(--color-ok); background: var(--color-ok-soft); }
.status.alert { color: var(--color-bad); background: var(--color-bad-soft); }

.providers { border-top: 1px solid var(--color-border); padding-top: var(--space-2); }
.providers summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: .875rem; color: var(--color-muted); }
.providers summary::-webkit-details-marker { display: none; }
.providers summary:hover { color: var(--color-text); }
.providers summary .chev { transition: transform .18s; }
.providers[open] summary .chev { transform: rotate(180deg); }
.provider-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--color-border); color: var(--color-faint); }
.provider-mark { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); font: 600 .8125rem var(--font-body); color: var(--color-muted); background: var(--color-panel); border: 1px solid var(--color-border); }
.provider-name { font-size: .875rem; color: var(--color-muted); }
.provider-note { font-size: .75rem; }
.tag { margin-left: auto; flex: none; display: inline-block; padding: 1px 7px; border-radius: 999px; font: 500 .6875rem/1.5 var(--font-body); color: var(--color-muted); background: var(--color-panel); border: 1px solid var(--color-border); white-space: nowrap; }
.tag.warn { color: var(--color-bad); background: var(--color-bad-soft); border-color: transparent; }

/* Sign-up */
.signup-progress { display: flex; align-items: center; gap: var(--space-3); }
.signup-bar { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.signup-bar span { height: 4px; border-radius: 2px; background: var(--color-border); }
.signup-bar span.done { background: var(--color-accent); }
.signup-count { font-size: .75rem; color: var(--color-muted); white-space: nowrap; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.field-prefix { color: var(--color-muted); }
.field-label .optional { font-weight: 400; color: var(--color-faint); }
.field-hint.ok { color: var(--color-ok); }
.field-hint.bad { color: var(--color-bad); }
.remember.terms { align-items: flex-start; }
.remember.terms input { margin-top: 3px; }
.captcha { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.captcha-img { display: block; width: 100%; max-width: 260px; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }
.captcha-new { background: none; border: 0; padding: 2px 4px; cursor: pointer; font: 500 .8125rem var(--font-body); color: var(--color-accent); }
.captcha-new:hover { text-decoration: underline; }
.field-row .captcha-input { letter-spacing: .25em; text-transform: uppercase; font-family: var(--font-mono); }
.signup-review { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--space-3); margin: 0; padding: var(--space-3); font-size: .8125rem;
  background: var(--color-panel); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.signup-review dt { color: var(--color-muted); }
.signup-review dd { margin: 0; overflow-wrap: anywhere; }
.signup-nav { display: flex; justify-content: space-between; font-size: .875rem; }
.signup-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; color: var(--color-accent); background: var(--color-accent-soft); }
.signup-tips { margin: 0; padding-left: 1.1rem; font-size: .8125rem; color: var(--color-muted); }
.resend-form { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.resend-form p { margin: 0; font-size: .875rem; color: var(--color-muted); }
.signup-link { font-size: .875rem; text-align: center; }

/* Consent, activation and device confirmation cards */
.consent-card { max-width: 460px; overflow: hidden; }
.consent-head { padding: var(--space-6) var(--space-6) var(--space-4); }
.consent-title { display: flex; align-items: center; gap: var(--space-4); }
.consent-title > div { min-width: 0; }
.app-icon { position: relative; width: 52px; height: 52px; flex: none; overflow: hidden; display: grid; place-items: center; border-radius: 12px; font: 600 1.25rem var(--font-body);
  color: var(--color-muted); background: var(--color-panel); border: 1px solid var(--color-border); }
.app-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.consent-head h1 { margin: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.consent-head h1 .tag { margin-left: .4em; vertical-align: 2px; }
.consent-lead { margin: 2px 0 0; font-size: .875rem; color: var(--color-muted); overflow-wrap: anywhere; }
.consent-desc { margin: var(--space-3) 0 0; font-size: .875rem; color: var(--color-muted); text-wrap: pretty; overflow-wrap: anywhere; }
.consent-who { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--color-border); font-size: .8125rem; color: var(--color-muted); }
.consent-who strong { color: var(--color-text); font-weight: 500; }
.consent-who a { margin-left: 6px; }
.consent-panel { margin: 0 var(--space-6); padding: var(--space-4); background: var(--color-panel); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.grant-lead { margin-bottom: var(--space-2); font-size: .8125rem; font-weight: 500; }
.grants, .notes { list-style: none; margin: 0; padding: 0; }
.grant { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; font-size: .875rem; line-height: 1.45; }
.grant svg { flex: none; margin-top: 1px; color: var(--color-ok); }
.grant .tag { margin-top: 1px; }
.grant.off { color: var(--color-faint); }
.grant.off svg { color: var(--color-faint); }
.consent-rule { height: 1px; border: 0; background: var(--color-border); margin: var(--space-3) 0; }
.notes li { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: .8125rem; line-height: 1.5; color: var(--color-muted); text-wrap: pretty; }
.notes svg { flex: none; margin-top: 2px; color: var(--color-faint); }
.notes strong { color: var(--color-text); font-weight: 500; }
.wrap { overflow-wrap: anywhere; }
.consent-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); padding: var(--space-5) var(--space-6) var(--space-6); margin: 0; }
.consent-actions.single { grid-template-columns: minmax(0, 1fr); }
.consent-banner { display: block; width: 100%; aspect-ratio: 3 / 1; object-fit: cover; background: var(--color-panel); border-bottom: 1px solid var(--color-border); }

@media (max-width: 560px) {
  .login-card { padding: var(--space-5); }
  .consent-head { padding: var(--space-5) var(--space-4) var(--space-4); }
  .consent-panel { margin: 0 var(--space-4); }
  .consent-actions { padding: var(--space-4); }
}

/* Activation code entry */
@keyframes castyr-caret { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
.code-form { margin: 0; }
.code-panel { text-align: center; }
.code-label { display: block; margin-bottom: 10px; font-size: .8125rem; font-weight: 500; color: var(--color-text); }
.code-label.left { text-align: left; }
.code-field { position: relative; }
/* Without JavaScript the real input is shown as-is. */
.code-field .code-input { width: 100%; text-align: center; text-transform: uppercase; letter-spacing: .15em; font: 600 1.5rem var(--font-mono); padding: .6rem .5rem; }
.code-cells { display: none; }
.code-field.js .code-input { position: absolute; inset: 0; height: 100%; opacity: 0; cursor: text; }
.code-field.js .code-cells { display: flex; align-items: center; justify-content: center; gap: 5px; pointer-events: none; }
.code-cell { flex: 1 1 0; max-width: 36px; min-width: 0; height: 48px; display: flex; align-items: center; justify-content: center; font: 500 1.375rem var(--font-mono);
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
.code-cell.filled { border-color: var(--color-text); }
.code-field.js:focus-within .code-cell.next { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.code-field.js:focus-within .code-cell.next::after { content: ""; width: 2px; height: 24px; background: var(--color-accent); animation: castyr-caret 1.1s step-end infinite; }
.code-cell.dash { flex: 0 0 12px; max-width: 12px; border: 0; background: none; color: var(--color-faint); }
.code-meta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: var(--space-3); font-size: .75rem; color: var(--color-muted); }
.code-paste { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--color-accent); }
.code-paste:hover { text-decoration: underline; }
.code-status { margin: var(--space-3) var(--space-6) 0; }
.code-notes { padding: 0 var(--space-6) var(--space-5); }
.code-form .consent-actions { padding-bottom: var(--space-4); }

/* Device confirm: pick the phrase */
.confirm-form { margin: 0; }
.phrases { border: 0; margin: 0; padding: 0; min-width: 0; }
.phrase { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; font-weight: 400; color: var(--color-text);
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); transition: border-color .15s, background .15s; }
.phrase:hover { border-color: var(--color-text); }
.phrase input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.phrase-dot { width: 16px; height: 16px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--color-border-strong); background: var(--color-surface); }
.phrase-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.phrase-text { font: 500 1rem var(--font-body); overflow-wrap: anywhere; }
.phrase:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); }
.phrase:has(input:checked) .phrase-dot { border-color: var(--color-accent); }
.phrase:has(input:checked) .phrase-dot::after { background: var(--color-accent); }
.phrase:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.phrase-help { margin: var(--space-2) 0 0; font-size: .8125rem; line-height: 1.5; color: var(--color-muted); text-wrap: pretty; }
.name-field { padding: var(--space-4) var(--space-6) 0; }
.name-field input { width: 100%; }
.code-foot { margin: 0; padding: 0 var(--space-6) var(--space-5); text-align: center; font-size: .75rem; color: var(--color-faint); }

/* Device activated */
@keyframes castyr-draw { to { stroke-dashoffset: 0; } }
@keyframes castyr-scale-in { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes castyr-fade-up { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.done-card { text-align: center; }
.done-badge { position: relative; width: 88px; height: 88px; margin: 0 auto var(--space-4); }
.login-main .done-badge { margin-bottom: 0; } /* the card's own gap spaces it */
.done-disc { position: absolute; inset: 10px; border-radius: 50%; background: var(--color-ok-soft); animation: castyr-scale-in .4s cubic-bezier(.2, .9, .3, 1) .3s both; }
.done-mark { position: relative; display: block; width: 88px; height: 88px; }
.done-track { stroke: var(--color-border); stroke-width: 3; }
.done-ring { stroke: var(--color-ok); stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 333; stroke-dashoffset: 333; animation: castyr-draw .7s cubic-bezier(.35, 0, .15, 1) .1s forwards; }
.done-tick { stroke: var(--color-ok); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60;
  animation: castyr-draw .4s cubic-bezier(.3, .7, .3, 1) .65s forwards; }
.done-card h1 { margin: 0 0 6px; font-size: 1.375rem; animation: castyr-fade-up .35s ease-out .75s both; }
.done-lead { margin: 0 auto; max-width: 34ch; font-size: .9375rem; color: var(--color-muted); text-wrap: pretty; animation: castyr-fade-up .35s ease-out .8s both; }
.done-device { display: flex; align-items: center; gap: var(--space-3); text-align: left; animation: castyr-fade-up .35s ease-out .85s both; }
.done-device .app-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--color-surface); }
.done-device-text { min-width: 0; flex: 1; }
.done-device-name { font-weight: 500; overflow-wrap: anywhere; }
.done-device-meta { font-size: .8125rem; color: var(--color-muted); overflow-wrap: anywhere; }
.tag.done-linked { margin-left: 0; color: var(--color-ok); background: var(--color-ok-soft); border-color: transparent; }
.done-actions { padding: var(--space-5) var(--space-6) var(--space-6); animation: castyr-fade-up .35s ease-out .9s both; }
.done-actions .btn-continue { display: block; width: 100%; }
.done-close-hint { margin: var(--space-2) 0 0; font-size: .8125rem; color: var(--color-muted); }
.done-links { display: flex; align-items: center; justify-content: center; gap: var(--space-5); padding-top: var(--space-4); font-size: .875rem; }
.done-links a.done-home { color: var(--color-muted); }
.done-links a.done-home:hover { color: var(--color-text); }

/* ---------- Shared components (inner pages) ---------- */
.muted { color: var(--color-muted); font-size: .875rem; margin: 0; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.stack > * { min-width: 0; }
/* Rails adds size=<maxlength> to text fields, which would make a 2048-char field ~15,000px wide. */
input[type=text], input[type=password], input[type=email], input[type=url], input[type=search], textarea, select { width: 100%; max-width: 100%; min-width: 0; }
label { display: grid; gap: .35rem; font-size: .875rem; font-weight: 500; color: var(--color-text); }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=search], textarea, select {
  font: 400 .9375rem var(--font-body); padding: .55rem .7rem; color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, input[type=url]:focus, input[type=search]:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
input:disabled { opacity: .6; }
input[type=checkbox], input[type=radio] { accent-color: var(--color-primary); }
textarea { resize: vertical; }
.btn { font: 500 .875rem/1.2 var(--font-body); padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text);
  cursor: pointer; text-decoration: none; display: inline-block; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--color-panel); color: var(--color-text); }
.btn.small { padding: .4rem .75rem; font-size: .8125rem; }
.btn.primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.btn.primary:hover { background: var(--color-primary-hover); }
.btn.danger { color: var(--color-bad); }
.btn.danger:hover { background: var(--color-bad-soft); border-color: var(--color-bad); }
a.btn { text-decoration: none; }
form.button_to { margin: 0; }
.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); margin: 0 0 var(--space-4); font-size: .875rem; }
.flash.alert { background: var(--color-bad-soft); color: var(--color-bad); }
.flash.notice { background: var(--color-ok-soft); color: var(--color-ok); }
.sessions, .settings-list { list-style: none; padding: 0; margin: 0 0 var(--space-5); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.sessions li, .settings-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-4) var(--space-5); }
.sessions li + li, .settings-list li + li { border-top: 1px solid var(--color-border); }
.badge { display: inline-block; font: 500 .6875rem/1.5 var(--font-body); color: var(--color-ok); background: var(--color-ok-soft); padding: 0 .5rem; border-radius: 999px; margin-left: .4rem; vertical-align: 1px; }
.badge.warn { background: var(--color-bad-soft); color: var(--color-bad); }
.scopes { padding-left: 1.2rem; margin: 0 0 var(--space-4); }
.scopes li { margin: .25rem 0; }
.actions { display: flex; gap: var(--space-3); margin-top: var(--space-4); }
.actions.wrap { flex-wrap: wrap; }
input.code { font: 600 1.4rem/1.2 var(--font-mono); letter-spacing: .15em; text-transform: uppercase; text-align: center; }
fieldset { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: .75rem 1rem; }
legend { color: var(--color-muted); font-size: .875rem; padding: 0 .4rem; }
.choice { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; font-weight: 400; color: var(--color-text); font-size: .9375rem; }
.kv { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: .6rem 1.25rem; margin: var(--space-4) 0; }
.kv dt { color: var(--color-muted); font-size: .875rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
code { font: .8125rem var(--font-mono); background: var(--color-panel); border: 1px solid var(--color-border); border-radius: 4px; padding: .05rem .3rem; }
pre { overflow-x: auto; background: var(--color-panel); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: .75rem 1rem; }
pre code { border: 0; padding: 0; background: none; }
.plain { list-style: none; padding: 0; margin: 0; }
.errs { margin: 0; padding-left: 1.1rem; }
.secret { background: var(--color-ok-soft); border: 1px solid var(--color-ok); border-radius: var(--radius-sm); padding: 1rem; margin: var(--space-4) 0; }

/* ---------- Two-factor ---------- */
.forgot-link { text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }
.tf-panel { padding: var(--space-5); }
.tf-panel > p:first-child { margin-top: 0; }
.tf-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: var(--space-5); }
.tf-steps > li > strong { display: block; margin-bottom: var(--space-3); }
.tf-qr { display: inline-block; padding: 6px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: #ffffff; }
.qr-code { display: block; width: 200px; height: 200px; }
.qr-bg { fill: #ffffff; }
.qr-dots { fill: #000000; }
.tf-alt { margin-top: var(--space-3); font-size: .875rem; }
.tf-alt summary { cursor: pointer; color: var(--color-accent); }
.tf-alt .qr-code { margin-top: var(--space-3); border-radius: var(--radius-sm); }
.tf-key { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin: var(--space-2) 0; }
.tf-key code { font-size: 1rem; letter-spacing: .08em; padding: .4rem .6rem; }
.tf-open { margin-bottom: var(--space-3); }
.tf-confirm, .tf-inline { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.tf-code-label { display: block; flex-basis: 100%; }
input.otp-input { width: 9.5rem; font: 600 1.25rem var(--font-mono); letter-spacing: .2em; text-align: center; }
.field-row .otp-input { width: auto; letter-spacing: .12em; }
/* The sign-in code step: icon, heading, field and hint all centred. */
.tf-challenge { text-align: center; }
.tf-challenge .signup-icon { margin: 0 auto; }
.tf-challenge .field-row .otp-input { text-align: center; font: 600 1.125rem var(--font-mono); letter-spacing: .12em; }
.tf-cancel { margin-top: var(--space-5); }
.tf-status { display: flex; align-items: center; gap: var(--space-3); }
.tf-status p { margin: 2px 0 0; }
.ok-pill { color: var(--color-ok); background: var(--color-ok-soft); }
.backup-codes { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr)); gap: 6px; counter-reset: code; }
.backup-codes li { display: flex; align-items: center; gap: var(--space-2); counter-increment: code; }
.backup-codes li::before { content: counter(code) "."; width: 1.6rem; text-align: right; color: var(--color-faint); font-size: .75rem; font-variant-numeric: tabular-nums; }
.backup-codes code { font-size: .8125rem; padding: .25rem .45rem; overflow-wrap: anywhere; }
@media (max-width: 560px) { .backup-codes { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Developer docs ---------- */
.page.docs { max-width: 68rem; }
.docs-layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.docs-nav { position: sticky; top: var(--space-5); display: flex; flex-direction: column; gap: 2px; font-size: .875rem; }
.docs-nav a { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--color-muted); text-decoration: none; }
.docs-nav a:hover { color: var(--color-text); background: var(--color-panel); }
.docs-nav a.current { color: var(--color-text); font-weight: 500; background: var(--color-surface); box-shadow: inset 2px 0 0 var(--color-accent); }
.docs-nav hr { width: 100%; height: 1px; border: 0; background: var(--color-border); margin: var(--space-2) 0; }
.docs-content { min-width: 0; max-width: 46rem; line-height: 1.65; }
.docs-content h1 { font-size: 1.75rem; margin-bottom: var(--space-2); }
.docs-content h2 { font-size: 1.125rem; margin: var(--space-6) 0 var(--space-3); padding-top: var(--space-2); }
.docs-content h3 { font-size: 1rem; margin: var(--space-5) 0 var(--space-2); }
.docs-content ul, .docs-content ol { padding-left: 1.3rem; }
.docs-content li { margin: .35rem 0; }
.docs-content .tablewrap { margin: var(--space-3) 0 var(--space-4); }
.docs-content pre { margin: var(--space-3) 0 var(--space-4); font-size: .8125rem; line-height: 1.55; }
.docs-lead { font-size: 1.0625rem; color: var(--color-muted); margin: 0 0 var(--space-5); }
.docs-steps li { padding-left: .25rem; }
.docs-note { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--color-warn-soft); }
.docs-pager { display: flex; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--color-border); font-size: .875rem; }
@media (max-width: 860px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .docs-nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
  .docs-nav hr { display: none; }
}

/* ---------- Admin ---------- */
.adminnav { display: flex; gap: 1.1rem; flex-wrap: wrap; align-items: center; padding: 0 0 var(--space-3); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-5); font-size: .875rem; }
.adminnav a { color: var(--color-muted); text-decoration: none; }
.adminnav a:hover { color: var(--color-text); }
.tablewrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
table { border-collapse: collapse; width: 100%; font-size: .875rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--color-border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { color: var(--color-muted); font-weight: 500; font-size: .75rem; background: var(--color-panel); }
td.wrap { max-width: 26rem; overflow-wrap: anywhere; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 var(--space-4); }
form.inline { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: 0 .5rem .5rem 0; }
input.reason { min-width: 12rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .75rem; margin: var(--space-4) 0 var(--space-5); }
.stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: .8rem 1rem; }
.stat .n { font: 600 1.5rem/1.2 var(--font-body); font-variant-numeric: tabular-nums; }
.pager { display: flex; gap: var(--space-4); align-items: center; margin-top: var(--space-4); }

/* Admin charts (status colours follow the dataviz reference status palette; always paired with a label) */
.chart-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-4); }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.chart-head h2 { margin: 0; font-size: .9375rem; }
.chart-sub { font-size: .8125rem; color: var(--color-muted); }
.chart-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 var(--space-4); }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--color-border); stroke-width: 1; }
/* Sizes are in the chart's 600-unit box: ~13px on screen in a half-width card, ~12px on a phone. */
.chart-tick { fill: var(--color-muted); font: 15px var(--font-body); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .chart-tick { font-size: 23px; } }
.chart-bar { fill: var(--color-chart); }
.chart-hit { fill: transparent; cursor: default; outline: none; }
.chart-hit.hover, .chart-hit:focus-visible { fill: var(--color-accent-soft); }
.status-bar { display: block; width: 100%; height: 20px; border-radius: 4px; overflow: hidden; }
.status-bar.empty { background: var(--color-panel); }
.status-seg { outline: none; }
.status-seg.good, .swatch.good { fill: #0ca30c; background: #0ca30c; }
.status-seg.strikes, .swatch.strikes { fill: #fab219; background: #fab219; }
.status-seg.banned, .swatch.banned { fill: #d03b3b; background: #d03b3b; }
.status-seg.hover, .status-seg:focus-visible { opacity: .8; }
.status-legend { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); margin: var(--space-3) 0 0; padding: 0; }
.status-legend a { display: flex; align-items: baseline; gap: 8px; color: var(--color-text); text-decoration: none; font-size: .875rem; }
.status-legend a:hover .legend-label { text-decoration: underline; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; align-self: center; }
.legend-value { font-weight: 600; }
.legend-pct { color: var(--color-muted); font-size: .8125rem; }
.chart-table { margin-top: var(--space-2); font-size: .8125rem; }
.chart-table summary { cursor: pointer; color: var(--color-muted); }
.chart-table .tablewrap { margin-top: var(--space-2); max-height: 240px; overflow-y: auto; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-tip { position: absolute; z-index: 10; pointer-events: none; display: flex; flex-direction: column; padding: 6px 10px; border-radius: var(--radius-sm);
  background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow-card); font-size: .8125rem; white-space: nowrap; }
.chart-tip[hidden] { display: none; }
.tip-value { font-weight: 600; }
.tip-label { color: var(--color-muted); }
.user-filters { display: flex; gap: var(--space-2); flex-wrap: wrap; margin: 0 0 var(--space-3); font-size: .875rem; }
.user-filters a { padding: .3rem .7rem; border: 1px solid var(--color-border); border-radius: 999px; color: var(--color-muted); text-decoration: none; background: var(--color-surface); }
.user-filters a.current { color: var(--color-text); border-color: var(--color-text); font-weight: 500; }
.badge.strikes { color: var(--color-warn); background: var(--color-warn-soft); }
.badge.admin { color: var(--color-accent); background: var(--color-accent-soft); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .done-ring, .done-tick { stroke-dashoffset: 0; }
}

/* ---------- Device details (/account/devices/:id) ---------- */
.back-link { margin: 0 0 var(--space-4); font-size: .875rem; }
.back-link a { color: var(--color-muted); }
.back-link a:hover { color: var(--color-text); }
.device-detail { overflow: hidden; }
.device-banner { display: block; width: 100%; aspect-ratio: 4 / 1; object-fit: cover; background: var(--color-panel); border-bottom: 1px solid var(--color-border); }
.device-hero { display: flex; align-items: flex-start; gap: var(--space-5); padding: var(--space-6); }
.device-logo { width: 96px; height: 96px; flex: none; display: grid; place-items: center; border-radius: 22px; color: var(--color-muted); background: var(--color-panel); border: 1px solid var(--color-border); }
.device-hero-text { min-width: 0; }
.device-hero h1 { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 4px; font-size: 1.5rem; overflow-wrap: anywhere; }
.device-hero h1 .tag { margin-left: 0; }
.device-by { margin: 0; color: var(--color-muted); font-size: .875rem; }
.device-desc { margin: var(--space-3) 0 0; font-size: .9375rem; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.device-app-desc { margin: var(--space-2) 0 0; color: var(--color-muted); font-size: .875rem; overflow-wrap: anywhere; }
.device-section { padding: var(--space-5) var(--space-6); border-top: 1px solid var(--color-border); }
.device-section h2 { margin: 0 0 var(--space-3); font-size: 1rem; }
.device-section .kv { margin: 0; }
.scope-name { margin-left: 4px; font-size: .75rem; }
.device-danger { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.device-danger h2 { margin-bottom: 4px; }
@media (max-width: 560px) {
  .device-hero { flex-direction: column; gap: var(--space-4); padding: var(--space-5) var(--space-4); }
  .device-logo { width: 80px; height: 80px; border-radius: 18px; }
  .device-section { padding: var(--space-4); }
  .device-section .kv { grid-template-columns: 1fr; gap: 2px; }
  .device-section .kv dd { margin-bottom: var(--space-2); }
}

/* ---------- Strikes (admin user page, account page) ---------- */
.strike-form { max-width: 40rem; margin-bottom: var(--space-5); }
.strike-form label { display: grid; gap: 6px; font-size: .875rem; font-weight: 500; }
.strike-form label .muted { display: inline; font-weight: 400; font-size: .8125rem; }
.strike-form textarea, .strike-form input[type=text] { width: 100%; }
.strike-notify { margin: 0; padding: 0; border: 0; display: grid; gap: var(--space-2); }
.strike-notify legend { margin-bottom: var(--space-2); font-size: .875rem; font-weight: 500; }
.strike-form label.check { display: flex; align-items: baseline; gap: 8px; font-weight: 400; }
.strike-history td { vertical-align: top; }
.strike-history .strike-msg { min-width: 16rem; max-width: 28rem; white-space: pre-line; overflow-wrap: anywhere; }
.strike-history tr.revoked td { color: var(--color-faint); }
.strike-history .badge { margin-left: 0; }
.strike-panel { margin-top: var(--space-3); }
.strike-list { list-style: none; margin: 0; padding: 0; }
.strike-list li { padding: var(--space-3) var(--space-5); }
.strike-list li + li { border-top: 1px solid var(--color-border); }
.strike-list .strike-when { font-size: .75rem; color: var(--color-muted); }
.strike-list .strike-text { margin: 2px 0 0; font-size: .875rem; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- Discord link (account page) ---------- */
.discord-card { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5); flex-wrap: wrap; }
.discord-avatar { position: relative; overflow: hidden; width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #5865f2; }
.discord-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.discord-main { min-width: 12rem; flex: 1; }
.discord-name { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); font-weight: 600; }
.discord-name .tag { margin-left: 0; }
.discord-note { margin: 2px 0 0; font-size: .875rem; color: var(--color-muted); }
.discord-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Live admin search ---------- */
.filters.is-live .live-submit { display: none; }
.filters .live-search { flex: 1; min-width: 14rem; max-width: 28rem; }
.live-count { margin: 0 0 var(--space-2); font-size: .8125rem; }
.live-empty { margin: var(--space-3) 0; }
[data-live-results][aria-busy="true"] .tablewrap { opacity: .6; transition: opacity .15s; }

/* ---------- Sign in with Discord ---------- */
.login-alt { margin-top: var(--space-4); }
.provider-form { margin: 0; }
button.provider-live { width: 100%; margin: 0; background: none; border: 0; border-top: 1px solid var(--color-border); cursor: pointer; text-align: left; font: inherit; color: var(--color-text); border-radius: 0; }
button.provider-live:hover .provider-name { text-decoration: underline; text-underline-offset: 3px; }
button.provider-live:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.provider-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.provider-live .provider-note { color: var(--color-muted); }
.provider-mark.discord { color: #fff; background: #5865f2; border-color: #5865f2; }
.provider-go { flex: none; color: var(--color-faint); }
.provider-live .provider-name { color: var(--color-text); font-weight: 500; }

/* ---------- Admin: a user's Discord account ---------- */
.admin-discord { overflow: hidden; margin-bottom: var(--space-5); max-width: 48rem; }
.admin-discord-banner { display: block; width: 100%; aspect-ratio: 5 / 1; object-fit: cover; background: var(--color-panel); }
.admin-discord-head { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5) var(--space-5) 0; }
.discord-avatar.big { width: 64px; height: 64px; }
.discord-avatar.has-image > svg { visibility: hidden; }
.admin-discord-name { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); font-size: 1.125rem; font-weight: 600; }
.admin-discord-name .badge { margin-left: 0; }
.admin-discord-error { margin: var(--space-4) var(--space-5) 0; }
.admin-discord-kv { padding: 0 var(--space-5); }
.admin-discord-actions { padding: 0 var(--space-5) var(--space-5); }
.role-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip { padding: 1px 8px; border-radius: 999px; font-size: .75rem; background: var(--color-panel); border: 1px solid var(--color-border); }

/* ---------- Admin: user avatars ---------- */
.uavatar { position: relative; overflow: hidden; flex: none; display: inline-grid; place-items: center; border-radius: 50%; color: var(--color-accent); background: var(--color-accent-soft); font-weight: 600; }
.uavatar.small { width: 32px; height: 32px; font-size: .8125rem; }
.uavatar.big { width: 88px; height: 88px; font-size: 2rem; border: 4px solid var(--color-surface); }
.uavatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.uavatar.has-image .uavatar-initial { visibility: hidden; }
.badge.live { color: #fff; background: var(--color-bad); }

/* ---------- Admin: users list ---------- */
.user-table .user-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 12rem; }
.user-names { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-names .muted { font-size: .8125rem; }
.user-link { font-weight: 600; }
.user-table td { vertical-align: middle; }
.user-table .badge { margin-left: 0; }
.user-email { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .filters .live-search { max-width: none; min-width: 0; width: 100%; }
  .user-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .user-filters a { white-space: nowrap; }
  .user-table-wrap { background: none; border: 0; overflow: visible; }
  .user-table thead { display: none; }
  .user-table, .user-table tbody { display: block; }
  .user-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px var(--space-3); padding: var(--space-4); margin-bottom: var(--space-3);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
  .user-table td { display: flex; flex-direction: column; gap: 2px; padding: 0; border: 0; font-size: .8125rem; text-align: left; }
  .user-table td::before { content: attr(data-label); font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-faint); }
  .user-table td.user-cell { grid-column: 1 / -1; flex-direction: row; font-size: .9375rem; margin-bottom: var(--space-1); }
  .user-table td.user-cell::before { content: none; }
  .user-table td .badge { align-self: flex-start; }
  .user-table td.user-email { grid-column: 1 / -1; }
  .user-table td.num { text-align: left; }
}

/* ---------- Admin: user page ---------- */
.uhero { overflow: hidden; margin-bottom: var(--space-4); }
.uhero-banner { display: block; width: 100%; aspect-ratio: 5 / 1; object-fit: cover; background: var(--color-panel); }
.uhero-head { display: flex; align-items: flex-end; gap: var(--space-4); padding: var(--space-5) var(--space-5) 0; }
.uhero-banner + .uhero-head { margin-top: -40px; }
.uhero-id { min-width: 0; padding-bottom: 4px; }
.uhero-id h1 { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 2px; font-size: 1.5rem; overflow-wrap: anywhere; }
.uhero-id h1 .badge { margin-left: 0; }
.uhero-bio { margin: var(--space-2) 0 0; font-size: .9375rem; white-space: pre-line; overflow-wrap: anywhere; }
.uhero-stats { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: var(--space-5) var(--space-5) 0; padding: 0;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.uhero-stats li { display: flex; flex-direction: column; align-items: center; padding: var(--space-3) var(--space-2); }
.uhero-stats li + li { border-left: 1px solid var(--color-border); }
.uhero-stats strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.uhero-stats span { font-size: .75rem; color: var(--color-muted); }
.uhero-kv { padding: 0 var(--space-5) var(--space-5); margin-top: var(--space-5); }
.uhero-kv .badge { margin-left: .4rem; }

.sec-toolbar { display: flex; justify-content: flex-end; gap: var(--space-2); margin-bottom: var(--space-2); }
.secs { display: grid; gap: var(--space-2); }
.sec { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: ""; flex: none; width: 8px; height: 8px; border-right: 1.5px solid var(--color-muted); border-bottom: 1.5px solid var(--color-muted); transform: rotate(45deg); margin: -4px 2px 0 0; transition: transform .15s; }
.sec[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.sec > summary:hover .sec-title { text-decoration: underline; text-underline-offset: 3px; }
.sec-title { font-weight: 600; }
.sec-pill { margin-left: auto; padding: 1px 9px; border-radius: 999px; font-size: .75rem; color: var(--color-muted); background: var(--color-panel); border: 1px solid var(--color-border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.sec-pill.warn { color: var(--color-warn); background: var(--color-warn-soft); border-color: transparent; }
.sec-body { padding: 0 var(--space-5) var(--space-5); border-top: 1px solid var(--color-border); padding-top: var(--space-4); }
.sec-body > :first-child { margin-top: 0; }
.sec-body .admin-discord { box-shadow: none; margin: 0; max-width: none; }
.sec-body .strike-form { margin-bottom: var(--space-4); }
.sec-sub { margin: var(--space-4) 0 var(--space-2); font-size: .875rem; }
.sec-sub:first-child { margin-top: 0; }
.sec-list { list-style: none; margin: 0; padding: 0; }
.sec-list li { display: flex; flex-wrap: wrap; gap: 4px var(--space-2); padding: var(--space-2) 0; font-size: .875rem; }
.sec-list li + li { border-top: 1px solid var(--color-border); }
@media (max-width: 640px) {
  .uhero-head { flex-direction: column; align-items: flex-start; padding: var(--space-4) var(--space-4) 0; }
  .uavatar.big { width: 72px; height: 72px; }
  .uhero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: var(--space-4) var(--space-4) 0; }
  .uhero-stats li:nth-child(4) { border-left: 0; }
  .uhero-stats li:nth-child(n+4) { border-top: 1px solid var(--color-border); }
  .uhero-kv { grid-template-columns: 1fr; gap: 2px; padding: 0 var(--space-4) var(--space-4); }
  .uhero-kv dd { margin-bottom: var(--space-2); }
  .sec > summary { padding: var(--space-3) var(--space-4); }
  .sec-body { padding: var(--space-3) var(--space-4) var(--space-4); }
  .sec-toolbar { justify-content: stretch; }
  .sec-toolbar .btn { flex: 1; }
  .admin .reason { width: 100%; }
  .admin form.inline { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; }
}
