/* ==========================================================================
   Wiz Chronicles — Components (mobile-first)
   Requires tokens.css. Class style: block / block__element / block--modifier,
   state classes: .is-open .is-active .is-loading .is-invalid
   Breakpoints: sm 40rem (640) · md 48rem (768) · lg 64rem (1024)
   ========================================================================== */

/* ---------- 0. Base & typography ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--page-bg);
  background-color: var(--bg);
  background-attachment: fixed;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.theme-public:not(body),
.theme-admin:not(body) {
  color: var(--text);
  background: var(--page-bg);
  background-color: var(--bg);
}

.is-scroll-locked,
.is-scroll-locked body { overflow: hidden; }

img, svg, video { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5 {
  margin: 0 0 0.5em;
  font-family: var(--font-serif);
  font-weight: var(--fw-heading);
  line-height: var(--lh-tight);
  color: var(--heading, var(--text));
}
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-heading-lg); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
strong, b { font-weight: var(--fw-semibold); }

p { margin: 0 0 1em; }

a {
  color: var(--primary-text);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }

::selection { background: rgba(142, 108, 240, 0.45); color: var(--text); }

/* English-only display type (Cinzel). Never apply to Thai text. */
.en-display {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
}
.display { font-size: var(--fs-3xl); }

/* Champagne foil text (wordmark / Latin display). Solid fallback colour first. */
.foil-text {
  color: #E9DDBC;
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .foil-text {
    background: var(--foil);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}
.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--fs-wordmark);
  line-height: 1.08;
  letter-spacing: 0.06em;
}
.eyebrow {
  margin: 0;
  font-family: var(--font-display);        /* English only */
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-text);
}
.lead { font-weight: var(--fw-light); font-size: var(--fs-md); color: var(--text-muted); }
.numeral { font-family: var(--font-numeric); font-weight: var(--fw-medium); font-variant-numeric: lining-nums tabular-nums; }

.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-primary { color: var(--primary-text); }
.text-gold { color: var(--gold-text); }
.text-danger { color: var(--danger-text); }
.text-success { color: var(--success-text); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.text-center { text-align: center; }
.fw-semibold { font-weight: var(--fw-semibold); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.nums { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- 1. Focus ring (everywhere) — amethyst #B49BFF on dark, #5B3FC4 on paper ---------- */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ---------- 2. Icons (lucide) ---------- */
svg.lucide {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  stroke-width: 2;
}
i[data-lucide] {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
}

/* ---------- 3. Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-bg-hover: var(--surface-3);
  --btn-fg: var(--text);
  --btn-bd: var(--hairline-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--control-h);
  padding: 0 var(--sp-5);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-full);
  background-color: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background-color: var(--btn-bg-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }

/* Primary: amethyst gem gradient, champagne inner hairline, sheen sweep on hover.
   ::before = sheen (::after is reserved for the .is-loading spinner). */
.btn--primary {
  --btn-bg: var(--primary);
  --btn-bg-hover: var(--primary-hover);
  --btn-fg: var(--on-primary);
  --btn-bd: transparent;
  isolation: isolate;
  overflow: hidden;
  background-image: var(--btn-primary-bg);
  box-shadow: var(--btn-primary-ring);
}
.btn--primary:hover { box-shadow: var(--btn-primary-glow); }
.btn--primary::before,
.btn--gold::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  background: var(--sheen);
  transform: translateX(-130%);
  transition: transform 1s var(--ease);
  pointer-events: none;
}
.btn--primary:hover::before,
.btn--primary:focus-visible::before,
.btn--gold:hover::before,
.btn--gold:focus-visible::before { transform: translateX(130%); }
@media (prefers-reduced-motion: reduce) {
  .btn--primary::before,
  .btn--gold::before { display: none; }
}
.btn--secondary {
  --btn-bg: var(--primary-soft);
  --btn-bg-hover: color-mix(in srgb, var(--primary) 26%, var(--surface));
  --btn-fg: var(--primary-text);
  --btn-bd: color-mix(in srgb, var(--primary) 35%, transparent);
}
.btn--ghost {
  --btn-bg: transparent;
  --btn-bg-hover: var(--surface-3);
  --btn-bd: transparent;
}
.btn--gold {
  --btn-bg: var(--gold);
  --btn-bg-hover: var(--gold-hover);
  --btn-fg: var(--on-gold);
  --btn-bd: transparent;
  isolation: isolate;
  overflow: hidden;
  background-image: var(--foil-h);
  background-size: 220% 100%;
  background-position: 0 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition: background-position 0.8s var(--ease), box-shadow var(--dur) var(--ease);
}
.btn--gold:hover { background-position: 100% 0; }
.btn--danger {
  --btn-bg: var(--danger);
  --btn-bg-hover: color-mix(in srgb, var(--danger) 86%, var(--text));
  --btn-fg: var(--on-danger);
  --btn-bd: transparent;
}
.btn--danger-soft {
  --btn-bg: var(--danger-soft);
  --btn-bg-hover: color-mix(in srgb, var(--danger) 18%, var(--surface));
  --btn-fg: var(--danger-text);
  --btn-bd: transparent;
}
.btn--success {
  --btn-bg: var(--success);
  --btn-bg-hover: color-mix(in srgb, var(--success) 86%, var(--text));
  --btn-fg: var(--on-success);
  --btn-bd: transparent;
}

.btn--sm {
  min-height: var(--control-h-sm);
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
}
.btn--lg {
  min-height: var(--control-h-lg);
  padding: 0 var(--sp-6);
  font-size: var(--fs-md);
}
.btn--block { display: flex; width: 100%; }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--icon.btn--sm { width: var(--control-h-sm); }
.btn--icon.btn--lg { width: var(--control-h-lg); }

/* Touch: every button reaches the 44px (--tap) target. Compound selectors (0,2,0) so a page
   stylesheet loaded later that trims a .btn for desktop density cannot undercut it on touch. */
@media (pointer: coarse) {
  .btn.btn { min-width: var(--tap); min-height: var(--tap); }
  .btn--icon.btn--sm { width: var(--tap); }
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}
.btn.is-loading {
  color: transparent !important;
  opacity: 1;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.15em;
  height: 1.15em;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- 4. Card / panel ---------- */
/* Glass panel: near-solid fallback; frosted only where backdrop-filter exists. */
.card,
.glass {
  position: relative;
  min-width: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card,
  .glass {
    background: var(--glass-bg-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
  }
}
.card--padded { padding: clamp(var(--sp-4), 3vw, var(--sp-6)); }
.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-4) clamp(var(--sp-4), 3vw, var(--sp-6));
  border-bottom: 1px solid var(--hairline);
}
.card__title { margin: 0; font-size: var(--fs-lg); }
.card__subtitle { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.card__body { padding: clamp(var(--sp-4), 3vw, var(--sp-6)); }
.card__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) clamp(var(--sp-4), 3vw, var(--sp-6));
  border-top: 1px solid var(--hairline);
}
/* 1px champagne hairline on the top edge — the "jewel" touch */
.card--accent::before {
  content: "";
  position: absolute;
  top: -1px;
  inset-inline: var(--sp-6);
  height: 1px;
  background: var(--hairline-gold);
}
.card--interactive {
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card--interactive:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--glass-border));
  box-shadow: var(--glow-amethyst);
}
.card--house { border-top: 3px solid var(--house, var(--primary)); }

.panel {
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}

.divider { height: 1px; margin: var(--sp-6) 0; border: 0; background: var(--border); }
.divider--gold { background: var(--hairline-gold); }

.ornament {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--gold);
}
.ornament::before,
.ornament::after {
  content: "";
  flex: 1;
  height: 1px;
}
.ornament::before { background: linear-gradient(90deg, transparent, var(--gold)); }
.ornament::after { background: linear-gradient(90deg, var(--gold), transparent); }
.ornament svg.lucide { width: 1rem; height: 1rem; }

/* ---------- 5. Badge · status pill · house tag ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 1.5rem;
  padding: 0 var(--sp-2);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge--primary { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.badge--gold    { background: var(--gold-soft); color: var(--gold-text); border-color: transparent; }
.badge--success { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.badge--danger  { background: var(--danger-soft); color: var(--danger-text); border-color: transparent; }
.badge--warn    { background: var(--warn-soft); color: var(--warn-text); border-color: transparent; }
.badge--info    { background: var(--info-soft); color: var(--info-text); border-color: transparent; }
.badge svg.lucide { width: 0.9rem; height: 0.9rem; }

.pill {
  --pill-fg: var(--text-muted);
  --pill-bg: var(--surface-2);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.75rem;
  padding: 0 0.75rem 0 0.6rem;
  border-radius: var(--r-full);
  background: var(--pill-bg);
  color: var(--pill-fg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pill-fg) 24%, transparent);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.pill--pending,       .pill[data-status="PENDING"]       { --pill-fg: var(--st-pending);       --pill-bg: var(--st-pending-bg); }
.pill--form-approved, .pill[data-status="FORM_APPROVED"] { --pill-fg: var(--st-form-approved); --pill-bg: var(--st-form-approved-bg); }
.pill--approved,      .pill[data-status="APPROVED"]      { --pill-fg: var(--st-approved);      --pill-bg: var(--st-approved-bg); }
.pill--rejected,      .pill[data-status="REJECTED"]      { --pill-fg: var(--st-rejected);      --pill-bg: var(--st-rejected-bg); }
.pill--locked,        .pill[data-status="LOCKED"]        { --pill-fg: var(--st-locked);        --pill-bg: var(--st-locked-bg); }
.pill--locked::before,
.pill[data-status="LOCKED"]::before { animation: pulse 1.6s var(--ease-in-out) infinite; }

/* House context: set on any element (tag, card, progress) */
[data-house="gryffindor"], .house--gryffindor { --house: var(--house-gryffindor); --house-soft: var(--house-gryffindor-soft); }
[data-house="slytherin"],  .house--slytherin  { --house: var(--house-slytherin);  --house-soft: var(--house-slytherin-soft); }
[data-house="ravenclaw"],  .house--ravenclaw  { --house: var(--house-ravenclaw);  --house-soft: var(--house-ravenclaw-soft); }
[data-house="hufflepuff"], .house--hufflepuff { --house: var(--house-hufflepuff); --house-soft: var(--house-hufflepuff-soft); }

.house-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.75rem;
  padding: 0 0.75rem 0 0.65rem;
  border-radius: var(--r-full);
  border: 1px solid color-mix(in srgb, var(--house, var(--text-muted)) 28%, transparent);
  background: var(--house-soft, var(--surface-2));
  color: var(--house, var(--text-muted));
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
}
.house-tag::before {          /* small crest diamond */
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(45deg);
  flex-shrink: 0;
}
.house-tag--lg { min-height: 2.25rem; padding-inline: 1rem; font-size: var(--fs-base); }

/* ---------- 6. Alert / banner ---------- */
.alert {
  --a-fg: var(--info-text);
  --a-bg: var(--info-soft);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid color-mix(in srgb, var(--a-fg) 28%, transparent);
  border-inline-start-width: 4px;
  border-inline-start-color: var(--a-fg);
  border-radius: var(--r-md);
  background: var(--a-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}
.alert--success { --a-fg: var(--success-text); --a-bg: var(--success-soft); }
.alert--error   { --a-fg: var(--danger-text);  --a-bg: var(--danger-soft); }
.alert--warn    { --a-fg: var(--warn-text);    --a-bg: var(--warn-soft); }
.alert--info    { --a-fg: var(--info-text);    --a-bg: var(--info-soft); }
.alert__icon { color: var(--a-fg); display: inline-flex; padding-top: 0.1rem; }
.alert__icon svg.lucide { width: 1.25rem; height: 1.25rem; }
.alert__content { flex: 1; min-width: 0; }
.alert__title { display: block; margin-bottom: 0.15rem; font-weight: var(--fw-semibold); color: var(--a-fg); font-size: var(--fs-base); }
.alert__close { margin: -0.5rem -0.5rem -0.5rem 0; }
.alert--banner { border-radius: 0; border-inline-width: 0; border-top-width: 0; }

/* ---------- 7. Form fields ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.field__label { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--text); line-height: var(--lh-snug); }
.field__label .req { color: var(--danger-text); margin-inline-start: 0.15rem; }
.field__hint { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-snug); }
.field__error {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--danger-text);
  line-height: var(--lh-snug);
}
.field__error svg.lucide { width: 1rem; height: 1rem; margin-top: 0.15rem; }
.field__meta { display: flex; align-items: flex-start; gap: var(--sp-3); }
.field__counter {
  margin-inline-start: auto;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.field__counter.is-near { color: var(--warn-text); }
.field__counter.is-over { color: var(--danger-text); font-weight: var(--fw-semibold); }

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background-color: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: max(16px, 1rem);   /* >=16px prevents iOS zoom */
  line-height: 1.5;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-subtle); opacity: 1; }
.input:hover,
.textarea:hover,
.select:hover { border-color: var(--text-muted); }
.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
  border-color: var(--primary);
}
.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.select[aria-invalid="true"],
.is-invalid .input,
.is-invalid .textarea,
.is-invalid .select { border-color: var(--danger); }
.input:disabled,
.textarea:disabled,
.select:disabled {
  background-color: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}
.textarea { min-height: 7.5rem; padding-block: var(--sp-3); resize: vertical; }
.select {
  padding-inline-end: 2.75rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  cursor: pointer;
}
.input[type="date"],
.input[type="time"],
.input[type="datetime-local"] { min-height: var(--control-h); cursor: pointer; }
/* Touch: compact variants set by page stylesheets (e.g. .select--inline "ต่อหน้า" = 36px)
   grow back to 44px; desktop keeps them compact. */
@media (pointer: coarse) {
  .input.input,
  .select.select { min-height: var(--tap); }
}

/* input with leading icon */
.input-icon { position: relative; min-width: 0; }
.input-icon > svg.lucide,
.input-icon > i[data-lucide] {
  position: absolute;
  inset-inline-start: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.15rem;
  height: 1.15rem;
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon > .input { padding-inline-start: 2.6rem; }

/* number stepper */
.num {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--input-bg);
  overflow: hidden;
}
.num:has(.num__input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 1px; }
.num__btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.num__btn:hover { background: var(--surface-3); }
.num__btn:focus-visible { outline-offset: -3px; }
.num__input {
  width: 4.5rem;
  min-width: 0;
  border: 0;
  border-inline: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: max(16px, 1rem);
  font-weight: var(--fw-semibold);
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.num__input:focus { outline: none; }
.num__input::-webkit-outer-spin-button,
.num__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* checkbox / radio rows (native controls, themed via accent-color) */
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding-block: var(--sp-2);
  cursor: pointer;
  line-height: var(--lh-snug);
}
.check input:not(.switch) {        /* :not() keeps `.switch` its own track size */
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.1rem 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.check__desc { display: block; font-size: var(--fs-sm); color: var(--text-muted); }

/* switch: <input type="checkbox" role="switch" class="switch"> */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  margin: 0;
  border-radius: var(--r-full);
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.1875rem;
  inset-inline-start: 0.1875rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur) var(--ease);
}
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(1.25rem); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }
.check .switch { margin-top: 0.05rem; }
/* Touch: the 44x24 track keeps its look; an invisible ::before widens the hit area to 44px tall
   (::after is the knob). Inside .check / .toggle the row itself is already the 44px target. */
@media (pointer: coarse) {
  .switch::before {
    content: "";
    position: absolute;
    inset: -0.625rem 0;
  }
}

/* radio-card (role picker) */
.radio-card { position: relative; display: block; min-width: 0; }
.radio-card__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.radio-card__input:disabled { cursor: not-allowed; }
.radio-card__body {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  height: 100%;
  padding: var(--sp-4);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.radio-card:hover .radio-card__body { border-color: var(--border-strong); }
.radio-card__input:checked + .radio-card__body {
  border-color: var(--primary);
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 12%, var(--surface)), color-mix(in srgb, var(--gold) 10%, var(--surface)));
  box-shadow: inset 0 0 0 1px var(--primary), var(--glow-amethyst);
}
.radio-card__input:focus-visible + .radio-card__body { outline: 2px solid var(--ring); outline-offset: 2px; }
.radio-card__input:disabled + .radio-card__body {
  background: var(--surface-2);
  border-color: var(--border);
  box-shadow: none;
  opacity: 0.7;
}
.radio-card__mark {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.15rem;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--input-bg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.radio-card__input:checked + .radio-card__body .radio-card__mark {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 0.25rem var(--input-bg), inset 0 0 0 1rem var(--primary);
}
.radio-card__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-md);
  background: linear-gradient(140deg, var(--primary-soft), color-mix(in srgb, var(--primary) 22%, var(--primary-soft)));
  color: var(--primary-text);
}
.radio-card__content { flex: 1; min-width: 0; }
.radio-card__title { display: block; font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
.radio-card__desc { display: block; margin-top: 0.15rem; font-size: var(--fs-sm); color: var(--text-muted); line-height: var(--lh-snug); }
.radio-card__meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

/* ---------- 8. Tabs · segmented control ---------- */
.tabs {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  margin-bottom: -1px;
  padding: 0 var(--sp-4);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"],
.tab.is-active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tab:focus-visible { outline-offset: -3px; }

.seg {
  display: inline-flex;
  gap: 0.25rem;
  max-width: 100%;
  padding: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.seg::-webkit-scrollbar { display: none; }
.seg--block { display: flex; width: 100%; }
.seg__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2.5rem;
  padding: 0 var(--sp-4);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.seg--block .seg__btn { flex: 1 0 auto; }
.seg__btn:hover { color: var(--text); }
.seg__btn[aria-selected="true"],
.seg__btn[aria-pressed="true"],
.seg__btn[aria-current="page"],
.seg__btn.is-active {
  background: var(--surface);
  color: var(--primary-text);
  box-shadow: var(--shadow-sm);
}
.seg__btn:focus-visible { outline-offset: -2px; }
@media (pointer: coarse) { .seg__btn.seg__btn { min-height: var(--tap); } }

/* ---------- 9. Table -> stacked cards (<768px) ---------- */
.table-wrap {
  position: relative;          /* keeps .sr-only cells inside the scroll box */
  overflow-x: auto;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: var(--fw-semibold);
  text-align: start;
  white-space: nowrap;
}
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 79.99rem) {
  .table th,
  .table td { padding-inline: var(--sp-3); }
}
.table--hover tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.table--hover tbody tr:hover { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.table tr.is-selected { background: var(--primary-soft); }
.table .cell-actions { text-align: end; white-space: nowrap; }
.table .cell-num { text-align: end; font-variant-numeric: tabular-nums; }
.cell-user { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.cell-user__name { display: block; font-weight: var(--fw-semibold); color: var(--text); }
.cell-user__sub { display: block; font-size: var(--fs-xs); color: var(--text-muted); }

@media (max-width: 47.99rem) {
  .table-wrap--stack,
  .table-wrap:has(> .table--stack) {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .table--stack thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table--stack,
  .table--stack tbody,
  .table--stack tr,
  .table--stack td { display: block; width: 100%; }
  .table--stack tr {
    margin-bottom: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }
  .table--stack td {
    display: grid;
    grid-template-columns: minmax(6rem, 36%) minmax(0, 1fr);
    align-items: center;
    justify-items: start;
    gap: var(--sp-3);
    padding: var(--sp-2) 0;
    text-align: start;
  }
  .table--stack td.cell-num { text-align: start; }
  .table--stack tbody tr td:not(:last-child) { border-bottom: 1px solid var(--border); }
  .table--stack tbody tr td:last-child { border-bottom: 0; }
  .table--stack td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
  }
  .table--stack td:not([data-label])::before,
  .table--stack td[data-label=""]::before { content: none; }
  .table--stack td:not([data-label]),
  .table--stack td[data-label=""] { grid-template-columns: minmax(0, 1fr); }
  .table--stack td.cell-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding-top: var(--sp-3);
  }
  .table--stack td.cell-actions::before { content: none; }
  .table--stack td.cell-actions .btn { flex: 1 1 auto; }
}

/* ---------- 10. Modal -> bottom sheet (<640px) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: var(--overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.modal.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--dur) var(--ease), visibility 0s;
}
.modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 32rem;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  transform: translateY(0.75rem) scale(0.98);
  transition: transform var(--dur-slow) var(--ease);
}
.modal__dialog::after {                 /* champagne hairline on the top edge */
  content: "";
  position: absolute;
  top: 0;
  inset-inline: var(--sp-8);
  height: 1px;
  background: var(--hairline-gold);
  pointer-events: none;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .modal.is-open { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
}
.modal__dialog:focus { outline: none; }
.modal.is-open .modal__dialog { transform: none; }
.modal--sm .modal__dialog { max-width: 26rem; }
.modal--lg .modal__dialog { max-width: 52rem; }
.modal__header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}
.modal__title { flex: 1; min-width: 0; margin: 0; font-size: var(--fs-lg); padding-top: 0.2rem; }
.modal__close { margin: -0.4rem -0.6rem 0 0; }
.modal__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--sp-2) var(--sp-5) var(--sp-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}
.modal__footer-start { margin-inline-end: auto; }

/* confirm dialog (built by App.confirmDialog) */
.confirm__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
}
.confirm__icon--danger { background: var(--danger-soft); color: var(--danger-text); }
.confirm__msg { margin: 0; color: var(--text-muted); white-space: pre-line; }

@media (max-width: 39.99rem) {
  .modal { align-items: flex-end; padding: 0; }
  .modal__dialog,
  .modal--sm .modal__dialog,
  .modal--lg .modal__dialog {
    max-width: none;
    max-height: 92vh;
    max-height: 92dvh;
    border-bottom: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
  .modal__dialog::before {            /* sheet grabber (decorative) */
    content: "";
    flex-shrink: 0;
    width: 2.5rem;
    height: 0.25rem;
    margin: var(--sp-2) auto 0;
    border-radius: var(--r-full);
    background: var(--border-strong);
    opacity: 0.5;
  }
  .modal__header { padding: var(--sp-3) var(--sp-4) var(--sp-2); }
  .modal__body { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  .modal__footer { padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom)); }
  .modal__footer > .btn { flex: 1 1 auto; }
}

/* ---------- 11. Toast ---------- */
.toast-stack {
  position: fixed;
  z-index: var(--z-toast);
  inset-inline-end: var(--sp-4);
  bottom: calc(var(--sp-4) + var(--toast-offset, 0px) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(24rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  --t-fg: var(--info-text);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2) var(--sp-3) var(--sp-4);
  border: 1px solid var(--glass-border);
  border-inline-start: 4px solid var(--t-fg);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast--success { --t-fg: var(--success-text); }
.toast--error   { --t-fg: var(--danger-text); }
.toast--warn    { --t-fg: var(--warn-text); }
.toast--info    { --t-fg: var(--info-text); }
.toast__icon { display: inline-flex; padding-top: 0.1rem; color: var(--t-fg); }
.toast__msg { flex: 1; min-width: 0; padding-top: 0.1rem; font-size: var(--fs-sm); line-height: var(--lh-snug); }
.toast__close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin: -0.15rem 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.toast__close:hover { background: var(--surface-3); color: var(--text); }
.toast__close svg.lucide { width: 1rem; height: 1rem; }
@media (pointer: coarse) { .toast__close { width: var(--tap); height: var(--tap); margin: -0.5rem 0; } }
@media (max-width: 47.99rem) {
  .toast-stack { inset-inline: var(--sp-3); width: auto; }
}

/* ---------- 12. Stat card ---------- */
.stat {
  --s-fg: var(--primary-text);
  --s-bg: var(--primary-soft);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
  padding: var(--sp-4);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  background: var(--glass-bg);
  box-shadow: var(--shadow-xs);
  color: var(--text);
  font: inherit;
  text-align: start;
}
.stat::before {                     /* amethyst bloom in the corner */
  content: "";
  position: absolute;
  z-index: -1;
  width: 9rem;
  height: 9rem;
  inset-inline-end: -2.5rem;
  bottom: -3.75rem;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--s-fg) 30%, transparent), transparent);
  pointer-events: none;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .stat {
    background: var(--glass-bg-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
  }
}
button.stat { cursor: pointer; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
button.stat:hover { box-shadow: var(--glow-amethyst); }
.stat[aria-pressed="true"] { border-color: var(--s-fg); box-shadow: inset 0 0 0 1px var(--s-fg); }
.stat__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.stat__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-muted); line-height: var(--lh-snug); }
.stat__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-md);
  background: var(--s-bg);
  color: var(--s-fg);
}
.stat__icon svg.lucide { width: 1.15rem; height: 1.15rem; }
.stat__value {                     /* Playfair Display numerals in champagne */
  font-family: var(--font-numeric);
  font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.4rem);
  font-weight: var(--fw-medium);
  line-height: 1.15;
  color: var(--numeral);
  font-variant-numeric: lining-nums tabular-nums;
}
.stat__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.stat--pending       { --s-fg: var(--st-pending);       --s-bg: var(--st-pending-bg); }
.stat--form-approved { --s-fg: var(--st-form-approved); --s-bg: var(--st-form-approved-bg); }
.stat--approved      { --s-fg: var(--st-approved);      --s-bg: var(--st-approved-bg); }
.stat--rejected      { --s-fg: var(--st-rejected);      --s-bg: var(--st-rejected-bg); }
.stat--gold          { --s-fg: var(--gold-text);        --s-bg: var(--gold-soft); }

/* ---------- 13. Progress ---------- */
.progress {
  height: 0.5rem;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--surface-3);
}
.progress--lg { height: 0.75rem; }
.progress__bar {
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--house, var(--primary));
  transition: width var(--dur-slow) var(--ease);
}
.progress--gold .progress__bar { background: linear-gradient(90deg, var(--gold-text), var(--gold)); }
.progress--success .progress__bar { background: var(--success); }
.progress--danger .progress__bar { background: var(--danger); }
.progress-label {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
  font-size: var(--fs-sm);
}
.progress-label__value { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- 14. Avatar · user chip ---------- */
.avatar {
  --size: 2rem;
  position: relative;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: calc(var(--size) * 0.42);
  font-weight: var(--fw-bold);
  line-height: 1;
  object-fit: cover;
}
/* Discord image layered over the initial; removed by app.js if it fails to load */
.avatar > img,
.avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { --size: 1.5rem; }
.avatar--lg { --size: 2.75rem; }
.avatar--xl { --size: 4.5rem; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--gold); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 100%;
  min-height: var(--tap);
  padding: 0.25rem 0.75rem 0.25rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  text-decoration: none;
}
.user-chip:hover { background: var(--surface-3); }
.user-chip__name { max-width: 10rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-chip__caret { width: 1rem; height: 1rem; color: var(--text-muted); }

/* ---------- 15. Dropdown menu ---------- */
.dropdown { position: relative; display: inline-flex; }
.menu {
  position: absolute;
  top: calc(100% + 0.375rem);
  inset-inline-start: 0;
  z-index: var(--z-dropdown);
  display: none;
  min-width: 13rem;
  max-width: min(20rem, calc(100vw - 2rem));
  padding: var(--sp-1);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.dropdown.is-open > .menu { display: block; animation: menu-in var(--dur) var(--ease); }
.menu--end { inset-inline-start: auto; inset-inline-end: 0; }
.menu--up { top: auto; bottom: calc(100% + 0.375rem); }
.menu__header {
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-snug);
}
.menu__header strong { display: block; color: var(--text); }
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: start;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.menu__item:hover,
.menu__item:focus-visible { background: var(--surface-3); text-decoration: none; }
.menu__item:focus-visible { outline-offset: -2px; }
.menu__item svg.lucide { width: 1.1rem; height: 1.1rem; color: var(--text-muted); }
.menu__item--danger,
.menu__item--danger svg.lucide { color: var(--danger-text); }
.menu__item:disabled { opacity: 0.5; cursor: not-allowed; }
.menu__sep { height: 1px; margin: var(--sp-1) 0; background: var(--border); }
@media (min-width: 48rem) and (pointer: fine) { .menu__item { min-height: 2.5rem; } }

/* ---------- 16. Stepper (multi-step progress) ---------- */
.steps {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}
.steps__item {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.steps__item + .steps__item::before {    /* connector */
  content: "";
  position: absolute;
  top: 1rem;
  inset-inline-start: calc(-50% + 1.375rem);
  inset-inline-end: calc(50% + 1.375rem);
  height: 2px;
  border-radius: 2px;
  background: var(--border);
}
.steps__item.is-done + .steps__item::before { background: linear-gradient(90deg, var(--primary), var(--gold)); }
.steps__dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.steps__dot svg.lucide { width: 1rem; height: 1rem; }
.steps__item.is-current .steps__dot {
  border-color: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.steps__item.is-done .steps__dot {
  border-color: var(--primary);
  background: var(--primary) var(--btn-primary-bg);
  color: var(--on-primary);
  box-shadow: var(--btn-primary-ring);
}
.steps__label { line-height: var(--lh-snug); overflow-wrap: anywhere; }
.steps__item.is-current .steps__label { color: var(--text); font-weight: var(--fw-semibold); }

/* ---------- 17. Timeline ---------- */
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline__item {
  position: relative;
  padding-inline-start: 2.5rem;
  padding-bottom: var(--sp-5);
}
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {               /* rail */
  content: "";
  position: absolute;
  top: 1.75rem;
  bottom: 0.25rem;
  inset-inline-start: 0.6875rem;
  width: 2px;
  border-radius: 2px;
  background: var(--border);
}
.timeline__item:last-child::before { display: none; }
.timeline__item.is-done::before { background: color-mix(in srgb, var(--success) 55%, var(--border)); }
.timeline__dot {
  position: absolute;
  top: 0.125rem;
  inset-inline-start: 0;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
}
.timeline__dot svg.lucide { width: 0.85rem; height: 0.85rem; stroke-width: 2.5; }
.timeline__item.is-done .timeline__dot { border-color: var(--success); background: var(--success); color: var(--on-success); }
.timeline__item.is-current .timeline__dot {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-text);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
}
.timeline__item.is-danger .timeline__dot { border-color: var(--danger); background: var(--danger); color: var(--on-danger); }
.timeline__title { font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
.timeline__time { font-size: var(--fs-xs); color: var(--text-muted); }
.timeline__body { margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- 18. Empty state · skeleton ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-4);
  text-align: center;
  color: var(--text-muted);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: var(--sp-2);
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
}
.empty__icon svg.lucide { width: 1.6rem; height: 1.6rem; }
.empty__title { margin: 0; font-size: var(--fs-lg); color: var(--text); }
.empty__text { max-width: 28rem; margin: 0; font-size: var(--fs-sm); }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-3); }

.skeleton {
  display: block;
  height: 1em;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 37%, var(--skeleton-a) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton--text { height: 0.875rem; margin-block: 0.4rem; }
.skeleton--title { height: 1.4rem; width: 55%; margin-bottom: 0.6rem; }
.skeleton--avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; flex-shrink: 0; }
.skeleton--block { height: 6rem; border-radius: var(--r-md); }

/* ---------- 19. Pagination ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.pagination__btn {
  display: inline-grid;
  place-items: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  cursor: pointer;
}
.pagination__btn:hover { background: var(--surface-3); text-decoration: none; }
.pagination__btn[aria-current="page"] { background: var(--primary) var(--btn-primary-bg); color: var(--on-primary); box-shadow: var(--btn-primary-ring); }
.pagination__btn[aria-disabled="true"],
.pagination__btn:disabled { opacity: 0.45; pointer-events: none; }
.pagination__gap { padding: 0 var(--sp-1); color: var(--text-muted); }
@media (max-width: 29.99rem) {
  .pagination__item--far { display: none; }
}

/* ---------- 20. Filter chips (horizontal scroll) ---------- */
.chips {
  display: flex;
  gap: var(--sp-2);
  padding: 0.125rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 2.5rem;
  padding: 0 var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"],
.chip[aria-current="page"],
.chip.is-active { background: var(--primary) var(--btn-primary-bg); border-color: transparent; color: var(--on-primary); box-shadow: var(--btn-primary-ring); }
.chip__dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--dot, var(--text-muted)); }
.chip__dot--pending       { --dot: var(--st-pending); }
.chip__dot--form-approved { --dot: var(--st-form-approved); }
.chip__dot--approved      { --dot: var(--st-approved); }
.chip__dot--rejected      { --dot: var(--st-rejected); }
.chip[aria-pressed="true"] .chip__dot { background: currentColor; }
.chip__count {
  min-width: 1.5rem;
  padding: 0 0.4rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] .chip__count,
.chip.is-active .chip__count { background: color-mix(in srgb, var(--on-primary) 16%, transparent); color: inherit; }
@media (pointer: coarse) { .chip.chip { min-height: var(--tap); } }

/* ---------- 21. Key-value list · Q&A (review detail) ---------- */
.kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-1) var(--sp-4);
  margin: 0;
}
.kv dt { font-size: var(--fs-sm); color: var(--text-muted); }
.kv dd { margin: 0 0 var(--sp-2); min-width: 0; }
@media (min-width: 30rem) {
  .kv { grid-template-columns: minmax(7rem, 32%) minmax(0, 1fr); }
  .kv dd { margin: 0; }
}
.qa { display: flex; flex-direction: column; gap: var(--sp-2); }
.qa__q { margin: 0; font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
.qa__a {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  white-space: pre-wrap;
  font-size: var(--fs-sm);
}

/* ---------- 22. Keyframes ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(0.5rem); } }

/* ---------- 23. Scroll — pearl paper between silver-gold rods ----------
   <div class="scroll [scroll--bleed]">
     <div class="scroll__rod" aria-hidden="true"></div>
     <div class="scroll__body"><div class="scroll__paper"> … any components … </div></div>
     <div class="scroll__rod" aria-hidden="true"></div>
   </div>
   Tokens are re-mapped on .scroll__paper (tokens.css §4), so fields, radio-cards,
   buttons, pills, house tags, alerts, steps, timeline and Q&A render as dark ink
   on pearl. Put data-theme="dark" on an element inside the paper (e.g. a sticky
   action bar) to switch it back to the obsidian palette.
   Pure CSS: rods, pearl finials and paper texture are gradients — no images. */
.scroll {
  --scroll-inset: calc(var(--scroll-fin) * 0.75);
  position: relative;
  min-width: 0;
  margin-inline: auto;
}
.scroll__rod {
  position: relative;
  z-index: 2;
  height: var(--scroll-rod-h);
  background:
    var(--scroll-rod) center / calc(100% - 2 * var(--scroll-fin) + 0.25rem) var(--scroll-bar-h) no-repeat,
    radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, 0.45), transparent) center calc(50% + var(--scroll-bar-h) * 0.6) / calc(100% - 2 * var(--scroll-fin)) calc(var(--scroll-bar-h) * 1.2) no-repeat;
}
.scroll__rod::before,
.scroll__rod::after {                    /* pearl finials */
  content: "";
  position: absolute;
  top: 50%;
  width: var(--scroll-fin);
  height: var(--scroll-fin);
  margin-top: calc(var(--scroll-fin) / -2);
  border-radius: 50%;
  background: var(--scroll-fin-bg);
  box-shadow: 0 0 0 1px rgba(203, 179, 122, 0.7), 0 0 18px rgba(142, 108, 240, 0.35);
}
.scroll__rod::before { inset-inline-start: 0; }
.scroll__rod::after { inset-inline-end: 0; }

.scroll__body {
  display: grid;
  grid-template-rows: 1fr;
  margin-block: calc(var(--scroll-rod-h) / -2);   /* paper slides out from under the rods */
}
.scroll__paper {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  margin-inline: var(--scroll-inset);
  padding: calc(var(--scroll-rod-h) / 2 + clamp(1.75rem, 4vw, 3rem)) clamp(1.5rem, 5vw, 3.25rem);
  border-radius: 0.25rem;
  background: var(--scroll-paper);
  color: var(--text);
  box-shadow:
    0 0 0 1px rgba(203, 179, 122, 0.22),
    0 30px 60px -30px rgba(0, 0, 0, 0.85),
    0 0 90px -20px rgba(142, 108, 240, 0.45);
}
@supports (overflow: clip) {
  .scroll__paper { overflow: clip; }    /* clip (not hidden) keeps position: sticky working */
}
.scroll__paper::before {                 /* inner amethyst frame */
  content: "";
  position: absolute;
  inset: calc(var(--scroll-rod-h) / 2 + 0.5rem) 0.75rem;
  z-index: -1;                           /* behind content, above the paper (isolated) */
  border: 1px solid var(--scroll-frame);
  border-radius: 0.125rem;
  pointer-events: none;
}

/* Unroll on load: the body grows from 0fr → 1fr between the rods. */
@supports (overflow: clip) {
  .scroll__body { animation: scroll-unroll var(--dur-unroll) var(--ease) backwards; }
  .scroll__paper > * { animation: scroll-ink 700ms var(--ease) calc(var(--dur-unroll) * 0.45) backwards; }
}
.scroll--static .scroll__body,
.scroll--static .scroll__paper > * { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .scroll__body,
  .scroll__paper > * { animation: none !important; }
}
@keyframes scroll-unroll { from { grid-template-rows: 0fr; } to { grid-template-rows: 1fr; } }
@keyframes scroll-ink { from { opacity: 0; } to { opacity: 1; } }

/* Components that read better flat on paper */
.scroll__paper .card,
.scroll__paper .stat {
  background: rgba(255, 255, 255, 0.62);
  border-color: var(--hairline);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.scroll__paper .card--flat {
  background: transparent;
  border: 0;
  border-radius: 0;
}
.scroll__paper .card--flat > .card__header,
.scroll__paper .card--flat > .card__body,
.scroll__paper .card--flat > .card__footer { padding-inline: 0; }
.scroll__paper .radio-card__body { background: rgba(255, 255, 255, 0.72); border-color: var(--hairline-strong); }
.scroll__paper .radio-card:hover .radio-card__body { border-color: var(--border-strong); }
.scroll__paper .qa__a,
.scroll__paper .panel { background: rgba(243, 239, 250, 0.8); }
.scroll__paper .ornament { color: var(--primary); }
.scroll__paper .ornament::before { background: linear-gradient(90deg, transparent, rgba(142, 108, 240, 0.7)); }
.scroll__paper .ornament::after { background: linear-gradient(90deg, rgba(142, 108, 240, 0.7), transparent); }
.scroll__paper .pill::before { background: currentColor; }

/* Mobile: thinner rods, 8–12px side margin (with .scroll--bleed), compact paper. */
@media (max-width: 39.99rem) {
  .scroll {
    --scroll-rod-h: 1.375rem;   /* 22 */
    --scroll-bar-h: 0.5rem;     /* 8  */
    --scroll-fin: 1rem;         /* 16 */
  }
  .scroll--bleed { margin-inline: calc(0.625rem - var(--gutter, 0.625rem)); }
  .scroll__paper { padding: calc(var(--scroll-rod-h) / 2 + 1.5rem) 1rem; }
  .scroll__paper::before { inset: calc(var(--scroll-rod-h) / 2 + 0.25rem) 0.375rem; }
}

/* ---------- 24. Dark glass bar / island ---------- */
.glass-bar {
  background: var(--glass-bar);
  color: var(--text);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-bar {
    background: var(--glass-bar-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
  }
}
