/*! djcns.css 3.5.0 | DJCNS "Athletic glass" design system | DJ2000-UK/app-workbench
 *
 * One file for every DJCNS app: tokens, the preset palettes, the base page
 * (with the iPhone Home Screen fill fix) and the shared components.
 *
 * Do not edit a copy of this file inside an app. Change it here, bump the
 * version above, then run `node scripts/copy-to-app.mjs <app folder>`. The
 * app's own test fails if its copy differs from the version it pins.
 *
 * Everything here sits in cascade layers, so any rule in the app's own
 * stylesheet (unlayered) wins without !important or extra specificity:
 *
 *   djcns.tokens      type, spacing, radii, sizes, glass, motion, colour roles
 *   djcns.palette     every colour; one block per preset, keyed on data-palette
 *   djcns.base        the page: atmosphere, safe areas, focus, reduced motion
 *   djcns.components  shell, sidebar, panels, buttons, fields, sheets...
 *
 * The tab bar, the round action button and More's grouped lists live in the
 * navigation set (navigation/navigation.css, its own djcns.navigation layer).
 *
 * Colour literals (hex and rgb() with numbers) appear only in the tokens and
 * palette layers; tests/design.test.mjs fails the build if one appears below.
 * System fonts only: no remote fonts, CDNs or external assets.
 */

@property --hold-progress { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --hold-pressure { syntax: "<number>"; inherits: true; initial-value: 0; }

@layer djcns.tokens, djcns.palette, djcns.base, djcns.components;

/* ========================================================================== */
@layer djcns.tokens {
  :root {
    /* Type. System stacks only. Inputs are always 16 px so iOS never zooms. */
    --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --font-mark: Georgia, "Times New Roman", serif;
    --text-label: 10px;   /* tab labels, eyebrows, stat labels: the floor */
    --text-small: 12px;   /* field labels, footnotes, chips, secondary lines */
    --text-body: 13px;    /* copy, buttons, toasts, settings */
    --text-item: 14px;    /* list row titles, sidebar links */
    --text-lead: 15px;    /* huge buttons, row values */
    --text-input: 16px;   /* every text field */
    --text-title: 18px;   /* page titles, panel titles */
    --text-sheet: 23px;   /* sheet and More titles */
    --text-display: clamp(1.16rem, 5.4vw, 1.42rem); /* date header */
    --text-stat: clamp(1.05rem, 4.8vw, 1.3rem);     /* stat tiles */
    --text-hero: clamp(1.6rem, 7.6vw, 2.05rem);     /* the one big number */
    --weight-medium: 600;
    --weight-semibold: 650;
    --weight-bold: 700;
    --weight-heavy: 900;
    --tracking-caps: .1em;      /* short UPPERCASE labels */
    --tracking-caps-wide: .14em;
    --tracking-title: -.035em;  /* sentence-case titles */
    --tracking-number: -.03em;  /* big tabular numbers */

    /* Space. A 4 px rhythm, plus Kaizen's own page measures. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --gutter: 13px;     /* page side margin on a phone */
    --panel-pad: 14px;  /* inside a panel on a phone (24px wide) */
    --stack: 12px;      /* between panels on a phone (14px wide) */
    --gutter-left: max(var(--gutter), env(safe-area-inset-left, 0px));
    --gutter-right: max(var(--gutter), env(safe-area-inset-right, 0px));

    /* Radii. Nested corners are concentric: inner radius = outer radius - padding. */
    --radius-xs: 6px;     /* tiny marks, day segments */
    --radius-sm: 12px;    /* buttons, fields, chips, icon buttons */
    --radius-md: 14px;    /* cards and rows inside a panel */
    --radius-lg: 20px;    /* panels; tab items (25 - 5 padding) */
    --radius-xl: 25px;    /* tab bar, More panel */
    --radius-sheet: 27px;
    --radius-sigil: 15px; /* the wordmark square */
    --radius-pill: 999px;

    /* Sizes. */
    --target: 44px;         /* the minimum for anything you can press */
    --target-large: 54px;   /* the one primary action, tab items */
    --tabbar-height: 62px;  /* Bevel's bar and + (DJ, 2026-11-29) */
    /* The tab bar's foot: 8px above the bottom safe area, clear of Android's
       gesture bar or three-button bar. On an iPhone it sits 13px down into the
       home indicator's 34px, as Bevel's does (the @supports rule below). */
    --tabbar-bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    --tabbar-clearance: calc(var(--tabbar-height) + var(--tabbar-bottom));
    --sidebar-width: 220px;
    --content-max: 1180px;
    --sheet-width: 510px;
    --z-header: 70;
    --z-tabbar: 90;
    --z-sheet: 95;
    --z-toast: 100;
    --z-skip: 120;

    /* The neutral light and dark that tints, edges and shades mix from. */
    --white: #fff;
    --black: #000;

    /* Glass. Three levels, darker and calmer as they nest. */
    --glass-panel: rgba(13, 14, 20, .47);
    --glass-card: rgba(10, 11, 16, .48);
    --glass-deep: rgba(5, 6, 10, .34);
    --glass-bar: rgba(7, 8, 13, .49);
    /* The header is solid, not glass: on an iPhone Home Screen app, iOS 26 and 27
       paint the status bar and the top of the screen from the top bar's own
       background-color only when that colour is at least 75% opaque and no
       backdrop-filter is on it. A see-through header left a band of the bare
       screen colour over the top of the page (DJ, 2026-11-29).
       --header-top is the header's top edge: its background-color, the colour
       iOS paints the status bar in, and the page's base colour, which iOS
       shows in the gap a pull past the top opens. One colour for all three,
       so nothing at the top of the screen is darker than the header
       (docs/IPHONE.md). The header fades from it to --header-solid. */
    --header-solid: color-mix(in srgb, var(--void) 72%, var(--panel));
    --header-top: color-mix(in srgb, rgb(var(--accent-rgb)) 4.5%, var(--header-solid));
    --glass-sidebar: linear-gradient(180deg, rgba(18, 21, 27, .69), rgba(8, 8, 13, .78));
    --glass-sheen: linear-gradient(145deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .018));
    /* The wordmark square: a gradient between the palette's two ends. The plain
       palettes make it one solid colour. */
    --sigil-fill: linear-gradient(145deg, rgba(var(--secondary-rgb), .78), rgba(var(--sigil-rgb), .58));
    /* The accent panel's wash, a picked switch's fill and how strong the
       accent's glow is (rings, the solid button: 1 full, 0 none). The plain
       palettes drop the wash and the glow and pick with a flat tint. */
    --accent-wash: linear-gradient(145deg, rgba(var(--accent-rgb), .1), rgba(var(--secondary-rgb), .05));
    --picked-wash: linear-gradient(135deg, rgba(var(--accent-rgb), .18), rgba(var(--secondary-rgb), .22));
    --glow: 1;
    --glass-sheen-soft: linear-gradient(145deg, rgba(255, 255, 255, .065), rgba(255, 255, 255, .012));
    --glass-edge: rgba(255, 255, 255, .12);
    --glass-edge-soft: rgba(255, 255, 255, .115);
    --blur-panel: blur(26px) saturate(132%);
    --blur-bar: blur(26px) saturate(140%);
    --blur-float: blur(28px) saturate(145%);
    --shadow-panel: inset 0 1px rgba(255, 255, 255, .055), 0 20px 54px rgba(0, 0, 0, .22);
    --shadow-card: inset 0 1px rgba(255, 255, 255, .045), 0 16px 42px rgba(0, 0, 0, .18);
    --shadow-bar: 0 8px 28px rgba(0, 0, 0, .22);
    --shadow-float: 0 -12px 36px rgba(0, 0, 0, .3), inset 0 1px rgba(255, 255, 255, .045); /* upward, so it never darkens the screen's foot */
    --shadow-sheet: 0 25px 90px rgba(0, 0, 0, .53);
    --shadow-toast: 0 16px 40px rgba(0, 0, 0, .45);
    --shadow-pressed: 0 3px 12px rgba(0, 0, 0, .13), inset 0 1px rgba(255, 255, 255, .07);
    --scrim: rgba(4, 4, 12, .44);
    --track: rgba(255, 255, 255, .07);
    --placeholder: rgba(255, 255, 255, .22);

    /* Motion. It confirms what a finger did; nothing moves on its own. */
    --dur-quick: 140ms;   /* hover, switches */
    --dur-base: 200ms;    /* section switch, small state changes */
    --dur-cancel: 220ms;  /* a released hold falls back */
    --dur-sweep: 720ms;   /* the energy sweep when a hold completes */
    --dur-hold: 1200ms;   /* hold to log or to confirm */
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    --ease-sweep: cubic-bezier(.22, .82, .2, 1);
    --ease-wave: cubic-bezier(.18, .58, .24, 1);
    --press-scale: .985;

    /* Colour roles, derived from the palette. A palette may override any. */
    --secondary: rgb(var(--secondary-rgb));
    --over: var(--secondary);  /* over a target: a fact, never red */
    --good: var(--positive);
    --okay: var(--amber);
    --bad: var(--danger);
    --focus: var(--accent);
    --secondary-text: var(--secondary); /* the secondary as text; each palette sets a lighter step */
  }

  /* iOS and iPadOS only: -webkit-touch-callout exists in no other browser. The
     iPhone's home indicator is a thin line inside its 34px safe area, so the bar
     may sit 13px into it. Android's system bars fill their safe area, so the
     default above keeps the bar out of it (docs/ANDROID.md). */
  @supports (-webkit-touch-callout: none) {
    :root { --tabbar-bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) - 13px)); }
  }
}

/* ========================================================================== */
/* Every colour lives here. The plain :root holds what every palette shares;
   each preset block sets the colours that change. Athletic (Mint) is also the
   bare :root, so a page without data-palette still has a palette. An app picks
   its default with <html data-palette="..."> and theme-init.js applies a saved
   choice before the first paint. The ids must match window.djcns.palettes in
   theme-init.js. Values approved by DJ on 2026-11-28 (six themes); Teal, Gold, Rose and Sand
   added at DJ's ask on 2026-11-30, for ten. Light and Dark, the two plain
   palettes, added at DJ's ask on 2026-11-30 (see the note above them). */
@layer djcns.palette {
  /* Shared by every palette. */
  :root {
    color-scheme: dark;
    --void-soft: #10111a;
    --panel: #171822;
    --panel-bright: #22232f;
    --ink: #f7f8fb;
    --muted: #9c9dab;
    --muted-bright: #c7c9d2;
    --line: rgba(255, 255, 255, .105);
    --line-strong: rgba(255, 255, 255, .21);
    --blue: #8796ff;
    --pink: #ff577c;
    --amber: #ffad55;
    --purple: #9b83ff;
    --positive: #4af08d;
    --danger: #fb7188;
    --danger-rgb: 251, 113, 136;
    /* Data colours stay the same in every palette, so a series (protein,
       carbs, fat...) keeps one colour whatever the theme. Chart series use
       them in this order. Every pair passes colour-blind checks. */
    --data-1: #70f2b2;
    --data-2: #8796ff;
    --data-3: #ffad55;
    --data-4: #ff7ab0;
    --data-5: #6fd0ff;
    /* The waking-day header: one colour per part of the day. */
    --phase-morning: #6fd0ff;
    --phase-afternoon: #70f2b2;
    --phase-evening: #9b83ff;
    /* The warning orange, the same in every palette (DJ, 2026-11-30). The sign-in
       banner (offline/connection.css) tints the header's colour with it and writes
       its action in it; --warning-ink is the dark ink for anything solid orange. */
    --warning: #ff9f0a;
    --warning-ink: #1f1300;
  }
  /* Mint */
  :root, :root[data-palette="athletic"] {
    --void: #07070d; --accent: #70f2b2; --tab-accent: #8ff5c2; --accent-ink: #06130f;
    --accent-rgb: 112, 242, 178; --secondary-rgb: 155, 131, 255; --secondary-text: #b6aaff;
    --sigil-rgb: 58, 235, 139; --sigil-shadow-rgb: 86, 73, 206;
    --atmosphere-a: 24, 187, 116; --atmosphere-b: 105, 72, 220; --atmosphere-c: 189, 40, 78; --atmosphere-d: 28, 113, 96;
    --backdrop-a: #071312; --backdrop-b: #11101f; --backdrop-c: #100a12; --backdrop-d: #050508;
  }
  /* Ocean */
  :root[data-palette="athletic-ocean"] {
    --void: #05080f; --accent: #85c4ff; --tab-accent: #acd6ff; --accent-ink: #061727;
    --accent-rgb: 133, 196, 255; --secondary-rgb: 49, 199, 213; --secondary-text: #3bcddb;
    --sigil-rgb: 98, 180, 255; --sigil-shadow-rgb: 0, 113, 122;
    --atmosphere-a: 0, 123, 204; --atmosphere-b: 0, 132, 143; --atmosphere-c: 88, 79, 191; --atmosphere-d: 0, 97, 127;
    --backdrop-a: #071219; --backdrop-b: #09131f; --backdrop-c: #090c15; --backdrop-d: #040508;
  }
  /* Violet */
  :root[data-palette="athletic-dusk"] {
    --void: #0d060a; --accent: #c59dff; --tab-accent: #d3b8ff; --accent-ink: #191125;
    --accent-rgb: 197, 157, 255; --secondary-rgb: 229, 87, 177; --secondary-text: #ff89cf;
    --sigil-rgb: 186, 134, 254; --sigil-shadow-rgb: 167, 32, 123;
    --atmosphere-a: 133, 82, 194; --atmosphere-b: 180, 36, 134; --atmosphere-c: 61, 93, 207; --atmosphere-d: 114, 78, 125;
    --backdrop-a: #150d17; --backdrop-b: #1c0d15; --backdrop-c: #0f0a13; --backdrop-d: #070406;
  }
  /* Sunset */
  :root[data-palette="athletic-sunset"] {
    --void: #0c060b; --accent: #ffa566; --tab-accent: #ffc299; --accent-ink: #241104;
    --accent-rgb: 255, 165, 102; --secondary-rgb: 193, 123, 234; --secondary-text: #d898ff;
    --sigil-rgb: 255, 139, 38; --sigil-shadow-rgb: 134, 54, 175;
    --atmosphere-a: 202, 104, 0; --atmosphere-b: 133, 58, 171; --atmosphere-c: 170, 41, 95; --atmosphere-d: 130, 69, 47;
    --backdrop-a: #190d08; --backdrop-b: #1a0d19; --backdrop-c: #13090e; --backdrop-d: #060507;
  }
  /* Forest */
  :root[data-palette="athletic-forest"] {
    --void: #080e0b; --accent: #9cdea7; --tab-accent: #b8ecc1; --accent-ink: #0b1a10;
    --accent-rgb: 156, 222, 167; --secondary-rgb: 229, 196, 123; --secondary-text: #e5c47b;
    --sigil-rgb: 104, 194, 136; --sigil-shadow-rgb: 72, 123, 76;
    --atmosphere-a: 57, 158, 105; --atmosphere-b: 125, 115, 46; --atmosphere-c: 98, 109, 44; --atmosphere-d: 31, 108, 90;
    --backdrop-a: #0a1710; --backdrop-b: #15190f; --backdrop-c: #11180e; --backdrop-d: #050906;
  }
  /* Graphite */
  :root[data-palette="athletic-graphite"] {
    --void: #07080b; --accent: #cfdceb; --tab-accent: #dfe9f4; --accent-ink: #13161a;
    --accent-rgb: 207, 220, 235; --secondary-rgb: 167, 167, 199; --secondary-text: #b4b4d4;
    --sigil-rgb: 187, 205, 221; --sigil-shadow-rgb: 83, 82, 107;
    --atmosphere-a: 104, 126, 141; --atmosphere-b: 96, 95, 127; --atmosphere-c: 73, 83, 99; --atmosphere-d: 62, 81, 87;
    --backdrop-a: #0d1012; --backdrop-b: #111116; --backdrop-c: #0b0c0f; --backdrop-d: #040506;
  }
  /* Teal */
  :root[data-palette="athletic-teal"] {
    --void: #020a0b; --accent: #42e5e0; --tab-accent: #8ff2ee; --accent-ink: #001b1a;
    --accent-rgb: 66, 229, 224; --secondary-rgb: 164, 216, 84; --secondary-text: #a4d854;
    --sigil-rgb: 0, 213, 209; --sigil-shadow-rgb: 77, 112, 0;
    --atmosphere-a: 0, 147, 144; --atmosphere-b: 89, 128, 0; --atmosphere-c: 0, 106, 157; --atmosphere-d: 20, 102, 85;
    --backdrop-a: #061410; --backdrop-b: #0e1506; --backdrop-c: #030f0e; --backdrop-d: #050603;
  }
  /* Gold */
  :root[data-palette="athletic-gold"] {
    --void: #0d0704; --accent: #f5d15c; --tab-accent: #ffe79c; --accent-ink: #1d1500;
    --accent-rgb: 245, 209, 92; --secondary-rgb: 254, 130, 92; --secondary-text: #ff9878;
    --sigil-rgb: 235, 191, 0; --sigil-shadow-rgb: 172, 52, 0;
    --atmosphere-a: 169, 136, 0; --atmosphere-b: 191, 59, 0; --atmosphere-c: 163, 39, 73; --atmosphere-d: 116, 79, 32;
    --backdrop-a: #170f06; --backdrop-b: #1e0d08; --backdrop-c: #140908; --backdrop-d: #080504;
  }
  /* Rose */
  :root[data-palette="athletic-rose"] {
    --void: #0b060c; --accent: #fd9ac6; --tab-accent: #ffbad7; --accent-ink: #230e18;
    --accent-rgb: 253, 154, 198; --secondary-rgb: 107, 185, 248; --secondary-text: #71bfff;
    --sigil-rgb: 248, 127, 184; --sigil-shadow-rgb: 0, 104, 165;
    --atmosphere-a: 193, 70, 133; --atmosphere-b: 0, 110, 174; --atmosphere-c: 115, 71, 175; --atmosphere-d: 118, 70, 102;
    --backdrop-a: #170d14; --backdrop-b: #06131f; --backdrop-c: #0a0c15; --backdrop-d: #030608;
  }
  /* Sand */
  :root[data-palette="athletic-sand"] {
    --void: #0a0806; --accent: #ebd3b4; --tab-accent: #f6e5ce; --accent-ink: #1a1510;
    --accent-rgb: 235, 211, 180; --secondary-rgb: 217, 163, 144; --secondary-text: #dfa996;
    --sigil-rgb: 223, 194, 156; --sigil-shadow-rgb: 110, 76, 64;
    --atmosphere-a: 145, 125, 94; --atmosphere-b: 129, 88, 73; --atmosphere-c: 102, 80, 63; --atmosphere-d: 83, 77, 58;
    --backdrop-a: #120f0b; --backdrop-b: #17100d; --backdrop-c: #0f0b09; --backdrop-d: #060504;
  }

  /* The two plain palettes (DJ, 2026-11-30): "a generic light and dark mode",
     with no colour gradient, for people who find the colours too much. They
     look like an iPhone's own day and night modes: a white or black page, grey
     panels, black or white text, and Apple's system blue (its high-contrast step) as the
     one accent, for buttons, focus and the current tab. No glow, no tint, no
     sheen. theme-init.js marks them plain and sets html[data-scheme]
     ("light" or "dark") from them, so any stylesheet can key a fix on
     :root[data-scheme="light"] whatever attribute its palettes use. */
  /* Light. The page is white, so every colour that is text or a mark is a
     darker step of the same hue: data and status colours keep their hue and
     meaning, and reach 4.5:1 on the greyest surface (a sheet, #ebebf0). */
  :root[data-palette="athletic-light"] {
    color-scheme: light;
    --void: #ffffff; --accent: #0040dd; --tab-accent: #0040dd; --accent-ink: #ffffff;
    --accent-rgb: 0, 64, 221; --secondary-rgb: 112, 68, 212; --secondary-text: #5b36c4;
    --sigil-rgb: 0, 64, 221; --sigil-shadow-rgb: 0, 0, 0;
    --atmosphere-a: 255, 255, 255; --atmosphere-b: 255, 255, 255; --atmosphere-c: 255, 255, 255; --atmosphere-d: 255, 255, 255;
    --backdrop-a: #ffffff; --backdrop-b: #ffffff; --backdrop-c: #ffffff; --backdrop-d: #ffffff;
    --void-soft: #f7f7f8;
    --panel: #f2f2f7;
    --panel-bright: #ffffff;
    --ink: #000000;
    --muted: #636366;
    --muted-bright: #3a3a3c;
    --line: rgba(60, 60, 67, .16);
    --line-strong: rgba(60, 60, 67, .3);
    --blue: #4b4fd6;
    --pink: #c8174a;
    --amber: #9a5300;
    --purple: #7044d4;
    --positive: #146b35;
    --danger: #c8102e;
    --danger-rgb: 200, 16, 46;
    --data-1: #08704e;
    --data-2: #4b4fd6;
    --data-3: #9a5300;
    --data-4: #c2185b;
    --data-5: #006b9c;
    --phase-morning: #006b9c;
    --phase-afternoon: #08704e;
    --phase-evening: #7044d4;
    --warning: #a84700;
    --warning-ink: #ffffff;
    --glass-panel: #f2f2f7;
    --glass-card: rgba(255, 255, 255, .86);
    --glass-deep: rgba(118, 118, 128, .08);
    --glass-bar: rgba(249, 249, 251, .86);
    --glass-sidebar: #f7f7f8;
    --glass-edge: rgba(60, 60, 67, .12);
    --glass-edge-soft: rgba(60, 60, 67, .1);
    --shadow-panel: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-bar: 0 4px 16px rgba(0, 0, 0, .08);
    --shadow-float: 0 -6px 20px rgba(0, 0, 0, .08);
    --shadow-sheet: 0 20px 60px rgba(0, 0, 0, .18);
    --shadow-toast: 0 10px 30px rgba(0, 0, 0, .16);
    --shadow-pressed: 0 2px 8px rgba(0, 0, 0, .08);
    --scrim: rgba(0, 0, 0, .28);
    --track: rgba(60, 60, 67, .12);
    --placeholder: rgba(60, 60, 67, .45);
    /* Plain: no tint on the header, no gradient, sheen or glow. */
    --header-top: var(--header-solid);
    --sigil-fill: rgb(var(--sigil-rgb));
    --accent-wash: linear-gradient(transparent, transparent);
    --picked-wash: linear-gradient(rgba(var(--accent-rgb), .14), rgba(var(--accent-rgb), .14));
    --glow: 0;
    --glass-sheen: linear-gradient(transparent, transparent);
    --glass-sheen-soft: linear-gradient(transparent, transparent);
  }
  /* Dark. The page is black and the panels the iPhone's dark grey; the shared
     text, data and status colours are already made for a dark page. */
  :root[data-palette="athletic-dark"] {
    --void: #000000; --accent: #4fa5ff; --tab-accent: #4fa5ff; --accent-ink: #000000;
    --accent-rgb: 79, 165, 255; --secondary-rgb: 155, 131, 255; --secondary-text: #b6aaff;
    --sigil-rgb: 79, 165, 255; --sigil-shadow-rgb: 0, 0, 0;
    --atmosphere-a: 0, 0, 0; --atmosphere-b: 0, 0, 0; --atmosphere-c: 0, 0, 0; --atmosphere-d: 0, 0, 0;
    --backdrop-a: #000000; --backdrop-b: #000000; --backdrop-c: #000000; --backdrop-d: #000000;
    --void-soft: #0e0e10;
    --panel: #1c1c1e;
    --panel-bright: #2c2c2e;
    --glass-panel: #1c1c1e;
    --glass-card: rgba(255, 255, 255, .05);
    --glass-deep: rgba(0, 0, 0, .3);
    --glass-bar: rgba(22, 22, 24, .86);
    --glass-sidebar: #0e0e10;
    --glass-edge: rgba(255, 255, 255, .1);
    --glass-edge-soft: rgba(255, 255, 255, .08);
    --scrim: rgba(0, 0, 0, .55);
    /* Plain: no tint on the header, no gradient, sheen or glow. */
    --header-top: var(--header-solid);
    --sigil-fill: rgb(var(--sigil-rgb));
    --accent-wash: linear-gradient(transparent, transparent);
    --picked-wash: linear-gradient(rgba(var(--accent-rgb), .14), rgba(var(--accent-rgb), .14));
    --glow: 0;
    --glass-sheen: linear-gradient(transparent, transparent);
    --glass-sheen-soft: linear-gradient(transparent, transparent);
  }
}

/* ========================================================================== */
@layer djcns.base {
  *, *::before, *::after { box-sizing: border-box; }
  [hidden] { display: none !important; }

  /* The atmosphere is the root's background, so it paints the whole screen,
     the home indicator area included, however short the page is. */
  html {
    min-width: 320px;
    -webkit-text-size-adjust: 100%;
    scrollbar-width: none;
    scroll-padding-top: calc(var(--header-height, 91px) + var(--conn-banner-height, 0px) + var(--space-3));
    scroll-padding-bottom: calc(var(--tabbar-clearance) + var(--space-8));
    background:
      radial-gradient(ellipse 72% 42% at -8% -4%, rgba(var(--atmosphere-a), .38), transparent 68%),
      radial-gradient(ellipse 75% 47% at 104% 4%, rgba(var(--atmosphere-b), .42), transparent 69%),
      radial-gradient(ellipse 80% 56% at 73% 58%, rgba(var(--atmosphere-c), .24), transparent 72%),
      radial-gradient(ellipse 68% 45% at 8% 93%, rgba(var(--atmosphere-d), .22), transparent 73%),
      linear-gradient(165deg, var(--backdrop-a) 0%, var(--backdrop-b) 33%, var(--backdrop-c) 67%, var(--backdrop-d) 100%);
    /* Hidden under the gradients. iOS shows only this colour (never a gradient)
       in the gap a pull past the top or the foot opens: the header's top in
       the upper half of the page, so the header seems to stretch, and --void
       in the lower half, where the page's foot fades into it. theme-init.js
       sets html.is-lower-half as the page scrolls. */
    background-color: var(--header-top);
    background-attachment: scroll;
    color: var(--ink);
    font-family: var(--font-sans);
    font-synthesis: none;
  }
  html.is-lower-half { background-color: var(--void); }
  html::-webkit-scrollbar { display: none; width: 0; height: 0; }

  /* Home Screen app on iOS 26 (WebKit bug 301108): with a see-through status
     bar, a page shorter than the screen gets a viewport one status bar short,
     and iOS draws nothing below it, leaving a bare strip under the tab bar.
     A root at least as tall as the screen gets the whole screen back; min()
     keeps the page from scrolling where the viewport is already full or the
     top inset is 0. iOS keeps the status bar style an app was added with, so
     this must work for both. theme-init.js sets html.standalone before paint. */
  html.standalone { min-height: min(100lvh, calc(100% + env(safe-area-inset-top, 0px))); }
  @media (display-mode: standalone) {
    html { min-height: min(100lvh, calc(100% + env(safe-area-inset-top, 0px))); }
  }

  /* The page's foot fades into --void, the colour iOS shows wherever the page
     is not drawn and in the gap a pull past the foot opens, so the bottom edge
     never shows a seam. The page ends at the body's foot: nothing may reach
     below it (see .visually-hidden), or the page scrolls past its own
     background and iOS shows the bare root colour there as a band
     (docs/IPHONE.md, "The foot of the screen"). */
  body {
    min-height: 100dvh;
    margin: 0;
    overflow-x: clip;
    color: var(--ink);
    background: linear-gradient(180deg, transparent calc(100% - 140px), var(--void));
    font-size: var(--text-body);
    line-height: 1.45;
  }

  /* A long press never selects text or opens a callout; fields still do. */
  body, body * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  input, textarea, select, [contenteditable="true"], .selectable { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
  button, input, select, textarea { font: inherit; color: inherit; }
  /* Nothing zooms (docs/ZOOM.md): iOS zooms into a focused field under 16 px,
     and a control that allowed a pinch would let one through. */
  input, select, textarea { font-size: var(--text-input); }
  button, a, input, select, label, summary, [role="button"] { touch-action: pan-x pan-y; -webkit-tap-highlight-color: transparent; }
  button { cursor: pointer; }
  button:disabled { cursor: not-allowed; }
  a { color: inherit; }
  svg { overflow: visible; }
  /* Script focus lands on the page, a sheet or a panel (tabindex="-1") so screen
     readers start there. Those never draw the ring: on a page it frames the
     whole screen in thin accent lines (Hokyu on iPhone, 2026-11-28). */
  :is(a, button, input, textarea, select, summary, [tabindex]:not([tabindex="-1"])):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

  /* Read by screen readers, never seen. The -1px margin keeps one at the end of
     the body (the live announcer) inside the page; without it, its box hangs
     below the body's foot and the page scrolls that far past its own
     background. Kaizen's announcer, a <p> with a 1em margin, left a 17 px
     band of the root colour at the foot of every page (DJ, 2026-11-30). */
  .visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px !important; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .skip-link { position: fixed; z-index: var(--z-skip); top: 10px; left: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); font-weight: var(--weight-semibold); transform: translateY(-200%); }
  .skip-link:focus-visible { transform: none; }
  .num { font-variant-numeric: tabular-nums; }
  /* Measures the safe-area insets for the display line (ui.js displayLine()). */
  .inset-probe { position: fixed; top: 0; left: 0; width: 0; height: 0; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); visibility: hidden; pointer-events: none; }

  /* Fixed backgrounds judder on iOS; only wide screens get them. */
  @media (min-width: 901px) {
    html { background-attachment: fixed; }
  }

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

/* ========================================================================== */
@layer djcns.components {
  /* Shell: one phone column with a floating tab bar; a labelled sidebar from 901 px. */
  .shell { min-width: 0; }
  .sidebar { display: none; }
  .app { min-width: 0; padding-bottom: calc(var(--tabbar-clearance) + var(--space-6)); }
  .app-main { display: grid; min-width: 0; gap: var(--stack); margin-inline: var(--gutter-left) var(--gutter-right); padding-top: 10px; align-content: start; outline: none; }
  .boot { padding: 40px var(--gutter-right) 40px var(--gutter-left); color: var(--muted); }

  /* One solid bar at the very top of the page. With no status bar style in
     index.html, iOS 26 paints the status bar in its background-color
     (--header-top, the colour of its top edge), so the bar seems to run up
     under the clock. No backdrop-filter here: it makes iOS use the bare screen
     colour instead. Where an older install still runs the page under the
     status bar, the top padding covers it. */
  .app-header {
    position: sticky;
    z-index: var(--z-header);
    top: 0;
    display: grid;
    gap: var(--space-2);
    padding: max(11px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px));
    border-bottom: 1px solid var(--line);
    background-color: var(--header-top);
    background-image: linear-gradient(180deg, transparent, var(--header-solid) 70%);
    box-shadow: var(--shadow-bar);
    isolation: isolate;
  }
  .app-header__actions { display: none; }

  /* Date header: weekday in the accent, date in ink, both heavy capitals. */
  .date-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-4); align-items: end; }
  .date-head__day { display: flex; flex-wrap: wrap; min-width: 0; column-gap: 9px; row-gap: 2px; align-items: baseline; }
  .date-head__weekday,
  .date-head__date { font-size: var(--text-display); font-weight: var(--weight-heavy); line-height: 1; letter-spacing: .045em; text-transform: uppercase; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .date-head__weekday { color: var(--accent); }
  .date-head__zone { color: var(--muted-bright); font-size: var(--text-label); font-weight: 800; letter-spacing: var(--tracking-caps-wide); line-height: 1; text-transform: uppercase; white-space: nowrap; }

  /* Page title row: the title, optional actions. A sub-page (.page-head--sub)
     leads with its back button on a line of its own, above the title. */
  .page-head { display: flex; min-width: 0; gap: var(--space-2); align-items: center; justify-content: space-between; }
  .page-head--sub { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--space-3); }
  .page-head--sub > .back-btn { grid-column: 1 / -1; justify-self: start; }
  .page-head h1,
  .page-title { min-width: 0; margin: 0; font-size: var(--text-title); font-weight: 620; line-height: 1.2; letter-spacing: var(--tracking-title); }
  .page-head__actions { display: flex; gap: var(--space-2); }

  /* Line icons: 24-unit grid, 1.7 stroke, round ends, drawn in currentColor. */
  .nav-icon svg,
  .icon { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

  /* Wordmark: the app's kanji on the gradient square, then its name in capitals. */
  .wordmark { display: inline-flex; width: 100%; padding: 0 6px 25px; gap: var(--space-3); align-items: center; border-bottom: 1px solid var(--line); text-decoration: none; }
  .wordmark__sigil {
    display: grid;
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--white) 17%, transparent);
    border-radius: var(--radius-sigil);
    background: var(--sigil-fill);
    color: var(--white);
    box-shadow: 0 10px 30px rgba(var(--sigil-shadow-rgb), .25);
    font-family: var(--font-mark);
    font-size: 1.38rem;
  }
  .wordmark__text strong,
  .wordmark__text small { display: block; }
  .wordmark__text strong { font-size: 1rem; letter-spacing: var(--tracking-caps); }
  .wordmark__text small { margin-top: 5px; color: var(--muted); font-size: var(--text-label); letter-spacing: var(--tracking-caps); }

  .sidebar-nav { display: grid; margin-top: 10px; gap: 5px; }
  .sidebar-nav a { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); min-height: 57px; padding: 10px; gap: 13px; align-items: center; border-radius: 15px; color: var(--muted-bright); text-decoration: none; transition: background var(--dur-quick) ease; }
  .sidebar-nav a::after { position: absolute; top: 14px; right: 1px; bottom: 14px; width: 3px; border-radius: 3px; background: transparent; content: ""; }
  .sidebar-nav a:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
  .sidebar-nav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--ink); }
  .sidebar-nav a[aria-current="page"]::after { background: var(--accent); box-shadow: 0 0 13px var(--accent); }
  .nav-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 11px; color: var(--accent); }
  .nav-icon svg { width: 22px; height: 22px; }
  .sidebar-nav a[aria-current="page"] .nav-icon { width: 42px; height: 42px; background: color-mix(in srgb, var(--accent) 14%, transparent); }
  .nav-copy { min-width: 0; font-size: var(--text-item); font-weight: var(--weight-semibold); letter-spacing: -.018em; }

  /* Glass surfaces. Level 1 panel; level 2 card; level 3 well. Only panels blur. */
  .panel {
    display: grid;
    min-width: 0;
    padding: var(--panel-pad);
    gap: var(--space-3);
    align-content: start;
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius-lg);
    background-color: var(--glass-panel);
    background-image: var(--glass-sheen);
    box-shadow: var(--shadow-panel);
    -webkit-backdrop-filter: var(--blur-panel);
    backdrop-filter: var(--blur-panel);
  }
  .panel--accent { border-color: rgba(var(--accent-rgb), .42); background-image: var(--accent-wash); }
  .panel__head { display: flex; min-width: 0; gap: var(--space-3); align-items: baseline; justify-content: space-between; }
  .panel__head h2 { min-width: 0; margin: 0; font-size: var(--text-title); font-weight: var(--weight-bold); letter-spacing: -.04em; line-height: 1.15; text-transform: uppercase; }
  .panel__head > span { flex: 0 0 auto; color: var(--muted); font-size: var(--text-label); font-weight: var(--weight-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
  .card { display: grid; min-width: 0; padding: 12px 14px; gap: var(--space-1); border: 1px solid var(--glass-edge-soft); border-radius: 16px; background-color: var(--glass-card); background-image: var(--glass-sheen-soft); box-shadow: var(--shadow-card); }
  .well { display: grid; min-width: 0; padding: 11px 13px; gap: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--glass-deep); }
  .empty { display: grid; gap: 10px; justify-items: start; padding: 18px; border: 1px dashed var(--line-strong); border-radius: 18px; }
  .notice { margin: 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent); border-radius: var(--radius-md); background: color-mix(in srgb, var(--amber) 8%, transparent); color: var(--amber); font-size: var(--text-body); line-height: 1.45; }

  /* Text. Capitals for short labels only; sentence case for anything you read. */
  .kicker { margin: 0; color: var(--accent); font-size: 11px; font-weight: var(--weight-bold); letter-spacing: .15em; text-transform: uppercase; }
  .eyebrow { margin: 0; color: var(--muted-bright); font-size: var(--text-label); font-weight: var(--weight-bold); letter-spacing: .13em; text-transform: uppercase; }
  .copy { margin: 0; color: var(--muted-bright); font-size: var(--text-body); line-height: 1.5; }
  .copy--muted { color: var(--muted); }
  .copy strong { color: var(--ink); font-weight: var(--weight-semibold); }
  .footnote { margin: 4px 0; color: var(--muted-bright); font-size: var(--text-small); line-height: 1.6; }
  .unit { color: var(--muted-bright); font-size: .62em; font-weight: var(--weight-medium); letter-spacing: 0; }

  /* Buttons. One primary per view; everything else quiet. */
  .btn {
    display: inline-flex;
    min-height: var(--target);
    padding: 10px 15px;
    gap: var(--space-2);
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--ink) 5%, transparent);
    color: var(--ink);
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
  }
  .btn:active { transform: scale(var(--press-scale)); }
  .btn--primary { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 19%, var(--panel)); }
  .btn--solid { border-color: transparent; background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 30px rgba(var(--accent-rgb), calc(.18 * var(--glow))); }
  .btn--danger { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 7%, transparent); color: var(--danger); }
  .btn--quiet { border-color: transparent; background: none; color: var(--muted-bright); }
  .btn--wide { width: 100%; }
  .btn--huge { min-height: var(--target-large); font-size: var(--text-lead); }
  .btn:disabled,
  .btn[aria-disabled="true"] { border-color: var(--line); background: color-mix(in srgb, var(--ink) 5%, transparent); box-shadow: none; color: var(--muted); opacity: .45; }
  .btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); }
  .icon-btn { display: grid; width: var(--target); height: var(--target); flex: 0 0 auto; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--ink) 4%, transparent); color: var(--muted-bright); font-size: 1.15rem; line-height: 1; }
  .icon-btn svg { width: 22px; height: 22px; }
  .back-btn { display: inline-flex; min-height: var(--target); padding: 0 13px 0 9px; gap: var(--space-1); align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--ink) 4%, transparent); color: var(--muted-bright); font-size: var(--text-small); font-weight: var(--weight-semibold); text-decoration: none; }

  /* Section switch: Kaizen's pill row for subpages of one tab. */
  .section-switch { display: flex; gap: var(--space-1); padding: var(--space-1); border: 1px solid var(--line); border-radius: 15px; background: color-mix(in srgb, var(--panel) 70%, transparent); }
  .section-switch :is(a, button) { display: flex; min-width: 0; min-height: var(--target); padding: 6px 12px; flex: 1; align-items: center; justify-content: center; border: 0; border-radius: 11px; background: none; color: var(--muted-bright); font-size: var(--text-body); font-weight: var(--weight-semibold); text-decoration: none; transition: background var(--dur-base), color var(--dur-base); }
  .section-switch :is(a[aria-current], button[aria-pressed="true"]) { background: color-mix(in srgb, var(--ink) 13%, transparent); color: var(--ink); box-shadow: var(--shadow-pressed); }

  /* Choices: segmented buttons and chips share one pressed look. */
  .segmented { display: flex; flex-wrap: wrap; gap: 6px; }
  .segmented button { min-width: 52px; min-height: var(--target); padding: 8px 10px; flex: 1 1 auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: none; color: var(--muted-bright); font-size: var(--text-small); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
  .chip { display: inline-flex; min-width: var(--target); min-height: var(--target); padding: 0 13px; gap: var(--space-2); align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: none; color: var(--muted-bright); font-size: var(--text-small); font-weight: var(--weight-medium); }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .segmented button[aria-pressed="true"],
  .chip[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--ink); }

  /* Switch: role="switch" with aria-checked. */
  .toggle-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; }
  .switch { position: relative; width: 64px; height: var(--target); flex: 0 0 auto; padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; }
  .switch::before { position: absolute; inset: 3px 0; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: color-mix(in srgb, var(--ink) 6%, transparent); content: ""; }
  .switch::after { position: absolute; top: 7px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: var(--muted-bright); content: ""; transition: transform var(--dur-quick) ease; }
  .switch[aria-checked="true"]::before { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 35%, var(--panel)); }
  .switch[aria-checked="true"]::after { background: var(--accent); transform: translateX(26px); }

  /* Fields. 16 px text so iOS never zooms on focus. */
  .field { display: grid; gap: 7px; }
  .field > span { color: var(--muted-bright); font-size: var(--text-small); }
  .text-input,
  .select,
  .textarea { width: 100%; min-width: 0; min-height: var(--target); padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--void) 70%, transparent); color: var(--ink); font-size: var(--text-input); }
  .textarea { min-height: 88px; resize: vertical; line-height: 1.4; }
  :is(.text-input, .select, .textarea)::placeholder { color: var(--placeholder); }
  :is(.text-input, .select, .textarea):focus { border-color: var(--accent); outline: none; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
  .setting { display: grid; padding: var(--space-3) 0; gap: 10px; border-top: 1px solid var(--line); }
  .setting:first-of-type { padding-top: 0; border-top: 0; }
  .setting__label { display: grid; gap: var(--space-1); }
  .setting__label strong { font-size: var(--text-body); font-weight: var(--weight-semibold); }
  .setting__label small { color: var(--muted-bright); font-size: var(--text-small); line-height: 1.45; }

  /* Stepper: big minus and plus around a big number, for logging with a thumb. */
  .stepper { display: grid; grid-template-columns: 60px minmax(0, 1fr) 60px; gap: var(--space-2); align-items: stretch; }
  .stepper__btn { min-height: 64px; border: 1px solid var(--line); border-radius: var(--radius-md); background: color-mix(in srgb, var(--ink) 5%, transparent); font-size: 1.7rem; font-weight: 400; line-height: 1; }
  .stepper__btn:active { background: rgba(var(--accent-rgb), .18); }
  .stepper__field { position: relative; display: grid; min-width: 0; }
  .stepper__field input { width: 100%; min-width: 0; height: 64px; padding: 0 44px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: color-mix(in srgb, var(--void) 70%, transparent); color: var(--ink); font-size: 2rem; font-weight: var(--weight-semibold); letter-spacing: -.04em; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
  .stepper__field input::-webkit-inner-spin-button,
  .stepper__field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .stepper__field input:focus { border-color: var(--accent); outline: none; }
  .stepper__unit { position: absolute; right: 12px; bottom: 10px; color: var(--muted-bright); font-size: var(--text-label); font-weight: var(--weight-bold); letter-spacing: .08em; pointer-events: none; text-transform: uppercase; }

  /* Numbers: tabular, units small and muted. */
  .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
  .stats--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { display: grid; min-width: 0; padding: 11px 12px; gap: 5px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--glass-deep); }
  .stat strong { display: flex; min-width: 0; flex-wrap: wrap; column-gap: .2em; align-items: baseline; font-size: var(--text-stat); font-weight: var(--weight-semibold); line-height: 1.15; letter-spacing: var(--tracking-number); font-variant-numeric: tabular-nums; }
  .stat > span { color: var(--muted-bright); font-size: var(--text-label); font-weight: var(--weight-bold); letter-spacing: .09em; text-transform: uppercase; }
  .hero-number { font-size: var(--text-hero); font-weight: var(--weight-semibold); line-height: 1; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
  .is-over { color: var(--over); }

  /* Progress: a ring (SVG circles) and a bar. Over target turns --over, never red. */
  .ring { display: block; width: 100%; height: auto; }
  .ring__track { fill: none; stroke: var(--track); stroke-width: 10; }
  .ring__fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), calc(.45 * var(--glow)))); }
  .ring.is-over .ring__fill { stroke: var(--over); filter: none; }
  .bar { --bar: var(--accent); height: 7px; overflow: hidden; border-radius: var(--radius-pill); background: var(--track); }
  .bar > i { display: block; height: 100%; border-radius: inherit; background: var(--bar); }
  .bar.is-over > i { background: var(--over); }

  /* Badges: a word on a tinted pill. Colour is never the only signal. */
  .badge { --badge: var(--accent); display: inline-flex; padding: 1px 8px; align-items: center; border: 1px solid color-mix(in srgb, var(--badge) 55%, transparent); border-radius: var(--radius-pill); background: color-mix(in srgb, var(--badge) 13%, transparent); color: var(--badge); font-size: var(--text-label); font-weight: 750; letter-spacing: .05em; line-height: 1.6; text-transform: uppercase; white-space: nowrap; }
  .badge--good { --badge: var(--good); }
  .badge--okay { --badge: var(--okay); }
  .badge--bad { --badge: var(--bad); }
  .badge--over { --badge: var(--over); }
  .badge--muted { --badge: var(--muted-bright); }

  /* Lists: rows on card glass, or quiet history rows on the deep well. */
  .list { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
  .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; min-height: 64px; padding: 12px 14px; gap: var(--space-3); align-items: center; border: 1px solid var(--glass-edge-soft); border-radius: 16px; background-color: var(--glass-card); background-image: var(--glass-sheen-soft); color: inherit; text-align: left; text-decoration: none; }
  .row--quiet { min-height: 52px; padding: 11px 13px; border-color: var(--line); border-radius: var(--radius-md); background: var(--glass-deep); }
  .row__main { display: grid; min-width: 0; gap: var(--space-1); }
  .row__main strong { font-size: var(--text-item); font-weight: var(--weight-semibold); line-height: 1.25; overflow-wrap: anywhere; }
  .row__main small { color: var(--muted-bright); font-size: var(--text-small); line-height: 1.35; }
  .row__side { display: grid; justify-items: end; gap: var(--space-1); text-align: right; font-variant-numeric: tabular-nums; }
  .row__side strong { font-size: var(--text-lead); font-weight: var(--weight-semibold); }
  .row__side small { color: var(--muted); font-size: 11px; }

  /* Charts drawn as inline SVG. Series colours come from --data-1..5. */
  .chart { width: 100%; height: auto; overflow: visible; }
  .chart text { fill: var(--muted); font-family: var(--font-sans); font-size: var(--text-label); font-variant-numeric: tabular-nums; }
  .chart__grid { stroke: var(--track); stroke-width: 1; }
  .chart__bar { fill: rgba(var(--accent-rgb), .55); }
  .chart__line { fill: none; stroke: var(--data-1); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
  .chart__line--2 { stroke: var(--data-2); }
  .chart__line--3 { stroke: var(--data-3); }
  .chart__dot { fill: var(--void); stroke: var(--data-1); stroke-width: 2; }
  .chart__target { fill: none; stroke: rgba(var(--secondary-rgb), .8); stroke-dasharray: 4 4; stroke-width: 1.5; }

  /* Theme switcher: one button per palette, a swatch and a short name. */
  .theme-switcher { display: flex; min-width: 0; flex-wrap: wrap; padding: 3px; border: 1px solid var(--glass-edge); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--void) 48%, transparent); box-shadow: inset 0 1px color-mix(in srgb, var(--white) 5%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
  .theme-switcher button { display: inline-flex; min-height: 36px; padding: 0 11px; gap: 5px; align-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
  .theme-switcher button > span { color: var(--swatch, currentColor); }
  /* A plain palette's swatch is white or black, so its star gets an outline
     that shows on any page. */
  .theme-switcher button[data-plain] > span { -webkit-text-stroke: 1px var(--muted); paint-order: stroke fill; }
  .theme-switcher button b { font-size: var(--text-label); letter-spacing: .06em; text-transform: uppercase; }
  .theme-switcher button[aria-pressed="true"] { background: var(--picked-wash); color: var(--ink); box-shadow: inset 0 0 0 1px var(--glass-edge), 0 8px 22px color-mix(in srgb, var(--black) 20%, transparent); }
  .theme-switcher--wide { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
  .theme-switcher--wide button { min-width: 0; min-height: 52px; padding: 5px 4px; flex-direction: column; gap: 3px; justify-content: center; }
  @media (pointer: coarse) {
    .theme-switcher button { min-height: var(--target); }
  }

  /* Sheets: above the tab bar on a phone, centred on a wide screen. The round
     close sits bottom right, under the thumb. The page behind is inert. */
  .sheet-layer { position: fixed; z-index: var(--z-sheet); inset: 0; }
  .sheet-backdrop { position: absolute; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
  .sheet {
    position: absolute;
    bottom: calc(var(--tabbar-clearance) + 13px);
    left: 50%;
    display: flex;
    width: min(var(--sheet-width), calc(100vw - 24px));
    max-height: calc(100dvh - 120px - env(safe-area-inset-top, 0px));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sheet);
    background: color-mix(in srgb, var(--panel) 97%, var(--black));
    box-shadow: var(--shadow-sheet);
    color: var(--ink);
    transform: translateX(-50%);
    outline: none;
  }
  .sheet__body { display: grid; min-height: 0; padding: 24px 20px 76px; gap: 14px; align-content: start; overflow-y: auto; overscroll-behavior: contain; }
  .sheet__head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: center; }
  .sheet__head--back { grid-template-columns: auto minmax(0, 1fr); }
  .sheet__head h2 { margin: 0; font-size: var(--text-sheet); font-weight: var(--weight-medium); line-height: 1.15; letter-spacing: -.03em; overflow-wrap: anywhere; }
  .sheet__close { position: absolute; z-index: 3; right: 17px; bottom: 17px; display: grid; width: var(--target); height: var(--target); padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--panel-bright); color: var(--ink); font-size: 26px; line-height: 1; box-shadow: 0 8px 24px color-mix(in srgb, var(--black) 40%, transparent); }
  .sheet-confirm { position: absolute; z-index: 4; right: 12px; bottom: 12px; left: 12px; display: grid; padding: 18px; gap: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--panel-bright); box-shadow: 0 -12px 40px color-mix(in srgb, var(--black) 53%, transparent); }
  .sheet-confirm__title { margin: 0; font-size: 17px; font-weight: 620; letter-spacing: -.02em; }

  /* Toast: under the header, clear of the thumb, with Undo instead of "Are you sure?". */
  .toast {
    position: fixed;
    z-index: var(--z-toast);
    top: calc(var(--header-height, 91px) + var(--conn-banner-height, 0px) + var(--space-2));
    left: 50%;
    display: flex;
    width: min(560px, calc(100% - 26px));
    padding: 9px 9px 9px 15px;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: color-mix(in srgb, var(--panel-bright) 96%, transparent);
    box-shadow: var(--shadow-toast);
    font-size: var(--text-body);
    line-height: 1.4;
    transform: translateX(-50%);
  }
  .toast button { min-height: var(--target); padding: 0 14px; flex: 0 0 auto; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 11px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--ink); font-size: var(--text-small); font-weight: var(--weight-semibold); }

  /* Hold: 1.2 s to log or to confirm. A pressure field grows under the finger,
     waves ripple out, haptics quicken; completing plays the energy sweep and +1.
     The behaviour lives in the template's ui.js (holdable()). */
  .hold { position: relative; overflow: hidden; isolation: isolate; touch-action: none; }
  .hold--scrollable { touch-action: pan-y; }
  .hold__label { position: relative; z-index: 2; }
  .hold-layers { position: absolute; z-index: 0; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; --hold-x: 50%; --hold-y: 50%; }
  .hold-fill { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 25%, transparent)); transform: scaleX(var(--hold-progress)); transform-origin: 0 50%; }
  .hold--danger { --accent: var(--danger); --accent-rgb: var(--danger-rgb); }
  .hold--danger .hold-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--danger) 10%, transparent), color-mix(in srgb, var(--danger) 34%, transparent)); }
  .is-hold-cancelling .hold-fill { transition: transform var(--dur-cancel) var(--ease-out); }
  .hold-pressure-field,
  .hold-pressure-wave { position: absolute; z-index: 1; top: var(--hold-y); left: var(--hold-x); border-radius: 50%; transform: translate(-50%, -50%); }
  .hold-pressure-field {
    width: calc(58px + var(--hold-pressure) * 92px);
    aspect-ratio: 1;
    background: radial-gradient(circle, color-mix(in srgb, var(--white) 16%, transparent), color-mix(in srgb, var(--accent) 20%, transparent) 32%, color-mix(in srgb, var(--accent) 7%, transparent) 56%, transparent 74%);
    filter: blur(calc(1px + var(--hold-pressure) * 4px));
    opacity: calc(var(--hold-pressure) * .92);
    transition: width 70ms linear, filter 110ms ease, opacity 100ms ease;
  }
  .hold-pressure-field::after { position: absolute; inset: 39%; border-radius: inherit; background: color-mix(in srgb, color-mix(in srgb, var(--accent) 12%, var(--white)) 75%, transparent); box-shadow: 0 0 calc(8px + var(--hold-pressure) * 12px) color-mix(in srgb, var(--accent) 85%, transparent); content: ""; opacity: calc(.2 + var(--hold-pressure) * .8); }
  .hold-pressure-wave { width: 74px; aspect-ratio: 1; border: 2px solid color-mix(in srgb, var(--accent) 66%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 13%, transparent); opacity: 0; }
  .is-holding .hold-pressure-wave { animation: djcns-hold-wave 1.05s var(--ease-wave) infinite; }
  .is-holding .hold-pressure-wave--two { animation-delay: -350ms; }
  .is-holding .hold-pressure-wave--three { animation-delay: -700ms; }
  .is-holding { border-color: color-mix(in srgb, var(--accent) 58%, var(--line)) !important; box-shadow: inset 0 0 28px color-mix(in srgb, var(--accent) 10%, transparent); }
  .energy-sweep-beam {
    position: absolute;
    z-index: 3;
    top: -22%;
    bottom: -22%;
    left: -34%;
    width: 24%;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--white) 24%, transparent), color-mix(in srgb, var(--accent) 94%, var(--white)), color-mix(in srgb, var(--white) 20%, transparent), transparent);
    filter: blur(.2px) drop-shadow(0 0 12px color-mix(in srgb, var(--accent) 72%, transparent));
    opacity: 0;
    transform: skewX(-12deg);
  }
  .is-energy-sweeping .energy-sweep-beam { animation: djcns-energy-sweep var(--dur-sweep) var(--ease-sweep) both; }
  .is-energy-sweeping { animation: djcns-energy-card 760ms ease-out both; }
  .log-plus-one { position: absolute; z-index: 4; top: 8px; right: 13px; color: var(--positive); font-size: .8rem; font-weight: 950; opacity: 0; text-shadow: 0 0 18px color-mix(in srgb, var(--positive) 65%, transparent); }
  .is-energy-sweeping .log-plus-one { animation: djcns-plus-one var(--dur-sweep) 110ms cubic-bezier(.18, .82, .22, 1) both; }
  @keyframes djcns-hold-wave { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.55); } 18% { opacity: calc(.28 + var(--hold-pressure) * .48); } 72% { opacity: calc(.12 + var(--hold-pressure) * .22); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(calc(1.65 + var(--hold-pressure) * .95)); } }
  @keyframes djcns-energy-sweep { 0% { left: -34%; opacity: 0; } 10% { opacity: 1; } 78% { opacity: 1; } 100% { left: 122%; opacity: 0; } }
  @keyframes djcns-energy-card { 0%, 100% { filter: none; } 36% { filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 22%, transparent)); } }
  @keyframes djcns-plus-one { 0% { opacity: 0; transform: translateY(13px) scale(.72); } 22% { opacity: 1; transform: translateY(8px) scale(1); } 58% { opacity: 1; transform: translateY(-3px) scale(1.14); } 100% { opacity: 0; transform: translateY(-16px) scale(.86); } }
  @media (prefers-reduced-motion: reduce) {
    .is-holding .hold-pressure-wave,
    .is-energy-sweeping,
    .is-energy-sweeping .energy-sweep-beam,
    .is-energy-sweeping .log-plus-one { animation: none; }
  }

  /* Narrow phones (320 px): one column where two would squeeze. */
  @media (max-width: 360px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .stepper { grid-template-columns: 52px minmax(0, 1fr) 52px; }
    .stepper__field input { padding-right: 40px; font-size: 1.7rem; }
  }

  /* Wide screens: the labelled sidebar replaces the tab bar, the round action
     button floats on its own at the right, and More's groups go two columns. */
  @media (min-width: 901px) {
    :root { --panel-pad: 24px; --stack: 14px; }
    .shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
    .sidebar {
      position: sticky;
      z-index: 25;
      top: 0;
      display: flex;
      height: 100dvh;
      padding: 25px 13px;
      flex-direction: column;
      overflow-y: auto;
      border-right: 1px solid var(--line);
      background: var(--glass-sidebar);
      box-shadow: inset -1px 0 color-mix(in srgb, var(--white) 6%, transparent);
      -webkit-backdrop-filter: blur(28px) saturate(135%);
      backdrop-filter: blur(28px) saturate(135%);
      scrollbar-width: none;
    }
    .glass-dock > .glass-tabbar { display: none !important; }
    :root { --glass-dock-left: auto; --glass-dock-right: max(28px, env(safe-area-inset-right, 0px)); --glass-dock-bottom: 28px; }
    .nav-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--stack); }
    .app { padding-bottom: 92px; }
    /* The date keeps its own width; the actions take the rest and wrap. With the date in a
       minmax(0, 1fr) column, ten palette dots squeezed it until MONDAY ran into 30 NOV. */
    .app-header { width: calc(100% - 48px); min-height: 96px; margin-inline: auto; padding: 12px 30px; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; }
    .app-header__actions { display: flex; min-width: 0; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: flex-end; }
    .date-head__weekday,
    .date-head__date { font-size: clamp(1.28rem, 2vw, 1.6rem); }
    .app-main { width: calc(100% - 48px); max-width: var(--content-max); margin-inline: auto; padding-top: 22px; }
    .panel { border-radius: 24px; }
    .panel__head h2 { font-size: 1.35rem; }
    .sheet { top: 50%; bottom: auto; max-height: calc(100dvh - 40px); transform: translate(-50%, -50%); }
    .sheet__body { padding: 30px 26px 86px; }
    .sheet__head h2 { font-size: 27px; }
    .toast { top: calc(var(--header-height, 120px) + var(--conn-banner-height, 0px) + var(--space-2)); }
  }
}
