/* ============================================================================
   GENERATED FILE - DO NOT EDIT.
   Source:    public/tools/design-system-v2.css
   Generator: scripts/build-ds-v2-scoped.js
   Guard:     tests/ds-v2-scoped-build.test.js re-runs the generator and fails
              if this file disagrees with the source.

   Every selector from the v2 stylesheet, rewritten to sit under a .ds-v2 scope
   class so v2 applies to the Training surface ONLY. Custom properties inherit,
   so tokens declared on .ds-v2 reach everything inside it and nothing outside.
   The rest of People keeps v1, byte for byte.

   Edit design-system-v2.css and re-run the generator. Never edit this file.

   When the full v2 rollout is greenlit: delete this file and its generator and
   link design-system-v2.css directly. Nothing here needs unpicking first.
   ============================================================================ */
/* ──────────────────────────────────────────────────────────────────
   HT OS Design System v2 - "Instrument" pass
   Same token NAMES as v1 (drop-in: rename this file to design-system.css,
   nothing that reads var(--*) or .ds-* breaks) - values and component
   rules are what changed. Read plans/design-system-v2.md for the why.

   STATUS (2026-07-13): staged reference asset, loaded by ZERO pages.
   The live public/tools/design-system.css is still v1. This file only
   becomes real when someone does the actual rollout (see the status
   banner at the top of plans/design-system-v2.md for what that involves)
   - don't assume any shipped page reflects these values yet just because
   the class/token names below already exist in production under v1.

   Prefix: .ds-*  - does not collide with legacy .htos-* classes.
   ────────────────────────────────────────────────────────────────── */

/* ────── Tokens ────── */
.ds-v2 {
  color-scheme: light dark;

  /* Brand - unchanged, from Home Therapist_Guidelines.pdf. Do not edit. */
  --brand-royal: #3D7CC9;
  --brand-royal-ink: #1E4F8A;
  --brand-royal-soft: #E6EEF9;
  --brand-sky: #00A0DF;
  --brand-sky-ink: #006A96;
  --brand-sky-soft: #E0F4FC;
  --brand-mint: #2ED9C3;
  --brand-mint-ink: #158F7D;
  --brand-mint-soft: #E1F9F4;
  --brand-gold-a: #D4A94A;
  --brand-gold-b: #F4D97B;
  --brand-gold-grad: linear-gradient(135deg, var(--brand-gold-a) 0%, var(--brand-gold-b) 100%);

  /* Value / Premium / Elite tier metals - bronze/silver/gold ladder for
     service plans, heat-calc sizing tiers, and good/better/best
     presentation. Elite reuses the brand gold tokens above (one gold,
     one meaning) instead of inventing a fourth palette. */
  --tier-value-a: #C89A5D;
  --tier-value-b: #9C7444;
  --tier-value-ink: #4A3018;
  --tier-value-border: #8C6A3D;
  --tier-premium-a: #DEE2E8;
  --tier-premium-b: #AEB6C1;
  --tier-premium-ink: #333A45;
  --tier-premium-border: #8E96A3;

  /* Semantic */
  --accent: var(--brand-royal);
  --accent-ink: var(--brand-royal-ink);
  --accent-soft: var(--brand-royal-soft);
  --success: #16875A;      /* darkened 1 step for AA on white chips at small sizes */
  /* 🔴 MUST EXIST HERE TOO. v1's sheet gained --success-ink on 2026-08-19 and
     pages reference it by name. A page that moves to v2 while this token is
     undefined does not fall back to green - the declaration is invalid at
     computed-value time and the text inherits body colour, which is the exact
     --warning trap documented in public/tools/water-report.css. */
  --success-ink: #0F6E4A;
  --success-soft: #E3F5EC;
  --warn: #C1740B;         /* darkened from #E08A1E - old value failed AA at text-xs */
  --warn-soft: #FBEEDA;
  --danger: #D42A2A;
  --danger-soft: #FBE4E4;
  --info: var(--brand-sky);
  --info-soft: var(--brand-sky-soft);

  /* Neutrals - light. Cooled 2° and de-blued vs v1 (was drifting toward
     "generic SaaS lavender-gray"); this ramp reads as instrument-panel
     slate, closer to the Stripe/Linear/Ramp neutral family. */
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F1F2F5;
  --surface-3: #E7E9ED;
  --surface-overlay: rgba(255, 255, 255, 0.88);
  --border: #E2E4E9;
  --border-subtle: #EBECEF;
  --ink: #0B0F17;          /* darkened from #0E1B33 - crisper, less "navy" */
  --ink-2: #3E4453;
  --ink-3: #6B7280;
  --muted: #8B90A0;

  /* Chat bubbles (the Inbox web thread and the phone chat), carried over from
     design-system.css so a page that moves to v2 does not lose them: an
     undefined token is not a fallback, the declaration is simply dropped. Green
     means "mine" here and nowhere else. Same values as v1; the rationale, and
     the contrast the test pins, are in design-system.css and
     tests/chat-bubble-look.test.js. */
  --chat-mine-bg: #D9FDD3;
  --chat-mine-border: #B9E9B3;
  --chat-mine-ink: var(--ink);
  --chat-mine-meta: var(--ink-2);
  --chat-theirs-bg: var(--surface);
  --chat-theirs-border: var(--border);
  --chat-theirs-ink: var(--ink);
  --chat-theirs-meta: var(--ink-3);
  --chat-wash: rgba(14, 27, 51, 0.06);

  /* The web chat bubble that travels across every page (Wave 7 item 4). Same
     values as v1 (design-system.css explains them); repeated in both dark blocks. */
  --chat-fab-bg: var(--brand-royal);
  --chat-fab-ink: #FFFFFF;
  --chat-badge-bg: var(--danger);
  --chat-badge-ink: #FFFFFF;
  --z-chat-bubble: 85;
  --z-chat-panel: 79;

  /* Type */
  --font-sans: 'Radio Canada Big', -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Type scale - unchanged sizes (proven for tool density), tracking
     tightened on the large end so headings read "engineered" not "web". */
  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-md:   1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;
  --text-4xl:  3rem;

  --lh-tight:  1.15;
  --lh-snug:   1.3;
  --lh-normal: 1.5;
  --lh-loose:  1.65;

  --tracking-tight: -0.03em;   /* was -0.02 */
  --tracking-snug:  -0.012em;  /* was -0.01 */
  --tracking-wide:   0.05em;   /* was 0.04 - uppercase labels need the extra air */

  /* Spacing (4px grid) - unchanged */
  --s-0:  0;
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-7:  28px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;

  /* Radius - tightened one notch across the board. Big radii read
     "consumer app"; a data-dense ops tool reads sharper and more
     confident with less roundness. Names unchanged, values tighter. */
  --r-xs:  4px;
  --r-sm:  6px;
  --r:     8px;    /* was 10px */
  --r-md:  10px;   /* was 12px */
  --r-lg:  12px;   /* was 16px */
  --r-xl:  16px;   /* was 22px */
  --r-full: 9999px;

  /* Elevation - rebuilt. v1 leaned on heavy multi-layer blur to do the
     job a 1px border should do; that's what read "AI-generated SaaS
     template" more than any color choice. New rule: borders separate
     surfaces at rest, shadows exist ONLY on things that float above the
     page (dropdowns, dialogs, toasts, drag state) or lift on hover. */
  --sh-xs: 0 1px 2px rgba(11, 15, 23, 0.04);
  --sh-sm: 0 1px 2px rgba(11, 15, 23, 0.06), 0 1px 1px rgba(11, 15, 23, 0.04);
  --sh:    0 2px 6px -1px rgba(11, 15, 23, 0.07), 0 1px 2px rgba(11, 15, 23, 0.04);
  --sh-md: 0 8px 16px -6px rgba(11, 15, 23, 0.10), 0 2px 4px -2px rgba(11, 15, 23, 0.05);
  --sh-lg: 0 16px 32px -12px rgba(11, 15, 23, 0.16), 0 4px 8px -4px rgba(11, 15, 23, 0.06);
  --sh-xl: 0 24px 48px -16px rgba(11, 15, 23, 0.22), 0 8px 16px -8px rgba(11, 15, 23, 0.08);

  /* Focus ring */
  --ring:       0 0 0 3px rgba(61, 124, 201, 0.30);
  --ring-danger:0 0 0 3px rgba(212, 42, 42, 0.30);

  /* Motion - trimmed ~25ms off each step. "Sleek" for a tool used all
     day means interactions resolve before the eye registers them, not
     spring-bounce delight. Spring survives only on the switch thumb. */
  --dur-fast: 110ms;
  --dur:      170ms;
  --dur-slow: 320ms;
  --ease:     cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout widths */
  --container-sm: 640px;
  --container:    1024px;
  --container-lg: 1280px;
  --container-xl: 1440px;

  /* Z stack */
  --z-sticky:   80;
  --z-dropdown: 120;
  --z-dialog:   400;
  --z-toast:    500;

  /* Legacy shell.css bridges - unchanged, keep .htos-* on tokens */
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --card2: var(--surface-3);
  --card: var(--surface);
  --line: var(--border);
  --line-2: var(--border-subtle);
  --text: var(--ink);
  --text2: var(--ink-2);
  --ok: var(--success);
  --ok-soft: var(--success-soft);
  --fail: var(--danger);
  --fail-soft: var(--danger-soft);
  --black: var(--ink);
  --shadow: var(--sh);

  /* Icon system tokens (new) - see design-system-v2.md §5 */
  --icon-stroke: 1.75;
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
}

/* ────── Dark mode - values retuned to match the new light ramp's
   contrast logic; same structural approach as v1 (deep blue-ink, three
   tonal layers), just recalibrated so it isn't washed out next to the
   crisper light mode. ────── */
[data-theme="dark"] .ds-v2 {
  color-scheme: dark;
  --bg: #12161F;
  --surface: #1A1F2B;
  --surface-2: #161A24;
  --surface-3: #232937;
  --surface-overlay: rgba(26, 31, 43, 0.88);
  --border: #2C3242;
  --border-subtle: #1F2430;
  --ink: #EEF0F4;
  --ink-2: #B7BCC8;
  --ink-3: #838a9c;
  --muted: #656d82;

  --accent: #5A9AE6;
  --accent-ink: #9FC3EF;
  --accent-soft: rgba(90, 154, 230, 0.18);
  /* -ink variants were unadjusted in v1 (bug found in review): dark navy
     brand-royal-ink/#1E4F8A etc. on a near-black bg is nearly invisible -
     this is what made .ds-chip-royal/-sky/-mint text unreadable in dark
     mode. Brightened all three to match the accent-ink treatment. */
  --brand-royal-ink: #9FC3EF;
  --brand-sky-ink: #6FD3EF;
  --brand-mint-ink: #6EEBD3;
  --brand-royal-soft: rgba(90, 154, 230, 0.20);
  --brand-sky-soft: rgba(0, 160, 223, 0.20);
  --brand-mint-soft: rgba(46, 217, 195, 0.18);
  --success: #38B888;
  --success-ink: #4ADE95;
  --success-soft: rgba(22, 168, 112, 0.20);
  --warn: #E3A23D;
  --warn-soft: rgba(244, 217, 123, 0.16);
  --danger: #E5645F;
  --danger-soft: rgba(220, 80, 80, 0.20);
  --info-soft: rgba(0, 160, 223, 0.20);
  /* Chat bubbles (see the light block). Keep identical to the @media block below. */
  --chat-mine-bg: #17503D;
  --chat-mine-border: #24705A;
  --chat-mine-ink: var(--ink);
  --chat-mine-meta: var(--ink-2);
  --chat-theirs-bg: var(--surface);
  --chat-theirs-border: var(--border);
  --chat-theirs-ink: var(--ink);
  --chat-theirs-meta: var(--ink-3);
  --chat-wash: rgba(0, 0, 0, 0.22);
  /* The web chat bubble stays brand royal in dark. */
  --chat-fab-bg: var(--brand-royal);
  --chat-fab-ink: #FFFFFF;
  --chat-badge-bg: var(--danger);
  --chat-badge-ink: #FFFFFF;

  --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.25);
  --sh:    0 4px 10px rgba(0, 0, 0, 0.30);
  --sh-md: 0 10px 22px rgba(0, 0, 0, 0.38);
  --sh-lg: 0 20px 36px rgba(0, 0, 0, 0.45);
  --sh-xl: 0 30px 48px rgba(0, 0, 0, 0.55);

  --ring: 0 0 0 3px rgba(90, 154, 230, 0.50);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ds-v2 {
    --bg: #12161F;
    --surface: #1A1F2B;
    --surface-2: #161A24;
    --surface-3: #232937;
    --surface-overlay: rgba(26, 31, 43, 0.88);
    --border: #2C3242;
    --border-subtle: #1F2430;
    --ink: #EEF0F4;
    --ink-2: #B7BCC8;
    --ink-3: #838a9c;
    --muted: #656d82;
    --accent: #5A9AE6;
    --accent-ink: #9FC3EF;
    --accent-soft: rgba(90, 154, 230, 0.18);
    --brand-royal-ink: #9FC3EF;
    --brand-sky-ink: #6FD3EF;
    --brand-mint-ink: #6EEBD3;
    --brand-royal-soft: rgba(90, 154, 230, 0.20);
    --brand-sky-soft: rgba(0, 160, 223, 0.20);
    --brand-mint-soft: rgba(46, 217, 195, 0.18);
    --success: #38B888;
    --success-ink: #4ADE95;
    --success-soft: rgba(22, 168, 112, 0.20);
    --warn: #E3A23D;
    --warn-soft: rgba(244, 217, 123, 0.16);
    --danger: #E5645F;
    --danger-soft: rgba(220, 80, 80, 0.20);
    --info-soft: rgba(0, 160, 223, 0.20);
    /* Chat bubbles: identical to the [data-theme="dark"] block above. */
    --chat-mine-bg: #17503D;
    --chat-mine-border: #24705A;
    --chat-mine-ink: var(--ink);
    --chat-mine-meta: var(--ink-2);
    --chat-theirs-bg: var(--surface);
    --chat-theirs-border: var(--border);
    --chat-theirs-ink: var(--ink);
    --chat-theirs-meta: var(--ink-3);
    --chat-wash: rgba(0, 0, 0, 0.22);
    /* The web chat bubble: identical to the [data-theme="dark"] block above. */
    --chat-fab-bg: var(--brand-royal);
    --chat-fab-ink: #FFFFFF;
    --chat-badge-bg: var(--danger);
    --chat-badge-ink: #FFFFFF;
    --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.25);
    --sh:    0 4px 10px rgba(0, 0, 0, 0.30);
    --sh-md: 0 10px 22px rgba(0, 0, 0, 0.38);
    --sh-lg: 0 20px 36px rgba(0, 0, 0, 0.45);
    --sh-xl: 0 30px 48px rgba(0, 0, 0, 0.55);
    --ring: 0 0 0 3px rgba(90, 154, 230, 0.50);
  }
}

/* ────── Base reset + type ────── */
.ds-v2, .ds-v2 *,
.ds-v2::before, .ds-v2 *::before,
.ds-v2::after, .ds-v2 *::after { box-sizing: border-box; }

.ds-v2 {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: var(--text-base); line-height: var(--lh-normal);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.ds-v2 h1,
.ds-v2 h2,
.ds-v2 h3,
.ds-v2 h4,
.ds-v2 h5,
.ds-v2 h6 { margin: 0; font-weight: 600; letter-spacing: var(--tracking-snug); color: var(--ink); }
.ds-v2 h1 { font-size: var(--text-2xl); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); font-weight: 650; }
.ds-v2 h2 { font-size: var(--text-xl); line-height: var(--lh-tight); }
.ds-v2 h3 { font-size: var(--text-lg); line-height: var(--lh-snug); }
.ds-v2 h4 { font-size: var(--text-md); line-height: var(--lh-snug); }
.ds-v2 p { margin: 0; }
.ds-v2 a { color: var(--accent-ink); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
.ds-v2 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.ds-v2 code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: var(--r-xs); }
.ds-v2 hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--s-6) 0; }
.ds-v2 ::selection { background: var(--accent-soft); color: var(--accent-ink); }
.ds-v2 :focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
@media (prefers-reduced-motion: reduce) {
  .ds-v2, .ds-v2 *,
.ds-v2::before, .ds-v2 *::before,
.ds-v2::after, .ds-v2 *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Numeric discipline: NO tabular-nums (2026-10-16). In Radio Canada Big the
   tnum feature also widens space, period, comma and colon to 9.6px (3.5px
   normally), so "$279.00" reads "$279 . 00". Number cells stay proportional;
   see .ds-tabular in design-system.css. */

/* ────── Layout primitives - unchanged ────── */
.ds-v2 .ds-container { max-width: var(--container-lg); margin: 0 auto; padding: 0 var(--s-6); }
.ds-v2 .ds-container-sm { max-width: var(--container-sm); }
.ds-v2 .ds-container-xl { max-width: var(--container-xl); }
.ds-v2 .ds-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.ds-v2 .ds-stack-sm { gap: var(--s-2); }
.ds-v2 .ds-stack-lg { gap: var(--s-6); }
.ds-v2 .ds-cluster { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.ds-v2 .ds-cluster-sm { gap: var(--s-2); }
.ds-v2 .ds-row { display: flex; align-items: center; gap: var(--s-3); }
.ds-v2 .ds-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.ds-v2 .ds-grid { display: grid; gap: var(--s-4); }
.ds-v2 .ds-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ds-v2 .ds-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ds-v2 .ds-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 960px) {
  .ds-v2 .ds-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-v2 .ds-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .ds-v2 .ds-grid-4,
.ds-v2 .ds-grid-3,
.ds-v2 .ds-grid-2 { grid-template-columns: 1fr; }
}
.ds-v2 .ds-divider { border-top: 1px solid var(--border-subtle); }
.ds-v2 .ds-mute { color: var(--ink-3); }
.ds-v2 .ds-muted { color: var(--muted); }
.ds-v2 .ds-section { padding: var(--s-10) 0; border-top: 1px solid var(--border-subtle); }
.ds-v2 .ds-section:first-of-type { border-top: 0; padding-top: var(--s-6); }

/* Eyebrow - de-pilled. A rounded uppercase pill on every section header
   was the single biggest "template" tell; a plain tracked label with a
   colored square tick reads as engineered documentation instead. */
.ds-v2 .ds-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent-ink);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: var(--tracking-wide);
  text-transform: uppercase; margin-bottom: var(--s-3);
}
.ds-v2 .ds-eyebrow::before {
  content: ""; width: 8px; height: 8px; background: var(--accent); border-radius: 2px; flex-shrink: 0;
}
.ds-v2 .ds-eyebrow-gold { color: #8A5F14; }
.ds-v2 .ds-eyebrow-gold::before { background: var(--brand-gold-grad); }

/* ────── Buttons ──────
   Flat at rest, hairline border on every variant (even primary), shadow
   appears ONLY on hover - this is the single biggest button change and
   the one that will read most immediately as "not the old system." */
.ds-v2 .ds-btn {
  --btn-bg: var(--accent);
  --btn-ink: #fff;
  --btn-border: color-mix(in srgb, var(--accent) 82%, black 12%);
  --btn-hover: var(--accent-ink);
  --btn-h: 40px;
  --btn-px: 16px;
  --btn-fs: var(--text-base);
  --btn-radius: var(--r);

  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 var(--btn-px);
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1px solid var(--btn-border);
  border-radius: var(--btn-radius);
  font-family: inherit;
  font-size: var(--btn-fs);
  font-weight: 600;
  letter-spacing: var(--tracking-snug);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  box-shadow: none;
}
.ds-v2 .ds-btn:hover { background: var(--btn-hover); box-shadow: var(--sh-sm); text-decoration: none; }
.ds-v2 .ds-btn:active { transform: translateY(0.5px); box-shadow: none; }
.ds-v2 .ds-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.ds-v2 .ds-btn:disabled,
.ds-v2 .ds-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.ds-v2 .ds-btn .ds-btn-icon { width: var(--icon-sm); height: var(--icon-sm); flex-shrink: 0; }

.ds-v2 .ds-btn-secondary {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-border: var(--border);
  --btn-hover: var(--surface-2);
}
.ds-v2 .ds-btn-ghost {
  --btn-bg: transparent;
  --btn-ink: var(--ink-2);
  --btn-border: transparent;
  --btn-hover: var(--surface-2);
}
.ds-v2 .ds-btn-ghost:hover { box-shadow: none; color: var(--ink); }
.ds-v2 .ds-btn-subtle {
  --btn-bg: var(--accent-soft);
  --btn-ink: var(--accent-ink);
  --btn-border: transparent;
  --btn-hover: var(--brand-royal-soft);
}
.ds-v2 .ds-btn-subtle:hover { box-shadow: none; }
.ds-v2 .ds-btn-danger {
  --btn-bg: var(--danger);
  --btn-ink: #fff;
  --btn-border: color-mix(in srgb, var(--danger) 80%, black 14%);
  --btn-hover: #B41F1F;
}
.ds-v2 .ds-btn-dark {
  --btn-bg: var(--ink);
  --btn-ink: var(--bg);
  --btn-border: var(--ink);
  --btn-hover: #000;
}
[data-theme="dark"] .ds-v2 .ds-btn-dark { --btn-hover: #FFFFFF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ds-v2 .ds-btn-dark { --btn-hover: #FFFFFF; } }

/* Gold - flat now, no inset gloss/bevel (the skeuomorphic highlight was
   the most dated single detail in the old system). A clean fill with a
   one-shade-darker gold border reads premium without looking like an
   iOS-6 button. */
.ds-v2 .ds-btn-gold {
  --btn-border: #B98F35;
  background: var(--brand-gold-grad);
  color: #4A3312;
  border: 1px solid var(--btn-border);
  box-shadow: none;
}
.ds-v2 .ds-btn-gold:hover { filter: brightness(1.04); box-shadow: var(--sh-sm); }
.ds-v2 .ds-btn-gold:active { filter: brightness(0.98); }

/* Duo - kept for hero moments, flattened the same way. */
.ds-v2 .ds-btn-duo {
  background: linear-gradient(135deg, var(--brand-royal) 0%, var(--brand-sky) 45%, var(--brand-gold-b) 100%);
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--brand-royal) 70%, black 15%);
  box-shadow: none;
}
.ds-v2 .ds-btn-duo:hover { filter: brightness(1.05); box-shadow: var(--sh-sm); }

.ds-v2 .ds-btn-sm { --btn-h: 32px; --btn-px: 12px; --btn-fs: var(--text-sm); --btn-radius: var(--r-sm); }
.ds-v2 .ds-btn-lg { --btn-h: 44px; --btn-px: 20px; --btn-fs: var(--text-md); }

.ds-v2 .ds-btn-icon-only { width: var(--btn-h); padding: 0; border-radius: var(--r); }
.ds-v2 .ds-btn-pill { border-radius: var(--r-full); }

.ds-v2 .ds-btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.ds-v2 .ds-btn-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: ds-spin 0.6s linear infinite; color: #fff; opacity: 1;
}
.ds-v2 .ds-btn-secondary.ds-btn-loading::after,
.ds-v2 .ds-btn-ghost.ds-btn-loading::after,
.ds-v2 .ds-btn-subtle.ds-btn-loading::after { color: var(--accent); }
@keyframes ds-spin { to { transform: rotate(360deg); } }

.ds-v2 .ds-btn-group { display: inline-flex; }
.ds-v2 .ds-btn-group .ds-btn { border-radius: 0; margin-left: -1px; }
.ds-v2 .ds-btn-group .ds-btn:first-child { border-top-left-radius: var(--r); border-bottom-left-radius: var(--r); margin-left: 0; }
.ds-v2 .ds-btn-group .ds-btn:last-child { border-top-right-radius: var(--r); border-bottom-right-radius: var(--r); }

/* ────── Form controls ────── */
.ds-v2 .ds-field { display: flex; flex-direction: column; gap: 6px; }
.ds-v2 .ds-label { font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); letter-spacing: var(--tracking-snug); }
.ds-v2 .ds-label .req { color: var(--danger); margin-left: 2px; }
.ds-v2 .ds-help { font-size: var(--text-xs); color: var(--muted); }
.ds-v2 .ds-error { font-size: var(--text-xs); color: var(--danger); min-height: 1em; }
.ds-v2 .ds-input,
.ds-v2 .ds-select,
.ds-v2 .ds-textarea {
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  color: var(--ink); font: inherit; font-size: var(--text-base); line-height: 1.4;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  outline: none;
}
.ds-v2 .ds-input::placeholder,
.ds-v2 .ds-textarea::placeholder { color: var(--muted); }
.ds-v2 .ds-input:hover,
.ds-v2 .ds-select:hover,
.ds-v2 .ds-textarea:hover { border-color: var(--ink-3); }
.ds-v2 .ds-input:focus,
.ds-v2 .ds-select:focus,
.ds-v2 .ds-textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.ds-v2 .ds-input:disabled,
.ds-v2 .ds-select:disabled,
.ds-v2 .ds-textarea:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
.ds-v2 .ds-input[aria-invalid="true"],
.ds-v2 .ds-select[aria-invalid="true"],
.ds-v2 .ds-textarea[aria-invalid="true"] { border-color: var(--danger); }
.ds-v2 .ds-input[aria-invalid="true"]:focus,
.ds-v2 .ds-select[aria-invalid="true"]:focus,
.ds-v2 .ds-textarea[aria-invalid="true"]:focus { box-shadow: var(--ring-danger); }
.ds-v2 .ds-textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.ds-v2 .ds-input-wrap { position: relative; display: flex; align-items: center; }
.ds-v2 .ds-input-wrap .ds-input { padding-left: 38px; }
.ds-v2 .ds-input-icon { position: absolute; left: 11px; width: var(--icon-sm); height: var(--icon-sm); color: var(--muted); pointer-events: none; }
.ds-v2 .ds-select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238B90A0' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; cursor: pointer;
}
.ds-v2 .ds-check,
.ds-v2 .ds-radio { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-base); color: var(--ink); cursor: pointer; user-select: none; }
.ds-v2 .ds-check input,
.ds-v2 .ds-radio input { position: absolute; opacity: 0; pointer-events: none; }
.ds-v2 .ds-check-box,
.ds-v2 .ds-radio-dot {
  width: 18px; height: 18px; border: 1.5px solid var(--border); background: var(--surface);
  display: inline-grid; place-items: center; flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.ds-v2 .ds-check-box { border-radius: 5px; }
.ds-v2 .ds-radio-dot { border-radius: 50%; }
.ds-v2 .ds-check:hover .ds-check-box,
.ds-v2 .ds-radio:hover .ds-radio-dot { border-color: var(--accent); }
.ds-v2 .ds-check input:checked ~ .ds-check-box,
.ds-v2 .ds-radio input:checked ~ .ds-radio-dot { background: var(--accent); border-color: var(--accent); }
.ds-v2 .ds-check input:checked ~ .ds-check-box::after {
  content: ""; width: 10px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
.ds-v2 .ds-radio input:checked ~ .ds-radio-dot::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.ds-v2 .ds-check input:focus-visible ~ .ds-check-box,
.ds-v2 .ds-radio input:focus-visible ~ .ds-radio-dot { box-shadow: var(--ring); }
.ds-v2 .ds-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: var(--text-base); color: var(--ink); }
.ds-v2 .ds-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ds-v2 .ds-switch-track { width: 36px; height: 21px; border-radius: var(--r-full); background: var(--surface-3); position: relative; transition: background var(--dur) var(--ease); }
.ds-v2 .ds-switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: var(--sh-sm); transition: transform var(--dur) var(--ease-spring);
}
.ds-v2 .ds-switch input:checked ~ .ds-switch-track { background: var(--accent); }
.ds-v2 .ds-switch input:checked ~ .ds-switch-track::after { transform: translateX(15px); }
.ds-v2 .ds-switch input:focus-visible ~ .ds-switch-track { box-shadow: var(--ring); }

/* ────── Cards ──────
   Border does the separating; shadow is reserved for the hover lift.
   Radius tightened. Hover lift reduced from -2px/spring to -1px/ease-out
   (a card that springs on hover reads like a mobile-game button). */
.ds-v2 .ds-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: none; overflow: hidden; }
.ds-v2 .ds-card-hoverable { cursor: pointer; transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.ds-v2 .ds-card-hoverable:hover { transform: translateY(-1px); box-shadow: var(--sh-md); border-color: var(--border); }
.ds-v2 .ds-card-head { padding: 13px 16px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ds-v2 .ds-card-head h3 { font-size: var(--text-md); letter-spacing: var(--tracking-snug); }
.ds-v2 .ds-card-body { padding: 16px; }
.ds-v2 .ds-card-body.ds-tight { padding: 12px 16px; }
.ds-v2 .ds-card-foot { padding: 11px 16px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* Hero card - the royal→gold radial "pour" from v1 stays (review verdict:
   "gives the system a cool tone"); added a slim gold top rule as a
   sharper signature edge on top of it. */
.ds-v2 .ds-card-hero {
  background:
    radial-gradient(800px 300px at 120% -20%, rgba(244,217,123,0.55) 0%, transparent 55%),
    linear-gradient(135deg, var(--brand-royal) 0%, var(--brand-royal-ink) 55%, #1B3B6B 100%);
  color: #fff;
  border: 0;
  box-shadow: 0 14px 32px -12px rgba(61,124,201,0.45), 0 4px 10px -4px rgba(212,169,74,0.2);
  position: relative; overflow: hidden;
}
.ds-v2 .ds-card-hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 180px at 0% 100%, rgba(0,160,223,0.25) 0%, transparent 60%);
  pointer-events: none;
}
.ds-v2 .ds-card-hero::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--brand-gold-grad);
}
.ds-v2 .ds-card-hero .ds-card-body { position: relative; z-index: 1; }

/* KPI card - a feature KPI reads through weight + a single top accent
   rule, not an arbitrary rainbow number. Color only comes back when it's
   semantically directional: .positive (green) for healthy money metrics,
   .negative (red) for ones that need attention. Anything without an
   inherent direction (job counts, headcounts) stays plain ink. */
.ds-v2 .ds-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease); }
.ds-v2 .ds-kpi-hoverable { cursor: pointer; }
.ds-v2 .ds-kpi-hoverable:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }
.ds-v2 .ds-kpi-label { color: var(--ink-3); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: var(--tracking-wide); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.ds-v2 .ds-kpi-value { font-size: var(--text-2xl); font-weight: 700; letter-spacing: var(--tracking-tight); line-height: 1.05; }
.ds-v2 .ds-kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: 700; padding: 2px 7px; border-radius: var(--r-sm); margin-top: 10px; }
.ds-v2 .ds-kpi-delta.up { background: var(--success-soft); color: var(--success); }
.ds-v2 .ds-kpi-delta.down { background: var(--danger-soft); color: var(--danger); }
.ds-v2 .ds-kpi-delta.flat { background: var(--surface-2); color: var(--ink-3); }
.ds-v2 .ds-kpi-feature { position: relative; border-top: 2px solid var(--accent); }
.ds-v2 .ds-kpi-feature .ds-kpi-value { color: var(--ink); }
.ds-v2 .ds-kpi-feature.positive { border-top-color: var(--success); }
.ds-v2 .ds-kpi-feature.positive .ds-kpi-value {
  background: linear-gradient(105deg, #0E9A64 0%, var(--success) 55%, #0B5A3C 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ds-v2 .ds-kpi-feature.negative { border-top-color: var(--danger); }
.ds-v2 .ds-kpi-feature.negative .ds-kpi-value {
  background: linear-gradient(105deg, #E5645F 0%, var(--danger) 55%, #901D1D 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ds-v2 .ds-kpi-sparkle { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--brand-gold-grad); margin-right: 2px; }

/* ────── Tables ────── */
.ds-v2 .ds-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.ds-v2 .ds-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.ds-v2 .ds-table thead th {
  text-align: left; padding: 9px 14px; background: var(--surface-2); color: var(--ink-3);
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: var(--tracking-wide);
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.ds-v2 .ds-table thead th.num,
.ds-v2 .ds-table td.num { text-align: right; }
.ds-v2 .ds-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-subtle); color: var(--ink); vertical-align: middle; }
.ds-v2 .ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-v2 .ds-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.ds-v2 .ds-table tbody tr:hover { background: var(--surface-2); }
.ds-v2 .ds-table tbody tr.clickable { cursor: pointer; }
@media (max-width: 640px) {
  .ds-v2 .ds-table thead { display: none; }
  .ds-v2 .ds-table,
.ds-v2 .ds-table tbody,
.ds-v2 .ds-table tr,
.ds-v2 .ds-table td { display: block; width: 100%; }
  .ds-v2 .ds-table tr { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
  .ds-v2 .ds-table td { padding: 4px 0; border: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .ds-v2 .ds-table td::before { content: attr(data-label); font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: 700; }
}

/* ────── Chips / tags / badges ──────
   Reverted to v1's tinted-pill treatment after review - a tiered
   quiet/loud version (outline for brand chips, solid fill only for
   alerts) tested "too rigid." All status chips keep one consistent
   weight, as before. */
.ds-v2 .ds-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink-2);
  font-size: var(--text-xs); font-weight: 600;
  border: 1px solid var(--border-subtle);
}
.ds-v2 .ds-chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.ds-v2 .ds-chip-solid { background: var(--accent); color: #fff; border-color: transparent; }
.ds-v2 .ds-chip-solid .ds-chip-dot { background: #fff; }
.ds-v2 .ds-chip-royal { background: var(--brand-royal-soft); color: var(--brand-royal-ink); border-color: transparent; }
.ds-v2 .ds-chip-royal .ds-chip-dot { background: var(--brand-royal); }
.ds-v2 .ds-chip-sky { background: var(--brand-sky-soft); color: var(--brand-sky-ink); border-color: transparent; }
.ds-v2 .ds-chip-sky .ds-chip-dot { background: var(--brand-sky); }
.ds-v2 .ds-chip-mint { background: var(--brand-mint-soft); color: var(--brand-mint-ink); border-color: transparent; }
.ds-v2 .ds-chip-mint .ds-chip-dot { background: var(--brand-mint); }
.ds-v2 .ds-chip-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.ds-v2 .ds-chip-success .ds-chip-dot { background: var(--success); }
.ds-v2 .ds-chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.ds-v2 .ds-chip-warn .ds-chip-dot { background: var(--warn); }
.ds-v2 .ds-chip-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.ds-v2 .ds-chip-danger .ds-chip-dot { background: var(--danger); }
.ds-v2 .ds-chip-outline { background: transparent; color: var(--ink-2); border-color: var(--border); }
.ds-v2 .ds-chip-x { background: transparent; border: 0; color: inherit; opacity: 0.6; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px; margin-right: -4px; }
.ds-v2 .ds-chip-x:hover { opacity: 1; }
.ds-v2 .ds-tag-gold {
  background: var(--brand-gold-b); color: #241A06;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: var(--tracking-snug);
  border: 1px solid var(--brand-gold-a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.ds-v2 .ds-chip-gold { background: var(--brand-gold-b); color: #241A06; border: 1px solid var(--brand-gold-a); box-shadow: inset 0 1px 0 rgba(255,255,255,0.6); font-weight: 700; }
.ds-v2 .ds-chip-gold .ds-chip-dot { background: #241A06; opacity: 0.55; }

/* ────── Tier system (new) - Value / Premium / Elite ──────
   Bronze / silver / gold ladder for anything presented as a 3-tier
   choice: service plans, heat-calc sizing options, good/better/best
   line-item presentation. Same gold-bubble rule applies to .elite: flat
   fill, near-black text, no gradient under text. */
.ds-v2 .ds-tier-badge {
  display: inline-flex; align-items: center; font-weight: 700; font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  padding: 3px 10px; border-radius: var(--r-full);
}
.ds-v2 .ds-tier-badge.value { background: linear-gradient(135deg, var(--tier-value-a), var(--tier-value-b)); color: var(--tier-value-ink); }
.ds-v2 .ds-tier-badge.premium { background: linear-gradient(135deg, var(--tier-premium-a), var(--tier-premium-b)); color: var(--tier-premium-ink); }
.ds-v2 .ds-tier-badge.elite { background: var(--brand-gold-b); color: #241A06; border: 1px solid var(--brand-gold-a); box-shadow: inset 0 1px 0 rgba(255,255,255,.6); }

.ds-v2 .ds-tier-card { background: var(--surface); border-radius: var(--r-md); padding: var(--s-4); border: 1.5px solid var(--border); position: relative; }
.ds-v2 .ds-tier-card.value { border-color: var(--tier-value-a); }
.ds-v2 .ds-tier-card.premium { border-color: var(--tier-premium-border); transform: translateY(-4px); box-shadow: var(--sh-md); }
.ds-v2 .ds-tier-card.elite { border-color: var(--brand-gold-a); overflow: hidden; }
.ds-v2 .ds-tier-card.elite::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--brand-gold-grad); }
.ds-v2 .ds-tier-card .ds-tier-price { font-size: var(--text-xl); font-weight: 700; color: var(--ink); margin-top: 10px; }
.ds-v2 .ds-tier-card .ds-tier-price small { font-size: var(--text-sm); color: var(--muted); font-weight: 500; }
.ds-v2 .ds-tier-card .ds-tier-desc { font-size: var(--text-sm); color: var(--ink-2); margin-top: 4px; }

/* Compact tier row - heat-calc sidebar / good-better-best line lists.
   This is the same structure as the live .hc-side-tier component in
   estimate.html; the tick is the only addition. */
.ds-v2 .ds-tier-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px; border-radius: var(--r-sm); }
.ds-v2 .ds-tier-row.recommend { background: var(--accent-soft); }
.ds-v2 .ds-tier-row-tick { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.ds-v2 .ds-tier-row-tick.value { background: linear-gradient(135deg, var(--tier-value-a), var(--tier-value-b)); }
.ds-v2 .ds-tier-row-tick.premium { background: linear-gradient(135deg, var(--tier-premium-a), var(--tier-premium-b)); }
.ds-v2 .ds-tier-row-tick.elite { background: var(--brand-gold-grad); }
.ds-v2 .ds-tier-row-name { flex: 1; font-weight: 600; font-size: var(--text-sm); color: var(--ink); }
.ds-v2 .ds-tier-row-rec { color: var(--accent-ink); font-size: 9.5px; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; margin-left: 6px; }
.ds-v2 .ds-tier-row-price { font-weight: 700; font-size: var(--text-sm); color: var(--ink); }

/* ────── App bar / nav ──────
   Active nav state is unchanged from v1 on purpose: a raised white pill
   with a small gold underline tested better in review than a flat ink
   chip (called out as "boring" against it) - the one place gold appears
   outside a badge/rule, because it's a 2px sliver, not a text-bearing fill. */
.ds-v2 .ds-appbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.3) blur(10px); -webkit-backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 var(--s-5); min-height: 56px;
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--s-4); align-items: center;
}
.ds-v2 .ds-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: var(--tracking-snug); color: var(--ink); }
.ds-v2 .ds-brand-mark {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff;
  display: grid; place-items: center; font-weight: 800;
  overflow: hidden; flex-shrink: 0;
}
.ds-v2 .ds-brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ds-v2 .ds-nav { display: flex; gap: 2px; align-items: center; }
.ds-v2 .ds-nav a {
  padding: 7px 11px; color: var(--ink-2); border-radius: var(--r-sm);
  font-weight: 600; font-size: var(--text-sm);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.ds-v2 .ds-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.ds-v2 .ds-nav a.active { color: var(--accent-ink); background: var(--accent-soft); }

.ds-v2 .ds-theme-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--ink-3); cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ds-v2 .ds-theme-btn:hover { background: var(--surface-2); color: var(--ink); }
.ds-v2 .ds-theme-btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: transparent; }
.ds-v2 .ds-theme-btn svg { width: 18px; height: 18px; display: none; }
/* Two steps, light ↔ dark (2026-10-19): the icon is the theme on screen, the
   device's while nothing is saved. */
:root:not([data-theme="light"]):not([data-theme="dark"]) .ds-v2 .ds-theme-icon-light { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ds-v2 .ds-theme-icon-light { display: none; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .ds-v2 .ds-theme-icon-dark { display: block; }
}
:root[data-theme="light"] .ds-v2 .ds-theme-icon-light { display: block; }
:root[data-theme="dark"] .ds-v2 .ds-theme-icon-dark { display: block; }

.ds-v2 .ds-appbar-menu { display: none; }
@media (max-width: 820px) {
  .ds-v2 .ds-appbar { grid-template-columns: auto auto 1fr auto; }
  .ds-v2 .ds-nav { display: none; }
  .ds-v2 .ds-nav.open {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border-subtle);
    padding: var(--s-2) var(--s-3); box-shadow: var(--sh-md);
  }
  .ds-v2 .ds-nav.open a { padding: 12px 14px; border-radius: var(--r-sm); }
  .ds-v2 .ds-appbar-menu {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--r-sm);
    background: transparent; border: 0; color: var(--ink-2); cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
  }
  .ds-v2 .ds-appbar-menu:hover { background: var(--surface-2); color: var(--ink); }
}

.ds-v2 .ds-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ds-v2 .ds-tab {
  padding: 11px 15px; background: transparent; border: 0; color: var(--ink-3);
  font-family: inherit; font-size: var(--text-sm); font-weight: 600;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.ds-v2 .ds-tab:hover { color: var(--ink); }
.ds-v2 .ds-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.ds-v2 .ds-breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--muted); }
.ds-v2 .ds-breadcrumbs a { color: var(--muted); }
.ds-v2 .ds-breadcrumbs .sep { opacity: 0.5; }
.ds-v2 .ds-breadcrumbs .here { color: var(--ink); font-weight: 600; }

/* ────── Empty / loading ────── */
.ds-v2 .ds-empty { text-align: center; padding: var(--s-12) var(--s-6); color: var(--muted); border: 1px dashed var(--border); border-radius: var(--r-md); background: var(--surface); }
.ds-v2 .ds-empty-icon { margin-bottom: 8px; opacity: 0.5; display: flex; justify-content: center; }
.ds-v2 .ds-empty-icon svg { width: 32px; height: 32px; }
.ds-v2 .ds-empty-title { font-size: var(--text-md); font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.ds-v2 .ds-empty-text { font-size: var(--text-sm); color: var(--muted); max-width: 420px; margin: 0 auto var(--s-4); }
.ds-v2 .ds-skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: ds-shimmer 1.4s infinite; border-radius: var(--r-sm); min-height: 12px;
}
@keyframes ds-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ────── Toast ────── */
.ds-v2 .ds-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r);
  font-size: var(--text-sm); font-weight: 600; box-shadow: var(--sh-lg); z-index: var(--z-toast);
  animation: ds-toast-in var(--dur) var(--ease-out);
}
@keyframes ds-toast-in { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ────── Dialog ────── */
.ds-v2 .ds-dialog-backdrop {
  position: fixed; inset: 0; background: rgba(11, 15, 23, 0.5); backdrop-filter: blur(4px);
  z-index: var(--z-dialog); display: flex; align-items: center; justify-content: center; padding: var(--s-5);
  animation: ds-fade-in var(--dur) var(--ease);
}
.ds-v2 .ds-dialog {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  /* max-height + column flex + min-height:0 on the body. See the long note in
     design-system.css: without all three a too-tall dialog is clipped at BOTH
     ends with no scrollbar anywhere on the dialog or the page. */
  width: min(480px, 100%); max-height: 100%; display: flex; flex-direction: column;
  box-shadow: var(--sh-xl); overflow: hidden;
  animation: ds-pop-in var(--dur) var(--ease-out);
}
/* A closed native <dialog class="ds-dialog"> stays hidden: the author
   `display: flex` above beats the browser's own dialog:not([open]) rule. See
   the note in design-system.css (Richard, 2026-09-28). */
.ds-v2 dialog.ds-dialog:not([open]) { display: none; }
@keyframes ds-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ds-pop-in { from { transform: scale(0.98) translateY(6px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.ds-v2 .ds-dialog-head { flex: 0 0 auto; padding: 16px 18px; border-bottom: 1px solid var(--border-subtle); }
/* 🔴 THE CLOSE X SAT UNDER THE TITLE, AND THE HEAD WAS TWICE AS TALL (Richard,
   2026-10-01, the plan page Book visit: "that X below the book a plan visit
   wording. It should be all the way to the right. And that header should not
   be that tall"). .ds-dialog-head was a plain block, so its title (a block
   heading) took the whole line and the close button wrapped onto a second one
   under it. A head that carries a .ds-dialog-title is the title-and-close
   pattern: ONE row, the title on the left, the close at the far right, the
   head's own padding. The same gap and centring as .ds-cluster, so a head
   that already made itself a row that way (plan-cancel-dialog.js,
   plan-remainder-block.js) looks exactly as before. A head without a
   .ds-dialog-title (a heading with a line under it: team-create.js,
   estimate.js) keeps its block layout. tests/ds-dialog-head-row.test.js. */
.ds-v2 .ds-dialog-head:has(> .ds-dialog-title) { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.ds-v2 .ds-dialog-title { margin: 0; min-width: 0; }
.ds-v2 .ds-dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 18px; color: var(--ink-2); font-size: var(--text-base); }

/* 🔴 THESE TWO CLASSES ARE USED AND WERE NEVER DEFINED, and the dialog fix above
   is what makes that matter. public/tools/money.html:464 and :508 are dialogs
   whose SOLE child is <form class="ds-dialog-form">, and plan.html:121 is the
   same shape with .ds-dialog-inner - so head, body and foot are GRANDCHILDREN of
   the flex container, the `flex: 1 1 auto; min-height: 0` on .ds-dialog-body
   applies to nothing, and the whole form overflows into the `overflow: hidden`
   above with no scrollbar. That is the exact bug just fixed, reintroduced one
   level down. The wrapper has to forward the column flex through itself. */
.ds-v2 .ds-dialog-form,
.ds-v2 .ds-dialog-inner { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.ds-v2 .ds-dialog-foot { flex: 0 0 auto; padding: 11px 18px; border-top: 1px solid var(--border-subtle); background: var(--surface-2); display: flex; justify-content: flex-end; gap: 8px; }


/* ────── Sortable table headers ────── */
/* Defined here rather than on a page, because a <style> block in a tool page
   raises scripts/check-ui-consistency.js's inline_style count above its baseline
   and fails CI. aria-sort drives the arrow, so the visual state and the state a
   screen reader announces cannot disagree.
   🔴 Glyphs are U+21C5 / U+25B2 / U+25BC, all below U+2600, so they pass the
   design-system-v2 section 10 emoji audit. Do not reach for the coloured
   triangles. */
.ds-v2 .ds-table th.ds-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.ds-v2 .ds-table th.ds-sortable:hover { color: var(--ink); }
.ds-v2 .ds-table th.ds-sortable:focus-visible { outline: 2px solid var(--brand-royal); outline-offset: -2px; }
.ds-v2 .ds-table th.ds-sortable::after { content: ' \21C5'; opacity: .35; font-size: .85em; }
.ds-v2 .ds-table th.ds-sortable[aria-sort="ascending"]::after { content: ' \25B2'; opacity: 1; color: var(--brand-royal); }
.ds-v2 .ds-table th.ds-sortable[aria-sort="descending"]::after { content: ' \25BC'; opacity: 1; color: var(--brand-royal); }
.ds-v2 .ds-table thead th.num,
.ds-v2 .ds-table td.num { text-align: right; }

/* A table wider than its container needs somewhere to go. .ds-table-wrap is
   `overflow: hidden` so its border radius clips the table corners, which also
   means a wide table is simply cut off with no scrollbar. A modifier rather than
   a change to the base rule, so no existing table's radius is disturbed. */
.ds-v2 .ds-table-scroll { overflow-x: auto; }

/* ────── Utilities ────── */
.ds-v2 .ds-hide-sm { }
.ds-v2 .ds-show-sm { display: none; }
@media (max-width: 640px) { .ds-v2 .ds-hide-sm { display: none !important; } .ds-v2 .ds-show-sm { display: initial; } }
.ds-v2 .ds-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; }

/* ────── Icon system (new) ──────
   .ds-icon wraps every inline <svg data-icon>. Fixed square box, fixed
   stroke - no more emoji, no more mismatched stroke widths between hand
   -copied SVGs. See design-system-v2.md §5 for the full icon set. */
.ds-v2 .ds-icon { width: var(--icon-md); height: var(--icon-md); flex-shrink: 0; display: inline-flex; }
.ds-v2 .ds-icon svg { width: 100%; height: 100%; display: block; stroke-width: var(--icon-stroke); }
.ds-v2 .ds-icon-sm { width: var(--icon-sm); height: var(--icon-sm); }
.ds-v2 .ds-icon-lg { width: var(--icon-lg); height: var(--icon-lg); }

/* Icon tiles - solid brand-color squares for icons that need to stand
   alone (quick actions, empty states, sidebar section markers). Plain
   .ds-icon stroke icons (no tile) are for icons that sit inline with
   text - table rows, kebabs, buttons - so the UI doesn't turn into
   confetti. Tiles are opaque solid fills, so they hold contrast in both
   themes without any dark-mode-specific override. */
.ds-v2 .ds-icon-tile {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ds-v2 .ds-icon-tile svg { width: 20px; height: 20px; stroke-width: 2; }
.ds-v2 .ds-icon-tile.royal { background: var(--brand-royal); box-shadow: 0 3px 8px -2px rgba(61,124,201,.4); }
.ds-v2 .ds-icon-tile.royal svg { stroke: #fff; }
.ds-v2 .ds-icon-tile.sky { background: var(--brand-sky); box-shadow: 0 3px 8px -2px rgba(0,160,223,.4); }
.ds-v2 .ds-icon-tile.sky svg { stroke: #fff; }
.ds-v2 .ds-icon-tile.gold { background: var(--brand-gold-grad); box-shadow: 0 3px 8px -2px rgba(212,169,74,.45); }
.ds-v2 .ds-icon-tile.gold svg { stroke: #4A3312; }
.ds-v2 .ds-icon-tile.mint { background: var(--brand-mint); box-shadow: 0 3px 8px -2px rgba(46,217,195,.4); }
.ds-v2 .ds-icon-tile.mint svg { stroke: #0B0F17; }
.ds-v2 .ds-icon-tile-sm { width: 32px; height: 32px; border-radius: var(--r); }
.ds-v2 .ds-icon-tile-sm svg { width: 16px; height: 16px; }

/* ────── Wizard chrome carve-out - unchanged ────── */
.ds-v2 body[data-htos-chrome="wizard"] #htos-shell-root > .htos-appbar,
.ds-v2 body[data-htos-chrome="wizard"] #htos-shell-root > .htos-aidrawer,
.ds-v2 body[data-htos-chrome="wizard"] #htos-shell-root > .htos-aidrawer-handle { display: none !important; }
.ds-v2 body[data-htos-chrome="wizard"] { margin: 0; padding: 0; background: var(--surface); }

/* ======================================================================
   Chrome modernization v2 - restyles the shell.js-injected legacy
   .htos-* appbar. Active state keeps v1's raised white pill + gold
   underline (approved as-is); search, icon buttons, +New, and avatar get
   the v2 flat/hairline treatment to match buttons and cards elsewhere.
   ====================================================================== */
.ds-v2 .htos-appbar {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.2) blur(14px); backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid var(--border-subtle); box-shadow: none; min-height: 56px;
}
.ds-v2 .htos-navlinks a {
  position: relative; border-radius: var(--r-full); padding: 0.42rem 0.85rem; letter-spacing: var(--tracking-snug);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring);
}
.ds-v2 .htos-navlinks a:hover { background: var(--surface-2); transform: translateY(-1px); }
.ds-v2 .htos-navlinks a.active {
  color: var(--accent-ink);
  background: var(--surface);
  box-shadow: var(--sh-sm);
}
.ds-v2 .htos-navlinks a.active::after {
  content: "";
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 3px;
  width: 16px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--brand-gold-a), var(--brand-gold-b));
}
.ds-v2 .htos-navlinks a.active:hover { transform: none; }
.ds-v2 .htos-search { border-radius: var(--r); background: var(--surface-2); border-color: var(--border-subtle); transition: box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.ds-v2 .htos-search:focus-within { border-color: var(--brand-royal); box-shadow: var(--ring); }
.ds-v2 .htos-iconbtn { border-radius: var(--r-sm); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.ds-v2 .htos-iconbtn:hover { background: var(--surface-2); }
.ds-v2 .htos-iconbtn:active { transform: scale(0.94); }
.ds-v2 .htos-newbtn { background: var(--ink); color: var(--bg); box-shadow: none; border-radius: var(--r); transition: filter var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.ds-v2 .htos-newbtn:hover { box-shadow: var(--sh-sm); }
.ds-v2 .htos-newbtn:active { transform: translateY(0.5px); }
.ds-v2 .htos-avatar { transition: box-shadow var(--dur-fast) var(--ease); border-radius: var(--r-full); }
.ds-v2 .htos-avatar:hover { box-shadow: var(--ring); }

@media (prefers-reduced-motion: reduce) {
  .ds-v2 .htos-navlinks a,
.ds-v2 .htos-iconbtn,
.ds-v2 .htos-newbtn,
.ds-v2 .htos-avatar { transition: none; }
}
