/* Themes: every colour in the app comes from here. One block per Theme, picked by data-theme on <html>
   (themes.js sets it; no reload). style.css only reads these variables, so a reskin is CSS only.
   Ported from prototypes/shared/themes.css + prototypes/a/style.css (Task-Tree: paper ... nocturne,
   plus Plain dark and Plain light).

   Roles: bg page / paper card / panel raised or inset / ink text / ink-dim secondary text (4.5:1 on cards)
   / ink-mute decoration only (fails 4.5:1: never text) / rule borders / accent / tag-bg, tag-ink chips
   / check done / warn late / ready / selection / code-bg / shadow.
   App tokens: card-bg = the see-through card (main, sidebar); solid = an opaque stand-in (option lists, Notes
   panel); card-mix = how much paper the card shows (raise it if a Theme fails contrast over its background).
   glass = the card's backdrop-filter (a blur of glass-blur). Where a blur could show nothing (an opaque card, or a blur
   of 0) it is `none`, so no blur pass is paid per frame, and glass-keep (the card's will-change) names the property
   instead: the card stays a layer of its own and the box its placed children measure from, as with the blur on.
   chart-1 .. chart-8 = chart series colours, in a fixed order, for marks only (never text). Checked for colour blindness
   and contrast on each Theme's solid; light Themes dip below 3:1 on some, which is why every chart has a table view.
   --land-* paint the landscape and the picker swatches; --star* are the star colours backdrop.js reads. */

:root {
  --glass-blur: 14px;
  --glass: blur(var(--glass-blur));
  --glass-keep: auto;
  --on-accent: #fff;
  --card-mix: 90%;
  --card-bg: color-mix(in srgb, var(--paper) var(--card-mix), transparent);
  --solid: var(--paper);
  --star: #fff; --star-violet: hsl(295 85% 82%); --star-blue: hsl(225 85% 82%); --star-gold: hsl(40 85% 82%);
  --ov-rain: rgba(214, 230, 250, 0.55); --ov-snow: rgba(255, 255, 255, 0.9); --ov-fog: rgba(232, 238, 244, 0.30);
  --ov-cloud: rgba(255, 255, 255, 0.24); --ov-fly: oklch(0.93 0.17 105);
  --sx: 35%;
  --sy: 30%;
  --chart-1: #2a78d6; --chart-2: #eb6834; --chart-3: #1baf7a; --chart-4: #eda100;
  --chart-5: #e87ba4; --chart-6: #008300; --chart-7: #6250d6; --chart-8: #e34948;
  /* Zen mode (prototype C's look): light ink on dark glass, over a dark scrim on the Theme's backdrop, on every Theme.
     The scrim's lightest end with the glass on it is proved over pure white (tests/themes.test.mjs), so all Zen text reads
     over any frame of any clip. --zen-on is the text on a --zen-ink fill (the main button). Blur follows the Theme's, so a
     video Theme does not blur. */
  --zen-ink: #f7f4ee; --zen-dim: #d3d0c8; --zen-warn: #ffc2aa; --zen-on: #10121c;
  --zen-scrim-top: rgba(6, 8, 20, 0.40); --zen-scrim-bottom: rgba(6, 8, 20, 0.62);
  --zen-glass: rgba(10, 12, 26, 0.50); --zen-solid: #14161f;
  --zen-line: rgba(255, 255, 255, 0.20); --zen-hover: rgba(255, 255, 255, 0.10); --zen-shade: rgba(0, 0, 0, 0.45);
  --zen-selection: rgba(255, 255, 255, 0.28);
  --zen-blur: var(--glass-blur);
  /* The pixel skin (pixel.css) mixes its frame colours from the Theme's tokens; these are what it mixes with and lays over. */
  --px-black: #000; --px-white: #fff; --px-dim: rgba(0, 0, 0, 0.30); --px-glint: rgba(255, 255, 255, 0.30);
}

html[data-theme] { background: var(--bg, #fff); color: var(--ink, #111); }
html[data-theme="cosmos"] { background: #050610; }
html[data-theme="nocturne"] { background: #010208; }

[data-theme="paper"] {
  color-scheme: light;
  --bg: #f4ecdc; --paper: #faf3e3; --panel: #f1e8d3;
  --ink: #2b2520; --ink-dim: #6b5e51; --ink-mute: #8a7e6e; --rule: #d8cbae;
  --accent: oklch(0.55 0.12 60); --tag-bg: #ebdfc3; --tag-ink: #5a4a36;
  --check: oklch(0.52 0.13 145); --warn: oklch(0.55 0.16 30); --ready: oklch(0.55 0.16 245);
  --selection: #e3d3a8; --code-bg: #ece1c5;
  --shadow: 0 1px 0 rgba(0,0,0,0.04), 0 8px 24px -12px rgba(74,55,30,0.25);
}
[data-theme="sepia"] {
  color-scheme: light;
  --bg: #efe2c4; --paper: #f4e8cc; --panel: #e9dab8;
  --ink: #3a2a18; --ink-dim: #6a5139; --ink-mute: #8d7355; --rule: #d3bf94;
  --accent: oklch(0.5 0.14 40); --tag-bg: #e2cfa4; --tag-ink: #5b4329;
  --check: oklch(0.5 0.13 135); --warn: oklch(0.55 0.18 25); --ready: oklch(0.5 0.16 245);
  --selection: #ddc78d; --code-bg: #e6d6ad;
  --shadow: 0 1px 0 rgba(0,0,0,0.04), 0 8px 24px -12px rgba(82,55,20,0.3);
}
[data-theme="dawn"] {
  color-scheme: light;
  --bg: #ecedf0; --paper: #f6f6f8; --panel: #e7e8ec;
  --ink: #20232a; --ink-dim: #5b6170; --ink-mute: #828897; --rule: #d2d5dd;
  --accent: oklch(0.55 0.15 250); --tag-bg: #e0e3eb; --tag-ink: #424857;
  --check: oklch(0.52 0.13 150); --warn: oklch(0.55 0.18 30); --ready: oklch(0.55 0.16 290);
  --selection: #c7d3eb; --code-bg: #e4e7ee;
  --shadow: 0 1px 0 rgba(0,0,0,0.03), 0 8px 24px -12px rgba(20,30,60,0.18);
}
[data-theme="dusk"] {
  color-scheme: dark;
  --bg: #1e1a18; --paper: #25201d; --panel: #2c2622;
  --ink: #ede3d3; --ink-dim: #b6a48d; --ink-mute: #7c6e5c; --rule: #3a322c;
  --accent: oklch(0.78 0.13 60); --tag-bg: #312924; --tag-ink: #d9c6a7;
  --check: oklch(0.75 0.12 150); --warn: oklch(0.78 0.15 30); --ready: oklch(0.82 0.13 240);
  --selection: #46382c; --code-bg: #2a2420; --on-accent: #1e1a18;
  --shadow: 0 1px 0 rgba(0,0,0,0.4), 0 12px 30px -12px rgba(0,0,0,0.5);
}
[data-theme="night"] {
  color-scheme: dark;
  --bg: #0e1115; --paper: #14181d; --panel: #1a1f25;
  --ink: #e6ebf2; --ink-dim: #97a2b2; --ink-mute: #5e6975; --rule: #242a32;
  --accent: oklch(0.78 0.14 235); --tag-bg: #1e242d; --tag-ink: #b7c2d2;
  --check: oklch(0.75 0.13 155); --warn: oklch(0.78 0.15 30); --ready: oklch(0.82 0.13 285);
  --selection: #1f3146; --code-bg: #181d23; --on-accent: #0e1115;
  --shadow: 0 1px 0 rgba(0,0,0,0.4), 0 12px 30px -12px rgba(0,0,0,0.6);
}
/* Glass Themes: the card is a dark scrim over the Cosmos background. */
[data-theme="cosmos"] {
  color-scheme: dark;
  --bg: transparent; --paper: rgba(255,255,255,0.045); --panel: rgba(255,255,255,0.07);
  --ink: #eef1f8; --ink-dim: rgba(238,241,248,0.66); --ink-mute: rgba(238,241,248,0.40); --rule: rgba(255,255,255,0.10);
  --accent: oklch(0.80 0.14 295); --tag-bg: rgba(255,255,255,0.08); --tag-ink: rgba(238,241,248,0.85);
  --check: oklch(0.82 0.13 165); --warn: oklch(0.78 0.16 25); --ready: oklch(0.82 0.13 240);
  --selection: rgba(167,139,250,0.35); --code-bg: rgba(255,255,255,0.05); --on-accent: #0c0e16;
  --shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 12px 40px -16px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
  --glass-blur: 22px;
  --card-bg: rgba(10,10,28,0.72); --solid: #14122e;
}
[data-theme="nocturne"] {
  color-scheme: dark;
  --bg: transparent; --paper: rgba(255,255,255,0.035); --panel: rgba(255,255,255,0.055);
  --ink: #f1f3fa; --ink-dim: rgba(241,243,250,0.70); --ink-mute: rgba(241,243,250,0.42); --rule: rgba(255,255,255,0.08);
  --accent: oklch(0.84 0.11 220); --tag-bg: rgba(255,255,255,0.07); --tag-ink: rgba(241,243,250,0.88);
  --check: oklch(0.84 0.13 170); --warn: oklch(0.80 0.16 25); --ready: oklch(0.84 0.13 290);
  --selection: rgba(125,211,252,0.30); --code-bg: rgba(255,255,255,0.04); --on-accent: #0c0e16;
  --shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 16px 50px -20px rgba(0,0,0,0.85), 0 0 0 1px rgba(255,255,255,0.03);
  --glass-blur: 28px;
  --card-bg: rgba(6,10,28,0.72); --solid: #0b1226;
}
/* Pixel Themes: the sky is a pixel-art scene on a canvas (pixel-cosmos.js). By default the UI wears the pixel skin on them
   (pixel.css; skin.js decides). Three palettes, shared by the scenes that use them (themes.js: pixel.palette).
   The card is see-through, so the sky shows: --card-alpha is its opacity, 80% unless the owner moved the Card opacity slider
   (skin.js: CARD_DEFAULT, never under CARD_MIN). --ink-dim is bright enough to keep 4.5:1 on the card at CARD_MIN over a pure
   white patch of sky (tests/themes.test.mjs).
   The skin's frame colours, tuned here; on every other Theme pixel.css mixes them from that Theme's own tokens:
   --px-line the frame's main line / --px-deep its dark outline and hard drop / --px-light a bevel's lit edge / --px-shade its
   shaded edge / --px-lip a raised accent button's lower edge / --px-hi a hovered fill / --px-void an inset fill (fields, the
   table's bed) / --px-face a raised fill (buttons). */
/* Pixel Space's colours: one set per palette, picked by data-px on <html> (backdrop.js sets it as the scenes flow, or to the
   held colour). Each token reads an --sp-* twin registered as a colour, so a change of palette fades over FLOW_FADE_MS
   (themes.js) instead of jumping. The picker swatch and a first paint with no data-px get Orchid. */
@property --sp-bg { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-paper { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-panel { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-ink { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-ink-dim { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-ink-mute { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-rule { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-accent { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-tag-bg { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-tag-ink { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-check { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-warn { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-ready { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-selection { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-code-bg { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-on-accent { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-line { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-deep { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-light { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-shade { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-lip { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-hi { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-void { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-px-face { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sp-solid { syntax: '<color>'; inherits: true; initial-value: #000; }
[data-theme="px-space"] {
  color-scheme: dark;
  --bg: var(--sp-bg); --paper: var(--sp-paper); --panel: var(--sp-panel); --ink: var(--sp-ink); --ink-dim: var(--sp-ink-dim);
  --ink-mute: var(--sp-ink-mute); --rule: var(--sp-rule); --accent: var(--sp-accent); --tag-bg: var(--sp-tag-bg); --tag-ink: var(--sp-tag-ink);
  --check: var(--sp-check); --warn: var(--sp-warn); --ready: var(--sp-ready); --selection: var(--sp-selection); --code-bg: var(--sp-code-bg);
  --on-accent: var(--sp-on-accent); --px-line: var(--sp-px-line); --px-deep: var(--sp-px-deep); --px-light: var(--sp-px-light); --px-shade: var(--sp-px-shade);
  --px-lip: var(--sp-px-lip); --px-hi: var(--sp-px-hi); --px-void: var(--sp-px-void); --px-face: var(--sp-px-face); --solid: var(--sp-solid);
  --sp-bg: #0b0a1f; --sp-paper: #15122e; --sp-panel: #221c48; --sp-ink: #f1ecff; --sp-ink-dim: #c8c3ea;
  --sp-ink-mute: #6f6aa8; --sp-rule: #3d3570; --sp-accent: #ffd23f; --sp-tag-bg: #2e2660; --sp-tag-ink: #ffe27a;
  --sp-check: #63d2b5; --sp-warn: #ff6f96; --sp-ready: #62b6e6; --sp-selection: #4a2278; --sp-code-bg: #0b0a1f;
  --sp-on-accent: #2a2238; --sp-px-line: #3d3570; --sp-px-deep: #05040f; --sp-px-light: #6f66b8; --sp-px-shade: #241f4a;
  --sp-px-lip: #c9951a; --sp-px-hi: #2e2660; --sp-px-void: #0b0a1f; --sp-px-face: #221c48; --sp-solid: #15122e;
  --shadow: 0 1px 0 rgba(0,0,0,0.4), 0 12px 30px -12px rgba(0,0,0,0.6);
  --glass-blur: 0px;
  --card-bg: color-mix(in srgb, var(--solid) var(--card-alpha, 80%), transparent);
}
html[data-theme="px-space"] { transition: --sp-bg 4s ease, --sp-paper 4s ease, --sp-panel 4s ease, --sp-ink 4s ease, --sp-ink-dim 4s ease, --sp-ink-mute 4s ease, --sp-rule 4s ease, --sp-accent 4s ease, --sp-tag-bg 4s ease, --sp-tag-ink 4s ease, --sp-check 4s ease, --sp-warn 4s ease, --sp-ready 4s ease, --sp-selection 4s ease, --sp-code-bg 4s ease, --sp-on-accent 4s ease, --sp-px-line 4s ease, --sp-px-deep 4s ease, --sp-px-light 4s ease, --sp-px-shade 4s ease, --sp-px-lip 4s ease, --sp-px-hi 4s ease, --sp-px-void 4s ease, --sp-px-face 4s ease, --sp-solid 4s ease; }
html[data-theme="px-space"][data-px="abyss"] {
  --sp-bg: #050b1c; --sp-paper: #0a1633; --sp-panel: #0e2450; --sp-ink: #e6fbff; --sp-ink-dim: #b4d4ea;
  --sp-ink-mute: #5a7fa8; --sp-rule: #1b4a80; --sp-accent: #a8e2f7; --sp-tag-bg: #123a75; --sp-tag-ink: #cdeeff;
  --sp-check: #7fd08a; --sp-warn: #ff8f9c; --sp-ready: #c9a8ff; --sp-selection: #1b5aa0; --sp-code-bg: #050b1c;
  --sp-on-accent: #2a2238; --sp-px-line: #1b4a80; --sp-px-deep: #02050e; --sp-px-light: #3f7fc0; --sp-px-shade: #0e2c52;
  --sp-px-lip: #62b6e6; --sp-px-hi: #123a75; --sp-px-void: #050b1c; --sp-px-face: #0e2450; --sp-solid: #0a1633;
}
html[data-theme="px-space"][data-px="ember"] {
  --sp-bg: #12070f; --sp-paper: #24091a; --sp-panel: #421026; --sp-ink: #fff0e4; --sp-ink-dim: #e6bdb4;
  --sp-ink-mute: #9c5a5a; --sp-rule: #7a2440; --sp-accent: #ffac4d; --sp-tag-bg: #5a1830; --sp-tag-ink: #ffe08a;
  --sp-check: #9be07a; --sp-warn: #ff8f8f; --sp-ready: #d9a0ff; --sp-selection: #6b1730; --sp-code-bg: #12070f;
  --sp-on-accent: #2a2238; --sp-px-line: #7a2440; --sp-px-deep: #070206; --sp-px-light: #b8456a; --sp-px-shade: #4a1228;
  --sp-px-lip: #cf6a2a; --sp-px-hi: #5a1830; --sp-px-void: #12070f; --sp-px-face: #421026; --sp-solid: #24091a;
}
/* Pixel Space's accent (data-acc, set by backdrop.js): the scene's own, or the one the owner holds. After the palettes, so it
   wins over theirs; --acc also paints the dots of the Accent choice in Settings. Each reads on every palette's card. */
[data-acc="gold"] { --acc: #ffd23f; --acc-lip: #c9951a; }
[data-acc="amber"] { --acc: #ffb561; --acc-lip: #cf6a2a; }
[data-acc="coral"] { --acc: #ffb1a2; --acc-lip: #c45040; }
[data-acc="rose"] { --acc: #ffabd2; --acc-lip: #c4528a; }
[data-acc="lilac"] { --acc: #d3b8ff; --acc-lip: #7d5cc4; }
[data-acc="sky"] { --acc: #8fd3ff; --acc-lip: #3f8fc0; }
[data-acc="mint"] { --acc: #7ee8c0; --acc-lip: #2f9e78; }
[data-acc="lime"] { --acc: #c6f06a; --acc-lip: #7fa82a; }
html[data-theme="px-space"][data-acc] { --sp-accent: var(--acc); --sp-px-lip: var(--acc-lip); }
@media (prefers-reduced-motion: reduce) { html[data-theme="px-space"] { transition: none; } }
/* Zen with the skin on: pixel.css mixes the frame colours again inside `.zen`, from Zen's own tokens (on a light Theme the
   ones above would give a pale button under Zen's pale ink). A Pixel Theme's tuned ones are dark already and Zen's ink reads
   on them (tests/themes.test.mjs), so there Zen keeps the Theme's frame. */
[data-theme^="px-"] .zen {
  --px-line: inherit; --px-deep: inherit; --px-light: inherit; --px-shade: inherit;
  --px-lip: inherit; --px-hi: inherit; --px-void: inherit; --px-face: inherit;
}
/* Plain: flat, nothing behind the card. */
[data-theme="plain-dark"] {
  color-scheme: dark;
  --bg: #121212; --paper: #1c1c1e; --panel: #262628;
  --ink: #f2f2f2; --ink-dim: #b0b0b4; --ink-mute: #77777c; --rule: #333336;
  --accent: oklch(0.78 0.12 250); --tag-bg: #2c2c2f; --tag-ink: #d0d0d4;
  --check: oklch(0.76 0.14 155); --warn: oklch(0.78 0.15 30); --ready: oklch(0.8 0.13 290);
  --selection: #2f3f58; --code-bg: #222225; --on-accent: #121212;
  --shadow: 0 1px 0 rgba(0,0,0,0.4), 0 12px 30px -12px rgba(0,0,0,0.6);
  --card-mix: 100%;
  --glass: none; --glass-keep: backdrop-filter, -webkit-backdrop-filter; /* an opaque card over one flat colour: a blur shows nothing */
}
[data-theme="plain-light"] {
  color-scheme: light;
  --bg: #ffffff; --paper: #ffffff; --panel: #f3f3f5;
  --ink: #1b1b1d; --ink-dim: #5f5f66; --ink-mute: #8e8e96; --rule: #e1e1e6;
  --accent: oklch(0.55 0.15 255); --tag-bg: #ececf0; --tag-ink: #3f3f46;
  --check: oklch(0.52 0.14 150); --warn: oklch(0.55 0.18 30); --ready: oklch(0.55 0.16 290);
  --selection: #cfe0fb; --code-bg: #f0f0f3;
  --shadow: 0 1px 0 rgba(0,0,0,0.03), 0 8px 24px -12px rgba(0,0,0,0.18);
  --card-mix: 100%;
  --glass: none; --glass-keep: backdrop-filter, -webkit-backdrop-filter; /* an opaque card over one flat colour: a blur shows nothing */
}

/* Video Themes (#52): a picture or looped clip sits behind the card. Text must read over ANY frame, in two ways:
   1. Contrast: the card is a near-opaque scrim (alpha 0.84 is the floor: white behind it still gives 5.0:1 text, 0.80
      does not) and inks are solid hex. Proved against pure white (tests/themes.test.mjs).
   2. No sharp shapes behind the words. A still backdrop is blurred (--glass-blur). When something moves behind the card
      (a clip plays or an overlay shows: media-layer.js sets data-moving on <html>) blur would redraw every frame, so
      the card turns more opaque instead (--card-moving: white and black behind it differ by under 1.15:1).
   --solid is the picture shown before the video arrives. */
[data-theme="forest"] { color-scheme: dark;
  --bg: transparent; --paper: rgba(255,255,255,0.04); --panel: rgba(255,255,255,0.07);
  --ink: #f0f4ee; --ink-dim: #c3cdc1; --ink-mute: #8b968a; --rule: rgba(255,255,255,0.14);
  --accent: oklch(0.84 0.12 145); --tag-bg: rgba(255,255,255,0.09); --tag-ink: #dbe4d8;
  --check: oklch(0.84 0.13 150); --warn: oklch(0.84 0.13 40); --ready: oklch(0.86 0.11 230);
  --selection: rgba(120,190,130,0.35); --code-bg: rgba(255,255,255,0.05); --on-accent: #0b120c;
  --shadow: 0 12px 40px -16px rgba(0,0,0,0.7);
  --glass-blur: 18px; --card-bg: rgba(8,18,12,0.84); --card-moving: rgba(8,18,12,0.95); --solid: #0d1a12; }
[data-theme="ocean"] { color-scheme: dark;
  --bg: transparent; --paper: rgba(255,255,255,0.04); --panel: rgba(255,255,255,0.07);
  --ink: #eef4f8; --ink-dim: #c0ccd6; --ink-mute: #87949f; --rule: rgba(255,255,255,0.14);
  --accent: oklch(0.84 0.11 220); --tag-bg: rgba(255,255,255,0.09); --tag-ink: #d8e3eb;
  --check: oklch(0.84 0.13 170); --warn: oklch(0.84 0.13 40); --ready: oklch(0.86 0.11 280);
  --selection: rgba(110,170,210,0.35); --code-bg: rgba(255,255,255,0.05); --on-accent: #0a1218;
  --shadow: 0 12px 40px -16px rgba(0,0,0,0.7);
  --glass-blur: 18px; --card-bg: rgba(7,16,24,0.84); --card-moving: rgba(7,16,24,0.95); --solid: #0c1a26; }
[data-theme="mountain"] { color-scheme: dark;
  --bg: transparent; --paper: rgba(255,255,255,0.04); --panel: rgba(255,255,255,0.07);
  --ink: #f1f2f6; --ink-dim: #c6c9d3; --ink-mute: #8d909c; --rule: rgba(255,255,255,0.14);
  --accent: oklch(0.84 0.10 270); --tag-bg: rgba(255,255,255,0.09); --tag-ink: #dcdfe8;
  --check: oklch(0.84 0.13 160); --warn: oklch(0.84 0.13 40); --ready: oklch(0.86 0.11 230);
  --selection: rgba(150,160,210,0.35); --code-bg: rgba(255,255,255,0.05); --on-accent: #0d0f16;
  --shadow: 0 12px 40px -16px rgba(0,0,0,0.7);
  --glass-blur: 18px; --card-bg: rgba(14,16,24,0.84); --card-moving: rgba(14,16,24,0.95); --solid: #151826; }
/* Mac Aerial (#53): an Apple Aerial from the Mac, or the Mountain clip when the Mac is not reachable. */
[data-theme="mac-aerial"] { color-scheme: dark;
  --bg: transparent; --paper: rgba(255,255,255,0.04); --panel: rgba(255,255,255,0.07);
  --ink: #f0f3f7; --ink-dim: #c4cad4; --ink-mute: #8b919c; --rule: rgba(255,255,255,0.14);
  --accent: oklch(0.84 0.10 240); --tag-bg: rgba(255,255,255,0.09); --tag-ink: #dbe0e9;
  --check: oklch(0.84 0.13 160); --warn: oklch(0.84 0.13 40); --ready: oklch(0.86 0.11 200);
  --selection: rgba(130,170,220,0.35); --code-bg: rgba(255,255,255,0.05); --on-accent: #0b1018;
  --shadow: 0 12px 40px -16px rgba(0,0,0,0.7);
  --glass-blur: 18px; --card-bg: rgba(10,14,22,0.84); --card-moving: rgba(10,14,22,0.95); --solid: #10151f; }
/* Your image: the owner's own picture (own-image.js), any colours at all, so the same white-backdrop proof as the clips. */
[data-theme="your-image"] { color-scheme: dark;
  --bg: transparent; --paper: rgba(255,255,255,0.04); --panel: rgba(255,255,255,0.07);
  --ink: #f2f2f2; --ink-dim: #c8c8c8; --ink-mute: #8f8f8f; --rule: rgba(255,255,255,0.14);
  --accent: oklch(0.84 0.10 250); --tag-bg: rgba(255,255,255,0.09); --tag-ink: #dedede;
  --check: oklch(0.84 0.13 160); --warn: oklch(0.84 0.13 40); --ready: oklch(0.86 0.11 220);
  --selection: rgba(150,170,210,0.35); --code-bg: rgba(255,255,255,0.05); --on-accent: #0e0f12;
  --shadow: 0 12px 40px -16px rgba(0,0,0,0.7);
  --glass-blur: 18px; --card-bg: rgba(14,14,16,0.84); --card-moving: rgba(14,14,16,0.95); --solid: #141416; }
/* Something moves behind the card: no blur, a more opaque card. Set only on the Themes above. */
html[data-moving] { --card-bg: var(--card-moving, var(--solid)); --glass-blur: 0px; --glass: none; --glass-keep: backdrop-filter, -webkit-backdrop-filter; }

/* Dark Themes: their own steps of the same chart hues. Light Themes keep the set on :root. */
[data-theme="dusk"], [data-theme="night"], [data-theme="cosmos"], [data-theme="nocturne"],
[data-theme="plain-dark"], [data-theme="forest"], [data-theme="ocean"], [data-theme="mountain"], [data-theme="mac-aerial"], [data-theme="your-image"],
[data-theme="px-space"] {
  --chart-1: #3987e5; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500;
  --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767;
}

/* Landscape tokens: sky, sun, four hill layers, trees. Cosmos and Nocturne show the Cosmos background instead;
   their values only paint the picker swatches. */
[data-theme="paper"]       { --land-sky-top: #ead8b0; --land-sky-bot: #f8ead0; --land-sun: #fff6dc; --land-glow: rgba(255, 208, 130, 0.65); --land-far: #d6c9a4; --land-mid: #bdbb8f; --land-near: #9eaa78; --land-fore: #7f9161; --land-tree: #6d8053; }
[data-theme="sepia"]       { --land-sky-top: #d8bb82; --land-sky-bot: #efd8a6; --land-sun: #fff1c8; --land-glow: rgba(255, 190, 100, 0.6); --land-far: #cfa977; --land-mid: #b78f5c; --land-near: #94724b; --land-fore: #725839; --land-tree: #5d462d; }
[data-theme="dawn"]        { --land-sky-top: #a9bcdc; --land-sky-bot: #eadfe9; --land-sun: #fff8ee; --land-glow: rgba(255, 196, 186, 0.7); --land-far: #b6c1d7; --land-mid: #98a9c6; --land-near: #7b91a9; --land-fore: #5f7b83; --land-tree: #4d686f; }
[data-theme="dusk"]        { --land-sky-top: #231a26; --land-sky-bot: #80504a; --land-sun: #ffbf80; --land-glow: rgba(255, 150, 90, 0.5); --land-far: #5b3e47; --land-mid: #45313c; --land-near: #33262e; --land-fore: #231a20; --land-tree: #1a1318; }
[data-theme="night"]       { --land-sky-top: #060a13; --land-sky-bot: #1b2744; --land-sun: #e9effd; --land-glow: rgba(150, 180, 255, 0.32); --land-far: #1e2c48; --land-mid: #172239; --land-near: #111a2a; --land-fore: #0b111c; --land-tree: #080d16; }
[data-theme="plain-dark"]  { --land-sky-top: #141416; --land-sky-bot: #26262a; --land-sun: #d2d2d8; --land-glow: rgba(210, 210, 220, 0.14); --land-far: #2b2b30; --land-mid: #232327; --land-near: #1c1c1f; --land-fore: #151517; --land-tree: #111113; }
[data-theme="plain-light"] { --land-sky-top: #e9ecf2; --land-sky-bot: #fbfbfd; --land-sun: #ffffff; --land-glow: rgba(255, 255, 255, 0.9); --land-far: #dde1e8; --land-mid: #ced3dc; --land-near: #bfc5d0; --land-fore: #b0b7c4; --land-tree: #a0a8b6; }
[data-theme="cosmos"]      { --land-sky-top: #150b34; --land-sky-bot: #3a1f6e; --land-sun: #f1e8ff; --land-glow: rgba(190, 150, 255, 0.4); --land-far: #3a2670; --land-mid: #2b1d58; --land-near: #1f1542; --land-fore: #150d30; --land-tree: #0f0924; }
[data-theme="nocturne"]    { --land-sky-top: #050a1c; --land-sky-bot: #123a62; --land-sun: #e3f6ff; --land-glow: rgba(125, 211, 252, 0.35); --land-far: #14335a; --land-mid: #0f2748; --land-near: #0a1c36; --land-fore: #07132a; --land-tree: #040c1c; }
[data-theme="forest"]      { --land-sky-top: #1b3a2a; --land-sky-bot: #6d8f5a; --land-sun: #f4f0b8; --land-glow: rgba(240, 235, 150, 0.45); --land-far: #3d6347; --land-mid: #2d5237; --land-near: #1f3d29; --land-fore: #152d1e; --land-tree: #0e2016; }
[data-theme="ocean"]       { --land-sky-top: #7fa5b8; --land-sky-bot: #d4e3e6; --land-sun: #fbfdff; --land-glow: rgba(255, 255, 255, 0.5); --land-far: #3f7f99; --land-mid: #2d6c88; --land-near: #1f5a75; --land-fore: #4d7a5a; --land-tree: #2e5a3c; }
[data-theme="mountain"]    { --land-sky-top: #8b97b8; --land-sky-bot: #e6e1ec; --land-sun: #fffaf0; --land-glow: rgba(255, 220, 190, 0.55); --land-far: #b9bfd6; --land-mid: #8d95b4; --land-near: #626c8f; --land-fore: #454e6e; --land-tree: #343c58; }
[data-theme="mac-aerial"]  { --land-sky-top: #0d1b33; --land-sky-bot: #4f6f96; --land-sun: #eef5ff; --land-glow: rgba(190, 215, 255, 0.45); --land-far: #3a5578; --land-mid: #2b4261; --land-near: #1f3049; --land-fore: #142235; --land-tree: #0d1726; }
[data-theme="your-image"]  { --land-sky-top: #2a2a30; --land-sky-bot: #6a6a74; --land-sun: #f4f4f6; --land-glow: rgba(230, 230, 240, 0.35); --land-far: #55555e; --land-mid: #44444c; --land-near: #33333a; --land-fore: #24242a; --land-tree: #1a1a1e; }
/* Pixel Space shows its own canvas; this only paints the picker swatch (hard-edged there: pixel.css). */
[data-theme="px-space"] { --land-sky-top: #0b0a1f; --land-sky-bot: #4a2278; --land-sun: #e8c07a; --land-glow: #c98a4a; --land-far: #7a2e8f; --land-mid: #4a2278; --land-near: #2d1b55; --land-fore: #1a1338; --land-tree: #0b0a1f; }

/* ---------- Backdrop: backdrop.js mounts .land-host once; CSS shows the right layer for the Theme ---------- */
.land-host { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.land { position: absolute; inset: 0; overflow: hidden; }
.land .sky { position: absolute; inset: 0; background: linear-gradient(180deg, var(--land-sky-top) 0%, var(--land-sky-bot) 64%); transition: background 600ms ease; }
.land .sun {
  position: absolute; left: var(--sx); top: var(--sy); width: clamp(64px, 9vmax, 120px); aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--land-sun);
  box-shadow: 0 0 0 clamp(14px, 2.4vmax, 30px) color-mix(in srgb, var(--land-glow) 38%, transparent), 0 0 clamp(80px, 12vmax, 180px) clamp(30px, 6vmax, 80px) var(--land-glow);
}
.land .hills { position: absolute; inset: 0; width: 100%; height: 100%; }
.land .hills path { transition: fill 600ms ease; }
.l-far { fill: var(--land-far); }
.l-mid { fill: var(--land-mid); }
.l-near { fill: var(--land-near); }
.l-fore { fill: var(--land-fore); }
.l-trees-mid use { fill: color-mix(in srgb, var(--land-tree) 60%, var(--land-mid)); }
.l-trees use { fill: var(--land-tree); }
html[data-theme="cosmos"] .land, html[data-theme="nocturne"] .land, html[data-theme^="plain"] .land,
html[data-theme="forest"] .land, html[data-theme="ocean"] .land, html[data-theme="mountain"] .land, html[data-theme="mac-aerial"] .land,
html[data-theme="your-image"] .land { display: none; }

/* Pixel Themes: one canvas the size of the window, each art pixel a whole number of screen pixels (backdrop.js, pixel-cosmos.js). */
.px-bg { position: absolute; inset: 0; display: none; overflow: hidden; background: var(--bg); }
.px-sky { position: absolute; inset: 0; display: none; }
.px-sky.on { display: block; }
.px-sky.top { z-index: 1; }
.px-sky.fade-in { animation: px-sky-in 4s ease both; } /* matches FLOW_FADE_MS (themes.js) */
@keyframes px-sky-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .px-sky.fade-in { animation: none; } }
.px-bg canvas { position: absolute; left: 0; top: 0; display: block; image-rendering: pixelated; }
html[data-theme^="px-"] .px-bg { display: block; }
html[data-theme^="px-"] .land { display: none; }

/* Cosmos background: drifting nebulas + stars (backdrop.js draws the stars). Only cosmos and nocturne show it;
   hidden with display:none elsewhere, so the blurred nebulas cost nothing. */
.cosmos-bg {
  position: absolute; inset: 0; overflow: hidden; display: none;
  background: radial-gradient(ellipse at 20% 10%, #0a0a1c 0%, #050610 40%, #02030a 100%);
}
html[data-theme="cosmos"] .cosmos-bg, html[data-theme="nocturne"] .cosmos-bg { display: block; }
html[data-theme="nocturne"] .cosmos-bg { background: radial-gradient(ellipse at 30% 0%, #060a1a 0%, #03050f 45%, #010208 100%); }
.cosmos-nebula { position: absolute; border-radius: 50%; filter: blur(70px) saturate(1.2); mix-blend-mode: screen; will-change: transform; }
.cosmos-nebula.n1 {
  width: 80vmax; height: 80vmax; top: -30vmax; left: -25vmax;
  background: radial-gradient(circle, oklch(0.55 0.22 290 / 0.55) 0%, oklch(0.45 0.18 270 / 0.30) 35%, transparent 65%);
  animation: cosmos-n1 64s ease-in-out infinite alternate;
}
.cosmos-nebula.n2 {
  width: 70vmax; height: 70vmax; bottom: -25vmax; right: -22vmax;
  background: radial-gradient(circle, oklch(0.55 0.20 230 / 0.50) 0%, oklch(0.45 0.16 200 / 0.25) 35%, transparent 65%);
  animation: cosmos-n2 86s ease-in-out infinite alternate;
}
.cosmos-nebula.n3 {
  width: 55vmax; height: 55vmax; top: 30vmax; right: 10vmax;
  background: radial-gradient(circle, oklch(0.60 0.18 340 / 0.40) 0%, oklch(0.50 0.14 320 / 0.18) 40%, transparent 70%);
  animation: cosmos-n3 104s ease-in-out infinite alternate;
}
html[data-theme="nocturne"] .cosmos-nebula.n1 { background: radial-gradient(circle, oklch(0.60 0.22 250 / 0.50) 0%, oklch(0.50 0.18 220 / 0.28) 35%, transparent 65%); }
html[data-theme="nocturne"] .cosmos-nebula.n2 { background: radial-gradient(circle, oklch(0.65 0.18 180 / 0.38) 0%, oklch(0.55 0.15 200 / 0.20) 35%, transparent 65%); }
html[data-theme="nocturne"] .cosmos-nebula.n3 { background: radial-gradient(circle, oklch(0.62 0.20 300 / 0.34) 0%, oklch(0.52 0.16 280 / 0.16) 40%, transparent 70%); }
@keyframes cosmos-n1 { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(8vmax,6vmax,0) scale(1.12); } }
@keyframes cosmos-n2 { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(-10vmax,-4vmax,0) scale(1.08); } }
@keyframes cosmos-n3 { from { transform: translate3d(0,0,0) scale(0.95); } to { transform: translate3d(-6vmax,8vmax,0) scale(1.1); } }
.cosmos-stars { position: absolute; inset: 0; }
.cosmos-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.45) 100%); }

/* ---------- Video Themes (#52): media-layer.js fills .media-layer and .overlay-layer inside .land-host ---------- */
.media-layer, .overlay-layer { position: absolute; inset: 0; display: none; }
html[data-theme="forest"] .media-layer, html[data-theme="ocean"] .media-layer, html[data-theme="mountain"] .media-layer, html[data-theme="mac-aerial"] .media-layer,
html[data-theme="forest"] .overlay-layer, html[data-theme="ocean"] .overlay-layer, html[data-theme="mountain"] .overlay-layer, html[data-theme="mac-aerial"] .overlay-layer,
html[data-theme="your-image"] .media-layer, html[data-theme="your-image"] .overlay-layer { display: block; }
.media-layer { overflow: hidden; background: var(--solid); }
.media-still, .media-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-video { opacity: 0; transition: opacity 900ms ease; }
.media-video.on { opacity: 1; }

/* Overlays are plain CSS: only transform and opacity move (no filter, blur, blend or shadow), so they stay off the
   main thread. Over the video, under the cards, so the contrast proof (white backdrop) still covers them. */
.overlay-layer { contain: strict; overflow: hidden; }
.overlay-layer i { position: absolute; display: block; will-change: transform; }
@keyframes ov-fall { to { transform: translate3d(0, var(--tile), 0); } }
@keyframes ov-drift { from { transform: translate3d(-9vw, 0, 0); } to { transform: translate3d(9vw, 3vh, 0); } }
@keyframes ov-cross { from { transform: translate3d(-50vw, 0, 0); } to { transform: translate3d(115vw, 0, 0); } }
@keyframes ov-fly { 0%, 100% { opacity: 0; transform: translate3d(0, 0, 0); } 50% { opacity: 1; transform: translate3d(var(--dx), var(--dy), 0); } }
/* rain: a tall strip with a tiled stroke mask, moved by exactly one tile height */
.ov-rain { left: 0; right: 0; top: calc(-1 * var(--tile)); height: calc(100% + var(--tile)); --tile: 320px;
  background: var(--ov-rain); animation: ov-fall var(--t) linear infinite;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='320'%3E%3Cg stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M20 18l-5 26M92 6l-5 26M158 40l-5 26M60 90l-5 26M126 112l-5 26M186 130l-5 26M30 170l-5 26M100 196l-5 26M164 218l-5 26M64 252l-5 26M132 280l-5 26M12 290l-5 26'/%3E%3C/g%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='320'%3E%3Cg stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M20 18l-5 26M92 6l-5 26M158 40l-5 26M60 90l-5 26M126 112l-5 26M186 130l-5 26M30 170l-5 26M100 196l-5 26M164 218l-5 26M64 252l-5 26M132 280l-5 26M12 290l-5 26'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-size: 200px 320px; mask-size: 200px 320px; }
.ov-rain.a { --t: 0.9s; }
.ov-rain.b { --t: 1.3s; left: 70px; opacity: 0.6; }
/* snow: tiled dots, moved by a whole tile */
.ov-snow { left: 0; right: 0; top: calc(-1 * var(--tile)); height: calc(100% + var(--tile)); animation: ov-fall var(--t) linear infinite; }
.ov-snow.a { --tile: 281px; --t: 14s;
  background: radial-gradient(circle at 337px 14px, var(--ov-snow) 0 2.4px, transparent 3.4px),
    radial-gradient(circle at 279px 110px, var(--ov-snow) 0 1.8px, transparent 2.8px),
    radial-gradient(circle at 72px 96px, var(--ov-snow) 0 1.8px, transparent 2.8px),
    radial-gradient(circle at 1px 193px, var(--ov-snow) 0 1.7px, transparent 2.7px),
    radial-gradient(circle at 142px 25px, var(--ov-snow) 0 2.2px, transparent 3.2px),
    radial-gradient(circle at 279px 267px, var(--ov-snow) 0 2.3px, transparent 3.3px),
    radial-gradient(circle at 219px 276px, var(--ov-snow) 0 2.0px, transparent 3.0px),
    radial-gradient(circle at 77px 82px, var(--ov-snow) 0 2.0px, transparent 3.0px),
    radial-gradient(circle at 132px 142px, var(--ov-snow) 0 2.0px, transparent 3.0px);
  background-size: 347px 281px; }
.ov-snow.b { --tile: 433px; --t: 22s;
  background: radial-gradient(circle at 484px 91px, var(--ov-snow) 0 3.5px, transparent 4.5px),
    radial-gradient(circle at 297px 346px, var(--ov-snow) 0 3.2px, transparent 4.2px),
    radial-gradient(circle at 382px 372px, var(--ov-snow) 0 3.4px, transparent 4.4px),
    radial-gradient(circle at 23px 156px, var(--ov-snow) 0 3.6px, transparent 4.6px),
    radial-gradient(circle at 188px 136px, var(--ov-snow) 0 3.2px, transparent 4.2px),
    radial-gradient(circle at 34px 339px, var(--ov-snow) 0 3.1px, transparent 4.1px);
  background-size: 521px 433px; }
/* fog and clouds: soft sprites (radial gradients), slow */
.ov-fog { width: 80vw; height: 55vh; background: radial-gradient(ellipse at center, var(--ov-fog) 0%, transparent 68%); animation: ov-drift var(--t) ease-in-out infinite alternate; }
.ov-fog.a { left: -10vw; top: 52vh; --t: 40s; }
.ov-fog.b { left: 38vw; top: 30vh; --t: 53s; animation-delay: -20s; }
.ov-fog.c { left: 10vw; top: 68vh; --t: 66s; animation-delay: -35s; }
.ov-cloud { width: 46vw; height: 22vh; background: radial-gradient(ellipse at center, var(--ov-cloud) 0%, transparent 68%); animation: ov-cross var(--t) linear infinite; }
.ov-cloud.a { top: 6vh; --t: 70s; animation-delay: -10s; }
.ov-cloud.b { top: 20vh; --t: 98s; animation-delay: -60s; }
.ov-cloud.c { top: 36vh; --t: 120s; animation-delay: -30s; }
.ov-cloud.d { top: 52vh; --t: 84s; animation-delay: -70s; }
.ov-cloud.e { top: 70vh; --t: 146s; animation-delay: -100s; }
/* fireflies: small glowing dots, fade and wander (positions and timing set per dot by media-layer.js) */
.ov-fly { width: 14px; height: 14px; background: radial-gradient(circle, var(--ov-fly) 0 22%, transparent 70%); opacity: 0; animation: ov-fly var(--t) ease-in-out infinite; }
/* a hidden tab pauses them (media-layer.js sets data-tab-hidden) */
html[data-tab-hidden] .overlay-layer i { animation-play-state: paused; }

/* Reduced motion: nothing animates or fades (nebulas, hill fades, hovers). Stars are drawn once (backdrop.js). */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation: none !important; transition: none !important; }
  .cosmos-nebula { animation: none; }
  .overlay-layer { display: none !important; }
}
/* Reduced transparency: the card is opaque and nothing blurs. */
@media (prefers-reduced-transparency: reduce) {
  html[data-theme] { --card-bg: var(--solid); --glass-blur: 0px; --glass: none; --glass-keep: backdrop-filter, -webkit-backdrop-filter; --zen-glass: var(--zen-solid); --zen-blur: 0px; --zen-feather: 0px; --zen-bleed: 0px; }
}

/* Overlay picker (pages/overlay-picker.js): two chip rows under the Theme swatches, video Themes only. */
.overlay-picker h3 { font-size: 15px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.overlay-picker .chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* Mac media (pages/mac-media-picker.js): the same chip rows, and a collapsed setup form. */
.mac-setup { margin-top: 14px; }
.mac-setup input { flex: 1; min-width: 0; }
