/* ==========================================================================
   THEMING CONVENTION (three light themes + three dark themes)
   --------------------------------------------------------------------------
   Theming is token-first. `:root` below defines every semantic token in its
   LIGHT value; the dark block further down RE-DEFINES those same tokens with
   dark (gb-*) values. Component CSS consumes var(--token) and stays
   theme-agnostic — it flips automatically when the tokens change.

   Seven data-theme values behind four settings (static/js/theme-boot.js).
   Four light — genmaicha (Genmaicha's light: warm paper, one green),
   matcha (the same look in true grays and lime), nord-light (Cosmic's
   light side, Nord's Snow Storm), prism (after Jira) — and three dark —
   dark (Gruvbox, which with data-look="genmaicha" is Genmaicha's dark,
   and with data-look="prism" is Prism's, in Jira's dark colours),
   cosmic (Cosmic's dark side, Nord's Polar Night) and kosmic (the same
   under the night sky). Genmaicha, Cosmic and Prism each have a light
   and a dark side; Matcha is light only. All but Prism wear one look,
   genmaicha.css; Prism wears its own, prism.css, on both sides.
   The other darks ARE the dark theme structurally — they share the dark
   token block and every dark structural rule, and only repoint the
   --gb-* ramp (see the blocks after the dark block). So any "dark" rule is
   scoped to ALL THREE:
   `:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"])`.
   The lights are light structurally: they inherit every :root default
   (Matcha's old token set, still the default and the light island below)
   and their blocks only repoint colour tokens; dark structural rules
   never apply. (Retired: sky, kosmos, kosmos-dark, latte, mocha, basic,
   paper, everforest, and Auto; theme-boot.js migrates stored settings.)

   RULE OF THUMB:
   1. If dark only needs a different *value*, add/repoint a token here. Do NOT
      write a scoped rule.
   2. Only when dark needs a structurally *different rule* (e.g. filled vs
      outline buttons, accent rail vs fill — where the colour moves to a
      different property) add a
      `:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"]) .component`
      block, co-located at the bottom of that component's own CSS file under a
      "Dark mode —" comment. Keep the colour decision in a token, the
      structural rule in the component. Do not start a monolithic dark.css.
   ========================================================================== */

/* The light token set is the default (:root). Tagging any element with
   data-theme="light" re-applies it within that subtree — used to keep a "light
   island" (e.g. the viewer's highlight cards) light inside a dark page. */
:root,
[data-theme="light"] {
  /* Native form controls + scrollbars follow this */
  color-scheme: light;

  /* ==========================================================================
     Design System - Semantic Colors
     These reference the palette.css color definitions
     ========================================================================== */

  /* Tab corner masks */
  --mask-tab-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M8,0 L8,8 L0,8 A8,8 0 0,0 8,0 Z' fill='white'/%3E%3C/svg%3E");
  --mask-tab-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M0,0 L0,8 L8,8 A8,8 0 0,1 0,0 Z' fill='white'/%3E%3C/svg%3E");

  /* Border radius. --radius-xs was referenced across the app for years but
     never defined — every var(--radius-xs) corner silently rendered square.
     Defined here so those chips and buttons actually round. */
  --radius-xs: 0.25rem;
  --radius-sm: 0.25rem;
  --radius-md: 0.25rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;

  /* Apple 8pt spacing scale (4px half-step + 8px multiples) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* ==========================================================================
     Typography & Text
     ========================================================================== */
  --color-primary: var(--stone-600);
  --color-darker: var(--stone-800);
  --color-muted: var(--stone-500);
  --color-muted-more: var(--stone-400);
  --color-lighter: var(--stone-300);

  /* ==========================================================================
     Links
     ========================================================================== */
  --link: var(--lime-750);
  --link-hover: var(--lime-600);
  /* Brand surfaces (sidebar mark/wordmark, auth monogram) follow the link
     colour unless a theme pins a dedicated ink. */
  --brand-ink: var(--link);
  /* The brand gradient (after the landing page's wordmark, mirrored): it
     leads with the brand ink, the stronger colour, and runs out into a
     second hue each theme picks from its own palette, across the word and
     again across the sparkle. Only that far end is a per-theme decision;
     a theme that sets --brand-grad-to to var(--brand-ink) keeps a flat
     brand. Matcha: the link green into violet, two steps lighter than
     the accent-icon violet so the tail lifts rather than deepens. */
  --brand-grad-from: var(--brand-ink);
  --brand-grad-to: var(--violet-500);

  /* Keyboard focus ring: each theme's accent pulled halfway toward a
     fixed mid-gray (OKLCH mix keeps the hue) — link colours are
     text-inks, too heavy as rings on light grounds and glaring on dark;
     the mix normalizes both directions toward mid-tone. (Relative color
     syntax expressed this more precisely but lacks browser support.)
     Resolves per theme because var(--accent-link) substitutes per
     element. */
  --focus-ring: color-mix(in oklch, var(--accent-link) 50%, oklch(0.62 0 none));
  /* Input focus borders run a step lighter than the keyboard ring — the
     border+inset pair reads heavier than an offset ring, so it gets
     diluted toward the field's own ground. */
  --field-focus: color-mix(in oklch, var(--focus-ring) 65%, var(--input-background));

  /* ==========================================================================
     Backgrounds
     ========================================================================== */
  --background-nav: var(--stone-350);
  --background-body: var(--stone-125);
  --background-subnav: var(--stone-200);
  --background-subnav-contrast: var(--stone-225);
  --background-control: var(--stone-200);
  --background-section: var(--stone-150);

  /* Table headers follow the control surface by default; themes that want
     lighter headers without touching the many other control-surface consumers
     (toolbars, buttons, chips) repoint this alone. */
  --background-th: var(--background-control);
  --background-td: var(--stone-125);
  --background-medium-light: var(--stone-75);
  --background-light: var(--stone-50);
  /* AI chat standalone surface ramp — its own light palette (frame darker than
     the panels on top); the dark values invert it into a proper dark ramp. */
  --ai-frame: var(--stone-300);
  --ai-surface: var(--stone-50);
  --ai-raised: var(--stone-100);
  --past-due-bg: var(--yellow-50);
  /* A board card's due date: overdue in the red, due by the day after
     tomorrow on the highlight yellow (the calendar's soon) */
  --due-overdue: var(--red-600);
  --due-soon-bg: var(--yellow-100);
  --due-soon-line: color-mix(in oklch, var(--yellow-400) 60%, transparent);
  --due-soon-ink: var(--yellow-900);
  /* Due today/tomorrow card wash (dash + overview timeline) — same soft
     yellow-50 family as the past-due surfaces, NOT the stronger --hl-yellow
     text highlight. Dark themes drop the wash for a rail, so no dark value. */
  --due-soon-bg: var(--yellow-50);
  --task-highlight-bg: var(--selected-background);

  /* Warning toast — a soft yellow wash in light mode so it reads against the
     page; the type rail is dropped here (the wash carries the signal). The dark
     block reverts to neutral surfaces and restores the rail. */
  --toast-warning-header-bg: var(--yellow-100);
  --toast-warning-body-bg: var(--yellow-50);
  --toast-warning-rail: 1px solid var(--border-dark);

  /* ==========================================================================
     Navigation
     ========================================================================== */
  --color-nav: var(--color-primary);
  --background-nav-tab-active: var(--background-body);
  --background-subnav-tab-active: var(--background-section);
  /* The detail pages' title-bar/subnav seam; themes with one flat chrome
     surface dissolve it. */
  --subnav-divider: var(--border-medium-dark);

  /* ==========================================================================
     Sidebar
     ========================================================================== */
  --sidebar-width: 16rem;
  --sidebar-width-collapsed: 4.5rem;
  --topnav-height: 3.5rem;
  --background-sidebar: var(--stone-200);
  --background-sidebar-hover: var(--stone-225);
  --background-sidebar-active: var(--stone-250);

  /* ==========================================================================
     Buttons
     ========================================================================== */
  --button-primary-background: var(--link);
  --button-primary-color: var(--color-lighter);
  --button-secondary-background: var(--background-section);
  --button-secondary-color: var(--color-primary);
  --button-toolbar: var(--color-primary);
  --btn-secondary-bg: var(--blue-50);
  --btn-success-bg: var(--lime-100);
  --btn-danger-bg: var(--red-100);

  /* ==========================================================================
     Forms & Inputs
     ========================================================================== */
  --input-border: var(--stone-300);
  --input-background: var(--stone-50);
  --input-placeholder: var(--stone-400);

  /* ==========================================================================
     Borders & Dividers
     ========================================================================== */
  --border-light: var(--stone-200);
  --border-medium: var(--stone-300);
  --border-medium-dark: var(--stone-350);
  --border-dark: var(--stone-400);
  /* Toolbar buttons follow the medium border by default; themes that want
     more button definition without touching the many other border-medium
     consumers (table grids, hairlines) repoint this alone. */
  --button-border: var(--border-medium);

  /* ==========================================================================
     Selection & Active States
     ========================================================================== */
  --selected-background: var(--violet-150);
  --selected-color: var(--stone-700);
  --selected-border: var(--border-medium-dark);

  /* A tooltip (the sidebar's, collapsed or across the top): the ink's
     darkest step, lettered in its lightest. The lights repoint the stone
     steps, so it follows them; the darks set their own below. */
  --tooltip-background: var(--stone-700);
  --tooltip-color: var(--stone-100);

  /* ==========================================================================
     Status & Feedback
     ========================================================================== */
  --urgent: var(--orange-800);
  --warning: var(--orange-800);
  --success: var(--lime-700);
  --true: var(--lime-700);
  --false: var(--urgent);
  --error: var(--urgent);
  --error-background: var(--orange-100);
  --error-border: var(--urgent);

  /* Semantic status-green chips — themable, unlike the provider brand
     badges which stay constant. Defaults are Matcha's limes. */
  --status-green-bg: var(--lime-100);
  --status-green-ink: var(--lime-800);
  --status-green-line: var(--lime-300);
  --status-green-hover: var(--lime-200);

  /* ==========================================================================
     Labels & Badges
     ========================================================================== */
  --label-gray: var(--background-control);
  --label-green: var(--lime-100);
  --label-orange: var(--orange-100);
  --label-purple: var(--violet-100);
  --label-red: var(--red-100);
  --label-yellow: var(--yellow-100);

  /* ==========================================================================
     Icons
     ========================================================================== */
  --icon-default: var(--color-primary);
  --icon-muted: var(--color-muted);
  --icon-muted-more: var(--color-muted-more);
  --accent-link: var(--link);
  --icon-violet: var(--violet-700);
  --icon-violet-muted: var(--violet-600);
  --icon-yellow: var(--yellow-700);
  --add: var(--link);

  /* ==========================================================================
     Row Highlights
     ========================================================================== */
  --hl-gray: var(--background-control);
  --hl-blue: var(--blue-100);
  --hl-slate: var(--slate-100);
  --hl-green: var(--lime-100);
  --hl-orange: var(--orange-100);
  --hl-violet: var(--violet-100);
  --hl-red: var(--red-100);
  --hl-yellow: var(--yellow-100);

  /* Calendar entries (apps/calendar.css reads these; every theme may
     repoint them). The event chip is stone halfway between the 200 and
     300 steps, let through at 78% so the day cell shows. An all-day event
     is the stone two steps off the cell with a breath of the links' lime
     in it, a task one step off with the same breath, each ruled round in
     the stone a step darker; the dot, for timed entries and the agenda,
     is the chip's hue well darker, so it reads at its size. */
  --calendar-chip: color-mix(
    in oklch,
    color-mix(in oklch, var(--stone-200), var(--stone-300)) 78%,
    transparent
  );
  --calendar-allday: oklch(0.87 0.018 131);
  --calendar-allday-color: var(--color-primary);
  --calendar-task: oklch(0.92 0.016 131);
  --calendar-task-color: var(--color-primary);
  --calendar-task-icon: var(--color-primary);
  --calendar-chip-border: var(--stone-350);
  --calendar-dot: oklch(0.58 0.045 131);
  --calendar-allday-dot: var(--calendar-dot);
  /* a holiday: the all-day chip turned blue at the same lightness */
  --calendar-holiday: oklch(from var(--calendar-allday) l c 250);
  --calendar-holiday-color: var(--calendar-allday-color);
  --calendar-today: var(--amber-100);

  /* Row washes — the same hues a step lighter, for tables that carry the colour
     across a whole row (the timeline). The --hl-* fills above are sized for
     small areas — text marks, chips, a button state — and over five columns
     that much tint reads heavy. Derived off each fill rather than pinned to a
     ramp step, so the tinted light themes soften by the same amount as Matcha.
     The darks paint a rail instead of a fill and never use these. */
  --hl-wash-gray: color-mix(in oklch, var(--hl-gray) 50%, var(--background-td));
  --hl-wash-blue: color-mix(in oklch, var(--hl-blue) 50%, var(--background-td));
  --hl-wash-slate: color-mix(in oklch, var(--hl-slate) 50%, var(--background-td));
  --hl-wash-green: color-mix(in oklch, var(--hl-green) 50%, var(--background-td));
  --hl-wash-orange: color-mix(in oklch, var(--hl-orange) 50%, var(--background-td));
  --hl-wash-violet: color-mix(in oklch, var(--hl-violet) 50%, var(--background-td));
  --hl-wash-red: color-mix(in oklch, var(--hl-red) 50%, var(--background-td));
  --hl-wash-yellow: color-mix(in oklch, var(--hl-yellow) 50%, var(--background-td));

}

/* ==========================================================================
   Nord Light — Nord's light side, cosmic's daytime counterpart.

   Snow Storm surfaces (nord4-6 plus the interpolated --nord-snow-* steps in
   palette.css), Polar Night text, frost deep-blue links and primary buttons,
   and the signature frost cyan as the selection wash. The frost family is
   deliberately cool everywhere; the warmth comes from aurora, placed only
   where meaning lives — status inks, Add, the yellow icons, and the
   highlight/label tints (aurora pulled to ink weight or diluted to snow
   tints in palette.css, since canonical aurora is sized for dark grounds).
   Structurally it IS the light theme — it inherits every :root token and
   only repoints colours; dark structural rules never apply.
   ========================================================================== */
[data-theme="nord-light"] {
  color-scheme: light;

  /* Typography & Text — the Polar Night ramp over snow */
  --color-primary: var(--nord2);
  --color-darker: var(--nord0);
  --color-muted: var(--nord3-bright);
  --color-muted-more: var(--nord-gray);
  --color-lighter: var(--nord4);

  /* Links — a step below nord10 for ink-level contrast, lifting to the
     canonical frost deep blue on hover */
  --link: var(--nord10-deep);
  --link-hover: var(--nord10);
  /* Brand gradient — the frost link blue into the aurora purple at ink
     weight (the accent-icon hue, as Matcha runs into its violet) */
  --brand-grad-to: var(--nord15-ink);

  /* Backgrounds — the Snow Storm ladder: nord6 body and table cells under a
     shared nord5 chrome tier, nord4 nav */
  --background-nav: var(--nord4);
  --background-body: var(--nord6);
  --background-subnav: var(--nord5);
  --background-subnav-contrast: var(--nord4);
  --background-section: var(--nord5);
  --background-th: var(--nord5);
  --background-control: var(--nord5);
  --background-td: var(--nord6);
  --background-medium-light: var(--nord-snow-mid);
  --background-light: var(--nord-snow-bright);
  --ai-frame: var(--nord4);
  --ai-surface: var(--nord-snow-bright);
  --ai-raised: var(--nord-snow-mid);

  /* Sidebar */
  --background-sidebar: var(--nord5);
  --background-sidebar-hover: var(--nord4);
  --background-sidebar-active: var(--nord-snow-dark);

  /* Buttons — solid frost blue under near-white snow */
  --button-primary-background: var(--nord10);
  --button-primary-color: var(--nord-snow-bright);

  /* Forms & Inputs */
  --input-border: var(--nord-snow-dark);
  --input-background: var(--nord-snow-bright);
  --input-placeholder: var(--nord-gray);

  /* Borders — cool polar grays in place of stone, the whole ramp one
     step darker than the surface ladder (2026-07-21: the surface-step
     values read faint as edges — tables, nav seams, and toolbar frames
     all rise together) */
  --border-light: var(--nord4);
  --border-medium: var(--nord-snow-dark);
  --border-medium-dark: var(--nord4-dim);
  --border-dark: var(--nord3-bright);

  /* Selection — the frost cyan wash under Polar Night text. The active
     border gets a real frost hue, dimmed toward the snow ground: full
     nord7 read sharp as an outline on the wash. Toolbar buttons take the
     mid border step for the same reason (nord4-dim is the general
     medium-dark border and stays put — cosmic's text ramp shares it). */
  --selected-background: var(--nord-frost-tint);
  --selected-color: var(--nord1);
  --selected-border: var(--nord7-dim);
  --button-border: var(--nord4-mid);

  /* Accent icons (filter, active sort, new-note/checklist badges) — aurora
     purple at ink weight. The 6yan ink blended into the gray-blue canvas;
     mauve is the one hue nothing else on screen uses, so "on" actually
     reads. */
  --icon-violet: var(--nord15-ink);
  --icon-violet-muted: var(--nord15);
  --icon-yellow: var(--nord13-ink);

  /* Status — aurora at ink weight (--false/--error/--error-border follow
     --urgent from :root automatically) */
  --urgent: var(--nord11-ink);
  --warning: var(--nord12-ink);
  --success: var(--nord14-ink);
  --true: var(--nord14-ink);
  --error-background: var(--nord11-tint);

  /* Add — aurora green (:root points it at --link, which is blue here) */
  --add: var(--nord14-ink);

  /* Past-due / due-soon washes and the warning toast — aurora yellow
     diluted to snow */
  --past-due-bg: var(--nord13-wash);
  --due-soon-bg: var(--nord13-wash);
  --toast-warning-header-bg: var(--nord13-tint);
  --toast-warning-body-bg: var(--nord13-wash);

  /* Buttons — success/danger fills on the aurora tints; Cancel takes the
     frost wash instead of inheriting Matcha's blue-50 */
  --btn-success-bg: var(--nord14-tint);
  --btn-danger-bg: var(--nord11-tint);
  --btn-secondary-bg: var(--nord-frost-tint);

  /* Row highlights — aurora (and frost blue) as snow tints; gray/slate
     inherit the cool defaults, which already read Nordic */
  --hl-blue: var(--nord9-tint);
  --hl-green: var(--nord14-tint);
  --hl-orange: var(--nord12-tint);
  --hl-violet: var(--nord15-tint);
  --hl-red: var(--nord11-tint);
  --hl-yellow: var(--nord13-tint);

  /* Calendar entries: the control grays, no lime; the dot is the link */
  --calendar-chip: var(--background-control);
  --calendar-allday: var(--background-control);
  --calendar-task: var(--background-light);
  --calendar-chip-border: var(--border-medium-dark);
  --calendar-dot: var(--link);
  --calendar-holiday: var(--hl-blue);
  --calendar-today: var(--nord13-tint);

  /* Labels & badges — the same aurora tints (label-gray follows control) */
  --label-green: var(--nord14-tint);
  --label-orange: var(--nord12-tint);
  --label-purple: var(--nord15-tint);
  --label-red: var(--nord11-tint);
  --label-yellow: var(--nord13-tint);
}

/* ==========================================================================
   Prism — a LIGHT theme after Jira today (the Atlassian Design System's
   2025 palette, the --prism-* ramps in palette.css). White everywhere a
   thing sits, a pale grey head on a table, one hairline grey, a
   near-black ink with two greys below it, and one blue for everything
   that acts or is chosen: links, the primary button, tabs, ticks,
   switches, selection, focus. Status is a tinted lozenge in its hue
   with a line a step darker.

   Structurally a light theme: the block repoints Kosmos's ramps onto
   Jira's first, as Genmaicha repoints its ladder, so every component
   that reaches a ramp step directly follows, and then sets the roles.
   What tokens cannot reach (the face, sentence-case table heads,
   underline tabs, lozenge lines) is in prism.css.
   ========================================================================== */
[data-theme="prism"] {
  color-scheme: light;
  /* The seven person colours: a user's initials on the board and their
     filter chip (CustomUser.person_hue, prism.css). Clear of red
     (overdue) and yellow (soon), and only ramps no theme repoints, so a
     person keeps one colour (violet is the darks' aqua). */
  --person-0: var(--orange-600);
  --person-1: var(--indigo-600);
  --person-2: var(--teal-600);
  --person-3: var(--blue-600);
  --person-4: var(--pink-600);
  --person-5: var(--fuchsia-600);
  --person-6: var(--cyan-600);


  /* The ladder: white surfaces, the near-neutral greys, the ink */
--stone-25: var(--prism-neutral-0);
  --stone-50: var(--prism-neutral-0);
  --stone-75: var(--prism-neutral-100);
  --stone-100: var(--prism-neutral-100);
  --stone-125: var(--prism-neutral-200);
  --stone-150: var(--prism-neutral-200);
  --stone-175: var(--prism-neutral-200);
  --stone-200: var(--prism-neutral-200);
  --stone-215: var(--prism-neutral-300);
  --stone-225: var(--prism-neutral-300);
  --stone-250: var(--prism-neutral-300);
  --stone-300: var(--prism-neutral-300);
  --stone-350: var(--prism-neutral-400);
  --stone-375: var(--prism-neutral-400);
  --stone-400: var(--prism-neutral-500);
  --stone-500: var(--prism-neutral-700);
  --stone-600: var(--prism-neutral-800);
  --stone-700: var(--prism-neutral-1000);
  --stone-800: var(--prism-neutral-1000);
  --stone-900: var(--prism-neutral-1000);

  /* Slate is the ladder too */
  --slate-50: var(--prism-neutral-100);
  --slate-100: var(--prism-neutral-200);
  --slate-300: var(--prism-neutral-300);
  --slate-400: var(--prism-neutral-500);
  --slate-500: var(--prism-neutral-700);
  --slate-600: var(--prism-neutral-800);
  --slate-800: var(--prism-neutral-1000);

  /* Matcha's violet (filters, sort, switches, ticks, selection) is the blue */
  --violet-50: var(--prism-blue-100);
  --violet-75: var(--prism-blue-100);
  --violet-100: var(--prism-blue-100);
  --violet-150: var(--prism-blue-200);
  --violet-200: var(--prism-blue-200);
  --violet-300: var(--prism-blue-300);
  --violet-400: var(--prism-blue-400);
  --violet-500: var(--prism-blue-600);
  --violet-600: var(--prism-blue-700);
  --violet-700: var(--prism-blue-700);
  --violet-800: var(--prism-blue-800);
  --violet-900: var(--prism-blue-900);
  --violet-950: var(--prism-blue-1000);

  /* Matcha's lime (success, the add mark, the money greens) is the green */
  --lime-50: var(--prism-green-100);
  --lime-100: var(--prism-green-100);
  --lime-200: var(--prism-green-200);
  --lime-300: var(--prism-green-300);
  --lime-400: var(--prism-green-400);
  --lime-500: var(--prism-green-500);
  --lime-600: var(--prism-green-600);
  --lime-700: var(--prism-green-700);
  --lime-750: var(--prism-green-700);
  --lime-800: var(--prism-green-800);
  --lime-900: var(--prism-green-900);
  --lime-950: var(--prism-green-1000);

  --green-50: var(--prism-green-100);
  --green-400: var(--prism-green-400);
  /* The hues, step for step */
  --blue-50: var(--prism-blue-100);
  --blue-100: var(--prism-blue-100);
  --blue-200: var(--prism-blue-200);
  --blue-300: var(--prism-blue-300);
  --blue-400: var(--prism-blue-400);
  --blue-500: var(--prism-blue-500);
  --blue-600: var(--prism-blue-700);
  --blue-700: var(--prism-blue-800);
  --blue-800: var(--prism-blue-800);
  --blue-900: var(--prism-blue-900);
  --blue-950: var(--prism-blue-1000);

  --red-50: var(--prism-red-100);
  --red-100: var(--prism-red-100);
  --red-200: var(--prism-red-200);
  --red-300: var(--prism-red-300);
  --red-400: var(--prism-red-400);
  --red-500: var(--prism-red-500);
  --red-600: var(--prism-red-700);
  --red-700: var(--prism-red-800);
  --red-800: var(--prism-red-800);
  --red-900: var(--prism-red-900);
  --red-950: var(--prism-red-1000);
  --orange-50: var(--prism-orange-100);
  --orange-100: var(--prism-orange-100);
  --orange-200: var(--prism-orange-200);
  --orange-300: var(--prism-orange-300);
  --orange-400: var(--prism-orange-400);
  --orange-500: var(--prism-orange-500);
  --orange-600: var(--prism-orange-700);
  --orange-700: var(--prism-orange-800);
  --orange-800: var(--prism-orange-800);
  --orange-900: var(--prism-orange-900);
  --orange-950: var(--prism-orange-1000);
  --yellow-50: var(--prism-yellow-100);
  --yellow-100: var(--prism-yellow-100);
  --yellow-200: var(--prism-yellow-200);
  --yellow-300: var(--prism-yellow-300);
  --yellow-400: var(--prism-yellow-400);
  --yellow-500: var(--prism-yellow-500);
  --yellow-600: var(--prism-yellow-600);
  --yellow-700: var(--prism-yellow-700);
  --yellow-800: var(--prism-yellow-800);
  --yellow-900: var(--prism-yellow-900);
  --yellow-950: var(--prism-yellow-1000);
  --amber-50: var(--prism-yellow-100);
  --amber-100: var(--prism-yellow-100);
  --amber-300: var(--prism-yellow-300);
  --amber-500: var(--prism-yellow-500);
  --amber-600: var(--prism-yellow-600);
  --amber-700: var(--prism-yellow-700);
  --purple-100: var(--prism-purple-100);
  --purple-400: var(--prism-purple-400);

  /* Corners: Jira's 6px on buttons and fields, 8px on tables and cards */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;

  /* Type: the ink, the head grey, the subtlest grey */
  --color-primary: var(--prism-neutral-1000);
  --color-darker: var(--prism-neutral-1000);
  --color-muted: var(--prism-neutral-800);
  --color-muted-more: var(--prism-neutral-700);
  --color-lighter: var(--prism-neutral-400);

  /* Links and the brand: the blue, deepening on hover; the brand runs
     out into Jira's purple */
  --link: var(--prism-blue-700);
  --link-hover: var(--prism-blue-800);
  --brand-grad-to: var(--prism-purple-700);

  /* Focus: the blue itself, not the derivation's grey mix */
  --focus-ring: var(--prism-blue-700);
  --field-focus: var(--prism-blue-700);

  /* Grounds: white; the first grey for a table's head and the second
     for a hover */
  --background-nav: var(--prism-neutral-0);
  --background-body: var(--prism-neutral-0);
  --background-subnav: var(--prism-neutral-0);
  --background-subnav-contrast: var(--prism-neutral-200);
  --background-control: var(--prism-neutral-0);
  --background-section: var(--prism-neutral-0);
  --background-th: var(--prism-neutral-100);
  --background-td: var(--prism-neutral-0);
  --background-medium-light: var(--prism-neutral-100);
  --background-light: var(--prism-neutral-0);
  --ai-frame: var(--prism-neutral-200);
  --ai-surface: var(--prism-neutral-0);
  --ai-raised: var(--prism-neutral-100);
  --past-due-bg: var(--prism-yellow-100);
  --due-soon-bg: var(--prism-yellow-100);
  --toast-warning-header-bg: var(--prism-yellow-200);
  --toast-warning-body-bg: var(--prism-yellow-100);

  /* Navigation: one white bar ruled along its foot; the place you are is
     underlined in the blue (prism.css) */
  --color-nav: var(--prism-neutral-800);
  --background-nav-tab-active: var(--prism-neutral-0);
  --background-subnav-tab-active: var(--prism-neutral-0);
  --subnav-divider: var(--prism-neutral-300);
  --background-sidebar: var(--prism-neutral-0);
  --background-sidebar-hover: var(--prism-neutral-200);
  --background-sidebar-active: var(--prism-blue-100);

  /* Buttons: the primary is the blue under white; the rest are white in
     the hairline, the save button too (prism.css fills it) */
  --button-primary-background: var(--prism-blue-700);
  --button-primary-color: var(--prism-neutral-0);
  --button-secondary-background: var(--prism-neutral-0);
  --button-secondary-color: var(--prism-neutral-800);
  --button-toolbar: var(--prism-neutral-800);
  --button-border: var(--prism-neutral-300);
  --btn-secondary-bg: var(--prism-neutral-0);
  --btn-success-bg: var(--prism-blue-700);
  --btn-danger-bg: var(--prism-red-100);

  /* Fields: white in the hairline, the blue when focused */
  --input-border: var(--prism-neutral-300);
  --input-background: var(--prism-neutral-0);
  --input-placeholder: var(--prism-neutral-700);

  /* Rules: one hairline grey; the tick box's darker line for emphasis */
  --border-light: var(--prism-neutral-200);
  --border-medium: var(--prism-neutral-300);
  --border-medium-dark: var(--prism-neutral-300);
  --border-dark: var(--prism-neutral-500);

  /* Selection: the palest blue under the blue's ink */
  --selected-background: var(--prism-blue-100);
  --selected-color: var(--prism-blue-800);
  --selected-border: var(--prism-blue-300);

  /* Status */
  --urgent: var(--prism-red-700);
  --warning: var(--prism-orange-700);
  --success: var(--prism-green-700);
  --true: var(--prism-green-700);
  --error-background: var(--prism-red-100);
  --status-green-bg: var(--prism-green-100);
  --status-green-ink: var(--prism-green-800);
  --status-green-line: var(--prism-green-300);
  --status-green-hover: var(--prism-green-200);

  /* Labels: the lozenge tints (In Progress's blue is the 200 step) */
  --label-gray: var(--prism-neutral-200);
  --label-green: var(--prism-green-200);
  --label-orange: var(--prism-orange-200);
  --label-purple: var(--prism-purple-200);
  --label-red: var(--prism-red-200);
  --label-yellow: var(--prism-yellow-200);

  /* Icons: the head grey; the blue for what is on */
  --icon-default: var(--prism-neutral-800);
  --icon-muted: var(--prism-neutral-700);
  --icon-muted-more: var(--prism-neutral-500);
  --icon-violet: var(--prism-blue-700);
  --icon-violet-muted: var(--prism-blue-400);
  --icon-yellow: var(--prism-yellow-700);
  --add: var(--prism-blue-700);

  /* Row highlights: the pale tints */
  --hl-gray: var(--prism-neutral-200);
  --hl-blue: var(--prism-blue-100);
  --hl-slate: var(--prism-neutral-100);
  --hl-green: var(--prism-green-100);
  --hl-orange: var(--prism-orange-100);
  --hl-violet: var(--prism-purple-100);
  --hl-red: var(--prism-red-100);
  --hl-yellow: var(--prism-yellow-100);

  /* Calendar: events in the blue tint under the blue's ink, ruled a
     step darker; tasks in the purple; holidays in the teal; today the
     palest blue */
  --calendar-chip: var(--prism-blue-100);
  --calendar-allday: var(--prism-blue-200);
  --calendar-allday-color: var(--prism-blue-900);
  --calendar-task: var(--prism-purple-100);
  --calendar-task-color: var(--prism-purple-900);
  --calendar-task-icon: var(--prism-purple-700);
  --calendar-chip-border: var(--prism-blue-300);
  --calendar-dot: var(--prism-blue-700);
  --calendar-allday-dot: var(--prism-blue-700);
  --calendar-holiday: var(--prism-teal-200);
  --calendar-holiday-color: var(--prism-teal-900);
  --calendar-today: var(--prism-blue-100);
}

/* ==========================================================================
   Utility Classes - Highlights
   ========================================================================== */

.hl-blue { background: var(--hl-blue) !important; }
.hl-slate { background: var(--hl-slate) !important; }
.hl-gray { background: var(--hl-gray) !important; }
.hl-green { background: var(--hl-green) !important; }
.hl-orange { background: var(--hl-orange) !important; }
.hl-violet { background: var(--hl-violet) !important; }
.hl-purple { background: var(--hl-violet) !important; }
.hl-red { background: var(--hl-red) !important; }
.hl-yellow { background: var(--hl-yellow) !important; }

/* Dark mode — bright "line" colour per highlight class, for contexts that show
   the colour as an accent (underline / rail / swatch) rather than a muddy dark
   fill. Harmless on the generic .hl-* fills, which ignore it. */
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) .hl-yellow { --hl-line: var(--yellow-400); }
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) .hl-red    { --hl-line: var(--red-400); }
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) .hl-orange { --hl-line: var(--orange-400); }
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) .hl-green  { --hl-line: var(--lime-400); }
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) .hl-blue   { --hl-line: var(--blue-400); }
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) :is(.hl-violet, .hl-purple) { --hl-line: var(--violet-400); }
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) :is(.hl-slate, .hl-gray) { --hl-line: var(--slate-400); }

/* Dark mode — any table row flagged with a highlight colour shows it as a bright
   left rail on the first cell, never a full-row fill (dark fills go muddy and
   dominate). Covers facts/timeline, calendar & event rows, dash totals, etc. */
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) tr[class*="hl-"],
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) tr[class*="hl-"] > td {
  background: transparent !important;
}
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) tr[class*="hl-"] > td:first-child {
  box-shadow: inset 3px 0 0 0 var(--hl-line);
}

.past-due td { background: var(--past-due-bg); }

/* ==========================================================================
   Utility Classes - Text
   ========================================================================== */

.text-muted {
  color: var(--color-muted) !important;
}

/* ==========================================================================
   Utility Classes - Status
   ========================================================================== */

.true-bool {
  color: var(--true);
}

.false-bool {
  color: var(--false);
}

.money-positive {
  color: var(--success) !important;
}

/* ==========================================================================
   Genmaicha, Matcha and Nord Light — three LIGHT themes, after the
   Booklist app, and one look (genmaicha.css, data-look="genmaicha"). Two grounds and no
   more: the page, and a card a little lighter than it, which is what a
   table, a control, the bars and a field on the page are made of. One
   line rules everything, at full strength round a thing and at a little
   over half between its rows.

   The block below is the look, said in the --genmaicha-* sources; each
   theme's own block after it says what the sources are.
   - Genmaicha: Booklist's warm paper and warm ink, and one muted green
     that does all the accent's work (the mark is the green too). It
     stands on Paper's ladder, so its block repoints the ramp steps.
   - Matcha: the same look in true grays, with the lime doing the
     accent's work (what acts and what is chosen alike) and the violet
     left to its own steps: the filter and sort icons, the priority
     flags, the AI marks, the far end of the brand. It stands on the
     :root ladder and ramps as they are.
   - Nord Light: the same look on Snow Storm under Polar Night ink, the
     deep frost blue for what acts and the frost cyan for what is chosen,
     as Nord's dark side has it. Its block repoints the stone steps the
     look stands on onto the snow.
   What tokens cannot reach (the small capitals, the inverted switches,
   the dialogs without rules) is in genmaicha.css.
   ========================================================================== */
:is([data-theme="genmaicha"], [data-theme="matcha"], [data-theme="nord-light"], [data-theme="mizan"]) {
  color-scheme: light;

  /* Corners: rounder than Matcha's, as Booklist's are. Tables, cards
     and dialogs are rounder still (genmaicha.css). */
  --radius-sm: 0.5rem;
  --radius-md: 0.5rem;

  /* The look's two grounds by name, what is written on the green, and the
     tick in a ticked box: genmaicha.css draws with these on both sides */
  --genmaicha-page: var(--stone-125);
  --genmaicha-on-green: var(--genmaicha-card);
  --genmaicha-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");

  /* The line, and the same at a little over half strength on the card */
  --genmaicha-line-soft: color-mix(in srgb, var(--genmaicha-line) 55%, var(--stone-50));
  --genmaicha-line-strong: color-mix(in srgb, var(--genmaicha-muted) 45%, var(--genmaicha-line));
  /* A breath of the mark in the card, and twice that for what is chosen */
  --genmaicha-hover: color-mix(in srgb, var(--genmaicha-mark) 7%, var(--stone-50));
  --genmaicha-selected: color-mix(in srgb, var(--genmaicha-mark) 14%, var(--stone-50));

  /* Grounds: the page is the base; everything that stands on it is the
     card. The bars are cards laid across the page, ruled along the foot. */
  --background-nav: var(--stone-50);
  --background-subnav: var(--stone-125);
  --background-subnav-contrast: var(--genmaicha-hover);
  --background-control: var(--stone-50);
  --background-section: var(--stone-50);
  --background-th: var(--stone-50);
  --background-td: var(--stone-50);
  --background-sidebar: var(--stone-50);
  --background-sidebar-hover: var(--genmaicha-hover);
  --background-sidebar-active: var(--genmaicha-selected);
  --subnav-divider: var(--genmaicha-line);

  /* Type */
  --color-lighter: var(--stone-50);

  /* Rules: the soft line between rows and cells, the full line round a
     table, a button and a field */
  --border-light: var(--genmaicha-line-soft);
  --border-medium: var(--genmaicha-line-soft);
  --border-medium-dark: var(--genmaicha-line);
  --border-dark: var(--genmaicha-line-strong);
  --button-border: var(--genmaicha-line);
  --input-border: var(--genmaicha-line);
  --input-placeholder: var(--genmaicha-muted-light);

  /* Buttons: Cancel and Delete are the card inside the line, the one
     that finishes the job is the green (their words: genmaicha.css) */
  --btn-secondary-bg: var(--stone-50);
  --btn-success-bg: var(--genmaicha-green);
  --btn-danger-bg: var(--stone-50);

  /* Selection */
  --selected-background: var(--genmaicha-selected);
  --selected-border: color-mix(in srgb, var(--genmaicha-mark) 40%, var(--genmaicha-line));
  --selected-color: var(--stone-700);

  /* Status */
  --urgent: var(--genmaicha-red);
  --warning: var(--genmaicha-red);
  --icon-yellow: var(--genmaicha-gold);
  --label-gray: var(--stone-125);
  --hl-gray: var(--stone-125);

  /* Calendar entries: an all-day event is the selected wash a step
     deeper, ruled in the green let into the line; a task is a hollow,
     the page's colour; a dot is the green */
  --calendar-chip: var(--stone-125);
  --calendar-allday: color-mix(in srgb, var(--genmaicha-green) 20%, var(--stone-50));
  --calendar-task: var(--stone-125);
  --calendar-task-icon: var(--genmaicha-muted);
  --calendar-chip-border: color-mix(in srgb, var(--genmaicha-green) 30%, var(--genmaicha-line));
  --calendar-dot: var(--genmaicha-green);
  --calendar-today: color-mix(in srgb, var(--genmaicha-gold) 12%, var(--stone-50));
}

/* Genmaicha — the warm paper, the warm ink and the green */
[data-theme="genmaicha"] {
  /* Delete's words and line: a brick red as strong as the green, ink on
     paper rather than the warning red's screen red */
  --genmaicha-delete: oklch(0.5 0.1 30);

  /* A pending all-day event due by the day after tomorrow, or past, in
     the highlight yellow (.fc-event-soon, calendar.css), and today in its
     paler step; the rest keep the green's */
  --calendar-allday-soon: var(--yellow-100);
  --calendar-today: var(--yellow-50);

  /* The ladder — Paper's, with the ink steps Booklist's warm ink */
  /* The card is a step lighter than Paper's (and Booklist's), so the tab,
     the cards and the fields hollowed in them stand clear of the page */
  --stone-25: var(--genmaicha-card);
  --stone-50: var(--genmaicha-card);
  --stone-75: var(--paper-75);
  --stone-100: var(--paper-100);
  --stone-125: var(--paper-125);
  --stone-150: var(--paper-150);
  --stone-175: var(--paper-175);
  --stone-200: var(--paper-200);
  --stone-215: var(--paper-215);
  --stone-225: var(--paper-225);
  --stone-250: var(--paper-250);
  --stone-300: var(--paper-300);
  --stone-350: var(--paper-350);
  --stone-375: var(--paper-375);
  --stone-400: var(--genmaicha-muted-light);
  --stone-500: var(--genmaicha-muted);
  --stone-600: var(--genmaicha-ink);
  --stone-700: var(--genmaicha-ink-strong);
  --stone-800: var(--genmaicha-ink-strong);

  /* The green — the lime steps Matcha uses at strength. --link, its
     hover, --success, --true and the status-green ink follow from :root. */
  --lime-600: var(--genmaicha-green-ink);
  --lime-700: var(--genmaicha-green-mid);
  --lime-750: var(--genmaicha-green);
  --lime-800: var(--genmaicha-green-ink);

  /* The strong violets are the green too: the filter and sort icons, the
     switches and tick boxes, the priority flags, the AI marks */
  --violet-400: var(--genmaicha-green-light);
  --violet-500: var(--genmaicha-green-mid);
  --violet-600: var(--genmaicha-green);
  --violet-700: var(--genmaicha-green);
  --violet-800: var(--genmaicha-green-ink);

  /* The tints — Paper's, under the same ground */
  --blue-50: var(--paper-blue-wash);
  --blue-100: var(--paper-blue-tint);
  --slate-50: var(--paper-slate-wash);
  --slate-100: var(--paper-slate-tint);
  --lime-50: var(--paper-lime-wash);
  --lime-100: var(--paper-lime-tint);
  --orange-50: var(--paper-orange-wash);
  --orange-100: var(--paper-orange-tint);
  --red-50: var(--paper-red-wash);
  --red-100: var(--paper-red-tint);
  --yellow-50: var(--paper-yellow-wash);
  --yellow-100: var(--paper-yellow-tint);
  --amber-50: var(--paper-amber-wash);
  --amber-100: var(--paper-amber-tint);
  --violet-50: var(--paper-violet-wash);
  --violet-75: var(--paper-violet-wash);
  --violet-100: var(--paper-violet-tint);
  --violet-150: var(--paper-violet-deep);

  /* A badge is filled with the wash a total row has (genmaicha.css), a
     paper-quiet one: the green (Paid) off the theme's green, not the
     lime's tint */
  --label-green: color-mix(in srgb, var(--genmaicha-green) 12%, var(--background-td));
  /* and the other badges the same wash, each off its own hue */
  --label-blue: color-mix(in srgb, var(--blue-600) 12%, var(--background-td));
  --label-orange: color-mix(in srgb, var(--orange-600) 12%, var(--background-td));
  --label-purple: color-mix(in srgb, var(--purple-600) 12%, var(--background-td));
  --label-red: color-mix(in srgb, var(--red-600) 12%, var(--background-td));
  --label-yellow: color-mix(in srgb, var(--yellow-600) 12%, var(--background-td));

  /* What is chosen is the green, as everything else is */
  --genmaicha-mark: var(--genmaicha-green);
  --genmaicha-mark-ink: var(--genmaicha-green-ink);

  /* A name in a table is a link, in the green; what is chosen keeps its
     fill */
  --genmaicha-name: var(--link);
  --genmaicha-name-hover: var(--link-hover);

  /* A task on the board is raised as a table is, on the page-coloured
     lane (.kanban-card, apps/tasks.css) */
  --kanban-card: var(--genmaicha-card);
  /* An overdue card is told by its date, not a fill */
  --kanban-past-due: var(--kanban-card);

  /* The brand: the green into the gold, tea and toasted rice */
  --brand-grad-to: var(--genmaicha-gold);
}

/* Mizan — professional legal minimal theme anchored on #8A181A burgundy.
   Architectural alabaster ground, crisp white cards and tables, deep charcoal
   ink, and one disciplined burgundy identity across interactive elements,
   navigation selection, primary buttons, and brand accents. */
[data-theme="mizan"] {
  /* Architectural neutral ladder */
  --stone-25: var(--mizan-light-surface);
  --stone-50: var(--mizan-light-surface);
  --stone-75: var(--mizan-light-surface);
  --stone-100: var(--mizan-light-page);
  --stone-125: var(--mizan-light-page);
  --stone-150: var(--mizan-light-subtle);
  --stone-175: var(--mizan-light-subtle);
  --stone-200: var(--mizan-light-subtle);
  --stone-215: var(--mizan-light-line);
  --stone-225: var(--mizan-light-line);
  --stone-250: var(--mizan-light-line);
  --stone-300: var(--mizan-light-line);
  --stone-350: var(--mizan-light-line-strong);
  --stone-375: var(--mizan-light-line-strong);
  --stone-400: var(--mizan-light-muted-light);
  --stone-500: var(--mizan-light-muted);
  --stone-600: var(--mizan-light-ink);
  --stone-700: var(--mizan-light-ink-strong);
  --stone-800: var(--mizan-light-ink-strong);

  /* Genmaicha look slots mapped to Mizan's alabaster + burgundy tokens */
  --genmaicha-card: var(--mizan-light-surface);
  --genmaicha-page: var(--mizan-light-page);
  --genmaicha-ink: var(--mizan-light-ink);
  --genmaicha-ink-strong: var(--mizan-light-ink-strong);
  --genmaicha-muted: var(--mizan-light-muted);
  --genmaicha-muted-light: var(--mizan-light-muted-light);
  --genmaicha-line: var(--mizan-light-line);
  --genmaicha-line-soft: color-mix(in oklch, var(--mizan-light-line) 55%, var(--mizan-light-surface));
  --genmaicha-line-strong: var(--mizan-light-line-strong);
  --genmaicha-green: var(--mizan-brand);
  --genmaicha-green-ink: var(--mizan-brand-ink);
  --genmaicha-green-mid: var(--mizan-brand-hover);
  --genmaicha-green-light: var(--mizan-brand-mid);
  --genmaicha-on-green: var(--mizan-light-surface);
  --genmaicha-mark: var(--mizan-brand);
  --genmaicha-mark-ink: var(--mizan-brand-ink);
  --genmaicha-gold: var(--mizan-light-amber);
  --genmaicha-red: var(--mizan-light-danger);
  --genmaicha-delete: var(--mizan-light-danger);

  /* Typography & links: burgundy as sole interactive anchor */
  --color-primary: var(--mizan-light-ink);
  --color-darker: var(--mizan-light-ink-strong);
  --color-muted: var(--mizan-light-muted);
  --color-muted-more: var(--mizan-light-muted-light);
  --link: var(--mizan-brand);
  --link-hover: var(--mizan-brand-hover);
  --accent-link: var(--mizan-brand);
  --focus-ring: var(--mizan-brand);
  --field-focus: var(--mizan-brand);
  --add: var(--mizan-brand);
  --brand-ink: var(--mizan-brand);
  --brand-grad-from: var(--mizan-brand);
  --brand-grad-to: var(--mizan-brand-ink);
  --genmaicha-name: var(--mizan-light-ink-strong);
  --genmaicha-name-hover: var(--mizan-brand);

  /* Accent icons, filters, switches, ticks stay in burgundy */
  --violet-400: var(--mizan-brand-soft);
  --violet-500: var(--mizan-brand-mid);
  --violet-600: var(--mizan-brand);
  --violet-700: var(--mizan-brand);
  --violet-800: var(--mizan-brand-ink);
  --icon-violet: var(--mizan-brand);
  --icon-violet-muted: var(--mizan-brand-soft);

  /* Subtle burgundy hover & selection washes */
  --genmaicha-hover: color-mix(in oklch, var(--mizan-brand) 6%, var(--mizan-light-surface));
  --genmaicha-selected: color-mix(in oklch, var(--mizan-brand) 9%, var(--mizan-light-surface));
  --selected-background: var(--genmaicha-selected);
  --selected-border: color-mix(in oklch, var(--mizan-brand) 34%, var(--mizan-light-line));
  --selected-color: var(--mizan-brand-ink);
  --genmaicha-on: var(--mizan-brand);
  --genmaicha-on-line: var(--mizan-brand);
  --genmaicha-on-ink: var(--mizan-light-surface);
  --genmaicha-chip: color-mix(in oklch, var(--mizan-brand) 12%, var(--mizan-light-surface));
  --genmaicha-chip-line: color-mix(in oklch, var(--mizan-brand) 42%, var(--mizan-light-line));

  /* Buttons */
  --button-primary-background: var(--mizan-brand);
  --button-primary-color: var(--mizan-light-surface);
  --btn-success-bg: var(--mizan-brand);
  --btn-secondary-bg: var(--mizan-light-surface);
  --btn-danger-bg: var(--mizan-light-surface);

  /* Surfaces */
  --background-body: var(--mizan-light-page);
  --background-nav: var(--mizan-light-surface);
  --background-subnav: var(--mizan-light-page);
  --background-control: var(--mizan-light-surface);
  --background-section: var(--mizan-light-surface);
  --background-th: var(--mizan-light-surface);
  --background-td: var(--mizan-light-surface);
  --background-medium-light: var(--mizan-light-surface);
  --background-light: var(--mizan-light-surface);
  --background-sidebar: var(--mizan-light-surface);
  --background-sidebar-hover: var(--genmaicha-hover);
  --background-sidebar-active: var(--genmaicha-selected);
  --ai-frame: var(--mizan-light-subtle);
  --ai-surface: var(--mizan-light-surface);
  --ai-raised: var(--mizan-light-page);

  /* Quiet semantic statuses — never competing with burgundy brand */
  --success: var(--mizan-light-green);
  --true: var(--mizan-light-green);
  --status-green-bg: var(--mizan-light-green-wash);
  --status-green-ink: var(--mizan-light-green);
  --status-green-line: color-mix(in oklch, var(--mizan-light-green) 35%, var(--mizan-light-line));
  --status-green-hover: color-mix(in oklch, var(--mizan-light-green) 14%, var(--mizan-light-surface));
  --label-green: color-mix(in oklch, var(--mizan-light-green) 11%, var(--mizan-light-surface));
  --label-blue: color-mix(in oklch, var(--blue-600) 10%, var(--mizan-light-surface));
  --label-orange: color-mix(in oklch, var(--orange-600) 11%, var(--mizan-light-surface));
  --label-purple: color-mix(in oklch, var(--mizan-brand) 10%, var(--mizan-light-surface));
  --label-red: color-mix(in oklch, var(--mizan-light-danger) 11%, var(--mizan-light-surface));
  --label-yellow: color-mix(in oklch, var(--mizan-light-amber) 14%, var(--mizan-light-surface));

  /* Calendar & Kanban */
  --calendar-allday: color-mix(in oklch, var(--mizan-brand) 12%, var(--mizan-light-surface));
  --calendar-allday-soon: var(--yellow-100);
  --calendar-chip-border: color-mix(in oklch, var(--mizan-brand) 28%, var(--mizan-light-line));
  --calendar-dot: var(--mizan-brand);
  --calendar-allday-dot: var(--mizan-brand);
  --calendar-today: color-mix(in oklch, var(--mizan-brand) 7%, var(--mizan-light-surface));
  --kanban-card: var(--mizan-light-surface);
  --kanban-past-due: var(--kanban-card);
}

/* Matcha — the look in true grays, in the original Matcha's two colours:
   the lime is what acts (links, the names in tables, the finishing
   button), the violet what is chosen (the selected wash, a switch that is
   on, the sorted column, ticked boxes) and the accent icons. The ladder,
   the ramps and the brand are :root's; only the sources move. */
[data-theme="matcha"] {
  --genmaicha-card: var(--stone-50);
  --genmaicha-ink: var(--stone-600);
  --genmaicha-ink-strong: var(--stone-700);
  --genmaicha-muted: var(--stone-500);
  --genmaicha-muted-light: var(--stone-400);
  --genmaicha-line: var(--stone-375);
  --genmaicha-green: var(--lime-750);
  --genmaicha-green-ink: var(--lime-800);
  --genmaicha-green-mid: var(--lime-700);
  --genmaicha-green-light: var(--lime-600);
  --genmaicha-mark: var(--violet-600);
  --genmaicha-mark-ink: var(--violet-700);
  --genmaicha-gold: var(--amber-500);
  --genmaicha-red: var(--red-700);

  /* The top bar: with the open page a pill rather than a tab, the bar
     need not be the card the tab was cut from; a shade under the page */
  --background-sidebar: var(--stone-175);

  /* Its gray is lighter against its ink than Genmaicha's is: a table's
     heads and a form's labels are drawn nearer the ink, where Genmaicha's
     sit */
  --genmaicha-head: color-mix(in oklch, var(--genmaicha-ink) 55%, var(--genmaicha-muted));

  /* A name in a table is a link, in the lime, as the original's were */
  --genmaicha-name: var(--link);
  --genmaicha-name-hover: var(--link-hover);

  /* Under the pointer, a breath of the link lime (the original's row
     hover), mixed in oklch: in srgb, as the look mixes, it greys out to
     olive on the white */
  --genmaicha-hover: color-mix(in oklch, var(--link) 7%, var(--stone-50));
  /* What is chosen is the original's lavender, ruled in the violet let
     into the line */
  --genmaicha-selected: var(--violet-150);
  --selected-border: color-mix(in oklch, var(--violet-500) 45%, var(--genmaicha-line));
  /* A switch that is on is the chosen lavender inside its violet line,
     in the ink, rather than the look's inverted ink */
  --genmaicha-on: var(--violet-150);
  --genmaicha-on-line: color-mix(in oklch, var(--violet-500) 45%, var(--genmaicha-line));
  --genmaicha-on-ink: var(--stone-700);
  /* Today on the calendar: the violet on the lavender, in its ring, as
     the original circled it */
  --genmaicha-today: var(--violet-150);
  --genmaicha-today-ink: var(--icon-violet);
  /* The sorted column's chip: the lavender in the violet's line */
  --genmaicha-chip: var(--violet-150);
  --genmaicha-chip-line: var(--genmaicha-on-line);
  /* An all-day event in the grey, a pending one due by the day after
     tomorrow, or past, in a pale butter (.fc-event-soon, calendar.css),
     ruled in the stone a step darker */
  --calendar-allday: var(--stone-150);
  --calendar-allday-soon: oklch(0.965 0.03 98);
  /* a holiday: the pale lime */
  --calendar-holiday: var(--lime-100);
  --calendar-chip-border: var(--stone-350);
}

/* Nord Light — the look on the snow: the card is the brightest snow, the
   page the step below it, the line a dimmed snow; the deep frost blue
   acts and the frost cyan is chosen. The stone steps the look reads
   (the card, the page, the chosen ink) are repointed onto the snow, so
   whatever else reaches them is snow too. */
[data-theme="nord-light"] {
  --stone-25: var(--nord-snow-bright);
  --stone-50: var(--nord-snow-bright);
  --stone-125: var(--nord5);
  --stone-700: var(--nord1);

  --genmaicha-card: var(--nord-snow-bright);
  --genmaicha-ink: var(--nord2);
  --genmaicha-ink-strong: var(--nord0);
  --genmaicha-muted: var(--nord3-bright);
  --genmaicha-muted-light: var(--nord-gray);
  --genmaicha-line: var(--nord4-mid);
  --genmaicha-green: var(--nord10);
  --genmaicha-green-ink: var(--nord10-deep);
  --genmaicha-green-mid: var(--nord9);
  --genmaicha-green-light: var(--nord9);
  --genmaicha-mark: var(--nord8-ink);
  --genmaicha-mark-ink: var(--nord8-ink);
  --genmaicha-gold: var(--nord13-ink);
  --genmaicha-red: var(--nord11-ink);

  /* The washes from the frost cyan itself, mixed in oklch so they stay
     frost rather than grey */
  --genmaicha-hover: color-mix(in oklch, var(--nord8) 16%, var(--nord-snow-bright));
  --genmaicha-selected: color-mix(in oklch, var(--nord8) 30%, var(--nord-snow-bright));
  --genmaicha-chip: var(--genmaicha-selected);

  /* Nord Light's own block grounds the page on nord6, a step lighter than
     the look's page; the bars and the open tab are the page, so the page
     is too */
  --background-body: var(--genmaicha-page);
}

/* Under the dawn (Cosmic's light side with the sky on, data-sky="dawn",
   cosmic-dawn.css): as under the night sky, the page is its ground let
   through, once (--dawn-wash, drawn over the sky's gradient), and what lies on the page (the bars, the
   tab rows, the open tabs) is clear, so the sky reads as a pale frost
   wash behind them. The vertical sidebar is a little more solid. Tables,
   cards, fields and dialogs stay solid snow. */
[data-theme="nord-light"][data-sky="dawn"] {
  --dawn-wash: color-mix(in oklch, var(--genmaicha-page) 58%, transparent);
  --background-subnav: transparent;
  --background-sidebar: color-mix(in oklch, var(--genmaicha-page) 80%, transparent);
  --genmaicha-tab: transparent;
  /* The cards and tables: snow, a little let through (cosmic-dawn.css),
     their cells clear so a table is one pane. Opaque enough that the ink
     keeps its contrast; the sky only tints them. */
  --dawn-glass: color-mix(in oklch, var(--nord-snow-bright) 80%, transparent);
  --background-td: transparent;
  --background-th: transparent;
  /* The tab rows' rules with a little of the frost blue in them, so the
     open tab's outline holds against the pale sky */
  --genmaicha-tab-line: color-mix(in oklch, var(--nord10) 35%, var(--nord4-mid));
}

/* ==========================================================================
   Dark theme — Gruvbox, a Hojicha-inspired warm palette
   Deepest base is neutral; surface lifts, text, and borders carry warmth
   (low-chroma tan/brown hues, 48–82°). Accent green shifts from cool lime
   to a softer yellow-green (~138°) for the Gruvbox-aqua feel.
   The bootstrap script in base.html resolves "auto" to either "light" or
   "dark" before paint, so CSS only handles the two concrete states.
   ========================================================================== */
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"]) {
  /* Native form controls (radios, checkboxes) + scrollbars render dark */
  color-scheme: dark;

  /* Warm grays — neutral deep base, warming as it lifts */
  --gb-dark:      oklch(0.277 0     263);
  --gb-dark-soft: oklch(0.311 0.003  48);
  --gb-dark1:     oklch(0.344 0.007  48);
  --gb-dark2:     oklch(0.411 0.011  52);
  --gb-dark3:     oklch(0.482 0.018  61);
  --gb-dark4:     oklch(0.551 0.023  63);

  /* Warm creams for text */
  --gb-light:  oklch(0.956 0.055 96);
  --gb-light3: oklch(0.756 0.041 82);
  --gb-light4: oklch(0.690 0.035 76);
  --gb-gray:   oklch(0.619 0.029 67);

  /* Yellow-green accents (Gruvbox aqua family) */
  --gb-bright-aqua: oklch(0.756 0.108 138);
  --gb-aqua:        oklch(0.645 0.094 145);
  --gb-faded-aqua:  oklch(0.534 0.082 155);

  /* Status accents */
  --gb-bright-red:    oklch(0.660 0.217  30);
  --gb-bright-orange: oklch(0.731 0.182  52);
  --gb-bright-green:  oklch(0.765 0.158 111);
  --gb-bright-purple: oklch(0.705 0.098   2);
  --gb-bright-yellow: oklch(0.832 0.159  83);

  /* Typography & Text */
  --color-primary: var(--gb-light4);
  --color-darker: var(--gb-light);
  --color-muted: var(--gb-gray);
  --color-muted-more: var(--gb-dark4);
  --color-lighter: var(--gb-light);

  /* Links */
  --link: var(--gb-bright-aqua);
  --link-hover: var(--gb-aqua);
  /* Brand gradient — the link accent into the ramp's yellow; cosmic and
     everforest follow by repointing --gb-bright-yellow */
  --brand-grad-to: var(--gb-bright-yellow);

  /* Backgrounds */
  --background-nav: var(--gb-dark-soft);
  --background-body: var(--gb-dark);
  --background-subnav: var(--gb-dark1);
  --background-subnav-contrast: var(--gb-dark2);
  --background-control: var(--gb-dark1);
  --background-section: var(--gb-dark1);
  --background-td: var(--gb-dark);
  --background-medium-light: var(--gb-dark-soft);
  --background-light: var(--gb-dark-soft);
  /* AI chat surface ramp — frame darkest, panels lift above it. */
  --ai-frame: var(--gb-dark);
  --ai-surface: var(--gb-dark-soft);
  --ai-raised: var(--gb-dark1);
  /* Dark mode signals task state with a left accent rail, not a row fill: a small
     saturated bar carries the hue without touching the elevation ladder or cell grid.
     Fills are neutralised to the normal cell background; the rail tokens do the work. */
  --past-due-bg: var(--background-td);
  /* In the darks the soon date is drawn, not filled */
  --due-overdue: var(--red-400);
  --due-soon-bg: transparent;
  --due-soon-line: var(--yellow-400);
  --due-soon-ink: var(--yellow-400);
  --task-highlight-bg: var(--background-td);
  --past-due-rail: oklch(0.60 0.17 358);        /* rose-pink — persistent "past due" */
  --task-highlight-rail: oklch(0.64 0.19 293);  /* violet — transient "recently changed" */

  /* Warning toast keeps the neutral surfaces and the orange rail in dark, where
     the rail already reads well. */
  --toast-warning-header-bg: var(--background-section);
  --toast-warning-body-bg: var(--background-light);
  --toast-warning-rail: 4px solid var(--warning);

  /* Navigation */
  --background-nav-tab-active: var(--background-body);
  --background-subnav-tab-active: var(--gb-dark2);  /* modest one-step lift above the surface */

  /* Sidebar */
  --background-sidebar: var(--gb-dark1);
  --background-sidebar-hover: var(--gb-dark2);
  --background-sidebar-active: var(--gb-dark2);  /* match the hover fill; border + text mark "active" */

  /* Buttons */
  --button-primary-background: var(--gb-faded-aqua);
  --button-primary-color: var(--gb-light);
  --button-secondary-background: var(--background-section);
  --button-secondary-color: var(--gb-light4);
  --button-toolbar: var(--gb-light3);
  --btn-secondary-bg: var(--gb-dark2);
  --btn-success-bg: oklch(0.405 0.096 138);
  --btn-danger-bg: var(--red-900);

  /* Forms & Inputs — inset well effect (input bg distinct from container) */
  --input-border: var(--gb-dark4);
  --input-background: var(--gb-dark-soft);
  --input-placeholder: var(--gb-dark4);

  /* Borders & Dividers */
  --border-light: var(--gb-dark1);
  --border-medium: var(--gb-dark2);
  --border-medium-dark: var(--gb-dark3);
  --border-dark: var(--gb-dark4);

  /* Selection & Active States */
  --selected-background: var(--background-control);
  --selected-color: var(--gb-bright-purple);
  /* A tooltip: a step lifted off the dark ground, in the light ink; the
     ramp is repointed by Cosmic, the night sky and Prism's dark, so it
     follows each */
  --tooltip-background: var(--gb-dark3);
  --tooltip-color: var(--gb-light);
  --selected-border: var(--gb-dark3);

  /* Status & Feedback */
  --urgent: var(--gb-bright-orange);
  --warning: var(--gb-bright-orange);
  --success: var(--gb-bright-green);
  --true: var(--gb-bright-green);
  --false: var(--urgent);
  --error: var(--urgent);
  --error-background: var(--red-950);
  --error-border: var(--urgent);

  /* Labels & Badges (mid-dark tints, readable under cream text) — still used as
     fills for text highlights in the case viewer (ai.css / highlights.css). */
  --label-gray: var(--gb-dark1);
  --label-green: var(--lime-950);
  --label-orange: var(--orange-950);
  --label-purple: var(--violet-900);
  --label-red: var(--red-950);
  --label-yellow: var(--yellow-950);
  /* Outline pill line colours — for badge/label chips the hue lives in the
     border + text instead of a fill (see badges.css). */
  --label-blue-line: var(--blue-400);
  --label-gray-line: var(--color-darker);
  --label-green-line: var(--green-400);
  --label-lime-line: var(--lime-400);
  --label-orange-line: var(--orange-400);
  --label-purple-line: var(--violet-400);
  --label-red-line: var(--red-400);
  --label-yellow-line: var(--yellow-400);

  /* Icons */
  --icon-default: var(--color-primary);
  --icon-muted: var(--color-muted);
  --accent-link: var(--link);
  --icon-violet: var(--gb-bright-purple);
  --icon-violet-muted: var(--violet-400);
  --icon-yellow: var(--gb-bright-orange);
  --add: var(--link);

  /* Row Highlights (dark tints) */
  --hl-gray: var(--gb-dark2);
  --hl-blue: var(--blue-950);
  --hl-slate: var(--gb-dark1);
  --hl-green: var(--lime-950);
  --hl-orange: var(--orange-950);
  --hl-violet: var(--violet-950);
  --hl-red: var(--red-950);
  --hl-yellow: oklch(0.31 0.075 92);  /* true-yellow hue so it reads mustard, not the red-brown of yellow-950 */

  /* Calendar entries, in the gruvbox grays themselves (cosmic, kosmic and
     everforest repoint the ramp). An all-day event is a step up from the
     chip, a task the chip itself, each ruled in the gray above; the dot
     is a mid gray; a holiday takes the all-day ground halfway to blue. */
  --calendar-chip: var(--gb-dark2);
  --calendar-allday: var(--gb-dark3);
  --calendar-allday-color: var(--color-primary);
  --calendar-task: var(--gb-dark2);
  --calendar-task-color: var(--color-primary);
  --calendar-task-icon: var(--color-primary);
  --calendar-chip-border: var(--gb-dark4);
  --calendar-dot: var(--gb-dark4);
  --calendar-allday-dot: var(--gb-dark4);
  --calendar-holiday: color-mix(in oklab, var(--gb-dark3) 55%, var(--blue-600));
  --calendar-holiday-color: var(--color-primary);
  --calendar-today: var(--hl-yellow);
}

/* ==========================================================================
   Cosmic — the dark theme, on the Nord palette.

   Cosmic IS the dark theme structurally: it shares the entire token mapping
   above and every co-located `:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"])`
   rule. The ONLY thing it changes is the underlying ramp — the --gb-* tokens
   are repointed from Gruvbox to Nord. Because the semantic tokens above resolve
   var(--gb-*) per element, swapping the ramp re-skins the whole UI to Nord.
   (The --gb-* names are kept, not renamed, so the shared structural rules that
   reference them directly — buttons, flatpickr, calendar — still resolve here.)
   ========================================================================== */
:is([data-theme="cosmic"], [data-theme="kosmic"]) {
  /* Polar Night — deep base, lifting */
  --gb-dark:      var(--nord0);
  --gb-dark-soft: var(--nord0-soft);
  --gb-dark1:     var(--nord1);
  --gb-dark2:     var(--nord2);
  --gb-dark3:     var(--nord3);
  --gb-dark4:     var(--nord3-bright);

  /* Snow Storm — text */
  --gb-light:  var(--nord6);
  --gb-light3: var(--nord4);
  --gb-light4: var(--nord4-dim);
  --gb-gray:   var(--nord-gray);

  /* Frost — accent family (was the Gruvbox aqua family) */
  --gb-bright-aqua: var(--nord8);
  --gb-aqua:        var(--nord9);
  --gb-faded-aqua:  var(--nord10);

  /* Aurora — status accents */
  --gb-bright-red:    var(--nord11);
  --gb-bright-orange: var(--nord12);
  --gb-bright-green:  var(--nord14);
  --gb-bright-purple: var(--nord15);
  --gb-bright-yellow: var(--nord13);

  /* Add stays green (the dark block points it at --link, frost cyan here) */
  --add: var(--gb-bright-green);
}

/* ==========================================================================
   Kosmic — Nord under the landing page's night sky.

   Kosmic is cosmic exactly (it shares the Nord ramp block above and every
   dark rule) with one change: the page ground is the animated sky from
   kosmos.law (kosmic.css + components/kosmic-sky.html), and the surfaces
   that sit flat on it let it through. The ground surfaces (page, tables,
   cards, sidebar) are Polar Night made translucent; table cells go clear so
   a table doesn't stack two washes. Raised surfaces (sections, controls,
   modals, menus) stay opaque, so anything floating over the page is solid.
   ========================================================================== */
[data-theme="kosmic"] {
  --background-body: color-mix(in oklch, var(--nord0) 64%, transparent);
  --background-td: transparent;
  --background-sidebar: color-mix(in oklch, var(--nord1) 85%, transparent);
}

/* ==========================================================================
   Mizan Dark — obsidian charcoal surfaces with burgundy as the sole brand
   anchor (authentic deep burgundy for filled actions, luminous rose-burgundy
   for accessible text links, focus rings, and selections).
   ========================================================================== */
[data-theme="mizan-dark"] {
  --gb-dark:      var(--mizan-dark-page);
  --gb-dark-soft: var(--mizan-dark-sunken);
  --gb-dark1:     var(--mizan-dark-card);
  --gb-dark2:     var(--mizan-dark-elevated);
  --gb-dark3:     var(--mizan-dark-line);
  --gb-dark4:     var(--mizan-dark-line-strong);

  --gb-light:  var(--mizan-dark-ink-strong);
  --gb-light3: var(--mizan-dark-ink);
  --gb-light4: var(--mizan-dark-muted);
  --gb-gray:   var(--mizan-dark-muted-light);

  --gb-bright-aqua: var(--mizan-dark-brand-ink);
  --gb-aqua:        var(--mizan-dark-brand-ink-hover);
  --gb-faded-aqua:  var(--mizan-dark-brand-fill);

  --gb-bright-red:    var(--mizan-dark-danger);
  --gb-bright-orange: var(--mizan-dark-amber);
  --gb-bright-green:  var(--mizan-dark-green);
  --gb-bright-purple: var(--mizan-dark-brand-ink);
  --gb-bright-yellow: var(--mizan-dark-amber);

  --background-medium-light: var(--mizan-dark-card);
  --background-light: var(--mizan-dark-card);

  --link: var(--mizan-dark-brand-ink);
  --link-hover: var(--mizan-dark-brand-ink-hover);
  --accent-link: var(--mizan-dark-brand-ink);
  --focus-ring: var(--mizan-dark-brand-ink);
  --field-focus: var(--mizan-dark-brand-ink);
  --add: var(--mizan-dark-brand-ink);
  --brand-ink: var(--mizan-dark-brand-ink);
  --brand-grad-from: var(--mizan-dark-brand-ink);
  --brand-grad-to: var(--mizan-dark-brand-fill-hover);

  --success: var(--mizan-dark-green);
  --true: var(--mizan-dark-green);
  --status-green-bg: var(--mizan-dark-green-wash);
  --status-green-ink: var(--mizan-dark-green);
  --status-green-line: var(--mizan-dark-green);
  --status-green-hover: var(--mizan-dark-green-wash);
  --label-green-line: var(--mizan-dark-green);
}

/* ==========================================================================
   Genmaicha's dark side — Booklist's dark, which is Gruvbox. It is the
   Gruvbox theme (data-theme="dark") marked data-look="genmaicha", so it
   takes every dark rule there is and this block only says where it
   differs: the two grounds are Gruvbox's dark and the step above it, one
   line rules everything, the ink is Gruvbox's light sand, and the bright
   aqua does all the accent's work, as the green does by day. The look's
   own names (--genmaicha-*) are reset to their dark values first, so
   genmaicha.css draws the same rules in them.

   Cosmic's dark side wears it too, with or without the night sky
   (cosmic, kosmic): those repoint the --gb-* ramp onto Polar Night, Snow
   Storm and Frost, so this block draws the look in Nord, and the blocks
   after it give the two values that are not ramp steps (the ink, the
   tick) and let the sky through.
   ========================================================================== */
:is([data-theme="dark"], [data-theme="cosmic"], [data-theme="kosmic"], [data-theme="mizan-dark"])[data-look="genmaicha"] {
  --genmaicha-page: var(--gb-dark);
  --genmaicha-card: var(--gb-dark1);
  --genmaicha-ink: oklch(0.829 0.052 89.8);          /* gb light1, 88% on the page */
  --genmaicha-ink-strong: oklch(0.894 0.057 89.2);   /* gb light1 */
  --genmaicha-muted: var(--gb-light4);
  --genmaicha-muted-light: var(--gb-gray);
  --genmaicha-line: var(--gb-dark2);
  --genmaicha-green: var(--gb-bright-aqua);
  --genmaicha-green-ink: var(--gb-bright-aqua);
  --genmaicha-green-mid: var(--gb-aqua);
  --genmaicha-green-light: var(--gb-aqua);
  --genmaicha-mark: var(--gb-bright-aqua);
  --genmaicha-mark-ink: var(--gb-bright-aqua);
  --genmaicha-gold: var(--gb-bright-yellow);
  --genmaicha-red: var(--gb-bright-red);
  /* A name in a table is a link, in the aqua, as on the light side */
  --genmaicha-name: var(--link);
  --genmaicha-name-hover: var(--link-hover);
  --genmaicha-on-green: var(--gb-dark);
  --genmaicha-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23282828' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --genmaicha-line-soft: color-mix(in srgb, var(--genmaicha-line) 55%, var(--genmaicha-card));
  --genmaicha-line-strong: var(--gb-dark3);
  --genmaicha-hover: color-mix(in srgb, var(--genmaicha-mark) 7%, var(--genmaicha-card));
  --genmaicha-selected: color-mix(in srgb, var(--genmaicha-mark) 14%, var(--genmaicha-card));

  /* The strong violets are the aqua, as they are the green by day */
  --violet-400: var(--gb-bright-aqua);
  --violet-500: var(--gb-bright-aqua);
  --violet-600: var(--gb-aqua);
  --violet-700: var(--gb-aqua);
  --violet-800: var(--gb-faded-aqua);

  --radius-sm: 0.5rem;
  --radius-md: 0.5rem;

  /* Type */
  --color-primary: var(--genmaicha-ink);
  --color-darker: var(--genmaicha-ink-strong);
  --color-muted: var(--genmaicha-muted);

  /* Grounds */
  --background-body: var(--genmaicha-page);
  --background-nav: var(--genmaicha-card);
  --background-subnav: var(--genmaicha-page);
  --background-subnav-contrast: var(--genmaicha-hover);
  --background-control: var(--genmaicha-card);
  --background-section: var(--genmaicha-card);
  --background-td: var(--genmaicha-card);
  --background-sidebar: var(--genmaicha-card);
  --background-sidebar-hover: var(--genmaicha-hover);
  --background-sidebar-active: var(--genmaicha-selected);
  --background-subnav-tab-active: var(--genmaicha-page);

  /* Rules */
  --border-light: var(--genmaicha-line-soft);
  --border-medium: var(--genmaicha-line-soft);
  --border-medium-dark: var(--genmaicha-line);
  --border-dark: var(--genmaicha-line-strong);
  --button-border: var(--genmaicha-line);
  --input-border: var(--genmaicha-line);
  --input-background: var(--genmaicha-card);

  /* Buttons */
  --button-primary-background: var(--genmaicha-green);
  --button-primary-color: var(--genmaicha-on-green);
  --button-secondary-color: var(--genmaicha-ink);
  --btn-secondary-bg: var(--genmaicha-card);
  --btn-success-bg: var(--genmaicha-green);
  --btn-danger-bg: var(--genmaicha-card);

  /* Selection */
  --selected-background: var(--genmaicha-selected);
  --selected-border: color-mix(in srgb, var(--genmaicha-green) 40%, var(--genmaicha-line));
  --selected-color: var(--genmaicha-ink-strong);

  /* Status */
  --urgent: var(--genmaicha-red);
  --warning: var(--genmaicha-red);
  --icon-violet: var(--genmaicha-green);
  --icon-violet-muted: var(--gb-aqua);
  --icon-yellow: var(--genmaicha-gold);
  --label-gray: var(--genmaicha-page);
  --hl-gray: var(--genmaicha-page);

  /* Calendar entries, as by day */
  --calendar-chip: var(--genmaicha-page);
  --calendar-allday: color-mix(in srgb, var(--genmaicha-green) 20%, var(--genmaicha-card));
  --calendar-task: var(--genmaicha-page);
  --calendar-task-icon: var(--genmaicha-muted);
  --calendar-chip-border: color-mix(in srgb, var(--genmaicha-green) 30%, var(--genmaicha-line));
  --calendar-dot: var(--genmaicha-green);
  --calendar-allday-dot: var(--genmaicha-green);
  --calendar-today: color-mix(in srgb, var(--genmaicha-gold) 12%, var(--genmaicha-card));

  /* The chips are not filled: a colour is a signal on a rail at the
     chip's left (calendar.css): the green for an all-day event, the
     yellow of the dashboard's soon for a pending one due by the day after
     tomorrow or past, a blue for a holiday */
  --calendar-allday: transparent;
  --calendar-allday-soon: transparent;
  --calendar-holiday: transparent;
  --calendar-chip-line: var(--genmaicha-line-strong);
  --calendar-allday-rail: var(--genmaicha-green);
  --calendar-allday-soon-rail: var(--yellow-400);
  --calendar-holiday-rail: oklch(from var(--genmaicha-green) l c 250);
}

/* Genmaicha's dark alone (Cosmic's is drawn in its pink, below): what is
   open, chosen or on is drawn in the line and the letter, not a wash,
   both in the cream of the ink, the dark side's counterpart of the light
   side's filled ink; the aqua stays with what acts */
[data-theme="dark"][data-look="genmaicha"] {
  --genmaicha-on-line: color-mix(in oklch, var(--genmaicha-ink-strong) 70%, var(--genmaicha-line));
  --genmaicha-chip-line: var(--genmaicha-on-line);
  --genmaicha-on-ink: var(--genmaicha-ink-strong);
  --selected-color: var(--genmaicha-ink-strong);
  --selected-border: var(--genmaicha-on-line);
  --genmaicha-on: transparent;
  --genmaicha-selected: transparent;
  --genmaicha-chip: transparent;
  --selected-background: transparent;
  --kanban-past-due: var(--kanban-card, var(--background-body));
  /* A green badge (Paid) is outlined in the green the links are, not
     Gruvbox's brighter one */
  --label-green-line: var(--link);
}

/* Nord's dark ink is the Snow Storm, a step down for the body; the tick
   is drawn in Polar Night on the frost cyan */
:is([data-theme="cosmic"], [data-theme="kosmic"])[data-look="genmaicha"] {
  --genmaicha-ink: var(--nord4);
  --genmaicha-ink-strong: var(--nord6);
  --genmaicha-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232e3440' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  /* Polar Night's lightest step for the rules: nord2, the ramp's dark2,
     is barely off the ground in Nord */
  --genmaicha-line: var(--nord3);
  --genmaicha-line-strong: var(--nord3-bright);

  /* Cosmic's colour, sky or none: what is open, chosen or on is drawn in
     the aurora's purple pushed to a pink that glows (--nord15-bright):
     the open page's name and pill, the sort, the selection and the
     ticks, a switch that is on, lettered and ruled in it, with the frost
     cyan left to what acts */
  --genmaicha-mark: var(--nord15-bright);
  --genmaicha-mark-ink: var(--nord15-bright);
  --selected-color: var(--nord15-bright);
  --selected-border: var(--genmaicha-on-line);
  --genmaicha-on-line: color-mix(in oklch, var(--nord15-bright) 75%, var(--genmaicha-line));
  --genmaicha-chip-line: color-mix(in oklch, var(--nord15-bright) 75%, var(--genmaicha-line));
  --genmaicha-on-ink: var(--nord15-bright);
  /* ...and drawn in the line and the letter alone: no wash under what is
     open, on, chosen or sorted */
  --genmaicha-on: transparent;
  --genmaicha-selected: transparent;
  --genmaicha-chip: transparent;
  --selected-background: transparent;
  /* Two colours, as Matcha's: the frost cyan of the links (the original
     Kosmic's) for names in tables and the Contacts rail, and a breath of
     it under the pointer; the pink for what is chosen */
  --genmaicha-name: var(--link);
  --genmaicha-name-hover: var(--link-hover);
  --genmaicha-hover: color-mix(in oklch, var(--link) 8%, var(--genmaicha-card));
}

/* Under the night sky (Cosmic's dark side with the sky on, data-theme=
   "kosmic"): the page is Polar Night let through, once, on the body.
   What lies on the page (the title area, the tab rows, the open tabs,
   the top bar, genmaicha.css) is clear, so an open tab is the sky and
   the page below it, unbroken; only the rules draw them. The vertical
   sidebar is a little more solid. A table is one wash and its cells are
   clear (rows past due or picked out too), and a card is the same wash,
   so the sky shows through them as it did under Kosmic; fields, menus
   and dialogs, which float, stay solid. (Its pink is Cosmic's dark's,
   in the block above.) */
[data-theme="kosmic"][data-look="genmaicha"] {
  --background-body: color-mix(in oklch, var(--nord0) 64%, transparent);
  --background-subnav: transparent;
  --background-sidebar: color-mix(in oklch, var(--nord1) 85%, transparent);
  --background-td: transparent;
  --past-due-bg: transparent;
  --task-highlight-bg: transparent;
  --genmaicha-card-wash: var(--background-body);
  --genmaicha-tab: transparent;
  /* The tab rows' rules a step brighter, against the stars' glow */
  --genmaicha-tab-line: var(--nord3-bright);
}

/* Mizan Dark with the Genmaicha layout look: deep obsidian page and raised
   charcoal cards, hairline rules, deep burgundy (#8A181A family) primary
   buttons under crisp alabaster text, and luminous burgundy-rose for links,
   selections, active indicators, and controls. */
[data-theme="mizan-dark"][data-look="genmaicha"] {
  --radius-sm: 0.5rem;
  --radius-md: 0.5rem;
  --genmaicha-page: var(--mizan-dark-page);
  --genmaicha-card: var(--mizan-dark-card);
  --genmaicha-ink: var(--mizan-dark-ink);
  --genmaicha-ink-strong: var(--mizan-dark-ink-strong);
  --genmaicha-muted: var(--mizan-dark-muted);
  --genmaicha-muted-light: var(--mizan-dark-muted-light);
  --genmaicha-line: var(--mizan-dark-line);
  --genmaicha-line-soft: color-mix(in oklch, var(--mizan-dark-line) 55%, var(--mizan-dark-card));
  --genmaicha-line-strong: var(--mizan-dark-line-strong);

  /* Filled actions keep authentic deep burgundy; interactive marks lift for contrast */
  --genmaicha-green: var(--mizan-dark-brand-fill);
  --genmaicha-green-ink: var(--mizan-dark-brand-ink);
  --genmaicha-green-mid: var(--mizan-dark-brand-fill-hover);
  --genmaicha-green-light: var(--mizan-dark-brand-ink);
  --genmaicha-on-green: var(--mizan-dark-ink-strong);
  --genmaicha-mark: var(--mizan-dark-brand-ink);
  --genmaicha-mark-ink: var(--mizan-dark-brand-ink);
  --genmaicha-gold: var(--mizan-dark-amber);
  --genmaicha-red: var(--mizan-dark-danger);
  --genmaicha-delete: var(--mizan-dark-danger);
  --genmaicha-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23131010' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");

  --genmaicha-name: var(--mizan-dark-ink-strong);
  --genmaicha-name-hover: var(--mizan-dark-brand-ink);
  --genmaicha-hover: color-mix(in oklch, var(--mizan-dark-brand-ink) 8%, var(--mizan-dark-card));
  --genmaicha-selected: var(--mizan-dark-brand-wash);
  --genmaicha-on: var(--mizan-dark-brand-fill);
  --genmaicha-on-line: var(--mizan-dark-brand-border);
  --genmaicha-on-ink: var(--mizan-dark-ink-strong);
  --genmaicha-chip: var(--mizan-dark-brand-wash);
  --genmaicha-chip-line: var(--mizan-dark-brand-border);

  --selected-background: var(--mizan-dark-brand-wash);
  --selected-border: var(--mizan-dark-brand-border);
  --selected-color: var(--mizan-dark-brand-ink-hover);
  --background-sidebar-active: var(--mizan-dark-brand-wash);

  --violet-400: var(--mizan-dark-brand-ink);
  --violet-500: var(--mizan-dark-brand-ink);
  --violet-600: var(--mizan-dark-brand-ink-hover);
  --violet-700: var(--mizan-dark-brand-ink);
  --violet-800: var(--mizan-dark-brand-fill);
  --icon-violet: var(--mizan-dark-brand-ink);
  --icon-violet-muted: var(--mizan-dark-brand-border);

  --button-primary-background: var(--mizan-dark-brand-fill);
  --button-primary-color: var(--mizan-dark-ink-strong);
  --btn-success-bg: var(--mizan-dark-brand-fill);

  --calendar-dot: var(--mizan-dark-brand-ink);
  --calendar-allday-dot: var(--mizan-dark-brand-ink);
  --calendar-allday-rail: var(--mizan-dark-brand-ink);
  --calendar-today: var(--mizan-dark-brand-wash);
  --kanban-past-due: var(--kanban-card, var(--background-body));
  --label-green-line: var(--mizan-dark-green);
}

/* ==========================================================================
   Prism's dark side — Jira's dark mode. Like Genmaicha's dark, it is the
   dark theme (data-theme="dark") marked with its look, data-look="prism",
   so it takes every dark rule there is (and prism.css, the face, the
   underline rails and the filled save button, on both sides). This block
   first repoints the dark ramp (--gb-*) onto Jira's dark (the
   --prism-dark-* roles in palette.css), so the shared dark rules draw in
   it, then sets the roles as Prism does by day: one ground, a step up for
   a table's head and a hover, one hairline, a soft light ink, and the one
   blue for everything that acts or is chosen. Each hue is a light ink
   over a deep wash of itself.
   ========================================================================== */
[data-theme="dark"][data-look="prism"] {
  /* The seven person colours: a user's initials on the board and their
     filter chip (CustomUser.person_hue, prism.css). Clear of red
     (overdue) and yellow (soon), and only ramps no theme repoints, so a
     person keeps one colour (violet is the darks' aqua). */
  --person-0: var(--orange-400);
  --person-1: var(--indigo-400);
  --person-2: var(--teal-400);
  --person-3: var(--blue-400);
  --person-4: var(--pink-400);
  --person-5: var(--fuchsia-400);
  --person-6: var(--cyan-400);

  /* The ramp: grounds lifting, the inks, the hues */
  --gb-dark: var(--prism-dark-surface);
  --gb-dark-soft: var(--prism-dark-surface-raised);
  --gb-dark1: var(--prism-dark-surface-raised);
  --gb-dark2: var(--prism-dark-surface-overlay);
  --gb-dark3: var(--prism-dark-line);
  --gb-dark4: var(--prism-dark-line-bold);
  --gb-light: var(--prism-dark-text-bright);
  --gb-light3: var(--prism-dark-text);
  --gb-light4: var(--prism-dark-text);
  --gb-gray: var(--prism-dark-text-subtle);
  --gb-bright-aqua: var(--prism-dark-blue);
  --gb-aqua: var(--prism-dark-blue-hover);
  --gb-faded-aqua: var(--prism-dark-blue);
  --gb-bright-red: var(--prism-dark-red);
  --gb-bright-orange: var(--prism-dark-orange);
  --gb-bright-green: var(--prism-dark-green);
  --gb-bright-purple: var(--prism-dark-purple);
  --gb-bright-yellow: var(--prism-dark-yellow);

  /* Matcha's violet (filters, sort, switches, ticks, selection) is the
     blue, as by day */
  --violet-300: var(--prism-dark-blue);
  --violet-400: var(--prism-dark-blue);
  --violet-500: var(--prism-dark-blue);
  --violet-600: var(--prism-dark-blue);
  --violet-700: var(--prism-dark-blue-hover);
  --violet-800: var(--prism-dark-blue-wash-strong);
  --violet-900: var(--prism-dark-blue-wash);
  --violet-950: var(--prism-dark-blue-wash);

  /* Corners, as by day */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;

  /* Type: the soft ink, the brighter ink for emphasis, the two greys */
  --color-primary: var(--prism-dark-text);
  --color-darker: var(--prism-dark-text-bright);
  --color-muted: var(--prism-dark-text-subtle);
  --color-muted-more: var(--prism-dark-text-subtlest);
  --color-lighter: var(--prism-dark-text-bright);

  /* Links, focus and the brand: the light blue, into Jira's purple */
  --link: var(--prism-dark-blue);
  --link-hover: var(--prism-dark-blue-hover);
  --accent-link: var(--prism-dark-blue);
  --focus-ring: var(--prism-dark-blue);
  --field-focus: var(--prism-dark-blue);
  --brand-grad-to: var(--prism-dark-purple);

  /* Grounds: one, everywhere a thing sits; a step up for a table's head,
     a hover and the AI's raised panels */
  --background-nav: var(--prism-dark-surface);
  --background-body: var(--prism-dark-surface);
  --background-subnav: var(--prism-dark-surface);
  --background-subnav-contrast: var(--prism-dark-surface-overlay);
  --background-control: var(--prism-dark-surface);
  --background-section: var(--prism-dark-surface);
  --background-th: var(--prism-dark-surface-raised);
  --background-td: var(--prism-dark-surface);
  --background-medium-light: var(--prism-dark-surface-raised);
  --background-light: var(--prism-dark-surface);
  --ai-frame: var(--prism-dark-surface-sunken);
  --ai-surface: var(--prism-dark-surface);
  --ai-raised: var(--prism-dark-surface-raised);

  /* Navigation: one bar ruled along its foot; the place you are is the
     blue underline (prism.css), or in the vertical sidebar the blue wash */
  --color-nav: var(--prism-dark-text-subtle);
  --background-nav-tab-active: var(--prism-dark-surface);
  --background-subnav-tab-active: var(--prism-dark-surface);
  --subnav-divider: var(--prism-dark-line);
  --background-sidebar: var(--prism-dark-surface);
  --background-sidebar-hover: var(--prism-dark-surface-overlay);
  --background-sidebar-active: transparent;

  /* Buttons: the primary and the save button are the light blue under
     the dark ink, as Jira's Create; the rest sit on the ground in the
     hairline */
  --button-primary-background: var(--prism-dark-blue);
  --button-primary-color: var(--prism-dark-surface);
  --button-secondary-background: var(--prism-dark-surface);
  --button-secondary-color: var(--prism-dark-text);
  --button-toolbar: var(--prism-dark-text);
  --button-border: var(--prism-dark-line);
  --btn-secondary-bg: var(--prism-dark-surface);
  --btn-success-bg: var(--prism-dark-blue);
  --btn-danger-bg: var(--prism-dark-red-wash);

  /* Fields: the ground in the input line, the blue when focused */
  --input-border: var(--prism-dark-line-bold);
  --input-background: var(--prism-dark-surface);
  --input-placeholder: var(--prism-dark-text-subtlest);

  /* Rules: one hairline; the bolder one for emphasis */
  --border-light: var(--prism-dark-line);
  --border-medium: var(--prism-dark-line);
  --border-medium-dark: var(--prism-dark-line);
  --border-dark: var(--prism-dark-line-bold);

  /* Selection: the blue wash under the blue */
  /* What is chosen is drawn in the blue's line and letter, not a wash */
  --selected-background: transparent;
  --selected-color: var(--prism-dark-blue);
  --selected-border: var(--prism-dark-blue);

  /* Status */
  --urgent: var(--prism-dark-red);
  --warning: var(--prism-dark-orange);
  --success: var(--prism-dark-green);
  --true: var(--prism-dark-green);
  --error-background: var(--prism-dark-red-wash);
  --status-green-bg: var(--prism-dark-green-wash);
  --status-green-ink: var(--prism-dark-green);
  --status-green-line: var(--prism-dark-green);
  --status-green-hover: var(--prism-dark-green-wash);

  /* Labels: each hue's wash, its light ink on the line (badges.css draws
     the dark side's outline pills) */
  --label-gray: var(--prism-dark-surface-overlay);
  --label-green: var(--prism-dark-green-wash);
  --label-orange: var(--prism-dark-orange-wash);
  --label-purple: var(--prism-dark-purple-wash);
  --label-red: var(--prism-dark-red-wash);
  --label-yellow: var(--prism-dark-yellow-wash);
  --label-blue-line: var(--prism-dark-blue);
  --label-gray-line: var(--prism-dark-text-subtle);
  --label-green-line: var(--prism-dark-green);
  --label-lime-line: var(--prism-dark-green);
  --label-orange-line: var(--prism-dark-orange);
  --label-purple-line: var(--prism-dark-purple);
  --label-red-line: var(--prism-dark-red);
  --label-yellow-line: var(--prism-dark-yellow);

  /* Icons: the subtle grey; the blue for what is on */
  --icon-default: var(--prism-dark-text-subtle);
  --icon-muted: var(--prism-dark-text-subtle);
  --icon-muted-more: var(--prism-dark-text-subtlest);
  --icon-violet: var(--prism-dark-blue);
  --icon-violet-muted: var(--prism-dark-blue-hover);
  --icon-yellow: var(--prism-dark-yellow);
  --add: var(--prism-dark-blue);

  /* Row highlights: the washes (the dark rows draw them as a rail) */
  --hl-gray: var(--prism-dark-surface-overlay);
  --hl-blue: var(--prism-dark-blue-wash);
  --hl-slate: var(--prism-dark-surface-raised);
  --hl-green: var(--prism-dark-green-wash);
  --hl-orange: var(--prism-dark-orange-wash);
  --hl-violet: var(--prism-dark-purple-wash);
  --hl-red: var(--prism-dark-red-wash);
  --hl-yellow: var(--prism-dark-yellow-wash);

  /* Calendar: events in the blue wash, tasks in the purple, holidays in
     the teal, each under its light ink; today the blue wash */
  --calendar-chip: var(--prism-dark-blue-wash);
  --calendar-allday: var(--prism-dark-blue-wash-strong);
  --calendar-allday-color: var(--prism-dark-text-bright);
  --calendar-task: var(--prism-dark-purple-wash);
  --calendar-task-color: var(--prism-dark-text);
  --calendar-task-icon: var(--prism-dark-purple);
  --calendar-chip-border: var(--prism-dark-blue-wash-strong);
  --calendar-dot: var(--prism-dark-blue);
  --calendar-allday-dot: var(--prism-dark-blue);
  --calendar-holiday: var(--prism-dark-teal-wash);

  /* ...but drawn unfilled, the colour a rail at the chip's left
     (calendar.css): the blue for an all-day event, the yellow for a
     pending one due soon, the teal for a holiday */
  --calendar-allday: transparent;
  --calendar-allday-soon: transparent;
  --calendar-holiday: transparent;
  --calendar-chip-line: var(--border-dark);
  --calendar-allday-rail: var(--prism-dark-blue);
  --calendar-allday-soon-rail: var(--prism-dark-yellow);
  --calendar-holiday-rail: var(--prism-dark-teal);
  --calendar-holiday-color: var(--prism-dark-teal);
  --calendar-today: var(--prism-dark-blue-wash);
}
