/* ══════════════════════════════════════════════════════════════
   Heros Design Tokens — palette derived from the Heros logo
   Olive ink #353B30 · Deep olive #242B21 · Sage #6D7266 / #A7AA9D
   Bone #EAECDF / #F2F4E5
   ══════════════════════════════════════════════════════════════ */

:root {
  /* Brand constants (theme independent) */
  --olive-950: #181c16;
  --olive-900: #242b21;
  --olive-800: #353b30;
  --olive-700: #454c3f;
  --olive-600: #5a6153;
  --sage-500: #6d7266;
  --sage-400: #8b9083;
  --sage-300: #a7aa9d;
  --bone-300: #d5d8ca;
  --bone-200: #e3e6d6;
  --bone-100: #eaecdf;
  --bone-50: #f5f6ee;
  --leaf-700: #46593a;
  --leaf-600: #5b7247;
  --leaf-400: #a9bf8c;

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;

  /* Shape & motion */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 0.18s;

  /* Layout */
  --sidebar-w: 272px;
  --rail-w: 60px;
  --topbar-h: 56px;
  --content-w: 768px;
}

/* ── Light (default) ─────────────────────────────────────────── */
:root,
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f6ef;
  --bg-sunken: #efefe6;
  --surface: #fdfdf9;
  --surface-2: #f1f2e8;
  --surface-3: #e7e9dc;
  --sidebar: #ededE3;
  --border: #dfe1d4;
  --border-strong: #c8cbbb;

  --text: #1e221b;
  --text-2: #42483d;
  --text-muted: #686e62;
  --text-faint: #91968a;

  --primary: #353b30;
  --primary-hover: #242b21;
  --on-primary: #f5f6ee;

  /* Hex on purpose: canvas code parses these */
  --accent: #5b7247;
  --accent2: #353b30;
  --accent-soft: rgba(91, 114, 71, 0.12);
  --accent-ring: rgba(91, 114, 71, 0.35);
  --link: #4b6838;

  --danger: #b4412f;
  --danger-soft: rgba(180, 65, 47, 0.1);
  --warning: #9a6511;
  --warning-soft: rgba(154, 101, 17, 0.12);
  --success: #3d7741;
  --success-soft: rgba(61, 119, 65, 0.12);
  --info: #3b6782;

  --hover: rgba(53, 59, 48, 0.055);
  --active: rgba(53, 59, 48, 0.1);
  --overlay: rgba(24, 28, 22, 0.36);

  --shadow-sm: 0 1px 2px rgba(36, 43, 33, 0.06);
  --shadow: 0 1px 2px rgba(36, 43, 33, 0.05), 0 6px 20px rgba(36, 43, 33, 0.07);
  --shadow-lg: 0 2px 6px rgba(36, 43, 33, 0.06), 0 24px 60px rgba(36, 43, 33, 0.16);
  --composer-shadow: 0 1px 2px rgba(36, 43, 33, 0.05), 0 8px 28px rgba(36, 43, 33, 0.08);

  --code-bg: #1d211b;
  --code-head: #272c24;
  --code-text: #e3e6d6;
  --inline-code-bg: rgba(53, 59, 48, 0.08);
  --user-bubble: #e8eadd;
}

/* ── Dark ─────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #141713;
  --bg-sunken: #111310;
  --surface: #22261f;
  --surface-2: #2a2f26;
  --surface-3: #343a2f;
  --sidebar: #1a1d18;
  --border: #30352c;
  --border-strong: #434a3d;

  --text: #eceee3;
  --text-2: #cdd1c2;
  --text-muted: #9ea395;
  --text-faint: #6f7468;

  --primary: #e3e6d6;
  --primary-hover: #f5f6ee;
  --on-primary: #1a1d18;

  --accent: #a9bf8c;
  --accent2: #6d7e5c;
  --accent-soft: rgba(169, 191, 140, 0.14);
  --accent-ring: rgba(169, 191, 140, 0.4);
  --link: #b7cb9b;

  --danger: #e07a66;
  --danger-soft: rgba(224, 122, 102, 0.13);
  --warning: #e0b05c;
  --warning-soft: rgba(224, 176, 92, 0.14);
  --success: #8fc58f;
  --success-soft: rgba(143, 197, 143, 0.14);
  --info: #8fb8d1;

  --hover: rgba(236, 238, 227, 0.055);
  --active: rgba(236, 238, 227, 0.1);
  --overlay: rgba(6, 8, 5, 0.6);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.3), 0 28px 70px rgba(0, 0, 0, 0.5);
  --composer-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.25);

  --code-bg: #121411;
  --code-head: #1b1e19;
  --code-text: #e3e6d6;
  --inline-code-bg: rgba(236, 238, 227, 0.09);
  --user-bubble: #2c3128;
}

/* Before JS runs, follow the OS preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #1a1d18;
    --surface: #22261f;
    --text: #eceee3;
  }
}

/* ── Legacy variable aliases (used by inline styles built in JS) ── */
:root {
  --text-dim: var(--text-muted);
  --text-main: var(--text);
  --bg-lighter: var(--surface-2);
  --bg-dark: var(--surface-2);
  --border-color: var(--border);
  --border-soft: var(--border);
  --accent-color: var(--primary);
  --ins-success: var(--success);
  --ins-accent2: var(--accent);
  --ins-muted: var(--text-muted);
  --ins-border: var(--border);
  --ins-text: var(--text);
  --font-stack: var(--font-sans);
}
