/* =====================================================================
   Etheria 2.0 · Design tokens ("Offen + Interface-Farben", open-spec
   2026-10-25; replaces the "Ingame-Look" box mode and every older
   direction wherever they conflict)

   Cascade layers of the whole e2 system, declared once, here:
     e2.tokens     custom properties only (this file)
     e2.base       reset, element defaults, a11y helpers, radius
                   registry, open patterns, the motion layer (e2-base.css)
     e2.layout     containers, bands, grids, archetypes   (e2-layout.css, shell/*.css)
     e2.components component classes                       (components/*.css)
     e2.prose      long-form CMS HTML                      (e2-prose.css)
     e2.pages      per-page CSS                            (pages/<id>.css)
     e2.compat     legacy-shell / admin compat             (above pages, below utilities)
     e2.utilities  single-purpose helpers
   e2-print.css is unlayered inside @media print, so it wins over all layers.

   The look in one sentence: content sits OPEN on the page in full-width
   bands (ivory by day, slate by night), separated by hairlines and band
   tones instead of boxes; champagne gold only as a thin accent (kicker
   diamond, dividers, the accent word, medals); a soft "sheet" surface
   only where a surface is needed (forms, dialogs, menus, toasts).

   Rules:
   - Every colour of the theme lives in this file and nowhere else.
     Other files use var(--e2-*) only (static check S2).
   - LIGHT ("day") IS THE DEFAULT (:root, .scheme-day, .e2-scheme-day).
     Dark is .scheme-night on <body> (cookie moe_scheme=night; also
     :root:has(> body.scheme-night), so the root scrollbar and
     color-scheme follow) and, locally, .e2-scheme-night (a dark island,
     e.g. the footer) or .e2-on-image (content on a photo: light ink,
     transparent background, the same in both schemes).
   - There is no light island any more: --e2-win-* / --e2-navy-* /
     --e2-btn-* … are legacy names that now resolve to the open palette
     of the current scheme (section 5), so un-ported CSS stays legible.
   - Tokens that reference other scheme tokens via var() are re-declared
     on every scheme root (section 5), because a custom property resolves
     var() where it is declared, not where it is used.
   - Contrast (WCAG 2.x; storage/tools/e2/contrast.py --scheme both):
     every text token passes 4.5:1 on every page tone it is meant for
     (--e2-bg, --e2-bg-2, --e2-bg-3, --e2-surface*), "large" tokens 3:1,
     UI / state tokens 3:1. Exceptions are marked "decoration only".
   - Shapes: rounded and soft (--e2-r-*); pills (999px) for buttons,
     chips, tags, tabs and status; images 16px; the sheet 24px.
   - Deprecated tokens (section 11) still resolve; delete each one when
     grep finds no use any more.
   ===================================================================== */

@layer e2.tokens, e2.base, e2.layout, e2.components, e2.prose, e2.pages, e2.compat, e2.utilities;

@layer e2.tokens {

  /* ------------------------------------------------------------------
     1. Scheme-independent tokens
     ------------------------------------------------------------------ */
  :root {
    /* Type scale (rem = px / 16; fluid maximum around 1440px).
       Big, confident Nunito headings (open-spec "Typography"). */
    --e2-fs-hero: clamp(2.875rem, 6vw, 5.125rem); /* 46-82px  landing H1 */
    --e2-fs-h1: clamp(2.25rem, 4.4vw, 3.75rem); /* 36-60px  banner H1 */
    --e2-fs-h2: clamp(1.875rem, 3.4vw, 2.75rem); /* 30-44px  section titles */
    --e2-fs-h3: clamp(1.125rem, 1.4vw, 1.3125rem); /* 18-21px  card / group titles */
    --e2-fs-h4: 1.0625rem; /* 17px */
    --e2-fs-lead: clamp(1rem, 1.2vw, 1.125rem); /* 16-18px */
    --e2-fs-body: 1rem; /* 16px (minimum body size) */
    --e2-fs-prose: 1.0625rem; /* 17px */
    --e2-fs-sm: 0.9375rem; /* 15px  card text, list text */
    --e2-fs-xs: 0.8125rem; /* 13px  meta, labels */
    --e2-fs-kicker: 0.78125rem; /* 12.5px, UPPER, letter-spaced, max 4 words */
    --e2-fs-hud: 0.75rem; /* 12px, small-caps labels (table heads, stat labels) */
    --e2-fs-stat: clamp(1.625rem, 2.6vw, 2.25rem); /* 26-36px  big numbers */
    --e2-fs-stat-lg: clamp(2rem, 3.6vw, 3rem); /* 32-48px  hero facts, KPI */
    --e2-fs-tagline: clamp(1.125rem, 1.6vw, 1.5rem); /* 18-24px */
    --e2-fs-win-title: 1.0625rem; /* 17px  surface heading (sheet / card) */
    --e2-fs-win-sub: 0.9375rem; /* 15px  sub heading */
    --e2-fs-sec: 0.9375rem; /* 15px  group head inside a surface */
    --e2-fs-label: 0.84375rem; /* 13.5px  form labels (Nunito 800, gold text) */

    /* Spacing: 4px base */
    --e2-space-1: 4px;
    --e2-space-2: 8px;
    --e2-space-3: 12px;
    --e2-space-4: 16px;
    --e2-space-5: 20px;
    --e2-space-6: 24px;
    --e2-space-7: 32px;
    --e2-space-8: 40px;
    --e2-space-9: 48px;
    --e2-space-10: 64px;
    --e2-space-11: 80px;
    --e2-space-12: 96px;
    --e2-space-13: 128px;
    --e2-gutter: clamp(16px, 4vw, 32px); /* 16px side gutter on phones */
    --e2-section-y: clamp(56px, 7.8vw, 112px); /* band padding: 56-72px phone, 96-112px desktop */
    --e2-section-y-sm: clamp(40px, 5vw, 72px); /* tighter band (follow-up band, admin) */
    --e2-band-gap: clamp(36px, 4.4vw, 56px); /* head -> content inside a band */
    --e2-split-gap: clamp(32px, 5vw, 72px); /* image + text split */
    --e2-grid-gap: clamp(20px, 2.4vw, 34px); /* card grids */
    --e2-seam-size: clamp(40px, 6vw, 80px); /* always < section-y */
    --e2-panel-pad: clamp(16px, 2.2vw, 28px); /* sheet / card body padding */
    --e2-sheet-pad: clamp(22px, 2.6vw, 34px); /* form sheet padding */
    --e2-stack: 16px;
    --e2-main-pt: clamp(40px, 5vw, 72px);
    --e2-main-pb: var(--e2-section-y);

    /* Containers and fixed sizes */
    --e2-container: 1240px; /* max content width (open-spec) */
    --e2-container-wide: 1440px;
    --e2-container-narrow: 760px;
    --e2-prose: 72ch;
    --e2-measure: 60ch;
    --e2-lead-measure: 36rem; /* ~560px lead width */
    --e2-aside: 320px;
    --e2-auth-card: 440px; /* sign-in sheet */
    --e2-char-safe: 28%;
    --e2-header-h: 64px; /* 76px from --e2-bp-md, see below */
    --e2-bottom-offset: 0px; /* height of the visible bottom bar (cookie / play bar), set by the shell */
    --e2-sticky-bar-h: 72px; /* sticky form action bar (admin) */
    --e2-target: 44px;
    --e2-target-min: 24px;
    --e2-row-h: 56px; /* open list row */
    --e2-icon-xs: 14px;
    --e2-icon-sm: 16px;
    --e2-icon-md: 20px;
    --e2-icon-lg: 24px;
    --e2-icon-xl: 32px;
    --e2-disc: 34px; /* icon disc of a pill button (sm 28px) */
    --e2-disc-sm: 28px;
    --e2-disc-lg: 52px; /* pillar / feature icon disc */
    --e2-medal: 32px; /* rank medal disc */
    --e2-medal-lg: 44px; /* podium medal */
    --e2-dot: 9px; /* status dot */
    --e2-banner-h: clamp(260px, 30vw, 440px); /* subpage banner band (shell) */

    /* Focus ring: 3px --e2-focus outside + 1px --e2-focus-inner between
       element and ring. A component that sets its own box-shadow appends
       var(--e2-focus-ring) on :focus-visible. */
    --e2-focus-w: 3px;
    --e2-focus-offset: 1px;
    --e2-focus-ring: 0 0 0 1px var(--e2-focus-inner);

    /* Surface geometry (the sheet; legacy window names kept for the
       un-ported files: no title bars any more, see e2-base.css) */
    --e2-win-title-h: 36px;
    --e2-win-sub-h: 30px;
    --e2-win-pad: var(--e2-panel-pad);
    --e2-win-in-pad: 14px 16px;
    --e2-win-gap: 12px;
    --e2-win-orn: 0px; /* corner brackets are retired */
    --e2-win-dia: 8px; /* the gold diamond (kicker, divider, bullets) */
    --e2-title-dia: 7px;
    --e2-sheet-inset: 8px; /* inner hairline of the sheet */
    --e2-kicker-dia: 7px; /* kicker diamond (outlined) */

    /* Radii: soft and rounded; pills for buttons, chips, tags, tabs */
    --e2-r-xs: 4px; /* checkboxes, code, tiny keys */
    --e2-r-sm: 8px; /* small thumbs, flags, inner chips */
    --e2-r-btn: 999px; /* buttons, tabs, segments: interface pills */
    --e2-r-md: 12px; /* inputs, inner groups, prose images */
    --e2-r-lg: 16px; /* images, cards */
    --e2-r-xl: 22px; /* big feature images ("shot") */
    --e2-r-win: 20px; /* dialogs, menus, legacy windows */
    --e2-r-in: 12px; /* inner group, row strip, stat well */
    --e2-r-img: 16px; /* image-led cards: rounded image, text below */
    --e2-r-shot: 22px; /* split-layout feature image */
    --e2-r-sheet: 24px; /* form sheet */
    --e2-r-sheet-in: 16px; /* inner hairline of the sheet (sheet - inset) */
    --e2-r-card: 14px; /* subtle cards (admin groups, compact surfaces) */
    --e2-r-input: 12px;
    --e2-r-pill: 999px; /* chips, tags, status pills, rank pills */
    --e2-r-round: 50%; /* medals, discs, radios, avatar, orbs */

    /* Legacy chamfer sizes, now corner RADII (the registry in e2-base.css
       turns --e2-c into border-radius; --e2-cut is "none"). */
    --e2-cut-xs: 8px;
    --e2-cut-sm: 10px;
    --e2-cut-md: 12px;
    --e2-cut-lg: 14px;
    --e2-cut-xl: 16px;
    --e2-cut-2xl: 20px;
    --e2-chamfer: var(--e2-cut-lg);

    /* Frames: an open image with a soft rounded edge (no mat, no frame) */
    --e2-frame-pad: 0px;
    --e2-frame-inner-r: var(--e2-r-img);

    /* Motion (motion-spec 2026-10-25 + open-spec "Motion"; calm, alive,
       never floaty). Movement durations and distances collapse under
       reduced motion (section 8) as a SAFETY NET only: every animated
       rule still handles reduced motion itself (e2-base.css "Motion",
       the gate). --e2-dur-fade stays: a short colour / opacity change is
       not motion. Loop periods never collapse (an infinite .01ms loop
       would flicker): every loop stops in its own rule. */
    --e2-dur-press: 80ms; /* button / key press */
    --e2-dur-1: 120ms; /* micro: hover colour, tooltip, ring */
    --e2-dur-2: 200ms; /* small: state change, backdrop */
    --e2-dur-3: 320ms; /* surface open (dialog, sheet, menu) */
    --e2-dur-4: 480ms; /* section entrance */
    --e2-dur-5: 1200ms; /* slow cross-fade (banner video) */
    --e2-dur-fade: 150ms; /* colour / opacity only; stays under reduced motion */
    --e2-dur-enter: 480ms; /* section / card / row entrance (timed path) */
    --e2-dur-img: 900ms; /* image reveal (clip / scale) */
    --e2-dur-draw: 700ms; /* divider hairlines draw from the centre */
    --e2-dur-exit: 180ms; /* dialog / sheet / toast exit */
    --e2-dur-menu: 180ms; /* dropdown / menu open */
    --e2-dur-menu-out: 140ms; /* dropdown / menu close */
    --e2-dur-page: 320ms; /* cross-document page transition (new page) */
    --e2-dur-page-out: 200ms; /* page transition (old page) */
    --e2-dur-hover: 400ms; /* card image zoom, underline grow */
    --e2-dur-glint: 600ms; /* light streak, one sweep */
    --e2-dur-shine: 500ms; /* pill shine sweep */
    --e2-dur-count: 900ms; /* count-up of numbers (countup.js reads it) */
    --e2-dur-grow: 700ms; /* bars / connector lines growing once */
    --e2-ease-out: cubic-bezier(.2, .8, .2, 1);
    --e2-ease-in: cubic-bezier(.4, 0, 1, 1); /* exits */
    --e2-ease-in-out: cubic-bezier(.65, 0, .35, 1);
    --e2-ease-spring: cubic-bezier(.34, 1.45, .64, 1); /* dialogs, keys, medals */
    --e2-ease-spring-lite: cubic-bezier(.3, 1.2, .55, 1); /* page swap, rows */
    --e2-ease-soft: cubic-bezier(.22, .61, .36, 1); /* section reveal, image reveal */
    --e2-ease-pop: var(--e2-ease-spring); /* legacy alias */
    --e2-stagger: 70ms; /* x --i / --e2-i (section reveal: 60-80ms) */
    --e2-stagger-max: 8; /* stagger steps at most (a number for min()) */
    --e2-dur-spin: 220s; /* rune ring */
    --e2-dur-float: 6s; /* character idle float, amplitude 6px */
    --e2-dur-mote-min: 14s;
    --e2-dur-mote-max: 30s;
    --e2-dur-pulse: 2.4s; /* status pulse (finite) */
    --e2-dur-breathe: 2.5s; /* online dot breathing */
    --e2-dur-glow: 4s; /* star CTA idle glow */
    --e2-dur-sweep: 6s; /* light sweep over gold accent words (incl. pause) */
    --e2-dur-medal: 6s; /* rank-1 medal glint period (700ms glint + pause) */
    --e2-dur-rotate: 9s; /* showcase auto-rotation */
    --e2-dur-failsafe: 3s; /* reveal / pre-hidden content failsafe */
    /* Distances and scales (0 / 1 under reduced motion, section 8) */
    --e2-reveal-y: 16px; /* section reveal: kicker, heading, lead, content fade up */
    --e2-reveal-row-y: 10px; /* list rows / strips */
    --e2-reveal-img-scale: 1.04; /* images settle from 1.04 to 1 */
    --e2-reveal-clip: inset(6% 4% 6% 4% round var(--e2-r-img)); /* images open from a soft inset */
    --e2-enter-y: var(--e2-reveal-y); /* legacy name (parked motion work) */
    --e2-enter-scale: 1; /* the open look does not scale content */
    --e2-enter-row-y: var(--e2-reveal-row-y);
    --e2-rise-y: 12px; /* new content / banner text fades up */
    --e2-sink-y: 8px; /* old content sinks (page swap) */
    --e2-lift: -3px; /* hover lift (sheets, admin cards) */
    --e2-lift-row: -1px; /* hover lift of list rows */
    --e2-press-y: 1px; /* pressed pill */
    --e2-menu-y: -6px; /* menus open from 6px above */
    --e2-menu-scale: .96;
    --e2-dialog-scale: .92;
    --e2-tip-y: 4px; /* tooltips rise 4px */
    --e2-zoom: 1.04; /* image zoom inside a hovered card */
    --e2-key-hover: 1.08; /* round disc hover scale */
    --e2-key-press: .94; /* round disc press scale */
    --e2-parallax: 40px; /* full-bleed band background drift (<= 40px) */
    --e2-motion: 1; /* 0 under reduced motion (readable by JS) */

    /* Breakpoints (documentation only: custom properties cannot be used in
       @media; components use the same numbers, mobile first, min-width) */
    --e2-bp-sm: 480px; /* 2-column card grids */
    --e2-bp-md: 720px; /* header 64 -> 76px; real tables; footer 2 columns */
    --e2-bp-lg: 960px; /* split layouts, hero / banner video */
    --e2-bp-xl: 1120px; /* full desktop nav; aside column */
    --e2-bp-2xl: 1360px;
    --e2-bp-3xl: 1600px;

    /* Z-index scale */
    --e2-z-below: -1;
    --e2-z-base: 0;
    --e2-z-raised: 10;
    --e2-z-sticky: 80;
    --e2-z-dropdown: 90;
    --e2-z-overlay: 100;
    --e2-z-dialog: 110;
    --e2-z-toast: 120;
    --e2-z-skip: 200;

    /* Density (admin sets compact) */
    --e2-density: comfortable;

    /* Assets used from CSS (root-relative, manually versioned) */
    --e2-orn-rune: url("/assets/e2/img/ornaments/rune-ring.svg?v=1");

    /* ---- The interface palette (constants; the scheme blocks map them
            to roles). Ivory, slate, champagne gold, rarity accents. ---- */
    --e2-slate-0: #161924;
    --e2-slate-1: #1c2030;
    --e2-slate-2: #242a3b;
    --e2-slate-3: #2f3649;
    --e2-slate-4: #3b4255;
    --e2-slate-5: #4f586d;
    --e2-ivory: #ece5d8;
    --e2-ivory-2: #f6f2ea;
    --e2-ivory-3: #d9cfbd;
    --e2-paper: #fffdf8; /* the light sheet */
    --e2-gold-hi: #f1e3c0; /* champagne: light gold (text on dark) */
    --e2-gold-mid: #d3bc8e; /* champagne: gold (decor on dark) */
    --e2-gold-lo: #a8875a; /* champagne: deep gold (decor on light) */
    --e2-gold-deep: #8a6a3a; /* champagne: large gold text on light */

    /* Rarity accents (also status / badges). The fills are the same in
       both schemes; their TEXT variants are per scheme (--e2-rarity-*-ink). */
    --e2-rarity-5: #e8b24f; /* 5★ gold-orange */
    --e2-rarity-5-hi: #fff1c9;
    --e2-rarity-5-lo: #b8763a;
    --e2-rarity-4: #a07cc5; /* 4★ violet */
    --e2-rarity-4-hi: #f3ecff;
    --e2-rarity-4-lo: #6d4c94;
    --e2-rarity-3: #5a86c8; /* 3★ blue */
    --e2-rarity-3-hi: #e6f0ff;
    --e2-rarity-3-lo: #36598f;
    --e2-jade: #74c2a8; /* online / ok */
    --e2-ember: #ef7938; /* warning / dungeon / offline */

    /* Fixed colours that are the same in both schemes */
    --e2-mask: #000; /* opaque stop for mask-image gradients (alpha only) */
    --e2-qr-bg: #fff; /* QR tile, always white for scanability */
    --e2-white: #fff; /* text on slate / rarity fills */
    --e2-on-image: #f6f2ea; /* light text on photos (banner, hero, world band) */
    --e2-on-image-2: #e7e0d3; /* secondary text on photos (behind a scrim) */
    --e2-plate-edge: rgb(255 255 255 / .55);
    --e2-btn-violet-edge: #2f3649;

    /* Pills (buttons): star CTA (main CTA only), ivory default, slate
       secondary, danger. Fills are the same in both schemes. Text sits on
       the middle stop (contrast is checked there). */
    --e2-pill-star-1: #f2c66d;
    --e2-pill-star-2: #e0a446;
    --e2-pill-star-3: #b8763a;
    --e2-pill-star-edge: #9c6328;
    --e2-pill-star-ink: #3b2a10; /* 6.3 on star-2 (AA). The spec's white text is --e2-pill-star-ink-light (2.2: decoration-grade, see notes) */
    --e2-pill-star-ink-light: #fff;
    --e2-pill-star-shadow: 0 1px 1px rgb(90 50 0 / .4); /* text-shadow of light ink on the star */
    --e2-pill-ivory-1: #f8f4ec;
    --e2-pill-ivory-2: #ece5d8;
    --e2-pill-ivory-edge: #cdbf9f;
    --e2-pill-ivory-ink: #3b4255; /* 8.0 */
    --e2-pill-slate-1: #4f586d;
    --e2-pill-slate-2: #3b4255;
    --e2-pill-slate-edge: rgb(211 188 142 / .45);
    --e2-pill-slate-ink: #ece5d8; /* 5.7 / 8.0 */
    --e2-pill-danger-1: #c05038;
    --e2-pill-danger-2: #9e3b26;
    --e2-pill-danger-edge: #7a2a1a;
    --e2-pill-danger-ink: #fff; /* 4.7 / 6.8 */
    --e2-grad-star: linear-gradient(180deg, var(--e2-pill-star-1), var(--e2-pill-star-2) 55%, var(--e2-pill-star-3));
    --e2-grad-ivory: linear-gradient(180deg, var(--e2-pill-ivory-1), var(--e2-pill-ivory-2));
    --e2-grad-slate: linear-gradient(180deg, var(--e2-pill-slate-1), var(--e2-pill-slate-2));
    --e2-grad-danger-pill: linear-gradient(180deg, var(--e2-pill-danger-1), var(--e2-pill-danger-2));
    /* Icon discs (inline-start of a pill; 34px, sm 28px) */
    --e2-disc-gold: radial-gradient(circle at 35% 30%, #f5d58a, #d9a441 70%, #b07d2a); /* on ivory pills */
    --e2-disc-gold-ink: #fff;
    --e2-disc-white: radial-gradient(circle at 35% 30%, #fff, #f5ead2); /* on the star */
    --e2-disc-white-ink: #b8763a;
    --e2-disc-ivory: radial-gradient(circle at 35% 30%, #fff, #ece5d8); /* on slate pills */
    --e2-disc-ivory-ink: #3b4255;
    --e2-disc-soft: radial-gradient(circle at 35% 30%, rgb(241 227 192 / .25), rgb(211 188 142 / .08)); /* pillar icon disc (decor) */
    --e2-disc-halo: 0 0 0 6px rgb(255 255 255 / .16); /* soft light ring around a play disc on a photo */
    --e2-halo-glow-4: radial-gradient(circle, rgb(160 124 197 / .26), rgb(160 124 197 / 0) 65%); /* 4★ halo (podium rank 2) */
    --e2-halo-glow-3: radial-gradient(circle, rgb(90 134 200 / .24), rgb(90 134 200 / 0) 65%); /* 3★ halo (podium rank 3) */

    /* Rank medals: 5★ / 4★ / 3★ discs with gloss (dark ink on all three) */
    --e2-medal-1a: var(--e2-rarity-5-hi);
    --e2-medal-1: var(--e2-rarity-5);
    --e2-medal-1b: var(--e2-rarity-5-lo);
    --e2-medal-1-rim: #b8763a;
    --e2-medal-1-ink: #4a2f00; /* 6.4 on the mid stop */
    --e2-medal-2a: var(--e2-rarity-4-hi);
    --e2-medal-2: var(--e2-rarity-4);
    --e2-medal-2b: var(--e2-rarity-4-lo);
    --e2-medal-2-rim: #6d4c94;
    --e2-medal-2-ink: #241638; /* 5.0 */
    --e2-medal-3a: var(--e2-rarity-3-hi);
    --e2-medal-3: var(--e2-rarity-3);
    --e2-medal-3b: var(--e2-rarity-3-lo);
    --e2-medal-3-rim: #36598f;
    --e2-medal-3-ink: #0f1d33; /* 4.6 */
    --e2-medal-ink: #4a2f00;
    --e2-medal-ring: rgb(255 255 255 / .7); /* thin light ring around medals / discs */
    --e2-grad-medal-1: radial-gradient(circle at 35% 30%, var(--e2-medal-1a), var(--e2-medal-1) 55%, var(--e2-medal-1b));
    --e2-grad-medal-2: radial-gradient(circle at 35% 30%, var(--e2-medal-2a), var(--e2-medal-2) 60%, var(--e2-medal-2b));
    --e2-grad-medal-3: radial-gradient(circle at 35% 30%, var(--e2-medal-3a), var(--e2-medal-3) 60%, var(--e2-medal-3b));
    --e2-medal-glow-1: 0 0 18px rgb(232 178 79 / .45);
    --e2-medal-glow-2: 0 0 14px rgb(160 124 197 / .35);
    --e2-medal-glow-3: 0 0 14px rgb(90 134 200 / .32);
    --e2-medal-shadow-1: var(--e2-medal-glow-1);
    --e2-medal-shadow-2: var(--e2-medal-glow-2);
    --e2-medal-shadow-3: var(--e2-medal-glow-3);

    /* Orb (category trees), chip dots */
    --e2-orb-1: #fff1c9;
    --e2-orb-2: #e8b24f;
    --e2-orb-3: #b8763a;
    --e2-orb-edge: #9c6328;
    --e2-dot-yellow: #e8b24f;
    --e2-dot-green: #74c2a8;
    --e2-dot-red: #ef7938;
    --e2-dot-blue: #5a86c8;
    --e2-dot-violet: #a07cc5;

    /* Tags / badges (pills, Nunito 800 12px): text passes 4.5 on each fill */
    --e2-tag-blue: #3d68ab; /* white 5.6 (3★) */
    --e2-tag-violet: #7a55a3; /* white 5.7 (4★) */
    --e2-tag-yellow: #e8b24f; /* ink --e2-tag-yellow-ink 7.2 (5★) */
    --e2-tag-yellow-ink: #3b2a10;
    --e2-tag-green: #2f7a62; /* white 5.2 (jade) */
    --e2-tag-red: #b4432a; /* white 5.6 (ember) */
    --e2-tag-grey: #5d6578; /* white 5.8 */
    --e2-tag-ink: #fff;

    /* Gradients built from the palette (constants) */
    --e2-grad-titlebar: linear-gradient(180deg, var(--e2-slate-5), var(--e2-slate-4)); /* legacy: no title bars; slate band */
    --e2-grad-subbar: linear-gradient(180deg, var(--e2-slate-5), var(--e2-slate-4));
    --e2-grad-navy-key: var(--e2-grad-slate); /* selected tab / chip: slate pill */
    --e2-grad-btn: var(--e2-grad-slate);
    --e2-grad-key: var(--e2-grad-slate); /* round keys */
    --e2-grad-cta: var(--e2-grad-star);
    --e2-grad-cream: var(--e2-grad-ivory);
    --e2-grad-grey: linear-gradient(180deg, #7b8394, #5d6578);
    --e2-grad-danger: var(--e2-grad-danger-pill);
    --e2-grad-feature: var(--e2-grad-slate);
    --e2-grad-tab: var(--e2-grad-ivory);
    --e2-grad-orb: radial-gradient(circle at 35% 30%, var(--e2-orb-1), var(--e2-orb-2) 60%, var(--e2-orb-3));
    --e2-grad-gold-word: linear-gradient(180deg, #fff3d6, #e8c88a 55%, #c99a4f); /* accent word on dark / photos */
    --e2-orn-line: linear-gradient(90deg, transparent, var(--e2-gold-mid));
    --e2-orn-line-end: linear-gradient(270deg, transparent, var(--e2-gold-mid));

    /* Plate shadows (constant) */
    --e2-hi: inset 0 1px 0 rgb(255 255 255 / .35); /* soft top highlight of a pill */
    --e2-btn-shadow: inset 0 1px 0 rgb(255 255 255 / .3), 0 4px 12px rgb(22 25 36 / .18);
    --e2-btn-shadow-cream: inset 0 1px 0 #fff, 0 4px 12px rgb(22 25 36 / .14);
    --e2-btn-press: inset 0 2px 4px rgb(0 0 0 / .22);
    --e2-tab-shadow: 0 1px 2px rgb(22 25 36 / .12);
    --e2-key-shadow: 0 2px 6px rgb(22 25 36 / .22);
    --e2-chip-shadow: none;
    --e2-text-shadow-dark: 0 1px 1px rgb(0 0 0 / .25); /* light text on slate / photos */
    --e2-text-shadow-light: 0 1px 0 rgb(255 255 255 / .5);
    --e2-text-shadow-image: 0 1px 6px rgb(0 0 0 / .45); /* light text directly on a photo */
    --e2-title-dia-glow: 0 0 6px rgb(241 227 192 / .7);
    --e2-hover-ring: 0 0 0 1px var(--e2-gold-mid);

    /* Photo scrims (scheme-independent: a banner / hero / world band is
       always image + light text; open-spec "Subpage banners") */
    --e2-scrim-photo-x: linear-gradient(90deg, rgb(22 25 36 / .82), rgb(22 25 36 / .34) 55%, rgb(22 25 36 / 0) 80%);
    --e2-scrim-photo-y: linear-gradient(0deg, rgb(22 25 36 / .88), rgb(22 25 36 / .12) 62%);
    --e2-scrim-photo: linear-gradient(180deg, rgb(22 25 36 / .25), rgb(22 25 36 / .62)); /* even veil for centred text */
    --e2-chip-photo-bg: rgb(22 25 36 / .55);
    --e2-chip-photo-line: rgb(211 188 142 / .4);

    /* Glints (decoration only, no contrast) */
    --e2-glint-hi: rgb(255 255 255 / .42);
    --e2-glint: linear-gradient(105deg, transparent 0 38%, var(--e2-glint-hi) 50%, transparent 62% 100%);
    --e2-glint-gold: drop-shadow(0 0 3px rgb(255 226 150 / .9));
    --e2-glint-soft: rgb(255 244 214 / .6); /* medal glint streak */

    /* Window scrollbar (inside scroll areas) */
    --e2-win-scroll-thumb: var(--e2-slate-5);

    /* Violet plate (legacy name; slate) */
    --e2-btn-violet-ink: #fff;
    --e2-btn-violet-text-shadow: rgb(0 0 0 / .3);

    /* Danger solid plate (confirm dialogs) */
    --e2-btn-danger-top: var(--e2-pill-danger-1);
    --e2-btn-danger-mid: var(--e2-pill-danger-1);
    --e2-btn-danger-bottom: var(--e2-pill-danger-2);
    --e2-btn-danger-border: var(--e2-pill-danger-edge);
    --e2-btn-danger-ink: #fff;

    /* Legacy palette constants (box mode names -> open palette) */
    --e2-navy-1: var(--e2-slate-5);
    --e2-navy-2: var(--e2-slate-4);
    --e2-navy-3: var(--e2-slate-3);
    --e2-on-navy: var(--e2-ivory-2); /* 9.1 on slate-4 */
    --e2-on-navy-2: var(--e2-ivory-3); /* 6.0 on slate-4 */
    --e2-gold-1: var(--e2-gold-hi);
    --e2-gold-2: var(--e2-gold-mid);
    --e2-gold-3: var(--e2-gold-lo);
    --e2-btn-1: #67718a;
    --e2-btn-2: var(--e2-slate-5); /* ivory 5.7, white 7.1 */
    --e2-btn-3: var(--e2-slate-4);
    --e2-btn-edge: var(--e2-slate-3);
    --e2-cta-1: var(--e2-pill-star-1);
    --e2-cta-2: var(--e2-pill-star-2);
    --e2-cta-3: var(--e2-pill-star-3);
    --e2-cta-edge: var(--e2-pill-star-edge);
    --e2-cta-ink: var(--e2-pill-star-ink);
    --e2-cream-1: var(--e2-pill-ivory-1);
    --e2-cream-2: var(--e2-pill-ivory-2);
    --e2-cream-ink: var(--e2-pill-ivory-ink);
    --e2-grey-1: #7b8394;
    --e2-grey-2: #5d6578; /* white 5.8 */
    --e2-grey-3: #4d5568;
    --e2-grey-edge: #3b4255;
    --e2-red-1: var(--e2-pill-danger-1);
    --e2-red-2: #b4432a; /* white 5.6 */
    --e2-red-3: var(--e2-pill-danger-2);
    --e2-red-edge: var(--e2-pill-danger-edge);
    --e2-feature-1: var(--e2-slate-5);
    --e2-feature-2: var(--e2-slate-4);
    --e2-feature-edge: var(--e2-slate-3);
  }

  /* Header height grows from --e2-bp-md (720px) */
  @media (min-width: 720px) {
    :root {
      --e2-header-h: 76px;
    }
  }

  /* ------------------------------------------------------------------
     2. Language-dependent tokens
        Declared on every element with a lang attribute, so a content
        block in another language gets its own stacks. Nunito (display +
        UI: headings, kickers, buttons, labels, numbers; 600-900) and
        Inter (body text; 400-700). Nunito has Latin ext + Cyrillic; CJK
        and Arabic fall back to their system stacks.
     ------------------------------------------------------------------ */
  :root,
  [lang] {
    --e2-font-display: 'Nunito', 'Noto Sans Arabic', 'PingFang SC', 'Microsoft YaHei', system-ui, 'Segoe UI', Tahoma, sans-serif;
    --e2-font-serif: var(--e2-font-display);
    --e2-font-ui: var(--e2-font-display);
    --e2-font-body: 'Inter', 'Noto Sans Arabic', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --e2-font-mono: ui-monospace, 'Cascadia Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    --e2-fw-hero: 900;
    --e2-fw-h1: 900;
    --e2-fw-h2: 900;
    --e2-fw-h3: 800;
    --e2-fw-h4: 800;
    --e2-fw-btn: 800;
    --e2-fw-stat: 900;
    --e2-fw-kicker: 800;
    --e2-fw-hud: 800;
    --e2-fw-label: 800; /* form labels, tags, chips */
    --e2-fw-ui: 700; /* Nunito UI text (tree items, nav) */
    --e2-fw-ui-muted: 600; /* Nunito muted labels (stat label) */
    --e2-fw-body: 400;
    --e2-fw-medium: 500;
    --e2-fw-strong: 700;
    --e2-fw-tagline: 700;

    --e2-case-display: none; /* titles are mixed case */
    --e2-case-kicker: uppercase; /* kickers and table-head labels */
    --e2-case-label: none; /* chips, badges, status, card labels */
    --e2-case-btn: none; /* buttons, nav, tabs, segments, pagination */
    --e2-track-display: -.012em;
    --e2-track-h3: 0;
    --e2-track-kicker: .18em;
    --e2-track-hud: .1em; /* small-caps labels */
    --e2-track-btn: .005em;
    --e2-track-crumb: 0;
    --e2-track-action: .01em;

    --e2-lh-hero: 1;
    --e2-lh-h1: 1.04;
    --e2-lh-h2: 1.08;
    --e2-lh-h3: 1.25;
    --e2-lh-h4: 1.3;
    --e2-lh-lead: 1.6;
    --e2-lh-body: 1.6;
    --e2-lh-prose: 1.72;
    --e2-lh-sm: 1.55;
    --e2-lh-xs: 1.45;
    --e2-lh-kicker: 1.2;
    --e2-lh-hud: 1.2;
    --e2-lh-stat: 1.05;
    --e2-lh-tagline: 1.4;
  }

  /* Chinese and Arabic: no caps, no tracking */
  :is([lang|="zh"], [lang|="ar"]) {
    --e2-case-display: none;
    --e2-case-kicker: none;
    --e2-case-label: none;
    --e2-case-btn: none;
    --e2-track-display: 0;
    --e2-track-h3: 0;
    --e2-track-kicker: 0;
    --e2-track-hud: 0;
    --e2-track-btn: 0;
    --e2-track-crumb: 0;
    --e2-track-action: 0;
  }

  /* Chinese: Nunito for Latin, then system CJK sans fonts; CJK has no
     800 / 900 cuts, so headings use 700; +0.1 line height */
  [lang|="zh"] {
    --e2-font-display: 'Nunito', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
    --e2-font-serif: var(--e2-font-display);
    --e2-font-ui: var(--e2-font-display);
    --e2-font-body: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
    --e2-lh-hero: 1.12;
    --e2-lh-h1: 1.16;
    --e2-lh-h2: 1.18;
    --e2-lh-h3: 1.3;
    --e2-lh-h4: 1.4;
    --e2-lh-lead: 1.7;
    --e2-lh-body: 1.75;
    --e2-lh-prose: 1.8;
    --e2-lh-sm: 1.6;
    --e2-lh-xs: 1.55;
    --e2-lh-kicker: 1.2;
    --e2-lh-hud: 1.3;
    --e2-lh-stat: 1.1;
    --e2-lh-tagline: 1.5;
  }

  /* Arabic (RTL): Kufi display, Naskh body; taller lines so diacritics
     are not clipped. */
  [lang|="ar"] {
    --e2-font-display: 'Noto Kufi Arabic', 'Nunito', 'Noto Naskh Arabic', 'Segoe UI', Tahoma, 'Geeza Pro', sans-serif;
    --e2-font-ui: var(--e2-font-display);
    --e2-font-body: 'Noto Naskh Arabic', 'Noto Sans Arabic', 'Inter', 'Segoe UI', Tahoma, 'Geeza Pro', system-ui, sans-serif;
    --e2-lh-hero: 1.3;
    --e2-lh-h1: 1.3;
    --e2-lh-h2: 1.3;
    --e2-lh-h3: 1.4;
    --e2-lh-h4: 1.45;
    --e2-lh-lead: 1.75;
    --e2-lh-body: 1.8;
    --e2-lh-prose: 1.85;
    --e2-lh-kicker: 1.3;
    --e2-lh-hud: 1.35;
  }

  /* ------------------------------------------------------------------
     3. Night ("Nacht", dark scheme): slate page, ivory ink, champagne gold.
        body.scheme-night (+ the root via :has), local .e2-scheme-night
        (a dark island) and .e2-on-image (light ink on a photo; its
        background stays transparent, e2-base.css).
     ------------------------------------------------------------------ */
  .scheme-night,
  .e2-scheme-night,
  .e2-on-image,
  :root:has(> body.scheme-night) {
    color-scheme: dark;

    --e2-bg: #1c2030; /* = E2_THEME_COLORS['night'] */
    --e2-bg-2: #242a3b;
    --e2-bg-3: #2f3649;
    --e2-bg-void: #161924;
    --e2-surface: #2a3042;
    --e2-surface-1: #2a3042;
    --e2-surface-2: #242a3b;
    --e2-surface-3: #2f3649;
    --e2-glass: rgb(42 48 66 / .88);
    --e2-glass-strong: rgb(36 42 59 / .95);
    --e2-glass-filter: blur(14px) saturate(120%);
    --e2-tint-mix: 16%;
    --e2-tint-mix-strong: 24%;

    --e2-ink: #ece5d8; /* 12.9 bg / 9.6 bg-3 */
    --e2-ink-2: #b9b2a4; /* 7.7 / 5.7 */
    --e2-ink-3: #a7a196; /* 6.3 / 4.7 */
    --e2-placeholder-ink: #9a948a;
    --e2-link: #e6cf9c; /* 10.6 / 7.9 */
    --e2-link-hover: #f6ecd2;
    --e2-label-ink: #e6cf9c;
    --e2-focus: #f1e3c0;
    --e2-focus-inner: #1c2030;

    --e2-gold-decor: #d3bc8e; /* 8.7 / 6.5 */
    --e2-gold-text: #f1e3c0; /* 12.7 / 9.5 */
    --e2-title-key: #f1e3c0;
    --e2-grad-title-key: var(--e2-grad-gold-word);

    --e2-hair: rgb(211 188 142 / .28);
    --e2-hair-soft: rgb(211 188 142 / .14);
    --e2-hair-strong: #a8875a; /* 4.8 bg, 3.9 surface */
    --e2-line: var(--e2-hair-soft);
    --e2-line-strong: #a8875a;
    --e2-control-border: #9c8a68; /* 4.8 bg, 3.9 surface */
    --e2-edge: var(--e2-hair);
    --e2-edge-hot: var(--e2-gold-decor);
    --e2-bracket: var(--e2-gold-decor);
    --e2-hud-1: var(--e2-gold-decor);
    --e2-hud-2: var(--e2-gold-lo);

    --e2-sheet-bg: #2a3042;
    --e2-sheet-ink: #ece5d8;
    --e2-sheet-line: rgb(211 188 142 / .28);
    --e2-sheet-edge: rgb(211 188 142 / .18);
    --e2-sheet-shadow: 0 30px 70px rgb(0 0 0 / .38), 0 2px 6px rgb(0 0 0 / .2);
    --e2-card-bg: #242a3b;
    --e2-card-line: rgb(211 188 142 / .16);
    --e2-card-shadow: 0 1px 2px rgb(0 0 0 / .2), 0 8px 22px rgb(0 0 0 / .18);
    --e2-row-hover: rgb(211 188 142 / .08);
    --e2-grad-row-hover: linear-gradient(90deg, rgb(211 188 142 / .1), rgb(211 188 142 / 0));

    --e2-img-shadow: 0 30px 60px rgb(0 0 0 / .35);
    --e2-img-shadow-sm: 0 12px 30px rgb(0 0 0 / .3);
    --e2-img-ring: inset 0 0 0 1px rgb(255 255 255 / .12);
    --e2-img-placeholder: #2f3649;

    --e2-header-solid: rgb(28 32 48 / .92); /* opaque fallback --e2-slate-1 */
    --e2-header-ink: #ece5d8;
    --e2-header-line: rgb(211 188 142 / .22);
    --e2-header-glass: var(--e2-header-solid);
    --e2-header-1: var(--e2-slate-5);
    --e2-header-2: var(--e2-slate-4);
    --e2-footer-bg: #161924;
    --e2-footer-bg-2: #1c2030;
    --e2-footer-ink: #ece5d8;
    --e2-footer-ink-2: #b9b2a4; /* 8.3 */
    --e2-band-alt-image: linear-gradient(180deg, #1c2030, #242a3b 30%, #242a3b 70%, #1c2030); /* alternate band: a soft slate swell by night */
    --e2-page-bg: #1c2030;
    --e2-page-bg-end: #1c2030;

    --e2-input-bg: #1f2433;
    --e2-input-ink: #ece5d8;
    --e2-input-border: rgb(211 188 142 / .38);
    --e2-input-border-focus: #d3bc8e;
    --e2-input-shadow: inset 0 1px 2px rgb(0 0 0 / .2);
    --e2-input-focus: 0 0 0 3px rgb(211 188 142 / .28);

    --e2-chip-bg: #242a3b;
    --e2-chip-line: rgb(211 188 142 / .3);
    --e2-chip-ink: #ece5d8;
    --e2-chip-count: #a7a196;
    --e2-chip-on-bg: #ece5d8; /* selected: ivory fill */
    --e2-chip-on-ink: #3b4255;

    --e2-rarity-5-ink: #e8b24f; /* 8.4 / 6.3 */
    --e2-rarity-4-ink: #b99cd9; /* 6.8 / 5.1 */
    --e2-rarity-3-ink: #86a9e0; /* 6.8 / 5.0 */
    --e2-jade-ink: #74c2a8; /* 7.7 / 5.8 */
    --e2-ember-ink: #f39a6a; /* 7.4 / 5.5 */

    --e2-gold-100: #f6ecd2;
    --e2-gold-300: #f1e3c0;
    --e2-gold-500: #d3bc8e;
    --e2-gold-700: #a8875a;
    --e2-gold-900: #6e5a3a;
    --e2-gold-ink: #f1e3c0;
    --e2-gold-soft: rgb(211 188 142 / .14);

    --e2-violet: #b99cd9;
    --e2-violet-fill: #7a55a3;
    --e2-violet-glow: #a07cc5;
    --e2-violet-soft: rgb(160 124 197 / .16);
    --e2-cyan: #86a9e0;
    --e2-cyan-glow: #5a86c8;
    --e2-cyan-soft: rgb(90 134 200 / .16);
    --e2-sakura: #f0a3c4;
    --e2-sakura-glow: #e889b0;
    --e2-sakura-soft: rgb(232 137 176 / .14);
    --e2-emerald: #74c2a8;
    --e2-emerald-glow: #74c2a8;
    --e2-emerald-soft: rgb(116 194 168 / .14);
    --e2-amber: #e8b24f;
    --e2-amber-glow: #e8b24f;
    --e2-amber-soft: rgb(232 178 79 / .14);
    --e2-crimson: #f49a8f;
    --e2-crimson-glow: #ef7938;
    --e2-crimson-soft: rgb(239 121 56 / .14);
    --e2-grad-aurora: linear-gradient(100deg, #86a9e0, #f1e3c0 55%, #f0a3c4);

    --e2-st-on-bg: #29373f;
    --e2-st-on-line: rgb(116 194 168 / .42);
    --e2-st-on-ink: #9fe0c9;
    --e2-st-on-dot: #74c2a8;
    --e2-st-off-bg: #3a2d31;
    --e2-st-off-line: rgb(239 121 56 / .42);
    --e2-st-off-ink: #f39a6a;
    --e2-st-off-dot: #ef7938;
    --e2-st-maint-bg: #393434;
    --e2-st-maint-line: rgb(232 178 79 / .42);
    --e2-st-maint-ink: #e8b24f;
    --e2-st-maint-dot: #e8b24f;
    --e2-st-unk-bg: #2f3649;
    --e2-st-unk-line: rgb(211 188 142 / .22);
    --e2-st-unk-ink: #b9b2a4;
    --e2-st-unk-dot: #8f8a80;

    --e2-crest-silver: #b99cd9;
    --e2-crest-bronze: #86a9e0;
    --e2-medal-rim: rgb(255 255 255 / .35);

    --e2-count-bg: #d3bc8e;
    --e2-count-ink: #1c2030; /* 8.7 */

    --e2-class-knight: #ff8f8a;
    --e2-class-blade: #f5a36f;
    --e2-class-ranger: #74c2a8;
    --e2-class-jester: #d3a3f0;
    --e2-class-ringmaster: #f0c56a;
    --e2-class-billposter: #f2b066;
    --e2-class-elementor: #86b9e0;
    --e2-class-psykeeper: #b9adf5;
    --e2-class-vagrant: #c9c3b6;

    --e2-plate-1: var(--e2-pill-star-1);
    --e2-plate-2: var(--e2-pill-star-3);
    --e2-plate-ink: var(--e2-pill-star-ink);
    --e2-btn-violet-top: var(--e2-slate-5);
    --e2-btn-violet-mid: var(--e2-slate-5);
    --e2-btn-violet-bottom: var(--e2-slate-4);
    --e2-btn-violet-border: rgb(211 188 142 / .45);
    --e2-btn-ghost-top: #2f3649;
    --e2-btn-ghost-mid: #2a3042;
    --e2-btn-ghost-bottom: #242a3b;
    --e2-btn-ghost-border: rgb(211 188 142 / .45);
    --e2-btn-ghost-ink: #ece5d8;

    --e2-fill: none;
    --e2-scan: none;
    --e2-grid: none;

    --e2-halo-light: rgb(255 245 220 / .16);
    --e2-halo-core: rgb(232 178 79 / .24);
    --e2-halo-rim: rgb(232 178 79 / 0);
    --e2-halo-glow: radial-gradient(circle, rgb(232 178 79 / .26), rgb(232 178 79 / 0) 65%);
    --e2-halo-ring: rgb(211 188 142 / .28);

    --e2-shadow-1: 0 2px 8px rgb(0 0 0 / .26);
    --e2-shadow-2: 0 12px 28px rgb(0 0 0 / .34);
    --e2-shadow-3: 0 18px 44px rgb(0 0 0 / .42);
    --e2-shadow-4: 0 30px 80px rgb(0 0 0 / .5);
    --e2-shadow-3-filter: drop-shadow(0 18px 44px rgb(0 0 0 / .42));
    --e2-shadow-4-filter: drop-shadow(0 28px 60px rgb(0 0 0 / .5));
    --e2-win-drop: 0 14px 34px rgb(0 0 0 / .32);
    --e2-win-drop-sm: 0 6px 16px rgb(0 0 0 / .26);
    --e2-inset-hi: inset 0 1px 0 rgb(255 255 255 / .06);
    --e2-glow-gold: 0 0 22px rgb(232 178 79 / .32);
    --e2-glow-violet: 0 0 22px rgb(160 124 197 / .35);
    --e2-glow-accent-mix: 45%;
    --e2-glow-hover: 0 12px 30px rgb(0 0 0 / .32);
    --e2-glow-hover-filter: drop-shadow(0 6px 16px rgb(0 0 0 / .4));
    --e2-glow-focus: var(--e2-input-focus);
    --e2-char-shadow: drop-shadow(0 20px 50px rgb(0 0 0 / .45));
    --e2-frame-edge: var(--e2-hair);
    --e2-frame-glow: var(--e2-img-shadow);
    --e2-title-glow: 0 3px 12px rgb(0 0 0 / .4);

    --e2-scrim-x: linear-gradient(90deg, rgb(22 25 36 / .86), rgb(22 25 36 / .35) 55%, rgb(22 25 36 / 0) 80%);
    --e2-scrim-media: linear-gradient(180deg, transparent 40%, rgb(22 25 36 / .86) 100%);
    --e2-backdrop: rgb(10 12 20 / .62);
    --e2-backdrop-solid: #11131c;

    --e2-ornament: var(--e2-gold-decor);
    --e2-gem-fill: var(--e2-gold-decor);
    --e2-arcane: #f1e3c0;
    --e2-arcane-opacity: .12;
    --e2-mote: rgb(241 227 192 / .7);

    --e2-selection-bg: rgb(211 188 142 / .35);
    --e2-selection-ink: #fff;
    --e2-highlight: rgb(232 178 79 / .3);
    --e2-zebra: rgb(236 229 216 / .03);
    --e2-accent-ui: #d3bc8e;
    --e2-scrollbar-thumb: #4f586d;
    --e2-scrollbar-track: #1c2030;
    --e2-win-scroll-track: #242a3b;

    --e2-row-hi-1: #343544;
    --e2-row-hi-2: #3a3b45;
  }

  /* ------------------------------------------------------------------
     3b. On-image island: content directly on a photo (banner, hero,
        world band, image-led feature) keeps light ink and the gold-word
        gradient in BOTH schemes; dark tokens above + these.
     ------------------------------------------------------------------ */
  .e2-on-image {
    --e2-ink: #f6f2ea;
    --e2-ink-2: #e7e0d3;
    --e2-ink-3: #d9cfbd;
    --e2-link: #f1e3c0;
    --e2-link-hover: #fff;
    --e2-gold-text: #f1e3c0;
    --e2-title-key: #f1e3c0;
    --e2-grad-title-key: var(--e2-grad-gold-word);
    --e2-hair: rgb(211 188 142 / .38);
    --e2-hair-soft: rgb(211 188 142 / .26);
    --e2-chip-bg: var(--e2-chip-photo-bg);
    --e2-chip-line: var(--e2-chip-photo-line);
    --e2-chip-ink: #ece5d8;
    --e2-chip-on-bg: #ece5d8;
    --e2-chip-on-ink: #3b4255;
    --e2-jade-ink: #9fe0c9;
    --e2-st-on-ink: #9fe0c9;
  }

  /* ------------------------------------------------------------------
     4. Day ("Tag", light scheme, THE DEFAULT): ivory page, slate ink,
        champagne gold accents. :root, body.scheme-day, html.scheme-day,
        local .e2-scheme-day.
     ------------------------------------------------------------------ */
  :root,
  .scheme-day,
  .e2-scheme-day {
    color-scheme: light;

    /* Page tones (bands alternate --e2-bg / --e2-bg-2) and surfaces */
    --e2-bg: #f4efe6; /* = E2_THEME_COLORS['day'] */
    --e2-bg-2: #ece5d8; /* alternate band */
    --e2-bg-3: #e2d9c8; /* deepest tone: hover / selected wells, tracks */
    --e2-bg-void: #e2d9c8;
    --e2-surface: #fffdf8; /* the sheet (forms, dialogs, menus, toasts) */
    --e2-surface-1: #fffdf8; /* raised: sheet, menu, card */
    --e2-surface-2: #f8f4ec; /* soft well inside a sheet, select options */
    --e2-surface-3: #ece5d8; /* hover / selected */
    --e2-glass: rgb(255 253 248 / .88); /* opaque fallback: --e2-surface-1 */
    --e2-glass-strong: rgb(255 253 248 / .95);
    --e2-glass-filter: blur(14px) saturate(120%);
    --e2-tint-mix: 12%; /* share of a hue in tinted fills (accent-soft, chips, row stripes) */
    --e2-tint-mix-strong: 18%;

    /* Ink (slate) */
    --e2-ink: #3b4255; /* 8.8 bg / 7.2 bg-3 */
    --e2-ink-2: #4d5568; /* 6.5 / 5.3 */
    --e2-ink-3: #565e71; /* 5.7 / 4.6 (small text) */
    --e2-placeholder-ink: #6b7385; /* placeholder only (4.7 on white inputs) */
    --e2-link: #77582b; /* gold text, underlined: 5.7 / 4.7 */
    --e2-link-hover: #5e4622;
    --e2-label-ink: #77582b; /* form labels (Nunito 800, gold text) */
    --e2-focus: #77582b; /* focus ring outer colour (3:1 on every tone) */
    --e2-focus-inner: #fffdf8;

    /* Gold roles */
    --e2-gold-decor: #a8875a; /* diamonds, divider marks, underlines: decoration only (2.9) */
    --e2-gold-text: #77582b; /* small gold text: kickers, labels, values (5.7 / 4.7) */
    --e2-title-key: #8a6a3a; /* accent word of a heading (large text: 4.4 / 3.6) */
    --e2-grad-title-key: linear-gradient(180deg, #8a6a3a, #8a6a3a); /* same, for background-clip:text */

    /* Hairlines and borders */
    --e2-hair: rgb(168 135 90 / .38); /* hairline: rows, groups, dividers (decoration) */
    --e2-hair-soft: rgb(168 135 90 / .18); /* softer separators (pillars, row lists) */
    --e2-hair-strong: #8a6d43; /* a line that must read (UI, 3:1 / 3.5 bg-3) */
    --e2-line: var(--e2-hair-soft); /* decorative only */
    --e2-line-strong: #8a6d43; /* frames, dividers, active borders (UI 3:1) */
    --e2-control-border: #8f7f5f; /* control boundary (3.9 sheet, 3.5 bg) */
    --e2-edge: var(--e2-hair);
    --e2-edge-hot: var(--e2-gold-decor);
    --e2-bracket: var(--e2-gold-decor);
    --e2-hud-1: var(--e2-gold-decor);
    --e2-hud-2: var(--e2-gold-lo);

    /* The sheet: the one surface (forms, dialogs, menus, toasts, sheet) */
    --e2-sheet-bg: #fffdf8;
    --e2-sheet-ink: #3b4255;
    --e2-sheet-line: rgb(168 135 90 / .35); /* inner hairline, inset 8px */
    --e2-sheet-edge: rgb(168 135 90 / .22); /* outer 1px edge */
    --e2-sheet-shadow: 0 24px 60px rgb(59 66 85 / .18), 0 2px 6px rgb(59 66 85 / .06);
    --e2-card-bg: #fffdf8; /* subtle card (admin groups) */
    --e2-card-line: rgb(168 135 90 / .26);
    --e2-card-shadow: 0 1px 2px rgb(59 66 85 / .05), 0 6px 18px rgb(59 66 85 / .06);
    --e2-row-hover: rgb(168 135 90 / .1); /* list row hover tint */
    --e2-grad-row-hover: linear-gradient(90deg, rgb(168 135 90 / .14), rgb(168 135 90 / 0));

    /* Images */
    --e2-img-shadow: 0 24px 50px rgb(59 66 85 / .22);
    --e2-img-shadow-sm: 0 10px 26px rgb(59 66 85 / .14);
    --e2-img-ring: inset 0 0 0 1px rgb(255 255 255 / .18);
    --e2-img-placeholder: #e2d9c8;

    /* Header / footer (shell) */
    --e2-header-solid: rgb(246 242 234 / .92); /* opaque fallback --e2-ivory-2 */
    --e2-header-ink: #3b4255;
    --e2-header-line: rgb(168 135 90 / .3);
    --e2-header-glass: var(--e2-header-solid);
    --e2-header-1: var(--e2-slate-5);
    --e2-header-2: var(--e2-slate-4);
    --e2-footer-bg: #3b4255; /* slate band */
    --e2-footer-bg-2: #2f3649;
    --e2-footer-ink: #ece5d8; /* 8.0 */
    --e2-footer-ink-2: #d9cfbd; /* 6.0 */
    --e2-band-alt-image: none; /* alternate band: flat ivory-2 by day */
    --e2-page-bg: #f4efe6; /* flat: bands carry the rhythm */
    --e2-page-bg-end: #f4efe6;

    /* Inputs */
    --e2-input-bg: #fff;
    --e2-input-ink: #3b4255;
    --e2-input-border: #cbbd9f; /* spec edge (decoration; --e2-control-border carries 3:1) */
    --e2-input-border-focus: #a8875a;
    --e2-input-shadow: inset 0 1px 2px rgb(59 66 85 / .06);
    --e2-input-focus: 0 0 0 3px rgb(168 135 90 / .28); /* 3px gold-soft ring */

    /* Chips */
    --e2-chip-bg: #fffdf8;
    --e2-chip-line: rgb(168 135 90 / .38);
    --e2-chip-ink: #3b4255;
    --e2-chip-count: #565e71;
    --e2-chip-on-bg: #3b4255; /* selected: slate fill */
    --e2-chip-on-ink: #ece5d8; /* 8.0 */

    /* Rarity text (on the light tones) */
    --e2-rarity-5-ink: #84501a; /* 5.8 / 4.8 */
    --e2-rarity-4-ink: #6f4d94; /* 5.8 / 4.7 */
    --e2-rarity-3-ink: #335c99; /* 5.9 / 4.8 */
    --e2-jade-ink: #256850; /* 5.8 / 4.7 */
    --e2-ember-ink: #9e3b1c; /* 5.9 / 4.8 */

    /* Gold scale (legacy numeric names) */
    --e2-gold-100: #fbf3df;
    --e2-gold-300: #e9d6ae;
    --e2-gold-500: #a8875a; /* decoration only */
    --e2-gold-700: #8a6a3a; /* large text */
    --e2-gold-900: #5e4622;
    --e2-gold-ink: #77582b;
    --e2-gold-soft: rgb(168 135 90 / .16);

    /* Accent hues as text (AA on every light tone) + their fills */
    --e2-violet: #6f4d94;
    --e2-violet-fill: #7a55a3;
    --e2-violet-glow: #a07cc5;
    --e2-violet-soft: rgb(160 124 197 / .14);
    --e2-cyan: #335c99;
    --e2-cyan-glow: #5a86c8;
    --e2-cyan-soft: rgb(90 134 200 / .14);
    --e2-sakura: #9b3a64;
    --e2-sakura-glow: #e889b0;
    --e2-sakura-soft: rgb(232 137 176 / .16);
    --e2-emerald: #256850;
    --e2-emerald-glow: #74c2a8;
    --e2-emerald-soft: rgb(116 194 168 / .18);
    --e2-amber: #84501a;
    --e2-amber-glow: #e8b24f;
    --e2-amber-soft: rgb(232 178 79 / .18);
    --e2-crimson: #a83434;
    --e2-crimson-glow: #ef7938;
    --e2-crimson-soft: rgb(239 121 56 / .14);
    --e2-grad-aurora: linear-gradient(100deg, #335c99, #8a6a3a 55%, #9b3a64);

    /* Status (jade online, ember offline, gold maintenance, muted unknown) */
    --e2-st-on-bg: #e2e9dd;
    --e2-st-on-line: #a9d6c5;
    --e2-st-on-ink: #256850; /* 5.3 */
    --e2-st-on-dot: #74c2a8;
    --e2-st-off-bg: #f3dfce;
    --e2-st-off-line: #eab89c;
    --e2-st-off-ink: #9e3b1c; /* 5.3 */
    --e2-st-off-dot: #ef7938;
    --e2-st-maint-bg: #f2e7d1;
    --e2-st-maint-line: #e3c58e;
    --e2-st-maint-ink: #84501a; /* 5.4 */
    --e2-st-maint-dot: #e8b24f;
    --e2-st-unk-bg: #ece5d8;
    --e2-st-unk-line: #cbbd9f;
    --e2-st-unk-ink: #4d5568; /* 6.0 */
    --e2-st-unk-dot: #8f8a80;

    /* Rank numerals and medal rim */
    --e2-crest-silver: #6f4d94; /* rank 2 text = 4★ ink */
    --e2-crest-bronze: #335c99; /* rank 3 text = 3★ ink */
    --e2-medal-rim: rgb(59 66 85 / .25);

    /* Count badge */
    --e2-count-bg: #3b4255;
    --e2-count-ink: #fff; /* 10.0 */

    /* Class hues (jobs), dark enough for text on the light tones */
    --e2-class-knight: #a83434;
    --e2-class-blade: #9e3b1c;
    --e2-class-ranger: #256850;
    --e2-class-jester: #7a3fae;
    --e2-class-ringmaster: #84501a;
    --e2-class-billposter: #8a4a12;
    --e2-class-elementor: #1f5f80;
    --e2-class-psykeeper: #5446b8;
    --e2-class-vagrant: #4d5568;

    /* Legacy plates (on the page) */
    --e2-plate-1: var(--e2-pill-star-1);
    --e2-plate-2: var(--e2-pill-star-3);
    --e2-plate-ink: var(--e2-pill-star-ink);
    --e2-btn-violet-top: var(--e2-slate-5);
    --e2-btn-violet-mid: var(--e2-slate-5);
    --e2-btn-violet-bottom: var(--e2-slate-4);
    --e2-btn-violet-border: var(--e2-slate-3);
    --e2-btn-ghost-top: #f8f4ec;
    --e2-btn-ghost-mid: #f3eee4;
    --e2-btn-ghost-bottom: #ece5d8;
    --e2-btn-ghost-border: #cdbf9f;
    --e2-btn-ghost-ink: #3b4255;

    /* Retired HUD fills (scan lines, grid): resolve to nothing */
    --e2-fill: none;
    --e2-scan: none;
    --e2-grid: none;

    /* Halo behind character art: a soft 5★ glow + a thin ring */
    --e2-halo-light: rgb(255 255 255 / .7);
    --e2-halo-core: rgb(232 178 79 / .26);
    --e2-halo-rim: rgb(232 178 79 / 0);
    --e2-halo-glow: radial-gradient(circle, rgb(232 178 79 / .28), rgb(232 178 79 / 0) 65%);
    --e2-halo-ring: rgb(168 135 90 / .38);

    /* Elevation */
    --e2-shadow-1: 0 1px 2px rgb(59 66 85 / .06), 0 4px 14px rgb(59 66 85 / .08);
    --e2-shadow-2: 0 10px 28px rgb(59 66 85 / .12);
    --e2-shadow-3: 0 18px 44px rgb(59 66 85 / .16);
    --e2-shadow-4: 0 30px 70px rgb(59 66 85 / .2);
    --e2-shadow-3-filter: drop-shadow(0 18px 44px rgb(59 66 85 / .16));
    --e2-shadow-4-filter: drop-shadow(0 28px 60px rgb(59 66 85 / .2));
    --e2-win-drop: 0 12px 30px rgb(59 66 85 / .12);
    --e2-win-drop-sm: 0 4px 14px rgb(59 66 85 / .08);
    --e2-inset-hi: inset 0 1px 0 rgb(255 255 255 / .8);
    --e2-glow-gold: 0 0 18px rgb(232 178 79 / .35);
    --e2-glow-violet: 0 0 18px rgb(160 124 197 / .3);
    --e2-glow-accent-mix: 30%;
    --e2-glow-hover: 0 10px 26px rgb(59 66 85 / .14);
    --e2-glow-hover-filter: drop-shadow(0 6px 14px rgb(59 66 85 / .18));
    --e2-glow-focus: var(--e2-input-focus);
    --e2-char-shadow: drop-shadow(0 20px 40px rgb(59 66 85 / .3));
    --e2-frame-edge: var(--e2-hair);
    --e2-frame-glow: var(--e2-img-shadow);
    --e2-title-glow: none;

    /* Scrims and veils (photo scrims are in section 1) */
    --e2-scrim-x: linear-gradient(90deg, rgb(28 32 48 / .72), rgb(28 32 48 / .25) 55%, rgb(28 32 48 / 0) 80%);
    --e2-scrim-media: linear-gradient(180deg, transparent 40%, rgb(28 32 48 / .78) 100%);
    --e2-backdrop: rgb(28 32 48 / .45);
    --e2-backdrop-solid: #9c9a99; /* --e2-backdrop composited over --e2-bg */

    /* Ornaments and ambience */
    --e2-ornament: var(--e2-gold-decor);
    --e2-gem-fill: var(--e2-gold-decor);
    --e2-arcane: #a8875a;
    --e2-arcane-opacity: .14;
    --e2-mote: rgb(232 178 79 / .55);

    /* Misc UI */
    --e2-selection-bg: rgb(168 135 90 / .3);
    --e2-selection-ink: #2f3649;
    --e2-highlight: rgb(232 178 79 / .38); /* <mark> */
    --e2-zebra: rgb(168 135 90 / .05);
    --e2-accent-ui: #8a6a3a; /* native accent-color / caret */
    --e2-scrollbar-thumb: #b8a684;
    --e2-scrollbar-track: #ece5d8;
    --e2-win-scroll-track: #ece5d8;

    /* Highlighted row (rank 1 / own row / selected) */
    --e2-row-hi-1: #fbf3e2;
    --e2-row-hi-2: #f4e7c9;
  }

  /* ------------------------------------------------------------------
     5. Aliases (re-resolved on every scheme root)
     ------------------------------------------------------------------ */
  :root,
  .scheme-day,
  .e2-scheme-day,
  .scheme-night,
  .e2-scheme-night,
  .e2-on-image {
    /* Semantic */
    --e2-ok: var(--e2-emerald);
    --e2-warn: var(--e2-amber);
    --e2-danger: var(--e2-crimson);
    --e2-info: var(--e2-cyan);
    --e2-ok-soft: var(--e2-emerald-soft);
    --e2-warn-soft: var(--e2-amber-soft);
    --e2-danger-soft: var(--e2-crimson-soft);
    --e2-info-soft: var(--e2-cyan-soft);
    --e2-online: var(--e2-jade-ink);
    --e2-offline: var(--e2-ember-ink);
    --e2-maint: var(--e2-rarity-5-ink);
    --e2-unknown: var(--e2-ink-3);
    --e2-online-dot: var(--e2-jade);
    --e2-offline-dot: var(--e2-ember);
    --e2-maint-dot: var(--e2-rarity-5);
    --e2-unknown-dot: var(--e2-st-unk-dot);

    /* Categories (news chips, event chips): patch 3★ blue, event 5★ gold,
       maintenance ember, guide jade, news 4★ violet, shop gold */
    --e2-cat-news: var(--e2-violet);
    --e2-cat-patch: var(--e2-cyan);
    --e2-cat-event: var(--e2-amber);
    --e2-cat-maintenance: var(--e2-crimson);
    --e2-cat-guide: var(--e2-emerald);
    --e2-cat-shop: var(--e2-gold-ink);
    --e2-cat-news-soft: var(--e2-violet-soft);
    --e2-cat-patch-soft: var(--e2-cyan-soft);
    --e2-cat-event-soft: var(--e2-amber-soft);
    --e2-cat-maintenance-soft: var(--e2-crimson-soft);
    --e2-cat-guide-soft: var(--e2-emerald-soft);
    --e2-cat-shop-soft: var(--e2-gold-soft);

    /* Rank numerals and class family hues */
    --e2-crest-gold: var(--e2-rarity-5-ink);
    --e2-class-mercenary: var(--e2-class-knight);
    --e2-class-acrobat: var(--e2-class-ranger);
    --e2-class-assist: var(--e2-class-ringmaster);
    --e2-class-magician: var(--e2-class-elementor);

    /* Context accent: components read only --e2-accent (decor) and
       --e2-accent-ink (text). The page accent is champagne gold. */
    --e2-accent: var(--e2-gold-decor);
    --e2-accent-ink: var(--e2-gold-text);

    /* Derived surfaces, lines and light */
    --e2-placeholder: var(--e2-placeholder-ink);
    --e2-scrim-y: linear-gradient(180deg, transparent, var(--e2-bg) 92%);
    --e2-scrim-bottom: linear-gradient(0deg, var(--e2-bg) 0%, transparent 38%); /* photo band melts into the page */
    --e2-scrim-top: linear-gradient(180deg, var(--e2-bg), transparent 22%);
    --e2-title-rule: linear-gradient(90deg, var(--e2-gold-decor), var(--e2-hair) 70%, transparent);
    --e2-hairline: linear-gradient(90deg, transparent, var(--e2-hair) 20%, var(--e2-hair) 80%, transparent);
    --e2-divider-line: linear-gradient(90deg, transparent, var(--e2-hair));
    --e2-divider-line-end: linear-gradient(270deg, transparent, var(--e2-hair));
    --e2-sec-rule: linear-gradient(90deg, var(--e2-gold-decor), transparent);
    --e2-sec-rule-rtl: linear-gradient(270deg, var(--e2-gold-decor), transparent);
    --e2-halo: radial-gradient(closest-side, var(--e2-halo-light) 0%, var(--e2-halo-core) 30%, var(--e2-halo-rim) 100%);
    --e2-glow-inset: inset 0 0 0 1px var(--e2-hair);

    /* Legacy window frame shadows: now a soft sheet / card shadow */
    --e2-win-shadow: 0 0 0 1px var(--e2-sheet-edge), var(--e2-win-drop);
    --e2-win-shadow-sm: 0 0 0 1px var(--e2-card-line), var(--e2-win-drop-sm);
    --e2-win-shadow-hover: 0 0 0 1px var(--e2-hair), var(--e2-glow-hover);

    /* Legacy window palette -> the open palette of this scheme */
    --e2-win-bg: var(--e2-surface);
    --e2-win-bg-2: var(--e2-surface);
    --e2-win-bg-3: var(--e2-surface-3);
    --e2-win-ink: var(--e2-ink);
    --e2-win-ink-2: var(--e2-ink-2);
    --e2-win-ink-3: var(--e2-ink-3);
    --e2-win-line: var(--e2-hair);
    --e2-win-line-soft: var(--e2-hair-soft);
    --e2-win-line-strong: var(--e2-line-strong);
    --e2-win-control-border: var(--e2-control-border);
    --e2-win-frame: var(--e2-hair);
    --e2-win-frame-2: var(--e2-hair-soft);
    --e2-win-head: var(--e2-ink);
    --e2-win-link: var(--e2-link);
    --e2-win-link-hover: var(--e2-link-hover);
    --e2-win-gold-ink: var(--e2-gold-text);
    --e2-win-violet: var(--e2-violet);
    --e2-win-cyan: var(--e2-cyan);
    --e2-win-sakura: var(--e2-sakura);
    --e2-win-emerald: var(--e2-emerald);
    --e2-win-amber: var(--e2-amber);
    --e2-win-crimson: var(--e2-crimson);
    --e2-navy-ink: var(--e2-ink);
    --e2-blue-ink: var(--e2-gold-text); /* labels and numbers: gold text */
    --e2-action-ink: var(--e2-gold-text);
    --e2-grad-row-hi: linear-gradient(180deg, var(--e2-row-hi-1), var(--e2-row-hi-2));
    --e2-grad-preview: radial-gradient(circle at 50% 60%, var(--e2-bg-2), var(--e2-bg) 70%);
    --e2-grad-title-hero: var(--e2-grad-title-key);
    --e2-sheet-ring: inset 0 0 0 1px var(--e2-sheet-line);
  }

  /* Accent-derived tokens: re-declared wherever --e2-accent can change.
     A component that sets --e2-accent in its own class should also carry
     data-e2-accent (or one of the other hooks below) to get these. */
  :root,
  .scheme-night,
  .e2-scheme-night,
  .scheme-day,
  .e2-scheme-day,
  .e2-on-image,
  [data-e2-accent],
  [data-e2-class],
  [data-e2-cat],
  [style*="--e2-accent"] {
    --e2-accent-soft: color-mix(in oklab, var(--e2-accent) var(--e2-tint-mix), transparent);
    --e2-accent-line: color-mix(in oklab, var(--e2-accent) 55%, transparent);
    --e2-glow-accent: 0 0 24px color-mix(in oklab, var(--e2-accent) var(--e2-glow-accent-mix), transparent);
  }

  @supports not (color: color-mix(in oklab, red 50%, transparent)) {
    :root,
    .scheme-night,
    .e2-scheme-night,
    .scheme-day,
    .e2-scheme-day,
    .e2-on-image,
    [data-e2-accent],
    [data-e2-class],
    [data-e2-cat],
    [style*="--e2-accent"] {
      --e2-accent-soft: var(--e2-gold-soft);
      --e2-accent-line: var(--e2-hair);
      --e2-glow-accent: var(--e2-glow-gold);
      --e2-glow-inset: inset 0 0 0 1px var(--e2-edge-hot);
    }
  }

  /* ------------------------------------------------------------------
     6. Accent contexts (category, class, named accent)
     ------------------------------------------------------------------ */
  [data-e2-accent="gold"] { --e2-accent: var(--e2-gold-decor); --e2-accent-ink: var(--e2-gold-text); }
  [data-e2-accent="violet"] { --e2-accent: var(--e2-violet-glow); --e2-accent-ink: var(--e2-violet); }
  [data-e2-accent="cyan"] { --e2-accent: var(--e2-cyan-glow); --e2-accent-ink: var(--e2-cyan); }
  [data-e2-accent="sakura"] { --e2-accent: var(--e2-sakura-glow); --e2-accent-ink: var(--e2-sakura); }
  [data-e2-accent="emerald"] { --e2-accent: var(--e2-emerald-glow); --e2-accent-ink: var(--e2-emerald); }
  [data-e2-accent="amber"] { --e2-accent: var(--e2-amber-glow); --e2-accent-ink: var(--e2-amber); }
  [data-e2-accent="crimson"] { --e2-accent: var(--e2-crimson-glow); --e2-accent-ink: var(--e2-crimson); }

  [data-e2-cat="news"] { --e2-accent: var(--e2-violet-glow); --e2-accent-ink: var(--e2-cat-news); }
  [data-e2-cat="patch"] { --e2-accent: var(--e2-cyan-glow); --e2-accent-ink: var(--e2-cat-patch); }
  [data-e2-cat="event"] { --e2-accent: var(--e2-amber-glow); --e2-accent-ink: var(--e2-cat-event); }
  [data-e2-cat="maintenance"] { --e2-accent: var(--e2-crimson-glow); --e2-accent-ink: var(--e2-cat-maintenance); }
  [data-e2-cat="guide"] { --e2-accent: var(--e2-emerald-glow); --e2-accent-ink: var(--e2-cat-guide); }
  [data-e2-cat="shop"] { --e2-accent: var(--e2-gold-decor); --e2-accent-ink: var(--e2-cat-shop); }

  /* Keys: lower-case job icon names (Img/jobs/Job<Name>.png) */
  :is([data-e2-class="mercenary"], [data-e2-class="knight"], [data-e2-class="lordtempler"], [data-e2-class="lordtemplar"]) {
    --e2-accent: var(--e2-class-knight); --e2-accent-ink: var(--e2-class-knight);
  }
  :is([data-e2-class="blade"], [data-e2-class="stormblade"]) {
    --e2-accent: var(--e2-class-blade); --e2-accent-ink: var(--e2-class-blade);
  }
  :is([data-e2-class="acrobat"], [data-e2-class="ranger"], [data-e2-class="crackshooter"]) {
    --e2-accent: var(--e2-class-ranger); --e2-accent-ink: var(--e2-class-ranger);
  }
  :is([data-e2-class="jester"], [data-e2-class="windlurker"]) {
    --e2-accent: var(--e2-class-jester); --e2-accent-ink: var(--e2-class-jester);
  }
  :is([data-e2-class="assist"], [data-e2-class="ringmaster"], [data-e2-class="florist"]) {
    --e2-accent: var(--e2-class-ringmaster); --e2-accent-ink: var(--e2-class-ringmaster);
  }
  :is([data-e2-class="billposter"], [data-e2-class="forcemaster"]) {
    --e2-accent: var(--e2-class-billposter); --e2-accent-ink: var(--e2-class-billposter);
  }
  :is([data-e2-class="magician"], [data-e2-class="elementor"], [data-e2-class="elementorlord"]) {
    --e2-accent: var(--e2-class-elementor); --e2-accent-ink: var(--e2-class-elementor);
  }
  :is([data-e2-class="psykeeper"], [data-e2-class="psychikeeper"], [data-e2-class="mentalist"]) {
    --e2-accent: var(--e2-class-psykeeper); --e2-accent-ink: var(--e2-class-psykeeper);
  }
  :is([data-e2-class="vagrant"], [data-e2-class="unknown"]) {
    --e2-accent: var(--e2-class-vagrant); --e2-accent-ink: var(--e2-class-vagrant);
  }

  /* ------------------------------------------------------------------
     7. Density: admin (compact) drops one step for h2/h3, denser rows
     ------------------------------------------------------------------ */
  .e2-admin,
  [data-e2-density="compact"] {
    --e2-density: compact;
    --e2-fs-h1: clamp(1.5rem, 2.2vw, 2rem);
    --e2-fs-h2: clamp(1.1875rem, 1.6vw, 1.5rem);
    --e2-fs-h3: 1.0625rem;
    --e2-section-y: clamp(28px, 3vw, 40px);
    --e2-panel-pad: 16px;
    --e2-win-pad: 16px;
    --e2-win-title-h: 30px;
    --e2-fs-win-title: 1rem;
    --e2-win-in-pad: 10px 12px;
    --e2-row-h: 44px;
  }

  /* ------------------------------------------------------------------
     8. Reduced motion: OS setting, html.e2-motion-off, body.motion-reduce
        (the site switch). A safety net at token level only: movement
        durations and distances collapse; --e2-dur-fade and the loop
        periods stay. Every animated rule handles reduced motion itself,
        case by case (e2-base.css "Motion": the gate).
     ------------------------------------------------------------------ */
  @media (prefers-reduced-motion: reduce) {
    :root {
      --e2-dur-press: .01ms;
      --e2-dur-1: .01ms;
      --e2-dur-2: .01ms;
      --e2-dur-3: .01ms;
      --e2-dur-4: .01ms;
      --e2-dur-5: .01ms;
      --e2-dur-enter: .01ms;
      --e2-dur-img: .01ms;
      --e2-dur-draw: .01ms;
      --e2-dur-exit: .01ms;
      --e2-dur-menu: .01ms;
      --e2-dur-menu-out: .01ms;
      --e2-dur-page: .01ms;
      --e2-dur-page-out: .01ms;
      --e2-dur-hover: .01ms;
      --e2-dur-glint: .01ms;
      --e2-dur-shine: .01ms;
      --e2-dur-count: .01ms;
      --e2-dur-grow: .01ms;
      --e2-stagger: 0ms;
      --e2-reveal-y: 0px;
      --e2-reveal-row-y: 0px;
      --e2-reveal-img-scale: 1;
      --e2-reveal-clip: inset(0 round var(--e2-r-img));
      --e2-rise-y: 0px;
      --e2-sink-y: 0px;
      --e2-lift: 0px;
      --e2-lift-row: 0px;
      --e2-press-y: 0px;
      --e2-menu-y: 0px;
      --e2-menu-scale: 1;
      --e2-dialog-scale: 1;
      --e2-tip-y: 0px;
      --e2-zoom: 1;
      --e2-key-hover: 1;
      --e2-key-press: 1;
      --e2-parallax: 0px;
      --e2-motion: 0;
    }
  }

  :root.e2-motion-off,
  .motion-reduce {
    --e2-dur-press: .01ms;
    --e2-dur-1: .01ms;
    --e2-dur-2: .01ms;
    --e2-dur-3: .01ms;
    --e2-dur-4: .01ms;
    --e2-dur-5: .01ms;
    --e2-dur-enter: .01ms;
    --e2-dur-img: .01ms;
    --e2-dur-draw: .01ms;
    --e2-dur-exit: .01ms;
    --e2-dur-menu: .01ms;
    --e2-dur-menu-out: .01ms;
    --e2-dur-page: .01ms;
    --e2-dur-page-out: .01ms;
    --e2-dur-hover: .01ms;
    --e2-dur-glint: .01ms;
    --e2-dur-shine: .01ms;
    --e2-dur-count: .01ms;
    --e2-dur-grow: .01ms;
    --e2-stagger: 0ms;
    --e2-reveal-y: 0px;
    --e2-reveal-row-y: 0px;
    --e2-reveal-img-scale: 1;
    --e2-reveal-clip: inset(0 round var(--e2-r-img));
    --e2-rise-y: 0px;
    --e2-sink-y: 0px;
    --e2-lift: 0px;
    --e2-lift-row: 0px;
    --e2-press-y: 0px;
    --e2-menu-y: 0px;
    --e2-menu-scale: 1;
    --e2-dialog-scale: 1;
    --e2-tip-y: 0px;
    --e2-zoom: 1;
    --e2-key-hover: 1;
    --e2-key-press: 1;
    --e2-parallax: 0px;
    --e2-motion: 0;
  }

  /* ------------------------------------------------------------------
     9. Forced colours (Windows High Contrast): map the tokens that end
         up in properties the UA does not force (outline offsets, masks,
         backgrounds of pseudo-elements) to system colours.
     ------------------------------------------------------------------ */
  @media (forced-colors: active) {
    :is(:root, .scheme-night, .e2-scheme-night, .scheme-day, .e2-scheme-day, .e2-on-image, :root:has(> body.scheme-night)) {
      --e2-focus: Highlight;
      --e2-focus-inner: Canvas;
      --e2-link: LinkText;
      --e2-link-hover: LinkText;
      --e2-control-border: ButtonText;
      --e2-line-strong: CanvasText;
      --e2-hair: CanvasText;
      --e2-hair-soft: CanvasText;
      --e2-edge: CanvasText;
      --e2-edge-hot: CanvasText;
      --e2-bracket: CanvasText;
      --e2-gold-decor: CanvasText;
      --e2-gold-1: CanvasText;
      --e2-gold-2: CanvasText;
      --e2-gold-3: CanvasText;
      --e2-accent-ui: Highlight;
      --e2-selection-bg: Highlight;
      --e2-selection-ink: HighlightText;
      --e2-glow-hover: none;
      --e2-glow-hover-filter: none;
      --e2-glow-focus: none;
    }
  }

  /* ------------------------------------------------------------------
     10. Print: ink on white, accents use the (darker) light values; no
         fills, halo or glow; surfaces become a thin grey frame
     ------------------------------------------------------------------ */
  @media print {
    :is(:root, .scheme-night, .e2-scheme-night, .scheme-day, .e2-scheme-day, .e2-on-image, :root:has(> body.scheme-night)) {
      color-scheme: light;
      --e2-bg-void: #fff;
      --e2-bg: #fff;
      --e2-bg-2: #fff;
      --e2-bg-3: #f4f4f4;
      --e2-surface: #fff;
      --e2-surface-1: #fff;
      --e2-surface-2: #f4f4f4;
      --e2-surface-3: #ebebeb;
      --e2-sheet-bg: #fff;
      --e2-card-bg: #fff;
      --e2-glass: #fff;
      --e2-glass-strong: #fff;
      --e2-header-glass: #fff;
      --e2-header-solid: #fff;
      --e2-footer-bg: #fff;
      --e2-footer-bg-2: #fff;
      --e2-footer-ink: #111;
      --e2-footer-ink-2: #333;
      --e2-page-bg: #fff;
      --e2-page-bg-end: #fff;
      --e2-on-navy: #111;
      --e2-on-navy-2: #333;
      --e2-on-image: #111;
      --e2-on-image-2: #333;
      --e2-white: #111;
      --e2-tag-ink: #111;
      --e2-row-hi-1: #fff;
      --e2-row-hi-2: #fff;
      --e2-ink: #111;
      --e2-ink-2: #333;
      --e2-ink-3: #555;
      --e2-link: #5e4622;
      --e2-link-hover: #5e4622;
      --e2-focus: #5e4622;
      --e2-gold-text: #5e4622;
      --e2-title-key: #5e4622;
      --e2-grad-title-key: linear-gradient(#5e4622, #5e4622);
      --e2-grad-gold-word: linear-gradient(#5e4622, #5e4622);
      --e2-line: #ccc;
      --e2-line-strong: #888;
      --e2-hair: #ccc;
      --e2-hair-soft: #ddd;
      --e2-sheet-line: #ccc;
      --e2-control-border: #777;
      --e2-edge: #ccc;
      --e2-edge-hot: #777;
      --e2-bracket: #888;
      --e2-hud-1: #888;
      --e2-hud-2: #888;
      --e2-gold-decor: #888;
      --e2-plate-1: #fff;
      --e2-plate-2: #fff;
      --e2-plate-ink: #111;
      --e2-plate-edge: #777;
      --e2-count-bg: #fff;
      --e2-count-ink: #111;
      --e2-gold-500: #8a6a3a;
      --e2-gold-ink: #5e4622;
      --e2-gold-soft: #fff;
      --e2-violet: #5c3f80;
      --e2-violet-soft: #fff;
      --e2-cyan: #2a4f86;
      --e2-cyan-soft: #fff;
      --e2-sakura: #9b3a64;
      --e2-sakura-soft: #fff;
      --e2-emerald: #205a46;
      --e2-emerald-soft: #fff;
      --e2-amber: #6e4314;
      --e2-amber-soft: #fff;
      --e2-crimson: #8f2c2c;
      --e2-crimson-soft: #fff;
      --e2-ornament: #888;
      --e2-gem-fill: #888;
      --e2-btn-ghost-top: #fff;
      --e2-btn-ghost-mid: #fff;
      --e2-btn-ghost-bottom: #fff;
      --e2-btn-ghost-border: #777;
      --e2-btn-ghost-ink: #111;
      --e2-fill: none;
      --e2-scan: none;
      --e2-grid: none;
      --e2-halo-light: transparent;
      --e2-halo-core: transparent;
      --e2-halo-rim: transparent;
      --e2-halo-glow: none;
      --e2-shadow-1: none;
      --e2-shadow-2: none;
      --e2-shadow-3: none;
      --e2-shadow-4: none;
      --e2-shadow-3-filter: none;
      --e2-shadow-4-filter: none;
      --e2-sheet-shadow: none;
      --e2-card-shadow: none;
      --e2-img-shadow: none;
      --e2-img-shadow-sm: none;
      --e2-win-drop: 0 0 0 transparent;
      --e2-win-drop-sm: 0 0 0 transparent;
      --e2-inset-hi: none;
      --e2-glow-gold: none;
      --e2-glow-violet: none;
      --e2-glow-hover: none;
      --e2-glow-hover-filter: none;
      --e2-glow-focus: none;
      --e2-char-shadow: none;
      --e2-title-glow: none;
      --e2-zebra: #f7f7f7;
    }
  }

  /* ------------------------------------------------------------------
     11. Deprecated tokens (the legacy palette names are mapped in
         sections 1 and 5). They still resolve, so component CSS that has
         not been ported keeps working. Delete each token as soon as grep
         finds no use any more.
     ------------------------------------------------------------------ */
  :root {
    --e2-btn-shine: transparent;
    --e2-btn-hi: transparent;
    --e2-btn-lo: transparent;
    --e2-btn-drop: transparent;
    --e2-btn-gold-drop: transparent;
    --e2-btn-gold-ledge: transparent;
    --e2-btn-violet-ledge: transparent;
    --e2-btn-ghost-ledge: transparent;
    --e2-btn-danger-ledge: transparent;
    --e2-frame-bezel: none;
    --e2-frame-inner-hi: transparent;
    --e2-frame-inner-lo: transparent;
    --e2-noise: none;
    --e2-noise-size: 128px;
    --e2-on-gold: var(--e2-pill-star-ink);
    --e2-orn-corner: url("/assets/e2/img/ornaments/filigree-corner.svg?v=2");
    --e2-orn-divider: url("/assets/e2/img/ornaments/gem-divider.svg?v=2");
    --e2-orn-seam: url("/assets/e2/img/ornaments/seam.svg?v=2");
    --e2-orn-gem: url("/assets/e2/img/ornaments/gem.svg?v=2");
    --e2-grad-night: none; /* the page is flat (bands carry the rhythm) */
    --e2-grad-dawn: none;
  }

  :root,
  .scheme-night,
  .e2-scheme-night,
  .scheme-day,
  .e2-scheme-day,
  .e2-on-image {
    --e2-gold-hairline: var(--e2-hairline);
    --e2-grad-gold-text: var(--e2-grad-title-key);
    --e2-title-gold-filter: none;
    --e2-btn-gold-top: var(--e2-pill-star-1);
    --e2-btn-gold-mid: var(--e2-pill-star-2);
    --e2-btn-gold-bottom: var(--e2-pill-star-3);
    --e2-btn-gold-border: var(--e2-pill-star-edge);
    --e2-btn-gold-ink: var(--e2-pill-star-ink);
  }
}
