/* ============================================================================
   Refocus X — Design Pack · tokens.css
   The single source of truth for colour, radius, elevation, type, layout and
   stacking across every Refocus X product.

   USAGE — link this BEFORE any page-local <style>:
     <link rel="stylesheet" href="/design-pack/tokens.css">

   Because it loads first, a page's own :root block still wins. That is
   deliberate: an existing app can adopt this file today and nothing changes
   until it starts deleting its local overrides, one page at a time.

   Every value here is taken from real shipped code. Nothing is invented.
   The reasoning for each ruling is in DECISIONS.md.
   ============================================================================ */

/* ── Fonts (D7, D82): the pack ships its own files; nothing is fetched from a third party ──
   DM Sans (400-700, one variable file, optical size pinned at 14) and DM Mono (400, 500),
   both SIL Open Font License 1.1 (fonts/OFL-*.txt). The urls are relative to THIS file, so
   they work from wherever a product vendors the pack (/design-pack/fonts/...). font-display
   swap: text shows at once in the fallback stack and swaps when the file arrives. */
@font-face {
  font-family: 'DM Sans'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('fonts/dm-sans-400-700.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/dm-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/dm-mono-500.woff2') format('woff2');
}

:root, [data-theme="light"] {
  color-scheme: light;

  /* ── Ink (text) ──────────────────────────────────────────────────────────
     Three steps. Anything below --rx-ink-subtle is not readable on our
     surfaces, so there is no fourth step on purpose. */
  --rx-ink:         #18181b;   /* primary text; also the primary button fill */
  --rx-ink-muted:   #52525b;   /* secondary text, field labels */
  --rx-ink-subtle:  #a1a1aa;   /* hints, placeholders, disabled, timestamps */
  --rx-on-ink:      #ffffff;   /* text ON an --rx-ink fill */
  --rx-ink-hover:   #27272a;   /* hover state of an --rx-ink fill */

  /* ── Surfaces ────────────────────────────────────────────────────────────
     Named by role, not by number, because numbered scales get used
     inconsistently the moment two people touch them. */
  --rx-surface-page:    #fafaf9;   /* the page background */
  --rx-surface-card:    #ffffff;   /* raised: cards, panels, menus, table head */
  --rx-surface-sunken:  #f4f4f5;   /* tints: row hover, chip rest, inset blocks */
  --rx-border:          #e4e4e7;   /* every border and divider. One value. */
  --rx-switch-off:      #e4e4e7;   /* the OFF track of a switch (D64). Same value as --rx-border today;
                                      its own name because dark must make it lighter - the knob sits on it. */
  --rx-border-strong:   #d4d4d8;   /* hover/active border ONLY. --rx-border is
                                      1.27:1 on white — a hover state that stays
                                      on it is not a hover state. Do not reach
                                      for this as a second default border. */

  /* ── Brand ───────────────────────────────────────────────────────────────
     The one pair a white-label deployment overrides at runtime. Defaults to
     the ink, so an unbranded install looks deliberate rather than unfinished.
     Set by RX.brand() from a tenant's settings; --rx-brand-on is COMPUTED
     from luminance, never assumed to be white. */
  --rx-brand:     #18181b;
  --rx-brand-on:  #ffffff;

  /* ── The Refocus X mark ──────────────────────────────────────────────────
     Our own corporate purple, #7f4fff - the RULED Refocus X purple (Pierre, 3 Oct
     2026, D64 note: the artwork's X measures #a379ff, and he kept #7f4fff).
     This is NOT
     --rx-brand: a tenant overrides --rx-brand, and must never override this
     one — its whole job is saying "Refocus X built this". Product favicons,
     app icons, the logo itself. Nothing else.
     Measured 4.70:1 on white and 3.77:1 on --rx-ink, so it may carry text on
     white and takes --rx-on-mark as a fill, but it is a mark colour, not a
     UI accent — reach for --rx-accent-ui before you reach for this. */
  --rx-mark:     #7f4fff;
  --rx-on-mark:  #ffffff;   /* 4.70:1 — text ON an --rx-mark fill */

  /* ── Accent (purple decorative, green UI+text) ───────────────────────────
     The three tiers now split by MEANING, not just by depth (D16).
     --rx-accent is brand: the sign-in headline, spinners, large decorative
     fills. It is the mark's purple and follows the brand.
     --rx-accent-ui and --rx-accent-text are STATE: switches, progress fills,
     toast-success, unread dots, "Saved", "Came online", "done". Those say
     something is good, and green is what says that. They do NOT follow the
     brand — a purple tick is just a tick.
     This is why D2's split exists at all now. Ratios against white. */
  --rx-accent:        #7f4fff;   /* 4.70:1 — BRAND: headline, spinner, fills */
  --rx-accent-hover:  #663fcc;   /* 6.67:1 — hover/active of an --rx-accent fill.
                                    RX.darkenTo-derived from the mark (v0.4.0's
                                    TEXT tier). Was the ui tier #7347e6 for a
                                    few hours — Pierre: "I can hardly see it"
                                    — so the step doubled to the next recorded
                                    rung; selftest pins a 1.35× floor so it can
                                    never quietly shrink again. Exists because
                                    the old hover swap accent→accent-ui crosses
                                    MEANINGS since D16: a brand-purple button
                                    must not hover state-green (D18). */
  --rx-accent-ui:     #16a34a;   /* 3.30:1 — STATE: switches, bars, dots */
  --rx-accent-text:   #15803d;   /* 5.02:1 — STATE: success copy on white */
  --rx-on-accent:     #ffffff;   /* 4.70:1 — text ON an --rx-accent fill */

  /* ── Status ──────────────────────────────────────────────────────────────
     Four families, one shape each (D17). Every family answers the same five
     questions, so nobody has to invent an answer for the one that is missing:

       --rx-X          the fill, and the text/border colour on white
       --rx-X-strong   the escalated step
       --rx-X-soft     the tint background for a card or badge
       --rx-X-border   the border that goes with that tint
       --rx-on-X       text ON an --rx-X fill

     Use -soft and -border together; they are contrast-checked as a set.
     --rx-danger-strong is the escalated destructive tier only (full wipes,
     unscoped deletion). See patterns/COMPONENTS.md. */
  --rx-danger:         #dc2626;
  --rx-danger-strong:  #991b1b;
  --rx-danger-soft:    #fef2f2;   /* danger-zone card background */
  --rx-danger-border:  #fecaca;   /* 4.41:1 — danger on danger-soft */
  --rx-on-danger:      #ffffff;

  --rx-warn:           #b45309;
  --rx-warn-strong:    #d97706;   /* reversible-but-serious actions */
  --rx-warn-soft:      #fff7ed;   /* 4.73:1 — warn on warn-soft */
  --rx-warn-border:    #fde68a;
  --rx-on-warn:        #ffffff;   /* 5.02:1 */

  --rx-info:           #2563eb;
  --rx-info-strong:    #1e40af;
  --rx-info-soft:      #dbeafe;   /* 7.15:1 — info-strong on info-soft */
  --rx-info-border:    #bfdbfe;
  --rx-on-info:        #ffffff;   /* 5.17:1 */

  /* The highlighter (PD-013, D122): three marker fills for a document's text. --rx-on-hl is the text on them: body text stays
     readable (light 12.5 to 15.2:1, dark 7.4 to 8.0:1). The print block at the end of this file puts the light values back on paper. */
  --rx-hl-yellow:     #fef08a;
  --rx-hl-green:      #bbf7d0;
  --rx-hl-blue:       #bfdbfe;
  --rx-on-hl:         #18181b;

  /* The SIXTH chart series tone (v0.60.0, PACK-036). A chart series needs a fill
     that is not a severity word, and the pack carried five (success, danger, warn,
     info, neutral), so a sixth series reused the first - LearnGuard's 'Due again'
     drew in the same orange as 'Paused' (LG-016, 8 Oct 2026). Magenta is the one
     hue left that is far from all four (CIELAB distance to info 46, danger 95,
     warn 120, success 149; a purple would sit 39 from info). Fill + ink only: no
     -strong/-soft/-border, because nothing but a chart fill uses it (RX.charts,
     tone 'magenta'). Measured with RX.contrast: the fill is UI-tier (>= 3.0) against
     page / card / sunken at 6.05 / 6.32 / 5.75, and white on the fill is 6.32:1. */
  --rx-magenta:        #a21caf;
  --rx-on-magenta:     #ffffff;   /* 6.32:1 */

  /* Success is a STATE, and it now has its own name (D17).
     These values are --rx-accent-ui and --rx-accent-text today, deliberately.
     The point is not that they differ — it is that they are free to. D16 made
     the accent's green tiers mean "state"; a name the brand cannot reach is
     what stops the next brand move turning every tick purple, which is exactly
     what v0.4.0 did. Reference --rx-success for anything that says good/on. */
  --rx-success:        #16a34a;   /* 3.30:1 — fills, bars, dots, switches */
  --rx-success-strong: #15803d;   /* 5.02:1 — success copy on white */
  --rx-success-soft:   #f0fdf4;   /* 4.79:1 — success-strong on success-soft */
  --rx-success-border: #bbf7d0;
  --rx-on-success:     #ffffff;

  /* ── Severity fills — alerting surfaces ──────────────────────────────────
     NOT the same thing as danger/warn/info, and the difference is the whole
     reason this tier exists (D17). Those are FOREGROUND colours, chosen for
     contrast on white: button text, badge ink, borders. These are FILLS for a
     surface that is itself the alarm — PageCast's full-screen kiosk takeover,
     its preset buttons, its pulsing banner.

     Ruled by Pierre 6 Aug 2026 and shipping since. Hazard yellow carries dark
     ink, not white: 9.53:1, the best-contrasting surface in the suite, and the
     one colour a person reads as "warning" from across a room without reading
     the word. Folding these onto --rx-warn would make it a brown screen at
     5.02:1. Do not.

     A life-safety UI is the one place a colour must never be re-derived. */
  --rx-alert-critical:       #b91c1c;   /* 6.47:1 with white */
  --rx-alert-critical-pulse: #7f1d1d;   /* the trough of the pulse — 10.02:1 */
  --rx-alert-warning:        #eab308;   /* hazard yellow */
  --rx-on-alert-warning:     #1c1400;   /* 9.53:1 — dark ink, NOT white */
  --rx-alert-info:  var(--rx-info-strong);  /* #1e40af, by reference: one place */
  --rx-on-alert:             #ffffff;   /* text on critical and info fills */

  /* ── Category tints ──────────────────────────────────────────────────────
     Background + readable-on-it text, for badges that classify rather than
     alarm (event namespaces, record types). Each pair is contrast-checked;
     use them together, never mix a tint with a different ink. */
  --rx-tint-green:   #dcfce7;  --rx-tint-green-ink:  #15803d;
  --rx-tint-blue:    #e0f2fe;  --rx-tint-blue-ink:   #0369a1;
  --rx-tint-purple:  #f3e8ff;  --rx-tint-purple-ink: #7c3aed;
  --rx-tint-orange:  #ffedd5;  --rx-tint-orange-ink: #c2410c;
  --rx-tint-amber:   #fef3c7;  --rx-tint-amber-ink:  #92400e;

  /* ── Radius ──────────────────────────────────────────────────────────────
     Three steps plus a pill. */
  --rx-radius-sm:    8px;    /* buttons, inputs, chips, small menus */
  --rx-radius:      10px;    /* default: panels, inset blocks, tiles */
  --rx-radius-lg:   14px;    /* cards, modals, big containers */
  --rx-radius-pill: 999px;   /* filter chips, tags, toggles */

  /* ── Scrim ───────────────────────────────────────────────────────────────
     The dim behind an overlay. Two weights: the heavier one for modal
     overlays that take the whole screen, the lighter one for a non-modal
     side panel where the list behind must stay readable. */
  --rx-scrim:      rgba(0,0,0,.45);
  --rx-scrim-soft: rgba(0,0,0,.25);

  /* ── Elevation ───────────────────────────────────────────────────────────
     One shadow per z-band. Do not mix bands. */
  --rx-shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --rx-shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --rx-shadow-pop:    0 8px 24px rgba(0,0,0,.18);
  --rx-shadow-modal:  0 16px 50px rgba(0,0,0,.28);

  /* ── Type ────────────────────────────────────────────────────────────────
     Self-hosted: the @font-face rules at the top of this file load fonts/ (D7, D82). */
  --rx-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --rx-mono: 'DM Mono', ui-monospace, Consolas, monospace;

  /* ── Type scale ──────────────────────────────────────────────────────────
     Taken from the real distribution across a shipped 15,000-line frontend,
     not invented. Usage counts are in DECISIONS.md D12.

     13px is the body size and by far the most used — this is a dense
     information product, not a marketing site. There is deliberately NO step
     below 11px: 10px appears 22 times in the source and is below the
     comfortable reading floor. Do not add one. */
  --rx-text-xs:    calc(11px * var(--rx-scale));   /* hints, micro-labels, timestamps */
  --rx-text-sm:    calc(12px * var(--rx-scale));   /* secondary text, meta rows */
  --rx-text:       calc(13px * var(--rx-scale));   /* BODY. The default for everything. */
  --rx-text-md:    calc(14px * var(--rx-scale));   /* inputs, prominent body, switch labels */
  --rx-text-lg:    calc(16px * var(--rx-scale));   /* subheads */
  --rx-title-sm:   calc(18px * var(--rx-scale));   /* card and section titles */
  --rx-title:      calc(22px * var(--rx-scale));   /* page title — management screens */
  --rx-title-lg:   calc(28px * var(--rx-scale));   /* big numbers: stat values */
  --rx-display:    calc(48px * var(--rx-scale));   /* hero, sign-in only */

  /* ── Layout ──────────────────────────────────────────────────────────────
     TWO widths. Every page that is not a form uses the content width, so
     pages line up across the whole suite — Pierre, 8 Sep 2026, D47.
     The content width is FLUID (D44): a share of the viewport, floored so a
     phone is never given dead margin, capped so an ultrawide never gets a
     table row the eye cannot track. The form width is fixed and stays fixed —
     that is D6 and it was right.
     There was a third, --rx-canvas-max, for dashboards. It is GONE (D47): it
     had no users left in the suite, and the one page that took it became the
     only page that did not line up with its siblings. */
  --rx-content-max: max(640px, min(80vw, 1800px));  /* reading + management screens. The default. */
  --rx-form-max:     640px;                         /* single-column task forms — deliberately NOT fluid */
  --rx-header-h:      60px;
  --rx-brand-mark:    32px;   /* the brand mark in the header — CANON (D20).
                                 Measured from FileDrop's nav.js (width="32");
                                 rx-shell applies it to brand.logo itself, so
                                 a caller's width="20" cannot shrink the tile
                                 to a dot. */
  --rx-gap:           20px;   /* grid gutter */
  --rx-toast-top:     18px;   /* toast-stack offset from the viewport top.
                                 Apps with fixed/sticky chrome raise it (even
                                 dynamically, from the header's measured
                                 height) so a toast never covers the header —
                                 PageCast's carries its master switch. */

  /* ── Focus ring ──────────────────────────────────────────────────────────
     One ring, used by every focusable control. */
  --rx-focus-ring: 0 0 0 3px rgba(24,24,27,.08);

  /* ── Stacking scale ──────────────────────────────────────────────────────
     NEVER write a raw z-index. Use one of these. The contract that explains
     why the gaps are where they are is in patterns/STACKING.md. */
  --rx-z-sticky:    10;      /* sticky table headers — clippable, in-flow */
  --rx-z-menu:      50;      /* page-local menus inside a container */
  --rx-z-header:   100;      /* the fixed app header */
  --rx-z-dropdown: 200;      /* menus belonging to the header */
  --rx-z-modal:   1000;      /* page modals */
  --rx-z-boot:    9999;      /* boot splash — must outrank page modals */
  --rx-z-popover:10000;      /* body-rendered, fixed, rect-anchored poppers */
  --rx-z-dialog: 11000;      /* shared dialog engine */
  --rx-z-toast:  12000;      /* toasts sit ABOVE dialogs, deliberately */
  --rx-z-expired:13000;      /* session-expired terminal state */
  --rx-z-blocked:99999;      /* access-denied takeover — nothing above this */

  /* The boot splash is a dark screen in BOTH themes (the logo it carries is
     the reversed one), so it has its own tokens instead of borrowing --rx-ink,
     which inverts in dark. Declared once, never redeclared. */
  --rx-boot-bg:    #18181b;
  --rx-boot-track: #27272a;

  /* The two surfaces a logo is judged against (D65, the logo upload's review):
     white and the dark the suite paints. They are the SAME in both themes on
     purpose - the question is "will this logo read on a light surface and on a
     dark one", and that does not change with the device's setting. Declared
     once, never redeclared in the dark blocks. */
  --rx-preview-light: #ffffff;
  --rx-preview-dark:  #18181b;
}

/* ── Text size and reduced motion (D90, v0.66.0; RX.a11y in engines/rx-a11y.js) ──────
   TEXT SIZE. Every type-size token below is `calc(<px> * var(--rx-scale))`, so ONE
   number on <html> resizes every size the pack draws from a token. --rx-scale is
   declared in its OWN :root rule, not in the theme block: a [data-theme="light"]
   subtree re-declares the tokens, and a --rx-scale inside that block would reset
   the scale for the subtree (an email preview would ignore the person's choice).
   The rule sits AFTER the light block on purpose: selftest and the manifest
   builder read the FIRST :root as the light theme.
   Only TEXT is scaled - not spacing, radii, icon boxes or a unitless line-height.
     html[data-rxtext="large"]   x1.15
     html[data-rxtext="larger"]  x1.3
   RX.a11y.setText() writes the attribute; with none the scale is 1 and every page
   looks exactly as it did before this block existed. */
:root { --rx-scale: 1; }
html[data-rxtext="large"]  { --rx-scale: 1.15; }
html[data-rxtext="larger"] { --rx-scale: 1.3; }
/* v0.67.0 (D91): <body> itself carries a size, 16px = the browser default, so text that
   inherits it (a bare td, .rx-glabel-name, the screen-reader chart table) scales with the rest.
   Identical at Normal. A product that sets its own body size overrides this on purpose. */
body { font-size: calc(16px * var(--rx-scale)); }

/* MOTION. Three states of html[data-rxmotion]: "reduced" (always off), "full" (always
   on, even when the device asks for less), absent = "system" (follow the device's
   prefers-reduced-motion). The standard pattern - near-zero, not none, so the
   transitionend / animationend events a page waits for still fire. */
html[data-rxmotion="reduced"] *, html[data-rxmotion="reduced"] *::before, html[data-rxmotion="reduced"] *::after {
  transition-duration: 0.01ms !important; animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not([data-rxmotion="full"]) *, html:not([data-rxmotion="full"]) *::before, html:not([data-rxmotion="full"]) *::after {
    transition-duration: 0.01ms !important; animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important; scroll-behavior: auto !important;
  }
}

/* ── THE DARK THEME (D64, v0.38.0 - Pierre, 3 Oct 2026) ─────────────────────
   "we need to ensure that all apps work when users have dark theme on the OS.
   This may mean that we need to detect then automatically switch the apps to
   dark theme making sure that everything works."  Supersedes the 20 Aug
   "skipped for now" ruling (DECISIONS.md D64).

   HOW THE THEME IS CHOSEN. Same values, two selectors:
     1. the device: @media (prefers-color-scheme: dark) turns dark on by
        default, unless the page says data-theme="light";
     2. an override: data-theme="dark" | "light" on <html> forces one (it beats
        the device); on any other element it themes just that subtree (an
        email preview stays light inside a dark app);
     3. the person: RX.theme (rx-esc.js) stores System / Light / Dark per
        browser and writes (or removes) data-theme on <html>.
   The light block above is complete on its own, so an app that never loads
   this block's dark half loses nothing. A page's own :root block has lower
   specificity than these selectors, so DARK WINS over a stale page :root.

   RATIOS, measured with RX.contrast (selftest recomputes every one and fails
   if a pair drops). Tiers: TEXT >= 4.5, UI >= 3.0, DECORATIVE (dividers and
   tint borders whose meaning is carried by words) >= 1.3, the light theme's
   own floor. The three figures per token are against page #0f0f12, card
   #18181b and sunken #222227. Lowest in each tier: TEXT 4.68 (--rx-danger-strong
   on sunken), UI 3.12 (a switch knob on its OFF track), DECORATIVE 1.40 (the
   divider on sunken). The full table: node harness/dark-pairs.js. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    /* Ink. Ratios are against --rx-surface-page / -card / -sunken (see the
       table). --rx-ink-subtle is TEXT here (>= 4.5:1 on all three): in the
       light theme it is 2.56:1, the pack's one honest miss, and dark does not
       copy the miss. */
    --rx-ink:         #f4f4f5;   /* 17.41 / 16.12 / 14.41 */
    --rx-ink-muted:   #b4b4bd;   /*  9.30 /  8.61 /  7.69 */
    --rx-ink-subtle:  #9a9aa4;   /*  6.86 /  6.35 /  5.68 */
    --rx-on-ink:      #18181b;   /* 16.12 on --rx-ink */
    --rx-ink-hover:   #d4d4d8;   /* hover of an --rx-ink fill: dimmer; 11.99 with --rx-on-ink */

    /* Surfaces: page darkest, card one step up, sunken one more (tints, row hover). */
    --rx-surface-page:    #0f0f12;
    --rx-surface-card:    #18181b;
    --rx-surface-sunken:  #222227;
    --rx-border:          #3a3a41;   /* divider: 1.70 / 1.57 / 1.40 (decorative, as in light) */
    --rx-border-strong:   #70707b;   /* UI: 3.91 / 3.62 / 3.24 - hover, focus, field edges */
    --rx-switch-off:      #66666f;   /* OFF track; the dark knob (--rx-surface-card) on it is 3.2:1 */

    /* Brand default is the dark panel; a tenant's colours are re-derived by
       RX.brand for dark and written inline (never a dark brand fill on the dark
       surface). --rx-mark and --rx-on-mark are NOT redeclared: the Refocus X
       mark is #7f4fff in both themes (4.07 / 3.77 / 3.37 on the dark
       surfaces, a mark, not text). */
    --rx-brand:     #2a2a31;
    --rx-brand-on:  #f4f4f5;

    /* Accent: BRAND tier lifted to carry text (7.03 / 6.51 / 5.82); STATE tiers
       lifted green. on-accent flips to dark ink: 6.51 on --rx-accent. */
    --rx-accent:        #a78bfa;   /* 7.03 / 6.51 / 5.82 - lifted so purple can carry text */
    --rx-accent-hover:  #c4b5fd;   /* 10.37 / 9.60 / 8.58; steps UP so dark text gains contrast */
    --rx-accent-ui:     #22c55e;   /* UI 8.40 / 7.78 / 6.95 */
    --rx-accent-text:   #4ade80;   /* 10.98 / 10.17 / 9.09 */
    --rx-on-accent:     #18181b;   /* 6.51 on --rx-accent */

    /* Status. X = text AND fill on dark; -on-X = dark ink on the fill.
       Pairs (card): danger 6.40/5.24 strong, warn 10.61/8.25, info 6.97/5.55,
       success 7.78/10.17. On -soft: X 6.17 / 9.58 / 6.25 / 7.17. */
    --rx-danger:         #f87171;
    --rx-danger-strong:  #f25555;
    --rx-danger-soft:    #2b1618;
    --rx-danger-border:  #5c2a2e;
    --rx-on-danger:      #18181b;

    --rx-warn:           #fbbf24;
    --rx-warn-strong:    #f59e0b;
    --rx-warn-soft:      #2a2010;
    --rx-warn-border:    #5c4511;
    --rx-on-warn:        #18181b;

    --rx-info:           #60a5fa;
    --rx-info-strong:    #4f8ff5;
    --rx-info-soft:      #12223d;
    --rx-info-border:    #1f3f73;
    --rx-on-info:        #18181b;

    --rx-hl-yellow:     #5c4a0e;
    --rx-hl-green:      #1f5a34;
    --rx-hl-blue:       #1f4a85;
    --rx-on-hl:         #f4f4f5;

    --rx-magenta:        #e879f9;   /* UI 7.78 / 7.20 / 6.44 against page / card / sunken */
    --rx-on-magenta:     #18181b;   /* 7.20 on --rx-magenta */

    --rx-success:        #22c55e;
    --rx-success-strong: #4ade80;
    --rx-success-soft:   #0f2417;
    --rx-success-border: #1f4a2e;
    --rx-on-success:     #18181b;

    /* Severity fills are alerting surfaces: life-safety colours are never
       re-derived, so critical, pulse, warning and their ink are NOT redeclared.
       Only --rx-alert-info is, because it is a reference to --rx-info-strong
       and that moved: pinned to its light value so white text on it stays 8.6:1. */
    --rx-alert-info: #1e40af;

    /* Category tints: dark tint + light ink (8.35 to 10.17:1). */
    --rx-tint-green:   #14301e;  --rx-tint-green-ink:  #86efac;
    --rx-tint-blue:    #0c2a40;  --rx-tint-blue-ink:   #7dd3fc;
    --rx-tint-purple:  #2a1b4d;  --rx-tint-purple-ink: #c4b5fd;
    --rx-tint-orange:  #3b1d0c;  --rx-tint-orange-ink: #fdba74;
    --rx-tint-amber:   #3a2a0a;  --rx-tint-amber-ink:  #fcd34d;

    /* Overlays and depth: heavier, because a shadow on a dark page is invisible
       unless it is strong; the border does the real work. */
    --rx-scrim:      rgba(0,0,0,.62);
    --rx-scrim-soft: rgba(0,0,0,.4);
    --rx-shadow-sm:     0 1px 3px rgba(0,0,0,.5);
    --rx-shadow:        0 1px 3px rgba(0,0,0,.5), 0 4px 16px rgba(0,0,0,.4);
    --rx-shadow-pop:    0 8px 24px rgba(0,0,0,.6);
    --rx-shadow-modal:  0 16px 50px rgba(0,0,0,.7);
    --rx-focus-ring: 0 0 0 3px rgba(244,244,245,.22);
  }
}

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

  /* Ink. Ratios are against --rx-surface-page / -card / -sunken (see the
     harness/dark-pairs.js). --rx-ink-subtle is TEXT here (>= 4.5:1 on all three): in the
     light theme it is 2.56:1, the pack's one honest miss, and dark does not
     copy the miss. */
  --rx-ink:         #f4f4f5;   /* 17.41 / 16.12 / 14.41 */
  --rx-ink-muted:   #b4b4bd;   /*  9.30 /  8.61 /  7.69 */
  --rx-ink-subtle:  #9a9aa4;   /*  6.86 /  6.35 /  5.68 */
  --rx-on-ink:      #18181b;   /* 16.12 on --rx-ink */
  --rx-ink-hover:   #d4d4d8;   /* hover of an --rx-ink fill: dimmer; 11.99 with --rx-on-ink */

  /* Surfaces: page darkest, card one step up, sunken one more (tints, row hover). */
  --rx-surface-page:    #0f0f12;
  --rx-surface-card:    #18181b;
  --rx-surface-sunken:  #222227;
  --rx-border:          #3a3a41;   /* divider: 1.70 / 1.57 / 1.40 (decorative, as in light) */
  --rx-border-strong:   #70707b;   /* UI: 3.91 / 3.62 / 3.24 - hover, focus, field edges */
  --rx-switch-off:      #66666f;   /* OFF track; the dark knob (--rx-surface-card) on it is 3.2:1 */

  /* Brand default is the dark panel; a tenant's colours are re-derived by
     RX.brand for dark and written inline (never a dark brand fill on the dark
     surface). --rx-mark and --rx-on-mark are NOT redeclared: the Refocus X
     mark is #7f4fff in both themes (4.07 / 3.77 / 3.37 on the dark
       surfaces, a mark, not text). */
  --rx-brand:     #2a2a31;
  --rx-brand-on:  #f4f4f5;

  /* Accent: BRAND tier lifted to carry text (7.03 / 6.51 / 5.82); STATE tiers
     lifted green. on-accent flips to dark ink: 6.51 on --rx-accent. */
  --rx-accent:        #a78bfa;   /* 7.03 / 6.51 / 5.82 - lifted so purple can carry text */
  --rx-accent-hover:  #c4b5fd;   /* 10.37 / 9.60 / 8.58; steps UP so dark text gains contrast */
  --rx-accent-ui:     #22c55e;   /* UI 8.40 / 7.78 / 6.95 */
  --rx-accent-text:   #4ade80;   /* 10.98 / 10.17 / 9.09 */
  --rx-on-accent:     #18181b;   /* 6.51 on --rx-accent */

  /* Status. X = text AND fill on dark; -on-X = dark ink on the fill.
     Pairs (card): danger 6.40/5.24 strong, warn 10.61/8.25, info 6.97/5.55,
     success 7.78/10.17. On -soft: X 6.17 / 9.58 / 6.25 / 7.17. */
  --rx-danger:         #f87171;
  --rx-danger-strong:  #f25555;
  --rx-danger-soft:    #2b1618;
  --rx-danger-border:  #5c2a2e;
  --rx-on-danger:      #18181b;

  --rx-warn:           #fbbf24;
  --rx-warn-strong:    #f59e0b;
  --rx-warn-soft:      #2a2010;
  --rx-warn-border:    #5c4511;
  --rx-on-warn:        #18181b;

  --rx-info:           #60a5fa;
  --rx-info-strong:    #4f8ff5;
  --rx-info-soft:      #12223d;
  --rx-info-border:    #1f3f73;
  --rx-on-info:        #18181b;

  --rx-hl-yellow:     #5c4a0e;
  --rx-hl-green:      #1f5a34;
  --rx-hl-blue:       #1f4a85;
  --rx-on-hl:         #f4f4f5;

  --rx-magenta:        #e879f9;   /* UI 7.78 / 7.20 / 6.44 against page / card / sunken */
  --rx-on-magenta:     #18181b;   /* 7.20 on --rx-magenta */

  --rx-success:        #22c55e;
  --rx-success-strong: #4ade80;
  --rx-success-soft:   #0f2417;
  --rx-success-border: #1f4a2e;
  --rx-on-success:     #18181b;

  /* Severity fills are alerting surfaces: life-safety colours are never
     re-derived, so critical, pulse, warning and their ink are NOT redeclared.
     Only --rx-alert-info is, because it is a reference to --rx-info-strong
     and that moved: pinned to its light value so white text on it stays 8.6:1. */
  --rx-alert-info: #1e40af;

  /* Category tints: dark tint + light ink (8.35 to 10.17:1). */
  --rx-tint-green:   #14301e;  --rx-tint-green-ink:  #86efac;
  --rx-tint-blue:    #0c2a40;  --rx-tint-blue-ink:   #7dd3fc;
  --rx-tint-purple:  #2a1b4d;  --rx-tint-purple-ink: #c4b5fd;
  --rx-tint-orange:  #3b1d0c;  --rx-tint-orange-ink: #fdba74;
  --rx-tint-amber:   #3a2a0a;  --rx-tint-amber-ink:  #fcd34d;

  /* Overlays and depth: heavier, because a shadow on a dark page is invisible
     unless it is strong; the border does the real work. */
  --rx-scrim:      rgba(0,0,0,.62);
  --rx-scrim-soft: rgba(0,0,0,.4);
  --rx-shadow-sm:     0 1px 3px rgba(0,0,0,.5);
  --rx-shadow:        0 1px 3px rgba(0,0,0,.5), 0 4px 16px rgba(0,0,0,.4);
  --rx-shadow-pop:    0 8px 24px rgba(0,0,0,.6);
  --rx-shadow-modal:  0 16px 50px rgba(0,0,0,.7);
  --rx-focus-ring: 0 0 0 3px rgba(244,244,245,.22);
}

/* On paper the highlighter keeps its light fills and dark text in every theme (PD-013, D122). */
@media print {
  :root, :root:not([data-theme="light"]), html[data-theme="dark"], [data-theme="dark"] {
    --rx-hl-yellow: #fef08a;
    --rx-hl-green:  #bbf7d0;
    --rx-hl-blue:   #bfdbfe;
    --rx-on-hl:     #18181b;
  }
}

/* An element carrying data-theme (not <html>) re-states ink and page so its
   subtree reads correctly even inside the opposite theme. */
[data-theme="light"]:not(html), [data-theme="dark"]:not(html) {
  color: var(--rx-ink);
  background: var(--rx-surface-page);
}

/* ── Adopting this in an app that already has its own token names? ──────────
   Do not edit this file. Link the matching alias sheet from `compat/` after
   it, and the app's existing `var(--its-own-name)` keeps working unchanged:

     <link rel="stylesheet" href="/design-pack/tokens.css">
     <link rel="stylesheet" href="/design-pack/compat/filedrop.css">

   Alias sheets are per-app and disposable — delete one when its app has
   finished migrating to the --rx-* names. Keeping them here rather than in
   this file means tokens.css stays the standard, not a pile of history.
   ============================================================================ */

/* ============================================================================
   BASE — the three rules every Refocus X app needs. Nothing else is imposed.
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--rx-font);
  background: var(--rx-surface-page);
  color: var(--rx-ink);
  margin: 0;
  /* Long unbroken strings — filenames, ids, email addresses — must wrap
     instead of forcing a horizontal scrollbar. This one line prevents a
     whole class of layout bug. */
  overflow-wrap: anywhere;
}

/* ── Layout primitives ─────────────────────────────────────────────────────
   Wrap page content in .rx-page. Put cards in a .rx-grid. Mark a full-bleed
   cell .rx-col-span. That is the entire layout system. */
/* The page-title size travels WITH the width modifier, because in the source
   it always did — 22px on management screens, 24px on task forms. That looked
   like inconsistent values until the pages were grouped by type, at which
   point it was one rule. See DECISIONS.md D12. (A third pairing, 26px with
   the canvas width, went with that width in D47.) */
.rx-page   { width: 100%; max-width: var(--rx-content-max); margin: 0 auto;
             --rx-page-title: var(--rx-title); }
.rx-page--form   { max-width: var(--rx-form-max);   --rx-page-title: calc(24px * var(--rx-scale)); }

.rx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--rx-gap);
  align-items: start;
}
.rx-grid > .rx-col-span { grid-column: 1 / -1; }

@media (max-width: 720px) {
  .rx-grid { grid-template-columns: 1fr; }
}
