:root,
[data-theme='light'] {
    color-scheme: light;

    /* Brand */
    --sos-brand-primary: #51065c;
    --sos-brand-accent: #76227c;
    --sos-brand-text: #353744;
    --sos-brand-ink: var(--sos-brand-primary);
    --sos-brand-accent-ink: var(--sos-brand-accent);

    /* Surfaces */
    --sos-fresha-bg: #eef1f4;
    --sos-fresha-surface: #ffffff;
    --sos-fresha-surface-2: #e4e8ee;
    --sos-fresha-border: #cfd6df;
    --sos-fresha-text: #1a1f26;
    --sos-fresha-muted: #667085;
    --sos-fresha-purple: #7b61ff;

    /* Calendar aliases */
    --sos-calendar-bg: #eef1f4;
    --sos-calendar-grid: #ffffff;
    --sos-calendar-line: #cfd6df;
    --sos-calendar-text: #1a1f26;
    --sos-calendar-muted: #667085;
    --sos-calendar-outside: #dce2ea;
    --sos-calendar-outside-hover: #d0d7e1;
    --sos-calendar-outside-text: #6b7280;
    --sos-calendar-hatch: rgba(26, 31, 38, 0.06);
    --sos-calendar-hatch-strong: rgba(26, 31, 38, 0.09);
    --sos-calendar-hover-wash: rgba(26, 31, 38, 0.04);
    --sos-calendar-hover-line: rgba(26, 31, 38, 0.18);
    --sos-calendar-col-hover-line: rgba(26, 31, 38, 0.22);
    --sos-calendar-control-bg: #ffffff;
    --sos-calendar-control-bg-hover: #f3f5f8;
    --sos-calendar-menu-bg: #ffffff;
    --sos-calendar-solid-bg: #1a1f26;
    --sos-calendar-solid-fg: #ffffff;

    /* Auth inputs */
    --sos-auth-input-bg: #ffffff;
    --sos-auth-input-border: #c5ccd6;

    /* Radius - soft spa edges, not oversized */
    --sos-radius-xs: 4px;
    --sos-radius-sm: 6px;
    --sos-radius-md: 8px;
    --sos-radius-lg: 12px;
    --sos-radius-xl: 16px;
    --sos-radius-pill: 999px;

    /* Spacing */
    --sos-space-1: 4px;
    --sos-space-2: 8px;
    --sos-space-3: 12px;
    --sos-space-4: 16px;
    --sos-space-5: 20px;
    --sos-space-6: 24px;
    --sos-space-8: 32px;

    /* Elevation */
    --sos-shadow-sm: 0 2px 8px rgba(26, 31, 38, 0.08);
    --sos-shadow-md: 0 8px 24px rgba(26, 31, 38, 0.12);

    /* Focus */
    --sos-focus-ring: color-mix(in srgb, var(--sos-brand-primary) 55%, transparent);

    /* Semantic status (finance / ops) */
    --sos-status-ok: #15803d;
    --sos-status-ok-border: #86efac;
    --sos-status-warn: #a16207;
    --sos-status-warn-border: #fde68a;
    --sos-status-danger: #b91c1c;
    --sos-status-danger-border: #fecaca;
    --sos-status-info: #1d4ed8;
    --sos-status-info-border: #bfdbfe;
    --sos-status-deposit: #166534;
    --sos-status-deposit-border: #86efac;
    --sos-status-due: #9a3412;

    /* Interactive hover wash */
    --sos-hover-wash: rgba(26, 31, 38, 0.04);
    --sos-hover-wash-strong: rgba(26, 31, 38, 0.08);
}

[data-theme='dark'] {
    color-scheme: dark;
    --sos-brand-ink: color-mix(in srgb, var(--sos-brand-primary) 25%, white);
    --sos-brand-accent-ink: color-mix(in srgb, var(--sos-brand-accent) 25%, white);

    --sos-fresha-bg: #171b20;
    --sos-fresha-surface: #22272e;
    --sos-fresha-surface-2: #2b313a;
    --sos-fresha-border: #353c46;
    --sos-fresha-text: #ffffff;
    --sos-fresha-muted: #9ca3af;

    --sos-calendar-bg: #171b20;
    --sos-calendar-grid: #1f242b;
    --sos-calendar-line: #353c46;
    --sos-calendar-text: #ffffff;
    --sos-calendar-muted: #9ca3af;
    --sos-calendar-outside: #2a3038;
    --sos-calendar-outside-hover: #323942;
    --sos-calendar-outside-text: #7a8494;
    --sos-calendar-hatch: rgba(255, 255, 255, 0.045);
    --sos-calendar-hatch-strong: rgba(255, 255, 255, 0.06);
    --sos-calendar-hover-wash: rgba(255, 255, 255, 0.03);
    --sos-calendar-hover-line: rgba(255, 255, 255, 0.28);
    --sos-calendar-col-hover-line: rgba(255, 255, 255, 0.32);
    --sos-calendar-control-bg: #1a1b1e;
    --sos-calendar-control-bg-hover: #222327;
    --sos-calendar-menu-bg: #1c1d20;
    --sos-calendar-solid-bg: #ffffff;
    --sos-calendar-solid-fg: #111111;

    --sos-auth-input-bg: #2b313a;
    --sos-auth-input-border: #3f4652;

    --sos-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.18);
    --sos-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.22);

    --sos-status-ok: #4ade80;
    --sos-status-ok-border: #166534;
    --sos-status-warn: #fbbf24;
    --sos-status-warn-border: #78350f;
    --sos-status-danger: #f87171;
    --sos-status-danger-border: #7f1d1d;
    --sos-status-info: #93c5fd;
    --sos-status-info-border: #1e3a5f;
    --sos-status-deposit: #86efac;
    --sos-status-deposit-border: #166534;
    --sos-status-due: #f0b27a;

    --sos-hover-wash: rgba(255, 255, 255, 0.04);
    --sos-hover-wash-strong: rgba(255, 255, 255, 0.07);
}

/* Additional palettes retain their light/dark base for component compatibility. */
[data-palette='lavender'] {
    --sos-palette-bg: #f2edf7;
    --sos-palette-surface: #fffafd;
    --sos-palette-surface-2: #e8def0;
    --sos-palette-border: #d7c8e0;
    --sos-palette-text: #322b3d;
    --sos-palette-muted: #6f617c;
    --sos-palette-accent: #80519c;
    --sos-palette-accent-hover: #6b3e86;
    --sos-palette-link: #714288;
    --sos-palette-outside: #e5dced;
}

[data-palette='blush'] {
    --sos-palette-bg: #faf3f5;
    --sos-palette-surface: #fffdfd;
    --sos-palette-surface-2: #f4e5eb;
    --sos-palette-border: #e3cdd6;
    --sos-palette-text: #3b2d35;
    --sos-palette-muted: #7b6670;
    --sos-palette-accent: #9d506e;
    --sos-palette-accent-hover: #88405d;
    --sos-palette-link: #8e405f;
    --sos-palette-outside: #efe0e6;
}

[data-palette='sage'] {
    --sos-palette-bg: #f1f4ed;
    --sos-palette-surface: #fdfef9;
    --sos-palette-surface-2: #e5ebdf;
    --sos-palette-border: #cdd8c7;
    --sos-palette-text: #2d382f;
    --sos-palette-muted: #627260;
    --sos-palette-accent: #527357;
    --sos-palette-accent-hover: #405e46;
    --sos-palette-link: #45684c;
    --sos-palette-outside: #e1e8db;
}

[data-palette='plum'] {
    --sos-palette-bg: #241e2b;
    --sos-palette-surface: #302737;
    --sos-palette-surface-2: #3b3143;
    --sos-palette-border: #514459;
    --sos-palette-text: #f3edf6;
    --sos-palette-muted: #bcb0c6;
    --sos-palette-accent: #83529c;
    --sos-palette-accent-hover: #70418a;
    --sos-palette-link: #dcb9ed;
    --sos-palette-outside: #2c2533;
}

[data-palette='twilight'] {
    --sos-palette-bg: #202831;
    --sos-palette-surface: #29343f;
    --sos-palette-surface-2: #34414d;
    --sos-palette-border: #4b5967;
    --sos-palette-text: #eef2f6;
    --sos-palette-muted: #b0bbc8;
    --sos-palette-accent: #875b8c;
    --sos-palette-accent-hover: #754b7a;
    --sos-palette-link: #dfb9e3;
    --sos-palette-outside: #26303b;
}

html[data-palette]:not([data-palette='light']):not([data-palette='dark']) {
    /* Explicit palette choices override the organisation's inline accents. */
    --sos-brand-primary: var(--sos-palette-accent) !important;
    --sos-brand-accent: var(--sos-palette-accent-hover) !important;
    --sos-brand-text: var(--sos-palette-text) !important;
    --sos-fresha-purple: var(--sos-palette-accent) !important;
    --sos-brand-ink: var(--sos-palette-link);
    --sos-brand-accent-ink: var(--sos-palette-link);
    --sos-fresha-bg: var(--sos-palette-bg);
    --sos-fresha-surface: var(--sos-palette-surface);
    --sos-fresha-surface-2: var(--sos-palette-surface-2);
    --sos-fresha-border: var(--sos-palette-border);
    --sos-fresha-text: var(--sos-palette-text);
    --sos-fresha-muted: var(--sos-palette-muted);
    --sos-calendar-bg: var(--sos-palette-bg);
    --sos-calendar-grid: var(--sos-palette-surface);
    --sos-calendar-line: var(--sos-palette-border);
    --sos-calendar-text: var(--sos-palette-text);
    --sos-calendar-muted: var(--sos-palette-muted);
    --sos-calendar-outside: var(--sos-palette-outside);
    --sos-calendar-outside-hover: var(--sos-palette-surface-2);
    --sos-calendar-outside-text: var(--sos-palette-muted);
    --sos-calendar-control-bg: var(--sos-palette-surface);
    --sos-calendar-control-bg-hover: var(--sos-palette-surface-2);
    --sos-calendar-menu-bg: var(--sos-palette-surface);
    --sos-calendar-solid-bg: var(--sos-palette-text);
    --sos-calendar-solid-fg: var(--sos-palette-surface);
    --sos-auth-input-bg: var(--sos-palette-surface);
    --sos-auth-input-border: var(--sos-palette-border);
}

/* Smooth theme crossfade (class toggled in core.js) */
html.sos-theme-animating,
html.sos-theme-animating body,
html.sos-theme-animating body * {
    transition:
        background-color 0.45s ease,
        color 0.45s ease,
        border-color 0.45s ease,
        box-shadow 0.45s ease,
        fill 0.45s ease,
        stroke 0.45s ease,
        outline-color 0.45s ease !important;
}
