/* ---------------------------------------------------------------------------
   Regree design tokens.
   Light is the base definition; dark overrides only the values that change.
   Never define a colour for the first time inside a media query.
   --------------------------------------------------------------------------- */

:root {
    color-scheme: dark light;

    /* --- surfaces (light) --- */
    --bg-base: #F5F7FA;
    --bg-surface: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-hover: #F1F4F9;
    --bg-sunken: #EDF0F5;
    --bg-inset: #F8FAFC;

    --border: #E1E6EF;
    --border-strong: #CBD3E1;

    --text-primary: #0F172A;
    --text-secondary: #56617A;
    --text-muted: #8A94A8;
    --text-inverse: #FFFFFF;

    /* --- brand --- */
    --brand: #2563EB;
    --brand-hover: #1D4ED8;
    --brand-soft: rgba(37, 99, 235, .10);
    --brand-border: rgba(37, 99, 235, .30);

    /* --- market semantics --- */
    --bull: #05996B;
    --bull-soft: rgba(5, 153, 107, .10);
    --bull-bar: rgba(5, 153, 107, .22);

    --bear: #DC2743;
    --bear-soft: rgba(220, 39, 67, .10);
    --bear-bar: rgba(220, 39, 67, .22);

    --flat: #8A94A8;
    --warn: #C2820B;
    --warn-soft: rgba(194, 130, 11, .12);
    --info: #2563EB;
    --info-soft: rgba(37, 99, 235, .10);

    /* --- call / put column tints --- */
    --call-tint: rgba(5, 153, 107, .045);
    --put-tint: rgba(220, 39, 67, .045);
    --atm-tint: rgba(37, 99, 235, .10);

    /* --- shape --- */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --shadow-1: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-2: 0 8px 24px rgba(15, 23, 42, .10);
    --shadow-3: 0 20px 50px rgba(15, 23, 42, .16);

    /* --- type --- */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-num: 'JetBrains Mono', 'SF Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

    /* Up one step across the scale. The old base of 13px is terminal-dense and
       fine for a trader staring at it all day, but it reads as cramped to
       everyone else - and the smallest sizes were doing real work in table
       cells and tile captions, where 11px is below comfortable. The ratios
       between steps are unchanged, so nothing re-flows out of proportion. */
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 15px;
    --fs-lg: 17px;
    --fs-xl: 21px;
    --fs-2xl: 27px;
    --fs-3xl: 35px;

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

    /* --- layout --- */
    --sidebar-w: 236px;
    --sidebar-collapsed: 64px;
    --topbar-h: 56px;
    --bottomnav-h: 60px;

    --ease: cubic-bezier(.4, 0, .2, 1);
    --dur: 160ms;
}

/* --- dark, the default look --- */
:root:not([data-theme="light"]) {
    --bg-base: #0B0E14;
    --bg-surface: #141821;
    --bg-elevated: #1B2029;
    --bg-hover: #222836;
    --bg-sunken: #0F131B;
    --bg-inset: #10151D;

    --border: #232A37;
    --border-strong: #343D4E;

    --text-primary: #E8ECF3;
    --text-secondary: #9AA6BC;
    --text-muted: #5E6A82;
    --text-inverse: #0B0E14;

    --brand: #4C8DFF;
    --brand-hover: #6BA1FF;
    --brand-soft: rgba(76, 141, 255, .12);
    --brand-border: rgba(76, 141, 255, .35);

    --bull: #0ECB81;
    --bull-soft: rgba(14, 203, 129, .12);
    --bull-bar: rgba(14, 203, 129, .20);

    --bear: #F6465D;
    --bear-soft: rgba(246, 70, 93, .12);
    --bear-bar: rgba(246, 70, 93, .20);

    --flat: #5E6A82;
    --warn: #F0B90B;
    --warn-soft: rgba(240, 185, 11, .14);
    --info: #4C8DFF;
    --info-soft: rgba(76, 141, 255, .12);

    --call-tint: rgba(14, 203, 129, .04);
    --put-tint: rgba(246, 70, 93, .04);
    --atm-tint: rgba(76, 141, 255, .13);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-3: 0 20px 50px rgba(0, 0, 0, .45);
}

/* Explicit light choice wins over the system preference in both directions. */
:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg-base: #0B0E14;
    --bg-surface: #141821;
    --bg-elevated: #1B2029;
    --bg-hover: #222836;
    --bg-sunken: #0F131B;
    --bg-inset: #10151D;

    --border: #232A37;
    --border-strong: #343D4E;

    --text-primary: #E8ECF3;
    --text-secondary: #9AA6BC;
    --text-muted: #5E6A82;
    --text-inverse: #0B0E14;

    --brand: #4C8DFF;
    --brand-hover: #6BA1FF;
    --brand-soft: rgba(76, 141, 255, .12);
    --brand-border: rgba(76, 141, 255, .35);

    --bull: #0ECB81;
    --bull-soft: rgba(14, 203, 129, .12);
    --bull-bar: rgba(14, 203, 129, .20);

    --bear: #F6465D;
    --bear-soft: rgba(246, 70, 93, .12);
    --bear-bar: rgba(246, 70, 93, .20);

    --flat: #5E6A82;
    --warn: #F0B90B;
    --warn-soft: rgba(240, 185, 11, .14);
    --info: #4C8DFF;
    --info-soft: rgba(76, 141, 255, .12);

    --call-tint: rgba(14, 203, 129, .04);
    --put-tint: rgba(246, 70, 93, .04);
    --atm-tint: rgba(76, 141, 255, .13);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-3: 0 20px 50px rgba(0, 0, 0, .45);
}
