/* base.css — design tokens for both themes, reset, body.
 *
 * Every colour, radius and shadow the webchat uses is defined here once, on
 * :root for the dark theme and on html.light for the light theme. Component
 * rules (ui.css and the page stylesheets) only reference these tokens, so a
 * theme switch is a single class toggle on <html> and repaints the whole page.
 *
 * Every themed token is redefined in html.light, and the text/background
 * pairs keep a WCAG AA contrast ratio of at least 4.5:1 in both themes;
 * tests/webchat/test_theme_tokens.py checks both.
 */
  :root {
    color-scheme: dark;
    /* User-adjustable chat text scale (Tools → Settings). 1 = default. */
    --font-scale: 1;
    --highlight-theme: 'tokyo-night-dark';

    /* Page background: deep ink with a soft colour glow. */
    --bg: #0e0d18;
    --glow-1: rgba(232,54,58,0.20);
    --glow-2: rgba(139,92,246,0.18);
    --glow-3: rgba(59,130,246,0.10);
    --bg-glow:
      radial-gradient(60vmax 45vmax at 0% 0%, var(--glow-1), transparent 70%),
      radial-gradient(55vmax 45vmax at 100% 100%, var(--glow-2), transparent 70%),
      radial-gradient(40vmax 30vmax at 100% 0%, var(--glow-3), transparent 70%);
    /* Title-bar colour of the installed app: the manifest and <meta name="theme-color">
       in index.html repeat this value, as they cannot read CSS. */
    --app-chrome: #0e0d18;

    /* Surfaces. --surface/--surface2 are opaque; the glass tokens are
       translucent and sit over the glow. */
    --surface: #1a1928; --surface2: #252338;
    --surface-chrome: rgba(20,19,33,0.72);
    --glass-bg: rgba(34,32,54,0.66);
    --glass-bg-strong: rgba(26,25,40,0.92);
    --glass-border: rgba(255,255,255,0.13);
    --glass-highlight: inset 0 1px 0 rgba(255,255,255,0.06);
    --glass-blur: blur(18px) saturate(140%);
    --border: #2f2d46;

    /* Text */
    --text: #ecebf5; --text-secondary: #bebcd2; --text-dim: #a3a1bb;
    /* Page titles: text filled with a soft gradient (page.css .page-title);
       the Home headline uses the warmer hero gradient. */
    --title-gradient: linear-gradient(180deg, #ffffff 30%, #d4d5dd);
    --hero-gradient: linear-gradient(100deg, #ffffff 0%, #ffd6cf 35%, #ff9a7e 55%, #d3c7ff 80%, #ffffff 100%);
    --accent: #ff6b6e; --accent-hover: #ff8a8c;
    --accent-subtle: rgba(232,54,58,0.14);
    --error: #f5ac45; --success: #5fd08a; --strong: #f5ac45; --em: #b9a0ff;

    /* Messages */
    --user-msg-bg: linear-gradient(135deg, rgba(232,54,58,0.22), rgba(255,122,89,0.10)); --user-msg-border: rgba(255,122,89,0.34); --user-msg-text: #f4f2fa;
    --msg-assistant-bg: rgba(30,28,48,0.62);
    --chip-bg: rgba(255,255,255,0.07); --chip-bg-hover: rgba(255,255,255,0.12);
    --user-chip-bg: rgba(0,0,0,0.18); --user-chip-bg-hover: rgba(0,0,0,0.28);
    --modal-overlay: rgba(6,5,14,0.66); --drop-bg: rgba(232,54,58,0.10);

    /* Buttons: primary (red), secondary (glass), ghost (text), danger (tinted red), success */
    --btn-primary-bg: linear-gradient(135deg, #d9343b 0%, #b8202a 100%);
    --btn-primary-text: #ffffff;
    --btn-primary-shadow: 0 6px 20px -6px rgba(232,54,58,0.65), inset 0 1px 0 rgba(255,255,255,0.18);
    --btn-primary-shadow-hover: 0 10px 26px -6px rgba(232,54,58,0.75), inset 0 1px 0 rgba(255,255,255,0.22);
    --btn-secondary-bg: rgba(255,255,255,0.06); --btn-secondary-bg-hover: rgba(255,255,255,0.11);
    --btn-secondary-border: rgba(255,255,255,0.16); --btn-secondary-text: #ecebf5;
    --btn-ghost-text: #bebcd2; --btn-ghost-text-hover: #ecebf5; --btn-ghost-bg-hover: rgba(255,255,255,0.08);
    --btn-danger-bg: rgba(239,68,68,0.14); --btn-danger-border: rgba(255,123,127,0.45); --btn-danger-text: #ff8f92;
    --btn-danger-bg-hover: #c0262d; --btn-danger-text-hover: #ffffff;
    --btn-success-bg: #1e7d47; --btn-success-text: #ffffff;
    --btn-neutral-bg: #3a3852; --btn-neutral-text: #ffffff;

    /* Badges: one tone = background, ring, text */
    --tone-neutral-bg: rgba(255,255,255,0.08); --tone-neutral-ring: rgba(255,255,255,0.16); --tone-neutral-text: #c4c2d8;
    --tone-accent-bg: rgba(232,54,58,0.16); --tone-accent-ring: rgba(255,107,110,0.40); --tone-accent-text: #ff8285;
    --tone-success-bg: rgba(34,197,94,0.14); --tone-success-ring: rgba(95,208,138,0.40); --tone-success-text: #6fdc98;
    --tone-warning-bg: rgba(245,158,11,0.14); --tone-warning-ring: rgba(245,172,69,0.42); --tone-warning-text: #f7b85c;
    --tone-danger-bg: rgba(239,68,68,0.16); --tone-danger-ring: rgba(255,123,127,0.42); --tone-danger-text: #ff8f92;
    --tone-info-bg: rgba(59,130,246,0.16); --tone-info-ring: rgba(122,170,255,0.42); --tone-info-text: #8ab6ff;
    --tone-violet-bg: rgba(139,92,246,0.18); --tone-violet-ring: rgba(185,160,255,0.42); --tone-violet-text: #c2adff;
    --tone-warning-solid: #f5ac45; --tone-warning-solid-text: #1a1408;

    /* Fields */
    --field-bg: rgba(8,7,18,0.55); --field-text: #ecebf5; --field-placeholder: #9c9ab5;
    --field-border: rgba(255,255,255,0.14); --field-border-hover: rgba(255,255,255,0.24);
    --field-focus-border: #ff6b6e; --field-focus-ring: 0 0 0 3px rgba(232,54,58,0.28);

    /* Tabs */
    --tab-text: #a3a1bb; --tab-text-hover: #ecebf5;
    --tab-active-text: #ff8285; --tab-active-bg: rgba(232,54,58,0.16); --tab-active-ring: rgba(255,107,110,0.40);

    /* Sidebar: the page shown (layout.css, ui.css) — a warm tint, a thin ring
       and a coloured icon; its name keeps the text colour. */
    --nav-active-bg: linear-gradient(135deg, rgba(255,59,48,0.16), rgba(255,122,89,0.06));
    --nav-active-ring: rgba(255,122,89,0.28); --nav-active-icon: #ff7a59;

    /* Cards and panels: the border a card shows under the pointer, and the
       tint behind the icon of an empty state (page.css .ui-empty). */
    --card-border-hover: rgba(255,122,89,0.45);
    --empty-icon-bg: linear-gradient(135deg, rgba(139,92,246,0.26), rgba(59,130,246,0.10));

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.30); --shadow-md: 0 6px 18px rgba(0,0,0,0.38); --shadow-lg: 0 18px 48px rgba(0,0,0,0.50);

    /* Home page ask box: its gradient border and its shadow */
    --ask-ring: linear-gradient(120deg, rgba(255,122,89,0.60), rgba(123,92,255,0.50), rgba(46,125,255,0.35));
    --ask-shadow: 0 30px 90px rgba(0,0,0,0.35);
    --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px; --radius-xl: 20px; --radius-pill: 999px;
  }
  html.light {
    color-scheme: light;
    --bg: #f4f2f8;
    --glow-1: rgba(232,54,58,0.12);
    --glow-2: rgba(139,92,246,0.12);
    --glow-3: rgba(59,130,246,0.08);

    --surface: #ffffff; --surface2: #eeebf4;
    --surface-chrome: rgba(255,255,255,0.74);
    --glass-bg: rgba(255,255,255,0.84);
    --glass-bg-strong: rgba(255,255,255,0.94);
    --glass-border: rgba(28,22,52,0.13);
    --glass-highlight: inset 0 1px 0 rgba(255,255,255,0.80);
    --border: #dedae8;

    --text: #1b1a26; --text-secondary: #4d4a62; --text-dim: #625f76;
    --title-gradient: linear-gradient(180deg, #1b1a26 30%, #4d4a62);
    --hero-gradient: linear-gradient(100deg, #1b1a26 0%, #8a1c22 38%, #b8232a 55%, #5a32b8 80%, #1b1a26 100%);
    --accent: #b8232a; --accent-hover: #9c1c23;
    --accent-subtle: rgba(192,39,46,0.09);
    --error: #924900; --success: #1b7543; --strong: #1b1a26; --em: #6a3fd1;

    --user-msg-bg: linear-gradient(135deg, #fbe7e5, #fdf2ef); --user-msg-border: #eec5c3; --user-msg-text: #3a2224;
    --msg-assistant-bg: rgba(255,255,255,0.80);
    --chip-bg: rgba(28,22,52,0.05); --chip-bg-hover: rgba(28,22,52,0.09);
    --user-chip-bg: rgba(255,255,255,0.45); --user-chip-bg-hover: rgba(255,255,255,0.70);
    --modal-overlay: rgba(28,22,52,0.32); --drop-bg: rgba(192,39,46,0.06);

    --btn-primary-bg: linear-gradient(135deg, #d32f36 0%, #b01f28 100%);
    --btn-primary-text: #ffffff;
    --btn-primary-shadow: 0 6px 16px -6px rgba(192,39,46,0.50), inset 0 1px 0 rgba(255,255,255,0.22);
    --btn-primary-shadow-hover: 0 10px 22px -6px rgba(192,39,46,0.60), inset 0 1px 0 rgba(255,255,255,0.26);
    --btn-secondary-bg: rgba(255,255,255,0.78); --btn-secondary-bg-hover: #ffffff;
    --btn-secondary-border: rgba(28,22,52,0.16); --btn-secondary-text: #1b1a26;
    --btn-ghost-text: #4d4a62; --btn-ghost-text-hover: #1b1a26; --btn-ghost-bg-hover: rgba(28,22,52,0.06);
    --btn-danger-bg: rgba(192,39,46,0.07); --btn-danger-border: rgba(176,31,40,0.40); --btn-danger-text: #b01f28;
    --btn-danger-bg-hover: #b01f28; --btn-danger-text-hover: #ffffff;
    --btn-success-bg: #1b7543; --btn-success-text: #ffffff;
    --btn-neutral-bg: #5a576e; --btn-neutral-text: #ffffff;

    --tone-neutral-bg: rgba(28,22,52,0.06); --tone-neutral-ring: rgba(28,22,52,0.14); --tone-neutral-text: #4d4a62;
    --tone-accent-bg: rgba(192,39,46,0.09); --tone-accent-ring: rgba(192,39,46,0.30); --tone-accent-text: #a8222a;
    --tone-success-bg: rgba(27,117,67,0.10); --tone-success-ring: rgba(27,117,67,0.30); --tone-success-text: #17643a;
    --tone-warning-bg: rgba(180,95,0,0.10); --tone-warning-ring: rgba(168,84,0,0.32); --tone-warning-text: #8a4600;
    --tone-danger-bg: rgba(192,39,46,0.09); --tone-danger-ring: rgba(176,31,40,0.32); --tone-danger-text: #a01d25;
    --tone-info-bg: rgba(37,99,235,0.09); --tone-info-ring: rgba(37,99,235,0.30); --tone-info-text: #1d4fb8;
    --tone-violet-bg: rgba(106,63,209,0.09); --tone-violet-ring: rgba(106,63,209,0.30); --tone-violet-text: #5a32b8;
    --tone-warning-solid: #f2b33d; --tone-warning-solid-text: #1a1408;

    --field-bg: #ffffff; --field-text: #1b1a26; --field-placeholder: #6b6880;
    --field-border: rgba(28,22,52,0.18); --field-border-hover: rgba(28,22,52,0.30);
    --field-focus-border: #b8232a; --field-focus-ring: 0 0 0 3px rgba(192,39,46,0.18);

    --tab-text: #625f76; --tab-text-hover: #1b1a26;
    --tab-active-text: #a8222a; --tab-active-bg: rgba(192,39,46,0.09); --tab-active-ring: rgba(192,39,46,0.28);

    --nav-active-bg: linear-gradient(135deg, rgba(192,39,46,0.11), rgba(210,65,42,0.04));
    --nav-active-ring: rgba(192,39,46,0.26); --nav-active-icon: #b8232a;

    --card-border-hover: rgba(184,35,42,0.42);
    --empty-icon-bg: linear-gradient(135deg, rgba(106,63,209,0.14), rgba(37,99,235,0.06));

    --shadow-sm: 0 1px 3px rgba(28,22,52,0.08); --shadow-md: 0 6px 18px rgba(28,22,52,0.10); --shadow-lg: 0 18px 44px rgba(28,22,52,0.16);

    --ask-ring: linear-gradient(120deg, rgba(210,65,42,0.55), rgba(106,63,209,0.45), rgba(37,99,235,0.35));
    --ask-shadow: 0 22px 60px rgba(28,22,52,0.12);
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { font-family: 'Mulish', system-ui, -apple-system, sans-serif; font-weight: 500; background-color: var(--bg); background-image: var(--bg-glow); color: var(--text); height: 100vh; height: 100dvh; transition: background-color 0.3s, color 0.3s; -webkit-font-smoothing: antialiased; }
  .input-area, .modal, .msg, .schedule-result, .drop-overlay span { transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; }

  /* Light theme overrides for syntax highlighting */
  html.light .hljs { background: var(--bg) !important; color: var(--text) !important; }
  html.light .hljs-keyword, html.light .hljs-selector-tag { color: #b01f28; }
  html.light .hljs-string, html.light .hljs-attr { color: #17643a; }
  html.light .hljs-number, html.light .hljs-literal { color: #8a4600; }
  html.light .hljs-comment { color: #6b6880; }
  html.light .hljs-title, html.light .hljs-function { color: #5a32b8; }
  html.light .hljs-built_in { color: #0b6278; }
  html.light .msg.user { color: var(--user-msg-text); }
