/* m1.css — PR-1 of M1 UI rewrite (foundation only)
 *
 * Mobile-first stylesheet for honest-router's M1 surfaces. Defines class-name
 * primitives that the React components in `_primitives.jsx` consume; PR-2
 * migrates each surface to render through them.
 *
 * Token sources:
 *   - colors_and_type.css  → --font-sans, --font-mono, --hr-trust,
 *                             --hr-warn, --hr-error-*, --muted, --border,
 *                             --foreground, --background, --muted-foreground.
 *   - this file (top of :root block) → --m1-space-1..8, --m1-bp-md.
 *
 * Class-name contract (asserted by tests/test_m1_responsive_class_contract.py):
 *   .m1-app .m1-banner .m1-nav
 *   .m1-section .m1-container
 *   .kpi-grid .kpi-card .data-table .data-table-stacked
 *   .signed-block .kv-list .kv-row .fallback-chain .anchor-block
 *   .pill .pill-success .pill-warn .pill-danger
 *   .honest-envelope .code-mono .button .button-primary .button-ghost
 */

/* Round-2 audit A-5: a universal `box-sizing: border-box` reset closes
   the 768px horizontal overflow caused by `.m1-container { width: 100%
   }` plus its own padding. Scoped to m1.css's load surface (M1 SPA
   pages only); no other surface depends on `content-box`. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --m1-space-1: 4px;
  --m1-space-2: 8px;
  --m1-space-3: 12px;
  --m1-space-4: 16px;
  --m1-space-5: 20px;
  --m1-space-6: 24px;
  --m1-space-7: 32px;
  --m1-space-8: 48px;
  --m1-bp-md: 768px;
}

/* ---- shell / layout ---- */

.m1-app {
  font-family: var(--font-sans);
  color: var(--foreground);
  background: var(--background);
  min-height: 100vh;
}

.m1-banner {
  /* DA-12: dark forest green so white text + bold badge pass WCAG AA.
     The previous `oklch(0.36 0.10 155)` background tested at 3.42:1 vs
     #fff (axe-core flagged this) — `--hr-trust-strong` (oklch(0.30 0.12 155)
     ≈ #2c7a45) measures at ≥ 4.5:1 with white body text. */
  background: var(--hr-trust-strong);
  color: #fff;
  /* Top edge honours the iOS notch / Android cutout. `viewport-fit=cover`
     in index.html lets the banner extend into the safe-area inset zone;
     `max(env(...), --m1-space-2)` ensures we never underpad on browsers
     that report 0 for the inset (M2 production-bar). Vertical padding
     is tight (8px) so the announcement does not eat the hero on mobile —
     see docs/m1-mobile-fidelity-audit-2026-05-04.md (H1). */
  padding-top: max(env(safe-area-inset-top), var(--m1-space-2));
  padding-right: max(env(safe-area-inset-right), var(--m1-space-4));
  padding-bottom: var(--m1-space-2);
  padding-left: max(env(safe-area-inset-left), var(--m1-space-4));
  font-size: clamp(12px, 2.6vw, 13px);
  line-height: 1.4;
  display: flex;
  flex-wrap: wrap;
  gap: var(--m1-space-2);
  align-items: center;
}

.m1-banner strong {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
}

.m1-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--m1-space-3);
  padding-right: max(env(safe-area-inset-right), var(--m1-space-4));
  padding-bottom: var(--m1-space-3);
  padding-left: max(env(safe-area-inset-left), var(--m1-space-4));
  gap: var(--m1-space-3);
}

.m1-section {
  padding: var(--m1-space-5) var(--m1-space-4);
}

.m1-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: max(env(safe-area-inset-left), var(--m1-space-4));
  padding-right: max(env(safe-area-inset-right), var(--m1-space-4));
}

/* ---- KPI grid (mobile = single column, desktop = up to 4) ---- */

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--m1-space-3);
}

.kpi-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--m1-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-2);
  font-family: var(--font-sans);
}

.kpi-card .kpi-card__title {
  font-size: 12px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-card .kpi-card__value {
  font-family: var(--font-mono);
  font-size: clamp(20px, 5vw, 28px);
  font-variant-numeric: tabular-nums;
  color: var(--foreground);
}

.kpi-card .kpi-card__footnote {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ---- DataTable: card-stacked on mobile, real table on desktop ---- */

.data-table {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 13px;
  border-collapse: collapse;
}

.data-table thead {
  /* Hidden on mobile; shown on >=768px via media query */
  display: none;
}

.data-table-stacked tbody,
.data-table tbody {
  display: block;
}

.data-table tr {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: var(--m1-space-3);
  padding: var(--m1-space-3);
  background: var(--background);
}

.data-table td {
  display: flex;
  justify-content: space-between;
  gap: var(--m1-space-3);
  padding: var(--m1-space-1) 0;
  border: none;
  word-break: break-word;
}

.data-table td::before {
  content: attr(data-label);
  font-size: 11px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* ---- receipt blocks ---- */

.signed-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--m1-space-4);
  background: var(--background);
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
  font-family: var(--font-sans);
}

.kv-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--m1-space-1);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: var(--m1-space-3);
  padding: var(--m1-space-1) 0;
  border-bottom: 1px dashed var(--border);
  word-break: break-all;
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-row .kv-row__key {
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.kv-row .kv-row__value {
  color: var(--foreground);
  text-align: right;
  font-family: var(--font-mono);
}

.fallback-chain {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-2);
}

.fallback-chain .fallback-rung {
  display: flex;
  align-items: center;
  gap: var(--m1-space-2);
  padding: var(--m1-space-2) var(--m1-space-3);
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--background);
  font-family: var(--font-mono);
  font-size: 12px;
}

.fallback-chain .fallback-rung--ok {
  border-color: var(--hr-trust);
  background: var(--hr-trust-soft);
  /* DA-12: text on `--hr-trust-soft` requires ≥ 4.5:1 — use the AA-passing
     `--hr-trust-strong` token rather than the inline 0.36-lightness colour
     that axe flagged across the surface. */
  color: var(--hr-trust-strong);
}

.fallback-chain .fallback-rung--fail {
  border-color: var(--hr-error-upstream);
  background: var(--hr-error-upstream-soft);
  color: oklch(0.36 0.12 260);
}

.anchor-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--m1-space-4);
  background: var(--background);
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
}

.anchor-block .anchor-block__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--m1-space-2);
}

/* ---- pills ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--m1-space-1);
  padding: 2px var(--m1-space-2);
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  background: var(--muted);
  /* Darker than --muted-foreground so 11px text passes 4.5:1 against --muted. */
  color: oklch(0.30 0 0);
  font-family: var(--font-sans);
  border: 1px solid transparent;
}

/* DA-12 fix: pills must hit WCAG AA at 11px (4.5:1). The previous text
   colour `oklch(0.36 0.10 155)` (≈ #429c5a) tested at 3.27:1 against
   `--hr-trust-soft` and 3.42:1 against `#ffffff` — failing. The
   `--hr-trust-strong` token in colors_and_type.css resolves to
   `oklch(0.30 0.12 155)` (≈ #2c7a45), which axe-core measures at ≥ 4.5:1
   against both backgrounds. Use it consistently for trust-flavoured
   text-on-light contexts. */
.pill-success {
  background: var(--hr-trust-soft);
  color: var(--hr-trust-strong);
}

.pill-warn {
  background: var(--hr-warn-soft);
  color: oklch(0.40 0.10 75);
}

.pill-danger {
  background: var(--hr-error-gateway-soft);
  color: oklch(0.42 0.18 25);
}

/* ---- HonestEnvelope (error voice) ---- */

.honest-envelope {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  padding: var(--m1-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
  max-width: 720px;
  margin: var(--m1-space-6) auto;
  font-family: var(--font-sans);
}

.honest-envelope .honest-envelope__title {
  font-family: var(--font-mono);
  font-size: clamp(14px, 3vw, 16px);
  font-weight: 600;
  color: var(--hr-error-gateway);
  letter-spacing: 0.02em;
}

.honest-envelope .honest-envelope__body {
  font-size: clamp(14px, 3vw, 16px);
  line-height: 1.5;
  color: var(--foreground);
}

.honest-envelope .honest-envelope__hint {
  font-size: 13px;
  color: var(--muted-foreground);
  border-top: 1px dashed var(--border);
  padding-top: var(--m1-space-3);
}

/* ---- code & buttons ---- */

.code-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--m1-space-3);
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--foreground);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--m1-space-2);
  height: 44px;
  padding: 0 var(--m1-space-4);
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--muted);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  /* M3: kill iOS double-tap zoom delay on the primary action surface. */
  touch-action: manipulation;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-primary {
  background: var(--foreground);
  color: var(--background);
}

.button-ghost {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

/* `.button-trust` — emerald CTA used to flag the action that proves the
   page's claim (e.g. the verifier-mini "Verify" button on TrustDashboard).
   Uses --hr-trust-strong so 14px white-on-emerald hits WCAG AA. */
.button-trust {
  background: var(--hr-trust-strong);
  color: #fff;
  border-color: transparent;
}

/* ---- mobile interaction discipline ---- */

/* M3 (production-bar): every interactive element opts out of iOS
   double-tap zoom. The `.button` rule already declares this above; the
   selectors below cover the burger trigger, tab-stop rows in DataTable,
   pill chips that act as filter / link surfaces, and any element wired
   as a button via ARIA. */
.pill,
[role="button"],
[tabindex="0"] {
  touch-action: manipulation;
}

/* ---- screen-reader-only utility (RouteAnnouncer offscreen region) ---- */

/* WebAIM-canonical screen-reader-only pattern. The RouteAnnouncer
   primitive renders its `aria-live="polite"` text into a node carrying
   this class; the node is announced by AT but invisible visually and
   does not reserve layout space. */
.m1-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- PR-3a — mobile drawer primitive ---- */

/* The mobile-only side drawer ("hamburger menu"). Off-screen by default;
   `.m1-drawer.open` slides the panel in from the right. The DOM is
   rendered on every viewport so the slide animation has a stable target
   to interpolate against; the trigger button (`.m1-burger`) is hidden on
   desktop ≥768px (see desktop-overrides block) so users on wide
   viewports never see (or open) the drawer.

   Accessibility:
     - Panel carries `role="dialog"` + `aria-modal="true"` (set by JSX).
     - When closed, `aria-hidden="true"` keeps it out of the AT tree.
     - Backdrop click + ESC + tap-on-link all close.
     - Focus is trapped inside the panel while open and restored to the
       previously-focused element on close (logic in `_primitives.jsx`).
*/
.m1-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.m1-drawer.open {
  pointer-events: auto;
}

.m1-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: oklch(0 0 0 / 0.4);
  opacity: 0;
  pointer-events: none;
}

.m1-drawer.open .m1-drawer__backdrop {
  opacity: 1;
  pointer-events: auto;
}

.m1-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 88vw);
  background: var(--background);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px oklch(0 0 0 / 0.18);
  display: flex;
  flex-direction: column;
  /* Off-screen by default; reduced-motion users get instant snap (no
     transition declared at the top level). The transition lives under
     `@media (prefers-reduced-motion: no-preference)` below. */
  transform: translateX(100%);
  /* Honour iOS safe-area inset on the right edge so the close button
     does not slide under a notch / cutout. */
  padding-right: env(safe-area-inset-right);
  padding-top: env(safe-area-inset-top);
}

.m1-drawer.open .m1-drawer__panel {
  transform: translateX(0);
}

.m1-drawer__close {
  position: absolute;
  top: var(--m1-space-3);
  right: var(--m1-space-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--foreground);
  touch-action: manipulation;
}

.m1-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: var(--foreground);
  touch-action: manipulation;
}

/* Desktop inline nav list. Hidden on mobile (the drawer holds the nav
   on narrow viewports); the desktop-overrides block flips it back to
   inline-flex at ≥768px. */
.m1-nav-links {
  display: none;
  gap: var(--m1-space-2);
  align-items: center;
}

/* ---- motion (gated under prefers-reduced-motion: no-preference) ---- */

/* A8 (production-bar): every transition / animation lives behind the
   reduced-motion gate so users who request reduced motion get
   `transition-duration: 0s` by default. Today the only animated
   property is the `.button` background+opacity hover; future surfaces
   add their declarations inside this block, NOT at the top level. */
@media (prefers-reduced-motion: no-preference) {
  .button {
    transition: background 120ms ease, opacity 80ms;
  }

  .m1-drawer__panel {
    transition: transform 200ms ease-out;
  }

  .m1-drawer__backdrop {
    transition: opacity 180ms ease-out;
  }
}

/* ---- contrast (AAA branch under prefers-contrast: more) ---- */

/* A9 (production-bar): users who request strong contrast get heavier
   borders and AAA-grade text. We bump structural borders by 1px and
   strengthen muted text to `--foreground`; focus rings double in
   thickness so keyboard navigation is unmistakable. */
@media (prefers-contrast: more) {
  .kpi-card,
  .signed-block,
  .anchor-block,
  .pill,
  .honest-envelope,
  .button,
  .button-ghost {
    border-width: 2px;
  }

  .kpi-card .kpi-card__title,
  .kpi-card .kpi-card__footnote,
  .honest-envelope .honest-envelope__hint,
  .data-table td::before {
    /* AAA contrast against --background: collapse muted-foreground
       (≈4.5:1) onto --foreground (≈18:1). */
    color: var(--foreground);
  }

  :focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 2px;
  }
}

/* ---- desktop overrides ---- */

@media (min-width: 768px) {
  /* PR-3a: desktop hides the mobile drawer trigger and reveals the
     inline nav list. The drawer DOM stays mounted (panel held off-screen
     via `transform: translateX(100%)`) but is unreachable without the
     burger. */
  .m1-burger {
    display: none;
  }

  .m1-nav-links {
    display: inline-flex;
  }

  .m1-section {
    padding: var(--m1-space-7) var(--m1-space-6);
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--m1-space-4);
  }

  .data-table {
    display: table;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }

  .data-table thead {
    display: table-header-group;
    background: var(--muted);
  }

  .data-table tbody {
    display: table-row-group;
  }

  .data-table tr {
    display: table-row;
    border: none;
    border-bottom: 1px solid var(--border);
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: var(--background);
  }

  .data-table tr:last-child {
    border-bottom: none;
  }

  .data-table th,
  .data-table td {
    display: table-cell;
    padding: var(--m1-space-3) var(--m1-space-4);
    text-align: left;
    border: none;
  }

  .data-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-foreground);
    font-weight: 500;
  }

  .data-table td::before {
    content: none;
  }

  .data-table-stacked tbody,
  .data-table-stacked tr,
  .data-table-stacked td {
    /* Opt-in to keep stacked layout on desktop. */
    display: block;
  }

  .data-table-stacked td::before {
    content: attr(data-label);
  }

  .kv-list {
    grid-template-columns: minmax(140px, auto) 1fr;
  }

  .kv-row {
    display: contents;
  }

  .kv-row .kv-row__key,
  .kv-row .kv-row__value {
    padding: var(--m1-space-1) 0;
    border-bottom: 1px dashed var(--border);
  }

  .kv-row .kv-row__value {
    text-align: left;
    word-break: break-all;
  }

  .fallback-chain {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
}

/* ─────────────────────────────────────────────────────────────────────
 * PR-2B — class extensions for migrated surfaces.
 *
 * Each class below is consumed by exactly one or two surfaces
 * (PersonalDashboard, ModelCatalogue, KeysPage, ErrorsExplainer). All
 * additive — no rewrites of the PR-1 foundation classes above.
 * ───────────────────────────────────────────────────────────────────── */

.m1-page-header {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
  margin-bottom: var(--m1-space-5);
}

.m1-page-title {
  margin: 0;
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.m1-page-subtitle {
  margin: var(--m1-space-2) 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted-foreground);
  max-width: 720px;
}

.m1-section-header {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-1);
  margin: var(--m1-space-5) 0 var(--m1-space-3);
}

.m1-section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.m1-section-hint {
  font-size: 12px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

/* KPI status — runway warning lights up the bottom rule of the card. */
.kpi-card[data-status="warn"] {
  border-left: 3px solid var(--hr-warn);
}

.kpi-card[data-status="warn"] .kpi-card__footnote {
  color: oklch(0.40 0.10 75);
}

/* M2.3.1: incidents feed (per-account). Compact list above the recent-
   traces table. Each row = kind pill + relative time + optional trace_id.
   Auto-hides when the feed is empty so healthy accounts see no stub. */
.m1-incidents {
  list-style: none;
  margin: 0 0 var(--m1-space-6) 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-2);
}

.m1-incident-row {
  display: flex;
  align-items: center;
  gap: var(--m1-space-3);
  padding: var(--m1-space-2) var(--m1-space-3);
  border: 1px solid oklch(0.92 0.01 240);
  border-radius: var(--m1-radius-sm);
  background: oklch(0.99 0.005 240);
  font-size: 0.875rem;
}

/* DataTable — small affordances added by PR-2B. */
.m1-cell-mono {
  display: inline-flex;
  align-items: center;
  gap: var(--m1-space-2);
  font-family: var(--font-mono);
}

.m1-cell-anchor-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hr-trust);
  flex-shrink: 0;
}

.m1-cell-button {
  height: 32px;
  padding: 0 var(--m1-space-3);
  font-size: 12px;
}

/* Toolbar — segmented + search row above the model catalogue table. */
.m1-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
  margin-bottom: var(--m1-space-4);
}

.m1-segmented {
  display: inline-flex;
  align-self: flex-start;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}

.m1-segmented__option {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  /* Inactive tabs need ≥4.5:1 against `var(--muted)` for WCAG AA. The
     project --muted-foreground is too light against --muted (≈3:1) — use
     a darker neutral that we know hits AA. Active tabs use --foreground
     against --background, which is already ~18:1. */
  color: oklch(0.30 0 0);
  cursor: pointer;
  font-weight: 500;
}

.m1-segmented__option.is-active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.05);
}

/* LangToggle — single-button compact switcher wired to window.I18N.
   Sits in the NavBar's right slot (signed-in) or the public-nav
   actions row. Width is bounded so it doesn't push the burger / nav
   chrome past the 768-wide breakpoint. */
.m1-lang-toggle {
  appearance: none;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: oklch(0.30 0 0);
  cursor: pointer;
  white-space: nowrap;
}
.m1-lang-toggle:hover {
  background: var(--background);
}
.m1-nav-right {
  display: inline-flex;
  align-items: center;
  gap: var(--m1-space-2);
}

.m1-search {
  display: flex;
  align-items: center;
  gap: var(--m1-space-2);
}

.m1-search__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

.m1-search input {
  flex: 1;
  min-height: 40px;
  padding: 0 var(--m1-space-3);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
}

/* Notes — dashed-bordered paragraph below tables. */
.m1-note {
  display: flex;
  gap: var(--m1-space-3);
  align-items: flex-start;
  margin-top: var(--m1-space-4);
  padding: var(--m1-space-3) var(--m1-space-4);
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--muted);
  color: var(--foreground);
  font-size: 13px;
  line-height: 1.55;
}

.m1-note__badge {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  background: var(--background);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  color: var(--foreground);
}

/* Card grid — sandbox-key + rotation-policy on KeysPage. */
.m1-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--m1-space-4);
  margin-top: var(--m1-space-5);
}

.m1-card-header {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-1);
}

.m1-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.m1-card-subtitle {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted-foreground);
}

.m1-card-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--foreground);
}

.m1-card-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-1);
}

.m1-card-hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.55;
}

.m1-card-hint__label {
  font-weight: 500;
  color: var(--foreground);
}

.m1-card-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.55;
  border-top: 1px dashed var(--border);
  padding-top: var(--m1-space-2);
}

.m1-inline-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--muted);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--foreground);
}

/* Errors explainer — list of cards. */
.m1-error-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
}

.m1-error-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--m1-space-3);
}

.m1-error-id {
  display: inline-flex;
  align-items: baseline;
  gap: var(--m1-space-3);
}

.m1-error-code {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--foreground);
}

.m1-error-slug {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted-foreground);
}

/* Signed-in chrome — brand + balance chip used by App.jsx's NavBar. */
.m1-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--m1-space-2);
  padding: 0 var(--m1-space-2);
  height: 40px;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  cursor: pointer;
  color: var(--foreground);
  /* Brand never shrinks below its content width. Without this, when the
     right-hand nav group competes for room (signed-out: Sign-in + Get-API-key;
     signed-in: balance chip + hamburger), flex would shrink the brand and
     wrap "honest-router" to two lines on a 375 viewport. */
  flex-shrink: 0;
}

.m1-brand__name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
  white-space: nowrap;
}

.m1-balance {
  display: inline-flex;
  align-items: baseline;
  gap: var(--m1-space-2);
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.m1-balance__amount {
  color: var(--foreground);
}

.m1-balance__runway {
  color: var(--muted-foreground);
  font-size: 12px;
}

.m1-balance__runway.is-warn {
  color: oklch(0.40 0.10 75);
}

@media (min-width: 768px) {
  .m1-page-header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--m1-space-4);
  }

  .m1-section-header {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
  }

  .m1-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .m1-search {
    max-width: 320px;
    flex: 0 1 320px;
  }

  .m1-card-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─────────────────────────────────────────────────────────────────────
 * PR-2C — class extensions for TopUp, Register, TrustDashboard.
 *
 * Additive only. PR-1 + PR-2B foundation classes above are unchanged.
 * ───────────────────────────────────────────────────────────────────── */

/* Back-link used by TopUp's "← back to dashboard" affordance. */
.m1-back-link {
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-foreground);
  cursor: pointer;
  margin-bottom: var(--m1-space-4);
  /* M3: kill the iOS double-tap zoom delay on this CTA-adjacent affordance. */
  touch-action: manipulation;
}

.m1-back-link:hover {
  color: var(--foreground);
}

/* Narrow column layout used by Register + TopUp single-column flows. */
.m1-narrow {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
}

/* TopUp amount preset grid. Buttons are large touch targets. */
.m1-amount-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--m1-space-2);
  margin-bottom: var(--m1-space-3);
}

.m1-amount-button {
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  /* M3: kill iOS double-tap zoom on touch surfaces. */
  touch-action: manipulation;
}

.m1-amount-button.is-active {
  background: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
}

/* Numeric / text input used by Register + TopUp. Mobile-safe min height. */
.m1-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 var(--m1-space-3);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
}

.m1-input:focus-visible {
  border-color: var(--foreground);
}

/* Register form rows — vertical stack of label + input. */
.m1-form-row {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-1);
  margin-bottom: var(--m1-space-3);
}

.m1-form-row__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

/* Checkbox + label row used in Register. */
.m1-form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--m1-space-2);
  margin: var(--m1-space-3) 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: oklch(0.30 0 0);
}

.m1-form-checkbox input {
  margin-top: 3px;
  flex-shrink: 0;
}

.m1-form-checkbox a {
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

/* Trust dashboard hero — large headline + verifier panel side-by-side. */
.m1-hero {
  padding: var(--m1-space-7) var(--m1-space-4);
  border-bottom: 1px solid var(--border);
}

.m1-hero__inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--m1-space-6);
  align-items: center;
}

.m1-hero__title {
  margin: 0;
  /* Mobile-first: design intent (m-screens-a `MTrust`) is 26px on a 390px
     viewport; previous clamp floored at 32px which made the hero feel
     top-heavy on phones. Floor at 26px so 375 wide reads at design size,
     while ≥640 wide phones / desktop still scale toward 52px. */
  font-size: clamp(26px, 6vw, 52px);
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.m1-hero__title-accent {
  /* Hero title is large (≥ 24px), so 3:1 suffices, but DA-12 standardises
     all trust-flavoured text on `--hr-trust-strong` to keep contrast
     consistent with the body-copy contexts. */
  color: var(--hr-trust-strong);
}

.m1-hero__lede {
  margin: var(--m1-space-4) 0 var(--m1-space-5);
  max-width: 500px;
  font-size: clamp(15px, 3.5vw, 17px);
  line-height: 1.55;
  color: oklch(0.40 0 0);
}

.m1-hero__cta-row {
  display: flex;
  gap: var(--m1-space-3);
  flex-wrap: wrap;
}

.m1-hero__footnote {
  margin-top: var(--m1-space-3);
  font-size: 12.5px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

/* Trust grid — 1 column on mobile, 2 on desktop. */
.m1-trust-grid {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--m1-space-4);
}

.m1-trust-card-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--m1-space-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
  margin-bottom: var(--m1-space-3);
}

.m1-trust-card-eyebrow--live {
  /* DA-12: 11.5px text — must hit 4.5:1; `--hr-trust-strong` is the
     AA-passing trust shade. */
  color: var(--hr-trust-strong);
}

.m1-trust-card-eyebrow__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hr-trust);
}

.m1-trust-card-title {
  margin: 0 0 var(--m1-space-2);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.45;
}

.m1-trust-card-meta {
  font-size: 13px;
  color: oklch(0.40 0 0);
  line-height: 1.55;
}

.m1-trust-card-foot {
  margin-top: auto;
  padding-top: var(--m1-space-3);
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

.m1-trust-card-foot--ok {
  /* DA-12: 12px text — must hit 4.5:1; use `--hr-trust-strong`. */
  color: var(--hr-trust-strong);
}

.m1-trust-card-link {
  color: var(--foreground);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

/* Sandbox CTA banner — visually distinct from production keys per A14. */
.m1-sandbox {
  padding: var(--m1-space-7) var(--m1-space-4);
  border-bottom: 1px solid var(--border);
  /* Distinct surface tint: slight cream/yellow wash to mark sandbox is not
     production. WCAG-AA against text — body remains var(--foreground). */
  background: var(--hr-warn-soft);
}

.m1-sandbox__inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--m1-space-5);
  align-items: center;
}

.m1-sandbox__title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.m1-sandbox__lede {
  margin: var(--m1-space-2) 0 0;
  font-size: 14px;
  /* WCAG AA: --muted-foreground (oklch 0.556) on --hr-warn-soft (oklch ~0.96)
     measures 3.6:1, below the 4.5:1 floor for normal text. Use the darker
     foreground token for guaranteed contrast on the cream sandbox tint. */
  color: var(--foreground);
  line-height: 1.55;
  max-width: 420px;
}

/* Provider uptime block. */
.m1-uptime {
  padding: var(--m1-space-6) var(--m1-space-4);
  border-bottom: 1px solid var(--border);
  background: oklch(0.985 0 0);
}

.m1-uptime__inner {
  max-width: 1080px;
  margin: 0 auto;
}

.m1-uptime__head {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
  margin-bottom: var(--m1-space-4);
}

.m1-uptime__legend {
  display: flex;
  gap: var(--m1-space-3);
  align-items: center;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  flex-wrap: wrap;
}

.m1-uptime__legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  margin-right: var(--m1-space-1);
  vertical-align: middle;
}

.m1-uptime__legend-dot--ok       { background: var(--hr-trust); }
.m1-uptime__legend-dot--degraded { background: var(--hr-warn); }
.m1-uptime__legend-dot--down     { background: var(--hr-error-upstream); }

.m1-uptime__body {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--background);
}

.m1-uptime__row {
  padding: var(--m1-space-3) var(--m1-space-4);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--m1-space-2);
  align-items: center;
}

.m1-uptime__row:last-child {
  border-bottom: none;
}

.m1-uptime__row-head {
  display: flex;
  align-items: center;
  gap: var(--m1-space-2);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}

.m1-uptime__row-sla {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* DA-12: 12px text — `--hr-trust` (lightness 0.62) does not hit 4.5:1. */
.m1-uptime__row-sla--ok       { color: var(--hr-trust-strong); }
/* WCAG AA: --hr-warn (oklch 0.74) on --background (oklch 1.0) measures
   2.7:1, below the 4.5:1 floor. Darken to --hr-warn-strong for AA. */
.m1-uptime__row-sla--warn     { color: var(--hr-warn-strong); }
.m1-uptime__row-sla--down     { color: var(--hr-error-upstream); }

/* The grid of 144 buckets. */
.m1-uptime-grid {
  display: grid;
  gap: 1.5px;
  align-items: stretch;
}

.m1-uptime-bucket {
  height: 14px;
  border-radius: 1.5px;
}

.m1-uptime-bucket--ok       { background: var(--hr-trust); }
.m1-uptime-bucket--degraded { background: var(--hr-warn); }
.m1-uptime-bucket--down     { background: var(--hr-error-upstream); }

/* Verifier mini panel on the trust hero. */
.m1-verifier-mini {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--background);
  box-shadow: 0 1px 0 oklch(0 0 0 / 0.02), 0 24px 60px -32px oklch(0 0 0 / 0.18);
}

.m1-verifier-mini__head {
  padding: var(--m1-space-2) var(--m1-space-3);
  border-bottom: 1px solid var(--border);
  background: oklch(0.985 0 0);
  display: flex;
  align-items: center;
  gap: var(--m1-space-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-foreground);
}

.m1-verifier-mini__body {
  padding: var(--m1-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
}

.m1-verifier-mini__row {
  display: flex;
  gap: var(--m1-space-2);
}

.m1-verifier-mini__row .m1-input {
  flex: 1;
}

/* Footnote at the bottom of TrustDashboard. */
.m1-footnote {
  padding: var(--m1-space-5) var(--m1-space-4);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.55;
}

.m1-footnote__inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
  justify-content: space-between;
}

.m1-footnote__links {
  display: inline-flex;
  gap: var(--m1-space-4);
}

.m1-footnote__links a {
  color: inherit;
  text-decoration: none;
}

.m1-footnote a {
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

/* Anchor chip used by TrustDashboard transparency-log links. */
.m1-anchor-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--m1-space-1);
  padding: var(--m1-space-1) var(--m1-space-2);
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--foreground);
  text-decoration: none;
}

@media (min-width: 768px) {
  .m1-hero {
    padding: 80px var(--m1-space-6) 72px;
  }

  .m1-hero__inner {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 56px;
  }

  .m1-trust-grid {
    grid-template-columns: 1fr 1fr;
  }

  .m1-sandbox {
    padding: var(--m1-space-8) var(--m1-space-6);
  }

  .m1-sandbox__inner {
    grid-template-columns: 1fr 1fr;
    gap: var(--m1-space-7);
  }

  .m1-uptime {
    padding: var(--m1-space-7) var(--m1-space-6);
  }

  .m1-uptime__head {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--m1-space-4);
  }

  .m1-uptime__row {
    grid-template-columns: 200px 1fr;
    gap: var(--m1-space-5);
  }

  .m1-footnote__inner {
    flex-direction: row;
    align-items: center;
  }
}

/* ─────────────────────────────────────────────────────────────────────
 * H5–H7 mobile fidelity (audit 2026-05-04 phase 3).
 *
 *   .m1-balance-hero      — PersonalDashboard's hoisted balance hero
 *   .m1-surface-header    — slim sticky bar replacing the dark Banner
 *                            on /v/ and /t/ surfaces
 *   .data-table.is-compact — single-line row layout for recent traces
 *
 * Additive only. Foundation classes (.m1-banner, .kpi-card, .data-table,
 * .m1-page-header) are unchanged.
 * ───────────────────────────────────────────────────────────────────── */

/* H5 — balance hero. Mobile-first: large mono number + secondary
   runway line + footnote + action slot. Desktop shrinks the number so
   the hero card matches the kpi-card scale (the dashboard remains
   balance-led but the visual delta narrows on wide screens). */
.m1-balance-hero {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-2);
  padding: var(--m1-space-4);
  margin-bottom: var(--m1-space-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background);
}

.m1-balance-hero[data-status="warn"] {
  border-left: 3px solid var(--hr-warn);
}

.m1-balance-hero__label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}

.m1-balance-hero__row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--m1-space-2);
}

.m1-balance-hero__amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.m1-balance-hero__runway {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted-foreground);
}

.m1-balance-hero[data-status="warn"] .m1-balance-hero__runway {
  /* Same warm-amber tone the kpi-card warn footnote uses. */
  color: oklch(0.40 0.10 75);
}

.m1-balance-hero__footnote {
  font-size: 12px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

.m1-balance-hero__action {
  margin-top: var(--m1-space-2);
  display: flex;
  gap: var(--m1-space-2);
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .m1-balance-hero {
    /* On desktop the hero stays present but shrinks toward kpi-card scale
       so the balance lead does not dominate the layout. */
    padding: var(--m1-space-3) var(--m1-space-4);
  }
  .m1-balance-hero__amount {
    font-size: 26px;
  }
}

/* H6 — DataTable compact mode. Only mobile (<768px) collapses rows
   into single-line list rows. The row's `.row__primary` is the lead
   glance (model · provider · trace_id-prefix); `.row__secondary` is
   the supporting line (ttft · when). Desktop ignores `.is-compact`
   entirely — the existing media-query already returns the table to
   its native `display: table` form and the compact-cell is hidden. */
.data-table.is-compact tr {
  border-radius: 10px;
  margin-bottom: var(--m1-space-2);
  padding: 0;
}

.data-table.is-compact .data-table__compact-cell {
  display: flex;
  align-items: center;
  gap: var(--m1-space-2);
  padding: var(--m1-space-2) var(--m1-space-3);
  border: none;
  width: 100%;
  font-family: var(--font-sans);
  /* Override the default `td` flex justify-content so primary / secondary
     stack inline rather than spread to opposite edges. */
  justify-content: flex-start;
}

.data-table.is-compact .data-table__compact-cell::before {
  /* The base `.data-table td::before` rule injects `data-label` text;
     we have no data-label on the compact cell so suppress it explicitly. */
  content: none;
}

.data-table.is-compact .row__primary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table.is-compact .row__secondary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-foreground);
  /* A-3: previously `flex-shrink: 0`, which kept this rail at intrinsic
     width and pushed the row past 375 wide. Allow shrinking + give a
     `min-width: 0` so flexbox can ellipsis the inner spans before the
     row overflows. */
  min-width: 0;
  overflow: hidden;
}

.data-table.is-compact .row__chevron {
  font-size: 18px;
  color: var(--muted-foreground);
  flex-shrink: 0;
  margin-left: auto;
}

/* On mobile, the per-column `<td>` siblings are redundant with the
   compact-cell. Hide them so the row stays single-line. */
.data-table.is-compact tr > td:not(.data-table__compact-cell) {
  display: none;
}

@media (min-width: 768px) {
  /* Desktop: `.is-compact` becomes a no-op. The compact-cell hides; the
     per-column `<td>` siblings reappear as the regular table layout. */
  .data-table.is-compact .data-table__compact-cell {
    display: none;
  }
  .data-table.is-compact tr > td:not(.data-table__compact-cell) {
    display: table-cell;
  }
}

/* H7 — slim surface page header. Replaces the dark `.m1-banner` on
   `/v/<id>` and `/t/<id>`; the announcement banner stays on `/`. */
.m1-surface-header {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: var(--m1-space-3);
  height: 44px;
  padding-left: max(env(safe-area-inset-left), var(--m1-space-4));
  padding-right: max(env(safe-area-inset-right), var(--m1-space-4));
  background: var(--background);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--foreground);
}

.m1-surface-header__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 var(--m1-space-2);
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
}

.m1-surface-header__title {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.m1-surface-header__right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--m1-space-2);
}

/* ─────────────────────────────────────────────────────────────────────
 * PR-3c — ModelCatalogue + KeysPage refresh.
 *
 * Additive only. Mobile (<768px) renders glanceable cards; desktop
 * (≥768px) hides the card list and lets the existing `.data-table`
 * media query own the wide-screen layout.
 *
 * Class prefixes:
 *   .models-card / .models-card-list   ModelCatalogue mobile cards
 *   .keys-card / .keys-card-list       KeysPage 3-line key cards
 *   .keys-card--sandbox                Sandbox-key card warm tint (audit P14)
 * ───────────────────────────────────────────────────────────────────── */

/* ---- ModelCatalogue: mobile card list ---- */
.models-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
}

.models-card {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-2);
  padding: var(--m1-space-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  font-family: var(--font-sans);
}

.models-card__head {
  display: flex;
  align-items: flex-start;
  gap: var(--m1-space-2);
  flex-wrap: wrap;
}

.models-card__slug {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13.5px;
  overflow-wrap: anywhere;
  color: var(--foreground);
}

.models-card__provider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
}

.models-card__pricing {
  display: flex;
  flex-wrap: wrap;
  gap: var(--m1-space-3);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--foreground);
}

.models-card__pricing strong {
  font-weight: 600;
}

.models-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--m1-space-3);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-foreground);
}

.models-card__meta-label {
  /* The `last fallback:` / `last verified:` / `traces 24h:` prefix labels.
     Quiet uppercase so the value stays readable. */
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10.5px;
  color: var(--muted-foreground);
  margin-right: 4px;
}

@media (min-width: 768px) {
  /* Desktop ≥768px: card list is hidden; the legacy `.data-table` takes
     over (its own media query at 768px restores `display: table` etc.). */
  .models-card-list {
    display: none;
  }
}

@media (max-width: 767.98px) {
  /* Mobile (<768px): the wide table is hidden; the card list owns the
     layout. The base `.data-table` already collapses to stacked rows on
     mobile via line 187 `display: block`. We hide the entire `.data-table`
     on this surface only, scoped via the `.models-table-wrap` wrapper so
     other surfaces' tables stay unaffected. */
  .models-table-wrap {
    display: none;
  }
}

/* ---- KeysPage: mobile 3-line card list ---- */
.keys-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-3);
}

.keys-card {
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-2);
  padding: var(--m1-space-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  font-family: var(--font-sans);
}

/* Line 1 — name + scope pill. */
.keys-card__row1 {
  display: flex;
  align-items: center;
  gap: var(--m1-space-2);
  flex-wrap: wrap;
}

.keys-card__name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--foreground);
}

/* Line 2 — redacted key + reveal button. */
.keys-card__row2 {
  display: flex;
  align-items: center;
  gap: var(--m1-space-2);
  flex-wrap: wrap;
}

.keys-card__redacted {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--foreground);
  overflow-wrap: anywhere;
}

.keys-card__reveal {
  /* The Reveal-once button — a quiet ghost that sits beside the redacted
     key. 32px tall to clear the touch-target floor when paired with the
     surrounding row's vertical padding. */
  height: 32px;
  padding: 0 var(--m1-space-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  /* Touch-target a11y: ensure the row padding plus button height clears
     44px effective when tapped. The button alone is 32px; the parent row
     adds vertical breathing via gap. */
}

.keys-card__reveal:hover {
  background: var(--muted);
}

.keys-card__revealed {
  /* When the Reveal-once flow has been consumed, the button is replaced
     by a static `(revealed)` glyph + the unredacted form. */
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* Line 3 — rpm + traces_24h + last_used + rotate / revoke split. */
.keys-card__row3 {
  display: flex;
  align-items: center;
  gap: var(--m1-space-3);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-foreground);
}

.keys-card__row3-stats {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--m1-space-2);
}

.keys-card__actions {
  margin-left: auto;
  display: inline-flex;
  gap: var(--m1-space-2);
}

.keys-card__action {
  height: 28px;
  padding: 0 var(--m1-space-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 11.5px;
  cursor: pointer;
}

.keys-card__action:hover {
  background: var(--muted);
  color: var(--foreground);
}

/* Sandbox key card — visually distinct via the warm `--hr-warn-soft`
   tint (audit P14). The body text colour stays on the foreground token
   so contrast holds at WCAG AA — `--muted-foreground` on `--hr-warn-soft`
   measures below 4.5:1. */
.keys-card--sandbox {
  background: var(--hr-warn-soft);
  border-color: var(--hr-warn);
}

.keys-card--sandbox .keys-card__name {
  color: var(--foreground);
}

.keys-card--sandbox .keys-card__redacted,
.keys-card--sandbox .keys-card__row3 {
  color: var(--foreground);
}

@media (min-width: 768px) {
  /* Desktop ≥768px: KeysPage card list is hidden in favour of the
     existing `.data-table` layout. Sandbox card stays visible (it's a
     side block, not a table row). */
  .keys-card-list {
    display: none;
  }
}

@media (max-width: 767.98px) {
  /* Mobile: hide the desktop key-table wrapper while the card list owns
     the layout. */
  .keys-table-wrap {
    display: none;
  }
}

/* ───────────────────────────────────────────────────────────────────────
 * A-4 — `.kv-row__value--unset`
 *
 * Honest placeholder for runtime-derived fields the gateway doesn't have
 * yet (`last_fallback`, `last_verified`, `traces_24h`). Rendering these
 * as `0` / `$0.00` / `verified · null` would be the fixture-as-truth bug.
 * The class hook is queryable by tests and stylable distinctly from
 * resolved values.
 * ───────────────────────────────────────────────────────────────────── */
.kv-row__value--unset {
  color: var(--muted-foreground);
  font-style: italic;
}

/* ───────────────────────────────────────────────────────────────────────
 * Round-2 polish bundle (A-7 / A-8 / A-9 / A-10).
 *
 * Append-only. Foundation classes above are unchanged.
 *
 *   A-7 — `.m1-hero__cta-stack`        TrustDashboard hero CTA pair stacks
 *                                       on mobile, lays out side-by-side at
 *                                       >=768px.
 *   A-8 — `.m1-amount-grid__option--selected`
 *                                       Bolder selected state for TopUp
 *                                       preset buttons.
 *         `.m1-amount-cta-bar`          Sticky bottom CTA bar on mobile so
 *                                       Continue-to-Stripe stays above the
 *                                       fold.
 *   A-9 — `.m1-checklist*`             Numbered 3-step list for the Trust
 *                                       verifier-mini.
 *   A-10 — `.m1-error-list-footer`     Single section-level footnote
 *                                       replacing the per-card boilerplate.
 * ───────────────────────────────────────────────────────────────────── */

/* A-7 — Hero CTA stack. Mobile: column, primary stretches full-width;
   desktop (>=768px): row, primary leads + ghost sits beside it. */
.m1-hero__cta-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--m1-space-3);
}

.m1-hero__cta-stack .button {
  /* Stretch primary to fill mobile width — visual hierarchy: a single
     bold rectangle at the top of the fold rather than two small chips. */
  width: 100%;
}

@media (min-width: 768px) {
  .m1-hero__cta-stack {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
  .m1-hero__cta-stack .button {
    /* Desktop: buttons size to content, sit side-by-side. */
    width: auto;
  }
}

/* A-8 — Amount preset selected affordance. Used together with `is-active`
   (which inverts foreground) to add a stronger ring + scale cue. */
.m1-amount-grid__option--selected {
  /* Distinct visual treatment: emerald accent ring matching the trust
     palette, plus a subtle inset shadow so the selection reads as
     pressed/locked rather than just inverted. The base `.is-active`
     rule already inverts background+foreground; this layer reinforces
     the affordance without duplicating colour-only state. */
  box-shadow: 0 0 0 2px var(--hr-trust-strong) inset,
              0 1px 0 oklch(0 0 0 / 0.08);
  border-color: var(--hr-trust-strong);
}

/* A-8 — sticky CTA bar. On mobile the Continue-to-Stripe / Cancel pair
   pins to the viewport bottom so the action stays above the fold even
   when the form scrolls. The safe-area-inset padding clears the iOS
   home-indicator. Desktop loses the sticky behaviour — the form is
   short enough that the CTA sits naturally. */
.m1-amount-cta-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--m1-space-2);
  flex-wrap: wrap;
  padding-top: var(--m1-space-3);
  padding-bottom: max(env(safe-area-inset-bottom), var(--m1-space-3));
  background: linear-gradient(
    to top,
    var(--background) 80%,
    oklch(1 0 0 / 0)
  );
  z-index: 5;
}

@media (min-width: 768px) {
  .m1-amount-cta-bar {
    /* Desktop: drop the sticky pin; the form fits without it. */
    position: static;
    background: transparent;
    padding-top: 0;
    padding-bottom: 0;
  }
}

/* A-9 — CheckList primitive. Numbered marker + title + optional
   description. Used by the Trust verifier-mini as the 3-step proof
   sequence: signature ok / merkle inclusion / anchored. */
.m1-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--m1-space-2);
}

.m1-checklist__item {
  display: flex;
  align-items: flex-start;
  gap: var(--m1-space-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--foreground);
}

.m1-checklist__marker {
  /* Small circular numbered chip. Trust-emerald background +
     white text — DA-12 contrast is satisfied because the marker is
     >=14px (large-text rule) but we still use the AA-passing
     `--hr-trust-strong` to be safe at every viewport. */
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--hr-trust-strong);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.m1-checklist__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.m1-checklist__title {
  font-weight: 500;
  color: var(--foreground);
}

.m1-checklist__desc {
  font-size: 11.5px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

/* A-10 — section-level footer for the errors-explainer card list.
   Replaces the per-card boilerplate "Surfaced via inspector_url..."
   so the same sentence appears once instead of N times. */
.m1-error-list-footer {
  margin-top: var(--m1-space-4);
  padding: var(--m1-space-3) var(--m1-space-4);
  border-top: 1px dashed var(--border);
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted-foreground);
  font-family: var(--font-sans);
}

/* Pre-signin nav actions ("Sign in" + "Get an API key").
   Hidden on mobile to keep the public nav a single brand line.
   The hero CTAs on TrustDashboard carry the same actions at full
   tap-size on mobile. Desktop ≥768px shows the nav buttons inline. */
.m1-public-nav-actions {
  display: none;
}

@media (min-width: 768px) {
  .m1-public-nav-actions {
    display: inline-flex;
    gap: var(--m1-space-2);
    margin-left: auto;
    flex-wrap: wrap;
  }
}
