/* Design tokens — single source of truth for colors, type, spacing and motion.
   Components must only use these variables: no hard-coded colors elsewhere. */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #FCFCFA;
  --bg-sidebar: #F7F7F5;
  --bg-hover: #EFEFED;
  --bg-active: #E8E8E5;
  --bg-subtle: #FAFAF9;
  --border: #E6E6E3;
  --border-strong: #D4D4D0;

  /* Text */
  --text: #1F1F1E;
  --text-secondary: #6B6B67;
  --text-tertiary: #6F6F6A;
  --text-on-accent: #FCFCFA;

  /* Accent (bordeaux) — small areas only */
  --accent: #8B1E3F;
  --accent-hover: #741832;
  --accent-subtle: #F6E9ED;
  --focus-ring: rgba(139, 30, 63, 0.35);

  /* Status */
  --success: #2F7D4F;
  --success-subtle: #EAF3EE;
  --warning: #B7791F;
  --warning-text: #8A5A12;
  --warning-subtle: #FBF3E3;
  --danger: #C0392B;
  --danger-subtle: #FBECEA;

  /* Tags — pale background + dark text of the same hue */
  --tag-gray-bg: #F1F1EF;   --tag-gray-text: #55554F;
  --tag-brown-bg: #F4EEEE;  --tag-brown-text: #6B4A3A;
  --tag-orange-bg: #FBECDD; --tag-orange-text: #8A4B14;
  --tag-yellow-bg: #FBF3DB; --tag-yellow-text: #735610;
  --tag-green-bg: #EDF3EC;  --tag-green-text: #2E5E3E;
  --tag-blue-bg: #E7F0F6;   --tag-blue-text: #24537A;
  --tag-purple-bg: #F1EDF6; --tag-purple-text: #5B3F7A;
  --tag-pink-bg: #F9EEF3;   --tag-pink-text: #7A3557;

  /* Floating elements */
  --shadow-float: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-drag: 0 2px 8px rgba(0, 0, 0, 0.08);
  --overlay: rgba(0, 0, 0, 0.35);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --fs-plus: 0px; /* "Grand" text setting sets this to 2px */
  --fs-12: calc(12px + var(--fs-plus));
  --fs-14: calc(14px + var(--fs-plus));
  --fs-16: calc(16px + var(--fs-plus));
  --fs-20: calc(20px + var(--fs-plus));
  --fs-28: calc(28px + var(--fs-plus));
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --lh-text: 1.5;
  --lh-title: 1.25;
  --tracking: 0.01em;
  --measure: 70ch;

  /* Spacing (4 px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;

  /* Shapes and sizes */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --control-sm: 28px;
  --control-md: 32px;
  --row-h: 36px;
  --icon: 16px;
  --sidebar-w: 248px;
  --topbar-h: 44px;
  --content-max: 960px;

  /* Motion */
  --duration: 140ms;
  --easing: ease-out;
}

/* Dark theme: follows the system unless the user forced light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #191919;
    --bg-sidebar: #202020;
    --bg-hover: #2A2A2A;
    --bg-active: #303030;
    --bg-subtle: #1E1E1E;
    --border: #2F2F2F;
    --border-strong: #3A3A3A;
    --text: #E8E8E6;
    --text-secondary: #A3A3A0;
    --text-tertiary: #8E8E8A;
    --text-on-accent: #FCFCFA;
    --accent: #C0476A;
    --accent-hover: #D0587A;
    --accent-subtle: #3A1F28;
    --focus-ring: rgba(192, 71, 106, 0.45);
    --success: #5FB283;
    --success-subtle: #1F2E25;
    --warning: #D9A04A;
    --warning-text: #E0B062;
    --warning-subtle: #33291A;
    --danger: #EC7F72;
    --danger-subtle: #3A2220;
    --tag-gray-bg: #2F2F2F;   --tag-gray-text: #C7C7C4;
    --tag-brown-bg: #3A2E2A;  --tag-brown-text: #D2B9A8;
    --tag-orange-bg: #3D2C1E; --tag-orange-text: #E3A770;
    --tag-yellow-bg: #3A3320; --tag-yellow-text: #DCC27A;
    --tag-green-bg: #23332A;  --tag-green-text: #8CC2A0;
    --tag-blue-bg: #1F2E3A;   --tag-blue-text: #8DB7DA;
    --tag-purple-bg: #2E2638; --tag-purple-text: #BBA3D6;
    --tag-pink-bg: #3A2430;   --tag-pink-text: #DDA0BE;
    --shadow-float: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-drag: 0 2px 8px rgba(0, 0, 0, 0.4);
    --overlay: rgba(0, 0, 0, 0.55);
  }
}

/* Dark theme forced by the toggle */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191919;
  --bg-sidebar: #202020;
  --bg-hover: #2A2A2A;
  --bg-active: #303030;
  --bg-subtle: #1E1E1E;
  --border: #2F2F2F;
  --border-strong: #3A3A3A;
  --text: #E8E8E6;
  --text-secondary: #A3A3A0;
  --text-tertiary: #8E8E8A;
  --text-on-accent: #FCFCFA;
  --accent: #C0476A;
  --accent-hover: #D0587A;
  --accent-subtle: #3A1F28;
  --focus-ring: rgba(192, 71, 106, 0.45);
  --success: #5FB283;
  --success-subtle: #1F2E25;
  --warning: #D9A04A;
  --warning-text: #E0B062;
  --warning-subtle: #33291A;
  --danger: #EC7F72;
  --danger-subtle: #3A2220;
  --tag-gray-bg: #2F2F2F;   --tag-gray-text: #C7C7C4;
  --tag-brown-bg: #3A2E2A;  --tag-brown-text: #D2B9A8;
  --tag-orange-bg: #3D2C1E; --tag-orange-text: #E3A770;
  --tag-yellow-bg: #3A3320; --tag-yellow-text: #DCC27A;
  --tag-green-bg: #23332A;  --tag-green-text: #8CC2A0;
  --tag-blue-bg: #1F2E3A;   --tag-blue-text: #8DB7DA;
  --tag-purple-bg: #2E2638; --tag-purple-text: #BBA3D6;
  --tag-pink-bg: #3A2430;   --tag-pink-text: #DDA0BE;
  --shadow-float: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-drag: 0 2px 8px rgba(0, 0, 0, 0.4);
  --overlay: rgba(0, 0, 0, 0.55);
}

/* "Grand" text size setting: +2 px on the whole scale */
:root[data-texte="grand"] { --fs-plus: 2px; }

/* Reduced motion: system preference or the in-app toggle */
@media (prefers-reduced-motion: reduce) {
  :root { --duration: 0ms; }
}
:root[data-animations="reduites"] { --duration: 0ms; }
