/* ============================================================
   ezpztrader.com — shared components (UI_REDESIGN.md §11)
   Loaded on every page (marketing + app) right after tokens.css.
   Restyles today's class names so un-migrated markup picks up the
   new look, and adds the new shared components. Visual only: no
   selector here changes what an element does.
   Sections: 1 reset · 2 type · 3 layout · 4 buttons · 5 badges ·
   6 cards · 7 tables · 8 forms · 9 feedback · 10 overlays ·
   11 navigation bits · 12 content · 13 utilities · 14 motion
   ============================================================ */

@layer legacy {

/* ---------- 1. reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  letter-spacing: var(--tracking-body);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv01" on, "ss03" on;
  overflow-x: hidden;
}
::selection { background: var(--action); color: var(--on-action); }
img, svg { max-width: 100%; display: block; }
/* Icon safety net (§14): zero specificity, icon contexts only — charts are untouched. */
:where(nav, header, aside, button, a, summary, label, .btn) svg:not([width]) { width: 1.25em; height: 1.25em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-xs); }
[data-theme="light"] .icon-moon,
[data-theme="dark"] .icon-sun { display: none; }

/* ---------- 2. type ---------- */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  line-height: var(--leading-heading);
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0 0 .5em;
  color: var(--ink);
}
h1 { font-size: var(--text-h1); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--text-h2); line-height: 1.15; letter-spacing: var(--tracking-tight); }
h3 { font-size: var(--text-h3); letter-spacing: var(--tracking-tight); }
h4 { font-size: var(--text-lg); letter-spacing: -0.005em; }
p { margin: 0 0 1em; max-width: var(--measure); }
a { color: var(--action-ink); text-decoration: none; transition: color .15s var(--ease-out); }
a:hover { color: var(--link-hover); }
code, pre, kbd, samp, .mono { font-family: var(--font-mono); }
code { font-size: .92em; }
pre {
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
}
ul, ol { padding-left: var(--space-5); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; }
.num, td.num, th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* Eyebrow: kept as a class, restyled from tracked mono to a quiet label. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: .02em;
  text-transform: none;
  color: var(--ink-3);
  margin-bottom: var(--space-3);
}
.eyebrow::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

/* ---------- 3. layout ---------- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); position: relative; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: var(--space-6); }
.section { padding: var(--section-y) 0; position: relative; }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* Page header — one pattern everywhere (title · description · actions). */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-6);
  margin-bottom: var(--space-6);
}
.page-head > :first-child { min-width: 0; }
.page-head h1, .page-title {
  font-size: var(--text-3xl);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-head p, .page-desc { color: var(--ink-2); font-size: var(--text-base); margin: var(--space-1) 0 0; }

/* ---------- 4. buttons ---------- */
.link-btn, .link-button {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; font-weight: var(--weight-medium);
  color: var(--action-ink); cursor: pointer;
}
.link-btn:hover, .link-button:hover { color: var(--link-hover); text-decoration: underline; }

/* ---------- 5. badges, pills, chips ---------- */
/* Account type: styles the EXISTING "(Paper)"/"Live" text only. */
.acct-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px;
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semi);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}
.acct-badge.is-live { background: var(--live-soft); color: var(--live); }
.acct-badge.is-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
.acct-badge.is-paper { color: var(--ink-2); border: 1px solid var(--border-strong); }

.count {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--action);
  color: var(--on-action);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  line-height: var(--leading-none);
}

/* Legacy colour-cycle badges (some set from templates/Python): Ion tones. */
.badge-violet, .badge-magenta { background: var(--brand-soft); color: var(--brand); }
.badge-gold { background: var(--warn-soft); color: var(--warn); }
.badge-teal { background: var(--action-soft); color: var(--action-ink); }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-rose { background: var(--danger-soft); color: var(--danger); }

/* Direction + money colour (from the sign/class templates already have). */
.dir-buy, .pnl-pos, .is-profit { color: var(--buy); }
.dir-sell, .pnl-neg, .is-loss { color: var(--sell); }

/* Fill timing cell — HTML built in Python (trading_extras.py); restyle only. */
.fill-timing { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-medium); white-space: nowrap; }
.fill-timing-icon { width: 16px; height: 16px; flex-shrink: 0; }
.fill-timing-buy { color: var(--ok); }
.fill-timing-accent { color: var(--info); }
.fill-timing-gold { color: var(--warn); }
.fill-timing-sell { color: var(--danger); }
.fill-timing-ms { color: var(--ink-3); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-normal); font-variant-numeric: tabular-nums; }
.fill-timing-note { display: block; min-width: 11rem; max-width: 18rem; margin-top: var(--space-1); color: var(--ink-3); font-size: var(--text-xs); line-height: var(--leading-snug); white-space: normal; }

/* ---------- 6. cards ---------- */
/* KPI / stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.stat { background: var(--surface); padding: var(--space-3) var(--space-4); display: grid; gap: 2px; min-width: 0; }
.stat-label { font-size: var(--text-xs); color: var(--ink-3); }
.stat-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-xl); font-weight: var(--weight-medium); color: var(--ink); }
.stat-sub { font-size: var(--text-xs); color: var(--ink-3); }
/* Money colour must win over the neutral stat value colour. */
.stat-value.pnl-pos, .pnl-pos .stat-value, .stat-value.is-profit, .stat-value.dir-buy { color: var(--buy); }
.stat-value.pnl-neg, .pnl-neg .stat-value, .stat-value.is-loss, .stat-value.dir-sell { color: var(--sell); }

/* ---------- 7. tables ---------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow-x: auto;
  /* Contains the cells' absolutely placed .sr-only text; without it that
     text sits past the scrolled-off columns and widens the whole page. */
  position: relative;
}
table { border-collapse: collapse; width: 100%; font-size: var(--text-base); }
th, td { text-align: left; padding: 0 var(--space-3); height: 44px; border-bottom: 1px solid var(--border); vertical-align: middle; }
td { padding-top: var(--space-2); padding-bottom: var(--space-2); }
thead th {
  height: 36px;
  background: var(--surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  white-space: nowrap;
}
th.num { font-family: var(--font-body); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--raised) 60%, transparent); }
.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 1024px) { .table-wrap.is-fit { overflow: visible; } }

/* Pagination (trading/_pagination.html) */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); font-size: var(--text-sm); color: var(--ink-2); }
.pagination a, .pagination span { min-width: 32px; height: 32px; padding: 0 var(--space-2); display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); color: var(--ink); background: var(--surface); }
.pagination a:hover { border-color: var(--input-border); color: var(--ink); }
.pagination [aria-current="page"] { background: var(--action-soft); border-color: var(--action); color: var(--ink); }

/* ---------- 8. forms ---------- */
.form-field { margin-bottom: var(--space-5); }
.form-field > label, .field-label, .form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink);
  margin-bottom: var(--space-2);
}
.input, .select, .textarea,
.form-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="color"]),
.form-field select,
.form-field textarea,
.filter-field select,
.filter-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  width: 100%;
  min-height: var(--control-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.input::placeholder, .textarea::placeholder, .form-field input::placeholder, .form-field textarea::placeholder, .filter-field input::placeholder { color: var(--ink-3); opacity: .8; }
.select, .form-field select, .filter-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-8);
  cursor: pointer;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.textarea, .form-field textarea { line-height: var(--leading-relaxed); resize: vertical; }
.input:focus, .select:focus, .textarea:focus,
.form-field input:focus, .form-field select:focus, .form-field textarea:focus,
.filter-field input:focus, .filter-field select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
  box-shadow: none;
}
.input:disabled, .select:disabled, .form-field input:disabled, .form-field select:disabled, .form-field textarea:disabled { opacity: .6; cursor: not-allowed; }
.form-field input[aria-invalid="true"], .input[aria-invalid="true"] { border-color: var(--danger); }
.form-field .helptext, .help, .form-help { display: block; font-size: var(--text-sm); color: var(--ink-2); margin-top: var(--space-2); line-height: var(--leading-snug); }
.form-field .helptext[hidden] { display: none; }
.form-field .errorlist, .errorlist { list-style: none; margin: var(--space-2) 0 0; padding: 0; color: var(--danger); font-size: var(--text-sm); }
.form-field-hint { display: block; font-size: var(--text-sm); color: var(--ink-2); margin-top: var(--space-2); line-height: var(--leading-snug); }
.form-field-error { display: block; margin-top: var(--space-2); color: var(--danger); font-size: var(--text-sm); }
.form-field-error[hidden] { display: none; }
.form-errors {
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: var(--text-sm);
}
.form-row { display: flex; gap: var(--space-4); }
.form-row .form-field { flex: 1; min-width: 0; }
.form-actions { margin-top: var(--space-6); }
.form-footer { margin-top: var(--space-6); text-align: center; font-size: var(--text-base); color: var(--ink-2); }
.form-footer a { font-weight: var(--weight-medium); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--action); }
.checkbox-option {
  display: flex; align-items: flex-start; gap: var(--space-2);
  font-size: var(--text-base); font-weight: var(--weight-normal);
  color: var(--ink-2); cursor: pointer;
}
.checkbox-option input:not(.switch-input) { width: 16px; height: 16px; flex-shrink: 0; margin-top: 3px; }
.checkbox-option a { font-weight: var(--weight-medium); }

/* Segmented control (visually-hidden radios inside labels). */
.segmented, .seg-group {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.segmented label, .seg-option {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 30px; padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  border: 0;
  background: transparent;
}
.segmented input, .seg-option input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; white-space: nowrap;
}
.segmented label:has(input:checked), .seg-option:has(input:checked), .seg-option.is-active, .seg-option.is-on {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border-strong);
}
.segmented label:has(input:focus-visible), .seg-option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Switch look for an existing checkbox (input stays the same element). */
.switch-input { appearance: none; -webkit-appearance: none; position: relative; width: 34px; height: 20px; border-radius: var(--radius-pill); background: var(--input-border); cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch-input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--knob); transition: transform .15s; box-shadow: var(--shadow-xs); }
.switch-input:checked { background: var(--action); }
.switch-input:checked::after { transform: translateX(14px); }

/* ---------- 9. feedback ---------- */
.toast-stack {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-2);
  width: min(92vw, 380px);
}
.toast {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--neutral);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-base);
  color: var(--ink);
  line-height: var(--leading-snug);
}
.toast-success { border-left-color: var(--ok); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warn); }
.toast-info    { border-left-color: var(--info); }
/* upgrade-modal.js turns this message into #upgrade-modal (ASSET_CLASS_LIMITS.md); hide the toast. */
.toast.toast-upgrade-modal { display: none; }
.toast-close {
  background: none; border: 0; color: var(--ink-3); cursor: pointer;
  font-size: var(--text-xl); line-height: var(--leading-none); padding: 0 var(--space-1); flex-shrink: 0;
}
.toast-close:hover { color: var(--ink); }
@media (max-width: 640px) {
  .toast-stack { left: var(--space-3); right: var(--space-3); width: auto; top: max(var(--space-3), env(safe-area-inset-top)); }
}

.callout, .inline-alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--sunken);
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.callout.is-warning { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); color: var(--ink); }
.callout.is-danger { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); color: var(--ink); }
.callout.is-info { border-color: color-mix(in srgb, var(--info) 45%, transparent); background: var(--info-soft); color: var(--ink); }

.empty {
  display: grid; justify-items: center; text-align: center; gap: var(--space-2);
  padding: var(--space-10) var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--ink-2);
}
.empty-icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--sunken); display: grid; place-items: center; color: var(--ink-3); }
.empty-icon svg { width: 20px; height: 20px; }
.empty h2, .empty h3 { font-size: var(--text-lg); margin: 0; }
.empty p { margin: 0 auto; max-width: 44ch; font-size: var(--text-base); }

/* ---------- 10. overlays ---------- */
dialog.modal {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 0;
  background: var(--raised);
  color: var(--ink);
  box-shadow: var(--shadow-2);
  max-width: min(92vw, 560px);
  width: 100%;
}
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.modal-inner { padding: var(--space-6); }
.modal-close, .modal-x {
  position: absolute; top: var(--space-3); right: var(--space-3);
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-3); cursor: pointer;
}
.modal-close:hover, .modal-x:hover { background: var(--sunken); color: var(--ink); }
.modal-close svg, .modal-x svg { width: 16px; height: 16px; }

/* Waitlist modal (base.html) */
dialog.waitlist-modal { max-width: min(92vw, 420px); background: var(--raised); }
.waitlist-modal-inner { padding: var(--space-8) var(--space-6) var(--space-6); position: relative; }
.waitlist-modal-inner .eyebrow { margin-bottom: var(--space-3); }
.waitlist-modal-inner h2 { margin: 0 0 var(--space-2); font-size: var(--text-2xl); }
.waitlist-modal-lede { margin: 0 0 var(--space-5); color: var(--ink-2); line-height: var(--leading-relaxed); }
.waitlist-modal-error { margin: calc(var(--space-3) * -1) 0 var(--space-4); color: var(--danger); font-size: var(--text-sm); }

/* Confirm modal (base.html #confirm-modal — replaces window.confirm, confirm.js) */
dialog.modal-confirm { max-width: min(calc(100vw - 2 * var(--space-4)), 400px); }
dialog.modal-confirm .modal-inner,
dialog.modal-upgrade .modal-inner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--space-7) var(--space-6) var(--space-6);
}
.modal-confirm-icon {
  display: grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; margin-bottom: var(--space-4);
  border-radius: 50%; background: var(--warn-soft); color: var(--warn);
}
.modal-confirm-icon svg { width: 22px; height: 22px; }
.modal-confirm-message { margin: 0 0 var(--space-6); color: var(--ink); font-size: var(--text-md); line-height: var(--leading-relaxed); overflow-wrap: anywhere; }
.modal-confirm-actions { display: flex; gap: var(--space-3); width: 100%; }
.modal-confirm-actions .btn { flex: 1 1 0; --btn-h: var(--control-md); }

/* Upgrade modal (asset-class plan limit — ASSET_CLASS_LIMITS.md) */
dialog.modal-upgrade { max-width: min(calc(100vw - 2 * var(--space-4)), 720px); }
dialog.modal-upgrade .modal-inner { max-height: calc(100vh - 2 * var(--space-6)); overflow-y: auto; }
dialog.modal-upgrade .modal-confirm-message { max-width: 52ch; }
.upgrade-plan-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3);
  width: 100%; margin-bottom: var(--space-6); text-align: left;
}
.upgrade-plan-card {
  display: flex; flex-direction: column; padding: var(--space-4);
  background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.upgrade-plan-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.upgrade-plan-card-name {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  margin: 0 0 var(--space-1); font-size: var(--text-md); font-weight: var(--weight-semi); color: var(--ink);
}
.upgrade-plan-card-badge {
  font-size: var(--text-2xs); font-weight: var(--weight-semi); padding: 2px var(--space-2);
  border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-ink);
}
.upgrade-plan-card-price { margin: 0 0 var(--space-3); font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--ink); font-variant-numeric: tabular-nums; }
.upgrade-plan-card-price span { font-size: var(--text-sm); font-weight: var(--weight-normal); color: var(--ink-3); }
.upgrade-plan-specs { margin: 0 0 var(--space-4); font-size: var(--text-sm); }
.upgrade-plan-specs div { display: flex; justify-content: space-between; padding: var(--space-1) 0; }
.upgrade-plan-specs dt { color: var(--ink-2); }
.upgrade-plan-specs dd { margin: 0; color: var(--ink); font-weight: var(--weight-semi); }
.upgrade-plan-card-cta { margin-top: auto; width: 100%; justify-content: center; }
.upgrade-plan-card-cta[aria-disabled="true"] { pointer-events: none; opacity: .6; }
@media (max-width: 480px) {
  .modal-confirm-actions { flex-direction: column-reverse; }
}
.waitlist-modal-success:not([hidden]) { display: flex; flex-direction: column; align-items: center; text-align: center; }
.waitlist-modal-success p { margin: 0 0 var(--space-5); color: var(--ink-2); line-height: var(--leading-relaxed); }
.waitlist-modal-success .btn { width: 100%; }
.waitlist-modal-icon { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin-bottom: var(--space-4); border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.waitlist-modal-icon svg { width: 24px; height: 24px; }
.waitlist-modal .form-actions .btn { width: 100%; }

/* Disclosure menu (<details data-menu>; menus.js closes on Esc/outside click). */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; z-index: var(--z-popover);
  top: calc(100% + 6px); right: 0;
  min-width: 200px;
  padding: var(--space-1);
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  display: grid;
}
.menu-panel.is-left { right: auto; left: 0; }
.menu-panel a, .menu-panel button, .menu-item {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%;
  min-height: 34px; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit; font-size: var(--text-base); text-align: left;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.menu-panel a:hover, .menu-panel button:hover, .menu-item:hover { background: var(--sunken); color: var(--ink); }
.menu-panel form { margin: 0; display: block; }
.menu-panel hr { margin: var(--space-1) 0; }
.menu-panel .is-danger { color: var(--danger); }
.menu-panel svg { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.menu-label { padding: var(--space-2) var(--space-3) var(--space-1); font-size: var(--text-xs); color: var(--ink-3); }

/* Tooltip-ish (chart-tooltip.js creates .chart-tooltip) */
.chart-tooltip {
  position: absolute; z-index: var(--z-tooltip); pointer-events: none;   /* chart-tooltip.js adds scroll offsets */
  padding: var(--space-2) var(--space-3);
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-xs);
}
.chart-tooltip-title { font-weight: var(--weight-semi); }
.chart-tooltip-sub { color: var(--ink-3); font-family: var(--font-mono); }

/* ---------- 11. navigation bits ---------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--space-5); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tab {
  flex: none;
  padding: var(--space-2) var(--space-3);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: var(--text-base); font-weight: var(--weight-medium);
  color: var(--ink-2); white-space: nowrap;
}
.tabs a:hover, .tab:hover { color: var(--ink); }
.tabs a[aria-current="page"], .tabs a.is-active, .tab.is-active { color: var(--ink); border-bottom-color: var(--action); }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--ink-3); min-width: 0; }
.breadcrumb a { color: var(--ink-2); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { color: var(--ink-3); opacity: .7; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: var(--z-skip);
  background: var(--action); color: var(--on-action);
  padding: var(--space-2) var(--space-4);
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: var(--weight-semi);
}
.skip-link:focus { left: 0; color: var(--on-action); }

/* Logo: the original full lockup (logo_mark.html). Sizes set per place and as attributes. */
.logo-mark { display: block; height: 28px; width: auto; flex-shrink: 0; }
.logo-mark-on-light { display: none; }
[data-theme="light"] .logo-mark-on-dark { display: none; }
[data-theme="light"] .logo-mark-on-light { display: block; }

/* Palette picker swatches (UI_REDESIGN.md §15) — shared by the public header,
   the mobile drawer and the app. Chip colours come from per-element --sw1..3. */
.palette-picker { display: grid; gap: var(--space-2); }
.palette-picker .menu-label { padding: 0; }
.palette-swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.palette-swatch {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: var(--text-xs); text-align: center; white-space: nowrap;
  cursor: pointer;
  transition: border-color .15s var(--ease-out), background-color .15s var(--ease-out);
}
.palette-swatch:hover { background: var(--sunken); border-color: var(--border-strong); color: var(--ink); }
.palette-swatch[aria-pressed="true"] { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); color: var(--ink); }
.palette-swatch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.palette-swatch-name { display: block; overflow: hidden; text-overflow: ellipsis; line-height: var(--leading-heading); }
.palette-chip {
  position: relative; display: block; flex: none;
  width: 100%; height: 22px;
  border-radius: var(--radius-sm);
  background: var(--sw1);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  overflow: hidden;
}
.palette-chip > span { position: absolute; display: block; }
.palette-chip > span:first-child { left: 6px; bottom: 6px; width: 45%; height: 4px; border-radius: 2px; background: var(--sw2); }
.palette-chip > span:last-child { right: 6px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--sw3); }

/* ---------- 12. content (DB-seeded HTML: legal, about, blog) ---------- */
.prose { max-width: 72ch; color: var(--ink-2); font-size: var(--text-md); line-height: var(--leading-normal); }
.prose > * + * { margin-top: 1em; }
.prose h2 { font-size: var(--text-2xl); color: var(--ink); margin: 2em 0 .5em; }
.prose h3 { font-size: var(--text-xl); color: var(--ink); margin: 1.6em 0 .4em; }
.prose h4 { font-size: var(--text-lg); color: var(--ink); }
.prose p { max-width: none; margin: 0 0 1em; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .35em; }
.prose strong { color: var(--ink); font-weight: var(--weight-semi); }
.prose blockquote { margin: 1.4em 0; padding: .2em 0 .2em 1em; border-left: 3px solid var(--brand); color: var(--ink); }
.prose img { border-radius: var(--radius-md); border: 1px solid var(--border); height: auto; }
.prose table { font-size: var(--text-sm); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; display: block; overflow-x: auto; }
.prose code { background: var(--sunken); padding: .1em .35em; border-radius: var(--radius-xs); color: var(--ink); }
.prose pre code { background: none; padding: 0; }

/* ---------- 13. utilities ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; white-space: nowrap; }
.muted { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
   .flex { display: flex; }   .small { font-size: var(--text-sm); }

/* ---------- 14. motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

} /* @layer legacy */

/* Phase 2 components (buttons, cards, partials, page head). The rules above stay in @layer legacy. */
@layer components {
/* ---------- buttons ----------
   Colours come from --btn-* set by the variant; size from --btn-h/--btn-px/--btn-fs,
   read with a fallback (not declared here) so a container can still size its
   buttons. Radius: fully rounded on public pages, 8px in the app (O14). */
.is-app { --btn-radius: var(--radius-md); }

.btn {
  --btn-bg: var(--raised);
  --btn-bg-hover: var(--surface-hover);
  --btn-ink: var(--ink);
  --btn-ink-hover: var(--btn-ink);
  --btn-line: var(--border-strong);
  --btn-line-hover: var(--input-border);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--btn-h, var(--space-10));
  padding: 0 var(--btn-px, var(--space-4));
  border: 1px solid var(--btn-line);
  border-radius: var(--btn-radius, var(--radius-pill));
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-family: var(--font-body);
  font-size: var(--btn-fs, var(--text-base));
  font-weight: var(--weight-medium);
  line-height: var(--leading-heading);
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-instant) var(--ease-out),
    border-color var(--dur-instant) var(--ease-out),
    color var(--dur-instant) var(--ease-out);
}
.btn svg { width: var(--space-4); height: var(--space-4); flex: none; }
@media (hover: hover) {
  .btn:hover {
    background: var(--btn-bg-hover);
    border-color: var(--btn-line-hover);
    color: var(--btn-ink-hover);
  }
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:is(:disabled, [aria-disabled="true"]) {
  --btn-bg-hover: var(--btn-bg);
  --btn-line-hover: var(--btn-line);
  --btn-ink-hover: var(--btn-ink);
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}
/* Set by confirm.js and fire-panel-ticker.js while a form posts. */
:is(.fire-panel-actions, form[data-submit-once]).is-sending .btn { opacity: .5; cursor: progress; pointer-events: none; }

.btn-sm, .btn-xs { --btn-h: var(--control-sm); --btn-px: var(--space-3); --btn-fs: var(--text-sm); }
.btn-lg { --btn-h: var(--control-lg); --btn-px: var(--space-5); --btn-fs: var(--text-md); }
.btn-icon { width: var(--btn-h, var(--space-10)); padding: 0; flex: none; }

/* Legacy names stay mapped until templates move: gold/main = primary,
   warning = secondary, confirm-accept = danger. */
.btn-primary, .btn-gold, .btn-main {
  --btn-bg: var(--action);
  --btn-bg-hover: var(--action-hover);
  --btn-ink: var(--on-action);
  --btn-line: var(--action-border);
  --btn-line-hover: var(--action-border);
  font-weight: var(--weight-semi);
}
.btn-secondary, .btn-warning {
  --btn-bg: var(--raised);
  --btn-bg-hover: var(--surface-hover);
}
.btn-ghost {
  --btn-bg: transparent;
  --btn-bg-hover: var(--surface-hover);
}
.btn-quiet {
  --btn-bg: transparent;
  --btn-bg-hover: var(--surface-hover);
  --btn-ink: var(--ink-2);
  --btn-ink-hover: var(--ink);
  --btn-line: transparent;
  --btn-line-hover: transparent;
}
.btn-danger, .btn-confirm-accept {
  --btn-bg: var(--danger);
  --btn-bg-hover: color-mix(in srgb, var(--danger) 88%, var(--ink));
  --btn-ink: var(--on-danger);
  --btn-line: transparent;
  --btn-line-hover: transparent;
  font-weight: var(--weight-semi);
}
/* Tone text is mixed 15% toward --ink so it stays AA on --danger-soft in light themes. */
.btn-danger-ghost {
  --btn-bg: transparent;
  --btn-bg-hover: var(--danger-soft);
  --btn-ink: color-mix(in srgb, var(--danger) 85%, var(--ink));
  --btn-line: color-mix(in srgb, var(--danger) 40%, transparent);
  --btn-line-hover: var(--danger);
}
.btn-buy, .btn-sell {
  --btn-line: transparent;
  --btn-line-hover: transparent;
  font-weight: var(--weight-semi);
}
.btn-buy {
  --btn-bg: var(--buy);
  --btn-bg-hover: color-mix(in srgb, var(--buy) 88%, var(--ink));
  --btn-ink: var(--on-buy);
}
.btn-sell {
  --btn-bg: var(--sell);
  --btn-bg-hover: color-mix(in srgb, var(--sell) 88%, var(--ink));
  --btn-ink: var(--on-sell);
}

/* Small buttons keep their size but get a 44px hit area on touch screens. */
@media (pointer: coarse) {
  .btn::after {
    content: "";
    position: absolute;
    inset: min(0px, calc(50% - var(--control-lg) / 2));
  }
}
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:active { transform: none; }
}

/* ---------- card and panel ---------- */
.card {
  position: relative;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-inset);
  transition:
    border-color var(--dur-quick) var(--ease-out),
    background-color var(--dur-quick) var(--ease-out),
    transform var(--dur-quick) var(--ease-out);
}
.card p:last-child { margin-bottom: 0; }
@media (hover: hover) {
  .card--interactive:hover, .card-hover:hover { border-color: var(--border-strong); }
}
/* The lift is public-only: the app has no decorative motion (§10.6). */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  :root:not(.is-app) .card--interactive:hover,
  :root:not(.is-app) .card-hover:hover { transform: translateY(-2px); }
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-inset);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.panel-head h2, .panel-head h3, .panel-head h4 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  letter-spacing: 0;
}
.panel-body { padding: var(--space-4); }

/* ---------- pills and tags ----------
   Pill: a rounded category chip (asset class, side, support). Tag: a squarer
   outlined attribute label (auth method, key type). Tone text is mixed 15%
   toward --ink so it stays AA on its soft tint in every palette. */
.pill {
  --pill-bg: var(--surface-hover);
  --pill-ink: var(--ink-2);
  --pill-line: var(--border);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--space-6);
  padding: 0 calc(var(--space-2) + var(--space-1) / 2);
  border: 1px solid var(--pill-line);
  border-radius: var(--radius-pill);
  background: var(--pill-bg);
  color: var(--pill-ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-none);
  white-space: nowrap;
}
.pill-buy    { --pill-bg: var(--buy-soft);   --pill-ink: color-mix(in srgb, var(--buy) 85%, var(--ink));   --pill-line: transparent; }
.pill-sell   { --pill-bg: var(--sell-soft);  --pill-ink: color-mix(in srgb, var(--sell) 85%, var(--ink));  --pill-line: transparent; }
.pill-gold   { --pill-bg: var(--warn-soft);  --pill-ink: color-mix(in srgb, var(--warn) 85%, var(--ink));  --pill-line: transparent; }
.pill-accent { --pill-bg: var(--brand-soft); --pill-ink: color-mix(in srgb, var(--brand) 85%, var(--ink)); --pill-line: transparent; }
.pill-btn { font-family: inherit; cursor: pointer; }
@media (hover: hover) {
  .pill-btn:hover { --pill-line: var(--input-border); }
}
.pill-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.tag {
  display: inline-flex;
  align-items: center;
  height: var(--space-6);
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-none);
  white-space: nowrap;
}

/* ---------- status badge ----------
   <span class="badge" data-tone="ok|warn|danger|info|neutral|pending|live">.
   The word carries the meaning and stays --ink-2 (AA on every tint); the dot
   and tint carry the tone. success/warning are the old tone names. */
.badge {
  --badge-c: var(--neutral);
  --badge-soft: var(--neutral-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--space-6);
  padding: 0 calc(var(--space-2) + var(--space-1) / 2);
  border-radius: var(--radius-pill);
  background: var(--badge-soft);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-none);
  white-space: nowrap;
}
.badge::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--badge-c);
}
.badge:is([data-tone="ok"], [data-tone="success"], [data-tone="live"]) { --badge-c: var(--ok); --badge-soft: var(--ok-soft); }
.badge:is([data-tone="warn"], [data-tone="warning"]) { --badge-c: var(--warn); --badge-soft: var(--warn-soft); }
.badge[data-tone="danger"] { --badge-c: var(--danger); --badge-soft: var(--danger-soft); }
.badge[data-tone="info"] { --badge-c: var(--info); --badge-soft: var(--info-soft); }
.badge[data-tone="pending"]::before { background: transparent; border: 1.5px solid var(--neutral); }
.badge[data-tone="live"]::before { animation: badge-live 2s var(--ease-out) infinite; }
@keyframes badge-live {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 5px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .badge[data-tone="live"]::before { animation: none; }
}

/* ---------- data table ----------
   <table class="table table--cards"> with data-label on every cell.
   Under 640px each row becomes a card of "label  value" lines. */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.table > caption:not(.sr-only) {
  padding: var(--space-3) var(--space-4);
  caption-side: top;
  text-align: left;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.table > thead > tr > th,
.table > tbody > tr > th,
.table > tbody > tr > td,
.table > tfoot > tr > th,
.table > tfoot > tr > td {
  height: var(--control-lg);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table > thead > tr > th {
  height: var(--control-md);
  padding-block: 0;
  background: var(--surface);
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.table > tbody > tr:last-child > th,
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table th.num, .table td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.table td.num { font-family: var(--font-mono); }
@media (hover: hover) {
  .table > tbody > tr:hover > th,
  .table > tbody > tr:hover > td { background: var(--surface-hover); }
}

/* .table-cards is the old name. .sg-table keeps its own grid card mode
   (app.css) until it moves to this one. */
@media (max-width: 640px) {
  .table--cards, .table-cards:not(.sg-table),
  /* :not(.sr-only) — a hidden caption keeps its 1px box; full width it sat
     past the gutter and widened the whole page on a phone (E2E_TEST_PLAN.md §12). */
  .table--cards > caption:not(.sr-only), .table-cards:not(.sg-table) > caption:not(.sr-only),
  .table--cards > tbody, .table-cards:not(.sg-table) > tbody,
  .table--cards > tbody > tr, .table-cards:not(.sg-table) > tbody > tr { display: block; width: 100%; }
  .table--cards > thead, .table-cards:not(.sg-table) > thead { display: none; }
  .table--cards > tbody > tr, .table-cards:not(.sg-table) > tbody > tr {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
  }
  .table--cards > tbody > tr:last-child, .table-cards:not(.sg-table) > tbody > tr:last-child { border-bottom: 0; }
  .table--cards > tbody > tr > th, .table-cards:not(.sg-table) > tbody > tr > th,
  .table--cards > tbody > tr > td, .table-cards:not(.sg-table) > tbody > tr > td {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-1) var(--space-3);
    width: 100%;
    height: auto;
    padding: var(--space-1) 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .table--cards > tbody > tr > th[data-label]::before, .table-cards:not(.sg-table) > tbody > tr > th[data-label]::before,
  .table--cards > tbody > tr > td[data-label]::before, .table-cards:not(.sg-table) > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    flex: none;
    color: var(--ink-3);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--weight-normal);
    text-align: left;
  }
  .table--cards > tbody > tr:hover > th, .table-cards:not(.sg-table) > tbody > tr:hover > th,
  .table--cards > tbody > tr:hover > td, .table-cards:not(.sg-table) > tbody > tr:hover > td { background: none; }
}

/* ---------- sample label (components/sample_label.html) ---------- */
.sample-label {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  letter-spacing: .02em;
  white-space: nowrap;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}

/* ---------- empty state (components/empty_state.html) ---------- */
.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  grid-column: 1 / -1;
  padding: var(--space-10) var(--space-5);
  text-align: center;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-state[hidden] { display: none; }
.empty-state-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--space-1);
  color: var(--ink-2);
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.empty-state-icon svg { display: block; width: 20px; height: 20px; }
.empty-state-eyebrow {
  margin: 0;
  max-width: none;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-3);
}
.empty-state-heading {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  line-height: var(--leading-heading);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.empty-state-text {
  margin: 0;
  max-width: 52ch;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
}
.empty-state-action { margin-top: var(--space-2); }
.empty-state--inline {
  display: block;
  padding: var(--space-6) var(--space-5);
  background: transparent;
}
.empty-state--inline .empty-state-heading { margin-bottom: var(--space-1); font-size: var(--text-md); }
.empty-state--inline .empty-state-text { max-width: none; }

/* ---------- filter bar (components/filter_bar.html) ---------- */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
}
.filter-bar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.filter-bar-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.filter-bar-panel[hidden] { display: none; }

/* Row: everything on one wrapping line. display: contents drops the panel box. */
.filter-bar--row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-bar--row > .filter-bar-main,
.filter-bar--row > .filter-bar-panel { display: contents; }

@media (min-width: 641px) {
  .filter-bar--drawer-mobile {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }
  .filter-bar--drawer-mobile > .filter-bar-main,
  .filter-bar--drawer-mobile > .filter-bar-panel,
  .filter-bar--drawer-mobile > .filter-bar-panel[hidden] { display: contents; }
  .filter-bar--drawer-mobile .filter-bar-toggle { display: none; }
}

.filter-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 16rem;
  min-width: 0;
  max-width: 28rem;
}
.filter-search > svg {
  position: absolute;
  left: var(--space-3);
  width: 16px;
  height: 16px;
  color: var(--ink-3);
  pointer-events: none;
}
.filter-search-input {
  width: 100%;
  min-height: var(--control-lg);
  padding: 0 var(--space-3) 0 var(--space-9);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
}
.filter-search-input::placeholder { color: var(--ink-3); }
.filter-search-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.filter-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 10rem;
  min-width: 0;
}
.filter-field--narrow { flex: 0 1 8rem; }
.filter-field--wide { flex: 2 1 14rem; }
.filter-field > label,
.filter-field-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-3);
}
/* the controls take the shared input/select look (form controls, above) */

.filter-bar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.filter-bar--drawer-always .filter-bar-actions { margin-left: auto; }

.filter-bar-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-1);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semi);
  font-variant-numeric: tabular-nums;
  color: var(--action-ink);
  background: var(--action-soft);
  border-radius: var(--radius-pill);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.filter-pill:hover { color: var(--ink); background: var(--surface-hover); }
.filter-pill.is-active {
  color: var(--ink);
  background: var(--action-soft);
  border-color: var(--border-brand);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  flex-basis: 100%;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--control-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}
.filter-chip:hover { color: var(--ink); border-color: var(--border-brand); }

/* ---------- pagination (components/pagination.html) ---------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.pager-count,
.pager-status {
  margin: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
.pager-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.pager-link {
  min-width: var(--control-sm);
  padding: 0 var(--space-2);
  font-variant-numeric: tabular-nums;
}
.pager-link[aria-current="page"] {
  color: var(--ink);
  background: var(--action-soft);
  border-color: var(--border-brand);
  cursor: default;
}
.pager-gap { padding: 0 var(--space-1); color: var(--ink-3); }
.pager--simple {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}
.pager--simple .pager-status { grid-column: 2; grid-row: 1; }
.pager-prev { grid-column: 1; grid-row: 1; justify-self: start; }
.pager-next { grid-column: 3; grid-row: 1; justify-self: end; }

/* ---------- touch targets ---------- */
@media (pointer: coarse) {
  .pager-link,
  .filter-pill,
  .filter-chip,
  .filter-bar-toggle,
  .filter-bar-clear { min-height: var(--control-lg); }
  .pager-link { min-width: var(--control-lg); }
}

/* ---------- public type: eyebrow shared by hero and section head ---------- */
.hero-eyebrow,
.sec-head-eyebrow {
  margin: 0 0 var(--space-3);
  max-width: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- section head (components/section_head.html) ----------
   Centred by default (link under the lead); .sec-head--start is the opt-out
   (text left, link to the right). .sec-head--center is the default kept as a
   class so align="center" still renders the same. */
.sec-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  margin: 0 0 var(--space-8);
  text-align: center;
}
.sec-head-text { min-width: 0; max-width: 64ch; margin-inline: auto; }
.sec-head-title {
  margin: 0;
  font-size: var(--text-h2);
  font-weight: var(--weight-semi);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  text-wrap: balance;
}
.sec-head-lead {
  margin: var(--space-3) auto 0;
  max-width: 60ch;
  font-size: var(--text-lead);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
}
.sec-head-link { flex-shrink: 0; }
.sec-head--start {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
  text-align: start;
}
.sec-head--start .sec-head-text,
.sec-head--start .sec-head-lead { margin-inline: 0; }

/* ---------- hero (components/hero.html) ---------- */
.hero {
  position: relative;
  padding-block: var(--space-18) var(--space-14);
}
.hero-inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.hero-copy { min-width: 0; }
.hero--centred .hero-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 46rem;
  margin-inline: auto;
  text-align: center;
}
.hero--split .hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: var(--space-16);
  align-items: center;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-sm);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}
.hero-title {
  margin: 0 0 var(--space-5);
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-semi);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  text-wrap: balance;
}
.hero-accent {
  display: block;
  color: transparent;
  background: linear-gradient(90deg, var(--ink), var(--brand));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-lead {
  margin: 0 0 var(--space-7);
  max-width: 54ch;
  font-size: var(--text-xl);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
}
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.hero--centred .hero-ctas { justify-content: center; }
.hero-note {
  margin: var(--space-5) 0 0;
  max-width: 60ch;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--ink-3);
}
.hero-visual { min-width: 0; }

/* ---------- CTA band (components/cta_band.html) ---------- */
.cta-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding-block: var(--section-y);
  text-align: center;
  border-top: 1px solid var(--border);
}
.cta-band--glow::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(60% 80% at 50% 100%, var(--brand-soft), transparent 70%);
}
.cta-band-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 46rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.cta-band-title {
  margin: 0 0 var(--space-4);
  font-size: var(--text-h2);
  font-weight: var(--weight-semi);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  text-wrap: balance;
}
.cta-band-text {
  margin: 0 0 var(--space-7);
  max-width: 52ch;
  font-size: var(--text-lead);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
}
.cta-band-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}
.cta-band-note {
  margin: var(--space-4) 0 0;
  max-width: 52ch;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--ink-3);
}

/* ---------- disclaimer (components/disclaimer.html) ---------- */
.disclaimer {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
}
.disclaimer p { margin: 0; max-width: 72ch; }
.disclaimer p + p { margin-top: var(--space-2); }
.disclaimer-title {
  margin: 0 0 var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  line-height: var(--leading-snug);
  letter-spacing: 0;
  color: var(--ink);
}
/* footer fine print: hairline above, no box; the points flow in two
   columns on wide screens, one on phones */
.disclaimer--footer {
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.disclaimer--footer .disclaimer-title {
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-2);
}
.disclaimer--footer .disclaimer-list {
  columns: 2;
  column-gap: var(--space-10);
  margin: 0;
  padding: 0;
  list-style: none;
}
.disclaimer--footer .disclaimer-list li {
  margin: 0 0 var(--space-2);
  break-inside: avoid;
}
.disclaimer--inline {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.disclaimer--warn {
  color: var(--ink);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}
.disclaimer-icon {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--warn);
}
.disclaimer-body { min-width: 0; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero--split .hero-inner { grid-template-columns: minmax(0, 1fr); gap: var(--space-10); }
}
@media (max-width: 640px) {
  .hero { padding-block: var(--space-12) var(--space-10); }
  .hero-ctas .btn,
  .cta-band-actions .btn { flex: 1 1 auto; }
  .pager { justify-content: center; }
  .sec-head { margin-bottom: var(--space-6); }
  .disclaimer--footer .disclaimer-list { columns: 1; }
}

/* ---------- motion and forced colours ---------- */
@media (prefers-reduced-motion: no-preference) {
  .filter-pill,
  .filter-chip { transition: color var(--dur-instant) var(--ease-out), background-color var(--dur-instant) var(--ease-out), border-color var(--dur-instant) var(--ease-out); }
}
@media (forced-colors: active) {
  .hero-accent {
    color: CanvasText;
    background: none;
    -webkit-text-fill-color: CanvasText;
  }
  .filter-pill.is-active,
  .pager-link[aria-current="page"] { border-color: Highlight; }
}

/* ---------- Page head ({% pagehead %}, common/templatetags/ui.py) ----------
   Breadcrumb, the page's one h1, optional eyebrow, lede, lead and meta
   slots, then actions. The actions drop under the title once the row is
   too narrow for both. */
.pagehead { margin: 0 0 var(--space-6); min-width: 0; }

.pagehead-crumbs { margin: 0 0 var(--space-2); }
.pagehead-crumbs ol {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-2);
  margin: 0; padding: 0; list-style: none;
  font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--ink-3);
}
.pagehead-crumbs li { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; overflow-wrap: anywhere; }
.pagehead-crumbs li + li::before { content: "/"; content: "/" / ""; color: var(--ink-3); }
.pagehead-crumbs a {
  display: inline-flex; align-items: center; min-height: var(--space-6);
  border-radius: var(--radius-xs);
  color: var(--ink-2); text-decoration: none;
}
.pagehead-crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; }
.pagehead-crumbs a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pagehead-crumbs [aria-current="page"] { color: var(--ink-3); }

.pagehead-body {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4) var(--space-6);
}
.pagehead-id { flex: 1 1 24rem; min-width: 0; display: flex; align-items: center; gap: var(--space-3); }
.pagehead-lead { flex: none; display: flex; align-items: center; }
.pagehead-text { flex: 1 1 auto; min-width: 0; }
.pagehead-heading { margin: 0; }
.pagehead-eyebrow {
  max-width: none; margin: 0 0 var(--space-1);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium);
  line-height: var(--leading-snug); letter-spacing: .02em; color: var(--ink-3);
}
.pagehead-title {
  margin: 0;
  font-family: var(--font-display); font-size: var(--text-3xl); font-weight: var(--weight-semi);
  line-height: var(--leading-heading); letter-spacing: -0.02em; color: var(--ink);
  overflow-wrap: anywhere; text-wrap: balance;
}
:root:not(.is-app) .pagehead-title { font-size: var(--text-4xl); }
.pagehead-lede {
  max-width: var(--measure); margin: var(--space-2) 0 0;
  font-size: var(--text-base); line-height: var(--leading-relaxed); color: var(--ink-2);
}
.pagehead-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3);
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--ink-2);
}
.pagehead-meta p { margin: 0; max-width: none; }
.pagehead-actions { flex: 0 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.pagehead-actions form { display: inline-flex; margin: 0; }

@media (max-width: 640px) {
  .pagehead-title,
  :root:not(.is-app) .pagehead-title { font-size: var(--text-2xl); }
}

/* ---------- Info dialog ({% infodialog %}) ----------
   The dialog box itself is dialog.modal (components.css); modal.js opens
   and closes it. The trigger is 28px to the eye with a 44px hit area. */
.infodialog-trigger {
  position: relative; flex: none;
  display: inline-grid; place-items: center;
  width: var(--space-7); height: var(--space-7); padding: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: transparent; color: var(--ink-2);
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-semi);
  line-height: var(--leading-none);
  cursor: pointer;
  transition: color var(--dur-instant) var(--ease-out), background-color var(--dur-instant) var(--ease-out),
    border-color var(--dur-instant) var(--ease-out);
}
.infodialog-trigger::after { content: ""; position: absolute; inset: calc((var(--space-7) - var(--control-lg)) / 2); }
.infodialog-trigger:hover { background: var(--surface-hover); border-color: var(--input-border); color: var(--ink); }
.infodialog-trigger:focus-visible,
.infodialog-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Wide, with a gap on the left and right (15% of the screen each, 2rem on phones). */
dialog.infodialog { width: 100%; max-width: 70vw; }
@media (max-width: 640px) {
  dialog.infodialog { max-width: calc(100vw - 2 * var(--space-8)); }
}
.infodialog-inner {
  max-height: calc(100dvh - 2 * var(--space-6)); overflow-y: auto;
  padding: var(--space-4) var(--space-6) var(--space-6);
}
.infodialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin: 0 calc(var(--space-3) * -1) var(--space-3) 0;
}
.infodialog-title {
  margin: 0;
  font-family: var(--font-body); font-size: var(--text-lg); font-weight: var(--weight-semi);
  line-height: var(--leading-heading); letter-spacing: -0.01em; color: var(--ink);
}
.infodialog-close {
  flex: none; display: inline-grid; place-items: center;
  width: var(--control-lg); height: var(--control-lg); padding: 0;
  border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--ink-3);
  font-size: var(--text-2xl); line-height: var(--leading-none);
  cursor: pointer;
}
.infodialog-close:hover { background: var(--surface-hover); color: var(--ink); }
.infodialog-body { font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--ink-2); }
.infodialog-body > :first-child { margin-top: 0; }
.infodialog-body > :last-child { margin-bottom: 0; }
.infodialog-body p { max-width: none; margin: 0 0 var(--space-3); }
.infodialog-body dl { display: grid; gap: var(--space-1); margin: 0; }
.infodialog-body dt { margin: var(--space-3) 0 0; font-weight: var(--weight-semi); color: var(--ink); }
.infodialog-body dt:first-child { margin-top: 0; }
.infodialog-body dd { margin: 0; }
.infodialog-body ul { margin: var(--space-1) 0 0; padding: 0 0 0 var(--space-5); }
.infodialog-body li + li { margin-top: var(--space-1); }

@media (prefers-reduced-motion: reduce) {
  .infodialog-trigger { transition: none; }
}

/* ---------- Product status ({% product_status %}) ----------
   Public availability: Live, Beta, Waitlist, Roadmap, Launching. Text in
   the tone colour on the page background (every tone is AA there); the
   hairline and dot are decoration. */
.product-status {
  --product-status-c: var(--neutral);
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  border: 1px solid color-mix(in srgb, var(--product-status-c) 45%, transparent);
  border-radius: var(--radius-pill);
  background: transparent; color: var(--product-status-c);
  font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: var(--weight-medium);
  line-height: var(--leading-snug); letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.product-status::before {
  content: ""; flex: none;
  width: 6px; height: 6px; border-radius: var(--radius-pill);
  background: currentColor;
}
.product-status[data-status="live"] { --product-status-c: var(--ok); }
.product-status[data-status="beta"] { --product-status-c: var(--info); }
.product-status[data-status="waitlist"] { --product-status-c: var(--action-ink); border-color: var(--border-brand); }
.product-status[data-status="roadmap"] { --product-status-c: var(--neutral); }
.product-status[data-status="launching"] { --product-status-c: var(--warn); }

@media (forced-colors: active) {
  .product-status::before { forced-color-adjust: none; background: CanvasText; }
}
}
