/* ContextIndex design tokens. Dark is the default look; [data-theme="light"] on <html> switches the palette
   (any element may set data-theme to render a subtree in the other theme, e.g. the UI kit).
   js/theme-init.js sets data-theme before the first paint (stored choice, else prefers-color-scheme).
   Every text/background pair is checked against WCAG 2.2 AA (see docs/design-system.md). */

:root,
[data-theme="dark"] {
    color-scheme: dark;

    /* Surfaces */
    --ci-bg: #0A0C10;
    --ci-sidebar: #0C0F14;
    --ci-surface: #0F1218;
    --ci-surface-2: #121722;
    --ci-surface-3: #18202D;
    --ci-inset: #0A0D12;
    --ci-hover: #121722;
    --ci-selected: #131A25;
    --ci-border: #1C2130;
    --ci-border-subtle: #171C26;
    --ci-border-strong: #2A3244;
    --ci-border-focus: #2B3C55;
    /* Boundary of form controls: at least 3:1 against the surfaces (WCAG 1.4.11). */
    --ci-control-border: #5D6880;
    --ci-control-border-hover: #75819A;

    /* Text */
    --ci-text: #E6E8EE;
    --ci-text-strong: #F2F4F8;
    --ci-text-2: #A9B1C2;
    --ci-text-muted: #8A93A6;
    --ci-text-dim: #838CA0;

    /* Accent */
    --ci-accent: #5EEAD4;
    --ci-accent-hover: #99F6E4;
    --ci-on-accent: #04201C;
    --ci-accent-text: #5EEAD4;
    --ci-accent-soft: #142028;
    --ci-accent-soft-border: #1E3A3A;
    --ci-accent-2: #A78BFA;
    --ci-accent-2-text: #C4B2FF;
    --ci-accent-2-soft: #12101A;
    --ci-accent-2-border: #2E2747;
    --ci-inverse-bg: #E6E8EE;
    --ci-inverse-text: #0A0C10;

    /* Brand mark and wordmark on dark backgrounds (docs/brand/README.md); fixed brand colours, not the UI accent. */
    --ci-brand-frame: var(--ci-brand-mint);
    --ci-brand-lines: var(--ci-brand-paper);
    --ci-brand-dot: var(--ci-brand-violet);
    --ci-brand-word: var(--ci-brand-paper);
    --ci-brand-word-accent: var(--ci-brand-mint);

    /* Status */
    --ci-success: #5EEAD4;
    --ci-success-text: #5EEAD4;
    --ci-success-soft: #0E1A19;
    --ci-success-border: #1E4A44;
    --ci-info: #7CB4FF;
    --ci-info-text: #9CC4FF;
    --ci-info-soft: #0E1522;
    --ci-info-border: #1E3350;
    --ci-warning: #F5C76B;
    --ci-warning-text: #F5C76B;
    --ci-warning-soft: #15130C;
    --ci-warning-border: #3A3220;
    --ci-warning-strong-border: #5B4A22;
    --ci-error: #FF8A8A;
    --ci-error-text: #FF9C9C;
    --ci-error-soft: #160F12;
    --ci-error-border: #3A1F25;
    --ci-neutral-text: #A9B1C2;
    --ci-neutral-soft: #141924;
    --ci-neutral-border: #2A3244;

    /* Data visualisation */
    --ci-chart-1: #5EEAD4;
    --ci-chart-2: #7CB4FF;
    --ci-chart-3: #A78BFA;
    --ci-chart-4: #F5C76B;
    --ci-chart-error: #FF8A8A;
    --ci-chart-grid: #1A1F2B;
    --ci-chart-axis: #262D3D;
    --ci-track: #1A2232;

    /* Code */
    --ci-code-bg: #0A0D12;
    --ci-code-text: #D7DCE5;
    --ci-line-number: #838CA0;
    /* Syntax highlighting of code in chat answers (>= 4.5:1 on code-bg and surface-3). */
    --ci-code-keyword: #C4B2FF;
    --ci-code-string: #8FD9A8;
    --ci-code-comment: #8A93A6;
    --ci-code-number: #F5C76B;
    --ci-code-type: #7CB4FF;
    --ci-code-attr: #5EEAD4;
    --ci-line-highlight: rgba(245, 199, 107, 0.12);
    --ci-mark-bg: rgba(94, 234, 212, 0.16);
    --ci-mark-text: #E6E8EE;

    /* Effects (used sparingly: hero/search panels and evidence panels only) */
    --ci-grid-line: rgba(255, 255, 255, 0.035);
    --ci-glow: radial-gradient(circle, rgba(94, 234, 212, 0.16), rgba(167, 139, 250, 0.08) 40%, transparent 68%);
    --ci-hero-bg: #0D1219;
    --ci-hero-border: #22304A;
    --ci-scrim: rgba(4, 6, 10, 0.68);
    --ci-shadow-overlay: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--ci-border-strong);
    --ci-scrollbar: #2A3244;
}

[data-theme="light"] {
    color-scheme: light;

    --ci-bg: #F7F8FA;
    --ci-sidebar: #F1F3F6;
    --ci-surface: #FFFFFF;
    --ci-surface-2: #F3F5F8;
    --ci-surface-3: #E9EDF2;
    --ci-inset: #F5F7FA;
    --ci-hover: #EEF1F5;
    --ci-selected: #E6F4F1;
    --ci-border: #E3E6EC;
    --ci-border-subtle: #EBEEF2;
    --ci-border-strong: #CDD3DD;
    --ci-border-focus: #8FA3C0;
    --ci-control-border: #7B8597;
    --ci-control-border-hover: #646E80;

    --ci-text: #0F1420;
    --ci-text-strong: #070A12;
    --ci-text-2: #384152;
    --ci-text-muted: #5B6475;
    --ci-text-dim: #5F6879;

    --ci-accent: #0B7F70;
    --ci-accent-hover: #086A5D;
    --ci-on-accent: #FFFFFF;
    --ci-accent-text: #0A7466;
    --ci-accent-soft: #E3F5F2;
    --ci-accent-soft-border: #A9DED6;
    --ci-accent-2: #6D4ED8;
    --ci-accent-2-text: #5B3CC4;
    --ci-accent-2-soft: #F1EDFD;
    --ci-accent-2-border: #D3C7F6;
    --ci-inverse-bg: #0F1420;
    --ci-inverse-text: #FFFFFF;

    /* Brand mark and wordmark on light backgrounds. */
    --ci-brand-frame: var(--ci-brand-teal);
    --ci-brand-lines: var(--ci-brand-ink);
    --ci-brand-dot: var(--ci-brand-violet-deep);
    --ci-brand-word: var(--ci-brand-ink);
    --ci-brand-word-accent: var(--ci-brand-teal);

    --ci-success: #0B7F70;
    --ci-success-text: #0A6E61;
    --ci-success-soft: #E8F6F3;
    --ci-success-border: #A9DED6;
    --ci-info: #2F6FD6;
    --ci-info-text: #1F58B5;
    --ci-info-soft: #EDF3FD;
    --ci-info-border: #B8CEF3;
    --ci-warning: #B7791F;
    --ci-warning-text: #7F5200;
    --ci-warning-soft: #FDF6E7;
    --ci-warning-border: #EBD3A0;
    --ci-warning-strong-border: #C99A3E;
    --ci-error: #D33A3A;
    --ci-error-text: #B42323;
    --ci-error-soft: #FDF0F0;
    --ci-error-border: #F0C2C2;
    --ci-neutral-text: #384152;
    --ci-neutral-soft: #F1F3F6;
    --ci-neutral-border: #CDD3DD;

    --ci-chart-1: #0E9F8C;
    --ci-chart-2: #2F6FD6;
    --ci-chart-3: #6D4ED8;
    --ci-chart-4: #B7791F;
    --ci-chart-error: #D33A3A;
    --ci-chart-grid: #EBEEF2;
    --ci-chart-axis: #CDD3DD;
    --ci-track: #E3E6EC;

    --ci-code-bg: #F5F7FA;
    --ci-code-text: #1B2230;
    --ci-line-number: #5F6879;
    --ci-code-keyword: #6D3FD1;
    --ci-code-string: #1E7A3C;
    --ci-code-comment: #5F6879;
    --ci-code-number: #8A5A00;
    --ci-code-type: #1F5FBF;
    --ci-code-attr: #0E6E64;
    --ci-line-highlight: rgba(183, 121, 31, 0.14);
    --ci-mark-bg: rgba(11, 127, 112, 0.14);
    --ci-mark-text: #0F1420;

    --ci-grid-line: rgba(15, 20, 32, 0.045);
    --ci-glow: radial-gradient(circle, rgba(14, 159, 140, 0.12), rgba(109, 78, 216, 0.06) 40%, transparent 68%);
    --ci-hero-bg: #FBFCFD;
    --ci-hero-border: #D5DDE8;
    --ci-scrim: rgba(15, 20, 32, 0.42);
    --ci-shadow-overlay: 0 16px 48px rgba(15, 20, 32, 0.16), 0 0 0 1px var(--ci-border-strong);
    --ci-scrollbar: #CDD3DD;
}

:root {
    /* Brand palette (docs/brand/README.md), the same in both themes: the dark variant of the mark and wordmark uses mint,
       paper and violet, the light variant teal, ink and deep violet. Components use the themed --ci-brand-* tokens above. */
    --ci-brand-mint: #5EEAD4;
    --ci-brand-paper: #E6E8EE;
    --ci-brand-violet: #A78BFA;
    --ci-brand-teal: #0E8F7E;
    --ci-brand-ink: #0F1420;
    --ci-brand-violet-deep: #6D4FD8;

    /* Type */
    --ci-font-ui: "Inter", "Noto Sans Arabic", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --ci-font-display: "Space Grotesk", "Inter", "Noto Sans Arabic", "Segoe UI", system-ui, sans-serif;
    --ci-font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
    --ci-text-xs: 11px;
    --ci-text-sm: 12.5px;
    --ci-text-md: 13.5px;
    --ci-text-base: 14px;
    --ci-text-lg: 15px;
    --ci-text-xl: 18px;
    --ci-text-2xl: 22px;
    --ci-text-3xl: 26px;
    --ci-text-h1: 30px;

    /* Radius */
    --ci-radius-sm: 8px;
    --ci-radius-md: 10px;
    --ci-radius-lg: 14px;
    --ci-radius-xl: 18px;
    --ci-radius-pill: 999px;

    /* Spacing (4-based) */
    --ci-space-1: 4px;
    --ci-space-2: 8px;
    --ci-space-3: 12px;
    --ci-space-4: 16px;
    --ci-space-5: 20px;
    --ci-space-6: 24px;
    --ci-space-7: 28px;
    --ci-space-8: 32px;

    /* Controls */
    --ci-control-h: 40px;
    --ci-control-h-sm: 32px;
    --ci-control-h-lg: 44px;

    /* Shell */
    --ci-sidebar-w: 248px;
    --ci-sidebar-w-collapsed: 68px;
    --ci-topbar-h: 68px;
    --ci-content-max: 1280px;

    /* The 2 px mint -> violet line on AI/evidence panels */
    --ci-evidence-line: linear-gradient(90deg, var(--ci-accent), var(--ci-accent-2));

    --ci-ease: cubic-bezier(.2, .7, .2, 1);
    --ci-duration: 140ms;
}
