/* ============================================================================
   AI Toolkit design system (CONTRIBUTING sections 5 and 10)
   Tokens first (color, type, spacing, radius, shadow, layers), then the five
   components with their named variants (button, card, badge, tabs, dialog),
   then the shared layout. Every page loads this file first; a page's own
   stylesheet (static/pages/...) holds only that page's layout.
   Brand colors are injected by theme-boot.js and lib/theme.js as --brand-*-light / --brand-*-dark
   and resolved per active theme below. The living style guide is
   /admin/style-guide (static/style-guide.html).
   ============================================================================ */

:root {
    /* Brand (defaults; lib/theme.js overrides from /api/branding). The light default
       is dark enough for white text (5.25:1, WCAG 2.2 AA). */
    --brand-primary-light: #1f6fb5;
    --brand-accent-light: #5aade8;
    --brand-primary-dark: #5aade8;
    --brand-accent-dark: #2b88d8;

    /* Light theme tokens */
    --bg: #f7f8fa;
    --surface: #fff;
    --surface-2: #f1f3f5;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;

    /* Secondary text: 4.86:1 on --surface-2 and 4.75:1 on its own 6 percent tint there (status chips). */
    --muted: #5d677b;

    /* Small meta text and placeholders: 5.14:1 on white. --decor keeps the
       lighter grey for dots and rules that carry no text. */
    --muted-2: #636e82;
    --decor: #98a2b3;

    /* Input, select and checkbox borders: 3.53:1 against the page (3:1 for UI). */
    --control-border: #7f899b;

    /* The focus ring: a solid 2px line drawn 2px outside the control (--focus-outline, --focus-offset), so a gap of
       page shows between the ring and the control. 3:1 or more against the page, the cards and the grey panels, and
       3:1 against the default brand fill (WCAG 2.2 1.4.11, 2.4.13): 14.5:1 on --surface-2 and 3.06:1 on the fill
       here. lib/theme.js works it out again for the brand in use (lib/contrast.js ringOn). */
    --ring: #12232e;
    --danger: #c8291d;
    --danger-bg: #fef3f2;

    /* The red a destructive button turns on hover, the same in both themes. */
    --danger-fill: #d92d20;

    /* Error text that sits on --danger-bg: 4.5:1 or more. */
    --danger-ink: #c4271b;
    --success: #067647;
    --success-bg: #ecfdf3;
    --warning: #b54708;
    --warning-ink: #b54708;

    /* Text on a brand fill. The brand colors are the admin's, so lib/theme.js works it out for the brand in use
       (lib/contrast.js onColor: 4.5:1 or more for any color); these defaults suit the default brand. */
    --on-primary: #fff;
    --white: #fff;
    --black: #000;
    --ink: #101828;

    /* Palette: fixed colors for status chips, chart marks and the House Brand gold. They are the same in
       both themes; a page names the step it needs (a dark-theme rule picks a lighter step). */
    --green-50: #ecfdf3;
    --green-200: #abefc6;
    --green-300: #75e0a7;
    --green-400: #48bb78;
    --green-500: #38a169;
    --green-700: #067647;
    --green-800: #085d3a;
    --green-950: #0f2419;
    --blue-50: #eff8ff;
    --blue-200: #b2ddff;
    --blue-300: #84caff;
    --blue-600: #175cd3;
    --blue-700: #1849a9;
    --blue-950: #0b1f35;
    --yellow-50: #fefbe8;
    --yellow-300: #fde272;
    --yellow-400: #ecc94b;
    --yellow-500: #eab308;
    --yellow-600: #ca8a04;
    --yellow-800: #854a0e;
    --yellow-950: #2a2208;
    --amber-300: #ffc14d;
    --amber-800: #8a5200;
    --orange-800: #93370d;
    --gold: #ffac0b;
    --red-400: #f56565;
    --violet-500: #8b5cf6;
    --gray-100: #eef1f5;
    --gray-400: #a0aec0;
    --gray-500: #6b7280;
    --gray-900: #1a202c;
    --gray-a13: #8882;
    --focus-line: var(--brand-accent);

    /* The brand colors as TEXT (links, the selected menu item, brand badges and icons that stand for words). A fill
       uses --brand-primary; text never does, since the admin's color may not read on the page (the house gold is
       1.74:1 on white). lib/theme.js sets these for the brand in use with lib/contrast.js textOn: the same hue,
       darker on a light page and lighter on a dark one, until it reaches 4.5:1 on --bg, --surface, --surface-2 and
       the brand's tints up to 14 percent. These defaults are that result for the default brand. */
    --brand-text: #1c64a3;
    --brand-accent-text: #346487;
    --focus-bg: color-mix(in srgb, var(--brand-accent) 13%, transparent);
    --brand-primary: var(--brand-primary-light);
    --brand-accent: var(--brand-accent-light);

    /* Type */
    --font: 'Inter', -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, sans-serif;
    --mono: 'DM Mono', ui-monospace, sfmono-regular, menlo, monospace;
    --fs-3xs: 0.68rem;
    --fs-2xs: 0.72rem;
    --fs-xs: 0.78rem;
    --fs-sm: 0.85rem;
    --fs-md: 0.9rem;
    --fs-base: 1rem;
    --fs-lg: 1.15rem;
    --fs-xl: 1.35rem;
    --fs-2xl: 1.6rem;
    --fw-medium: 550;
    --fw-semibold: 600;
    --fw-bold: 650;

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 7px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-xl: 16px;
    --radius-pill: 999px;
    --radius-round: 50%;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
    --shadow-md: 0 4px 12px rgb(16 24 40 / 8%);
    --shadow-toast: 0 4px 12px rgb(16 24 40 / 12%);
    --shadow-lg: 0 12px 32px rgb(16 24 40 / 18%);
    --shadow-xl: 0 20px 60px rgb(0 0 0 / 25%);
    --focus-ring: 0 0 0 2px var(--ring);
    --focus-outline: 2px solid var(--ring);
    --focus-offset: 2px;
    --shadow-tab: 0 -1px 2px rgb(16 24 40 / 4%);
    --shadow-tab-open: 0 -1px 3px rgb(16 24 40 / 10%);
    --shadow-tab-dark: 0 -1px 2px rgb(0 0 0 / 25%);
    --shadow-hero: 0 20px 50px rgb(0 0 0 / 25%);
    --shadow-hero-lg: 0 20px 60px rgb(0 0 0 / 30%);
    --shadow-glow: 0 4px 15px rgb(43 136 216 / 35%);
    --shadow-glow-hover: 0 6px 20px rgb(43 136 216 / 45%);
    --shadow-xs: 0 2px 6px rgb(0 0 0 / 10%);
    --shadow-cta: 0 6px 20px rgb(12 28 87 / 40%);
    --shadow-raise: 0 4px 15px rgb(0 0 0 / 20%);
    --shadow-raise-hover: 0 6px 20px rgb(0 0 0 / 30%);
    --ring-brand-thin: 0 0 0 1px color-mix(in srgb, var(--brand-primary) 35%, transparent);
    --ring-brand-flash: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 45%, transparent);
    --ring-brand-soft: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 14%, transparent);
    --overlay: rgb(16 24 40 / 50%);
    --overlay-soft: rgb(16 24 40 / 45%);

    /* Layers */
    --z-base: 1;
    --z-raised: 3;
    --z-sticky: 5;
    --z-dropdown: 100;
    --z-overlay: 1000;
    --z-under-overlay: 998;
    --z-overlay-top: 1001;
    --z-dialog: 10000;
    --z-toast: 10001;
    --z-system: 100000;

    /* Controls */
    --control-h: 40px;
    --control-h-md: 36px;
    --control-h-sm: 32px;
    --sidebar-w: 248px;

    /* Every other step the page sheets use, each its exact old value, so moving them onto tokens
       changed nothing on screen. Font sizes: --fs-<hundredths of a rem>, --fs-em-<hundredths of an em>
       (relative to the text around it), --fs-px-<px>. Spacing: --sp-<px / 4>, so --sp-2-5 is 10px.
       --sp-vh-10 is the sign-in card's top margin. Radius: --radius-<px>. New rules pick the named steps above. */
    --fs-em-75: 0.75em;
    --fs-em-80: 0.8em;
    --fs-em-82: 0.82em;
    --fs-em-85: 0.85em;
    --fs-em-88: 0.88em;
    --fs-em-90: 0.9em;
    --fs-em-92: 0.92em;
    --fs-em-95: 0.95em;
    --fs-em-100: 1em;
    --fs-em-105: 1.05em;
    --fs-em-110: 1.1em;
    --fs-em-120: 1.2em;
    --fs-em-130: 1.3em;
    --fs-em-150: 1.5em;
    --fs-em-180: 1.8em;
    --fs-em-200: 2em;
    --fs-em-250: 2.5em;
    --fs-px-11: 11px;
    --fs-px-13: 13px;
    --fs-px-14: 14px;
    --fs-px-15: 15px;
    --fs-px-16: 16px;
    --fs-px-18: 18px;
    --fs-px-20: 20px;
    --fs-70: 0.7rem;
    --fs-74: 0.74rem;
    --fs-75: 0.75rem;
    --fs-76: 0.76rem;
    --fs-80: 0.8rem;
    --fs-82: 0.82rem;
    --fs-84: 0.84rem;
    --fs-86: 0.86rem;
    --fs-88: 0.88rem;
    --fs-92: 0.92rem;
    --fs-95: 0.95rem;
    --fs-98: 0.98rem;
    --fs-105: 1.05rem;
    --fs-108: 1.08rem;
    --fs-110: 1.1rem;
    --fs-112: 1.12rem;
    --fs-120: 1.2rem;
    --fs-125: 1.25rem;
    --fs-130: 1.3rem;
    --fs-140: 1.4rem;
    --fs-145: 1.45rem;
    --fs-150: 1.5rem;
    --fs-200: 2rem;
    --fs-225: 2.25rem;
    --sp-0-25: 1px;
    --sp-0-5: 2px;
    --sp-0-75: 3px;
    --sp-1-25: 5px;
    --sp-1-5: 6px;
    --sp-1-75: 7px;
    --sp-2-25: 9px;
    --sp-2-5: 10px;
    --sp-2-75: 11px;
    --sp-3-25: 13px;
    --sp-3-5: 14px;
    --sp-3-75: 15px;
    --sp-4-5: 18px;
    --sp-5-5: 22px;
    --sp-6-25: 25px;
    --sp-6-5: 26px;
    --sp-7: 28px;
    --sp-7-5: 30px;
    --sp-9: 36px;
    --sp-11: 44px;
    --sp-12: 48px;
    --sp-12-5: 50px;
    --sp-15: 60px;
    --sp-17-5: 70px;
    --radius-3: 3px;
    --radius-5: 5px;
    --radius-6: 6px;
    --radius-8: 8px;
    --radius-9: 9px;
    --radius-15: 15px;
    --radius-20: 20px;
    --radius-25: 25px;
    --sp-vh-10: 10vh;

    /* The printed SSO setup guide's steps (pages/admin/sso-print.css), each its exact old value. */
    --fs-pt-11: 11pt;
    --fs-pt-12: 12pt;
    --fs-pt-14: 14pt;
    --fs-pt-20: 20pt;
    --sp-pt-18: 18pt;
    --sp-mm-18: 18mm;
    --print-code-bg: #f2f4f7;

    /* The presenter window's dark look (pages/prospect/presenter.css), each its exact old value. */
    --presenter-bg: #111418;
    --presenter-button: #232831;
    --presenter-rule: #2a2f37;
    --presenter-button-hover: #2e3540;
    --presenter-button-edge: #3a414c;
    --presenter-label: #8a93a1;
    --presenter-meta: #aab2bf;

    /* The shared widgets' own steps (the notes, windows and panels lib/*.js used to style in script), each its
       exact old value. */
    --fs-65: 0.65rem;
    --amber-50: #fef0c7;
    --amber-400: #fec84b;
    --amber-850: #7a4b00;
    --amber-900: #5a3200;
    --shadow-support: 0 2px 8px rgb(0 0 0 / 25%);
    --shadow-note: 0 6px 18px rgb(16 24 40 / 16%);
    --shadow-note-lg: 0 8px 24px rgb(16 24 40 / 18%);
    --shadow-window: 0 18px 48px rgb(16 24 40 / 28%);
    --shadow-warn: 0 12px 40px rgb(0 0 0 / 30%);
    --overlay-strong: rgb(8 12 20 / 72%);
    --z-pill: 999;
    --z-support: 9999;
    --z-banner: 10002;
    --z-panel: 10003;
    --z-window: 10004;
    --ring-brand-inset: inset 0 0 0 1px var(--brand-primary);

    /* White and black see-through steps, for the overlays and the dark viewers (the image viewer, the deck
       preview, the full-screen player) that look the same in both themes. */
    --white-10: rgb(255 255 255 / 10%);
    --white-14: rgb(255 255 255 / 14%);
    --white-18: rgb(255 255 255 / 18%);
    --white-25: rgb(255 255 255 / 25%);
    --white-26: rgb(255 255 255 / 26%);
    --white-30: rgb(255 255 255 / 30%);
    --white-45: rgb(255 255 255 / 45%);
    --white-80: rgb(255 255 255 / 80%);
    --white-85: rgb(255 255 255 / 85%);
    --black-45: rgb(0 0 0 / 45%);
    --black-60: rgb(0 0 0 / 60%);
    --black-70: rgb(0 0 0 / 70%);
    --black-82: rgb(0 0 0 / 82%);
    --black-85: rgb(0 0 0 / 85%);
    --shade-55: rgb(15 18 25 / 55%);
    --viewer-bar: rgb(12 14 18 / 94%);
    --gray-a20: #8883;

    /* The estimate's four phases (Gantt bars and legend; pages/prospect/estimate.js reads them by name). */
    --ph-disc: #7aa7d9;
    --ph-build: #2b88d8;
    --ph-test: #6da19d;
    --ph-roll: #e39b07;

    /* The kinds of saved work on Home's lists: a demo and a report are the brand's two colors, a presentation and
       a scope of work mix the brand with grey, an analysis mixes the two brand colors. */
    --kind-demo: var(--brand-primary);
    --kind-report: var(--brand-accent);
    --kind-presentation: color-mix(in srgb, var(--brand-primary) 55%, var(--gray-500));
    --kind-sow: color-mix(in srgb, var(--brand-accent) 55%, var(--gray-500));
    --kind-analysis: color-mix(in srgb, var(--brand-primary) 50%, var(--brand-accent));

    /* The floating theme toggle sits over the setup wizard's card. */
    --z-wiz-toggle: 10;

    /* The demo's colors (pages/demo/theme.js sets them): --primary, --secondary and --accent are fills (with
       --*-text on top), and --*-ink the same colors adjusted to read as text or thin lines on the current page.
       They come from the app's branding unless the presenter picked colors in the demo; these defaults only
       cover the moment before it runs. */
    --primary: var(--brand-primary);
    --secondary: var(--brand-accent);
    --accent: var(--brand-accent);
    --primary-text: #fff;
    --secondary-text: #fff;
    --accent-text: #fff;
    --primary-ink: var(--brand-primary);
    --secondary-ink: var(--brand-accent);
    --accent-ink: var(--brand-accent);

    /* Status colors not in the design system, light values */
    --info: #175cd3;
    --info-bg: #eff8ff;
    --warning-bg: #fffaeb;

    /* A thin edge on filled brand areas, so a fill close to the page color
       still has a visible outline. */
    --fill-edge: inset 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent);

    /* Focus and selection rings in the demo's brand ink, and its layers. */
    --ring-primary-ink: 0 0 0 3px color-mix(in srgb, var(--primary-ink) 30%, transparent);
    --ring-primary-ink-soft: 0 0 0 3px color-mix(in srgb, var(--primary-ink) 25%, transparent);
    --ring-primary-ink-2: 0 0 0 2px var(--primary-ink);
    --ring-primary-ink-1: 0 0 0 1px var(--primary-ink);
    --ring-text: 0 0 0 3px color-mix(in srgb, var(--text) 15%, transparent);
    --ring-swatch-selected: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
    --z-notification: 9999;

    /* The page choices' swatches in Edit colors: each page's own background. */
    --swatch-light: #f7f8fa;
    --swatch-warm: #f6f2ea;
    --swatch-dark: #0b0e14;
    --swatch-slate: #1e2734;
}

/* Dark tokens: applied when the OS prefers dark and no explicit light override,
   and whenever data-theme="dark" is set. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --bg: #0b0e14;
        --surface: #12161f;
        --surface-2: #171c26;
        --border: #242b38;
        --border-strong: #313a4a;
        --text: #e6e9ef;
        --muted: #97a1b2;
        --muted-2: #8a94a6;
        --decor: #6b7688;
        --control-border: #626c7e;
        --ring: #fff;
        --on-primary: #101828;
        --danger: #f97066;
        --danger-bg: #2a1512;
        --danger-ink: #f97066;
        --success: #47cd89;
        --success-bg: #0f2419;
        --warning: #f79009;
        --warning-ink: #f79009;
        --brand-text: #5aade8;
        --brand-accent-text: #4999dd;
        --brand-primary: var(--brand-primary-dark);
        --brand-accent: var(--brand-accent-dark);
        --info: #53b1fd;
        --info-bg: #0d1f33;
        --warning-bg: #2a1d0c;

        /* The same in both themes: named here too, so every color token has a value in each theme. */
        --brand-primary-light: #1f6fb5;
        --brand-accent-light: #5aade8;
        --brand-primary-dark: #5aade8;
        --brand-accent-dark: #2b88d8;
        --ink: #101828;
        --focus-line: var(--brand-accent);
        --focus-bg: color-mix(in srgb, var(--brand-accent) 13%, transparent);
        --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
        --shadow-md: 0 4px 12px rgb(16 24 40 / 8%);
        --shadow-toast: 0 4px 12px rgb(16 24 40 / 12%);
        --shadow-lg: 0 12px 32px rgb(16 24 40 / 18%);
        --shadow-xl: 0 20px 60px rgb(0 0 0 / 25%);
        --focus-ring: 0 0 0 2px var(--ring);
        --focus-outline: 2px solid var(--ring);
        --shadow-tab: 0 -1px 2px rgb(16 24 40 / 4%);
        --shadow-tab-open: 0 -1px 3px rgb(16 24 40 / 10%);
        --shadow-tab-dark: 0 -1px 2px rgb(0 0 0 / 25%);
        --shadow-hero: 0 20px 50px rgb(0 0 0 / 25%);
        --shadow-hero-lg: 0 20px 60px rgb(0 0 0 / 30%);
        --shadow-glow: 0 4px 15px rgb(43 136 216 / 35%);
        --shadow-glow-hover: 0 6px 20px rgb(43 136 216 / 45%);
        --shadow-xs: 0 2px 6px rgb(0 0 0 / 10%);
        --shadow-cta: 0 6px 20px rgb(12 28 87 / 40%);
        --shadow-raise: 0 4px 15px rgb(0 0 0 / 20%);
        --shadow-raise-hover: 0 6px 20px rgb(0 0 0 / 30%);
        --ring-brand-thin: 0 0 0 1px color-mix(in srgb, var(--brand-primary) 35%, transparent);
        --ring-brand-flash: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 45%, transparent);
        --ring-brand-soft: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 14%, transparent);
        --print-code-bg: #f2f4f7;
        --presenter-bg: #111418;
        --shadow-support: 0 2px 8px rgb(0 0 0 / 25%);
        --shadow-note: 0 6px 18px rgb(16 24 40 / 16%);
        --shadow-note-lg: 0 8px 24px rgb(16 24 40 / 18%);
        --shadow-window: 0 18px 48px rgb(16 24 40 / 28%);
        --shadow-warn: 0 12px 40px rgb(0 0 0 / 30%);
        --ring-brand-inset: inset 0 0 0 1px var(--brand-primary);
        --accent: var(--brand-accent);
        --primary-text: #fff;
        --secondary-text: #fff;
        --accent-text: #fff;
        --primary-ink: var(--brand-primary);
        --secondary-ink: var(--brand-accent);
        --accent-ink: var(--brand-accent);
        --ring-primary-ink: 0 0 0 3px color-mix(in srgb, var(--primary-ink) 30%, transparent);
        --ring-primary-ink-soft: 0 0 0 3px color-mix(in srgb, var(--primary-ink) 25%, transparent);
        --ring-primary-ink-2: 0 0 0 2px var(--primary-ink);
        --ring-primary-ink-1: 0 0 0 1px var(--primary-ink);
        --ring-text: 0 0 0 3px color-mix(in srgb, var(--text) 15%, transparent);
        --ring-swatch-selected: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
    }
}

:root[data-theme='dark'] {
    --bg: #0b0e14;
    --surface: #12161f;
    --surface-2: #171c26;
    --border: #242b38;
    --border-strong: #313a4a;
    --text: #e6e9ef;
    --muted: #97a1b2;
    --muted-2: #8a94a6;
    --decor: #6b7688;
    --control-border: #626c7e;
    --ring: #fff;
    --on-primary: #101828;
    --danger: #f97066;
    --danger-bg: #2a1512;
    --danger-ink: #f97066;
    --success: #47cd89;
    --success-bg: #0f2419;
    --warning: #f79009;
    --warning-ink: #f79009;
    --brand-text: #5aade8;
    --brand-accent-text: #4999dd;
    --brand-primary: var(--brand-primary-dark);
    --brand-accent: var(--brand-accent-dark);
    --info: #53b1fd;
    --info-bg: #0d1f33;
    --warning-bg: #2a1d0c;

    /* The same in both themes: named here too, so every color token has a value in each theme. */
    --brand-primary-light: #1f6fb5;
    --brand-accent-light: #5aade8;
    --brand-primary-dark: #5aade8;
    --brand-accent-dark: #2b88d8;
    --ink: #101828;
    --focus-line: var(--brand-accent);
    --focus-bg: color-mix(in srgb, var(--brand-accent) 13%, transparent);
    --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
    --shadow-md: 0 4px 12px rgb(16 24 40 / 8%);
    --shadow-toast: 0 4px 12px rgb(16 24 40 / 12%);
    --shadow-lg: 0 12px 32px rgb(16 24 40 / 18%);
    --shadow-xl: 0 20px 60px rgb(0 0 0 / 25%);
    --focus-ring: 0 0 0 2px var(--ring);
    --focus-outline: 2px solid var(--ring);
    --shadow-tab: 0 -1px 2px rgb(16 24 40 / 4%);
    --shadow-tab-open: 0 -1px 3px rgb(16 24 40 / 10%);
    --shadow-tab-dark: 0 -1px 2px rgb(0 0 0 / 25%);
    --shadow-hero: 0 20px 50px rgb(0 0 0 / 25%);
    --shadow-hero-lg: 0 20px 60px rgb(0 0 0 / 30%);
    --shadow-glow: 0 4px 15px rgb(43 136 216 / 35%);
    --shadow-glow-hover: 0 6px 20px rgb(43 136 216 / 45%);
    --shadow-xs: 0 2px 6px rgb(0 0 0 / 10%);
    --shadow-cta: 0 6px 20px rgb(12 28 87 / 40%);
    --shadow-raise: 0 4px 15px rgb(0 0 0 / 20%);
    --shadow-raise-hover: 0 6px 20px rgb(0 0 0 / 30%);
    --ring-brand-thin: 0 0 0 1px color-mix(in srgb, var(--brand-primary) 35%, transparent);
    --ring-brand-flash: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 45%, transparent);
    --ring-brand-soft: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 14%, transparent);
    --print-code-bg: #f2f4f7;
    --presenter-bg: #111418;
    --shadow-support: 0 2px 8px rgb(0 0 0 / 25%);
    --shadow-note: 0 6px 18px rgb(16 24 40 / 16%);
    --shadow-note-lg: 0 8px 24px rgb(16 24 40 / 18%);
    --shadow-window: 0 18px 48px rgb(16 24 40 / 28%);
    --shadow-warn: 0 12px 40px rgb(0 0 0 / 30%);
    --ring-brand-inset: inset 0 0 0 1px var(--brand-primary);
    --accent: var(--brand-accent);
    --primary-text: #fff;
    --secondary-text: #fff;
    --accent-text: #fff;
    --primary-ink: var(--brand-primary);
    --secondary-ink: var(--brand-accent);
    --accent-ink: var(--brand-accent);
    --ring-primary-ink: 0 0 0 3px color-mix(in srgb, var(--primary-ink) 30%, transparent);
    --ring-primary-ink-soft: 0 0 0 3px color-mix(in srgb, var(--primary-ink) 25%, transparent);
    --ring-primary-ink-2: 0 0 0 2px var(--primary-ink);
    --ring-primary-ink-1: 0 0 0 1px var(--primary-ink);
    --ring-text: 0 0 0 3px color-mix(in srgb, var(--text) 15%, transparent);
    --ring-swatch-selected: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);

    color-scheme: dark;
}

/* Extra page backgrounds a presenter can pick for the demo (Edit colors). */
:root[data-demo-bg='warm'] {
    --bg: #f6f2ea;
    --surface: #fffdf9;
    --surface-2: #f2ede3;
    --border: #e7dfd0;
    --border-strong: #d8ccb7;
    --muted: #5b6272;
}

:root[data-demo-bg='slate'] {
    --bg: #1e2734;
    --surface: #263141;
    --surface-2: #2c384a;
    --border: #364357;
    --border-strong: #455269;
    --muted: #a7b1c2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    color-scheme: light dark;
}

/* Native controls (radio buttons, checkboxes, date pickers) follow the theme picked in
   the app, not the computer's: a light page on a dark computer drew dark radios, where
   the unselected one looked filled. */
:root[data-theme='light'] {
    color-scheme: light;
}

input[type='radio'],
input[type='checkbox'] {
    accent-color: var(--brand-primary);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* The keyboard focus ring for everything a person can reach with Tab: a solid line with a gap of page between it and
   the control (--focus-outline, --focus-offset); check boxes, radios and color wells too, whose browser ring is too
   faint in the dark theme. :where keeps it at no specificity, so a component that draws its own ring (a text
   field's border and ring) still does. */
:where(
    a[href],
    button,
    summary,
    select,
    input,
    [role='button'],
    [role='tab'],
    [role='menuitem'],
    [tabindex]
):focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
}

a {
    color: var(--brand-text);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* A link with no component class is a link in running text (a hint, a notice, a sentence in a dialog): it is
   underlined, so it doesn't rely on color alone to stand out from the words around it (WCAG 2.2 1.4.1). */
a:not([class]) {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

h1,
h2,
h3 {
    line-height: 1.2;
    font-weight: var(--fw-bold);
    letter-spacing: -0.01em;
}

.muted {
    color: var(--muted);
}

.mono {
    font-family: var(--mono);
}

/* Read by screen readers, not shown: a page's heading when the page shows only one line. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- Button: .btn, filled with the brand; --secondary, --ghost, --danger, --sm, --block.
   The chained names (.btn.secondary and so on) are the same rules, kept while templates move. --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    height: var(--control-h);
    padding: 0 var(--sp-4);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--brand-primary);
    color: var(--on-primary);
    font: var(--fw-semibold) var(--fs-md) var(--font);
    cursor: pointer;
    transition:
        filter 0.15s,
        background 0.15s,
        border-color 0.15s,
        opacity 0.15s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
}

/* One hover language everywhere (user rule): it has to be easy to see.
   Filled buttons darken, outlined and text buttons turn brand blue with a light tint. */
.btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--brand-primary) 82%, var(--black));
}

.btn--secondary,
.btn.secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn--secondary:hover:not(:disabled),
.btn.secondary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--brand-primary) 10%, var(--surface));
    border-color: var(--brand-primary);
    color: var(--brand-text);
    filter: none;
}

.btn--ghost,
.btn.ghost {
    background: transparent;
    color: var(--muted);
}

.btn--ghost:hover:not(:disabled),
.btn.ghost:hover:not(:disabled) {
    background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
    color: var(--brand-text);
    filter: none;
}

/* Destructive buttons look exactly like the other buttons (they follow the
   theme and branding the same way) and only turn red on hover. */
.btn--danger,
.btn.danger {
    background: var(--brand-primary);
    color: var(--on-primary);
}

.btn--danger:hover:not(:disabled),
.btn.danger:hover:not(:disabled) {
    background: var(--danger-fill);
    color: var(--white);
    filter: none;
}

.btn.ghost.danger-text:hover:not(:disabled) {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.btn--sm,
.btn.sm {
    height: var(--control-h-sm);
    padding: 0 var(--sp-3);
    font-size: var(--fs-82);
}

.btn.block {
    width: 100%;
}

/* --md: the dialog and toolbar size, a step below the default (dialogs, toasts and the demo's top bar). */
.btn--md {
    height: var(--control-h-md);
    padding: 0 var(--sp-3-5);
    font-size: var(--fs-sm);
}

.btn--md:disabled {
    opacity: 0.55;
    cursor: default;
}

/* --sync: a small square icon button beside a line of text (Sync from Gamma on a presentation). */
.btn--sync {
    width: 22px;
    height: 22px;
    gap: 0;
    margin-left: var(--sp-1);
    padding: 0;
    vertical-align: middle;
    border: 1px solid var(--border);
    border-radius: var(--radius-6);
    background: var(--surface);
    color: var(--brand-text);
}

.btn--sync:hover:not(:disabled) {
    border-color: var(--brand-primary);
    background: color-mix(in srgb, var(--brand-primary) 8%, var(--surface));
}

.btn--sync svg {
    width: 13px;
    height: 13px;
}

/* --hero: the one large call to action on a page (Report: Generate). */
.btn--hero {
    width: 100%;
    padding: var(--sp-4-5);
    background: var(--brand-primary);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius);
    font-size: var(--fs-px-18);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-cta);
}

.btn--hero:active {
    transform: translateY(0);
}

.btn--hero:disabled {
    background: var(--border-strong);
    cursor: not-allowed;
    transform: none;
}

.btn--hero:hover:not(:disabled) {
    background: color-mix(in srgb, var(--brand-primary) 82%, var(--black));
    color: var(--on-primary);
}

/* --- Form controls --- */
.label {
    display: block;
    font-size: var(--fs-82);
    font-weight: var(--fw-semibold);
    color: var(--text);
    margin-bottom: var(--sp-1-5);
}

/* Mermaid names each diagram label's group "label" too. Left alone, the form label's size and weight reach it after
   mermaid has measured the box, and the words are cut off (the demo's Process Automation workflows). */
svg .label {
    display: inline;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    margin: 0;
}

.hint {
    font-size: var(--fs-80);
    color: var(--muted);
    margin-top: var(--sp-1-5);
}

.field {
    margin-bottom: var(--sp-4-5);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}

.input,
.select,
.textarea {
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--sp-3);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
    font: var(--fs-md) var(--font);
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}

.textarea {
    height: auto;
    min-height: 92px;
    padding: var(--sp-2-5) var(--sp-3);
    resize: vertical;
    line-height: 1.5;
}

.input::placeholder,
.textarea::placeholder {
    color: var(--muted-2);
}

.select {
    appearance: none;
    cursor: pointer;
    padding-right: var(--sp-9);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23667085' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--focus-ring);
}

.input.mono {
    font-family: var(--mono);
    font-size: var(--fs-sm);
}

/* Another service's secret (an API key, a mail server's or an SSO app's): a text box drawn as dots. Chrome's password
   manager takes any page with a password box for a sign-in form and fills the box before it with the person's own
   saved sign-in, whatever autocomplete says, so these are never type="password" (lib/password-fields.js gives them
   the Show button, through its maskClass). */
.input--secret {
    -webkit-text-security: disc;
}

.input.invalid,
.select.invalid,
.textarea.invalid {
    border-color: var(--danger);
}

/* --- Password field (lib/password-fields.js, the app and the console): a Show button inside the box's right end,
   and under a new password a strength bar with a short sentence. The bar is muted for weak and short, brand for
   the rest; the sentence says it in words. --- */
.c-password {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.c-password .c-password__input {
    padding-right: var(--sp-17-5);
}

.c-password__toggle {
    position: absolute;
    top: 50%;
    right: var(--sp-1);
    transform: translateY(-50%);
}

.c-password__toggle[aria-pressed='true'] {
    color: var(--brand-text);
}

.c-strength {
    margin-top: var(--sp-1-5);
}

.c-strength__bar {
    height: var(--sp-1);
    overflow: hidden;
    background: var(--border);
    border-radius: var(--radius-pill);
}

.c-strength__fill {
    width: 0;
    height: 100%;
    background: var(--brand-primary);
    border-radius: inherit;
    transition: width 0.15s;
}

.c-strength--short .c-strength__fill {
    width: 10%;
    background: var(--warning);
}

.c-strength--weak .c-strength__fill {
    width: 25%;
    background: var(--warning);
}

.c-strength--fair .c-strength__fill {
    width: 50%;
}

.c-strength--good .c-strength__fill {
    width: 75%;
}

.c-strength--strong .c-strength__fill {
    width: 100%;
}

.c-strength__text {
    min-height: 1lh;
    margin: var(--sp-1) 0 0;
    font-size: var(--fs-80);
    color: var(--muted);
}

input[type='color'].swatch {
    width: 100%;
    height: var(--control-h);
    padding: var(--sp-1);
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
}

/* --- Card: .card with __header, __title, __desc, __body, __footer (the dashed names are the same rules) --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card__header,
.card-header {
    padding: var(--sp-5) var(--sp-5-5) 0;
}

.card__title,
/* A card's title is a heading (h2 or h3) that keeps the card's own line height and spacing, not the h2/h3 defaults. */
.card-title {
    font-size: var(--fs-105);
    font-weight: var(--fw-bold);
    line-height: inherit;
    letter-spacing: normal;
}

.card__desc,
.card-desc {
    font-size: var(--fs-sm);
    color: var(--muted);
    margin-top: var(--sp-1);
}

.card__body,
.card-body {
    padding: var(--sp-5) var(--sp-5-5);
}

.card__footer,
.card-footer {
    padding: var(--sp-4) var(--sp-5-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2-5);
}

/* --hero: the page's main panel, raised (Analyze). */
.card--hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-hero);
    padding: var(--sp-8);
    animation: slide-up 0.5s ease-out;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Badge: .badge with --brand, --success, --warning, --muted --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1-25);
    font: var(--fw-semibold) var(--fs-2xs) var(--font);
    padding: var(--sp-0-75) var(--sp-2-25);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}

.badge--brand,
.badge.brand {
    color: var(--brand-text);
    background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
    border-color: color-mix(in srgb, var(--brand-primary) 30%, transparent);
}

.badge--success,
.badge.success {
    color: var(--success);
    background: var(--success-bg);
    border-color: transparent;
}

.badge.muted {
    color: var(--muted);
}

/* --- Long tables: search and filter above, sortable headers, a pager below (admin listTable) --- */
.tbl-tools {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    align-items: center;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
}

.tbl-tools .input,
.tbl-tools .select {
    height: 34px;
    font-size: var(--fs-sm);
}

.tbl-tools .select,
.tbl-pager .select {
    width: auto;
    flex: 0 0 auto;
}

.tbl-tools .input {
    flex: 1 1 220px;
    max-width: 320px;
}

.tbl-pager {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2-5);
    align-items: center;
    justify-content: flex-end;
    padding: var(--sp-2-5) var(--sp-4);
    border-top: 1px solid var(--border);
    font-size: var(--fs-82);
    color: var(--muted);
}

.tbl-pager .select {
    height: 30px;
    font-size: var(--fs-82);
}

.tbl-pager[hidden] {
    display: none;
}

th[data-sort] {
    user-select: none;
    white-space: nowrap;
}

th[data-sort]:hover {
    color: var(--text);
}

/* The header's text is a button (lib/list-table.js puts it there), so the keyboard can sort too; it looks like the
   header text it holds. */
.th-sort {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-align: inherit;
    text-transform: inherit;
    white-space: nowrap;
    cursor: pointer;
}

th[aria-sort]::after {
    content: '';
    display: inline-block;
    margin-left: var(--sp-1-5);
    vertical-align: middle;
    border: 4px solid transparent;
}

th[aria-sort='ascending']::after {
    border-bottom-color: currentcolor;
    margin-top: calc(var(--sp-1) * -1);
}

th[aria-sort='descending']::after {
    border-top-color: currentcolor;
    margin-top: var(--sp-1);
}

.badge--warning,
.badge.warning {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 12%, transparent);
    border-color: transparent;
}

/* --- Alerts --- */
.alert {
    display: none;
    padding: var(--sp-2-75) var(--sp-3-5);
    border-radius: var(--radius-sm);
    font-size: var(--fs-86);
    margin-bottom: var(--sp-4);
    border: 1px solid transparent;
}

.alert.error {
    display: block;
    background: var(--danger-bg);
    color: var(--danger-ink);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.alert.success {
    display: block;
    background: var(--success-bg);
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

/* --- Tables --- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-88);
}

.table th {
    text-align: left;
    font-weight: var(--fw-semibold);
    color: var(--muted);
    font-size: var(--fs-75);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: var(--sp-2-5) var(--sp-3);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: var(--sp-3);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

/* --- App shell (sidebar layout) --- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: var(--sp-5) var(--sp-3-5);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2-5);
    padding: var(--sp-1) var(--sp-2) var(--sp-5);
    min-height: 40px;
}

/* The logo fills the brand slot: as wide as the sidebar allows, up to 56px tall,
   scaled to fit either limit without distortion. */
.sidebar-brand img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 56px;
    object-fit: contain;
    object-position: left center;
}

.sidebar-brand .name {
    font-weight: 700;
    font-size: var(--fs-105);
    letter-spacing: -0.01em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--sp-0-5);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2-5);
    padding: var(--sp-2-25) var(--sp-3);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
}

.nav-item:hover {
    background: color-mix(in srgb, var(--brand-primary) 8%, transparent);
    color: var(--brand-text);
}

.nav-item.active {
    background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
    color: var(--brand-text);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex: none;
}

/* Admin center menu: groups that fold, one open at a time, so the menu never needs a scroll bar. */
.sidebar.grouped .nav-item {
    font-size: var(--fs-84);
    padding: var(--sp-1-75) var(--sp-3);
}

.nav-group-head {
    display: flex;
    align-items: center;
    gap: var(--sp-1-5);
    width: 100%;
    margin-top: var(--sp-2-5);
    padding: var(--sp-1-5) var(--sp-3);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
    font-size: var(--fs-3xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text);
    border-radius: var(--radius-sm);
}

.nav-group-head:hover {
    color: var(--brand-text);
}

.nav-group-head .nav-chev {
    width: 12px;
    height: 12px;
    flex: none;
    transition: transform 0.15s;
}

.nav-group.open .nav-chev {
    transform: rotate(90deg);
}

.nav-group-head .nav-dot {
    margin-left: var(--sp-0-5);
}

.nav-group-items {
    display: none;
    flex-direction: column;
    gap: var(--sp-0-5);
    padding-top: var(--sp-0-5);
}

.nav-group.open .nav-group-items {
    display: flex;
}

.sidebar-version {
    font-family: var(--mono);
    font-size: var(--fs-3xs);
    color: var(--muted-2);
    padding: var(--sp-2) var(--sp-3);
}

.nav-count {
    margin-left: auto;
    font-size: var(--fs-70);
    font-weight: var(--fw-semibold);
    min-width: 20px;
    text-align: center;
    padding: var(--sp-0-25) var(--sp-1-75);
    border-radius: var(--radius-pill);
    color: var(--brand-text);
    background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--brand-primary) 30%, transparent);
}

.sidebar-foot {
    margin-top: auto;
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.main {
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4-5) var(--sp-8);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.topbar h1 {
    font-size: var(--fs-120);
}

.content {
    padding: var(--sp-7) var(--sp-8);
    max-width: 960px;
}

.content.wide {
    max-width: 1200px;
}

/* --- Tabs: .tabs with .tab. The open tab is filled with the primary color in light
   and dark (user rule, 2026-10-09), with the text color that reads on it (lib/theme.js works out --on-primary);
   the others have a faint look and a 12 percent primary tint on hover. Variants: --outlined (a faint
   outline and lift, the prospect page), --sub (small pills under a tab row), --fill (tabs share the row
   equally: Analyze and the demo). A page whose fill color is its own (the demo) colors its open tab in its own
   sheet. --- */

/* overflow-y hidden: with overflow-x auto the open tab's 1px overlap made a vertical scrollbar. */
.tabs {
    display: flex;
    gap: var(--sp-1);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-6);
    overflow: auto hidden;
    scrollbar-width: thin;
}

.tab {
    padding: var(--sp-2-5) var(--sp-3-5);
    border: none;
    background: none;
    color: var(--muted);
    font: var(--fw-semibold) var(--fs-88) var(--font);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: calc(var(--sp-0-25) * -1);
    white-space: nowrap;
    border-radius: var(--sp-2) var(--sp-2) 0 0;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

.tab:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--brand-primary) 12%, var(--surface));
}

.tab.active,
.tab[aria-selected='true'] {
    color: var(--on-primary);
    background: var(--brand-primary);
    border-bottom: 3px solid var(--brand-primary);
}

.tab.active:hover,
.tab[aria-selected='true']:hover {
    color: var(--on-primary);
    background: var(--brand-primary);
}

.tab .count {
    font-family: var(--mono);
    font-size: var(--fs-74);
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0 var(--sp-1-75);
    font-weight: 500;
}

.tab.active .count,
.tab[aria-selected='true'] .count {
    color: inherit;
    border-color: currentcolor;
    background: transparent;
}

/* The tab list inside a tab row that also holds a plain button (the way back): the row lays the tabs out as if
   the list weren't there, and the list carries role="tablist" so only tabs sit in it. */
.tabs__list {
    display: contents;
}

/* --outlined: tabs look like tabs, a faint outline and the lightest lift, so it's clear there is more
   to pick. The open tab keeps its fill, sits flush with the page and gets a touch more lift (the
   prospect page, .ins-tabs). */
.tabs--outlined,
.ins-tabs {
    margin: var(--sp-1) 0 0;
    overflow-y: hidden;
    scrollbar-width: none;
}

/* --sub: small pills under a tab row (Profile). */
.tabs--sub {
    margin: var(--sp-1) 0 0;
    border-bottom: none;
    gap: var(--sp-1-5);
}

.tabs--sub .tab {
    font-size: var(--fs-82);
    padding: var(--sp-1-5) var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    margin-bottom: 0;
}

.tabs--outlined .tab,
.ins-tabs .tab {
    border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
    border-bottom: 2px solid transparent;
    border-radius: var(--sp-2) var(--sp-2) 0 0;
    background: color-mix(in srgb, var(--surface) 70%, var(--bg));
    box-shadow: var(--shadow-tab);
    margin-bottom: calc(var(--sp-0-25) * -1);
}

.tabs--outlined .tab:hover,
.ins-tabs .tab:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--brand-primary) 12%, var(--surface));
}

.tabs--sub .tab.active,
.tabs--sub .tab[aria-selected='true'] {
    border: 1px solid var(--brand-primary);
}

.tabs--outlined .tab[aria-selected='true'],
.ins-tabs .tab[aria-selected='true'] {
    color: var(--on-primary);
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    border-bottom: 3px solid var(--brand-primary);
    box-shadow: var(--shadow-tab-open);
}

:root[data-theme='dark'] .tabs--outlined .tab,
:root[data-theme='dark'] .ins-tabs .tab {
    box-shadow: var(--shadow-tab-dark);
}

.tabs--outlined::-webkit-scrollbar,
.ins-tabs::-webkit-scrollbar {
    display: none;
}

/* --fill: the tabs share the row equally, with an icon beside the label (Analyze, the demo's research
   tabs, .tab-btn). Open is filled like every other tab. */
.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3-5) var(--sp-4);
    background: none;
    border: none;
    border-radius: var(--sp-2) var(--sp-2) 0 0;
    border-bottom: 3px solid transparent;
    margin-bottom: calc(var(--sp-0-5) * -1);
    font: var(--fw-semibold) var(--fs-md) var(--font);
    color: var(--muted);
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}

.tab-btn:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
}

.tab-btn.active,
.tab-btn.active:hover {
    color: var(--on-primary);
    background: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.tab-btn svg {
    width: 18px;
    height: 18px;
}

/* --- Stepbar: where a step page sits in the playbook (Analyze, Report, Presentation). The page places it. --- */
.stepbar {
    display: flex;
    align-items: center;
    gap: var(--sp-2-5);
    flex-wrap: wrap;
    padding: var(--sp-2-5) var(--sp-3-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: var(--fs-88);
}

.stepbar .step-n {
    font: var(--fw-semibold) var(--fs-2xs) var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-text);
}

.stepbar .step-links {
    margin-left: auto;
    display: flex;
    gap: var(--sp-3-5);
    flex-wrap: wrap;
}

.stepbar a {
    color: var(--brand-text);
    font-weight: 600;
    text-decoration: none;
}

.stepbar a:hover {
    text-decoration: underline;
}

/* --- Link pills: a small filled chip that takes you somewhere (e.g. a capability) --- */
.pill-link {
    display: inline-flex;
    align-items: center;
    font: 500 var(--fs-2xs) var(--font);
    color: var(--on-primary);
    background: var(--brand-primary);
    border: 1px solid var(--brand-primary);
    border-radius: var(--radius-pill);
    padding: var(--sp-0-5) var(--sp-2-25);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

.pill-link:hover {
    background: color-mix(in srgb, var(--brand-primary) 82%, var(--black));
    border-color: color-mix(in srgb, var(--brand-primary) 82%, var(--black));
    color: var(--on-primary);
    text-decoration: none;
}

.pill-link:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
}

/* --- Theme toggle --- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--surface-2);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-dark {
    display: none;
}

:root[data-theme='dark'] .theme-toggle .icon-dark {
    display: block;
}

:root[data-theme='dark'] .theme-toggle .icon-light {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) .theme-toggle .icon-dark {
        display: block;
    }

    :root:not([data-theme='light']) .theme-toggle .icon-light {
        display: none;
    }
}

/* --- Auth / wizard centered layout --- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-10) var(--sp-4);
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

.auth-head {
    text-align: center;
    margin-bottom: var(--sp-6);
}

.auth-head img {
    max-height: 44px;
    max-width: 240px;
    object-fit: contain;
    margin-bottom: var(--sp-3);
}

.auth-head .name {
    font-size: var(--fs-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-head .sub {
    color: var(--muted);
    font-size: var(--fs-92);
    margin-top: var(--sp-1);
}

/* Utilities: a state a script puts on anything, which wins over the component's own display or cursor. They sit in
   a declared layer, the one place !important is used (an important declaration in a layer beats an unlayered one). */
@layer utilities {
    .hidden {
        display: none !important;
    }

    .dx-busy {
        cursor: progress !important;
    }
}

/* --- Dialog (lib/dialog.js) and toasts (lib/toast.js), moved here from lib/dx-style.js as they were.
   .dx-dialog is the dialog; --wide (also .wide), .leave and --editor (also .editor) set its width.
   Its buttons are the one button, .btn, at the dialog size (.btn--md). --- */
.dx-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-dialog);
    background: var(--overlay-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
}

.dx-dialog {
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font);
    text-align: left;
}

.dx-dialog.wide {
    max-width: 560px;
}

/* The leave prompt has three buttons: wide enough to keep them on one row. */
.dx-dialog.leave {
    max-width: 640px;
}

/* Editors: wide, and the body scrolls so long content never pushes the buttons off screen. */
.dx-dialog.editor {
    max-width: min(1000px, 96vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

.dx-dialog .dx-body {
    padding: var(--sp-2-5) var(--sp-5-5) var(--sp-1);
    font-size: var(--fs-md);
    line-height: 1.55;
    color: var(--muted);
}

.dx-dialog.editor .dx-body {
    overflow: auto;
    flex: 1;
}

.dx-dialog h3 {
    margin: 0;
    padding: var(--sp-5) var(--sp-5-5) 0;
    font-size: var(--fs-105);
    font-weight: var(--fw-bold);
    letter-spacing: -0.01em;
    color: var(--text);
}

.dx-dialog .dx-body p {
    margin: 0 0 var(--sp-2-5);
}

.dx-foot {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: var(--sp-2);
    padding: var(--sp-3-5) var(--sp-5-5) var(--sp-4-5);
}

.dx-input {
    width: 100%;
    box-sizing: border-box;
    height: 38px;
    padding: 0 var(--sp-2-75);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: 400 var(--fs-md) var(--font);
}

.dx-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--focus-ring);
}

.dx-label {
    display: block;
    font-size: var(--fs-80);
    font-weight: var(--fw-semibold);
    color: var(--text);
    margin: var(--sp-1) 0 var(--sp-1-5);
}

.dx-err {
    display: none;
    margin: var(--sp-2-5) 0 0;
    padding: var(--sp-2-25) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-84);
    background: var(--danger-bg);
    color: var(--danger-ink);
}

.dx-err--shown {
    display: block;
}

.dx-toast {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: var(--z-toast);
    padding: var(--sp-2-25) var(--sp-3-5);
    border-radius: var(--sp-2);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-toast);
    font: 500 var(--fs-sm) var(--font);
    transition: opacity 0.3s;
}

/* --- Responsive --- */
@media (width <= 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        flex-flow: row wrap;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        flex-flow: row wrap;
    }

    .nav-group-head {
        display: none;
    }

    /* as specific as the open group's rule and later, so it wins whether the group is open or not */
    .nav-group,
    :is(.nav-group, .nav-group.open) .nav-group-items {
        display: contents;
    }

    .sidebar-foot {
        margin: 0 0 0 auto;
        flex-direction: row;
        border: none;
        padding: 0;
    }

    .content,
    .topbar {
        padding-left: var(--sp-4);
        padding-right: var(--sp-4);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ============================================================================
   Shared widgets (were constructed sheets in lib/*.js)
   The notes, windows, panels and cards the shared scripts draw on every page. They were CSS strings in the
   scripts (adopted through the CSSOM); here they sit on the tokens, and the scripts only add and remove classes.
   ============================================================================ */

/* --- Notes and windows for admins (lib/theme.js): Support view, a new release, What's new, Set up email --- */
.dx-support-view {
    position: fixed;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    z-index: var(--z-support);
    background: var(--amber-850);
    color: var(--white);
    font: var(--fw-semibold) var(--fs-px-13) / 1.3 var(--font);
    padding: var(--sp-1-5) var(--sp-3-5);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-support);
    pointer-events: none;
}

.dx-notebox {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: var(--z-toast);
    max-width: 380px;
    padding: var(--sp-3-5) var(--sp-4);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-note);
    font: 500 var(--fs-86) / 1.45 var(--font);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2-5);
}

.dx-notebox__row {
    display: flex;
    gap: var(--sp-2);
    justify-content: flex-end;
}

.dx-box-btn {
    height: 32px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-sm);
    font: var(--fw-semibold) var(--fs-82) var(--font);
    cursor: pointer;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

.dx-box-btn--primary {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: var(--on-primary);
}

.dx-veil {
    position: fixed;
    inset: 0;
    z-index: var(--z-window);
    background: var(--overlay-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
}

.dx-win {
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-window);
    font: 400 var(--fs-92) / 1.5 var(--font);
}

.dx-win--notes {
    width: min(560px, 100%);
    max-height: min(640px, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
}

.dx-win--mail {
    width: min(520px, 100%);
}

.dx-note-link {
    color: var(--primary-ink, var(--brand-text));
}

.dx-note-link--strong {
    font-weight: var(--fw-semibold);
}

.dx-win__head {
    padding: var(--sp-5) var(--sp-5-5) var(--sp-2-5);
}

.dx-win__head--tight {
    padding: var(--sp-5) var(--sp-5-5) var(--sp-1-5);
}

.dx-win__title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
}

.dx-win__sub {
    color: var(--muted);
    margin-top: var(--sp-1);
}

.dx-win__sub--6 {
    margin-top: var(--sp-1-5);
}

.dx-win__sub--8 {
    margin-top: var(--sp-2);
}

.dx-win__notes {
    padding: var(--sp-1) var(--sp-5-5) var(--sp-2);
    overflow-y: auto;
    flex: 1;
}

.dx-win__muted {
    color: var(--muted);
}

.dx-win__foot {
    padding: var(--sp-3-5) var(--sp-5-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-2-5);
}

.dx-win__actions {
    padding: var(--sp-3-5) var(--sp-5-5);
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2-5);
}

.dx-win__version {
    margin: var(--sp-1-5) 0 var(--sp-4);
}

.dx-win__version-name {
    font-weight: var(--fw-bold);
}

.dx-win__group {
    margin-top: var(--sp-1-5);
}

.dx-win__group-name {
    font-size: var(--fs-2xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.dx-win__list {
    margin: var(--sp-1) 0 0 var(--sp-4-5);
    padding: 0;
}

.dx-win__item {
    margin: var(--sp-0-5) 0;
}

.dx-win__mail-list {
    margin: var(--sp-2-5) 0 var(--sp-1) var(--sp-4-5);
    padding: 0;
}

.dx-win__mail-item {
    margin: var(--sp-0-75) 0;
}

/* --- Maintenance: the banner across the top, and action buttons greyed out while it shows --- */
.dx-maint-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-banner);
    padding: var(--sp-2-25) var(--sp-4);
    text-align: center;
    font: var(--fw-semibold) var(--fs-88) var(--font);
    color: var(--amber-900);
    background: var(--amber-50);
    border-bottom: 1px solid var(--amber-400);
}

.dx-maint body button.btn:not(.dx-overlay button, dialog button) {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
}

/* --- Notification center (lib/theme.js): the bell, its panel and the banners --- */
.nc-pair {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    flex: none;
}

.nc-bell {
    position: relative;
}

.nc-bell svg {
    width: 18px;
    height: 18px;
}

.nc-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 var(--sp-1-25);
    border-radius: var(--radius-pill);
    background: var(--brand-primary);
    color: var(--on-primary);
    font: 700 var(--fs-3xs) var(--font);
    line-height: 18px;
    text-align: center;
}

.nc-panel {
    position: fixed;
    top: var(--panel-top, auto);
    right: var(--panel-right, auto);
    z-index: var(--z-panel);
    width: min(380px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 90px));
    display: flex;
    flex-direction: column;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font);
    transition: opacity 0.4s ease;
}

/* The last notification cleared: the panel fades out on its own. */
.nc-panel.nc-fading {
    opacity: 0;
    pointer-events: none;
}

.nc-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-3-5);
    border-bottom: 1px solid var(--border);
}

.nc-head b {
    flex: 1;
    font-size: var(--fs-95);
}

.nc-act {
    background: none;
    border: 0;
    color: var(--brand-text);
    font: var(--fw-semibold) var(--fs-80) var(--font);
    cursor: pointer;
    padding: var(--sp-1) var(--sp-1-5);
    border-radius: var(--radius-6);
}

.nc-act:hover {
    background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
}

.nc-act:disabled {
    opacity: 0.45;
    cursor: default;
    background: none;
}

.nc-list {
    overflow-y: auto;
    flex: 1;
}

.nc-empty {
    padding: var(--sp-7) var(--sp-4);
    text-align: center;
    color: var(--muted);
    font-size: var(--fs-88);
}

.nc-item {
    display: flex;
    gap: var(--sp-2-5);
    align-items: flex-start;
    padding: var(--sp-2-75) var(--sp-3-5);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.nc-item:last-child {
    border-bottom: 0;
}

.nc-item:hover {
    background: color-mix(in srgb, var(--brand-primary) 6%, transparent);
}

.nc-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-round);
    margin-top: var(--sp-1-75);
    background: transparent;
}

.nc-item.unread .nc-dot {
    background: var(--brand-primary);
}

.nc-body {
    flex: 1;
    min-width: 0;
}

.nc-text {
    font-size: var(--fs-88);
    line-height: 1.4;
    overflow-wrap: break-word;
}

.nc-item.unread .nc-text {
    font-weight: var(--fw-semibold);
}

.nc-meta {
    font-size: var(--fs-75);
    color: var(--muted);
    margin-top: var(--sp-0-75);
    display: flex;
    gap: var(--sp-2-5);
}

.nc-link {
    color: var(--brand-text);
}

.nc-x {
    flex: none;
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: var(--fs-110);
    line-height: 1;
    padding: var(--sp-0-5) var(--sp-1-5);
    border-radius: var(--radius-6);
}

.nc-x:hover {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* The stack the lasting toasts and the notification banners sit in, bottom right (lib/toast.js, lib/theme.js). */
.dx-toasts {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--sp-2);
}

.nc-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    max-width: 420px;
    padding: var(--sp-2-75) var(--sp-3-5);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-note);
    font: 500 var(--fs-86) / 1.45 var(--font);
    transition: opacity 0.3s;
}

.nc-banner__body {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.nc-banner__acts {
    display: flex;
    gap: var(--sp-2-5);
    flex: none;
}

.nc-banner__act {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font: var(--fw-semibold) var(--fs-80) var(--font);
    color: var(--muted);
}

a.nc-banner__act {
    color: var(--primary-ink, var(--brand-text));
    text-decoration: none;
}

/* A toast or banner on its way out fades first (lib/toast.js, lib/theme.js). */
.dx-toast.dx-fading,
.nc-banner.dx-fading {
    opacity: 0;
}

/* A lasting toast sits in the stack instead of the corner, with its buttons in a row. */
.dx-toast.dx-toast--notice {
    position: static;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.dx-toast__btn {
    height: 30px;
    text-decoration: none;
}

/* --- Autopilot chip and its runs (lib/theme.js) --- */
.ap-run-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1-75);
    padding: var(--sp-1-25) var(--sp-2-75);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--brand-primary) 8%, var(--surface));
    color: var(--text);
    font: var(--fw-semibold) var(--fs-xs) var(--font);
    cursor: pointer;
    white-space: nowrap;
}

.ap-run-chip[hidden] {
    display: none;
}

.ap-run-chip:hover {
    border-color: var(--brand-primary);
}

@keyframes apspin {
    to {
        transform: rotate(360deg);
    }
}

.ap-run-chip__spin {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-round);
    border: 2px solid var(--brand-primary);
    border-right-color: transparent;
    animation: apspin 0.9s linear infinite;
    flex: none;
}

.nc-panel a.ap-run,
.nc-panel a.ap-run:hover {
    text-decoration: none;
    color: inherit;
}

.nc-panel .ap-run .nc-text {
    font-weight: var(--fw-semibold);
}

/* --- Click feedback (lib/theme.js DXBusy): a busy button, its spinner, and the note that says how it went --- */
.dx-busy {
    opacity: 0.85;
    pointer-events: none;
}

@keyframes dx-spin {
    to {
        transform: rotate(360deg);
    }
}

.dx-spin {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    border: 2px solid currentcolor;
    border-right-color: transparent;
    border-radius: var(--radius-round);
    animation: dx-spin 0.7s linear infinite;
    margin-right: var(--sp-1-5);
    vertical-align: -0.12em;
}

.dx-note {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: var(--z-window);
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    padding: var(--sp-2-5) var(--sp-3-5);
    border-radius: var(--radius);
    font: 500 var(--fs-md) var(--font);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-note-lg);
    max-width: min(560px, calc(100vw - 32px));
}

.dx-note button {
    font: var(--fw-semibold) var(--fs-sm) var(--font);
    padding: var(--sp-1-25) var(--sp-2-5);
    border-radius: var(--radius-8);
    border: 0;
    cursor: pointer;
    background: var(--brand-primary);
    color: var(--on-primary);
}

/* --- The app was updated while the page was open (lib/version.js) --- */
.dx-reload-bar {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-panel);
    padding: var(--sp-2-5) var(--sp-3-5);
    border-radius: var(--radius);
    font: 500 var(--fs-md) var(--font);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-note-lg);
    display: flex;
    gap: var(--sp-3);
    align-items: center;
}

.dx-reload-bar button {
    font: var(--fw-semibold) var(--fs-sm) var(--font);
    padding: var(--sp-1-5) var(--sp-3);
    border-radius: var(--radius-8);
    border: 0;
    cursor: pointer;
    background: var(--brand-primary);
    color: var(--on-primary);
}

/* --- Reports running, bottom left on the tool pages (lib/session-cache.js) --- */
.dx-running {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: var(--z-pill);
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1-75);
    padding: var(--sp-1-5) var(--sp-2-75);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font: 500 var(--fs-xs) var(--font);
    text-decoration: none;
}

.dx-running[hidden] {
    display: none;
}

.dx-running__dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-round);
    background: var(--brand-primary);
}

/* --- The signed-in person's photo in the menu (lib/app-shell.js) --- */
.side-avatar {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-round);
    object-fit: cover;
    flex: none;
}

/* --- The prospect's brand kit (lib/brand-kit.js) --- */
.bk {
    margin-top: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-3) var(--sp-3-5);
    background: var(--surface);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--sp-3) var(--sp-4);
    align-items: center;
}

.bk[hidden] {
    display: none;
}

.bk-logo {
    width: 132px;
    height: 64px;
    border: 1px solid var(--border);
    border-radius: var(--radius-8);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.bk-logo img {
    max-width: 118px;
    max-height: 52px;
    object-fit: contain;
}

.bk-logo span {
    font-size: var(--fs-75);
    color: var(--gray-500);
    text-align: center;
    padding: var(--sp-1);
}

.bk-side {
    min-width: 0;
}

.bk-t {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.bk-note {
    font-size: var(--fs-80);
    color: var(--muted);
    margin-top: var(--sp-0-5);
}

.bk-sw {
    display: flex;
    gap: var(--sp-2-5);
    margin-top: var(--sp-2);
    flex-wrap: wrap;
}

.bk-sw label {
    display: flex;
    align-items: center;
    gap: var(--sp-1-5);
    font-size: var(--fs-xs);
    color: var(--muted);
    cursor: pointer;
}

.bk-sw input[type='color'] {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-6);
    background: none;
    cursor: pointer;
}

.bk-sw input[type='color']:disabled {
    cursor: default;
}

.bk-acts {
    grid-column: 1/-1;
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    align-items: center;
}

.bk-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: var(--fs-82);
    color: var(--brand-text);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bk-link:disabled {
    opacity: 0.5;
    cursor: default;
}

.bk-err {
    grid-column: 1/-1;
    font-size: var(--fs-80);
    color: var(--danger);
}

@media (width <= 520px) {
    .bk {
        grid-template-columns: 1fr;
    }
}

/* --- PowerPoint template and images in presentations (lib/deck-settings.js) --- */
.tpl-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--sp-1-5) var(--sp-3-5);
    font-size: var(--fs-88);
    margin: var(--sp-1) 0 var(--sp-3);
}

.tpl-facts dt {
    color: var(--muted);
}

.tpl-facts dd {
    margin: 0;
}

.sw {
    display: inline-flex;
    gap: var(--sp-1);
    vertical-align: middle;
}

/* A template's or a theme's own colors, which only the script knows (lib/deck-settings.js, lib/theme-picker.js). */
[data-ds-color],
[data-tp-color] {
    background: var(--fill, transparent);
}

.sw i {
    width: 18px;
    height: 18px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    display: inline-block;
}

.tpl-warn {
    margin: 0 0 var(--sp-3);
    padding-left: var(--sp-4-5);
    font-size: var(--fs-sm);
    color: var(--warning);
}

.tpl-drop {
    display: block;
    cursor: pointer;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: var(--sp-4);
    text-align: center;
    font-size: var(--fs-md);
    color: var(--muted);
}

.tpl-drop.over {
    border-color: var(--brand-primary);
    background: var(--surface-2);
}

.ds-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2-5);
}

.ds-state {
    font-size: var(--fs-sm);
    color: var(--muted);
    margin-bottom: var(--sp-2-5);
}

.ph-on {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: var(--fw-semibold);
    cursor: pointer;
}

.ph-src {
    display: grid;
    gap: var(--sp-2);
    margin-top: var(--sp-1-5);
    font-size: var(--fs-md);
}

.ph-src label {
    display: flex;
    gap: var(--sp-2);
    align-items: baseline;
    cursor: pointer;
}

.ph-src b {
    margin-right: var(--sp-1);
}

.ph-legacy {
    margin: var(--sp-2-5) 0 0;
    padding: var(--sp-2-5) var(--sp-3);
    border-radius: var(--radius-8);
    font-size: var(--fs-86);
    background: color-mix(in srgb, var(--warning) 8%, transparent);
    color: var(--text);
}

.px-result {
    margin: 0;
    padding: 0 var(--sp-5) var(--sp-3);
    font-size: var(--fs-88);
    min-height: 0;
}

.px-result:empty {
    display: none;
}

.px-result.ok {
    color: var(--success);
}

.px-result.bad {
    color: var(--danger);
}

.card-body .hint.ds-hint-flush {
    margin-top: 0;
}

.card-body .label.ds-gap,
.card-body .ds-state.ds-gap {
    margin-top: var(--sp-3-5);
}

/* --- Gamma theme gallery (lib/theme-picker.js): the dialog, its grid and the drawn previews --- */
.dx-dialog.tp-dlg {
    max-width: min(1040px, 96vw);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.dx-dialog.tp-dlg .dx-body {
    overflow: auto;
    flex: 1;
}

.tp-dlg .dx-foot {
    justify-content: space-between;
}

.tp-tools {
    display: flex;
    align-items: center;
    gap: var(--sp-2-5);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}

.tp-search {
    height: 36px;
    padding: 0 var(--sp-2-75);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: 400 var(--fs-88) var(--font);
    width: 220px;
    margin-left: auto;
}

.tp-filters {
    display: flex;
    gap: var(--sp-1-5);
}

.tp-f {
    border: 1px solid var(--border);
    background: none;
    color: var(--muted);
    border-radius: var(--radius-pill);
    padding: var(--sp-1) var(--sp-2-75);
    font: 500 var(--fs-80) var(--font);
    cursor: pointer;
}

.tp-f.on {
    color: var(--brand-text);
    border-color: var(--brand-primary);
}

.tp-note {
    font-size: var(--fs-80);
    color: var(--muted);
    margin: 0 0 var(--sp-3);
}

.tp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--sp-3-5);
}

.tp-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    color: inherit;
    font: inherit;
    transition:
        border-color 0.15s,
        transform 0.12s;
}

.tp-card:hover {
    border-color: var(--brand-primary);
    transform: translateY(-2px);
}

.tp-card.cur {
    border: 2px solid var(--brand-primary);
}

.tp-slide {
    aspect-ratio: 16/9;
    padding: var(--sp-3) var(--sp-3-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1-5);
    position: relative;
}

.tp-slide .t {
    height: 9px;
    width: 62%;
    border-radius: var(--radius-3);
}

.tp-slide .l {
    height: 5px;
    border-radius: var(--radius-3);
    opacity: 0.55;
}

.tp-slide .l--80 {
    width: 80%;
}

.tp-slide .l--70 {
    width: 70%;
}

.tp-slide .l--45 {
    width: 45%;
}

.tp-slide .a {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    gap: var(--sp-1-25);
}

.tp-slide .a span {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-5);
}

.tp-slide .bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
}

.tp-meta {
    padding: var(--sp-2) var(--sp-2-5);
    border-top: 1px solid var(--border);
}

.tp-name {
    font-weight: var(--fw-bold);
    font-size: var(--fs-86);
    display: flex;
    align-items: center;
    gap: var(--sp-1-5);
}

.tp-tag {
    font-size: var(--fs-65);
    font-weight: var(--fw-semibold);
    padding: var(--sp-0-25) var(--sp-1-5);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    color: var(--muted);
}

.tp-tone {
    font-size: var(--fs-74);
    color: var(--muted);
    margin-top: var(--sp-0-5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tp-empty {
    color: var(--muted);
    font-size: var(--fs-88);
    padding: var(--sp-5) 0;
}

.tp-label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2-5);
}

.tp-label__thumb {
    display: inline-block;
    width: 132px;
    border-radius: var(--radius-6);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* --- Share and delete dialogs (lib/actions.js) --- */
.share-opt {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: var(--sp-1-5) 0;
    color: var(--text);
    font-size: var(--fs-md);
    cursor: pointer;
}

.share-people {
    margin-top: var(--sp-2-5);
}

.share-people[hidden],
.share-pager[hidden] {
    display: none;
}

.share-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-8);
    margin-top: var(--sp-2);
    max-height: 240px;
    overflow: auto;
}

.share-list label {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1-75) var(--sp-2-5);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: var(--fs-86);
    cursor: pointer;
}

.share-list label:last-child {
    border-bottom: none;
}

.share-list .none {
    padding: var(--sp-2-5);
    font-size: var(--fs-sm);
    color: var(--muted);
}

.share-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1-5);
    margin-top: var(--sp-2);
}

.share-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--fs-xs);
    padding: var(--sp-0-5) var(--sp-1) var(--sp-0-5) var(--sp-2-25);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.share-chip button {
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: var(--fs-95);
    line-height: 1;
    padding: 0 var(--sp-1);
}

.share-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--sp-1-5);
    font-size: var(--fs-80);
}

.why-opt {
    display: flex;
    gap: var(--sp-2-5);
    align-items: flex-start;
    padding: var(--sp-2-5) var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-8);
    margin: var(--sp-2) 0;
    cursor: pointer;
    color: var(--text);
    font-size: var(--fs-md);
}

.why-opt[hidden] {
    display: none;
}

.why-opt small {
    display: block;
    color: var(--muted);
    font-size: var(--fs-80);
    margin-top: var(--sp-0-5);
}

/* The chosen option has to be obvious in light and dark: brand border, tint, filled control. */
.why-opt input {
    accent-color: var(--brand-primary);
    width: 16px;
    height: 16px;
    margin-top: var(--sp-0-5);
    flex: none;
}

.why-opt:has(input:checked) {
    border-color: var(--brand-primary);
    background: color-mix(in srgb, var(--brand-primary) 8%, transparent);
    box-shadow: var(--ring-brand-inset);
}

.why-opt:has(input:checked) > span {
    font-weight: var(--fw-semibold);
}

.why-opt:has(input:checked) > span small {
    font-weight: 400;
}

/* --- Phones and tablets: the one-time warning (small-screen.js) --- */
.ss-warn {
    position: fixed;
    inset: 0;
    z-index: var(--z-system);
    background: var(--overlay-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
}

.ss-warn__box {
    max-width: 420px;
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    font-family: var(--font);
    box-shadow: var(--shadow-warn);
}

.ss-warn__title {
    margin: 0 0 var(--sp-2-5);
    font-size: var(--fs-lg);
}

.ss-warn__text {
    margin: 0 0 var(--sp-2-5);
    line-height: 1.55;
    color: var(--muted);
    font-size: var(--fs-95);
}

.ss-warn__text--last {
    margin-bottom: var(--sp-4-5);
}

.ss-warn__btn {
    width: 100%;
    min-height: 44px;
    border-radius: var(--radius-8);
    border: 1px solid var(--border);
    background: transparent;
    color: inherit;
    font: var(--fw-semibold) var(--fs-95) var(--font);
    cursor: pointer;
}
