/*
 * tokens.css — CSS reset, design tokens, and theme definitions.
 *
 * This file provides two things:
 *
 * 1. A minimal CSS reset (replacing Tailwind's Preflight) that sets
 *    border-box sizing, zero margins, inherited fonts, and sane defaults
 *    for media and form elements. The entire app was built against these
 *    rules — do not remove them without auditing every view.
 *
 * 2. All CSS custom properties that the design system depends on:
 *    color palette, semantic theme aliases, spacing base, shadows, font
 *    family, form widths, and light/dark theme blocks. Domain CSS files
 *    reference these via var(--color-*), calc(var(--spacing) * N), etc.
 *
 * Load order (set in app/views/layouts/application.html.erb):
 *   1. trix         — Trix editor base styles
 *   2. tokens.css   — this file (reset + :root tokens)
 *   3. primitives   — composable layout classes + font/radius/transition tokens
 *   4. components   — domain component classes
 *   ...area files
 *
 * NOT linted by bin/lint-design-css — tokens legitimately contain hex colors
 * and raw values that domain CSS files must not use directly.
 */


/* ─── CSS Reset ─── */

*,
::before,
::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
}

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  font-family: var(--font-sans);
}

body {
  margin: 0;
  line-height: inherit;
}

/* Component color transitions must not animate from browser defaults while
 * the initial stylesheets resolve. The head theme initializer removes this
 * guard after the first fully styled frame. */
html[data-theme-initializing] *,
html[data-theme-initializing] *::before,
html[data-theme-initializing] *::after {
  transition: none !important;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

p, blockquote, dl, dd, figure, pre, hr {
  margin: 0;
}

ol, ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/*
 * The `hidden` attribute is only a User-Agent rule (lowest priority), so any
 * author `display` declaration (e.g. .stack, .cluster, grid utilities) silently
 * overrides it and the element stays visible. Force it to win everywhere so
 * `hidden`/`element.hidden = true` reliably hides, matching author expectations.
 */
[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: inherit;
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

/*
 * Turbo stream-source elements are connection-only and never visual. Hide them
 * so they don't occupy a slot in flex/grid stacks (e.g. a turbo_stream_from
 * inside a .stack-lg column would otherwise add an extra gap).
 */
turbo-cable-stream-source {
  display: none;
}

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

button, input, optgroup, select, textarea {
  font-family: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

button, [role="button"] {
  cursor: pointer;
  background: transparent;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

hr {
  height: 0;
  border-top-width: 1px;
  color: inherit;
}

::placeholder {
  opacity: 1;
  color: var(--color-text-muted);
}


/* ─── Design tokens ─── */

:root {
  /* Spacing base — used in calc(var(--spacing) * N) throughout domain CSS. */
  --spacing: 0.25rem;

  /* Colors — static palette (always available regardless of theme) */
  --color-black: #050505;
  --color-white: #FFFFFF;
  --color-blue-light: #7AB5E8;
  --color-blue: #176bb0;
  --color-blue-dark: #0f5589;
  --color-blue-strong: #176bb0; /* deep enough to carry white text at WCAG AA (5.6:1) */
  --color-cream: #FCFBE3;
  --color-gray-50: #FAFAFA;
  --color-gray-100: #F4F4F5;
  --color-gray-200: #E4E4E7;
  --color-gray-300: #D4D4D8;
  --color-gray-400: #A1A1AA;
  --color-gray-500: #71717A;
  --color-gray-600: #52525B;
  --color-gray-700: #3F3F46;
  --color-gray-800: #27272A;
  --color-gray-850: #222225;
  --color-gray-900: #18181B;
  --color-gray-1000: #111114;
  --color-gray-1100: #0C0C0F;
  /* Hue family — the brand hues, taken from the marketing site's canonical
   * palette (via-marketing src/theme/palette.js) so the app and the marketing
   * site are the same green, the same red, the same amber.
   *
   * There is one hue family, not two. Identity chrome (module signature hues,
   * app-switcher tiles, tile glows) and meaning (statuses, badges, deltas)
   * both draw from these tokens, so a module's icon chip and its records'
   * status pills read as the same green rather than as two greens that nearly
   * match. Calm comes from the treatment, not from desaturating the hue: a
   * status is a 15–25% tint of its hue carrying --color-status-text-*, never
   * a solid fill. See the Colors section of DESIGN.md.
   *
   * Each family runs base → -dark from the marketing ramp; the -light sibling
   * is the base at 65% over white (one step lighter, the same step for every
   * hue). --color-yellow-extra-light is the base at 20% over white, the pale
   * wash the audiences warning notice sits on.
   *
   * --color-yellow-orange* is the one bridge step, the midpoint of the amber
   * and orange ramps. It stays a name of its own because the builder topbar
   * shows a draft dot and a saving dot that have to be two separable ambers.
   *
   * Which of the two steps a mark is painted with is a theme decision, not a
   * per-element one — see the presentation-strength tokens (--color-*-mark)
   * declared in the two theme blocks at the bottom of this file. */
  --color-green-light: #89EAAC;
  --color-green: #4ADE80;
  --color-green-dark: #16A34A;
  --color-orange-light: #FBA468;
  --color-orange: #F97316;
  --color-orange-dark: #B8650F;
  --color-purple-light: #D6AFFD;
  --color-purple: #C084FC;
  --color-purple-dark: #9333EA;
  --color-red-light: #FAA3A3;
  --color-red: #F87171;
  --color-red-dark: #DC2626;
  --color-yellow-extra-light: #FEF2D3;
  --color-yellow-light: #FCD571;
  --color-yellow: #FBBF24;
  --color-yellow-dark: #D97706;
  --color-yellow-orange-light: #FCBD6C;
  --color-yellow-orange: #FA991D;
  --color-yellow-orange-dark: #C86E0A;

  /* Identity-only extras — pink, teal, and slate. They carry no meaning and
   * never appear in a status; they exist so a module that needs a signature
   * of its own can have one. Each runs base → -dark like every other family,
   * so the presentation-strength tokens below can flip them with the theme.
   *
   * Pink's pair is the marketing palette's pinkLight/pink. Teal and slate have
   * no deep sibling in the marketing palette, so each takes the 600-level step
   * of the ramp it came from — the same step green-dark (#16A34A), purple-dark
   * (#9333EA), red-dark (#DC2626), and pink-dark (#db2777) all sit on — which
   * puts every family's deep sibling the same distance below its base. */
  --color-pink: #f472b6;
  --color-pink-dark: #db2777;
  --color-teal: #2dd4bf;
  --color-teal-dark: #0d9488;
  --color-slate: #94a3b8;
  --color-slate-dark: #475569;

  --color-brand-primary: var(--color-primary);
  --color-brand-secondary: var(--color-secondary);

  /* Identity aliases — the names the identity surfaces already use, pointing
   * at the one hue family above. There is no separate vivid palette to keep
   * in step with the semantic one: emerald IS the green, rose IS the red,
   * violet IS the purple, so a module chip and a status pill on the same row
   * are the same object.
   *
   * -amber-deep is the exception: its only consumer paints small text on a
   * 14% amber tint, which is the status-ink job, so it resolves to the yellow
   * ramp's ink rather than to a raw hue that cannot carry text.
   *
   * Pink, teal, and slate are identity-only extras — hues the semantic family
   * has no use for, kept so modules that need a signature of their own can
   * have one. They carry no meaning and never appear in a status.
   *
   * Every one of these resolves to its family's presentation-strength face
   * (--color-*-mark), so a module signature is the deep sibling on Cool Paper
   * and the base hue on Studio Dark. Blue is the one brand blue and already
   * flips that way through --color-accent, which is the model the -mark tokens
   * generalise: an identity hue is one object that presents at the strength
   * its background can carry. */
  --color-vivid-slate: var(--color-slate-mark);
  --color-vivid-blue: var(--color-accent);
  --color-vivid-amber: var(--color-yellow-mark);
  --color-vivid-amber-deep: var(--color-status-text-yellow);
  --color-vivid-violet: var(--color-purple-mark);
  --color-vivid-emerald: var(--color-green-mark);
  --color-vivid-rose: var(--color-red-mark);
  --color-vivid-orange: var(--color-orange-mark);
  --color-vivid-pink: var(--color-pink-mark);
  --color-vivid-teal: var(--color-teal-mark);

  /* Task-surface fills — the hue family under the names the client
   * dashboard's status pills, priority pills, timer pings, and
   * asset-approval banners already use. */
  --color-task-slate: var(--color-vivid-slate);
  --color-task-blue: var(--color-vivid-blue);
  --color-task-amber: var(--color-vivid-amber);
  --color-task-amber-dark: var(--color-vivid-amber-deep);
  --color-task-violet: var(--color-vivid-violet);
  --color-task-emerald: var(--color-vivid-emerald);
  --color-task-rose: var(--color-vivid-rose);
  --color-task-orange: var(--color-vivid-orange);

  /* Customer-profile insights palette — a single blue hue family used across
   * the insight profile's charts: bar fills, donut segments, the match-rate
   * ring, section icons, and lightbulb badges. Anchored on --color-accent so
   * charts stay in the brand-blue family and adapt per theme; the tints lighten
   * toward white so donut/bar segments stay distinguishable, and the bg/border
   * alphas back the context chip and icon badges. */
  --color-insights-accent: var(--color-accent);
  --color-insights-accent-tint-2: color-mix(in srgb, var(--color-accent) 70%, var(--color-white));
  --color-insights-accent-tint-3: color-mix(in srgb, var(--color-accent) 45%, var(--color-white));
  --color-insights-accent-tint-4: color-mix(in srgb, var(--color-accent) 22%, var(--color-white));
  --color-insights-accent-bg-subtle: color-mix(in srgb, var(--color-accent) 8%, transparent);
  --color-insights-accent-bg: color-mix(in srgb, var(--color-accent) 10%, transparent);
  --color-insights-accent-border: color-mix(in srgb, var(--color-accent) 20%, transparent);

  /* Module-upsell palette — accent, platform-badge, status-pill, and dark-band
   * hues for the paid-module upsell surface (.component-upsell). Like
   * --color-task-*, these are platform-specific values the hue family can't
   * deliver, kept here (the linter-exempt token file) so the component stays
   * token-only. The accent's -strong (text) variant has a lighter dark-mode
   * sibling (-strong-dark) the component swaps in under
   * [data-theme="dark"]. The Meta / Google badge hues are the platforms' own
   * brand colors. The band is a fixed dark marketing surface, so its hues are
   * theme-independent. */
  --color-upsell-ads: var(--color-vivid-orange);
  --color-upsell-ads-strong: #c2410c;
  --color-upsell-ads-strong-dark: #fdba74;
  --color-upsell-email: var(--color-vivid-pink);
  --color-upsell-email-strong: #be185d;
  --color-upsell-email-strong-dark: #f9a8d4;

  --color-upsell-meta-bg: #e7f3ff;
  --color-upsell-meta-fg: #0082fb;
  --color-upsell-google-bg: #e8f0fe;
  --color-upsell-google-fg: #4285f4;

  /* The preview's status pills are a facsimile of a VIA surface, so they take
   * the badge recipe the real pills do rather than a solid fill. */
  --color-upsell-status-active-bg: var(--theme-badge-green-bg);
  --color-upsell-status-active-border: var(--theme-badge-green-border);
  --color-upsell-status-active-text: var(--theme-badge-green-text);
  --color-upsell-status-scheduled-bg: var(--theme-badge-blue-bg);
  --color-upsell-status-scheduled-border: var(--theme-badge-blue-border);
  --color-upsell-status-scheduled-text: var(--theme-badge-blue-text);
  --color-upsell-status-sending-bg: var(--theme-badge-yellow-bg);
  --color-upsell-status-sending-border: var(--theme-badge-yellow-border);
  --color-upsell-status-sending-text: var(--theme-badge-yellow-text);

  --color-upsell-band-bg: #0b0d10;
  --color-upsell-band-text: #f5f7fa;
  --color-upsell-band-text-dim: rgba(245, 247, 250, 0.62);
  --color-upsell-band-border: rgba(255, 255, 255, 0.08);
  --color-upsell-band-scrim: rgba(14, 16, 20, 0.55);
  --color-upsell-band-stat-bg: rgba(14, 16, 20, 0.38);
  --color-upsell-band-stat-border: rgba(255, 255, 255, 0.22);
  --color-upsell-band-stat-shadow: rgba(0, 0, 0, 0.18);
  --color-upsell-band-stat-value-shadow: rgba(0, 0, 0, 0.35);
  --color-upsell-band-stat-label: rgba(255, 255, 255, 0.9);
  --color-upsell-band-stat-label-shadow: rgba(0, 0, 0, 0.3);

  /* Semantic theme colors (resolve to CSS custom properties set by theme) */
  --color-surface-body: var(--theme-bg-body);
  --color-surface-sidebar: var(--theme-bg-sidebar);
  --color-surface-primary: var(--theme-bg-surface);
  --color-surface-elevated: var(--theme-bg-elevated);
  --color-surface-input: var(--theme-bg-input);
  --color-surface-hover: var(--theme-bg-hover);
  --color-surface-quick-action: var(--theme-bg-quick-action);
  --color-surface-private: var(--theme-bg-private);

  /* The one scrim: the wash a modal or a drawer lays over the page it has just
   * made inert. Both wear the same token because both mean the same thing —
   * everything under this is out of reach until you deal with what is over it.
   *
   * It carries a per-theme strength for the reason the auth backdrop washes do:
   * a scrim is read by how far it moves the page away from where it was, and on
   * Studio Dark the page is already near black. Cool Paper's 32% takes #f4f6f9
   * down to about #a6a8ab — an unmistakable step. The same 32% on Studio Dark
   * takes #0d0d0e to #0a0a0a, a step of three values out of 255 that nobody can
   * see, which is why the dark share runs more than twice as heavy. */
  --color-scrim: var(--theme-scrim);

  --color-border-themed: var(--theme-border-primary);
  --color-border-strong: var(--theme-border-secondary);
  --color-border-subtle: var(--theme-border-subtle);
  /* Hairline used between rows inside hairline-divided lists (admin table,
   * admin-detail-list-card). Equals --color-border-subtle in light mode,
   * but bumps one step up in dark mode so the divider stays readable on
   * the deep surface — -subtle in dark collapses too close to the row bg. */
  --color-border-row: var(--theme-border-row);

  /* Loading skeleton blocks: the resting fill and the brighter band that
   * sweeps across it. Their own aliases because the sweep needs a step big
   * enough to read as motion in both themes, and no surface pair gives that
   * — -elevated to -hover is a ~3% step in light mode, which looks static. */
  --color-skeleton-base: var(--theme-bg-elevated);
  --color-skeleton-highlight: var(--theme-border-secondary);

  --color-text-heading: var(--theme-text-primary);
  --color-text-body: var(--theme-text-secondary);
  --color-text-muted: var(--theme-text-muted);
  --color-text-hover: var(--theme-text-hover);
  --color-text-inverted: var(--theme-text-inverted);
  --color-text-input: var(--theme-text-input);
  /* Ink for glyphs and labels sitting on a full-strength hue fill — see
   * --theme-text-on-vivid in the theme blocks. */
  --color-text-on-vivid: var(--theme-text-on-vivid);

  /* Status ink — the one recipe for text and icons that carry status
   * meaning: the hue's -dark sibling deepened halfway toward the theme's
   * heading ink. One declaration serves both themes because the ink token
   * flips with the theme, so the mix darkens on Cool Paper and lightens on
   * Studio Dark.
   *
   * This is where the calm comes from. The hue itself is a full brand hue —
   * it is the tint-plus-ink treatment, not a desaturated pigment, that keeps
   * a screen full of statuses quiet. The raw -dark siblings cannot carry text
   * on their own tint (yellow bottoms out at 2.4:1); mixed to 50% heading ink
   * every hue keeps its identity and clears WCAG AA on a plain surface and on
   * an 18% tint of itself, in both themes — measured low point 5.17:1 (gray,
   * on a tinted elevated surface in dark).
   *
   * All six hues use the same 50% ratio, purple included: with a real purple
   * ramp behind it, --color-purple-dark mixes to a deep violet that still
   * reads purple, so purple no longer needs the base-derived exception it
   * carried when its -dark sibling was a near-black. */
  --color-status-text-green: color-mix(in srgb, var(--color-green-dark) 50%, var(--color-text-heading));
  --color-status-text-yellow: color-mix(in srgb, var(--color-yellow-dark) 50%, var(--color-text-heading));
  --color-status-text-orange: color-mix(in srgb, var(--color-orange-dark) 50%, var(--color-text-heading));
  --color-status-text-red: color-mix(in srgb, var(--color-red-dark) 50%, var(--color-text-heading));
  --color-status-text-purple: color-mix(in srgb, var(--color-purple-dark) 50%, var(--color-text-heading));
  --color-status-text-blue: color-mix(in srgb, var(--color-accent) 50%, var(--color-text-heading));
  /* The bridge step gets an ink of its own for the same reason the hue does:
   * the kanban card's approval line and its blocking glyph are two separable
   * ambers, and the approval line is text, so it needs the ink face rather
   * than the mark face (raw --color-yellow-orange measured 2.0:1 on a card). */
  --color-status-text-yellow-orange: color-mix(in srgb, var(--color-yellow-orange-dark) 50%, var(--color-text-heading));

  --color-text-success: var(--color-status-text-green);
  --color-text-warning: var(--color-status-text-yellow);
  --color-text-danger: var(--color-status-text-red);
  /* Hover face for destructive text and icon buttons — the danger ink taken
   * one step further toward the heading ink, so "delete" deepens on hover the
   * way the old raw --color-red → --color-red-dark pair did, without either
   * face being a raw hue that cannot carry text. */
  --color-text-danger-hover: color-mix(in srgb, var(--color-status-text-red) 65%, var(--color-text-heading));

  /* Badge colors (BadgeComponent + the .badge-* utilities below) — the status
   * recipe: an 18% tint of the hue for the background, the status ink above
   * for the text, a 35% tint of the same hue for the hairline. Blue is the
   * brand accent (One Blue Rule); gray comes from the neutral family.
   *
   * These sit in :root rather than in the two theme blocks because every
   * value is built from tokens that already flip with the theme, so one
   * declaration renders correctly under both lighting conditions — a tinted
   * mix over Cool Paper darkens, the same mix over Studio Dark lightens. The
   * --theme- prefix is kept so the ~30 existing consumers stay untouched. */
  --theme-badge-green-bg: color-mix(in srgb, var(--color-green) 18%, transparent);
  --theme-badge-green-text: var(--color-status-text-green);
  --theme-badge-green-border: color-mix(in srgb, var(--color-green) 35%, transparent);
  --theme-badge-yellow-bg: color-mix(in srgb, var(--color-yellow) 18%, transparent);
  --theme-badge-yellow-text: var(--color-status-text-yellow);
  --theme-badge-yellow-border: color-mix(in srgb, var(--color-yellow) 35%, transparent);
  --theme-badge-blue-bg: color-mix(in srgb, var(--color-accent) 18%, transparent);
  --theme-badge-blue-text: var(--color-status-text-blue);
  --theme-badge-blue-border: color-mix(in srgb, var(--color-accent) 35%, transparent);
  --theme-badge-orange-bg: color-mix(in srgb, var(--color-orange) 18%, transparent);
  --theme-badge-orange-text: var(--color-status-text-orange);
  --theme-badge-orange-border: color-mix(in srgb, var(--color-orange) 35%, transparent);
  --theme-badge-red-bg: color-mix(in srgb, var(--color-red) 18%, transparent);
  --theme-badge-red-text: var(--color-status-text-red);
  --theme-badge-red-border: color-mix(in srgb, var(--color-red) 35%, transparent);
  --theme-badge-gray-bg: color-mix(in srgb, var(--color-text-muted) 15%, transparent);
  --theme-badge-gray-text: var(--color-text-body);
  --theme-badge-gray-border: color-mix(in srgb, var(--color-text-muted) 30%, transparent);
  --theme-badge-purple-bg: color-mix(in srgb, var(--color-purple) 18%, transparent);
  --theme-badge-purple-text: var(--color-status-text-purple);
  --theme-badge-purple-border: color-mix(in srgb, var(--color-purple) 35%, transparent);

  --color-accent: var(--theme-accent);
  --color-accent-subtle: var(--theme-accent-subtle);
  --color-accent-border: var(--theme-accent-border);
  --color-accent-hover: var(--theme-accent-hover);
  /* Deeper accent variant for accent text/links that need extra contrast.
     Light mode matches --color-accent (already AA-safe at #176bb0); dark mode
     runs a touch deeper than the brightened accent. */
  --color-accent-strong: var(--theme-accent-strong);
  --color-accent-strong-hover: var(--theme-accent-strong-hover);

  /* Focus ring — single source for input/textarea/select focus styling.
   * Accent border + accent-tinted ring. Built from --color-accent via
   * color-mix, so it tracks the active theme automatically (one definition,
   * no per-theme override). Reference as box-shadow: var(--focus-ring); never
   * hardcode the rgba. --focus-ring-error is the red variant for invalid fields.
   *
   * Contrast requirement: WCAG 1.4.11 (Non-text Contrast) requires focus
   * indicators to clear 3:1 against their adjacent backdrop. The mix % is
   * effectively the ring's alpha when composited over whatever sits behind
   * it, so it's set to 70% — measured at ~3.11:1 against white in light mode
   * and ~3.75:1 against the dark theme's input surface (#1e1f22) in dark
   * mode. --focus-ring-error is raised by the same amount for consistency. */
  --focus-ring: 0 0 0 0.1875rem color-mix(in srgb, var(--color-accent) 70%, transparent);
  --focus-ring-error: 0 0 0 0.1875rem color-mix(in srgb, var(--color-red) 70%, transparent);

  /* App identity — colored tiles in the sidebar app switcher
   * (AppSwitcherComponent). Module-identity hues used only as tinted
   * tile backgrounds + glyph color, never for CTAs. */
  --color-app-via: var(--color-accent);
  --color-app-admin: var(--theme-dashboard-purple);
  --color-app-core: var(--color-vivid-emerald);

  /* Module identity — one signature hue per app module, keyed by the module
   * key ModuleThemeHelper uses (the same string as the sidebar i18n label).
   * ModuleThemeHelper::MODULE_THEMES resolves each entry's color to the token
   * below, so a module's hue is declared once here instead of as a hex literal
   * in Ruby.
   *
   * Identity only: eyebrow chips, active sidebar icons, icon badges, tile
   * glows. Primary CTAs stay --color-accent on every page (see the Module
   * Identity Rule in DESIGN.md), so "act here" never changes color by section.
   *
   * The modules that carry a hue of their own draw it from the one hue family
   * above, through the identity aliases: a signature color is the same object
   * under both lighting conditions, and the same object as the status that
   * hue means elsewhere — an audiences icon chip and a Ready pill are one
   * green. The modules with no signature of their own point at --color-accent rather
   * than repeating its light-theme hex, so they theme-shift with every other
   * blue on the page — a frozen #176bb0 would be a second blue in dark mode,
   * which the One Blue Rule in DESIGN.md rules out. */
  --color-module-dashboard: var(--color-accent);
  --color-module-audiences: var(--color-vivid-emerald);
  --color-module-databases: var(--color-vivid-violet);
  --color-module-vault: var(--color-vivid-slate);
  --color-module-vendor-vault: var(--color-vivid-slate);
  --color-module-email-campaigns: var(--color-vivid-pink);
  --color-module-direct-mail: var(--color-vivid-teal);
  --color-module-ad-services: var(--color-vivid-orange);
  --color-module-data-tools: var(--color-accent);
  --color-module-insights: var(--color-accent);
  --color-module-imports: var(--color-vivid-violet);
  --color-module-my-tasks: var(--color-accent);
  --color-module-client-rollup: var(--color-accent);
  --color-module-team-capacity: var(--color-accent);
  --color-module-team-assignments: var(--color-accent);
  --color-module-settings: var(--color-accent);
  --color-module-admin: var(--color-accent);
  --color-module-core: var(--color-accent);
  /* The market dashboard's four headline figures: addressable market,
   * personas, locations and campaigns. Deep on Cool Paper, bright on Studio
   * Dark, like every other signature. */
  --color-module-tam: var(--theme-module-tam);
  --color-module-personas: var(--theme-module-personas);
  --color-module-locations: var(--theme-module-locations);
  --color-module-campaigns: var(--theme-module-campaigns);

  /* Market dashboard section — the gray stage the market sits on, one step
   * darker than the page, so it reads as its own section apart from the
   * white cards below it. */
  --color-bg-section: var(--theme-bg-section);
  --color-border-section: var(--theme-border-section);

  /* Persona palette — an account's personas take these in order, the first
   * persona the first hue. Checked for colorblind separation on both surfaces
   * (#ffffff, #16171a), so each persona is the same hex in both themes. The
   * sixth is the brand blue: personas always show with their names, so color
   * is never the only label. Categorical identity, never status. */
  --color-persona-1: #4f46e5;
  --color-persona-2: #e8590c;
  --color-persona-3: #0d9488;
  --color-persona-4: #c026d3;
  --color-persona-5: #a16207;
  --color-persona-6: #176bb0;

  /* Persona palette on the market dashboard's dark panel — lighter steps of
   * the persona hues for a dark ground (task 2869). 1-3 are the design's own
   * values; 4-6 keep their hue and take the lightness and chroma that hold
   * every neighbor apart for normal, protan and deutan vision (OKLab
   * distance of at least 10.8, the design's own 1-3 worst), checked as a set in
   * design-conflicts.md (C23). The panel is dark in both themes, so these
   * are too. */
  --color-persona-1-on-dark: #be9cf8;
  --color-persona-2-on-dark: #f9ab77;
  --color-persona-3-on-dark: #7dd6c7;
  --color-persona-4-on-dark: #bd88c4;
  --color-persona-5-on-dark: #c7925b;
  --color-persona-6-on-dark: #97d4ff;
  --color-market-customers-on-dark: #55a8f0;

  /* The check mark inside a filled segment check circle, one per color
   * above. 1-3 are the design's darkest stroke cores; 4-6 and customers keep
   * their segment's hue at the mean of 1-3's lightness (OKLCH L 0.259) and
   * chroma ratio (x0.543). */
  --color-persona-1-check-on-dark: #261b4e;
  --color-persona-2-check-on-dark: #2a1006;
  --color-persona-3-check-on-dark: #043437;
  --color-persona-4-check-on-dark: #301a33;
  --color-persona-5-check-on-dark: #341e04;
  --color-persona-6-check-on-dark: #0a2638;
  --color-market-customers-check-on-dark: #002544;

  /* Market dashboard dark panel ("Your market, in focus.") — dark in both
   * themes, values measured from the design (docs/plans/market-dashboard/
   * mock-measurements.md). The header zone carries a soft glow top right;
   * the band under it (segments and map) runs a little darker. */
  --color-market-panel-bg: #151e27;
  --color-market-panel-glow: #182839;
  --color-market-panel-border: #252f38;
  --color-market-panel-band-start: #0e171e;
  --color-market-panel-band-middle: #101922;
  --color-market-panel-band-end: #131d27;
  --color-market-panel-heading: #ffffff;
  --color-market-panel-accent-text: #a5d3f2;
  --color-market-panel-eyebrow: #a2cbe9;
  --color-market-panel-eyebrow-dot: #4fb8ef;
  --color-market-panel-rule: #66707a;
  --color-market-panel-subline: #aeb8c2;
  --color-market-panel-caption: #8995a1;
  --color-market-panel-label: #808e9b;
  --color-market-panel-tabs-bg: #202a34;
  --color-market-panel-tabs-border: #323a45;
  --color-market-panel-tab-active: var(--color-blue-strong);
  --color-market-panel-tab-text: #a7b3bf;
  --color-market-segment-bg: #1e252d;
  --color-market-segment-border: #3d4751;
  --color-market-segment-off-bg: #161e2b;
  --color-market-segment-off-border: #2c3441;
  --color-market-segment-name: #ebf4fb;
  --color-market-segment-description: #79828b;
  --color-market-segment-ring: #434b58;
  --color-market-frame-border: #40536a;
  --color-market-frame-bg: #13283b;

  /* The market map inside the dark panel (task 2869, measured from the
   * design): the store pin, its city label, the zoom stack and the hint, and
   * the dark-ground stand-ins for the theme's map colors. */
  --color-market-pin-fill: #ffffff;
  --color-market-pin-ring: #3a8cc4;
  --color-market-pin-icon: #226194;
  --color-market-pin-label: #ffffff;
  --color-market-map-control-bg: #11202e;
  --color-market-map-control-divider: #283845;
  --color-market-map-control-icon: #dcecf9;
  --color-market-map-control-disabled: #50606f;
  --color-market-map-hint: #aac1d3;
  --color-map-dot-on-dark: #8b93a1;
  --color-map-customer-on-dark: #f5f5f4;
  --color-map-accent-on-dark: #3fa7ed;

  /* "How your personas overlap" on the dark panel (task 2870) — the block's
   * raised ground and its inks, borders and marks. Constant in both themes
   * like the panel; #3fa7ed, #5b616d and #f5f5f4 are the dark theme's accent,
   * "Venn gray" and customer ink, held fixed here because the panel stays
   * dark in the light theme too (design-conflicts.md C35, C40, C41). */
  --color-market-overlap-raised: #1c2630;
  --color-market-overlap-raised-2: #222d38;
  --color-market-overlap-bg: color-mix(in srgb, var(--color-market-overlap-raised) 55%, var(--color-market-panel-bg));
  --color-market-overlap-border: #28313a;
  --color-market-overlap-border-strong: #3a4550;
  --color-market-overlap-ink: #f5f7fa;
  --color-market-overlap-body: #c3cad3;
  --color-market-overlap-muted: #9aa4af;
  --color-market-overlap-accent: #3fa7ed;
  --color-market-overlap-rest: #5b616d;
  --color-market-overlap-customer: #f5f5f4;
  --color-market-overlap-tooltip-bg: #0b1117;
  --focus-ring-market-overlap: 0 0 0 0.1875rem color-mix(in srgb, var(--color-market-overlap-accent) 70%, transparent);
  /* The proportional Venn's circle fill (each persona's on-dark color at this
   * opacity, screen-blended) and the halo under its region numbers. One place
   * to change both: the numbers' contrast on the overlaps depends on them
   * (design-conflicts.md C66, C67 and the Venn recheck). */
  --market-overlap-venn-fill-opacity: 0.42;
  --color-market-overlap-venn-halo: color-mix(in srgb, var(--color-market-panel-bg) 70%, transparent);

  /* Territory palette — the client's own store regions, in the order the
   * market dashboard lists them. Kept clear of the status hues, the accent
   * and the channel colors so a region never reads as a state; mid-tone
   * steps that hold up on both basemaps. Neighbors differ most. */
  --color-territory-1: #0d9488;
  --color-territory-2: #6366f1;
  --color-territory-3: #b8693d;
  --color-territory-4: #db2777;
  --color-territory-5: #8a7a3a;
  --color-territory-6: #c026d3;
  --color-territory-7: #0e7490;
  --color-territory-8: #9d6b9f;
  --color-territory-9: #5f7f99;

  /* Map inks for the market dashboard's dot map: households outside the
   * personas switched on, customers drawn over them, and the store marker. */
  --color-map-dot: var(--theme-map-dot);
  --color-map-customer: var(--theme-map-customer);
  --color-map-marker: #475569;

  /* Unauthenticated-page backdrop — soft sky/lavender radial wash behind
   * the sign-in card. Decorative ambient light kept at low opacity so it
   * reads as atmosphere. The sky derives from the brand accent, so it stays
   * on-brand and theme-shifts with it; the lavender companion derives from
   * the purple family and carries its own per-theme strength (the two page
   * backgrounds absorb a wash very differently). */
  --color-auth-backdrop-sky: color-mix(in srgb, var(--color-accent) 18%, transparent);
  --color-auth-backdrop-lavender: var(--theme-auth-backdrop-lavender);

  /* Dashboard hero band — the ambient wash inside the band that opens the
   * dashboard. Same language as the auth backdrop above (soft accent-derived
   * radials that read as light in the room, never as glass), pitched much
   * quieter because this wash sits behind live figures rather than behind a
   * sign-in card. Two washes, near and far, so the band has a light source
   * rather than a flat tint.
   *
   * Each theme carries its own strength: Cool Paper reads a wash by how much
   * it darkens the page, Studio Dark by how much it lightens it, so one
   * percentage cannot serve both — it would vanish in dark and bloom in
   * light. */
  --color-dashboard-hero-wash-near: var(--theme-dashboard-hero-wash-near);
  --color-dashboard-hero-wash-far: var(--theme-dashboard-hero-wash-far);

  /* The money band of the dashboard triage list. A single washed row in the
   * accent-washed-row language the setup checklist's active step already
   * speaks — not the banned per-row slab fill, which paints every row in a
   * neutral gray and adds weight without adding meaning. Only the tier that
   * costs the client money is washed, so the wash still means something when
   * the reader sees it. Per-theme for the same reason as the hero wash. */
  --color-dashboard-severity-money: var(--theme-dashboard-severity-money);

  --color-chart-grid: var(--theme-chart-grid);
  --color-tooltip-bg: var(--theme-tooltip-bg);
  --color-tooltip-border: var(--theme-tooltip-border);
  --color-tooltip-text: var(--theme-tooltip-text);

  /* Font family */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

  /* Breakpoints */
  --breakpoint-3xl: 120rem;

  /* Box shadows
   * Banded scale matching the prototype's light/dark tiers. Actual values are
   * theme-dependent (cards float on a gray bg in light, sit on near-neutral
   * dark in dark) and live inside the theme blocks below.
   *
   *   --shadow-sm   card hairline lift
   *   --shadow-md   row hover lift
   *   --shadow-lg   drawer / popover
   *   --shadow-elev modal / login card
   *
   * --shadow-card is the alias used by card surfaces and resolves to
   * --shadow-sm per theme. */
  --shadow-card: var(--shadow-sm);

  /* Motion
   * Apple's signature easing at apple-y durations. Use --motion-fast on
   * micro-interactions (hover, focus ring, color shifts) and --motion-base
   * on view-level changes (drawer slide-in, modal appear). */
  --motion-fast: 200ms cubic-bezier(0.32, 0.72, 0, 1);
  --motion-base: 320ms cubic-bezier(0.32, 0.72, 0, 1);

  /* Form widths — single-column form and card max-widths.
   * Use these via var(--form-width-*) in domain CSS; do not add
   * bespoke rem values. See docs/guides/design-system.md. */
  --form-width-sm: 32rem;
  --form-width-md: 36rem;
  --form-width-lg: 44rem;
  --form-width-xl: 48rem;

  /* Content column width — the cap a landing page's column reads at, centred
   * in whatever gutter is left. The form widths above stop at 48rem because a
   * single column of fields has a measure; a dashboard column holds a hero
   * band, a four-up tile grid and a pair of cards, so it needs more room than
   * a form and less than the screen.
   *
   * 64rem is where the hero band's two fact columns land at a readable
   * proportion and where a triage row stops putting a thousand pixels between
   * what broke and the button that fixes it. Uncapped, those rows stretched to
   * the full width of a 27" display and orphaned every control. */
  --dashboard-content-width: 64rem;

  /* Field geometry — shared by Forms::FieldComponent, Forms::LabelComponent,
   * and Forms::DropdownFieldComponent. Kept outside the --spacing scale
   * because form density is a domain decision, not a layout one.
   * Field-to-field spacing is the parent's responsibility (use .stack,
   * .stack-sm, or a grid primitive). */
  --field-padding-block: 0.625rem;   /* 10px — input py */
  --field-padding-inline: 0.75rem;   /* 12px — input px */
  --field-label-gap: 0.375rem;       /* 6px  — label to input */

  /* Field font floor — iOS Safari zooms the page when a focused
   * input/select/textarea computes below 16px. Any form control styled
   * below --font-size-base must wrap its font-size in
   * max(<size>, var(--field-font-floor)): a no-op on desktop, 16px on
   * touch devices (see the media query below). 0rem, not 0 — unitless
   * zero is invalid inside max(). */
  --field-font-floor: 0rem;

  /* Badge geometry — shared by BadgeComponent. Kept outside the --spacing
   * scale because badge density is a domain decision (small inline label),
   * mirroring the --field-* tokens above. */
  --badge-padding-block: 0.125rem;              /* 2px — badge py */
  --badge-padding-inline: calc(var(--spacing) * 2); /* 8px — badge px */

  /* Card padding — used by Cards::CardComponent and StatCardsComponent.
   * 28px gives the cards Apple-bento breathing room (the prototype's p-7).
   * Off the --spacing rhythm scale because card density is a domain decision. */
  --card-padding: 1.75rem;           /* 28px */

  /* Search input horizontal padding — used by the ResourceListComponent
   * search field. Off the rhythm scale because it must clear the 14px
   * leading icon (at left: 16px) with ~10px of breathing room before
   * text begins. */
  --search-padding-inline: 2.5rem;      /* 40px */
}

/* On touch devices (phones/tablets, incl. iPad Safari in desktop-UA
 * mode) raise the field font floor to 16px so focusing a form control
 * never triggers iOS Safari's auto-zoom. Hover-capable fine-pointer
 * devices keep the designed compact sizes. */
@media (hover: none) and (pointer: coarse) {
  :root {
    --field-font-floor: 1rem;
  }
}


/* ─── Native control theming ─── */

/* Everything the app paints comes from the tokens below, but select carets,
 * date/time pickers, scrollbars, spinners, and the caret in a text field are
 * drawn by the browser, and it draws them light until told otherwise. Declaring
 * color-scheme is the whole of that telling.
 *
 * Keyed off [data-theme] alone, with no prefers-color-scheme variant: the app
 * never follows the OS setting. Every layout stamps data-theme on <html> from
 * the account's saved preference (ApplicationController#current_theme, default
 * light), so a media query would hand dark native chrome to a light page
 * whenever the OS happened to be dark. See app/javascript/utils/theme_colors.js,
 * which documents the same invariant for charts. */
:root,
[data-theme="light"] {
  color-scheme: light;
}

[data-theme="dark"] {
  color-scheme: dark;
}


/* ─── Theme tokens: Light (default) ─── */

:root,
[data-theme="light"] {
  /* The light theme reads as: cool blue-gray page → white sidebar → white
   * surfaces floating above. All grays come from the cool blue-gray family
   * that matches the marketing site. Do not substitute neutral or warm grays
   * (#f5f5f5, #e5e5e5) — they create a temperature mismatch. */
  --theme-bg-body: #f4f6f9;
  --theme-bg-sidebar: #ffffff;
  --theme-bg-surface: #ffffff;
  --theme-bg-elevated: #eef1f5;
  --theme-bg-input: #ffffff;
  --theme-bg-hover: rgba(11, 13, 16, 0.04);
  --theme-bg-quick-action: #eef1f5;
  /* 32% black over the page: #f4f6f9 → ~#a6a8ab. */
  --theme-scrim: color-mix(in srgb, var(--color-black) 32%, transparent);

  --theme-border-primary: #e3e7ed;
  --theme-border-secondary: #cdd3dc;
  --theme-border-subtle: #eaedf2;
  --theme-border-row: #eaedf2;

  --theme-text-primary: #171717;
  --theme-text-secondary: #525252;
  --theme-text-muted: #5f6368; /* darkened from #737373 to clear WCAG AA (4.5:1) on light surfaces */
  --theme-text-hover: #171717;
  --theme-text-inverted: #ffffff;
  --theme-text-input: #171717;

  /* Brand blue deepened to #176bb0 (the AA-compliant blue) so the whole
   * light-theme accent — links, borders, icons, highlights — matches the deeper
   * blue used for buttons. Dark theme keeps the brighter accent for readability. */
  --theme-accent: #176bb0;
  --theme-accent-subtle: #e7f1f9;
  --theme-accent-border: #a9cce6;
  --theme-accent-hover: #125d96;
  --theme-accent-strong: #176bb0;
  --theme-accent-strong-hover: #1872bb;

  /* Presentation strength — the full-strength face of each hue family for
   * this theme, and the one place a mark's strength is decided.
   *
   * On Cool Paper that face is the -dark sibling. The 400-level bases are
   * built for dark backgrounds (that is how the marketing site uses them); at
   * full strength on a white card they read acid, and they read as a different
   * green from the deep green sitting next to them in a badge's ink. So in
   * light the base hue appears only diluted inside a tint (≤25%), never as a
   * glyph, a dot, a solid fill, or a decorative accent. Dark flips it.
   *
   * This is how the brand blue has always worked (#176bb0 light, #3fa7ed
   * dark); these tokens give every other family the same behaviour. Blue's
   * face is --color-accent itself, so it has no -mark alias. */
  --color-green-mark: var(--color-green-dark);
  --color-yellow-mark: var(--color-yellow-dark);
  --color-orange-mark: var(--color-orange-dark);
  --color-red-mark: var(--color-red-dark);
  --color-purple-mark: var(--color-purple-dark);
  --color-pink-mark: var(--color-pink-dark);
  --color-teal-mark: var(--color-teal-dark);
  --color-slate-mark: var(--color-slate-dark);
  --color-yellow-orange-mark: var(--color-yellow-orange-dark);

  /* Ink for a glyph or label painted ON a full-strength hue (a done disc, an
   * applied chip, a checked box). The fill flips with the theme, so its ink
   * has to: white over the deep light-mode fill, the page's near-black over
   * the bright dark-mode one. Not --color-text-inverted, which is white in
   * both themes because it rides on the accent. */
  --theme-text-on-vivid: #ffffff;

  --theme-chart-grid: #e5e5e5;
  --theme-chart-hover-line: #b0b0b0;
  --theme-tooltip-bg: #ffffff;
  --theme-tooltip-border: #e5e5e5;
  --theme-tooltip-text: #171717;

  --theme-scrollbar-track: #f5f5f5;
  --theme-scrollbar-thumb: #d4d4d4;
  --theme-scrollbar-thumb-hover: #a3a3a3;

  /* Shadows — visible against the gray page bg. Multi-layer so the lift
   * reads as ambient light, not a single drop. */
  --shadow-sm: 0 4px 12px rgba(11, 13, 16, 0.04), 0 1px 2px rgba(11, 13, 16, 0.03);
  --shadow-md: 0 8px 24px rgba(11, 13, 16, 0.06), 0 1px 3px rgba(11, 13, 16, 0.04);
  --shadow-lg: 0 16px 40px rgba(11, 13, 16, 0.10), 0 4px 8px rgba(11, 13, 16, 0.05);
  --shadow-elev: 0 28px 60px rgba(11, 13, 16, 0.14), 0 8px 16px rgba(11, 13, 16, 0.06);

  /* Glass — translucent surfaces with backdrop blur. Reserved for the hero
   * summary card on AudienceVisualization. Do not spread it. */
  --surface-glass: rgba(255, 255, 255, 0.72);
  --surface-glass-border: rgba(11, 13, 16, 0.06);
  --blur-glass: blur(20px) saturate(180%);

  /* Lavender half of the auth backdrop wash. Tuned to land at roughly the
   * sky sibling's visual weight over Cool Paper — the two quadrants have to
   * balance, and a pale purple needs a far higher share than the accent does
   * to get there. 45% settles at luminance 0.720 against the sky's 0.706 at
   * 18%; the brand purple is more saturated than the old pale lavender, which
   * is why this share came down from 55%. */
  --theme-auth-backdrop-lavender: color-mix(in srgb, var(--color-purple-light) 45%, transparent);

  /* Dashboard hero band wash. Far quieter than the auth backdrop's 18% sky:
   * that wash sits behind one card on an otherwise empty page, this one sits
   * under a 56px figure and a bar chart that both have to stay legible. */
  --theme-dashboard-hero-wash-near: color-mix(in srgb, var(--theme-accent) 13%, transparent);
  --theme-dashboard-hero-wash-far: color-mix(in srgb, var(--theme-accent) 8%, transparent);

  /* Money-band triage row wash. Sits just under the accent-subtle step the
   * checklist's active row uses (~12% over white); red carries further than
   * blue at the same share, and the row still has to read as a list row. */
  --theme-dashboard-severity-money: color-mix(in srgb, var(--color-red) 7%, transparent);

  --theme-logo-filter: brightness(0);
  --theme-bg-private: color-mix(in srgb, var(--color-yellow) 12%, transparent);

  /* Dashboard colors — decorative identity hues for milestone ranks, tool
   * chips, and icon badges, drawn from the one hue family. */
  --theme-dashboard-info: var(--theme-accent);
  --theme-dashboard-info-subtle: color-mix(in srgb, var(--theme-accent) 10%, transparent);
  --theme-dashboard-purple: var(--color-vivid-violet);
  --theme-dashboard-purple-subtle: color-mix(in srgb, var(--color-vivid-violet) 10%, transparent);
  --theme-dashboard-gold: var(--color-vivid-amber);

  /* Active task panel — a decorative accent-to-green sweep behind the panel
   * chrome, not a success signal.
   *
   * The glyph rides a full-strength hue, so it takes --color-text-on-vivid like
   * every other mark-borne glyph rather than a frozen white. White works on
   * Cool Paper (5.58:1 at the blue end, 3.30:1 at the green one, both clearing
   * the 3:1 graphical bar) but collapses on Studio Dark, where the sweep runs
   * through the bright bases: white measures 2.64:1 on the accent end and
   * 1.74:1 on the green one. The theme-flipping ink clears both at 7.36:1 and
   * 11.15:1. */
  --theme-active-panel-bg: linear-gradient(135deg, var(--color-accent), var(--color-vivid-emerald));
  --theme-active-panel-border: transparent;
  --theme-active-panel-icon: var(--color-text-on-vivid);

  /* Market dashboard — see the :root block for the roles. */
  --theme-bg-section: #e8ecf1;
  --theme-border-section: #d3d9e1;
  --theme-map-dot: #94a3b8;
  --theme-map-customer: #18181b;
  --theme-module-tam: #0369a1;
  --theme-module-personas: #6d28d9;
  --theme-module-locations: #4d7c0f;
  --theme-module-campaigns: #a21caf;
}


/* ─── Theme tokens: Dark ─── */

[data-theme="dark"] {
  /* Dark theme grays are near-neutral (R≈G≈B). An earlier attempt used cool
   * blue-tinted darks pulled directly from marketing — they read too
   * "Linear/Vercel" in practice. The values below pull the blue channel down
   * so dark mode feels closer to macOS's neutral dark gray. */
  --theme-bg-body: #0d0d0e;
  --theme-bg-sidebar: #0a0a0b;
  --theme-bg-surface: #16171a;
  --theme-bg-elevated: #1e1f22;
  --theme-bg-input: #1e1f22;
  --theme-bg-hover: rgba(255, 255, 255, 0.04);
  --theme-bg-quick-action: #141518;
  /* 72% rather than the light theme's 32%: on a #0d0d0e page a 32%
   * black scrim moves three values out of 255 and reads as nothing.
   * At 72% the page goes to ~#040404 and clearly drops away behind
   * the panel, which is itself a lighter surface than the page. */
  --theme-scrim: color-mix(in srgb, var(--color-black) 72%, transparent);

  --theme-border-primary: #2a2b2f;
  --theme-border-secondary: #3a3b3f;
  --theme-border-subtle: #1b1c1f;
  --theme-border-row: #2a2b2f;

  --theme-text-primary: #ffffff;
  --theme-text-secondary: #a3a3a3;
  --theme-text-muted: #949699; /* lightened from #737373 to clear WCAG AA (4.5:1) on dark surfaces */
  --theme-text-hover: #d4d4d4;
  --theme-text-inverted: #ffffff;
  --theme-text-input: #f5f5f5;

  --theme-accent: #3fa7ed;
  --theme-accent-subtle: rgba(63, 167, 237, 0.08);
  --theme-accent-border: rgba(63, 167, 237, 0.2);
  --theme-accent-hover: #6bbdf2;
  /* accent-strong is the "accent-on-dark": the deeper #176bb0 would be too
     low-contrast as foreground text/icons on dark surfaces, so use a slightly
     brighter blue that clears WCAG AA there. */
  --theme-accent-strong: #2b8cd8;
  --theme-accent-strong-hover: #6bbdf2;

  /* Presentation strength — see the light block. Studio Dark is the lighting
   * the 400-level bases were drawn for, so here they carry the marks and the
   * -dark siblings step back: a #16A34A glyph on a #16171a card goes muddy the
   * same way a #4ADE80 one goes acid on white. */
  --color-green-mark: var(--color-green);
  --color-yellow-mark: var(--color-yellow);
  --color-orange-mark: var(--color-orange);
  --color-red-mark: var(--color-red);
  --color-purple-mark: var(--color-purple);
  --color-pink-mark: var(--color-pink);
  --color-teal-mark: var(--color-teal);
  --color-slate-mark: var(--color-slate);
  --color-yellow-orange-mark: var(--color-yellow-orange);

  /* The bright marks carry the page's near-black rather than white — white on
   * a #4ADE80 disc is 1.7:1, the ink below is 12:1. */
  --theme-text-on-vivid: #0d0d0e;

  --theme-chart-grid: #2a2a2a;
  --theme-chart-hover-line: #4a4a4a;
  --theme-tooltip-bg: #1a1a1a;
  --theme-tooltip-border: #2a2a2a;
  --theme-tooltip-text: #f5f5f5;

  --theme-scrollbar-track: #1a1a1a;
  --theme-scrollbar-thumb: #3a3a3a;
  --theme-scrollbar-thumb-hover: #4a4a4a;

  /* Shadows — heavier negative spread + higher opacity so the lift is
   * visible against the dark page bg. */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 28px -10px rgba(0, 0, 0, 0.55), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-elev: 0 28px 60px -24px rgba(0, 0, 0, 0.7), 0 8px 16px -8px rgba(0, 0, 0, 0.4);

  /* Glass */
  --surface-glass: rgba(22, 22, 24, 0.74);
  --surface-glass-border: rgba(255, 255, 255, 0.10);
  --blur-glass: blur(20px) saturate(180%);

  /* Studio Dark reads a wash by how much it lightens the page, not by how
   * much it darkens it, so the mix drops and moves to the fuller purple; the
   * light theme's pale share would bloom far too bright here. 18% lands at
   * luminance 0.0202 against the sky's 0.0200. */
  --theme-auth-backdrop-lavender: color-mix(in srgb, var(--color-purple) 18%, transparent);

  /* Studio Dark reads a wash by how much it lightens the surface, and the
   * bright dark-theme accent is a far lighter blue than the light theme's, so
   * the same share lands quieter here. Stepped up until the band reads as lit
   * rather than as a slightly different gray — and stopped there, because the
   * figure and the bars sit on top of it. */
  --theme-dashboard-hero-wash-near: color-mix(in srgb, var(--theme-accent) 14%, transparent);
  --theme-dashboard-hero-wash-far: color-mix(in srgb, var(--theme-accent) 8%, transparent);

  /* Same reasoning for the money row: 7% red over #16171a is invisible. */
  --theme-dashboard-severity-money: color-mix(in srgb, var(--color-red) 12%, transparent);

  --theme-logo-filter: brightness(0) invert(1);
  --theme-bg-private: color-mix(in srgb, var(--color-yellow) 8%, transparent);

  /* Dashboard colors — see the light block; the identity hues are the same
   * object under both lighting conditions. */
  --theme-dashboard-info: var(--theme-accent);
  --theme-dashboard-info-subtle: color-mix(in srgb, var(--theme-accent) 10%, transparent);
  --theme-dashboard-purple: var(--color-vivid-violet);
  --theme-dashboard-purple-subtle: color-mix(in srgb, var(--color-vivid-violet) 10%, transparent);
  --theme-dashboard-gold: var(--color-vivid-amber);

  /* Active task panel — see the light block for why the glyph is the on-vivid
   * ink rather than a frozen white. */
  --theme-active-panel-bg: linear-gradient(135deg, var(--color-accent), var(--color-vivid-emerald));
  --theme-active-panel-border: transparent;
  --theme-active-panel-icon: var(--color-text-on-vivid);

  /* Market dashboard — see the :root block for the roles. */
  --theme-bg-section: #121315;
  --theme-border-section: #2a2b2f;
  --theme-map-dot: #8b93a1;
  --theme-map-customer: #f5f5f4;
  --theme-module-tam: #38bdf8;
  --theme-module-personas: #a78bfa;
  --theme-module-locations: #a3e635;
  --theme-module-campaigns: #e879f9;
}


/* ─── Badge color utilities ─── */

.badge-green  { background: var(--theme-badge-green-bg);  color: var(--theme-badge-green-text);  border: 1px solid var(--theme-badge-green-border); }
.badge-yellow { background: var(--theme-badge-yellow-bg); color: var(--theme-badge-yellow-text); border: 1px solid var(--theme-badge-yellow-border); }
.badge-blue   { background: var(--theme-badge-blue-bg);   color: var(--theme-badge-blue-text);   border: 1px solid var(--theme-badge-blue-border); }
.badge-orange { background: var(--theme-badge-orange-bg); color: var(--theme-badge-orange-text); border: 1px solid var(--theme-badge-orange-border); }
.badge-red    { background: var(--theme-badge-red-bg);    color: var(--theme-badge-red-text);    border: 1px solid var(--theme-badge-red-border); }
.badge-gray   { background: var(--theme-badge-gray-bg);   color: var(--theme-badge-gray-text);   border: 1px solid var(--theme-badge-gray-border); }
.badge-purple { background: var(--theme-badge-purple-bg); color: var(--theme-badge-purple-text); border: 1px solid var(--theme-badge-purple-border); }


/* ─── Border-color default ─── */

/*
 * Sets the default border color to gray-200, matching what the app was
 * built against. The CSS reset above sets border-width: 0 and
 * border-style: solid on *, so adding a border to any element just
 * needs `border-width: 1px` — the color is already correct.
 *
 * Can be removed once every border element has an explicit border-color
 * set via a domain CSS class.
 */
*,
::after,
::before,
::backdrop,
::file-selector-button {
  border-color: var(--color-gray-200, currentColor);
}


/* ─── Custom scrollbar styling ─── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--theme-scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--theme-scrollbar-thumb);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--theme-scrollbar-thumb-hover);
}


/* ─── Global form focus ring ─── */

/*
 * Single source of truth for input focus styling. Every text input, textarea,
 * and select gets the same accent border + accent-tinted ring on focus.
 * Domain CSS should not set its own input :focus / :focus-visible rules —
 * if a control needs a different focus treatment, add a class-specific
 * override here, not in the component file.
 */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

/* The setup guide's composer sits directly above answer cards whose selected
   state is the same accent border, so the halo would put two outline styles on
   one screen. Focus here is border-only: the accent border still comes from the
   global rule, and an invalid field keeps its red border through focus via the
   component's aria-invalid rule. */
.component-audiences-builder-workspace-wizard-goal textarea:focus-visible {
  box-shadow: none;
}

/* The audiences toolbar search input is borderless inside a pill wrapper,
   so the focus ring moves from the input to the wrapper. */
.component-audiences-toolbar-search-input:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.component-audiences-toolbar-search:focus-within {
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

/* The direct mail stores toolbar search input is borderless inside a pill
   wrapper, so the focus ring moves from the input to the wrapper (mirrors
   audiences). */
.direct-mail-toolbar-search-input:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.direct-mail-toolbar-search:focus-within {
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

/* The vault toolbar search input is borderless inside a pill wrapper, so the
   focus ring moves from the input to the wrapper (mirrors audiences). */
.component-vault-toolbar-search-input:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.component-vault-toolbar-search:focus-within {
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

/* The inbox toolbar search input is borderless inside a pill wrapper, so the
   focus ring moves from the input to the wrapper (mirrors audiences). */
.component-inbox-toolbar-search-input:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.component-inbox-toolbar-search:focus-within {
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

/* The admin command palette's query field is borderless and fills the modal's
   search row, so the focus treatment moves from the input to the row's
   hairline divider. */
.admin-command-palette-input:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.admin-command-palette-search:focus-within {
  border-bottom-color: var(--color-accent);
  transition: border-color var(--motion-fast);
}

/* The help-center hero search input is borderless inside a pill wrapper, so the
   focus ring moves from the input to the wrapper (mirrors audiences). */
.help-hero-search-input:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.help-hero-search:focus-within {
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}


/* ─── Reduced motion ─── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
