/*
 * semantic.css — roles that point at the scale.
 *
 * Control CSS uses these names and never a primitive. Every value here is a var() of a
 * primitive (or of another role), or a calc() of those with whole-number factors; no literal
 * length, colour or other value is allowed (fsm/semantic-roles).
 *
 * These roles are the base theme: a page without data-theme looks like this. Another theme
 * (themes/, e.g. themes/acme.css) reassigns a few of them in the themes layer and wins. It may not reassign the
 * density-derived roles at the bottom of this file; it sets their -regular and -compact
 * sources instead, so compact density keeps working under every theme.
 *
 * The roles are declared on every element that can carry a theme or a density, not only on
 * :root, so a role that points at another role is recomputed where the theme changes.
 *
 * The dark scheme is not a theme: it combines with any theme (a tenant in the dark). It
 * reassigns the colour and shadow roles in its own layer, schemes, after themes, at the end of
 * this file. It follows the system (prefers-color-scheme); data-scheme="light" or "dark" on the
 * root element overrides it, for a person's own choice. Its accent tints are mixed from the
 * accent, whatever the theme made it, so a tenant's accent brings its own dark tints. The same
 * declarations stand twice, once per way in (fsm/scheme-twins keeps them equal).
 */
@layer semantic {
    :root,
    [data-theme] {
        /* Colour — surfaces */
        --app-color-scheme: var(--app-scheme-light);
        --app-color-page: var(--app-gray-25);
        --app-color-surface: var(--app-gray-0);
        --app-color-surface-muted: var(--app-gray-50);
        --app-color-surface-hover: var(--app-gray-50);
        --app-color-surface-disabled: var(--app-gray-50);
        /* What lies above the page's surfaces: a dialog, a drawer, a menu, a list, a toast. In
           the light a shadow lifts it; in the dark it is a step lighter. */
        --app-color-surface-raised: var(--app-color-surface);

        /* Colour — text */
        --app-color-text: var(--app-gray-900);
        --app-color-text-muted: var(--app-gray-700);
        --app-color-text-subtle: var(--app-gray-500);
        --app-color-text-disabled: var(--app-gray-400);
        --app-color-text-on-accent: var(--app-gray-0);

        /* Colour — lines */
        --app-color-line: var(--app-gray-100);
        --app-color-line-strong: var(--app-gray-200);
        --app-color-line-control: var(--app-gray-400);
        --app-color-line-hover: var(--app-gray-500);

        /* Colour — accent: the one colour of the base look. A theme may bring its own. */
        --app-color-accent: var(--app-blue-600);
        --app-color-accent-hover: var(--app-blue-700);
        --app-color-accent-soft: var(--app-blue-100);
        --app-color-accent-subtle: var(--app-blue-50);
        --app-color-accent-text: var(--app-blue-700);
        --app-color-focus: var(--app-color-accent);

        /* Colour — tones */
        --app-color-danger: var(--app-red-700);
        --app-color-danger-hover: var(--app-red-800);
        --app-color-danger-line: var(--app-red-600);
        --app-color-danger-text: var(--app-red-700);
        --app-color-danger-soft: var(--app-red-50);
        --app-color-success: var(--app-green-600);
        --app-color-success-text: var(--app-green-700);
        --app-color-success-soft: var(--app-green-50);
        --app-color-warning: var(--app-amber-600);
        --app-color-warning-text: var(--app-amber-700);
        --app-color-warning-soft: var(--app-amber-50);
        /* Information is not the accent: blue means "act here" or "you are here", never a
           status or a message (DESIGN.md, the One Accent Rule). */
        --app-color-info: var(--app-violet-600);
        --app-color-info-text: var(--app-violet-700);
        --app-color-info-soft: var(--app-violet-50);

        --app-color-scrim: var(--app-overlay-32);

        /* Colour — tables and placeholders */
        --app-color-row-hover: var(--app-color-surface-hover);
        --app-color-row-selected: var(--app-color-accent-subtle);
        /* The row open beside the list: "you are here", like the current navigation item. */
        --app-color-row-current: var(--app-color-accent-soft);
        --app-color-row-current-text: var(--app-color-accent-text);
        /* A row whose changes wait to be sent: the tone of the offline status in the bar. */
        --app-color-row-pending: var(--app-color-warning-text);
        --app-color-skeleton: var(--app-gray-100);
        /* The knob of a switch: white on its track, in both schemes. */
        --app-color-switch-thumb: var(--app-gray-0);
        --app-color-avatar: var(--app-color-accent-soft);
        --app-color-avatar-text: var(--app-color-accent-text);
        /* Forced colours: frames, and the one highlight for what is chosen, current or active. */
        --app-color-forced-line: var(--app-system-text);
        --app-color-forced-current: var(--app-system-highlight);
        --app-color-forced-current-text: var(--app-system-highlight-text);
        --app-color-forced-disabled: var(--app-system-gray);
        --app-color-forced-canvas: var(--app-system-canvas);

        /* Colour — navigation */
        --app-color-nav: var(--app-color-surface);
        --app-color-nav-current: var(--app-color-accent-soft);
        --app-color-nav-current-text: var(--app-color-accent-text);
        /* Colour — the entry screens (start, sign-in): the brand field and the mark on it. */
        --app-color-entry-brand: var(--app-color-accent);
        --app-color-entry-mark: var(--app-color-text-on-accent);

        /* Type — families */
        --app-font-text: var(--app-font-family-sans);
        --app-font-display: var(--app-font-family-grotesk);
        --app-font-mono: var(--app-font-family-code);

        /* Type — roles. Sizes, weights and leading a control may use. */
        --app-text-body-size: var(--app-font-size-body);
        --app-text-body-weight: var(--app-font-weight-regular);
        --app-text-body-leading: var(--app-line-height-20);
        --app-text-strong-weight: var(--app-font-weight-semibold);

        --app-text-control-size: var(--app-font-size-body);
        --app-text-control-leading: var(--app-line-height-20);
        --app-text-button-weight: var(--app-font-weight-semibold);

        --app-text-label-size: var(--app-font-size-meta);
        --app-text-label-weight: var(--app-font-weight-medium);
        --app-text-label-leading: var(--app-line-height-16);

        /* Small text is one size: labels, hints, chips, meta. Caption is only for a count inside
           a small round (badge, avatar, step marker), where a digit must fit. */
        --app-text-help-size: var(--app-font-size-meta);
        --app-text-help-leading: var(--app-line-height-16);

        --app-text-chip-size: var(--app-font-size-meta);
        --app-text-chip-weight: var(--app-font-weight-medium);
        --app-text-segment-weight: var(--app-font-weight-medium);
        --app-text-count-size: var(--app-font-size-caption);

        /* A description list: the value is what is looked for, so it outweighs its term. */
        --app-text-term-weight: var(--app-font-weight-regular);
        --app-text-value-weight: var(--app-font-weight-medium);

        /* An identifier (order number, serial number): read aloud and typed back, so every
           character is unmistakable. */
        --app-text-code-size: var(--app-font-size-body);
        --app-text-code-weight: var(--app-font-weight-medium);
        --app-text-code-tracking: var(--app-letter-spacing-normal);
        --app-text-code-leading: var(--app-line-height-16);

        --app-text-link-weight: var(--app-font-weight-medium);

        --app-text-tab-size: var(--app-font-size-body);
        --app-text-tab-weight: var(--app-font-weight-medium);

        --app-text-heading-size: var(--app-font-size-title);
        --app-text-heading-weight: var(--app-font-weight-semibold);
        --app-text-heading-leading: var(--app-line-height-24);

        --app-text-display-size: var(--app-font-size-display);
        --app-text-display-weight: var(--app-font-weight-semibold);
        --app-text-display-leading: var(--app-line-height-32);
        --app-text-display-tracking: var(--app-letter-spacing-tight);

        /* The work timer's reading: display figures, so it reads at arm's length. */
        --app-text-timer-size: var(--app-font-size-display);
        --app-text-timer-weight: var(--app-font-weight-semibold);
        --app-text-timer-leading: var(--app-line-height-32);

        --app-text-nav-size: var(--app-font-size-body);
        --app-text-nav-weight: var(--app-font-weight-medium);
        --app-text-crumb-size: var(--app-font-size-meta);
        --app-text-table-head-size: var(--app-font-size-meta);
        --app-text-table-head-weight: var(--app-font-weight-medium);

        /* Space — between things */
        --app-space-field: var(--app-space-4);
        --app-space-section: var(--app-space-8);
        --app-space-label: var(--app-space-2);
        /* A term and its value read as one: tighter than a label and its control, which has a
           frame of its own to separate it. */
        --app-space-term: var(--app-space-1);
        /* How far a sideways-scrolling row fades at an edge with more behind it. */
        --app-scroll-fade: var(--app-space-8);
        --app-space-inline: var(--app-space-2);
        --app-space-choice: var(--app-space-3);
        --app-space-tabs: var(--app-space-4);
        --app-space-stack: var(--app-space-4);
        --app-space-cluster: var(--app-space-2);
        --app-space-actions: var(--app-space-2);
        --app-space-popover-offset: var(--app-space-1);
        --app-space-chevron: var(--app-space-1);
        --app-space-header-row: var(--app-space-1);
        --app-space-page-gap: var(--app-space-6);
        --app-space-header-x: var(--app-space-3);
        --app-space-section-header: var(--app-space-1);
        --app-space-form-label: var(--app-space-4);
        --app-space-nav-items: var(--app-space-1);
        --app-space-nav-groups: var(--app-space-5);

        /* Space — the column grid. Columns are separated by the gutter: narrow while the region
           has 4 columns, wide from 8 columns on. Rows of a grid are separated by grid-row. */
        --app-space-gutter-narrow: var(--app-space-4);
        --app-space-gutter-wide: var(--app-space-6);
        --app-space-grid-row: var(--app-space-4);

        /* Space — insets */
        --app-space-field-x: var(--app-space-3);
        --app-space-chip-x: var(--app-space-3);
        /* A chip's border is in its height: the room above its text takes it back. */
        --app-space-chip-y: calc(var(--app-space-control-y-compact) - var(--app-border-width));
        --app-space-chip-gap: var(--app-space-1);
        --app-space-sync-x: var(--app-space-3);
        --app-space-sync-gap: var(--app-space-2);
        --app-space-sync-x-narrow: var(--app-space-2);
        --app-space-sync-gap-narrow: var(--app-space-1);
        --app-space-reason-gap: var(--app-space-2);
        --app-space-link-gap: var(--app-space-2);
        --app-space-tab-x: var(--app-space-4);
        --app-space-option-x: var(--app-space-3);
        --app-space-list-inset: var(--app-space-1);
        --app-space-notice-x: var(--app-space-4);
        --app-space-notice-y: var(--app-space-3);
        --app-space-notice-text: var(--app-space-1);
        --app-space-dialog-wide: var(--app-space-6);
        --app-space-dialog-narrow: var(--app-space-4);
        --app-space-dialog-gap: var(--app-space-4);
        --app-space-focus-room: var(--app-space-1);
        --app-space-page-wide: var(--app-space-6);
        --app-space-page-narrow: var(--app-space-4);
        --app-space-bar-y: var(--app-space-3);
        --app-space-nav-inset: var(--app-space-3);
        --app-space-nav-item-x: var(--app-space-3);
        --app-space-cell-x: var(--app-space-3);
        --app-space-row-y: var(--app-space-3);
        --app-space-badge-x: var(--app-space-1);
        --app-space-state-y: var(--app-space-12);
        --app-space-state-x: var(--app-space-4);
        --app-space-state-gap: var(--app-space-2);

        /* Radius */
        --app-radius-button-regular: var(--app-radius-10);
        --app-radius-button-compact: var(--app-radius-8);
        --app-radius-field-regular: var(--app-radius-8);
        --app-radius-field-compact: var(--app-radius-6);
        --app-radius-check: var(--app-radius-6);
        --app-radius-option: var(--app-radius-6);
        --app-radius-popover: var(--app-radius-10);
        --app-radius-notice: var(--app-radius-10);
        --app-radius-card: var(--app-radius-14);
        --app-radius-chip: var(--app-radius-full);
        --app-radius-sync: var(--app-radius-full);
        --app-radius-nav-item: var(--app-radius-8);
        --app-radius-round: var(--app-radius-full);

        /* Size */
        --app-control-height-regular: var(--app-control-40);
        --app-control-height-compact: var(--app-control-32);
        --app-space-control-x-regular: var(--app-space-4);
        --app-space-control-x-compact: var(--app-space-3);
        /* Room above and below a control's one line of text. Less than the height leaves, so
           the height holds at 1×; with large system text (Android scales px text) the control
           grows and the text keeps this room instead of touching the frame. */
        --app-space-control-y-regular: var(--app-space-2);
        --app-space-control-y-compact: var(--app-space-1);
        --app-touch-target: var(--app-touch-44);
        --app-chip-height: var(--app-control-28);
        --app-sync-height: var(--app-control-32);
        --app-action-height-touch: var(--app-control-48);
        --app-link-underline-width: var(--app-border-width);
        --app-link-underline-offset: var(--app-border-2);
        --app-choice-size: var(--app-icon-20);
        --app-icon-size: var(--app-icon-16);
        --app-icon-stroke: var(--app-stroke-regular);
        --app-select-list-height: var(--app-measure-320);
        /* The date and time picker: a day is a control square, seven to a week; the list of
           times beside a calendar is 120 wide. */
        --app-picker-day: var(--app-control-height);
        --app-picker-weekday: var(--app-space-6);
        --app-picker-times: var(--app-measure-120);
        --app-space-picker: var(--app-space-3);
        --app-space-picker-gap: var(--app-space-2);
        --app-space-picker-button: var(--app-space-1);
        --app-dialog-width-s: var(--app-measure-400);
        --app-dialog-width-m: var(--app-measure-560);
        --app-drawer-width: var(--app-measure-480);
        --app-sidebar-width: var(--app-measure-320);
        --app-switcher-threshold: var(--app-measure-560);
        --app-page-height: var(--app-viewport-height);
        /* What the on-screen keyboard covers at the bottom; fsm-ui.js writes it on the root
           for every browser, with data-keyboard while one is up. */
        --app-space-keyboard: var(--app-viewport-keyboard);
        /* What the device covers at each edge; whatever touches an edge of the screen pads by it. */
        --app-space-safe-top: var(--app-viewport-safe-top);
        --app-space-safe-right: var(--app-viewport-safe-right);
        --app-space-safe-bottom: var(--app-viewport-safe-bottom);
        --app-space-safe-left: var(--app-viewport-safe-left);
        --app-nav-width: var(--app-measure-240);
        /* The rail: one touch target wide inside the navigation's inset, so a split view still
           fits beside it on a tablet held across (1180 - 68 leaves more than 960). */
        --app-nav-rail-width: calc(var(--app-touch-target) + 2 * var(--app-space-nav-inset));
        /* The tab bar: 8 + 20 icon + 4 + 16 label + 8 = 56 an item, in a 4px inset: 64, as tall
           as the header bar. */
        --app-space-tab-bar: var(--app-space-1);
        --app-tab-bar-item-width: var(--app-measure-120);
        /* The link list: rows that lead on (a sub-page, a sheet), 16 to the sides and 12 above
           and below, at least a touch target tall, 48 on a touch screen for a gloved thumb. */
        /* A section's heading row stands 8 above its panel, as an agenda day's does. */
        --app-space-section-head: var(--app-space-2);
        --app-space-load-more: var(--app-space-3);
        /* The narrowest column of a grid of choices: "Nach Nummer finden" on one line. */
        --app-choice-column: var(--app-measure-160);
        /* Files shown by what they show: tiles at least 160 wide with a thumb 160 tall (two
           across a phone, six across a desktop), and the preview of one, 400 tall on a phone
           and 560 from a region of 560. */
        --app-file-column: var(--app-measure-160);
        --app-file-thumb-height: var(--app-measure-160);
        --app-radius-thumb: var(--app-radius-10);
        --app-space-file-grid: var(--app-space-4);
        --app-space-file-grid-row: var(--app-space-5);
        --app-space-file-name: var(--app-space-2);
        --app-space-file-text: var(--app-space-1);
        --app-preview-height-narrow: var(--app-measure-400);
        --app-preview-height: var(--app-measure-560);
        --app-space-preview: var(--app-space-4);
        /* The board: lanes at least 240 wide, side by side and scrolled sideways when they do not
           fit; on a phone one lane at a time, the next one peeking in by 48. A card is 12 in. */
        --app-board-column-min: var(--app-measure-240);
        --app-space-board: var(--app-space-4);
        --app-space-board-peek: var(--app-space-12);
        --app-space-board-lane: var(--app-space-3);
        --app-space-board-cards: var(--app-space-2);
        --app-space-board-card: var(--app-space-3);
        --app-space-board-card-text: var(--app-space-1);
        --app-radius-board-lane: var(--app-radius-14);
        --app-radius-board-card: var(--app-radius-10);
        --app-shadow-board-lifted: var(--app-shadow-popover);
        --app-space-link-list-x: var(--app-space-4);
        --app-space-link-list-y: var(--app-space-3);
        --app-link-list-row: var(--app-touch-target);
        --app-link-list-row-touch: var(--app-control-48);
        --app-nav-rail-icon: var(--app-icon-20);
        --app-space-tab-bar-item-y: var(--app-space-2);
        --app-space-tab-bar-label: var(--app-space-1);
        --app-tab-bar-height: calc(2 * var(--app-space-tab-bar) + 2 * var(--app-space-tab-bar-item-y) + var(--app-icon-20) + var(--app-space-tab-bar-label) + var(--app-text-label-leading));
        --app-split-list-width: var(--app-measure-400);
        --app-form-label-width: var(--app-measure-160);
        --app-form-width: var(--app-measure-800);
        --app-column-width-s: var(--app-measure-80);
        --app-column-width-m: var(--app-measure-120);
        --app-column-width-l: var(--app-measure-160);
        --app-column-width-xl: var(--app-measure-240);
        /* A record's detail area (document.css): its parts 16 apart and 16 in from a panel's
           edge, rows of one line with 8 above and below (36), and the three figures of an amount
           row in columns of their own (Menge 72, × Preis 88, Netto 96), so every amount of a
           record ends on one edge. The totals panel is as wide as those columns and its inset,
           so its labels stand on the Menge column's edge. An identifier's line is small text. */
        --app-space-record: var(--app-space-4);
        --app-space-record-row: var(--app-space-2);
        --app-record-quantity: calc(var(--app-space-12) + var(--app-space-6));
        --app-record-price: calc(var(--app-measure-80) + var(--app-space-2));
        --app-record-amount: calc(2 * var(--app-space-12));
        --app-record-totals-width: calc(var(--app-record-quantity) + var(--app-record-price) + var(--app-record-amount) + 2 * var(--app-space-record));
        --app-record-term-width: var(--app-measure-160);
        --app-text-id-size: var(--app-font-size-meta);
        --app-text-id-leading: 1;
        --app-filter-search-width: var(--app-measure-320);
        --app-badge-size: var(--app-icon-20);
        --app-state-icon-size: var(--app-control-40);
        --app-skeleton-height: var(--app-space-3);
        /* A text area: its padding takes the border back, so 3 lines are 76 and every line
           adds 20, on the 4px rhythm. */
        --app-space-area-y: calc(var(--app-space-2) - var(--app-border-width));
        --app-menu-width-min: var(--app-measure-160);
        --app-menu-width-max: var(--app-measure-320);
        --app-toast-width: var(--app-measure-400);
        --app-entry-width: var(--app-measure-400);
        --app-entry-mark-height: var(--app-control-48);
        --app-space-overlay-edge: var(--app-space-4);
        --app-space-toasts: var(--app-space-2);
        --app-space-toast-y: var(--app-space-1);
        --app-space-toast-x: var(--app-space-2);
        --app-space-attachment-x: var(--app-space-2);
        /* The signature pad: a paper-like strip with a line to sign on, and a pen as heavy as a
           ballpoint's on paper. */
        --app-signature-height: var(--app-measure-160);
        --app-signature-ink: var(--app-stroke-ink);
        --app-signature-line-box: var(--app-space-1);
        --app-space-signature-x: var(--app-space-6);
        --app-space-signature-line: var(--app-space-12);
        --app-space-signature-note: var(--app-space-5);
        /* The agenda: rows inset like a card's content, a step between the drive line and its
           row, and the heading of a day a step over its list. */
        --app-space-agenda-x: var(--app-space-4);
        --app-space-agenda-y: var(--app-space-3);
        --app-space-agenda-band: var(--app-space-1);
        --app-space-agenda-head: var(--app-space-2);
        --app-space-agenda-actions: var(--app-space-3);
        --app-agenda-skeleton-short: var(--app-measure-160);
        /* The time column is at least as wide as the widest time, so the days line up; it grows
           with large text. The agenda keeps a measure an office reader can follow across. */
        --app-agenda-time: var(--app-space-12);
        --app-agenda-width: var(--app-measure-800);
        /* A progress bar: a rounded track a step tall, its line of text a step above it. */
        --app-progress-height: var(--app-space-2);
        --app-space-progress: var(--app-space-1);
        --app-progress-stripe: var(--app-space-1);
        /* The work timer: its state's dot, and the status line over the reading. */
        --app-timer-dot: var(--app-space-2);
        --app-space-timer: var(--app-space-1);
        --app-switch-width: calc(2 * var(--app-choice-size) - var(--app-space-1));
        --app-switch-thumb: var(--app-icon-16);
        --app-space-switch-inset: calc((var(--app-choice-size) - var(--app-switch-thumb)) / 2);
        --app-avatar-size: var(--app-control-32);
        --app-avatar-size-compact: var(--app-icon-24);
        --app-marker-size: var(--app-icon-24);
        --app-space-timeline: var(--app-space-4);
        --app-space-timeline-text: var(--app-space-1);
        --app-space-disclosure: var(--app-space-4);
        --app-space-steps: var(--app-space-2);

        /* Lines */
        --app-border-width: var(--app-border-1);
        --app-border-width-strong: var(--app-border-2);
        --app-focus-ring-width: var(--app-border-2);
        --app-focus-ring-offset: var(--app-border-2);

        /* Elevation */
        --app-shadow-card: var(--app-shadow-resting);
        --app-shadow-popover: var(--app-shadow-overlay);
        --app-shadow-dialog: var(--app-shadow-modal);
        --app-shadow-drawer: var(--app-shadow-modal);

        /* Motion */
        --app-duration-hover: var(--app-duration-fast);
        --app-duration-overlay: var(--app-duration-base);
        --app-duration-panel: var(--app-duration-slow);
        --app-duration-busy: var(--app-duration-spin);
        --app-duration-skeleton: var(--app-duration-pulse);
        --app-duration-progress: var(--app-duration-pulse);
        --app-easing: var(--app-easing-standard);
        --app-easing-in: var(--app-easing-enter);
        --app-easing-out: var(--app-easing-exit);
        --app-easing-busy: var(--app-easing-linear);

        /* Stacking */
        --app-z-header: var(--app-z-sticky);
        --app-z-select: var(--app-z-popover);
        --app-z-side-panel: var(--app-z-drawer);
        --app-z-modal: var(--app-z-dialog);
    }

    /* Derived roles. A theme sets the sources above (-regular and -compact, -wide and
       -narrow); it never sets these, so density and the phone width keep working under every
       theme. data-size="compact" on a single control is the density override, scoped. */
    :root,
    [data-theme],
    [data-density="regular"],
    [data-size="regular"] {
        --app-control-height: var(--app-control-height-regular);
        --app-radius-button: var(--app-radius-button-regular);
        --app-radius-field: var(--app-radius-field-regular);
        --app-space-control-x: var(--app-space-control-x-regular);
        --app-space-control-y: var(--app-space-control-y-regular);
        --app-bar-height: calc(var(--app-control-height-regular) + 2 * var(--app-space-bar-y));
    }

    [data-density="compact"],
    [data-density="compact"] [data-theme],
    [data-size="compact"] {
        --app-control-height: var(--app-control-height-compact);
        --app-radius-button: var(--app-radius-button-compact);
        --app-radius-field: var(--app-radius-field-compact);
        --app-space-control-x: var(--app-space-control-x-compact);
        --app-space-control-y: var(--app-space-control-y-compact);
        --app-bar-height: calc(var(--app-control-height-compact) + 2 * var(--app-space-bar-y));
    }

    :root,
    [data-theme] {
        --app-space-page: var(--app-space-page-wide);
        --app-space-dialog: var(--app-space-dialog-wide);
    }

    /* A phone gets the narrow page gutter and dialog inset. Viewport, --app-breakpoint-480. */
    @media (width <= 480px) {
        :root,
        [data-theme] {
            --app-space-page: var(--app-space-page-narrow);
            --app-space-dialog: var(--app-space-dialog-narrow);
        }
    }
}

/*
 * The dark scheme. Composed, not inverted: the page is the darkest night and each surface
 * above it a step lighter (surface, then raised: dialogs, menus, toasts), because a shadow
 * barely shows in the dark; text is the light end of gray; the tones step to their 300s and
 * 400s on 950 washes. Every pair that is read keeps the light scheme's contrast floor (4.5:1
 * text, 3:1 outlines and icons). The block stands twice: for the system's choice, unless the
 * root says light, and for the root's own data-scheme="dark".
 */
@layer schemes {
    @media (prefers-color-scheme: dark) {
        :root:not([data-scheme="light"]),
        :root:not([data-scheme="light"]) [data-theme] {
            --app-color-scheme: var(--app-scheme-dark);
            --app-color-page: var(--app-night-900);
            --app-color-surface: var(--app-night-800);
            --app-color-surface-raised: var(--app-night-700);
            --app-color-surface-muted: var(--app-night-700);
            --app-color-surface-hover: var(--app-night-600);
            --app-color-surface-disabled: var(--app-night-700);
            --app-color-text: var(--app-gray-50);
            --app-color-text-muted: var(--app-gray-200);
            --app-color-text-subtle: var(--app-gray-400);
            --app-color-text-disabled: var(--app-gray-700);
            --app-color-line: var(--app-night-500);
            --app-color-line-strong: var(--app-night-400);
            --app-color-line-control: var(--app-gray-450);
            --app-color-line-hover: var(--app-gray-400);
            /* The accent's fill and its hover stay (white text on them holds); its text and tints are
               mixed from it, so they follow a theme's accent. */
            --app-color-accent-soft: color-mix(in oklab, var(--app-color-accent) 30%, var(--app-night-800));
            --app-color-accent-subtle: color-mix(in oklab, var(--app-color-accent) 16%, var(--app-night-800));
            --app-color-accent-text: color-mix(in oklab, var(--app-color-accent) 50%, var(--app-gray-0));
            --app-color-focus: var(--app-color-accent-text);
            --app-color-danger-hover: var(--app-red-600);
            --app-color-danger-line: var(--app-red-400);
            --app-color-danger-text: var(--app-red-300);
            --app-color-danger-soft: var(--app-red-950);
            --app-color-success: var(--app-green-400);
            --app-color-success-text: var(--app-green-300);
            --app-color-success-soft: var(--app-green-950);
            --app-color-warning: var(--app-amber-400);
            --app-color-warning-text: var(--app-amber-300);
            --app-color-warning-soft: var(--app-amber-950);
            --app-color-info: var(--app-violet-400);
            --app-color-info-text: var(--app-violet-300);
            --app-color-info-soft: var(--app-violet-950);
            --app-color-scrim: var(--app-overlay-56);
            --app-color-skeleton: var(--app-night-600);
            --app-color-switch-thumb: var(--app-gray-100);
            /* The brand field at night: the accent deepened, the white mark on it. */
            --app-color-entry-brand: color-mix(in oklab, var(--app-color-accent) 45%, var(--app-night-900));
            --app-shadow-card: var(--app-shadow-resting-dark);
            --app-shadow-popover: var(--app-shadow-overlay-dark);
            --app-shadow-dialog: var(--app-shadow-modal-dark);
            --app-shadow-drawer: var(--app-shadow-modal-dark);
        }
    }

    :root[data-scheme="dark"],
    :root[data-scheme="dark"] [data-theme] {
        --app-color-scheme: var(--app-scheme-dark);
        --app-color-page: var(--app-night-900);
        --app-color-surface: var(--app-night-800);
        --app-color-surface-raised: var(--app-night-700);
        --app-color-surface-muted: var(--app-night-700);
        --app-color-surface-hover: var(--app-night-600);
        --app-color-surface-disabled: var(--app-night-700);
        --app-color-text: var(--app-gray-50);
        --app-color-text-muted: var(--app-gray-200);
        --app-color-text-subtle: var(--app-gray-400);
        --app-color-text-disabled: var(--app-gray-700);
        --app-color-line: var(--app-night-500);
        --app-color-line-strong: var(--app-night-400);
        --app-color-line-control: var(--app-gray-450);
        --app-color-line-hover: var(--app-gray-400);
        /* The accent's fill and its hover stay (white text on them holds); its text and tints are
           mixed from it, so they follow a theme's accent. */
        --app-color-accent-soft: color-mix(in oklab, var(--app-color-accent) 30%, var(--app-night-800));
        --app-color-accent-subtle: color-mix(in oklab, var(--app-color-accent) 16%, var(--app-night-800));
        --app-color-accent-text: color-mix(in oklab, var(--app-color-accent) 50%, var(--app-gray-0));
        --app-color-focus: var(--app-color-accent-text);
        --app-color-danger-hover: var(--app-red-600);
        --app-color-danger-line: var(--app-red-400);
        --app-color-danger-text: var(--app-red-300);
        --app-color-danger-soft: var(--app-red-950);
        --app-color-success: var(--app-green-400);
        --app-color-success-text: var(--app-green-300);
        --app-color-success-soft: var(--app-green-950);
        --app-color-warning: var(--app-amber-400);
        --app-color-warning-text: var(--app-amber-300);
        --app-color-warning-soft: var(--app-amber-950);
        --app-color-info: var(--app-violet-400);
        --app-color-info-text: var(--app-violet-300);
        --app-color-info-soft: var(--app-violet-950);
        --app-color-scrim: var(--app-overlay-56);
        --app-color-skeleton: var(--app-night-600);
        --app-color-switch-thumb: var(--app-gray-100);
        /* The brand field at night: the accent deepened, the white mark on it. */
        --app-color-entry-brand: color-mix(in oklab, var(--app-color-accent) 45%, var(--app-night-900));
        --app-shadow-card: var(--app-shadow-resting-dark);
        --app-shadow-popover: var(--app-shadow-overlay-dark);
        --app-shadow-dialog: var(--app-shadow-modal-dark);
        --app-shadow-drawer: var(--app-shadow-modal-dark);
    }
}
