/* App layout on top of design/components/bundle.css. Values come from the generated tokens. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/21px var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:is(a, button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* Glass fields (wp-field) show focus once, on the field: a soft ring and a darker edge (still a
   visible change, WCAG 2.4.7). The borderless input inside draws no outline of its own, so there's
   no hard double outline. */
.wp-field { transition: border-color 0.15s, box-shadow 0.15s; }
.wp-field input { border: 0; background: transparent; }
.wp-field input:focus, .wp-field input:focus-visible { outline: none; }
.wp-field:focus-within {
  outline: none;
  border-color: var(--faint);
  box-shadow: var(--shadow-control), 0 0 0 4px color-mix(in srgb, var(--faint) 22%, transparent);
}

/* Backdrop: the Liquid Glass wallpaper lives in src/styles/glass.css (.backdrop). */

/* Shell: floating sidebar and main panel, space-frame from the window edge. */
.shell { position: relative; display: flex; gap: var(--space-frame); padding: var(--space-frame); height: 100%; }
.sidebar { width: 244px; flex-shrink: 0; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-name { display: block; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-firm { display: block; font-size: 12px; color: var(--muted); }
.nav-section { font-size: 12px; color: var(--muted); padding: 18px 12px 6px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 4px; border-top: 1px solid var(--line); }
.avatar { width: 26px; height: 26px; border-radius: var(--radius-pill); background: var(--neutral-soft); border: 1px solid var(--line-strong); font: 500 11px var(--font-sans); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.engine { background: var(--ink); border-color: var(--ink); color: var(--on-primary); }
.main-panel { flex: 1; min-width: 0; overflow-y: auto; }

.page { padding: 40px 8px 64px; display: flex; flex-direction: column; gap: var(--space-6); }
.page-narrow { max-width: 976px; width: 100%; margin: 0 auto; padding-top: 56px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 16px; min-height: 52px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
a.row:hover { background: var(--row-hover); }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.hstack { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--space-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 16px 0; border-top: 1px solid var(--rule-strong); }
.stat-value { font-size: 30px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 48px; }
.empty { padding: 20px 0; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { font-weight: 500; text-align: left; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.card-pad { padding: var(--space-5); }

/* Auth screens: one glass card on the backdrop. */
.auth-wrap { position: relative; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 420px; max-width: 100%; padding: 32px; display: flex; flex-direction: column; gap: 18px; }

/* Error and not-found pages inside the app shell. */
.err-card { max-width: 640px; padding: 32px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.input { width: 100%; height: 42px; border-radius: var(--radius-md); border: 1px solid var(--line-strong); background: var(--surface-solid); padding: 0 12px; font: inherit; color: var(--ink); }
.input-code { letter-spacing: 0.5em; font: 500 22px var(--font-sans); font-variant-numeric: tabular-nums; text-align: center; height: 52px; }
.label { font-size: 13px; font-weight: 500; display: block; margin-bottom: 6px; }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 13.5px; background: var(--info-soft); color: var(--info); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.closing-banner { background: var(--review-soft); color: var(--review); margin-bottom: 16px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font: 500 14px var(--font-sans); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; background: var(--surface-solid); border-radius: 12px; padding: 14px; }
.qr { background: var(--surface-solid); border-radius: 12px; padding: 12px; width: 204px; height: 204px; }
.qr svg { width: 180px; height: 180px; display: block; }
.wp-btn.block { justify-content: center; width: 100%; }

/* Contrast and hierarchy: the shared rules, defined once and used on every screen.
   - Lists and sections sit on .section-card (padded). The design system's .wp-card resolves to the
     same surface, so every card in the app reads the same: a whiter panel, a hairline edge, a soft shadow.
   - Secondary actions use .wp-btn.soft; .wp-btn.outline resolves to the same look. The main action
     of a row adds .strong (a darker edge). A borderless icon button uses .wp-btn.ghost.
     The one primary action per area stays .wp-btn.primary.
   - Section labels use .eyebrow (.wp-eyebrow and .t-eyebrow.muted resolve to the same ink).
   - List rows keep their hairline dividers (--line) and hover with --row-hover.
   - Filter pills (.qx-filters a, .rq-filters a) use the secondary button's fill, edge and states.
   Values are tokens or color-mix() of tokens only. The secondary edge is about 3:1 against white
   (WCAG 1.4.11); button text is ink, about 16:1. tests/ux/contrast-rules.test.ts guards the patterns. */
:root {
  --section-fill: var(--glass-bg);
  --section-edge: var(--glass-edge);
  --section-shadow: var(--shadow-float);
  --control-fill: var(--surface-solid);
  --control-edge: color-mix(in srgb, var(--faint) 85%, var(--line-strong));
  --control-edge-strong: color-mix(in srgb, var(--ink-2) 40%, var(--faint));
  --control-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 8%, transparent);
  --control-hover-fill: var(--surface-sunk);
  --control-hover-edge: color-mix(in srgb, var(--ink-2) 55%, var(--faint));
  --control-pressed-fill: color-mix(in srgb, var(--surface-sunk) 55%, var(--line-strong));
  --control-pressed-shadow: inset 0 1px 2px color-mix(in srgb, var(--ink) 14%, transparent);
  --row-hover: color-mix(in srgb, var(--ink) 3.5%, transparent);
  --eyebrow-ink: color-mix(in srgb, var(--ink) 30%, var(--ink-2));
  --rule-strong: var(--ink);
}
.wp-card, .section-card {
  background: var(--section-fill);
  border: 1px solid var(--section-edge);
  border-radius: var(--radius-card);
  box-shadow: var(--section-shadow);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}
/* A card that carries figures, a table or a long list is a flat panel: near-solid, never blurred. */
.wp-card.panel, .section-card.panel {
  background: var(--panel-bg);
  border-color: transparent;
  box-shadow: var(--shadow-panel);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.section-card { padding: var(--space-4) var(--space-5); }
.section-card.flush { padding: var(--space-3) var(--space-1) var(--space-1); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; padding-bottom: var(--space-2); }
.section-card > :last-child, .section-card > ul:last-child > :last-child { border-bottom-color: transparent; }
.section-card > .empty:last-child { padding-bottom: var(--space-1); }
.two-col.cards { gap: var(--space-6); align-items: start; }
.row.item { padding-block: 10px; gap: 12px; }
.row.item.top { align-items: flex-start; }
/* Section labels use the sidebar's type (sans, sentence case, no tracking); the app uses no monospace font anywhere. */
.eyebrow, .wp-eyebrow, .t-eyebrow.muted { font-family: var(--font-sans); font-size: 13px; line-height: 18px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--eyebrow-ink); }
.t-eyebrow { font-family: var(--font-sans); font-size: 13px; line-height: 18px; font-weight: 500; letter-spacing: 0; text-transform: none; }
a.eyebrow:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
a.stat:hover .stat-value { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }

.wp-btn { transition: background-color 0.15s ease-out, border-color 0.15s ease-out, box-shadow 0.15s ease-out; }
.wp-btn:is(.soft, .outline):not([disabled]) {
  background: var(--control-fill);
  color: var(--ink);
  border: 1px solid var(--control-edge);
  box-shadow: var(--control-shadow);
}
.wp-btn:is(.soft, .outline).strong:not([disabled]) { border-color: var(--control-edge-strong); }
.wp-btn:is(.soft, .outline):not([disabled]):hover { background: var(--control-hover-fill); border-color: var(--control-hover-edge); }
.wp-btn:is(.soft, .outline):not([disabled]):active { background: var(--control-pressed-fill); border-color: var(--control-hover-edge); box-shadow: var(--control-pressed-shadow); }
.wp-btn.ghost { background: transparent; border: 0; box-shadow: none; }
.wp-btn.ghost:not([disabled]) { color: var(--ink); }
.wp-btn.ghost:not([disabled]):hover { background: var(--row-hover); }
.wp-btn.ghost:not([disabled]):active { background: var(--control-pressed-fill); }

@media (max-width: 1000px) {
  .shell { flex-direction: column; height: auto; min-height: 100%; padding: 16px; }
  .sidebar { width: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px; gap: 4px; }
  .sidebar .nav-section, .sidebar .me, .brand-firm { display: none; }
  .sidebar .wp-nav { white-space: nowrap; }
  .brand { padding: 0 8px; }
  .page { padding: 28px 4px 64px; }
  .page-narrow { padding-top: 28px; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  /* Phones: the brand and the account on the first row, the nav links on a full-width second row
     (one scrolling strip, with the current page scrolled into view by sidebar.tsx). */
  .sidebar.with-account { flex-wrap: wrap; row-gap: 6px; }
  .sidebar.with-account .brand { flex: 1; }
  .sidebar.with-account .me { order: 2; }
  .sidebar.with-account .nav-scroll { order: 3; flex: 1 0 100%; }
}

/* Touch screens (phones and tablets). tests/ux/mobile-touch.test.ts guards these rules.
   - Fields are at least 16px, so iOS doesn't zoom the page when one is focused. The 2FA code keeps
     its larger size.
   - Buttons and nav links are at least 44px tall (small buttons 40px, still well over the 24px
     minimum of WCAG 2.5.8); icon buttons are 44px square.
   - Keyboard shortcut hints (key caps and the key legend) are hidden: there's no keyboard. */
@media (pointer: coarse), (max-width: 640px) {
  :is(input, select, textarea):not([type="checkbox"], [type="radio"], [type="range"], [type="file"], .input-code) { font-size: 16px !important; }
}
@media (pointer: coarse) {
  .wp-btn { min-height: 44px; }
  .wp-btn.sm { min-height: 40px; }
  .wp-btn.primary.sm { min-height: 44px; }
  .sidebar .wp-nav { min-height: 44px; }
  .gs-open, .wpx-viewer-icon, .wp-btn:has(> svg:only-child) { min-width: 44px; min-height: 44px; }
  .gs-field kbd { display: none !important; }
  .touch-hide { display: none !important; }
}
@media (pointer: fine) {
  .touch-only { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Brand type (specs/brand/brand-system.md): titles 24px and up set in Bricolage Grotesque, everything smaller in
   Onest. These page and card titles size themselves in component CSS, so they take the display face here. */
:root h1.cl-title, :root .qx-list h1, :root h1.qx-title, :root .rt-head h1, :root .wpx-head h1, :root .wpx-card h2, :root .hm-greet, :root .drop-t {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.028em;
}
:root .wpx-card h2 { font-weight: 600; letter-spacing: -0.018em; }
:root .pd-rh h1 { font-family: var(--font-display); font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -0.018em; }
