/* AUTO-GENERATED CSS bundle - DO NOT EDIT. Source: ui-src/ (build/build_dist.py) */

/* ==== css/fonts.css ==== */
/*
 * All @font-face declarations for the selectable UI fonts (Settings → Visuals → Font).
 *
 * Every family carries a `size-adjust` calibrated against JetBrains Mono (the app
 * default) so switching fonts never changes layout: size-adjust scales the glyphs
 * inside the em box without touching the em box itself, so font-size, line-height
 * and padding everywhere stay identical. Values blend the x-height and cap-height
 * ratios measured from the TTF metrics (JetBrains x-height = 0.550em, cap = 0.730em).
 *
 * Adding a font: drop the folder into fonts/, add @font-face blocks here (same
 * size-adjust on every face of a family), and add one entry to FONT_CHOICES in
 * modules/js/util/theme.js.
 */

/* JetBrains Mono — app default, the size-adjust baseline (x-height 0.550em). */
@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/JetBrains/JetBrainsMono-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/JetBrains/JetBrainsMono-Bold.ttf") format("truetype");
    font-weight: bold;
    font-style: normal;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/JetBrains/JetBrainsMono-Italic.ttf") format("truetype");
    font-weight: normal;
    font-style: italic;
}

/* Fira Code — metrics nearly identical to JetBrains (x-height 0.540em). No italics shipped. */
@font-face {
    font-family: "Fira Code";
    src: url("../fonts/Fira_Code/FiraCode-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    size-adjust: 102%;
}
@font-face {
    font-family: "Fira Code";
    src: url("../fonts/Fira_Code/FiraCode-Bold.ttf") format("truetype");
    font-weight: bold;
    font-style: normal;
    size-adjust: 102%;
}

/* IBM Plex Mono (x-height 0.516em). */
@font-face {
    font-family: "IBM Plex Mono";
    src: url("../fonts/IBM_Plex_Mono/IBMPlexMono-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    size-adjust: 105%;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("../fonts/IBM_Plex_Mono/IBMPlexMono-Bold.ttf") format("truetype");
    font-weight: bold;
    font-style: normal;
    size-adjust: 105%;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("../fonts/IBM_Plex_Mono/IBMPlexMono-Italic.ttf") format("truetype");
    font-weight: normal;
    font-style: italic;
    size-adjust: 105%;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("../fonts/IBM_Plex_Mono/IBMPlexMono-BoldItalic.ttf") format("truetype");
    font-weight: bold;
    font-style: italic;
    size-adjust: 105%;
}

/* Plus Jakarta Sans — proportional sans (not mono). Metrics land on JetBrains almost
   exactly (x-height 0.536em, cap 0.745em → blend ~100%), so no size-adjust needed. */
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/Plus_Jakarta_Sans/PlusJakartaSans-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/Plus_Jakarta_Sans/PlusJakartaSans-Bold.ttf") format("truetype");
    font-weight: bold;
    font-style: normal;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/Plus_Jakarta_Sans/PlusJakartaSans-Italic.ttf") format("truetype");
    font-weight: normal;
    font-style: italic;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/Plus_Jakarta_Sans/PlusJakartaSans-BoldItalic.ttf") format("truetype");
    font-weight: bold;
    font-style: italic;
}

/* Share Tech Mono — regular only (browser synthesizes bold/italic; x-height 0.500em). */
@font-face {
    font-family: "Share Tech Mono";
    src: url("../fonts/Share_Tech_Mono/ShareTechMono-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    size-adjust: 108%;
}

/* VT323 — retro low-res pixel font, regular only. Tiny glyphs in a huge em box
   (x-height 0.400em) — this is the font the whole size-adjust scheme exists for. */
@font-face {
    font-family: "VT323";
    src: url("../fonts/VT323/VT323-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    size-adjust: 134%;
}

/* Anton — heavy bold condensed display font (regular weight only) */
@font-face {
    font-family: "Anton";
    src: url("../fonts/Anton/Anton-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    size-adjust: 90%;
}

/* VCR OSD Mono — blocky VHS on-screen-display font, regular only
   (x-height 0.537em, cap-height 0.684em — blend against JetBrains ≈ 105%). */
@font-face {
    font-family: "VCR OSD Mono";
    src: url("../fonts/VCR_OSD_MONO/VCR_OSD_MONO_1.001.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    size-adjust: 105%;
}

/* Barlow Condensed — high-legibility retro condensed sans-serif */
@font-face {
    font-family: "Barlow Condensed";
    src: url("../fonts/Barlow_Condensed/BarlowCondensed-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    size-adjust: 104%;
}
@font-face {
    font-family: "Barlow Condensed";
    src: url("../fonts/Barlow_Condensed/BarlowCondensed-Bold.ttf") format("truetype");
    font-weight: bold;
    font-style: normal;
    size-adjust: 104%;
}
@font-face {
    font-family: "Barlow Condensed";
    src: url("../fonts/Barlow_Condensed/BarlowCondensed-Italic.ttf") format("truetype");
    font-weight: normal;
    font-style: italic;
    size-adjust: 104%;
}
@font-face {
    font-family: "Barlow Condensed";
    src: url("../fonts/Barlow_Condensed/BarlowCondensed-BoldItalic.ttf") format("truetype");
    font-weight: bold;
    font-style: italic;
    size-adjust: 104%;
}

/* ==== css/tokens.css ==== */
/* ==========================================================================
   Design Tokens  —  Single source of truth for all CSS custom properties.
   Every rule in every other stylesheet consumes values from here.
   Theme overrides live in css/themes/*.css (loaded after this file).
   ========================================================================== */

:root {
    /* ── Backgrounds ─────────────────────────────────────────────────── */
    --bg-darker: #080a0f;
    --bg-main: #0c0e14;
    --bg-panel: #11141e;
    --bg-hover: #1b2030;

    /* NOTE: --bg-header / --bg-sidebar / --bg-footer / --bg-inner are declared on
       `body` (not :root) so they resolve lazily against the body-scoped --bg-darker
       that theme classes override. Declaring them in :root would lock them to the
       cyberpunk default before any theme class is applied. */

    /* ── Borders ─────────────────────────────────────────────────────── */
    --border-color: #2e364f;
    --border-glow: #00ff66;
    --border-width: 1px;
    --border-width-thick: 2px;

    /* ── Accents ─────────────────────────────────────────────────────── */
    --accent-primary: #00ff66;
    --accent-primary-dim: rgba(0, 255, 102, 0.15);
    --accent-warning: #f59e0b;
    --accent-warning-dim: rgba(245, 158, 11, 0.15);
    --accent-secondary: #00f0ff;
    --accent-secondary-dim: rgba(0, 240, 255, 0.15);
    --accent-error: #ff3b30;
    --accent-error-dim: rgba(255, 59, 48, 0.15);

    /* ── Status indicators ───────────────────────────────────────────── */
    /* Kept independent of --accent-primary so online is always green-ish,
       offline always red-ish, and dormant always amber regardless of theme. */
    --indicator-online: #00ff66;
    --indicator-online-dim: rgba(0, 255, 102, 0.18);
    --indicator-offline: #ff3b30;
    --indicator-offline-dim: rgba(255, 59, 48, 0.18);
    --indicator-dormant: #f59e0b;
    --indicator-dormant-dim: rgba(245, 158, 11, 0.18);

    /* ── Typography ──────────────────────────────────────────────────── */
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
    --text-bright: #ffffff;

    /* Font resolution chain (Settings → Visuals → Font):
       --font-theme  = the active theme's default (overridden in theme blocks).
                       Falls back to JetBrains Mono, the app default.
       --font-user   = set inline on <html> by applyFontChoice() when the user pins
                       "Default" or an explicit font; absent in "Theme Default" mode.
       --font-mono   = what every rule actually consumes. Re-declared on body
                       (not just :root) because var() resolves where the property is
                       DECLARED — body is where theme classes live. */
    --font-theme: "JetBrains Mono", "Courier New", Courier, monospace;
    --font-mono: var(--font-user, var(--font-theme));

    /* ── Shape & layout ──────────────────────────────────────────────── */
    --panel-border-radius: 4px;
    --input-border-radius: 4px;
    --modal-border-radius: 8px;
    --bubble-border-radius: 6px;
    --titlebar-btn-radius: 3px;
    --titlebar-btn-border-width: 1px;
    --titlebar-btn-bg: none;
    --titlebar-btn-border-color: var(--border-color);
    --titlebar-height: 38px;

    /* Shorthand radius tokens */
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* ── Shadows ─────────────────────────────────────────────────────── */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.55);

    /* ── Scrollbars ──────────────────────────────────────────────────── */
    --scrollbar-width: 6px;
    --scrollbar-radius: 4px;
    --scrollbar-thumb: rgba(255, 255, 255, 0.2);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
    --scrollbar-track: transparent;

    /* ── Buttons — generic (literal values only; alias chain moves to body) ─ */
    --btn-gradient: none;
    --bg-gradient: none;
    --btn-shadow: none;
    --btn-text-shadow: none;

    /* ── Checkboxes & controls ───────────────────────────────────────── */
    --checkmark-bg: #ffffff;

    /* ── SVG arrows (form controls, literal fallbacks for cyberpunk) ─── */
    /* Themes override these with their own data-URIs; the component CSS
       references --select-arrow-svg / --preset-arrow-svg / --spin-buttons-svg. */
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ff66' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* ── Capability / behaviour tokens (literal values) ─────────────── */
    --heading-font-weight: normal;
    --heading-text-transform: none;
    --heading-letter-spacing: normal;
    --heading-text-shadow: none;
    --backdrop-blur: 0px;
    --send-btn-text-shadow: none;
    --input-border-focus: 1px solid var(--border-glow); /* border-glow is literal → safe */
    --panel-border: 1px solid var(--border-color); /* border-color is literal → safe */
    --btn-border: 1px solid var(--border-color); /* border-color is literal → safe */
    --send-btn-border: 1px solid var(--border-color); /* overridden on body below */

    /* ── Vana-Link / light-theme helper tokens ───────────────────────── */
    --text-shadow-dark: 0 1px 3px rgba(0, 0, 0, 0.5);
    --overlay-light: rgba(255, 255, 255, 0.08);
    --glow-blue: rgba(173, 220, 255, 0.4);
    --placeholder-light: rgba(255, 255, 255, 0.35);
    --border-faint: rgba(255, 255, 255, 0.25);
    --inbound-green: #7dffb3;
}

/* All vars that reference other vars (aliases) must live on `body`, not :root.
   This ensures they re-evaluate against whatever --bg-* / --accent-* the active
   theme class declares on body, rather than locking to the :root cyberpunk defaults. */
body {
    /* ── Font resolution ─────────────────────────────────────────────── */
    --font-mono: var(--font-user, var(--font-theme));
    --font-theme-code: var(--font-theme);
    --font-code: var(--font-user-code, var(--font-theme-code));

    /* ── Layout background aliases ───────────────────────────────────── */
    --bg-header: var(--bg-darker);
    --bg-sidebar: var(--bg-darker);
    --bg-footer: var(--bg-darker);
    --bg-inner: var(--bg-darker);

    /* Opacity applied to header/sidebar/footer when a custom background image is set */
    /*--opacity-header: clamp(0.35, var(--ui-opacity, 0.72), 1);
    --opacity-sidebar: clamp(0.35, var(--ui-opacity, 0.72), 1);
    --opacity-footer: 1;*/

    /* ── Buttons — aliases onto primitive tokens ─────────────────────── */
    --btn-radius: var(--input-border-radius);
    --btn-color: var(--text-primary);
    --btn-hover-bg: var(--bg-hover);
    --btn-hover-color: var(--text-primary);

    /* Ok / Save / Apply */
    --btn-ok-bg: var(--accent-primary-dim);
    --btn-ok-color: var(--accent-primary);
    --btn-ok-border: var(--accent-primary);
    --btn-ok-hover-bg: var(--accent-primary);
    --btn-ok-hover-color: var(--bg-main);

    /* Cancel / Close */
    --btn-cancel-bg: var(--bg-panel);
    --btn-cancel-color: var(--text-primary);
    --btn-cancel-border: var(--border-color);
    --btn-cancel-hover-bg: var(--bg-hover);
    --btn-cancel-hover-color: var(--text-primary);
    --btn-close-bg: var(--btn-cancel-bg);
    --btn-close-color: var(--btn-cancel-color);
    --btn-close-border: var(--btn-cancel-border);
    --btn-close-hover-bg: var(--btn-cancel-hover-bg);
    --btn-close-hover-color: var(--btn-cancel-hover-color);

    /* Send button */
    --send-btn-gradient: var(--btn-ok-bg);
    --send-btn-border: 1px solid var(--btn-ok-border);
    --send-btn-color: var(--btn-ok-color);

    /* ── Icon colours ────────────────────────────────────────────────── */
    --icon-files: var(--accent-primary);
    --icon-debug: var(--accent-secondary);
    --icon-settings: var(--text-muted);

    /* ── Panel text aliases ──────────────────────────────────────────── */
    --panel-text: var(--text-primary);
    --panel-header-text: var(--text-bright);
    --panel-footer-text: var(--text-muted);
    --header-text: var(--text-primary);
    --footer-text: var(--text-muted);
    --header-bg: var(--bg-darker);
    --footer-bg: var(--bg-darker);

    /* ── Input aliases ───────────────────────────────────────────────── */
    --input-bg-focus: var(--bg-hover);

    /* ── Chat bubble aliases ─────────────────────────────────────────── */
    --user-bubble-bg: color-mix(in srgb, var(--bg-panel) 40%, transparent);
    --user-bubble-border: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
    --user-bubble-accent-border: 2px solid var(--accent-primary-dim);
    --user-bubble-color: var(--text-primary);
    --user-bubble-time-color: var(--user-bubble-color);
    --assistant-bubble-bg: color-mix(in srgb, var(--bg-panel) 40%, transparent);
    --assistant-bubble-border: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
    --assistant-bubble-accent-border: 2px solid var(--accent-primary-dim);
    --assistant-bubble-color: var(--text-primary);
    --assistant-bubble-time-color: var(--text-muted);

    /* ── Sidebar badges ──────────────────────────────────────────────── */
    --sidebar-tag-bg: var(--border-color);
    --sidebar-tag-color: var(--text-muted);

    /* ── Checkbox aliases ────────────────────────────────────────────── */
    --checkmark-border: var(--border-color);
    --checkmark-checked-bg: var(--accent-primary);
    --checkmark-checked-border: var(--accent-primary);

    /* ── SVG arrow colour aliases (resolved after theme sets --text-muted etc.) */
    --arrow-color: var(--text-muted);
    --arrow-accent-color: var(--accent-primary);

    /* ── Visualizer ──────────────────────────────────────────────────── */
    --visualizer-color: var(--accent-primary);
}

/* ==== css/themes/pear.css ==== */
/* ==========================================================================
   Pear Themes  —  Apple-inspired (Plus Jakarta Sans)
   ========================================================================== */

body.theme-pear-dark {
    --font-theme: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    --bg-darker: #161617; /* Apple's sleek header/sidebar dark background */
    --bg-main: #000000; /* Apple's pure black main messaging canvas */
    --bg-panel: #1c1c1e; /* Apple's elevated modal/input gray */
    --bg-hover: #2c2c2e;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #2c2c2e;
    --border-glow: #30d158; /* Soft green border glow */

    --accent-primary: #30d158; /* Pear vibrant green */
    --accent-primary-dim: rgba(48, 209, 88, 0.15);
    --accent-secondary: #0a84ff; /* Apple Dark Blue */
    --accent-secondary-dim: rgba(10, 132, 255, 0.15);
    --accent-warning: #ffd60a;
    --accent-warning-dim: rgba(255, 214, 10, 0.15);
    --accent-error: #ff453a;
    --accent-error-dim: rgba(255, 69, 58, 0.15);

    --text-primary: #ffffff;
    --text-muted: #8e8e93;
    --text-bright: #ffffff;

    --bubble-border-radius: 16px;
    --panel-border-radius: 10px;
    --input-border-radius: 18px;
    --modal-border-radius: 12px;

    /* Outgoing User (Human) Bubbles — Deep forest green, white text */
    --user-bubble-bg: #248a3d;
    --user-bubble-border: none;
    --user-bubble-accent-border: none;
    --user-bubble-color: #ffffff;

    /* Incoming Assistant (AI) Bubbles — Dark gray, white text */
    --assistant-bubble-bg: #26262a;
    --assistant-bubble-border: none;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #ffffff;

    --sidebar-tag-bg: #2c2c2e;
    --sidebar-tag-color: #a1a1a6;

    --arrow-color: #8e8e93;
    --arrow-accent-color: #248a3d;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23248a3d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #30d158;
    --indicator-online-dim: rgba(48, 209, 88, 0.18);
    --indicator-offline: #ff453a;
    --indicator-offline-dim: rgba(255, 69, 58, 0.18);
    --indicator-dormant: #ffd60a;
    --indicator-dormant-dim: rgba(255, 214, 10, 0.18);

    /* Action Buttons: darker forest green OK so white text stays readable; dark-panel Cancel */
    --btn-ok-bg: #248a3d;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #1a6b2e;
    --btn-ok-hover-bg: #1a6b2e;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #2c2c2e;
    --btn-cancel-color: #8e8e93;
    --btn-cancel-border: #3a3a3c;
    --btn-cancel-hover-bg: #3a3a3c;
    --btn-cancel-hover-color: #ebebf5;
}

body.theme-pear-light {
    --font-theme: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    --bg-darker: #f5f5f7; /* Apple's sleek off-white sidebar */
    --bg-main: #ffffff; /* Apple's pure white messaging canvas */
    --bg-panel: #ffffff; /* Clean white modals/inputs */
    --bg-hover: #e5e5ea;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #d1d1d6;
    --border-glow: #34c759;

    --accent-primary: #34c759; /* Pear vibrant green */
    --accent-primary-dim: rgba(52, 199, 89, 0.15);
    --accent-secondary: #007aff; /* Apple Light Blue */
    --accent-secondary-dim: rgba(0, 122, 255, 0.15);
    --accent-warning: #ff9500;
    --accent-warning-dim: rgba(255, 149, 0, 0.15);
    --accent-error: #ff3b30;
    --accent-error-dim: rgba(255, 59, 48, 0.15);

    --text-primary: #000000;
    --text-muted: #8e8e93;
    --text-bright: #000000;

    --bubble-border-radius: 16px;
    --panel-border-radius: 10px;
    --input-border-radius: 18px;
    --modal-border-radius: 12px;

    /* Outgoing User (Human) Bubbles — Green with White text */
    --user-bubble-bg: #34c759;
    --user-bubble-border: none;
    --user-bubble-accent-border: none;
    --user-bubble-color: #ffffff;

    /* Incoming Assistant (AI) Bubbles — Light Gray with Black text */
    --assistant-bubble-bg: #e5e5ea;
    --assistant-bubble-border: none;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #000000;

    --sidebar-tag-bg: #e5e5ea;
    --sidebar-tag-color: #8e8e93;

    --arrow-color: #8e8e93;
    --arrow-accent-color: #34c759;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2334c759' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #34c759;
    --indicator-online-dim: rgba(52, 199, 89, 0.15);
    --indicator-offline: #ff3b30;
    --indicator-offline-dim: rgba(255, 59, 48, 0.15);
    --indicator-dormant: #ff9500;
    --indicator-dormant-dim: rgba(255, 149, 0, 0.15);

    /* Action Buttons: solid fills that remain legible inside the solid-green user bubble */
    --btn-ok-bg: #34c759;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #34c759;
    --btn-ok-hover-bg: #30b651;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #e5e5ea;
    --btn-cancel-color: #000000;
    --btn-cancel-border: #c7c7cc;
    --btn-cancel-hover-bg: #d1d1d6;
    --btn-cancel-hover-color: #000000;
}

/* ==== css/themes/standard.css ==== */
/* ==========================================================================
   Standard Themes  —  ChatGPT/Gemini-inspired (Plus Jakarta Sans)
   ========================================================================== */

body.theme-standard-dark {
    --font-theme: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    --bg-darker: #131314; /* Darker slate/charcoal (Gemini-like sidebar) */
    --bg-main: #1f1f20; /* Central workspace panels (ChatGPT/Gemini main background) */
    --bg-panel: #2d2f31; /* Settings panel/modals, input area */
    --bg-hover: #3e4144; /* Hover states on buttons/inputs */
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #444746; /* Standard separators and outlines */
    --border-glow: #10a37f; /* Glowing accent border effects */

    --accent-primary: #10a37f; /* ChatGPT mint-green */
    --accent-primary-dim: rgba(16, 163, 127, 0.15);
    --accent-secondary: #4285f4; /* Gemini Blue */
    --accent-secondary-dim: rgba(66, 133, 244, 0.15);
    --accent-warning: #f59e0b;
    --accent-warning-dim: rgba(245, 158, 11, 0.15);
    --accent-error: #ef4444;
    --accent-error-dim: rgba(239, 68, 68, 0.15);

    --text-primary: #e3e3e3; /* Main chat bubble text */
    --text-muted: #b4b4b4; /* Secondary descriptions, timestamps */
    --text-bright: #ffffff; /* Titles and highlighted terms */

    --arrow-color: #b4b4b4;
    --arrow-accent-color: #10a37f;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4b4b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2310a37f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4b4b4' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #10a37f;
    --indicator-online-dim: rgba(16, 163, 127, 0.18);
    --indicator-offline: #ef4444;
    --indicator-offline-dim: rgba(239, 68, 68, 0.18);
    --indicator-dormant: #f59e0b;
    --indicator-dormant-dim: rgba(245, 158, 11, 0.18);

    --sidebar-tag-bg: #3e4144;
    --sidebar-tag-color: #e3e3e3;

    /* Action Buttons: solid mint OK; charcoal Cancel */
    --btn-ok-bg: #10a37f;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #0d8065;
    --btn-ok-hover-bg: #0d8065;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #3e4144;
    --btn-cancel-color: #e3e3e3;
    --btn-cancel-border: #5a5d61;
    --btn-cancel-hover-bg: #52565a;
    --btn-cancel-hover-color: #ffffff;
}

body.theme-standard-light {
    --font-theme: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    --bg-darker: #f4f4f5; /* Light gray background (ChatGPT/Gemini sidebar) */
    --bg-main: #ffffff; /* Pure white main canvas */
    --bg-panel: #fafafa; /* Light panels/modals */
    --bg-hover: #f0f0f1; /* Hover states */
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #e3e3e3;
    --border-glow: #0b57d0; /* Blue border glow */

    --accent-primary: #0b57d0; /* Gemini Google Blue */
    --accent-primary-dim: rgba(11, 87, 208, 0.15);
    --accent-secondary: #10a37f; /* ChatGPT green */
    --accent-secondary-dim: rgba(16, 163, 127, 0.15);
    --accent-warning: #b45309;
    --accent-warning-dim: rgba(180, 83, 9, 0.15);
    --accent-error: #dc2626;
    --accent-error-dim: rgba(220, 38, 38, 0.15);

    --text-primary: #0d0d0d; /* Dark gray text */
    --text-muted: #676767; /* Muted descriptions/labels */
    --text-bright: #000000; /* Clear headings */

    --arrow-color: #676767;
    --arrow-accent-color: #0b57d0;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23676767' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b57d0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23676767' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #16a34a;
    --indicator-online-dim: rgba(22, 163, 74, 0.15);
    --indicator-offline: #dc2626;
    --indicator-offline-dim: rgba(220, 38, 38, 0.15);
    --indicator-dormant: #d97706;
    --indicator-dormant-dim: rgba(217, 119, 6, 0.15);

    --user-bubble-bg: #f2f0f0;
    --user-bubble-border: 1px solid #f2f0f0;
    --user-bubble-accent-border: none;
    --user-bubble-color: #0d0d0d;

    --assistant-bubble-bg: #f2f0f0;
    --assistant-bubble-border: 1px solid #f2f0f0;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #0d0d0d;

    --sidebar-tag-bg: #e2e8f0;
    --sidebar-tag-color: #475569;

    /* Action Buttons: solid fills for light background */
    --btn-ok-bg: #0b57d0;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #0842a0;
    --btn-ok-hover-bg: #0842a0;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #f0f0f1;
    --btn-cancel-color: #0d0d0d;
    --btn-cancel-border: #c8c8c8;
    --btn-cancel-hover-bg: #e3e3e3;
    --btn-cancel-hover-color: #0d0d0d;
}

/* ==== css/themes/light.css ==== */
/* ==========================================================================
   Light Themes  —  Modern Slate, Grey Monochrome, Grey Colourful
   ========================================================================== */

body.theme-light-modern {
    --bg-darker: #cbd5e1;
    --bg-main: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-hover: #e2e8f0;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #94a3b8;
    --border-glow: #64748b;

    --accent-primary: #059669;
    --accent-primary-dim: rgba(5, 150, 105, 0.15);
    --accent-warning: #d97706;
    --accent-warning-dim: rgba(217, 119, 6, 0.15);
    --accent-secondary: #0284c7;
    --accent-secondary-dim: rgba(2, 132, 199, 0.15);
    --accent-error: #dc2626;
    --accent-error-dim: rgba(220, 38, 38, 0.15);

    --text-primary: #0f172a;
    --text-muted: #475569;
    --text-bright: #000000;

    --arrow-color: #475569;
    --arrow-accent-color: #059669;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: slightly deeper shades for contrast on light backgrounds */
    --indicator-online: #16a34a;
    --indicator-online-dim: rgba(22, 163, 74, 0.15);
    --indicator-offline: #dc2626;
    --indicator-offline-dim: rgba(220, 38, 38, 0.15);
    --indicator-dormant: #d97706;
    --indicator-dormant-dim: rgba(217, 119, 6, 0.15);

    /* Chat Boxes / Message Bubbles — Modern Slate & Light Mint */
    --user-bubble-bg: #e6f4ea;
    --user-bubble-border: 1px solid #e6f4ea;
    --user-bubble-accent-border: none;
    --user-bubble-color: #0f172a;

    --assistant-bubble-bg: #f8fafc;
    --assistant-bubble-border: 1px solid #e2e8f0;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #0f172a;

    --sidebar-tag-bg: #f1f5f9;
    --sidebar-tag-color: #64748b;

    /* Action Buttons: solid fills for light background */
    --btn-ok-bg: #059669;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #047857;
    --btn-ok-hover-bg: #047857;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #e2e8f0;
    --btn-cancel-color: #0f172a;
    --btn-cancel-border: #94a3b8;
    --btn-cancel-hover-bg: #cbd5e1;
    --btn-cancel-hover-color: #0f172a;
}

body.theme-grey-monochrome {
    --bg-darker: #8f8f8f;
    --bg-main: #cfcfcf;
    --bg-panel: #dfdfdf;
    --bg-hover: #b8b8b8;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #6f6f6f;
    --border-glow: #404040;

    --accent-primary: #2f2f2f;
    --accent-primary-dim: rgba(47, 47, 47, 0.18);
    --accent-warning: #3f3f3f;
    --accent-warning-dim: rgba(63, 63, 63, 0.18);
    --accent-secondary: #1f1f1f;
    --accent-secondary-dim: rgba(31, 31, 31, 0.2);
    --accent-error: #4f4f4f;
    --accent-error-dim: rgba(79, 79, 79, 0.2);

    --text-primary: #111111;
    --text-muted: #2d2d2d;
    --text-bright: #000000;

    --arrow-color: #2d2d2d;
    --arrow-accent-color: #2f2f2f;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232d2d2d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f2f2f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232d2d2d' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: use real semantic colours so they remain distinguishable
       even though the theme's own accents are all grey shades. */
    --indicator-online: #2e7d32;
    --indicator-online-dim: rgba(46, 125, 50, 0.2);
    --indicator-offline: #c62828;
    --indicator-offline-dim: rgba(198, 40, 40, 0.18);
    --indicator-dormant: #e65100;
    --indicator-dormant-dim: rgba(230, 81, 0, 0.2);

    --user-bubble-bg: #e8e8e8;
    --user-bubble-border: 1px solid #cfcfcf;
    --user-bubble-accent-border: none;
    --user-bubble-color: #111111;

    --assistant-bubble-bg: #dfdfdf;
    --assistant-bubble-border: 1px solid #cfcfcf;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #111111;

    --sidebar-tag-bg: #2f2f2f;
    --sidebar-tag-color: #ffffff;

    /* Action Buttons: solid fills — since accent-primary is near-black on grey, keep solid */
    --btn-ok-bg: #2f2f2f;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #1a1a1a;
    --btn-ok-hover-bg: #111111;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #b8b8b8;
    --btn-cancel-color: #111111;
    --btn-cancel-border: #6f6f6f;
    --btn-cancel-hover-bg: #a0a0a0;
    --btn-cancel-hover-color: #111111;
}

body.theme-grey-colourful {
    --bg-darker: #7b7d7b;
    --bg-main: #a5a6a5;
    --bg-panel: #bfbfbf;
    --bg-hover: #8c8d8c;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #525352;
    --border-glow: #383938;

    --accent-primary: #32e769f0;
    --accent-primary-dim: rgba(0, 230, 118, 0.15);
    --accent-secondary: #2eaceb;
    --accent-secondary-dim: rgba(2, 132, 199, 0.15);
    --accent-warning: #c963e6;
    --accent-warning-dim: rgba(138, 44, 163, 0.22);
    --accent-error: #ff1744;
    --accent-error-dim: rgba(255, 23, 68, 0.15);

    --text-primary: #101010;
    --text-muted: #3a3b3a;
    --text-bright: #000000;

    --arrow-color: #3a3b3a;
    --arrow-accent-color: #32e769;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233a3b3a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2332e769' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233a3b3a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: light background needs slightly darker greens/reds */
    --indicator-online: #1aad4a;
    --indicator-online-dim: rgba(26, 173, 74, 0.2);
    --indicator-offline: #e5143a;
    --indicator-offline-dim: rgba(229, 20, 58, 0.18);
    --indicator-dormant: #b86b00;
    --indicator-dormant-dim: rgba(184, 107, 0, 0.2);

    --user-bubble-bg: rgba(50, 231, 105, 0.12);
    --user-bubble-border: 1px solid rgba(50, 231, 105, 0.4);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);

    --assistant-bubble-bg: rgba(46, 172, 235, 0.1);
    --assistant-bubble-border: 1px solid rgba(46, 172, 235, 0.35);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    --sidebar-tag-bg: #1c719c;
    --sidebar-tag-color: #ffffff;

    /* Action Buttons: solid fills for readability on mid-grey backgrounds */
    --btn-ok-bg: #1da84f;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #14813b;
    --btn-ok-hover-bg: #14813b;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #8c8d8c;
    --btn-cancel-color: #101010;
    --btn-cancel-border: #525352;
    --btn-cancel-hover-bg: #797a79;
    --btn-cancel-hover-color: #101010;
}

/* ==== css/themes/retro.css ==== */
/* ==========================================================================
   Retro Themes  —  Blue Retro (XP), 80s Neon, CGA 8-bit, Acheron (Matrix)
   ========================================================================== */

body.theme-blue-retro {
    --font-theme: "IBM Plex Mono", "Courier New", Courier, monospace;

    --bg-darker: #142755;
    --bg-main: #3b63a3;
    --bg-panel: #5f86c0;
    --bg-hover: #4b74b0;
    --border-color: #223f79;
    --border-glow: #0d1f45;

    --accent-primary: #42d65b;
    --accent-primary-dim: rgba(27, 212, 58, 0.2);
    --accent-warning: #f7e18e;
    --accent-warning-dim: rgba(247, 225, 142, 0.2);
    --accent-secondary: #d6e6ff;
    --accent-secondary-dim: rgba(214, 230, 255, 0.18);
    --accent-error: #ff9d6e;
    --accent-error-dim: rgba(255, 157, 110, 0.2);

    --text-primary: #f5f8ff;
    --text-muted: #d8e6ff;
    --text-bright: #ffffff;

    --arrow-color: #d8e6ff;
    --arrow-accent-color: #42d65b;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d8e6ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2342d65b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d8e6ff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: brighter online green for contrast against mid-blue panels;
       red/amber chosen to pop clearly without clashing with the blue palette. */
    --indicator-online: #4cff70;
    --indicator-online-dim: rgba(76, 255, 112, 0.2);
    --indicator-offline: #ff5252;
    --indicator-offline-dim: rgba(255, 82, 82, 0.2);
    --indicator-dormant: #ffd740;
    --indicator-dormant-dim: rgba(255, 215, 64, 0.2);

    --user-bubble-bg: rgba(66, 214, 91, 0.12);
    --user-bubble-border: 1px solid rgba(66, 214, 91, 0.35);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);

    --assistant-bubble-bg: rgba(95, 134, 192, 0.25);
    --assistant-bubble-border: 1px solid rgba(34, 63, 121, 0.4);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    --sidebar-tag-bg: #3b63a3;
    --sidebar-tag-color: #ffffff;

    /* Windows XP close button styling */
    --close-btn-bg: #da4925;
    --close-btn-border: 1px solid #7d260f;
    --close-btn-color: #ffffff;
    --close-btn-hover-bg: #e66040;
    --close-btn-hover-border: 1px solid #993319;
    --close-btn-hover-color: #ffffff;

    /* Action Buttons: Ok matches the Windows XP Start button green */
    --btn-ok-bg: #3c7a28;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #2a5a1a;
    --btn-ok-hover-bg: #2a5a1a;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #4b74b0;
    --btn-cancel-color: #f5f8ff;
    --btn-cancel-border: #223f79;
    --btn-cancel-hover-bg: #3b63a3;
    --btn-cancel-hover-color: #ffffff;
}

body.theme-80s {
    --font-theme: "Share Tech Mono", "Courier New", Courier, monospace;

    --bg-darker: #0d0d0d;
    --bg-main: #1a1024;
    --bg-panel: #251635;
    --bg-hover: #331d49;
    --border-color: #5f3c88;
    --border-glow: #ff3b3b;

    --accent-primary: #ff3b3b;
    --accent-primary-dim: rgba(255, 59, 59, 0.2);
    --accent-warning: #ffe347;
    --accent-warning-dim: rgba(255, 227, 71, 0.2);
    --accent-secondary: #43d3ff;
    --accent-secondary-dim: rgba(67, 211, 255, 0.2);
    --accent-error: #ff6a00;
    --accent-error-dim: rgba(255, 106, 0, 0.2);

    --text-primary: #fff6d0;
    --text-muted: #ffca7a;
    --text-bright: #ffffff;

    --arrow-color: #ffca7a;
    --arrow-accent-color: #ff3b3b;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffca7a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff3b3b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffca7a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: accent-primary is red here, so we must define online separately
       to avoid a nonsensical red "online" lamp. Use neon green to match 80s vibe. */
    --indicator-online: #39ff14;
    --indicator-online-dim: rgba(57, 255, 20, 0.2);
    --indicator-offline: #ff1744;
    --indicator-offline-dim: rgba(255, 23, 68, 0.2);
    --indicator-dormant: #ffe347;
    --indicator-dormant-dim: rgba(255, 227, 71, 0.2);

    --user-bubble-bg: rgba(67, 211, 255, 0.12);
    --user-bubble-border: 1px solid rgba(67, 211, 255, 0.3);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);

    --assistant-bubble-bg: rgba(255, 59, 59, 0.08);
    --assistant-bubble-border: 1px solid rgba(255, 59, 59, 0.25);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    /* Action Buttons: cyan OK avoids red-as-confirm confusion; dark-purple Cancel */
    --btn-ok-bg: #43d3ff;
    --btn-ok-color: #0d0d0d;
    --btn-ok-border: #22b8e8;
    --btn-ok-hover-bg: #22b8e8;
    --btn-ok-hover-color: #0d0d0d;
    --btn-cancel-bg: #331d49;
    --btn-cancel-color: #ffca7a;
    --btn-cancel-border: #5f3c88;
    --btn-cancel-hover-bg: #4a2a6a;
    --btn-cancel-hover-color: #fff6d0;
}

/* ─── CGA (8-bit Throwback) ──────────────────────────────────────────────────
   Authentic CGA Palette 1, High Intensity: the notorious cyan/magenta/white
   combo. Pure black background keeps text readable.
   Colour reference (CGA 16-colour RGBI):
     Bright Cyan    #55ffff  │  Bright Magenta #ff55ff
     Bright Yellow  #ffff55  │  Bright Red     #ff5555
     Dark Cyan      #005555  │  White          #ffffff
   ─────────────────────────────────────────────────────────────────────────── */
body.theme-cga {
    --font-theme: "VT323", "Courier New", Courier, monospace;

    --bg-darker: #000000;
    --bg-main: #000000;
    --bg-panel: #0a0a0a;
    --bg-hover: #141414;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #005555; /* dark cyan — exists in the CGA 16-colour set */
    --border-glow: #55ffff;

    --accent-primary: #55ffff; /* bright cyan */
    --accent-primary-dim: rgba(85, 255, 255, 0.15);
    --accent-warning: #ffff55; /* bright yellow */
    --accent-warning-dim: rgba(255, 255, 85, 0.18);
    --accent-secondary: #ff55ff; /* bright magenta */
    --accent-secondary-dim: rgba(255, 85, 255, 0.15);
    --accent-error: #ff5555; /* bright red */
    --accent-error-dim: rgba(255, 85, 85, 0.18);

    --text-primary: #ffffff;
    --text-muted: #55ffff; /* dim text uses bright cyan — no greys in CGA */
    --text-bright: #ffffff;

    --arrow-color: #55ffff;
    --arrow-accent-color: #55ffff;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355ffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355ffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2355ffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: straight from the CGA colour chart */
    --indicator-online: #55ff55; /* bright green */
    --indicator-online-dim: rgba(85, 255, 85, 0.2);
    --indicator-offline: #ff5555; /* bright red */
    --indicator-offline-dim: rgba(255, 85, 85, 0.2);
    --indicator-dormant: #ffff55; /* bright yellow */
    --indicator-dormant-dim: rgba(255, 255, 85, 0.2);

    --user-bubble-bg: #000000;
    --user-bubble-border: 1px solid #ff55ff;
    --user-bubble-accent-border: 1px solid #ff55ff;
    --user-bubble-color: #ffffff;

    --assistant-bubble-bg: #000000;
    --assistant-bubble-border: 1px solid #55ffff;
    --assistant-bubble-accent-border: 1px solid #55ffff;
    --assistant-bubble-color: #ffffff;

    --sidebar-tag-bg: #ff55ff;
    --sidebar-tag-color: #000000;

    /* Action Buttons: magenta OK (distinct from cyan UI accent); dark-cyan Cancel */
    --btn-ok-bg: #ff55ff;
    --btn-ok-color: #000000;
    --btn-ok-border: #cc22cc;
    --btn-ok-hover-bg: #cc22cc;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #000000;
    --btn-cancel-color: #55ffff;
    --btn-cancel-border: #008888;
    --btn-cancel-hover-bg: #007777;
    --btn-cancel-hover-color: #ffffff;
}

body.theme-acheron {
    --font-theme: "Share Tech Mono", "Courier New", Courier, monospace;

    --bg-darker: #040605;
    --bg-main: #070d0a;
    --bg-panel: #0d1511;
    --bg-hover: #16241d;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #22372b;
    --border-glow: #00ff41;

    --accent-primary: #00ff41;
    --accent-primary-dim: rgba(0, 255, 65, 0.15);
    --accent-warning: #ffb000;
    --accent-warning-dim: rgba(255, 176, 0, 0.15);
    --accent-secondary: #2dff61;
    --accent-secondary-dim: rgba(0, 255, 65, 0.15);
    --accent-error: #ff1111;
    --accent-error-dim: rgba(255, 17, 17, 0.15);

    --text-primary: #85e09b;
    --text-muted: #4e805b;
    --text-bright: #d1ffd9;

    --arrow-color: #4e805b;
    --arrow-accent-color: #00ff41;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234e805b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ff41' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234e805b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: accent-primary is already a strong green; offline/dormant use
       theme-consistent colours. */
    --indicator-online: #00ff41;
    --indicator-online-dim: rgba(0, 255, 65, 0.18);
    --indicator-offline: #ff1111;
    --indicator-offline-dim: rgba(255, 17, 17, 0.18);
    --indicator-dormant: #ffb000;
    --indicator-dormant-dim: rgba(255, 176, 0, 0.18);

    --user-bubble-bg: rgba(27, 57, 41, 0.35);
    --user-bubble-border: none;
    --user-bubble-accent-border: none;
    --user-bubble-color: #ffffff;
    --user-bubble-time-color: var(--user-bubble-color);

    --assistant-bubble-bg: rgba(27, 57, 41, 0.35);
    --assistant-bubble-border: none;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #ffffff;
    --assistant-bubble-time-color: var(--assistant-bubble-color);

    --sidebar-tag-bg: rgba(0, 255, 65, 0.15);
    --sidebar-tag-color: #00ff41;

    /* Action Buttons: deeper matrix-green OK; near-black green Cancel */
    --btn-ok-bg: #00c830;
    --btn-ok-color: #070d0a;
    --btn-ok-border: #009924;
    --btn-ok-hover-bg: #009924;
    --btn-ok-hover-color: #070d0a;
    --btn-cancel-bg: #16241d;
    --btn-cancel-color: #85e09b;
    --btn-cancel-border: #22372b;
    --btn-cancel-hover-bg: #22372b;
    --btn-cancel-hover-color: #d1ffd9;
}

/* Sharp / zero-radius rendering for pixel-perfect retro aesthetics */
body.theme-cga,
body.theme-cga * {
    border-radius: 0px !important;
}

body.theme-acheron,
body.theme-acheron * {
    border-radius: 0px !important;
}

body.theme-cga ::-webkit-scrollbar-thumb {
    border-radius: 0px !important;
}

body.theme-acheron ::-webkit-scrollbar-thumb {
    border-radius: 0px !important;
}

/* ==== css/themes/scifi.css ==== */
/* ==========================================================================
   Sci-Fi Themes  —  Renaissance Gold, Starship Terminal, Celestial OS, Aqua Classic
   ========================================================================== */

/* ─── Renaissance Gold ───────────────────────────────────────────────────────
   Inspired by the amber-gold-on-dark-charcoal aesthetic of augmented-reality
   heads-up displays. Deep almost-black backgrounds with rich antique gold and
   warm bronze accents evoke an age of mechanical enlightenment.
   ─────────────────────────────────────────────────────────────────────────── */
body.theme-renaissance {
    --font-theme: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace; /* required: --font-theme is proportional */

    --bg-darker: #0a0800;
    --bg-main: #100d00;
    --bg-panel: #1a1500;
    --bg-hover: #251e00;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #3d3000;
    --border-glow: #e8a000;

    --accent-primary: #e8a000;
    --accent-primary-dim: rgba(232, 160, 0, 0.15);
    --accent-warning: #ffcc44;
    --accent-warning-dim: rgba(255, 204, 68, 0.18);
    --accent-secondary: #c47b00;
    --accent-secondary-dim: rgba(196, 123, 0, 0.18);
    --accent-error: #cc2200;
    --accent-error-dim: rgba(204, 34, 0, 0.18);

    --text-primary: #f0dfa0;
    --text-muted: #a08840;
    --text-bright: #fff8d0;

    --arrow-color: #a08840;
    --arrow-accent-color: #e8a000;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a08840' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e8a000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a08840' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #6fcf3a;
    --indicator-online-dim: rgba(111, 207, 58, 0.2);
    --indicator-offline: #cc2200;
    --indicator-offline-dim: rgba(204, 34, 0, 0.2);
    --indicator-dormant: #e8a000;
    --indicator-dormant-dim: rgba(232, 160, 0, 0.2);

    --user-bubble-bg: rgba(232, 160, 0, 0.12);
    --user-bubble-border: 1px solid rgba(232, 160, 0, 0.4);
    --user-bubble-accent-border: 2px solid var(--accent-primary);
    --user-bubble-color: #fff8d0;

    --assistant-bubble-bg: rgba(196, 123, 0, 0.08);
    --assistant-bubble-border: 1px solid rgba(196, 123, 0, 0.3);
    --assistant-bubble-accent-border: 2px solid var(--accent-secondary);
    --assistant-bubble-color: var(--text-primary);

    --sidebar-tag-bg: #3d3000;
    --sidebar-tag-color: #f0dfa0;

    /* Action Buttons: solid bronze OK; near-black parchment Cancel */
    --btn-ok-bg: #c47b00;
    --btn-ok-color: #fff8d0;
    --btn-ok-border: #9a6000;
    --btn-ok-hover-bg: #9a6000;
    --btn-ok-hover-color: #fff8d0;
    --btn-cancel-bg: #251e00;
    --btn-cancel-color: #a08840;
    --btn-cancel-border: #3d3000;
    --btn-cancel-hover-bg: #3d3000;
    --btn-cancel-hover-color: #f0dfa0;
}

/* ─── Starship Terminal ──────────────────────────────────────────────────────
   Inspired by LCARS-style federation computer interfaces. Black backgrounds
   with warm beige/peach/orange panel dividers and that characteristic
   burnt-orange rounded-panel aesthetic. Text is a warm off-white.
   ─────────────────────────────────────────────────────────────────────────── */
body.theme-starship {
    --bg-darker: #000000;
    --bg-main: #06060f;
    --bg-panel: #0d0d1a;
    --bg-hover: #14142a;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #cc7722;
    --border-glow: #dd9944;

    --accent-primary: #dd9944;
    --accent-primary-dim: rgba(221, 153, 68, 0.18);
    --accent-warning: #ffcc00;
    --accent-warning-dim: rgba(255, 204, 0, 0.18);
    --accent-secondary: #cc6633;
    --accent-secondary-dim: rgba(204, 102, 51, 0.18);
    --accent-error: #cc3333;
    --accent-error-dim: rgba(204, 51, 51, 0.18);

    --text-primary: #f5e6cc;
    --text-muted: #b09060;
    --text-bright: #fff5e0;

    --arrow-color: #b09060;
    --arrow-accent-color: #dd9944;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b09060' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dd9944' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b09060' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #66cc44;
    --indicator-online-dim: rgba(102, 204, 68, 0.2);
    --indicator-offline: #cc3333;
    --indicator-offline-dim: rgba(204, 51, 51, 0.2);
    --indicator-dormant: #ffcc00;
    --indicator-dormant-dim: rgba(255, 204, 0, 0.2);

    --user-bubble-bg: rgba(221, 153, 68, 0.1);
    --user-bubble-border: 1px solid rgba(221, 153, 68, 0.3);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);

    --assistant-bubble-bg: rgba(204, 102, 51, 0.08);
    --assistant-bubble-border: 1px solid rgba(204, 102, 51, 0.25);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    --sidebar-tag-bg: #cc6633;
    --sidebar-tag-color: #ffffff;

    /* Action Buttons: LCARS burnt-orange OK; very-dark-space Cancel */
    --btn-ok-bg: #cc6633;
    --btn-ok-color: #fff5e0;
    --btn-ok-border: #a04e22;
    --btn-ok-hover-bg: #a04e22;
    --btn-ok-hover-color: #fff5e0;
    --btn-cancel-bg: #14142a;
    --btn-cancel-color: #b09060;
    --btn-cancel-border: #cc7722;
    --btn-cancel-hover-bg: #1e1e3a;
    --btn-cancel-hover-color: #f5e6cc;
}

/* ─── Celestial OS ───────────────────────────────────────────────────────────
   Inspired by TempleOS's stark, high-contrast 16-color palette on pure white.
   Vivid primary colours on a blinding white background — bold cobalt blue,
   bright red errors, sunshine yellow warnings. No subtlety; pure intent.
   ─────────────────────────────────────────────────────────────────────────── */
body.theme-celestial {
    --bg-darker: #d8d8d8;
    --bg-main: #ffffff;
    --bg-panel: #f0f0f0;
    --bg-hover: #e0e0e0;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #a0a0a0;
    --border-glow: #0000aa;

    --accent-primary: #0000cc;
    --accent-primary-dim: rgba(0, 0, 204, 0.12);
    --accent-warning: #aaaa00;
    --accent-warning-dim: rgba(170, 170, 0, 0.15);
    --accent-secondary: #00aaaa;
    --accent-secondary-dim: rgba(0, 170, 170, 0.15);
    --accent-error: #cc0000;
    --accent-error-dim: rgba(204, 0, 0, 0.12);

    --text-primary: #000000;
    --text-muted: #444444;
    --text-bright: #000000;

    --arrow-color: #444444;
    --arrow-accent-color: #0000cc;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23444444' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230000cc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23444444' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: use vivid system colours faithful to a 16-colour palette */
    --indicator-online: #00aa00;
    --indicator-online-dim: rgba(0, 170, 0, 0.15);
    --indicator-offline: #cc0000;
    --indicator-offline-dim: rgba(204, 0, 0, 0.15);
    --indicator-dormant: #aaaa00;
    --indicator-dormant-dim: rgba(170, 170, 0, 0.15);

    --user-bubble-bg: #e8f0fe;
    --user-bubble-border: 1px solid #0000cc;
    --user-bubble-accent-border: none;
    --user-bubble-color: #000000;

    --assistant-bubble-bg: #e0f7fa;
    --assistant-bubble-border: 1px solid #00aaaa;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #000000;

    --sidebar-tag-bg: #0000cc;
    --sidebar-tag-color: #ffffff;

    /* Action Buttons: solid fills faithful to 16-colour palette — plain blue Ok, grey Cancel */
    --btn-ok-bg: #0000cc;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #000099;
    --btn-ok-hover-bg: #000099;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #d8d8d8;
    --btn-cancel-color: #000000;
    --btn-cancel-border: #a0a0a0;
    --btn-cancel-hover-bg: #c0c0c0;
    --btn-cancel-hover-color: #000000;
}

/* ─── Aqua Classic ───────────────────────────────────────────────────────────
   Inspired by Mac OS X 10.0–10.4 Aqua. Soft sky-blue panels on near-white,
   with that iconic deep-water teal accent and polished platinum sidebars.
   Secondary accent echoes the original graphite/mauve finder window chrome.
   ─────────────────────────────────────────────────────────────────────────── */
body.theme-aqua {
    --bg-darker: #c5d9f0;
    --bg-main: #ddeeff;
    --bg-panel: #eef5ff;
    --bg-hover: #d0e8ff;
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #8ab4d8;
    --border-glow: #0077cc;

    --accent-primary: #0077cc;
    --accent-primary-dim: rgba(0, 119, 204, 0.15);
    --accent-warning: #e07800;
    --accent-warning-dim: rgba(224, 120, 0, 0.15);
    --accent-secondary: #008b9c;
    --accent-secondary-dim: rgba(0, 139, 156, 0.15);
    --accent-error: #cc1100;
    --accent-error-dim: rgba(204, 17, 0, 0.15);

    --text-primary: #1a2a3a;
    --text-muted: #4a6a8a;
    --text-bright: #000000;

    --arrow-color: #4a6a8a;
    --arrow-accent-color: #0077cc;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a6a8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230077cc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a6a8a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Indicators: vivid but still within the cool-blue palette */
    --indicator-online: #1a8c1a;
    --indicator-online-dim: rgba(26, 140, 26, 0.18);
    --indicator-offline: #cc1100;
    --indicator-offline-dim: rgba(204, 17, 0, 0.18);
    --indicator-dormant: #e07800;
    --indicator-dormant-dim: rgba(224, 120, 0, 0.18);

    --user-bubble-bg: rgba(0, 119, 204, 0.08);
    --user-bubble-border: 1px solid rgba(0, 119, 204, 0.25);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);

    --assistant-bubble-bg: rgba(0, 139, 156, 0.06);
    --assistant-bubble-border: 1px solid rgba(0, 139, 156, 0.2);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    --sidebar-tag-bg: #c5d9f0;
    --sidebar-tag-color: #1a2a3a;

    /* Action Buttons: solid fills within the Aqua blue palette */
    --btn-ok-bg: #0077cc;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #005599;
    --btn-ok-hover-bg: #005599;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #c5d9f0;
    --btn-cancel-color: #1a2a3a;
    --btn-cancel-border: #8ab4d8;
    --btn-cancel-hover-bg: #b0caeb;
    --btn-cancel-hover-color: #1a2a3a;
}

/* ==== css/themes/grand-prix-98.css ==== */
/* ==========================================================================
   Grand Prix 98 (Ridge Racer Type 4-inspired Dark Theme)
   ========================================================================== */

body.theme-grand-prix-98-dark {
    --font-theme: "Barlow Condensed", "Segoe UI", sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    --bg-darker: #f3b704; /* Namco Yellow margin frame */
    --bg-main: #1e1e22; /* Central workspace panels (charcoal slate) */
    --bg-panel: #26262a; /* Sidebar, settings boxes, card items */
    --bg-hover: #323238; /* Hover states on buttons/inputs */
    --border-color: #3b3b40;
    --border-glow: #ff3b00; /* Glowing accent border effects (scarlet) */

    /* Layout & Inner Container overrides */
    --bg-header: var(--bg-darker);
    --bg-sidebar: var(--bg-panel);
    --bg-footer: var(--bg-darker);
    --bg-inner: #151518;
    --opacity-header: 1;
    --opacity-footer: 1;

    --accent-primary: #ff3b00; /* Scarlet orange-red */
    --accent-primary-dim: rgba(255, 59, 0, 0.15);
    --accent-secondary: #f3b704; /* Namco yellow-orange */
    --accent-secondary-dim: rgba(243, 183, 4, 0.15);
    --accent-warning: #ffd60a;
    --accent-warning-dim: rgba(255, 214, 10, 0.15);
    --accent-error: #ff453a;
    --accent-error-dim: rgba(255, 69, 58, 0.15);

    --text-primary: #ffffff;
    --text-muted: #8e909a;
    --text-bright: #ffffff;

    --arrow-color: #8e909a;
    --arrow-accent-color: #ff3b00;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e909a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff3b00' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e909a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #30d158;
    --indicator-online-dim: rgba(48, 209, 88, 0.2);
    --indicator-offline: #ef4617;
    --indicator-offline-dim: rgba(255, 69, 58, 0.18);
    --indicator-dormant: #1e1e22;
    --indicator-dormant-dim: rgba(185, 185, 209, 0.2);

    --user-bubble-bg: #ff3b00;
    --user-bubble-border: none;
    --user-bubble-accent-border: none;
    --user-bubble-color: #ffffff;
    --user-bubble-time-color: var(--user-bubble-color);

    --assistant-bubble-bg: #26262a;
    --assistant-bubble-border: none;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #ffffff;
    --assistant-bubble-time-color: var(--assistant-bubble-color);

    --sidebar-tag-bg: #ff3b00;
    --sidebar-tag-color: #ffffff;

    /* Grand Prix close button styling (slate grey with white X) */
    --close-btn-bg: #26262a;
    --close-btn-border: 1px solid #3b3b40;
    --close-btn-color: #ffffff;
    --close-btn-hover-bg: var(--accent-error);
    --close-btn-hover-border: var(--accent-error);
    --close-btn-hover-color: #ffffff;

    /* Action Buttons: white OK with dark text (pops on the charcoal settings panel); charcoal Cancel */
    --btn-ok-bg: #ffffff;
    --btn-ok-color: #1e1e22;
    --btn-ok-border: #c0c0c0;
    --btn-ok-hover-bg: #ff3b00;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #3b3b40;
    --btn-cancel-color: #ffffff;
    --btn-cancel-border: #5a5a60;
    --btn-cancel-hover-bg: #52525a;
    --btn-cancel-hover-color: #ffffff;

    /* Header/Footer text for yellow background readability */
    --header-text: #1e1e22;
    --footer-text: #1e1e22;

    /* Checkbox styling */
    --checkmark-bg: #ffffff;
    --checkmark-border: #1e1e22;
    --checkmark-checked-bg: #ff3b00;
    --checkmark-checked-border: #ff3b00;
}

/* ── Structural overrides ─────────────────────────────────────────────────── */

/* Force rigid, sharp console menu styling */
body.theme-grand-prix-98-dark,
body.theme-grand-prix-98-dark * {
    border-radius: 0px !important;
}

body.theme-grand-prix-98-dark ::-webkit-scrollbar-thumb {
    border-radius: 0px !important;
}

/* Header & HUD Styling using Anton font */
body.theme-grand-prix-98-dark .app-title,
body.theme-grand-prix-98-dark h1,
body.theme-grand-prix-98-dark h2,
body.theme-grand-prix-98-dark h3,
body.theme-grand-prix-98-dark .sidebar-header,
body.theme-grand-prix-98-dark .panel-header h2,
body.theme-grand-prix-98-dark .status-lamp,
body.theme-grand-prix-98-dark #sidebar-toggle-btn,
body.theme-grand-prix-98-dark .ptt-btn,
body.theme-grand-prix-98-dark .action-btn,
body.theme-grand-prix-98-dark .input-controls label {
    font-family: "Anton", "Arial Black", sans-serif !important;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Emoji trigger button: icon colour must be charcoal against the yellow footer background
   (the default --text-muted grey is invisible on #f3b704). */
body.theme-grand-prix-98-dark .emoji-trigger-btn {
    color: var(--header-text);
    border-color: var(--header-text);
}

/* R4 Header Prefix (*) */
body.theme-grand-prix-98-dark h1:before,
body.theme-grand-prix-98-dark h2:before,
body.theme-grand-prix-98-dark .panel-header h2:before,
body.theme-grand-prix-98-dark .sidebar-header:before {
    content: "*";
    color: var(--accent-primary);
    margin-right: 6px;
}

/* Custom titlebar styling for Grand Prix 98 (Yellow header) */
body.theme-grand-prix-98-dark .titlebar {
    border-bottom: var(--border-width-thick) solid var(--header-text); /* Sharp dark separator */
}

/* Make text, buttons, and icons inside the header dark charcoal for high readability on yellow */
body.theme-grand-prix-98-dark .titlebar .app-title,
body.theme-grand-prix-98-dark .titlebar .tb-btn-label,
body.theme-grand-prix-98-dark .titlebar .status-btn:not(#status-stt):not(#status-tts),
body.theme-grand-prix-98-dark .titlebar .set-default-btn,
body.theme-grand-prix-98-dark .titlebar .win-btn {
    color: var(--header-text) !important;
}

body.theme-grand-prix-98-dark .titlebar .app-icon {
    color: var(--accent-primary) !important; /* Keep the red accent icon */
    filter: drop-shadow(0 0 2px var(--accent-primary-dim)) !important;
}

body.theme-grand-prix-98-dark #sidebar-toggle-btn {
    color: var(--header-text) !important;
    border-color: var(--header-text) !important;
}
body.theme-grand-prix-98-dark #sidebar-toggle-btn:hover {
    color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    background-color: rgba(30, 30, 34, 0.1) !important;
}

/* Button borders and states on yellow background */
body.theme-grand-prix-98-dark .titlebar .status-btn,
body.theme-grand-prix-98-dark .titlebar .file-browser-btn,
body.theme-grand-prix-98-dark .titlebar .debug-btn,
body.theme-grand-prix-98-dark .titlebar .settings-btn {
    border-color: rgba(30, 30, 34, 0.35) !important;
}

body.theme-grand-prix-98-dark .titlebar .status-btn:hover,
body.theme-grand-prix-98-dark .titlebar .file-browser-btn:hover,
body.theme-grand-prix-98-dark .titlebar .file-browser-btn.active,
body.theme-grand-prix-98-dark .titlebar .debug-btn:hover,
body.theme-grand-prix-98-dark .titlebar .debug-btn.active,
body.theme-grand-prix-98-dark .titlebar .settings-btn:hover {
    background-color: rgba(30, 30, 34, 0.1) !important;
    border-color: var(--header-text) !important;
}

/* Debug / Files / Settings buttons in Titlebar */
body.theme-grand-prix-98-dark .titlebar .file-browser-btn .ui-icon {
    color: var(--header-text) !important; /* Force dark instead of yellow */
}
body.theme-grand-prix-98-dark .titlebar .debug-btn .ui-icon {
    color: var(--header-text) !important; /* Force dark instead of yellow */
}
body.theme-grand-prix-98-dark .titlebar .settings-btn .ui-icon {
    color: var(--header-text) !important; /* Force dark instead of muted grey */
}

/* Emoji button: --accent-secondary is Namco yellow, same as the yellow footer bg — override
   to scarlet so the icon is visible against the dark charcoal input panel background. */
body.theme-grand-prix-98-dark .emoji-trigger-btn:hover {
    border-color: var(--accent-primary) !important;
    color: var(--accent-primary) !important;
    box-shadow: 0 0 8px var(--accent-primary-dim) !important;
}

/* Grand Prix footer overrides for Namco Yellow background */
body.theme-grand-prix-98-dark .panel-footer {
    border-top: var(--border-width) solid var(--header-text);
}
body.theme-grand-prix-98-dark .panel-footer .metric-lbl {
    color: var(--footer-text) !important;
}
body.theme-grand-prix-98-dark .panel-footer .metric-val {
    color: var(--accent-primary) !important;
}
body.theme-grand-prix-98-dark .panel-footer .checkbox-container {
    color: var(--footer-text) !important;
}
body.theme-grand-prix-98-dark .panel-footer .checkbox-container input:checked ~ .scroll-lbl {
    color: var(--accent-primary) !important;
}
body.theme-grand-prix-98-dark .panel-footer .checkmark {
    border-color: var(--checkmark-border) !important;
    background-color: var(--checkmark-bg) !important;
}
body.theme-grand-prix-98-dark .panel-footer .checkbox-container input:checked + .checkmark {
    background-color: var(--checkmark-checked-bg) !important;
    border-color: var(--checkmark-checked-border) !important;
}
body.theme-grand-prix-98-dark .panel-footer .checkbox-container input:checked + .checkmark::after {
    color: var(--checkmark-bg) !important;
}

/* ==== css/themes/xross-blue.css ==== */
/* ==========================================================================
   Xross Blue (Console/Handheld Wave Theme)
   ========================================================================== */

body.theme-xross-blue {
    --font-theme: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    /* Base Palette */
    --bg-darker: #051829;
    --bg-main: #0c437a;
    --bg-panel: rgba(255, 255, 255, 0.04);
    --bg-hover: rgba(255, 255, 255, 0.12);

    /* Layout & Glass transparency */
    --bg-header: transparent;
    --bg-sidebar: rgba(5, 24, 41, 0.35);
    --bg-footer: transparent;
    --bg-inner: rgba(5, 24, 41, 0.2);
    --opacity-header: 0.6;
    --opacity-sidebar: 0.5;
    --opacity-footer: 0.8;

    /* Borders & Glows */
    --border-color: rgba(255, 255, 255, 0.12);
    --border-glow: rgba(173, 220, 255, 0.3);

    /* Accents */
    --accent-primary: #addcff; /* Glowing Wave Cyan */
    --accent-primary-dim: rgba(173, 220, 255, 0.15);
    --accent-warning: #ffd740;
    --accent-warning-dim: rgba(255, 215, 64, 0.15);
    --accent-secondary: #ffffff; /* Pure white console text */
    --accent-secondary-dim: rgba(255, 255, 255, 0.2);
    --accent-error: #ff5252;
    --accent-error-dim: rgba(255, 82, 82, 0.15);

    /* Typography */
    --text-primary: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.65);
    --text-bright: #ffffff;

    /* Chat Bubbles (Rounded Pill Style) */
    --user-bubble-bg: rgba(173, 220, 255, 0.08);
    --user-bubble-border: 1px solid rgba(173, 220, 255, 0.25);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);

    --assistant-bubble-bg: rgba(255, 255, 255, 0.03);
    --assistant-bubble-border: 1px solid rgba(255, 255, 255, 0.08);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    /* Buttons & Badges */
    --sidebar-tag-bg: rgba(255, 255, 255, 0.15);
    --sidebar-tag-color: #ffffff;
    --btn-ok-bg: rgba(255, 255, 255, 0.9);
    --btn-ok-color: #0c437a;
    --btn-ok-border: transparent;
    --btn-ok-hover-bg: #ffffff;
    --btn-ok-hover-color: #051829;
    --btn-cancel-bg: rgba(255, 255, 255, 0.08);
    --btn-cancel-color: #ffffff;
    --btn-cancel-border: rgba(255, 255, 255, 0.2);
    --btn-cancel-hover-bg: rgba(255, 255, 255, 0.15);
    --btn-cancel-hover-color: #ffffff;

    --arrow-color: white;
    --arrow-accent-color: #addcff;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23addcff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Status Indicators */
    --indicator-online: #00e676;
    --indicator-online-dim: rgba(0, 230, 118, 0.2);
    --indicator-offline: #ff5252;
    --indicator-offline-dim: rgba(255, 82, 82, 0.2);
    --indicator-dormant: #ffd740;
    --indicator-dormant-dim: rgba(255, 215, 64, 0.2);
}

/* ── Structural overrides ─────────────────────────────────────────────────── */

/* Rounded Capsule Pill Aesthetics */
body.theme-xross-blue .btn,
body.theme-xross-blue .action-btn,
body.theme-xross-blue .ptt-btn,
body.theme-xross-blue .sidebar-item,
body.theme-xross-blue .status-btn,
body.theme-xross-blue .set-default-btn,
body.theme-xross-blue .emoji-trigger-btn,
body.theme-xross-blue .settings-tab-btn,
body.theme-xross-blue .nav-btn,
body.theme-xross-blue .sidebar-search input,
body.theme-xross-blue .preset-dropdown,
body.theme-xross-blue .input-panel-wrapper,
body.theme-xross-blue .panel-header-btn {
    border-radius: 9999px !important;
}

body.theme-xross-blue .message-bubble {
    border-radius: 18px !important;
}

body.theme-xross-blue .welcome-box,
body.theme-xross-blue .settings-box,
body.theme-xross-blue .modal-content,
body.theme-xross-blue .note-editor,
body.theme-xross-blue .file-browser-panel,
body.theme-xross-blue .settings-drawer,
body.theme-xross-blue .system-alert-toast {
    border-radius: 16px !important;
}

body.theme-xross-blue .system-alert-toast {
    border-left-width: 1px !important;
}

/* Glassmorphism blur on background-active structures */
body.theme-xross-blue.has-custom-bg .message-bubble,
body.theme-xross-blue.has-custom-bg .sidebar,
body.theme-xross-blue.has-custom-bg .file-browser-sidebar,
body.theme-xross-blue.has-custom-bg .debug-console,
body.theme-xross-blue.has-custom-bg .titlebar,
body.theme-xross-blue.has-custom-bg .input-panel,
body.theme-xross-blue.has-custom-bg .welcome-box,
body.theme-xross-blue.has-custom-bg .settings-box,
body.theme-xross-blue.has-custom-bg .modal-content,
body.theme-xross-blue.has-custom-bg .settings-drawer,
body.theme-xross-blue.has-custom-bg .system-alert-toast {
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

/* Glowing text styling for XMB console titles */
body.theme-xross-blue h1,
body.theme-xross-blue h2,
body.theme-xross-blue h3,
body.theme-xross-blue .app-title,
body.theme-xross-blue .panel-header h2,
body.theme-xross-blue .sidebar-header,
body.theme-xross-blue .sidebar-title {
    font-weight: 300 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    text-shadow: 0 0 10px rgba(173, 220, 255, 0.45) !important;
}

/* Translucent Inputs & Dropdowns */
body.theme-xross-blue .sidebar-search input,
body.theme-xross-blue .preset-dropdown {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: var(--text-bright) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
}
body.theme-xross-blue .sidebar-search input:focus,
body.theme-xross-blue .preset-dropdown:focus,
body.theme-xross-blue .preset-dropdown:hover {
    background-color: rgba(255, 255, 255, 0.12) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 8px var(--border-glow) !important;
}

/* Custom Dropdown Option styling inside WebView2 (Solid color override to avoid white-on-white) */
body.theme-xross-blue select option {
    background-color: var(--bg-darker) !important;
    color: var(--text-primary) !important;
}

/* Glowing scrollbars */
body.theme-xross-blue ::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}
body.theme-xross-blue ::-webkit-scrollbar-track {
    background: transparent !important;
}
body.theme-xross-blue ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 9999px !important;
}
body.theme-xross-blue ::-webkit-scrollbar-thumb:hover {
    background: rgba(173, 220, 255, 0.4) !important;
}

/* ==== css/themes/aero-glass.css ==== */
/* ==========================================================================
   Aero Glass (Windows Vista / Longhorn-inspired Theme)
   ========================================================================== */

body.theme-aero-glass {
    --font-theme: "Segoe UI", "Plus Jakarta Sans", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    /* Base Palette: Dark Slate Teal-Black */
    --bg-darker: #080d12;
    --bg-main: #0f161d;
    --bg-panel: rgba(16, 26, 36, 0.35); /* Frosted teal-black glass */
    --bg-hover: rgba(255, 255, 255, 0.12);

    /* Layout & Glass transparency */
    --bg-header: transparent;
    --bg-sidebar: rgba(12, 20, 28, 0.45);
    --bg-footer: transparent;
    --bg-inner: rgba(8, 12, 18, 0.2);
    --opacity-header: 0.55;
    --opacity-sidebar: 0.55;
    --opacity-footer: 0.85;

    /* Borders & Glows */
    --border-color: rgba(255, 255, 255, 0.14); /* Crisp, thin white glass border */
    --border-glow: rgba(92, 225, 230, 0.25);

    /* Accents: Aero Teal & Vista Orange */
    --accent-primary: #5ce1e6; /* Aero Teal / Cyan */
    --accent-primary-dim: rgba(92, 225, 230, 0.15);
    --accent-warning: #ff8f00; /* Vista Amber / Orange */
    --accent-warning-dim: rgba(255, 143, 0, 0.15);
    --accent-secondary: #ffffff;
    --accent-secondary-dim: rgba(255, 255, 255, 0.2);
    --accent-error: #ff4a4a;
    --accent-error-dim: rgba(255, 74, 74, 0.15);

    /* Typography */
    --text-primary: #f0f3f6;
    --text-muted: rgba(240, 243, 246, 0.65);
    --text-bright: #ffffff;

    /* Chat Bubbles (Frosted Glass panels) */
    --user-bubble-bg: rgba(92, 225, 230, 0.07);
    --user-bubble-border: 1px solid rgba(92, 225, 230, 0.2);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);

    --assistant-bubble-bg: rgba(255, 255, 255, 0.03);
    --assistant-bubble-border: 1px solid rgba(255, 255, 255, 0.06);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    /* Buttons & Controls */
    --sidebar-tag-bg: rgba(92, 225, 230, 0.15);
    --sidebar-tag-color: #ffffff;
    --btn-ok-bg: #1bbb0a; /* Classic Windows Start Green */
    --btn-ok-color: #ffffff;
    --btn-ok-border: #138707;
    --btn-ok-hover-bg: #138707;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: rgba(255, 255, 255, 0.08);
    --btn-cancel-color: #ffffff;
    --btn-cancel-border: rgba(255, 255, 255, 0.18);
    --btn-cancel-hover-bg: rgba(255, 255, 255, 0.15);
    --btn-cancel-hover-color: #ffffff;

    --arrow-color: white;
    --arrow-accent-color: #5ce1e6;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235ce1e6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Status Indicators */
    --indicator-online: #1bbb0a;
    --indicator-online-dim: rgba(27, 187, 10, 0.2);
    --indicator-offline: #ff4a4a;
    --indicator-offline-dim: rgba(255, 74, 74, 0.2);
    --indicator-dormant: #ff8f00;
    --indicator-dormant-dim: rgba(255, 143, 0, 0.2);
}

/* ── Structural overrides ─────────────────────────────────────────────────── */

/* Rounded Vista Window Styling (Subtler 8px - 10px curves) */
body.theme-aero-glass .btn,
body.theme-aero-glass .action-btn,
body.theme-aero-glass .ptt-btn,
body.theme-aero-glass .sidebar-item,
body.theme-aero-glass .status-btn,
body.theme-aero-glass .set-default-btn,
body.theme-aero-glass .emoji-trigger-btn,
body.theme-aero-glass .settings-tab-btn,
body.theme-aero-glass .nav-btn,
body.theme-aero-glass .sidebar-search input,
body.theme-aero-glass .preset-dropdown,
body.theme-aero-glass .panel-header-btn {
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

body.theme-aero-glass .chat-bubble {
    border-radius: 8px !important;
}

body.theme-aero-glass .welcome-box,
body.theme-aero-glass .settings-box,
body.theme-aero-glass .modal-content,
body.theme-aero-glass .note-editor,
body.theme-aero-glass .file-browser-panel,
body.theme-aero-glass .settings-drawer,
body.theme-aero-glass .system-alert-toast {
    border-radius: 10px !important;
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.16) !important;
}

/* Glassmorphism blur on background-active structures */
body.theme-aero-glass.has-custom-bg .message-bubble,
body.theme-aero-glass.has-custom-bg .sidebar,
body.theme-aero-glass.has-custom-bg .file-browser-sidebar,
body.theme-aero-glass.has-custom-bg .debug-console,
body.theme-aero-glass.has-custom-bg .titlebar,
body.theme-aero-glass.has-custom-bg .input-panel,
body.theme-aero-glass.has-custom-bg .welcome-box,
body.theme-aero-glass.has-custom-bg .settings-box,
body.theme-aero-glass.has-custom-bg .modal-content,
body.theme-aero-glass.has-custom-bg .settings-drawer,
body.theme-aero-glass.has-custom-bg .system-alert-toast {
    backdrop-filter: blur(16px) !important; /* Slightly stronger Vista-style blur */
    -webkit-backdrop-filter: blur(16px) !important;
}

/* Glossy Aero Diagonal Light Beam/Shine Reflections */
body.theme-aero-glass .sidebar,
body.theme-aero-glass .file-browser-sidebar,
body.theme-aero-glass .debug-console,
body.theme-aero-glass .settings-drawer,
body.theme-aero-glass .message-bubble,
body.theme-aero-glass .welcome-box,
body.theme-aero-glass .system-alert-toast {
    background-image: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0.03) 48%,
        rgba(255, 255, 255, 0) 48.5%,
        rgba(255, 255, 255, 0) 100%
    ) !important;
}

/* Flat Glowing text details */
body.theme-aero-glass h1,
body.theme-aero-glass h2,
body.theme-aero-glass h3,
body.theme-aero-glass .app-title,
body.theme-aero-glass .panel-header h2,
body.theme-aero-glass .sidebar-header,
body.theme-aero-glass .sidebar-title {
    font-weight: 400 !important;
    letter-spacing: 0.03em !important;
    text-transform: none !important;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.5) !important;
}

/* Translucent Inputs & Dropdowns */
body.theme-aero-glass .sidebar-search input,
body.theme-aero-glass .preset-dropdown {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: var(--text-bright) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
}
body.theme-aero-glass .sidebar-search input:focus,
body.theme-aero-glass .preset-dropdown:focus,
body.theme-aero-glass .preset-dropdown:hover {
    background-color: rgba(255, 255, 255, 0.12) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 8px var(--border-glow) !important;
}

/* Custom Dropdown Option styling inside WebView2 (Solid color override to avoid white-on-white) */
body.theme-aero-glass select option {
    background-color: #26262a !important;
    color: #ffffff !important;
}

/* Glowing scrollbars */
body.theme-aero-glass ::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}
body.theme-aero-glass ::-webkit-scrollbar-track {
    background: transparent !important;
}
body.theme-aero-glass ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: 9999px !important;
}
body.theme-aero-glass ::-webkit-scrollbar-thumb:hover {
    background: rgba(92, 225, 230, 0.3) !important;
}

/* ==== css/themes/vanalink.css ==== */
/* ==========================================================================
   Vana-Link (Classic PlayOnline-inspired Theme)
   ========================================================================== */

body.theme-vanalink {
    /* Background Gradient */
    --bg-gradient: radial-gradient(circle at 50% 15%, #4fa3e3 0%, #1d61b3 45%, #081a38 100%);

    /* Shape & Layout - Retro/Millennium Pill Look */
    --titlebar-btn-radius: 9999px;
    --titlebar-btn-border-width: 2px;
    --titlebar-btn-bg: rgba(255, 255, 255, 0.06);

    /* Icon Colors - Themed to match PlayOnline aesthetic */
    --icon-files: #4fa3e3;
    --icon-debug: #addcff;
    --icon-settings: #ffd700;

    /* Button Gradient & Shape */
    --btn-gradient: linear-gradient(to bottom, #4a7ec5 0%, #2d558d 100%);
    --btn-border: 1px solid #4a7ec5;
    --btn-shadow: none;
    --btn-color: #ffffff;
    --btn-radius: 9999px;
    --btn-text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);

    /* Send Button */
    --send-btn-gradient: linear-gradient(to bottom, #4a7ec5 0%, #2d558d 100%);
    --send-btn-border: 1px solid var(--border-color);
    --send-btn-color: #ffffff;

    --font-theme: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;
    --visualizer-color: #7dbbff;

    /* Base Palette */
    --bg-darker: #081a38;
    --bg-main: #143d75;
    --bg-panel: #dce6f0;
    --bg-hover: #b8cadd;

    /* Layout & Transparency overrides */
    --bg-header: transparent;
    --bg-sidebar: transparent;
    --bg-footer: transparent;
    --bg-inner: transparent;
    --opacity-header: 1;
    --opacity-sidebar: 1;
    --opacity-footer: 1;

    /* Borders & Glows */
    --border-color: #1a2430;
    --border-glow: rgba(173, 220, 255, 0.45);

    /* Accents */
    --accent-primary: #1c5298;
    --accent-primary-dim: rgba(28, 82, 152, 0.15);
    --accent-secondary: #1c2733;
    --accent-secondary-dim: rgba(28, 39, 51, 0.15);
    --accent-warning: #f09a1e;
    --accent-warning-dim: rgba(240, 154, 30, 0.15);
    --accent-error: #d13b3b;
    --accent-error-dim: rgba(209, 59, 59, 0.15);

    /* Typography */
    --text-primary: #1c2733;
    --text-muted: #526071;
    --text-bright: #ffffff;

    /* Chat Bubbles (Rounded Card Style) */
    --user-bubble-bg: #1d519b;
    --user-bubble-border: 2px solid #0d1e36;
    --user-bubble-accent-border: none;
    --user-bubble-color: #ffffff;
    --user-bubble-time-color: rgba(255, 255, 255, 0.8);

    --assistant-bubble-bg: #e5edf6;
    --assistant-bubble-border: 2px solid #1c2733;
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: #1c2733;
    --assistant-bubble-time-color: #526071;

    /* Buttons & Badges */
    --sidebar-tag-bg: #1d519b;
    --sidebar-tag-color: #ffffff;
    --btn-ok-bg: #1d519b;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #0d1e36;
    --btn-ok-hover-bg: #2f79d1;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #7d8c9e;
    --btn-cancel-color: #ffffff;
    --btn-cancel-border: #b0c0d2;
    --btn-cancel-hover-bg: linear-gradient(to bottom, #8d9dae 0%, #626e7d 100%);
    --btn-cancel-hover-border: #c0d0e2;
    --btn-cancel-hover-color: #ffffff;

    --arrow-color: #1c2733;
    --arrow-accent-color: #1d519b;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231c2733' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d519b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231c2733' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* Status Indicators — brighter green for contrast against dark blue titlebar */
    --indicator-online: #32cf54;
    --indicator-online-dim: rgba(50, 207, 84, 0.25);
    --indicator-offline: #bd2626;
    --indicator-offline-dim: rgba(189, 38, 38, 0.2);
    --indicator-dormant: #e6a117;
    --indicator-dormant-dim: rgba(230, 161, 23, 0.2);

    /* Sidebar Capsule Items */
    --sidebar-item-bg: linear-gradient(180deg, #2b61a7 0%, #153c70 100%);
    --sidebar-item-border: 2px solid #0d1e36;
    --sidebar-item-radius: 9999px;
    --sidebar-item-text: #ffffff;
    --sidebar-item-text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    --sidebar-item-shadow: 0 4px 6px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    --sidebar-item-hover-bg: linear-gradient(180deg, #3d7ccb 0%, #1c5298 100%);
    --sidebar-item-hover-border: #3b76bd;
    --sidebar-item-hover-shadow: 0 0 10px rgba(173, 220, 255, 0.6), 0 4px 6px rgba(0, 0, 0, 0.2);

    /* Glossy Orbs */
    --sidebar-orb-bg: radial-gradient(circle at 35% 35%, #ffffff 0%, #7dbbff 30%, #1c58ad 70%, #08295b 100%);
    --sidebar-orb-shadow: 0 0 6px rgba(125, 187, 255, 0.8), inset -1px -1px 2px rgba(0, 0, 0, 0.6);
    --sidebar-orb-hover-bg: radial-gradient(circle at 35% 35%, #ffffff 0%, #a6d2ff 30%, #3086ff 70%, #0d4699 100%);
    --sidebar-orb-hover-shadow: 0 0 10px rgba(166, 210, 255, 1), 0 0 4px rgba(255, 255, 255, 0.6);

    /* Layout Panels & Cards */
    --panel-bg: #dce6f0;
    --panel-border: 3px solid #1a2430;
    --panel-radius: 24px;
    --panel-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    --panel-text: #1a2430;
    --panel-header-bg: #1c3a6a;
    --panel-header-text: #dce6f0;
    --panel-footer-bg: #1c3a6a;
    --panel-footer-text: #dce6f0;

    /* Input Fields & Textarea */
    --input-bg: #ffffe8;
    --input-border: 2px solid #7d8b9c;
    --input-radius: 16px;
    --input-text: #1a2430;
    --input-bg-focus: #ffffff;
    --input-border-focus: #1c5298;
    --input-shadow: 0 0 8px rgba(28, 82, 152, 0.4);

    /* Sidebar Search Box */
    --sidebar-search-bg: rgba(0, 0, 0, 0.25);
    --sidebar-search-border: 2px solid #4a7ec5;
    --sidebar-search-radius: 9999px;
    --sidebar-search-text: #ffffff;
    --sidebar-search-placeholder: rgba(255, 255, 255, 0.5);
    --sidebar-search-bg-focus: rgba(0, 0, 0, 0.4);
    --sidebar-search-border-focus: #3b76bd;
    --sidebar-search-shadow: 0 0 8px rgba(173, 220, 255, 0.4);

    /* Sidebar Labels & Shadows */
    --sidebar-label-text: #e5edf6;
    --sidebar-label-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    --sidebar-label-color: #dbe8f7;
    --sidebar-label-shadow-global: 0 1px 2px rgba(0, 0, 0, 0.5);

    /* Unified Button Hover */
    --btn-hover-bg: linear-gradient(to bottom, #5a8fd5 0%, #3d659d 100%);
    --btn-hover-border: #add3ff;
    --btn-hover-shadow: 0 0 8px rgba(173, 220, 255, 0.6), 0 2px 4px rgba(0, 0, 0, 0.2);

    /* Chat Bubbles */
    --user-bubble-gradient: linear-gradient(135deg, #1d519b 0%, #2f79d1 100%);
    --bubble-radius: 20px;
    --bubble-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);

    /* Scrollbars */
    --scrollbar-thumb: rgba(28, 82, 152, 0.3);
    --scrollbar-thumb-hover: rgba(28, 82, 152, 0.5);

    /* Schedule Cards */
    --schedule-card-bg: rgba(255, 255, 255, 0.03);
    --schedule-card-border: rgba(255, 255, 255, 0.08);
    --schedule-card-hover-bg: rgba(255, 255, 255, 0.1);
    --schedule-filter-border: rgba(255, 255, 255, 0.2);
    --schedule-filter-active-bg: var(--accent-primary-dim);
    --schedule-card-tag-bg: rgba(28, 82, 152, 0.4);
    --schedule-card-tag-border: rgba(255, 255, 255, 0.1);

    /* Message Controls & Fork Navigator */
    --control-btn-bg: rgba(0, 0, 0, 0.2);
    --control-btn-border: 1px solid rgba(255, 255, 255, 0.2);
    --control-btn-hover-bg: rgba(255, 255, 255, 0.1);
    --control-btn-hover-border: #ffffff;
    --fork-nav-bg: rgba(0, 0, 0, 0.3);
    --fork-nav-border: rgba(255, 255, 255, 0.1);

    /* Debug Console Log Entries */
    --log-entry-bg: rgba(0, 0, 0, 0.4);
    --log-entry-border: var(--accent-primary);
    --log-entry-outbound-bg: var(--accent-primary-dim);
    --log-entry-outbound-border: rgba(173, 220, 255, 0.3);
    --log-entry-inbound-bg: rgba(0, 255, 102, 0.05);
    --log-entry-inbound-border: rgba(0, 255, 102, 0.25);
    --log-entry-system-bg: rgba(0, 0, 0, 0.2);
    --log-entry-system-border: var(--panel-footer-bg);

    /* Notes Editor */
    --note-overlay-bg: var(--bg-darker);
    --note-editor-bg: var(--debug-console-bg);
    --note-editor-text: var(--debug-console-text);
    --note-toolbar-bg: var(--panel-footer-bg);
    --note-toolbar-border: var(--accent-primary);
    --note-tool-btn-color: var(--text-muted);
    --note-tool-btn-hover-bg: rgba(28, 82, 152, 0.4);
    --note-tool-btn-hover-border: var(--accent-secondary);
    --note-tool-sep-bg: #2b3f55;
    --note-scope-chip-bg: var(--panel-footer-bg);
    --note-scope-chip-border: #2b3f55;
    --note-generating-box-bg: var(--panel-footer-bg);
    --note-generating-cancel-border: #2b3f55;
    --note-action-btn-border: #2b3f55;
    --note-action-btn-hover-bg: rgba(28, 82, 152, 0.3);
    --note-action-btn-hover-border: var(--accent-secondary);
    --note-danger-hover-color: #ff6b6b;

    /* Debug Console & Logs */
    --debug-console-bg: #0c1c38;
    --debug-console-text: #e5edf6;

    /* Drawer tab overrides */
    --drawer-tab-border-left-width: 3px;
    --drawer-tab-text: rgba(255, 255, 255, 0.7);
    --drawer-tab-text-active: #ffffff;
    --drawer-tab-hover-bg: rgba(255, 255, 255, 0.05);
}

body.theme-vanalink.has-custom-bg {
    --bg-header: var(--bg-darker);
    --bg-sidebar: var(--bg-darker);
    --bg-footer: var(--bg-darker);
    --bg-inner: var(--bg-darker);
}

/* ── Structural overrides ─────────────────────────────────────────────────── */

/* Beautiful dynamic gradient background */
body.theme-vanalink {
    background: var(--bg-gradient) !important;
}

/* Sidebar navigation buttons (Capsules with glossy indicator) */
body.theme-vanalink .new-chat-item,
body.theme-vanalink .history-toggle,
body.theme-vanalink .schedule-toggle,
body.theme-vanalink .projects-toggle,
body.theme-vanalink .notes-toggle {
    background: var(--sidebar-item-bg) !important;
    border: var(--sidebar-item-border) !important;
    border-radius: var(--sidebar-item-radius) !important;
    padding: 8px 36px 8px 16px !important;
    margin-bottom: 8px !important;
    color: var(--sidebar-item-text) !important;
    font-weight: 500 !important;
    text-shadow: var(--sidebar-item-text-shadow) !important;
    box-shadow: var(--sidebar-item-shadow) !important;
    position: relative !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    text-align: left !important;
}
body.theme-vanalink .new-chat-item *,
body.theme-vanalink .history-toggle *,
body.theme-vanalink .schedule-toggle *,
body.theme-vanalink .projects-toggle *,
body.theme-vanalink .notes-toggle * {
    color: var(--sidebar-item-text) !important;
}
body.theme-vanalink .new-chat-item:hover,
body.theme-vanalink .new-chat-item.active,
body.theme-vanalink .history-toggle:hover,
body.theme-vanalink .schedule-toggle:hover,
body.theme-vanalink .projects-toggle:hover,
body.theme-vanalink .notes-toggle:hover {
    background: var(--sidebar-item-hover-bg) !important;
    border-color: var(--sidebar-item-hover-border) !important;
    box-shadow: var(--sidebar-item-hover-shadow) !important;
}

/* Indent child panels when accordion is open */
body.theme-vanalink .history-list,
body.theme-vanalink .schedule-timeline,
body.theme-vanalink .projects-content,
body.theme-vanalink .notes-content {
    padding-left: 15px !important;
    padding-right: 4px !important;
    box-sizing: border-box !important;
}

/* Glossy blue sphere indicator at the right of sidebar items */
body.theme-vanalink .new-chat-item::after,
body.theme-vanalink .history-toggle::after,
body.theme-vanalink .schedule-toggle::after,
body.theme-vanalink .projects-toggle::after,
body.theme-vanalink .notes-toggle::after {
    content: "" !important;
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 10px !important;
    height: 10px !important;
    border-radius: 50% !important;
    background: var(--sidebar-orb-bg) !important;
    box-shadow: var(--sidebar-orb-shadow) !important;
    transition: all 0.2s ease !important;
}
body.theme-vanalink .new-chat-item:hover::after,
body.theme-vanalink .new-chat-item.active::after,
body.theme-vanalink .history-toggle:hover::after,
body.theme-vanalink .schedule-toggle:hover::after,
body.theme-vanalink .projects-toggle:hover::after,
body.theme-vanalink .notes-toggle:hover::after {
    background: var(--sidebar-orb-hover-bg) !important;
    box-shadow: var(--sidebar-orb-hover-shadow) !important;
}

/* Collapse state overrides */
body.theme-vanalink .sidebar.collapsed .new-chat-item::after,
body.theme-vanalink .sidebar.collapsed .history-toggle::after,
body.theme-vanalink .sidebar.collapsed .schedule-toggle::after,
body.theme-vanalink .sidebar.collapsed .projects-toggle::after,
body.theme-vanalink .sidebar.collapsed .notes-toggle::after {
    display: none !important;
}
body.theme-vanalink .sidebar.collapsed .new-chat-item,
body.theme-vanalink .sidebar.collapsed .history-toggle,
body.theme-vanalink .sidebar.collapsed .schedule-toggle,
body.theme-vanalink .sidebar.collapsed .projects-toggle,
body.theme-vanalink .sidebar.collapsed .notes-toggle {
    padding: 8px !important;
    justify-content: center !important;
}

/* Sidebar search box overrides */
body.theme-vanalink .sidebar-search input {
    background-color: var(--sidebar-search-bg) !important;
    border: var(--sidebar-search-border) !important;
    border-radius: var(--sidebar-search-radius) !important;
    color: var(--sidebar-search-text) !important;
    padding: 6px 12px 6px 32px !important;
}
body.theme-vanalink .sidebar-search input::placeholder {
    color: var(--sidebar-search-placeholder) !important;
}
body.theme-vanalink .sidebar-search input:focus {
    background-color: var(--sidebar-search-bg-focus) !important;
    border-color: var(--sidebar-search-border-focus) !important;
    box-shadow: var(--sidebar-search-shadow) !important;
}
body.theme-vanalink .sidebar-search .search-icon {
    color: var(--sidebar-search-text) !important;
}

/* Outer layout panel cards styling */
body.theme-vanalink .welcome-box,
body.theme-vanalink .settings-box,
body.theme-vanalink .modal-content,
body.theme-vanalink .note-editor,
body.theme-vanalink .file-browser-panel,
body.theme-vanalink .settings-drawer,
body.theme-vanalink .system-alert-toast {
    background-color: var(--panel-bg) !important;
    border: var(--panel-border) !important;
    border-radius: var(--panel-radius) !important;
    box-shadow: var(--panel-shadow) !important;
    color: var(--panel-text) !important;
}

/* Panel header (HOLD TO SPEAK / STOP SPK bar): transparent, flat */
body.theme-vanalink .panel-header {
    background: transparent !important;
    color: var(--panel-header-text) !important;
    display: flex !important;
}
/* Modal header: dark with rounded top corners */
body.theme-vanalink .modal-header {
    background: var(--panel-header-bg) !important;
    color: var(--panel-header-text) !important;
    border-bottom: 2px solid var(--panel-header-bg) !important;
    border-top-left-radius: 18px !important;
    border-top-right-radius: 18px !important;
    padding: 10px 20px !important;
}
body.theme-vanalink .panel-header h2,
body.theme-vanalink .modal-header h3,
body.theme-vanalink .modal-title,
body.theme-vanalink .panel-header-btn {
    color: var(--panel-header-text) !important;
    font-weight: bold !important;
    letter-spacing: 0.05em !important;
}

/* Panel footer: dark with rounded bottom corners */
body.theme-vanalink .panel-footer {
    background: var(--panel-footer-bg) !important;
    color: var(--panel-footer-text) !important;
    border-top: 2px solid var(--panel-footer-bg) !important;
    padding: 8px 16px !important;
    border-radius: 18px !important;
}
body.theme-vanalink .panel-footer * {
    color: var(--panel-footer-text) !important;
}

/* Chat Input Panel Background and Structure */
body.theme-vanalink .input-panel-wrapper,
body.theme-vanalink .input-panel {
    background-color: var(--panel-bg) !important;
    padding-top: 2px !important;
    border-top: var(--panel-border) !important;
    color: var(--panel-text) !important;
}
body.theme-vanalink .input-panel textarea {
    background-color: var(--input-bg) !important;
    border: var(--input-border) !important;
    border-radius: var(--input-radius) !important;
    color: var(--input-text) !important;
    padding: 10px 16px !important;
}
body.theme-vanalink .input-panel textarea:focus {
    background-color: var(--input-bg-focus) !important;
    border-color: var(--input-border-focus) !important;
    box-shadow: var(--input-shadow) !important;
    outline: none !important;
}

/* Input elements inside settings / modal / browser */
body.theme-vanalink input[type="text"],
body.theme-vanalink input[type="password"],
body.theme-vanalink input[type="number"],
body.theme-vanalink input[type="url"],
body.theme-vanalink input[type="email"],
body.theme-vanalink textarea,
body.theme-vanalink select,
body.theme-vanalink .preset-dropdown {
    background-color: var(--input-bg) !important;
    border: var(--input-border) !important;
    border-radius: var(--input-radius) !important;
    color: var(--input-text) !important;
    padding: 6px 16px !important;
}
body.theme-vanalink textarea {
    /* Textareas need a bit more breathing room and a readable resize handle */
    padding: 10px 16px !important;
    resize: vertical;
}
body.theme-vanalink textarea::placeholder,
body.theme-vanalink input::placeholder {
    color: rgba(28, 39, 51, 0.45) !important;
}
body.theme-vanalink input:focus,
body.theme-vanalink textarea:focus,
body.theme-vanalink select:focus,
body.theme-vanalink .preset-dropdown:focus {
    background-color: var(--input-bg-focus) !important;
    border-color: var(--input-border-focus) !important;
    box-shadow: var(--input-shadow) !important;
}
body.theme-vanalink select option {
    background-color: var(--panel-bg) !important;
    color: var(--panel-text) !important;
}

/* Settings drawer internals */
body.theme-vanalink .settings-drawer h3,
body.theme-vanalink .settings-drawer label,
body.theme-vanalink .settings-drawer span:not(.tb-btn-label):not(.ui-icon),
body.theme-vanalink .settings-drawer p {
    color: var(--panel-text) !important;
}
body.theme-vanalink .drawer-tabs {
    background-color: var(--panel-footer-bg) !important;
    border-right: 2px solid var(--panel-footer-bg) !important;
}
body.theme-vanalink .drawer-tabs .tab-btn {
    color: var(--drawer-tab-text) !important;
    border-left-width: var(--drawer-tab-border-left-width) !important;
}
body.theme-vanalink .drawer-tabs .tab-btn:hover {
    color: var(--drawer-tab-text-active) !important;
    background-color: var(--drawer-tab-hover-bg) !important;
}
body.theme-vanalink .drawer-tabs .tab-btn.active {
    color: var(--drawer-tab-text-active) !important;
    background-color: var(--accent-primary) !important;
    border-left-color: var(--accent-secondary) !important;
}
body.theme-vanalink .drawer-content {
    background-color: transparent !important;
}
body.theme-vanalink .drawer-content input[type="text"],
body.theme-vanalink .drawer-content input[type="password"],
body.theme-vanalink .drawer-content input[type="number"],
body.theme-vanalink .drawer-content input[type="url"],
body.theme-vanalink .drawer-content input[type="email"],
body.theme-vanalink .drawer-content textarea,
body.theme-vanalink .drawer-content select,
body.theme-vanalink .drawer-content .preset-dropdown,
body.theme-vanalink .drawer-content select option,
body.theme-vanalink .mcp-config-editor {
    color: var(--panel-text) !important;
}

/* Specific styling for the MCP config editor textarea */
body.theme-vanalink .mcp-config-editor {
    background-color: var(--input-bg) !important;
    border: var(--input-border) !important;
    border-radius: var(--input-radius) !important;
    padding: 12px !important;
}
body.theme-vanalink .mcp-config-editor:focus {
    background-color: var(--input-bg-focus) !important;
    border-color: var(--input-border-focus) !important;
    box-shadow: var(--input-shadow) !important;
}

/* Theming range slider inputs (like Temperature) */
body.theme-vanalink input[type="range"] {
    background: #7d8b9c !important;
    height: 6px !important;
    border-radius: 9999px !important;
}
body.theme-vanalink input[type="range"]::-webkit-slider-thumb {
    background: var(--btn-ok-bg) !important;
    border: var(--btn-ok-border) !important;
}
body.theme-vanalink input[type="range"]::-moz-range-thumb {
    background: var(--btn-ok-bg) !important;
    border: var(--btn-ok-border) !important;
}

/* Modal and layout form labels */
body.theme-vanalink .welcome-box *,
body.theme-vanalink .settings-box *,
body.theme-vanalink .modal-content * {
    color: var(--panel-text);
}
body.theme-vanalink .welcome-box a,
body.theme-vanalink .modal-content a {
    color: var(--accent-primary) !important;
    text-decoration: underline !important;
}

/* ==========================================================================
   Unified Button System: PlayOnline Blue Gradient & Retro Pill Look
   ========================================================================== */
body.theme-vanalink .btn,
body.theme-vanalink .action-btn,
body.theme-vanalink .set-default-btn,
body.theme-vanalink .settings-tab-btn,
body.theme-vanalink .nav-btn,
body.theme-vanalink .ptt-btn,
body.theme-vanalink .send-btn,
body.theme-vanalink .emoji-trigger-btn,
body.theme-vanalink .titlebar .set-default-btn,
body.theme-vanalink .titlebar .file-browser-btn,
body.theme-vanalink .titlebar .debug-btn,
body.theme-vanalink .titlebar .settings-btn,
body.theme-vanalink .titlebar .status-btn,
body.theme-vanalink #sidebar-toggle-btn,
body.theme-vanalink .new-chat-item,
body.theme-vanalink .history-toggle,
body.theme-vanalink .schedule-toggle,
body.theme-vanalink .projects-toggle,
body.theme-vanalink .notes-toggle {
    background: var(--btn-gradient) !important;
    color: var(--btn-color) !important;
    border: var(--btn-border) !important;
    border-radius: var(--btn-radius) !important;
    box-shadow: var(--btn-shadow) !important;
    text-shadow: var(--btn-text-shadow) !important;
    transition: all 0.2s ease !important;
}

/* Specific sizing overrides */
body.theme-vanalink .ptt-btn {
    padding: 4px 14px !important;
    font-size: 9px !important;
}
body.theme-vanalink .send-btn {
    padding: 10px 18px !important;
    font-size: 11px !important;
}
body.theme-vanalink .emoji-trigger-btn {
    display: flex !important;
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
}

/* Unified Hover State */
body.theme-vanalink .btn:hover,
body.theme-vanalink .action-btn:hover,
body.theme-vanalink .ptt-btn:hover,
body.theme-vanalink .send-btn:hover,
body.theme-vanalink .emoji-trigger-btn:hover,
body.theme-vanalink .titlebar .set-default-btn:hover,
body.theme-vanalink .titlebar .file-browser-btn:hover,
body.theme-vanalink .titlebar .debug-btn:hover,
body.theme-vanalink .titlebar .settings-btn:hover,
body.theme-vanalink .titlebar .status-btn:hover,
body.theme-vanalink #sidebar-toggle-btn:hover,
body.theme-vanalink .new-chat-item:hover,
body.theme-vanalink .history-toggle:hover,
body.theme-vanalink .schedule-toggle:hover,
body.theme-vanalink .projects-toggle:hover,
body.theme-vanalink .notes-toggle:hover {
    background: var(--btn-hover-bg) !important;
    border-color: var(--btn-hover-border) !important;
    box-shadow: var(--btn-hover-shadow) !important;
}

/* Cancel/Close buttons: Neutral Grey Gradient */
body.theme-vanalink .btn-cancel,
body.theme-vanalink .btn.cancel {
    background: var(--btn-cancel-bg) !important;
    border-color: var(--btn-cancel-border) !important;
}
body.theme-vanalink .btn-cancel:hover,
body.theme-vanalink .btn.cancel:hover {
    background: var(--btn-cancel-hover-bg) !important;
    border-color: var(--btn-cancel-hover-border) !important;
}

/* Chat bubble styling */
body.theme-vanalink .chat-area,
body.theme-vanalink .feed-container {
    background-color: transparent !important;
}
body.theme-vanalink .message-bubble {
    border-radius: var(--bubble-radius) !important;
    box-shadow: var(--bubble-shadow) !important;
}
body.theme-vanalink .message.user .message-bubble {
    background: var(--user-bubble-gradient) !important;
}
body.theme-vanalink .message.assistant .message-bubble {
    background: var(--assistant-bubble-bg) !important;
}

/* Titlebar: white text/buttons over the radial gradient */
body.theme-vanalink .titlebar .app-title,
body.theme-vanalink .titlebar .tb-btn-label,
body.theme-vanalink #sidebar-toggle-btn {
    color: var(--text-bright) !important;
    text-shadow: var(--text-shadow-dark) !important;
}

/* Status buttons */
body.theme-vanalink .titlebar .status-btn {
    background: var(--titlebar-btn-bg) !important;
    border: var(--titlebar-btn-border-width) solid var(--titlebar-btn-border-color, var(--border-faint)) !important;
    color: var(--text-bright) !important;
    text-shadow: var(--text-shadow-dark) !important;
    border-radius: var(--titlebar-btn-radius) !important;
    transition: all 0.2s ease !important;
}
body.theme-vanalink .titlebar .status-btn .status-dot {
    background-color: var(--indicator-offline) !important;
    box-shadow: 0 0 5px var(--indicator-offline) !important;
}
body.theme-vanalink .titlebar .status-btn.online .status-dot {
    background-color: var(--indicator-online) !important;
    box-shadow: 0 0 5px var(--indicator-online) !important;
}
body.theme-vanalink .titlebar .status-btn.offline .status-dot {
    background-color: var(--indicator-offline) !important;
    box-shadow: 0 0 5px var(--indicator-offline) !important;
}
body.theme-vanalink .titlebar .status-btn.dormant .status-dot {
    background-color: var(--indicator-dormant) !important;
    box-shadow: 0 0 5px var(--indicator-dormant) !important;
}
body.theme-vanalink .titlebar .status-btn .status-icon {
    color: inherit !important;
}
body.theme-vanalink .titlebar .status-btn.online {
    color: var(--indicator-online) !important;
    border-color: var(--indicator-online-dim) !important;
}
body.theme-vanalink .titlebar .status-btn.offline {
    color: var(--indicator-offline) !important;
    border-color: var(--indicator-offline-dim) !important;
}
body.theme-vanalink .titlebar .status-btn.dormant {
    color: var(--indicator-dormant) !important;
    border-color: var(--indicator-dormant-dim) !important;
}

/* Themed icon colours */
body.theme-vanalink .titlebar .file-browser-btn .ui-icon {
    color: var(--icon-files) !important;
}
body.theme-vanalink .titlebar .debug-btn .ui-icon {
    color: var(--icon-debug) !important;
}
body.theme-vanalink .titlebar .settings-btn .ui-icon {
    color: var(--icon-settings) !important;
}

/* Sidebar labels */
body.theme-vanalink .sidebar-header,
body.theme-vanalink .sidebar-title,
body.theme-vanalink .chat-group-title,
body.theme-vanalink .sidebar-item-name {
    color: var(--sidebar-label-color) !important;
    text-shadow: var(--sidebar-label-shadow-global) !important;
}

/* Debug console: solid dark panel */
body.theme-vanalink .debug-console {
    background-color: var(--debug-console-bg) !important;
    border-left: 2px solid var(--panel-footer-bg) !important;
    backdrop-filter: none !important;
}
body.theme-vanalink .debug-console * {
    color: var(--debug-console-text) !important;
}
body.theme-vanalink .debug-console ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* File browser sidebar */
body.theme-vanalink .file-browser-sidebar {
    background-color: var(--debug-console-bg) !important;
    border-right: 2px solid var(--panel-footer-bg) !important;
}
body.theme-vanalink .file-browser-sidebar * {
    color: var(--debug-console-text) !important;
}

/* Scrollbars */
body.theme-vanalink ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb) !important;
    border-radius: 9999px !important;
}
body.theme-vanalink ::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover) !important;
}

/* ──────────────────────────────────────────────────────────────────────────
   Vana-Link Readability & Visual Polish Overrides
   ────────────────────────────────────────────────────────────────────────── */

/* 1. Projects Sidebar Section */
body.theme-vanalink .projects-item-label,
body.theme-vanalink .projects-conv-item-label,
body.theme-vanalink .projects-conv-item {
    color: var(--sidebar-label-text) !important;
    text-shadow: var(--sidebar-label-shadow) !important;
}
body.theme-vanalink .projects-conv-item.new-chat {
    color: var(--accent-secondary) !important;
    text-shadow: var(--sidebar-label-shadow) !important;
}
body.theme-vanalink .projects-item-icon {
    color: var(--icon-debug) !important;
}
body.theme-vanalink .projects-item-desc {
    color: var(--text-muted) !important;
}
body.theme-vanalink .projects-new-btn {
    background-color: var(--accent-primary-dim) !important;
    color: var(--sidebar-label-text) !important;
    border-color: var(--accent-secondary) !important;
}
body.theme-vanalink .projects-new-btn:hover {
    background-color: var(--accent-primary) !important;
    color: var(--btn-ok-color) !important;
}
body.theme-vanalink .projects-item-row:hover,
body.theme-vanalink .projects-conv-item:hover {
    background-color: var(--overlay-light) !important;
}
body.theme-vanalink .projects-item.expanded {
    background-color: var(--accent-primary-dim) !important;
    border-left-color: var(--accent-secondary) !important;
}

/* 2. Notes Sidebar Section */
body.theme-vanalink .notes-item-title {
    color: var(--sidebar-label-text) !important;
    text-shadow: var(--sidebar-label-shadow) !important;
}
body.theme-vanalink .notes-item-date {
    color: var(--sidebar-label-text) !important;
}
body.theme-vanalink .notes-item.empty {
    color: var(--text-muted) !important;
}
body.theme-vanalink .notes-item:hover {
    background-color: var(--overlay-light) !important;
}
body.theme-vanalink .notes-item.active {
    background-color: var(--accent-primary-dim) !important;
    border-left-color: var(--accent-secondary) !important;
}
body.theme-vanalink .notes-new-btn {
    background-color: var(--accent-primary-dim) !important;
    color: var(--sidebar-label-text) !important;
    border-color: var(--accent-secondary) !important;
}
body.theme-vanalink .notes-new-btn:hover {
    background-color: var(--accent-primary) !important;
    color: var(--btn-ok-color) !important;
}

/* 3. Schedule Sidebar Section */
body.theme-vanalink .schedule-group-header {
    color: var(--icon-debug) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}
body.theme-vanalink .schedule-card-title {
    color: var(--sidebar-label-text) !important;
    text-shadow: var(--sidebar-label-shadow) !important;
}
body.theme-vanalink .schedule-card-time {
    color: var(--text-muted) !important;
}
body.theme-vanalink .schedule-card {
    background: var(--schedule-card-bg) !important;
    border-color: var(--schedule-card-border) !important;
}
body.theme-vanalink .schedule-card:hover {
    background: var(--schedule-card-hover-bg) !important;
    border-color: var(--accent-secondary) !important;
}
body.theme-vanalink .schedule-filter-btn,
body.theme-vanalink .schedule-add-btn {
    border-color: var(--schedule-filter-border) !important;
    color: var(--sidebar-label-text) !important;
}
body.theme-vanalink .schedule-filter-btn.active,
body.theme-vanalink .schedule-filter-btn:hover {
    background-color: var(--schedule-filter-active-bg) !important;
    border-color: var(--accent-secondary) !important;
    color: var(--btn-ok-color) !important;
}
body.theme-vanalink .schedule-add-btn:hover {
    border-color: var(--icon-debug) !important;
    color: var(--icon-debug) !important;
    box-shadow: 0 0 6px var(--glow-blue) !important;
}
body.theme-vanalink .schedule-card-tag {
    color: var(--btn-ok-color) !important;
    background-color: var(--schedule-card-tag-bg) !important;
    border: var(--schedule-card-tag-border) !important;
}
body.theme-vanalink .schedule-item.empty {
    color: var(--sidebar-label-text) !important;
    text-shadow: var(--sidebar-label-shadow) !important;
}

/* Sidebar search: remove bottom separator line (gradient BG makes it redundant) */
body.theme-vanalink .sidebar-search {
    border-bottom: none !important;
}

body.theme-vanalink .message-header {
    color: var(--sidebar-label-text) !important;
    text-shadow: var(--sidebar-label-shadow) !important;
}
body.theme-vanalink .message.user .message-header {
    color: var(--icon-debug) !important;
}
body.theme-vanalink .control-btn-small {
    border: var(--control-btn-border) !important;
    color: var(--sidebar-label-text) !important;
    background-color: var(--control-btn-bg) !important;
}
body.theme-vanalink .control-btn-small:hover {
    color: #ffffff !important;
    border-color: var(--control-btn-hover-border) !important;
    background-color: var(--control-btn-hover-bg) !important;
}
body.theme-vanalink .message-fork-navigator {
    background-color: var(--fork-nav-bg) !important;
    border-color: var(--fork-nav-border) !important;
    color: var(--text-muted) !important;
}
body.theme-vanalink .fork-arrow {
    color: var(--text-muted) !important;
}
body.theme-vanalink .fork-arrow:hover {
    color: var(--btn-ok-color) !important;
}
body.theme-vanalink .repeat-tts-btn {
    color: var(--text-muted) !important;
}
body.theme-vanalink .repeat-tts-btn:hover {
    color: var(--btn-ok-color) !important;
}
body.theme-vanalink .edit-message-textarea {
    background-color: var(--input-bg) !important;
    color: var(--input-text) !important;
    border: var(--input-border) !important;
}

/* 5. Tool Permissions Box */
body.theme-vanalink .tool-perm-box {
    background-color: var(--panel-bg) !important;
    border: var(--panel-border) !important;
    color: var(--panel-text) !important;
}
body.theme-vanalink .tool-perm-box * {
    color: var(--panel-text);
}
body.theme-vanalink .tool-perm-title,
body.theme-vanalink .tool-perm-icon {
    color: var(--accent-primary) !important;
}
body.theme-vanalink .tool-perm-purpose,
body.theme-vanalink .tool-perm-func code,
body.theme-vanalink .tool-perm-args {
    background-color: var(--bg-darker) !important;
    color: var(--btn-ok-color) !important;
    border-color: var(--panel-footer-bg) !important;
}
body.theme-vanalink .tool-perm-purpose *,
body.theme-vanalink .tool-perm-func code *,
body.theme-vanalink .tool-perm-args * {
    color: var(--btn-ok-color) !important;
}

/* 6. Debug Console Log Entries */
body.theme-vanalink .log-entry {
    background-color: var(--log-entry-bg) !important;
    border: var(--log-entry-border) !important;
    color: var(--debug-console-text) !important;
}
body.theme-vanalink .log-entry.outbound {
    border-color: var(--log-entry-outbound-border) !important;
    color: var(--icon-debug) !important;
    background-color: var(--log-entry-outbound-bg) !important;
}
body.theme-vanalink .log-entry.inbound {
    border-color: var(--log-entry-inbound-border) !important;
    color: var(--inbound-green) !important;
    background-color: var(--log-entry-inbound-bg) !important;
}
body.theme-vanalink .log-entry.system {
    border-color: var(--log-entry-system-border) !important;
    color: var(--text-muted) !important;
    background-color: var(--log-entry-system-bg) !important;
}

/* 7. History List Item Overrides */
body.theme-vanalink .history-item:not(.new-chat-item) {
    color: var(--sidebar-label-text) !important;
    text-shadow: var(--sidebar-label-shadow) !important;
    background-color: transparent !important;
    border: none !important;
    border-left: 2px solid transparent !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
    padding: 8px 16px !important;
    box-shadow: none !important;
}
body.theme-vanalink .history-item:not(.new-chat-item) * {
    color: var(--sidebar-label-text) !important;
}
body.theme-vanalink .history-item:not(.new-chat-item):hover {
    background-color: var(--overlay-light) !important;
}
body.theme-vanalink .history-item:not(.new-chat-item).active {
    background-color: var(--accent-primary-dim) !important;
    border-left-color: var(--accent-secondary) !important;
}
body.theme-vanalink .history-item:not(.new-chat-item)::after {
    display: none !important;
}

/* Settings drawer header & footer: override --bg-darker with the themed medium blue */
body.theme-vanalink .drawer-header {
    background-color: var(--panel-header-bg) !important;
    border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}
body.theme-vanalink .drawer-header h2 {
    color: var(--sidebar-label-text) !important;
    text-shadow: none !important;
}
body.theme-vanalink .drawer-footer {
    background-color: var(--panel-footer-bg) !important;
    border-top-color: rgba(255, 255, 255, 0.1) !important;
}

/* File Browser Dropdown */
body.theme-vanalink .fb-dropdown {
    background-color: var(--panel-bg) !important;
}

/* 9. Notes Editor */
body.theme-vanalink .note-editor-overlay {
    background-color: var(--note-overlay-bg) !important;
}
body.theme-vanalink .note-editor-overlay * {
    color: var(--note-editor-text) !important;
}
body.theme-vanalink .note-textarea {
    background-color: var(--note-editor-bg) !important;
    color: var(--note-editor-text) !important;
}
body.theme-vanalink .note-textarea::placeholder {
    color: var(--placeholder-light) !important;
}
body.theme-vanalink .note-preview-pane {
    background-color: var(--note-editor-bg) !important;
    color: var(--note-editor-text) !important;
}
body.theme-vanalink .note-editor-topbar {
    background-color: var(--note-toolbar-bg) !important;
    border-color: var(--note-toolbar-border) !important;
}
body.theme-vanalink .note-editor-title-input {
    color: var(--icon-debug) !important;
}
body.theme-vanalink .note-toolbar {
    background-color: var(--note-toolbar-bg) !important;
    border-color: var(--note-toolbar-border) !important;
}
body.theme-vanalink .note-tool-btn {
    color: var(--note-tool-btn-color) !important;
}
body.theme-vanalink .note-tool-btn:hover {
    color: var(--btn-ok-color) !important;
    background-color: var(--note-tool-btn-hover-bg) !important;
    border-color: var(--note-tool-btn-hover-border) !important;
}
body.theme-vanalink .note-tool-sep {
    background-color: var(--note-tool-sep-bg) !important;
}
body.theme-vanalink .note-scope-chip {
    background-color: var(--note-scope-chip-bg) !important;
    border-color: var(--note-scope-chip-border) !important;
    color: var(--text-muted) !important;
}
body.theme-vanalink .note-generating-box {
    background-color: var(--note-generating-box-bg) !important;
}
body.theme-vanalink .note-generating-label {
    color: var(--icon-debug) !important;
}
body.theme-vanalink .note-generating-cancel {
    color: var(--text-muted) !important;
    border-color: var(--note-generating-cancel-border) !important;
}
body.theme-vanalink .note-generating-cancel:hover {
    color: var(--note-danger-hover-color) !important;
    border-color: var(--note-danger-hover-color) !important;
}
body.theme-vanalink .note-action-btn {
    color: var(--text-muted) !important;
    border-color: var(--note-action-btn-border) !important;
}
body.theme-vanalink .note-action-btn:hover {
    color: var(--icon-debug) !important;
    background-color: var(--note-action-btn-hover-bg) !important;
    border-color: var(--note-action-btn-hover-border) !important;
}
body.theme-vanalink .note-action-btn.danger:hover {
    color: var(--note-danger-hover-color) !important;
    border-color: var(--note-danger-hover-color) !important;
}
body.theme-vanalink .note-save-status {
    color: var(--text-muted) !important;
}

/* ── Tools permission tab ─────────────────────────────────────────────────── */
/* .tools-grid-header and #prompt-tools-list both default to var(--bg-darker)
   which is near-black navy in Vana-Link — replace with the light card surface. */
body.theme-vanalink .tools-grid-header {
    background-color: var(--panel-header-bg) !important;
    color: var(--panel-header-text) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}
body.theme-vanalink #prompt-tools-list {
    background-color: var(--panel-bg) !important;
    border-color: var(--border-color) !important;
}
/* Checkboxes: unchecked box must look clearly empty, not filled dark blue.
   Use the input cream (#ffffe8) to match the text fields on this theme. */
body.theme-vanalink .settings-drawer .checkmark,
body.theme-vanalink .drawer-content .checkmark {
    background-color: var(--input-bg) !important;
    border-color: #7d8b9c !important;
}
body.theme-vanalink .settings-drawer .checkbox-container input:checked + .checkmark,
body.theme-vanalink .drawer-content .checkbox-container input:checked + .checkmark {
    background-color: var(--btn-ok-bg) !important;
    border-color: var(--btn-ok-border) !important;
}
body.theme-vanalink .settings-drawer .checkbox-container input:checked + .checkmark::after,
body.theme-vanalink .drawer-content .checkbox-container input:checked + .checkmark::after {
    color: var(--btn-ok-color) !important;
}

/* ==== css/themes/chrono-lcd.css ==== */
/* ==========================================================================
   Chrono LCD (Retro Digital Watch-inspired Theme)
   ========================================================================== */

body.theme-chrono-lcd {
    --font-theme: "VT323", "Courier New", Courier, monospace;
    --font-theme-code: "VT323", "Courier New", Courier, monospace;

    --bg-darker: #0c0d0f; /* Watch outer case (dark steel gray/black) */
    --bg-main: #b8c1a9; /* Greenish-gray LCD glass panel */
    --bg-panel: #a9b29a; /* Slightly darker LCD glass panel for sidebar/settings */
    --bg-hover: #9ca58d; /* Deepened LCD for hovers */
    --border-color: #383e32; /* Liquid crystal boundary line color (dark gray-green) */
    --border-glow: #1a4cd2; /* Blue border line matching signature quartz look */

    --accent-primary: #1a4cd2; /* Signature blue accent */
    --accent-primary-dim: rgba(26, 76, 210, 0.15);
    --accent-secondary: #c99300; /* Alarm gold/yellow label accent */
    --accent-secondary-dim: rgba(201, 147, 0, 0.15);
    --accent-warning: #c99300;
    --accent-warning-dim: rgba(201, 147, 0, 0.15);
    --accent-error: #c9182b; /* Red 'WR' label accent */
    --accent-error-dim: rgba(201, 24, 43, 0.15);

    --text-primary: #171d15; /* Dark liquid crystal text */
    --text-muted: #3d4538; /* Dimmed liquid crystal text */
    --text-bright: #050604; /* Solid active liquid crystal text */

    --arrow-color: #3d4538;
    --arrow-accent-color: #1a4cd2;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23171d15' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a4cd2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23171d15' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    --indicator-online: #1a4cd2; /* Using blue/black lamps to match the monochrome styling */
    --indicator-online-dim: rgba(26, 76, 210, 0.2);
    --indicator-offline: #c9182b;
    --indicator-offline-dim: rgba(201, 24, 43, 0.18);
    --indicator-dormant: #c99300;
    --indicator-dormant-dim: rgba(201, 147, 0, 0.2);

    --user-bubble-bg: rgba(26, 76, 210, 0.08);
    --user-bubble-border: 1px solid rgba(26, 76, 210, 0.3);
    --user-bubble-accent-border: none;
    --user-bubble-color: var(--text-primary);
    --user-bubble-time-color: var(--text-muted);

    --assistant-bubble-bg: rgba(23, 29, 21, 0.04);
    --assistant-bubble-border: 1px solid rgba(56, 62, 50, 0.2);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);
    --assistant-bubble-time-color: var(--text-muted);

    --sidebar-tag-bg: #171d15;
    --sidebar-tag-color: #b8c1a9;

    --close-btn-bg: #a9b29a;
    --close-btn-border: 1px solid #383e32;
    --close-btn-color: #171d15;
    --close-btn-hover-bg: #c9182b;
    --close-btn-hover-border: #c9182b;
    --close-btn-hover-color: #ffffff;

    --btn-ok-bg: #171d15;
    --btn-ok-color: #b8c1a9;
    --btn-ok-border: 1px solid #171d15;
    --btn-ok-hover-bg: #1a4cd2;
    --btn-ok-hover-color: #ffffff;
    --btn-ok-hover-border: 1px solid #1a4cd2;

    --btn-cancel-bg: #a9b29a;
    --btn-cancel-color: #171d15;
    --btn-cancel-border: 1px solid #383e32;
    --btn-cancel-hover-bg: #9ca58d;
    --btn-cancel-hover-color: #050604;
    --btn-cancel-hover-border: 1px solid #383e32;

    /* Checkbox styling */
    --checkmark-bg: #b8c1a9;
    --checkmark-border: #383e32;
    --checkmark-checked-bg: #171d15;
    --checkmark-checked-border: #171d15;

    /* Override layouts for flat LCD style */
    --bg-header: #0c0d0f;
    --bg-sidebar: var(--bg-panel);
    --bg-footer: #0c0d0f;
    --bg-inner: var(--bg-main);
    --ui-opacity: 0.85;

    --header-text: #ffffff;
    --footer-text: #ffffff;
}

/* ── Structural overrides ─────────────────────────────────────────────────── */

body.theme-chrono-lcd,
body.theme-chrono-lcd * {
    border-radius: 0px !important;
}

body.theme-chrono-lcd ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

body.theme-chrono-lcd ::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

body.theme-chrono-lcd ::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border: 2px solid var(--bg-panel);
}

body.theme-chrono-lcd ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Casio F-91W screen accent border overlay */
body.theme-chrono-lcd .app-container {
    border: 3px double var(--border-color);
    margin: 4px;
}
body.theme-chrono-lcd:not(.has-custom-bg) .app-container {
    background-color: var(--bg-darker);
}

body.theme-chrono-lcd .workspace-container {
    border: 2px solid var(--accent-primary) !important;
    position: relative;
}

/* Stylized headings using segmented font with a subtle LCD pixel glow look */
body.theme-chrono-lcd h1,
body.theme-chrono-lcd h2,
body.theme-chrono-lcd h3,
body.theme-chrono-lcd .app-title {
    font-family: "VT323", "Courier New", Courier, monospace !important;
    font-weight: normal;
    text-transform: uppercase;
}

body.theme-chrono-lcd .app-title {
    color: var(--accent-secondary) !important;
    letter-spacing: 0.1em;
}

/* Force VT323 typography to match digital segmented LCD watchface */
body.theme-chrono-lcd .status-lamp,
body.theme-chrono-lcd .ptt-btn,
body.theme-chrono-lcd .action-btn,
body.theme-chrono-lcd .sidebar-header,
body.theme-chrono-lcd .tab-btn {
    font-family: "VT323", "Courier New", Courier, monospace !important;
}

/* Make sure active states glow with the theme's blue/yellow accent */
body.theme-chrono-lcd .tab-btn.active {
    border-bottom: 2px solid var(--accent-primary) !important;
}

/* Custom titlebar styling for watchface bezel */
body.theme-chrono-lcd .titlebar {
    border-bottom: 2px solid var(--border-color);
}

/* ==== css/themes/tactical.css ==== */
/* ==========================================================================
   Tactical Slate Theme  —  Tactical Tech Hub (JetBrains Mono / BlueprintJS)
   ========================================================================== */

body.theme-tactical {
    --font-theme: "JetBrains Mono", "Courier New", Courier, monospace;
    --font-theme-code: "JetBrains Mono", "Courier New", Courier, monospace;

    /* ── Backgrounds ── */
    --bg-darker: #12141a; /* Darker navy/slate for titlebar, sidebar rail, and footers */
    --bg-main: #1a1d24; /* Main canvas background */
    --bg-panel: #222630; /* Sidebar history panel, settings, modal box */
    --bg-hover: #2d323f; /* Hover states on sidebar items, inputs, and buttons */
    --opacity-header: 1;
    --opacity-footer: 1;
    --border-color: #383e4e; /* Steel grid and section dividers */
    --border-glow: #2d7ff9; /* Tactical glowing blue accents */

    /* ── Glowing UI Accents ── */
    --accent-primary: #2d7ff9; /* Tactical blue */
    --accent-primary-dim: rgba(45, 127, 249, 0.15);
    --accent-secondary: #00f0ff; /* Precision cyan */
    --accent-secondary-dim: rgba(0, 240, 255, 0.15);
    --accent-warning: #f59e0b; /* Caution amber */
    --accent-warning-dim: rgba(245, 158, 11, 0.15);
    --accent-error: #ef4444; /* Alert red */
    --accent-error-dim: rgba(239, 68, 68, 0.15);

    /* ── Typography ── */
    --text-primary: #e1e8ed; /* Clean high-contrast steel-white for readability */
    --text-muted: #8a9ba8; /* Secondary labels, timestamps, and muted text */
    --text-bright: #ffffff; /* Active tabs, titles, and highlighted values */

    /* ── SVG Forms ── */
    --arrow-color: #8a9ba8;
    --arrow-accent-color: #2d7ff9;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a9ba8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232d7ff9' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a9ba8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* ── Subsystem Indicators ── */
    --indicator-online: #10b981; /* Blueprint green */
    --indicator-online-dim: rgba(16, 185, 129, 0.18);
    --indicator-offline: #ef4444; /* Blueprint red */
    --indicator-offline-dim: rgba(239, 68, 68, 0.18);
    --indicator-dormant: #f59e0b; /* Blueprint amber */
    --indicator-dormant-dim: rgba(245, 158, 11, 0.18);

    /* ── Chat Bubbles ── */
    --user-bubble-bg: rgba(45, 127, 249, 0.06);
    --user-bubble-border: 1px solid rgba(45, 127, 249, 0.25);
    --user-bubble-accent-border: 2px solid var(--accent-primary);
    --user-bubble-color: #ffffff;

    --assistant-bubble-bg: rgba(138, 155, 168, 0.04);
    --assistant-bubble-border: 1px solid rgba(138, 155, 168, 0.18);
    --assistant-bubble-accent-border: none;
    --assistant-bubble-color: var(--text-primary);

    --sidebar-tag-bg: #2d323f;
    --sidebar-tag-color: #8a9ba8;

    /* ── Buttons ── */
    --btn-ok-bg: #2d7ff9;
    --btn-ok-color: #ffffff;
    --btn-ok-border: #1a62d6;
    --btn-ok-hover-bg: #1a62d6;
    --btn-ok-hover-color: #ffffff;
    --btn-cancel-bg: #222630;
    --btn-cancel-color: #8a9ba8;
    --btn-cancel-border: #383e4e;
    --btn-cancel-hover-bg: #2d323f;
    --btn-cancel-hover-color: #e1e8ed;
}

/* ==== css/themes/crystal-palace.css ==== */
/* ==========================================================================
   Crystal Palace (Big Board Console)
   Named for the NORAD ops-room nickname inside Cheyenne Mountain. Deep
   board-blue void, radar-amber key lights, and phosphor-blue vector glow —
   built to pair with the "War Room (Vector Earth)" background. Successor to
   (and saved-config alias of) the old vcr-eas theme; keeps its blocky
   zero-radius OSD bones.
   ========================================================================== */

body.theme-crystal-palace {
    --font-theme: "Share Tech Mono", "Courier New", Courier, monospace;
    --font-theme-code: "Share Tech Mono", "Courier New", Courier, monospace;

    /* ── Backgrounds — unlit ops room, board-blue depths ── */
    --bg-darker: #000508;
    --bg-main: #020a14;
    --bg-panel: #071523;
    --bg-hover: #0e2438;
    --border-color: #16324a;
    --border-glow: #4fb4ff;

    /* ── Glowing UI Accents — radar amber keys, vector-blue readouts ── */
    --accent-primary: #ffb000; /* radar amber — key lights, primary highlights */
    --accent-primary-dim: rgba(255, 176, 0, 0.15);
    --accent-warning: #ffc400;
    --accent-warning-dim: rgba(255, 196, 0, 0.15);
    --accent-secondary: #4fb4ff; /* big-board vector blue (matches War Room glow) */
    --accent-secondary-dim: rgba(79, 180, 255, 0.15);
    --accent-error: #ff3b3b;
    --accent-error-dim: rgba(255, 59, 59, 0.18);

    /* ── Typography ── */
    --text-primary: #cfe4f5;
    --text-muted: #5c7f9c;
    --text-bright: #ffffff;

    /* ── SVG Forms ── */
    --arrow-color: #5c7f9c;
    --arrow-accent-color: #ffb000;
    --select-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235c7f9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --preset-arrow-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffb000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    --spin-buttons-svg: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235c7f9c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 8 12 3 18 8'%3e%3c/polyline%3e%3cpolyline points='6 16 12 21 18 16'%3e%3c/polyline%3e%3c/svg%3e");

    /* ── Subsystem Connectivity Lamps — status-board green/red/amber, kept
       apart from the amber accent-primary so "dormant" still reads distinct. ── */
    --indicator-online: #35ff6e;
    --indicator-online-dim: rgba(53, 255, 110, 0.2);
    --indicator-offline: #ff3b3b;
    --indicator-offline-dim: rgba(255, 59, 59, 0.2);
    --indicator-dormant: #ffb000;
    --indicator-dormant-dim: rgba(255, 176, 0, 0.2);

    /* ── Chat Bubbles — operator amber vs board blue, hard corners ── */
    --user-bubble-bg: rgba(255, 176, 0, 0.07);
    --user-bubble-border: 1px solid rgba(255, 176, 0, 0.3);
    --user-bubble-accent-border: 1px solid rgba(255, 176, 0, 0.3);
    --user-bubble-color: var(--text-primary);
    --user-bubble-time-color: var(--text-muted);

    --assistant-bubble-bg: rgba(79, 180, 255, 0.05);
    --assistant-bubble-border: 1px solid rgba(79, 180, 255, 0.22);
    --assistant-bubble-accent-border: 1px solid rgba(79, 180, 255, 0.22);
    --assistant-bubble-color: var(--text-primary);
    --assistant-bubble-time-color: var(--text-muted);

    --sidebar-tag-bg: #0e2438;
    --sidebar-tag-color: #4fb4ff;

    /* ── Action Buttons: amber launch key OK, board-blue Cancel ── */
    --btn-ok-bg: #ffb000;
    --btn-ok-color: #000000;
    --btn-ok-border: #cc8c00;
    --btn-ok-hover-bg: #cc8c00;
    --btn-ok-hover-color: #000000;
    --btn-cancel-bg: #0e2438;
    --btn-cancel-color: #cfe4f5;
    --btn-cancel-border: #16324a;
    --btn-cancel-hover-bg: #16324a;
    --btn-cancel-hover-color: #ffffff;
}

/* ── Structural overrides ─────────────────────────────────────────────────── */

/* Sharp / zero-radius rendering — status boards and console bezels have no curves. */
body.theme-crystal-palace,
body.theme-crystal-palace * {
    border-radius: 0px !important;
}
body.theme-crystal-palace ::-webkit-scrollbar-thumb {
    border-radius: 0px !important;
}

/* Titlebar / app title as a DEFCON-level readout: radar amber, wide tracking,
   hard black double-shadow so it stays legible over the vector map the way
   burned-in console annunciators do. */
body.theme-crystal-palace .app-title {
    color: var(--accent-primary) !important;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-shadow:
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000 !important;
}

/* Connectivity lamp blinks like a live channel indicator on the comms rack. */
@keyframes cp-tally-blink {
    0%,
    49% {
        opacity: 1;
    }
    50%,
    100% {
        opacity: 0.35;
    }
}
body.theme-crystal-palace .status-btn.online .status-dot {
    animation: cp-tally-blink 1.6s step-end infinite;
}

/* Push-to-talk button: black/amber hazard stripes while transmitting — the
   "positive control" warning tape on every launch console switch cover. */
body.theme-crystal-palace .ptt-btn.active.pressed {
    background: repeating-linear-gradient(
        135deg,
        #000000 0px,
        #000000 10px,
        var(--accent-warning) 10px,
        var(--accent-warning) 20px
    ) !important;
    color: #000000 !important;
    text-shadow: none !important;
    box-shadow: 0 0 10px var(--accent-primary-dim) !important;
}

/* Send button: flat, blocky console key — no gradients. */
body.theme-crystal-palace .send-btn {
    letter-spacing: 0.05em;
}

/* ==== css/base.css ==== */
/* ==========================================================================
   base.css  —  Reset & base element styles.

   Load order (handled by the <link> tags in dashboard.html / index.html):
     1. fonts.css        — @font-face declarations
     2. tokens.css       — :root design token defaults  (NEW)
     3. themes/*.css     — per-theme variable overrides  (NEW)
     4. base.css         — this file: reset + element defaults
     5. titlebar.css … responsive.css  — component / layout rules

   @font-face declarations live in fonts.css (loaded before this file).
   Design tokens (:root) live in tokens.css (loaded before this file).
   Per-theme variable overrides live in css/themes/*.css (loaded before this file).
   ========================================================================== */

/* ── Reset ───────────────────────────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-mono);
    -webkit-font-smoothing: antialiased;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

/* ==== css/titlebar.css ==== */
/* Frameless Window Custom Titlebar */
.titlebar {
    height: var(--titlebar-height);
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    user-select: none;
    z-index: 1000;
}

.titlebar-drag-region {
    display: flex;
    align-items: center;
    padding-left: 12px;
    height: 100%;
    flex-grow: 1;
    cursor: default;
    /* On platforms that support webview drag-regions, saucer maps dragging automatically, but on Windows, we also have draggable titlebars */
}

.app-icon {
    font-size: 14px;
    color: var(--accent-primary);
    margin-right: 8px;
    filter: drop-shadow(0 0 4px var(--accent-primary));
}

.app-title {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.titlebar-controls-left {
    display: flex;
    align-items: center;
    /* gap here is the spacing BETWEEN the two groups (status lamps | action buttons);
       each group owns its own tight internal gap (.status-indicators / .titlebar-actions = 6px).
       margin-left + .titlebar-prompt-slot margin-right form the prompt→status boundary (also 16px). */
    gap: 16px;
    margin-left: 6px;
    margin-right: 15px; /* match the sidebar toggle's 15px left margin for symmetric edges */
    flex-shrink: 0;
}

/* Action-button group (FILES / DEBUG / SETTINGS) — a peer group to .status-indicators. */
.titlebar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.titlebar-prompt-slot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 12px;
    margin-right: 10px;
}

.preset-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    width: clamp(170px, 28vw, 300px);
    min-width: 150px;
    max-width: 100%;
    min-height: 0;
}

.preset-dropdown {
    background-color: var(--bg-main);
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 24px 2px 8px;
    font-size: 10px;
    outline: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    appearance: none;
    background-image: var(--preset-arrow-svg);
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
}

.preset-dropdown:focus,
.preset-dropdown:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary-dim);
}

.set-default-btn {
    background: var(--titlebar-btn-bg);
    border: var(--titlebar-btn-border-width) solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--titlebar-btn-radius);
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.set-default-btn:hover {
    color: var(--accent-warning);
    border-color: var(--accent-warning);
    box-shadow: 0 0 6px var(--accent-warning-dim);
}

.status-indicators {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.status-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--titlebar-btn-bg);
    border: var(--titlebar-btn-border-width) solid var(--border-color);
    border-radius: var(--titlebar-btn-radius);
    padding: 2px 8px;
    height: 22px;
    box-sizing: border-box;
    font-size: 9px;
    line-height: 1;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

/* FILES / DEBUG / SETTINGS triggers share the status lamps' flex rhythm so the
   whole control row sits on one consistent height/baseline. */
.titlebar-controls-left .file-browser-btn,
.titlebar-controls-left .debug-btn,
.titlebar-controls-left .settings-btn {
    display: inline-flex;
    align-items: center;
    height: 22px;
    box-sizing: border-box;
    line-height: 1;
}

/* Label text inside the trigger buttons; hidden at narrow widths so the
   buttons collapse to icons before the prompt box or status lamps shrink. */
.titlebar-controls-left .tb-btn-label {
    margin-left: 5px;
}

.status-btn .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition:
        background-color 0.2s ease,
        box-shadow 0.2s ease;
}

/* Status variants */
.status-btn.online {
    color: var(--indicator-online);
    border-color: var(--indicator-online-dim);
}
.status-btn.online .status-dot {
    background-color: var(--indicator-online);
    box-shadow: 0 0 5px var(--indicator-online);
}

.status-btn.offline {
    color: var(--indicator-offline);
    border-color: var(--indicator-offline-dim);
}
.status-btn.offline .status-dot {
    background-color: var(--indicator-offline);
    box-shadow: 0 0 5px var(--indicator-offline);
}

.status-btn.dormant {
    color: var(--indicator-dormant);
    border-color: var(--indicator-dormant-dim);
}
.status-btn.dormant .status-dot {
    background-color: var(--indicator-dormant);
    box-shadow: 0 0 5px var(--indicator-dormant);
}

.status-btn:hover {
    background-color: var(--bg-hover);
}

/* --- Monochrome sprite icons in the titlebar --- */
/* The identifying status icon (server/mic/speaker) shows only in the compact vertical/narrow
   rail (see responsive.css), where it replaces the dot; in the full-width bar the dot carries
   status, so the icon stays hidden here. It inherits the button's status colour via currentColor. */
.status-btn .status-icon {
    display: none;
}
/* STT & TTS read as status-coloured icon TOGGLES at every width (not passive dot+label pills), so
   it's obvious they're clickable. SRVR keeps the labeled-pill form — it's a connection status/test,
   not a toggle. (At narrow widths responsive.css already collapses all three to circular icons.) */
#status-stt,
#status-tts {
    width: 22px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
}
#status-stt .status-lbl,
#status-tts .status-lbl,
#status-stt .status-dot,
#status-tts .status-dot {
    display: none;
}
#status-stt .status-icon,
#status-tts .status-icon {
    display: inline-block;
    font-size: 13px;
}
/* Trigger-button icons keep the established per-control accents (themeable, all viewport sizes). */
.titlebar-controls-left .file-browser-btn .ui-icon {
    color: var(--icon-files);
}
.titlebar-controls-left .debug-btn .ui-icon {
    color: var(--icon-debug);
}
.titlebar-controls-left .settings-btn .ui-icon {
    color: var(--icon-settings);
}

.titlebar-window-actions {
    display: flex;
    height: 100%;
}

.win-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 44px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.win-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-bright);
}

.close-btn:hover {
    background-color: var(--accent-error) !important;
    color: var(--text-bright) !important;
}

/* ==== css/layout.css ==== */
/* App Main Container */
.app-container {
    display: flex;
    flex-grow: 1;
    height: calc(100vh - var(--titlebar-height));
    overflow: hidden;
    position: relative; /* Absolute context for responsive drawers */
}

/* Sidebar Styling */
.sidebar {
    width: 255px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--text-muted);
    flex-grow: 1;
    text-align: left;
}

/* Sidebar Collapse Toggle Button */
.sidebar-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    /* Accent at rest so this primary nav control stands out (the rotation + outline carry the
       open/collapsed state; hover still adds the glow). */
    color: var(--accent-primary);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    font-size: 12px;
    flex-shrink: 0;
    /* Centres the 28px button on the collapsed-rail icon axis (x≈30), so the toggle
       lines up vertically with the mini-sidebar icons below it. */
    margin-left: 15px;
}

.sidebar-toggle-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary-dim);
}

.sidebar-toggle-btn.collapsed {
    transform: rotate(90deg);
}

/* Themeable monochrome sprite icons (sidebar). Sized in em so they inherit the host
   span's font-size (incl. the collapsed-rail 16px override) and `color` (currentColor),
   so every theme's accent/muted color tints them with no per-icon rules. */
.ui-icon {
    /* inline-block (not the default inline) so the em size lays out — an inline <svg>
       with no width/height attributes collapses to 0x0 in Chromium/WebView2. */
    display: inline-block;
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.125em; /* optical baseline centering next to text labels */
    flex-shrink: 0;
}

/* History list item icons */
.history-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: inherit;
    margin-right: 10px;
    transition:
        font-size 0.3s ease,
        margin-right 0.3s ease;
    flex-shrink: 0;
}

/* Scrim for the phone overlay drawer — hidden by default; responsive.css (≤550px) reveals
   it while the drawer is open and a tap on it closes the drawer (js/chat/events.js). */
.sidebar-scrim {
    display: none;
}

/* Collapsed Sidebar Rail Layout */
.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-header .icon-btn,
.sidebar.collapsed .sidebar-search input,
.sidebar.collapsed .history-item-label,
.sidebar.collapsed .history-item-tag,
.sidebar.collapsed .history-separator {
    display: none !important;
}

/* Collapsed Rail Search styles */
.sidebar.collapsed .sidebar-search {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.sidebar.collapsed .search-input-wrapper {
    justify-content: center;
    width: auto;
}

.sidebar.collapsed .search-icon {
    position: static; /* Remove absolute overlay */
    font-size: 13px; /* Compact icon size */
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar.collapsed .search-icon:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary-dim);
    background-color: var(--bg-hover);
}

.sidebar.collapsed .history-item {
    justify-content: center;
    padding: 12px 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    margin: 4px 8px;
    /* width:auto (overriding the base width:100%) lets the flex column shrink the item to
       rail-width minus the side margins, so the inset stays symmetric and the icon centres
       on the same axis as the section icons (base width:100% + margin overflowed to the right). */
    width: auto;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sidebar.collapsed .history-item-icon {
    margin-right: 0;
    font-size: 16px;
}

.sidebar.collapsed .history-item.active {
    background-color: var(--bg-hover);
    border-bottom-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary-dim);
}

.sidebar.collapsed .new-chat-item.active {
    border-bottom-color: var(--accent-secondary);
    color: var(--accent-secondary);
    box-shadow: 0 0 10px var(--accent-secondary-dim);
}

/* Smooth expansion animation for text elements */
@keyframes fadeInCompact {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar:not(.collapsed) .sidebar-title,
.sidebar:not(.collapsed) .sidebar-header .icon-btn,
.sidebar:not(.collapsed) .sidebar-search input,
.sidebar:not(.collapsed) .history-item-label,
.sidebar:not(.collapsed) .history-item-tag {
    animation: fadeInCompact 0.25s ease-out forwards;
}

.icon-btn {
    background: none;
    border: 1px solid var(--accent-primary-dim);
    color: var(--accent-primary);
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background-color: var(--accent-primary-dim);
    box-shadow: 0 0 8px var(--accent-primary-dim);
}

.sidebar-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 8px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.sidebar-search input {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px 6px 26px; /* Extra left padding to make room for magnifying glass */
    font-size: 10px;
    border-radius: 3px;
    outline: none;
    transition: all 0.2s ease;
}

.sidebar-search input[type="search"]::-webkit-search-decoration,
.sidebar-search input[type="search"]::-webkit-search-cancel-button,
.sidebar-search input[type="search"]::-webkit-search-results-button,
.sidebar-search input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.sidebar-search input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary-dim);
}

.sidebar-search input::placeholder {
    color: var(--text-muted);
    opacity: 0.9;
}

.search-input-wrapper:focus-within .search-icon {
    color: var(--accent-primary);
    filter: drop-shadow(0 0 2px var(--accent-primary-dim));
}

.history-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Pinned NEW CHAT is a real <button>; strip native chrome so it matches the log rows.
   (The base .history-item rule still supplies the flex layout, font-size and padding.) */
button.history-item {
    width: 100%;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

/* ==========================================================================
   Sidebar accordion shell — shared by the HISTORY, SCHEDULE, PROJECTS and NOTES
   sections. The collapsible header (group flex, toggle, chevron, label, count)
   is identical for all four and lives here ONCE. Each section keeps only its own
   body/list/item styling in its file (schedule below; projects.css; notes.css).
   Collapsed-rail (mini-sidebar) overrides are further down in this file.
   ========================================================================== */
.sidebar-history-group,
.sidebar-schedule-group,
.sidebar-projects-group,
.sidebar-notes-group {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto; /* expanded: grow to share the sidebar height */
    min-height: 0;
}

.sidebar-history-group.collapsed,
.sidebar-schedule-group.collapsed,
.sidebar-projects-group.collapsed,
.sidebar-notes-group.collapsed {
    flex: 0 0 auto; /* folded: only the header height */
}

.sidebar-history-group.collapsed .history-list,
.sidebar-schedule-group.collapsed .schedule-content,
.sidebar-projects-group.collapsed .projects-content,
.sidebar-notes-group.collapsed .notes-content {
    display: none;
}

.history-toggle,
.schedule-toggle,
.projects-toggle,
.notes-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-top: 1px solid var(--border-color); /* single separator between sections */
    color: var(--text-muted);
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    text-align: left;
    cursor: pointer;
    transition:
        color 0.2s ease,
        background-color 0.2s ease;
}

.history-toggle:hover,
.schedule-toggle:hover,
.projects-toggle:hover,
.notes-toggle:hover {
    color: var(--accent-primary);
    background-color: var(--bg-hover);
}

.history-chevron,
.schedule-chevron,
.projects-chevron,
.notes-chevron {
    display: inline-flex;
    align-items: center;
    font-size: 12px; /* sizes the inline SVG chevron (1em) */
    transition: transform 0.2s ease;
    transform: rotate(90deg); /* expanded: chevron points down */
}

.sidebar-history-group.collapsed .history-chevron,
.sidebar-schedule-group.collapsed .schedule-chevron,
.sidebar-projects-group.collapsed .projects-chevron,
.sidebar-notes-group.collapsed .notes-chevron {
    transform: rotate(0deg); /* folded: chevron points right (▸) */
}

.history-toggle-label,
.schedule-toggle-label,
.projects-toggle-label,
.notes-toggle-label {
    flex-grow: 1;
}

.history-count,
.schedule-count,
.projects-count,
.notes-count {
    font-size: 8px;
    padding: 1px 5px;
    background-color: var(--sidebar-tag-bg);
    color: var(--sidebar-tag-color);
    border-radius: 8px;
}

.history-count:empty,
.schedule-count:empty,
.projects-count:empty,
.notes-count:empty {
    display: none;
}

/* Body padding for sections whose content is a generic container. HISTORY is the
   exception — it indents its log rows instead (rule just below). */
.sidebar:not(.collapsed) .sidebar-schedule-group .schedule-content,
.sidebar:not(.collapsed) .sidebar-projects-group .projects-content,
.sidebar:not(.collapsed) .sidebar-notes-group .notes-content {
    padding: 8px 12px;
}

/* Indent the saved-log rows under the HISTORY header (full-width sidebar only). */
.sidebar:not(.collapsed) .sidebar-history-group .history-item {
    padding-left: 24px;
}

/* Narrow icon rail — section launchers. Each accordion header collapses to a single
   centered icon; clicking it expands the sidebar AND opens that section (see the
   expandSidebarIfCollapsed wiring in js/chat/events.js, schedule.js, notes.js,
   projects.js). Accordion content never renders in the rail. */
.section-icon {
    display: none; /* full-width sidebar: the text label carries the meaning */
    font-size: 15px;
    line-height: 1;
}

.sidebar.collapsed .section-icon {
    display: inline-block;
}

.sidebar.collapsed .history-toggle,
.sidebar.collapsed .schedule-toggle,
.sidebar.collapsed .projects-toggle,
.sidebar.collapsed .notes-toggle {
    /* All four toggles are already display:flex; width:100% in their base rules
       (layout.css / projects.css / notes.css); just centre the icon in the rail. */
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .history-chevron,
.sidebar.collapsed .history-toggle-label,
.sidebar.collapsed .history-count,
.sidebar.collapsed .schedule-chevron,
.sidebar.collapsed .schedule-toggle-label,
.sidebar.collapsed .schedule-count,
.sidebar.collapsed .projects-chevron,
.sidebar.collapsed .projects-toggle-label,
.sidebar.collapsed .projects-count,
.sidebar.collapsed .notes-chevron,
.sidebar.collapsed .notes-toggle-label,
.sidebar.collapsed .notes-count {
    display: none;
}

.sidebar.collapsed .history-list,
.sidebar.collapsed .schedule-content,
.sidebar.collapsed .projects-content,
.sidebar.collapsed .notes-content {
    display: none !important;
}

.sidebar.collapsed .sidebar-history-group,
.sidebar.collapsed .sidebar-schedule-group,
.sidebar.collapsed .sidebar-projects-group,
.sidebar.collapsed .sidebar-notes-group {
    flex: 0 0 auto;
}

/* Ambient voice visualizer pinned to the bottom of the sidebar (#sidebar-viz).
   The disc itself is animated inline by voice-visualizer.js (transform/glow). */
.sidebar-viz {
    flex-shrink: 0;
    margin-top: auto; /* stay pinned to the sidebar bottom even when HISTORY is collapsed */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 97px;
    border-top: 1px solid var(--border-color);
}

.sidebar-viz-disc {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        color-mix(in srgb, var(--accent-primary) 8%, var(--bg-sidebar)) 30%,
        var(--bg-sidebar) 100%
    );
    border: 2px dashed var(--accent-primary);
    box-shadow: 0 0 10px color-mix(in srgb, var(--accent-primary) 12%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
}

.sidebar-viz-disc-center {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    box-shadow: inset 0 0 4px var(--bg-sidebar);
}

/* Collapsed rail: hide the visualizer so it doesn't clip the narrow column. */
.sidebar.collapsed .sidebar-viz {
    display: none;
}

/* Scrollbars */
/* Standard Scrollbars for all modern browsers */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.history-item {
    padding: 8px 16px;
    font-size: 10px;
    cursor: pointer;
    border-left: 2px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.history-item.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.history-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-bright);
}

.history-item.active {
    background-color: var(--bg-panel);
    border-left-color: var(--accent-primary);
    color: var(--accent-primary);
    font-weight: bold;
}

/* A turn is generating in this conversation (which may not be the one on screen). A pulsing accent
   dot at the end of the row signals it — see background_chat_switching.md §3.3 ("generating…"). */
.history-item.generating {
    border-left-color: var(--accent-primary);
}
.history-item.generating::after {
    content: "";
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: history-gen-pulse 1.1s ease-in-out infinite;
}
@keyframes history-gen-pulse {
    0%,
    100% {
        opacity: 0.35;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* In-progress placeholder shown when returning to a conversation whose turn is still generating. */
.generating-placeholder {
    color: var(--text-muted);
    font-style: italic;
    animation: gen-placeholder-pulse 1.4s ease-in-out infinite;
}
@keyframes gen-placeholder-pulse {
    0%,
    100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

.history-item-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
    flex-grow: 1;
}

.history-item-tag {
    font-size: 8px;
    padding: 1px 4px;
    background-color: var(--sidebar-tag-bg);
    color: var(--sidebar-tag-color);
    border-radius: 2px;
}

/* Delete control: hidden until the row is hovered; turns red on hover. */
.history-item-delete {
    font-size: 11px;
    line-height: 1;
    color: var(--text-muted);
    padding: 2px 4px;
    margin-left: 4px;
    border-radius: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition:
        opacity 0.15s ease,
        color 0.15s ease,
        background-color 0.15s ease;
}

.history-item:hover .history-item-delete {
    opacity: 0.6;
}

.history-item-delete:hover {
    opacity: 1;
    color: var(--accent-error);
    background-color: var(--bg-hover);
}

/* No room for the control in the collapsed rail. */
.sidebar.collapsed .history-item-delete {
    display: none !important;
}

.history-separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color) 20%, var(--border-color) 80%, transparent);
    margin: 8px 12px;
    opacity: 0.5;
}

.history-item.new-chat-item {
    color: var(--accent-secondary);
    font-weight: bold;
}

.history-item.new-chat-item.active {
    border-left-color: var(--accent-secondary);
    color: var(--accent-secondary);
    background-color: var(--bg-hover);
    box-shadow: inset 4px 0 0 var(--accent-secondary-dim);
}

/* ==========================================================================
   SCHEDULE — accordion header shell is shared (see "Sidebar accordion shell"
   above); only the schedule body (filters + timeline) is section-specific.
   ========================================================================== */
/* Schedule Content, Filters and Timeline */
.schedule-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.schedule-filters {
    display: flex;
    gap: 4px;
    padding: 0 4px;
    align-items: center;
    flex-shrink: 0;
}

.schedule-filter-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 8px;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 2px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.schedule-filter-btn.active,
.schedule-filter-btn:hover {
    background: var(--accent-primary-dim);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary-dim);
}

.schedule-add-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s ease;
}

.schedule-add-btn:hover {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
    box-shadow: 0 0 6px var(--accent-secondary-dim);
    transform: scale(1.1);
}

.schedule-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex-grow: 1;
}

.schedule-group-header {
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--accent-secondary);
    opacity: 0.8;
    padding: 10px 4px 4px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 4px;
    text-transform: uppercase;
}

.schedule-card {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--accent-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 10px;
}

.event-card {
    border-left-color: var(--accent-secondary);
}

.schedule-card:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary-dim);
}

.event-card:hover {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary-dim);
}

.schedule-card-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.schedule-card-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex-grow: 1;
}

.schedule-card-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.schedule-card-time {
    font-size: 9px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.3;
}

.schedule-card-tag {
    font-size: 7px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.06);
    padding: 0px 3px;
    border-radius: 2px;
    color: var(--accent-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.schedule-item.empty {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 16px 0;
}

/* ==========================================================================
   Schedule Modal Specific styles
   ========================================================================== */
.schedule-drawer {
    max-width: 480px;
    max-height: 600px;
    height: auto;
}

.schedule-body {
    padding: 20px;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    display: flex;
}

.schedule-footer {
    justify-content: flex-end;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.checkbox-group label {
    cursor: pointer;
    margin-bottom: 0;
    user-select: none;
}

/* Ensure datetime-local and date form elements are themed correctly */
.form-group input[type="datetime-local"],
.form-group input[type="date"] {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 11px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input[type="datetime-local"]:focus,
.form-group input[type="date"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary-dim);
    background-color: var(--bg-hover);
}

/* ==== css/chat.css ==== */
/* Chat Area Styling */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    overflow: hidden;
    position: relative;
}

.feed-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.messages-feed {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Welcome Box */
.system-welcome {
    margin: auto;
    max-width: 550px;
    width: 100%;
    text-align: center;
}

.welcome-box {
    border: 1px dashed var(--border-color);
    padding: 30px;
    background-color: var(--bg-panel);
    border-radius: var(--modal-border-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.welcome-box h2 {
    color: var(--accent-primary);
    font-size: 16px;
    margin-bottom: 12px;
    letter-spacing: 2px;
    filter: drop-shadow(0 0 4px var(--accent-primary-dim));
}

.welcome-box p {
    color: var(--text-muted);
    font-size: 10px;
    margin-bottom: 24px;
    letter-spacing: 1px;
}

.ascii-art {
    font-family: var(--font-code); /* character-grid art: keep monospace under proportional UI fonts */
    white-space: pre;
    font-size: 9px;
    color: var(--text-muted);
    line-height: 1.2;
    text-align: left;
    display: inline-block;
}

/* Message Styles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 90%;
    margin-bottom: 8px;
    animation: fadeIn 0.25s ease-out;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-header {
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    margin-bottom: 4px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.message.user .message-header {
    color: var(--accent-primary);
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--bubble-border-radius);
    line-height: 1.5;
    font-size: 12px;
    word-break: break-word;
    user-select: text;
}

.message.user .message-bubble {
    background-color: var(--user-bubble-bg);
    border: var(--user-bubble-border);
    border-right: var(--user-bubble-accent-border);
    padding-left: 14px;
    color: var(--user-bubble-color);
}

.message.assistant .message-bubble {
    background-color: var(--assistant-bubble-bg);
    border: var(--assistant-bubble-border);
    border-left: var(--assistant-bubble-accent-border);
    padding-left: 14px;
    color: var(--assistant-bubble-color);
}

/* Inline actions (e.g. ~waves~) */
.action-tag {
    color: var(--accent-warning);
    font-style: italic;
    background-color: var(--accent-warning-dim);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px dashed var(--accent-warning-dim);
}

/* System notifications about context management / compression — styled as an internal "action"
   to signal the model's own housekeeping. Uses the standard accent (secondary) to distinguish
   it from the amber "warning" used for reasoning-loop detection. */
.action-compression {
    display: block;
    margin: 8px 0;
    padding: 8px 14px;
    color: var(--accent-secondary);
    font-style: italic;
    font-size: 11px;
    background-color: var(--accent-secondary-dim);
    border: 1px solid var(--accent-secondary-dim);
    border-radius: 4px;
    text-align: left;
    letter-spacing: 0.3px;
    line-height: 1.4;
    user-select: none;
}

/* General system action warnings (e.g. context limit exceeded) */
.action-warning {
    display: block;
    margin: 8px 0;
    padding: 8px 14px;
    color: var(--accent-warning);
    font-style: italic;
    font-size: 11px;
    background-color: var(--accent-warning-dim);
    border: 1px solid var(--accent-warning-dim);
    border-radius: 4px;
    text-align: left;
    letter-spacing: 0.3px;
    line-height: 1.4;
    user-select: none;
}

/* Choices: model-offered options rendered from a ```choices fenced block (see CLAUDE.md).
   Clicking a button sends its text as the next chat message; the whole group locks afterward. */
.choices-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}
.choice-btn {
    font-family: inherit;
    font-size: inherit; /* match .message-bubble's 12px — buttons are a browser-default 16px otherwise */
    text-align: left;
    padding: 8px 14px;
    border-radius: 4px;
    border: 1px solid var(--accent-secondary);
    background: var(--accent-secondary-dim);
    color: var(--accent-secondary);
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}
.choice-btn:hover:not(:disabled) {
    background: var(--accent-secondary);
    color: var(--bg-main);
}
.choice-btn.selected {
    background: var(--accent-secondary);
    color: var(--bg-main);
}
.choice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* System action errors (e.g. server error, connection failure) */
.action-error {
    display: block;
    margin: 8px 0;
    padding: 8px 14px;
    color: var(--accent-error);
    font-style: italic;
    font-size: 11px;
    background-color: var(--accent-error-dim);
    border: 1px solid var(--accent-error-dim);
    border-radius: 4px;
    text-align: left;
    letter-spacing: 0.3px;
    line-height: 1.4;
    user-select: none;
}

/* System Notifications inside feed */
.message.system {
    align-self: center;
    max-width: 80%;
    width: 100%;
}

.system-alert-bubble {
    background-color: var(--accent-secondary-dim);
    border: 1px solid var(--accent-secondary-dim);
    color: var(--accent-secondary);
    padding: 8px 16px;
    font-size: 10px;
    border-radius: 4px;
    text-align: center;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px var(--accent-secondary-dim);
}

/* A scheduled-reminder trigger is centered (it's neither a user nor an AI message) but kept
   narrower than a full-width system banner — it's a short third-party notice. */
.message.system.reminder-event-message {
    width: auto;
    max-width: min(480px, 80%);
}

/* Interleaved Message Parts */
/* Reasoning (Collapsible details) */
.reasoning-container {
    background-color: var(--accent-secondary-dim);
    border: 1px solid var(--accent-secondary-dim);
    border-radius: 4px;
    margin: 8px 0;
    padding: 2px;
}

.reasoning-details {
    outline: none;
}

.reasoning-summary {
    font-size: 10px;
    font-weight: bold;
    color: var(--accent-secondary);
    cursor: pointer;
    padding: 6px 12px;
    user-select: none;
}

.reasoning-summary:hover {
    color: var(--text-bright);
}

.reasoning-content {
    font-size: 11px;
    color: var(--text-primary);
    padding: 8px 12px;
    background-color: var(--bg-hover);
    border-top: 1px solid var(--accent-secondary-dim);
    white-space: pre-wrap;
    line-height: 1.6;
}

/* Improve contrast for collapsible reasoning blocks in PS1 grey mode */
body.theme-grey-colourful .reasoning-container {
    background-color: #c7c8c7;
    border-color: #6c6d6c;
}

body.theme-grey-colourful .reasoning-summary {
    color: #141414;
    background-color: #b8b9b8;
}

body.theme-grey-colourful .reasoning-summary:hover {
    color: #000000;
    background-color: #adadad;
}

body.theme-grey-colourful .reasoning-content {
    color: #111111;
    background-color: #d2d3d2;
    border-top: 1px solid #8a8b8a;
}

/* Tool execution */
.tool-container {
    background-color: var(--accent-warning-dim);
    border: 1px solid var(--accent-warning-dim);
    border-radius: 4px;
    margin: 8px 0;
    padding: 2px;
}

.tool-details {
    outline: none;
}

.tool-summary {
    font-size: 10px;
    font-weight: bold;
    color: var(--accent-warning);
    cursor: pointer;
    padding: 6px 12px;
    user-select: none;
    display: flex;
    align-items: center;
    list-style: none;
}

.tool-summary::-webkit-details-marker {
    display: none;
}

.tool-summary:hover {
    color: var(--text-bright);
}

/* Tool running spinner and completion dot indicators */
.tool-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.tool-status-indicator.running {
    border: 2px solid var(--accent-warning-dim, rgba(255, 143, 0, 0.2));
    border-top: 2px solid var(--accent-warning, #ff8f00);
    background: transparent;
    animation: tool-spin 0.8s linear infinite;
    box-shadow: 0 0 4px var(--accent-warning-dim, rgba(255, 143, 0, 0.4));
}

.tool-status-indicator.completed {
    background-color: var(--indicator-online, #1bbb0a);
    box-shadow: 0 0 6px var(--indicator-online, rgba(27, 187, 10, 0.6));
    width: 6px;
    height: 6px;
    margin-left: 1px;
    margin-right: 9px;
}

@keyframes tool-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Tool boxes render command output / JSON / file listings — always code-ish, so the whole
   box stays on --font-code (monospace even under a proportional UI font). The descendant
   selector is needed because the global * rule sets font-family per-element. */
.tool-content,
.tool-content * {
    font-family: var(--font-code);
}

.tool-content {
    font-size: 10px;
    color: var(--text-primary);
    padding: 8px 12px;
    background-color: var(--bg-hover);
    border-top: 1px solid var(--accent-warning-dim);
    white-space: pre-wrap;
}

/* Rendered tool output (replaces raw pre-wrap textContent) */
.tool-args-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
    white-space: normal;
}
.tool-args-label {
    font-size: 9px;
    font-weight: bold;
    color: var(--accent-warning);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}
.tool-args-code {
    font-size: 9px;
    color: var(--text-muted);
    background: none;
    padding: 0;
    word-break: break-all;
}
.tool-output-body {
    white-space: normal;
    font-size: 11px;
}
.tool-output-body pre {
    font-size: 10px;
}

/* Undo button shown below file_editor write/patch tool results */
.tool-revert-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}
.tool-revert-btn {
    font-family: var(--font-code); /* lives inside .tool-content; keep the whole box consistent */
    font-size: 10px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 3px;
    border: 1px solid;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition:
        background 0.15s,
        color 0.15s;
}
.tool-revert-btn.reject {
    color: #f07178;
    border-color: #f07178;
    background: rgba(240, 113, 120, 0.08);
}
.tool-revert-btn.reject:hover {
    background: rgba(240, 113, 120, 0.2);
}
.tool-revert-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Message Forks (Sibling navigation) */
.message-fork-navigator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 6px;
    align-self: flex-start;
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 10px;
    user-select: none;
}

.fork-arrow {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: bold;
    padding: 0 4px;
}

.fork-arrow:hover {
    color: var(--accent-primary);
}

/* Repeating TTS button */
.repeat-tts-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    transition: color 0.2s ease;
}

.repeat-tts-btn:hover {
    color: var(--accent-warning);
}

/* Message Controls & Fork selectors styles */
.message-controls-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn-small {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 1px 6px;
    font-size: 8px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn-small:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 4px var(--accent-primary-dim);
}

.control-btn-small.retry-btn:hover {
    color: var(--accent-warning);
    border-color: var(--accent-warning);
    box-shadow: 0 0 4px var(--accent-warning-dim);
}

/* Edit Message Input & Controls */
.edit-message-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

.edit-message-textarea {
    width: 100%;
    min-height: 80px;
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 11px;
    border-radius: 4px;
    outline: none;
    resize: vertical;
    font-family: inherit;
    transition: all 0.2s ease;
}

.edit-message-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary-dim);
}

.edit-message-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

/* Edit-message action buttons use the dedicated button-colour variables so they
   remain legible on any bubble background (e.g. Pear Light's solid-green bubble). */
.edit-message-buttons .icon-btn.edit-save {
    background-color: var(--btn-ok-bg);
    border-color: var(--btn-ok-border);
    color: var(--btn-ok-color);
}

.edit-message-buttons .icon-btn.edit-save:hover {
    background-color: var(--btn-ok-hover-bg);
    color: var(--btn-ok-hover-color);
    box-shadow: none;
}

.edit-message-buttons .icon-btn.edit-cancel {
    background-color: var(--btn-cancel-bg);
    border-color: var(--btn-cancel-border);
    color: var(--btn-cancel-color);
}

.edit-message-buttons .icon-btn.edit-cancel:hover {
    background-color: var(--btn-cancel-hover-bg);
    color: var(--btn-cancel-hover-color);
    box-shadow: none;
}

/* Floating Alerts Container */
.alerts-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1050;
    pointer-events: none;
}

.system-alert-toast {
    background-color: var(--bg-panel);
    border: 1px solid var(--accent-secondary);
    border-left: 4px solid var(--accent-secondary);
    color: var(--text-primary);
    padding: 12px 18px;
    font-size: 10px;
    border-radius: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    max-width: 380px;
    pointer-events: auto;
    animation: slideIn 0.3s ease-out;
}

.system-alert-toast.warning {
    border-color: var(--accent-warning);
    border-left-color: var(--accent-warning);
}

.system-alert-toast.error {
    border-color: var(--accent-error);
    border-left-color: var(--accent-error);
}

/* WhatsApp-style message bubble timestamp */
.message-time {
    display: block;
    text-align: right;
    font-size: 9px;
    margin-top: 4px;
    margin-bottom: -4px;
    user-select: none;
    pointer-events: none;
}

.message.user .message-time {
    color: var(--user-bubble-time-color, var(--user-bubble-color));
    opacity: 0.68;
}

.message.assistant .message-time {
    color: var(--assistant-bubble-time-color, var(--text-muted));
    opacity: 0.8;
}

/* Pulsing typing indicator */
.typing-indicator-message {
    margin-bottom: 12px;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 12px;
    padding: 2px 0;
}

.typing-dots .dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
    box-shadow: 0 0 4px var(--accent-primary);
}

.typing-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing-bounce {
    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Inline spinner shown inside the generating block between tool iterations */
.tool-wait-spinner {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 12px;
    padding: 2px 0;
    vertical-align: middle;
}

.tool-wait-spinner .dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
    box-shadow: 0 0 4px var(--accent-primary);
}

.tool-wait-spinner .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.tool-wait-spinner .dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* ==== css/markdown.css ==== */
/* Markdown Formatting */
/* Shared heading styling. Per-level font-size below gives #..###### a real visual hierarchy
   (they were previously all grouped at a single 13px, so every heading rendered identically). */
.message-bubble h1,
.markdown-body h1,
.message-bubble h2,
.markdown-body h2,
.message-bubble h3,
.markdown-body h3,
.message-bubble h4,
.markdown-body h4,
.message-bubble h5,
.markdown-body h5,
.message-bubble h6,
.markdown-body h6 {
    color: var(--accent-primary);
    margin: 10px 0 6px 0;
    font-weight: 600;
    line-height: 1.3;
}

/* Dashed underline reserved for the top-level section headers (# / ## / ###). */
.message-bubble h1,
.markdown-body h1,
.message-bubble h2,
.markdown-body h2,
.message-bubble h3,
.markdown-body h3 {
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 2px;
}

.message-bubble h1,
.markdown-body h1 {
    font-size: 20px;
}

.message-bubble h2,
.markdown-body h2 {
    font-size: 17px;
}

.message-bubble h3,
.markdown-body h3 {
    font-size: 15px;
}

.message-bubble h4,
.markdown-body h4 {
    font-size: 13px;
}

.message-bubble h5,
.markdown-body h5 {
    font-size: 12px;
}

.message-bubble h6,
.markdown-body h6 {
    font-size: 11px;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-bubble p,
.markdown-body p {
    margin-bottom: 8px;
}

.message-bubble p:last-child,
.markdown-body p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.markdown-body ul,
.message-bubble ol,
.markdown-body ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.message-bubble li,
.markdown-body li {
    margin-bottom: 4px;
}

.message-bubble pre,
.markdown-body pre {
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px 14px;
    margin: 8px 0;
    overflow-x: auto;
}

/* Code stays on --font-code (monospace even when a proportional UI font is pinned — see
   base.css). The descendant selectors matter: the global `* { font-family: var(--font-mono) }`
   rule would otherwise restyle children (e.g. diff spans) past the code element itself. */
.message-bubble pre,
.markdown-body pre,
.message-bubble pre *,
.markdown-body pre * {
    font-family: var(--font-code);
}

.message-bubble code,
.markdown-body code {
    font-family: var(--font-code);
    font-size: 11px;
    color: var(--accent-secondary);
    background-color: var(--accent-secondary-dim);
    padding: 1px 4px;
    border-radius: 3px;
}

.message-bubble pre code,
.markdown-body pre code {
    color: var(--text-primary);
    background: none;
    padding: 0;
}

/* Diff syntax highlighting — works for any ```diff code block, not tool-specific */
.message-bubble pre code.language-diff,
.markdown-body pre code.language-diff {
    display: block;
}
.message-bubble pre code.language-diff span,
.markdown-body pre code.language-diff span {
    display: block;
    white-space: pre;
}
.diff-add {
    color: #4ec94e;
    background: rgba(78, 201, 78, 0.08);
}
.diff-remove {
    color: #f07178;
    background: rgba(240, 113, 120, 0.08);
}
.diff-hunk {
    color: #61afef;
    font-style: italic;
}
.diff-meta {
    color: var(--text-muted);
}
.diff-context {
    color: var(--text-secondary);
}

/* Markdown Tables */
.message-bubble table,
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 11px;
}

.message-bubble th,
.markdown-body th,
.message-bubble td,
.markdown-body td {
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    text-align: left;
}

.message-bubble th,
.markdown-body th {
    background-color: var(--bg-panel);
    color: var(--accent-primary);
    font-weight: bold;
}

.message-bubble tr:nth-child(even),
.markdown-body tr:nth-child(even) {
    background-color: var(--bg-hover);
}

/* Markdown Blockquotes */
.message-bubble blockquote,
.markdown-body blockquote {
    border-left: 3px solid var(--accent-secondary);
    background-color: var(--accent-secondary-dim);
    padding: 8px 14px;
    margin: 10px 0 10px 4px;
    font-style: italic;
    color: var(--text-primary);
    border-radius: 0 4px 4px 0;
}

/* Shield nested blockquotes from accumulating background opacity and layout paddings */
.message-bubble blockquote blockquote,
.markdown-body blockquote blockquote {
    background-color: transparent;
    padding-right: 0;
    margin-right: 0;
}

/* Markdown Hyperlinks */
.message-bubble a,
.markdown-body a {
    color: var(--accent-secondary);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent-secondary-dim);
    transition: all 0.2s ease;
}

.message-bubble a:hover,
.markdown-body a:hover {
    color: #ffffff;
    border-bottom: 1px solid var(--accent-secondary);
    text-shadow: 0 0 4px var(--accent-secondary);
}

/* Markdown Horizontal Rules */
.message-bubble hr,
.markdown-body hr {
    border: none;
    height: 1px;
    background: linear-gradient(
        90deg,
        var(--accent-secondary-dim) 0%,
        var(--accent-secondary) 50%,
        var(--accent-secondary-dim) 100%
    );
    margin: 16px 0;
    opacity: 0.6;
}

/* Cyberpunk Checklists */
.message-bubble ul.checklist,
.markdown-body ul.checklist {
    list-style-type: none;
    margin-left: 0;
    padding-left: 4px;
}

.message-bubble ul.checklist li,
.markdown-body ul.checklist li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    list-style-type: none;
}

.message-bubble ul.checklist input[type="checkbox"],
.markdown-body ul.checklist input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--accent-secondary);
    border-radius: 3px;
    background-color: var(--bg-inner);
    cursor: default;
    position: relative;
    outline: none;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.message-bubble ul.checklist input[type="checkbox"]:checked,
.markdown-body ul.checklist input[type="checkbox"]:checked {
    background-color: var(--accent-secondary-dim);
}

.message-bubble ul.checklist input[type="checkbox"]:checked::after,
.markdown-body ul.checklist input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-secondary);
    font-size: 10px;
    font-weight: bold;
}

.message-bubble ul.checklist li.checked,
.markdown-body ul.checklist li.checked {
    color: var(--text-muted, #8b9bb4);
    text-decoration: line-through;
    opacity: 0.7;
}

.message-bubble ul.checklist input[type="checkbox"].in-progress,
.markdown-body ul.checklist input[type="checkbox"].in-progress {
    border-color: var(--accent-warning, #ffaa00);
    background-color: rgba(255, 170, 0, 0.1);
}

.message-bubble ul.checklist input[type="checkbox"].in-progress::after,
.markdown-body ul.checklist input[type="checkbox"].in-progress::after {
    content: "~";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-warning, #ffaa00);
    font-size: 11px;
    font-weight: bold;
    animation: checklist-pulse 1.5s infinite ease-in-out;
}

.message-bubble ul.checklist li.in-progress,
.markdown-body ul.checklist li.in-progress {
    color: var(--text-normal);
}

@keyframes checklist-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Async Mermaid Diagram Loading & Error styling */
.async-mermaid-diagram {
    background-color: var(--bg-inner, #13141f);
    border: 1px solid var(--border-color, #2d3142);
    border-radius: 6px;
    padding: 15px;
    margin: 8px 0;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mermaid-loader {
    color: var(--text-muted, #718096);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mermaid-loader::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-primary, #00e5ff);
    border-top-color: transparent;
    border-radius: 50%;
    animation: mermaid-spin 0.8s linear infinite;
}

.mermaid-error {
    color: var(--accent-danger, #ff3333);
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    text-align: left;
    white-space: pre-wrap;
    width: 100%;
}

@keyframes mermaid-spin {
    to { transform: rotate(360deg); }
}

/* ==== css/input-panel.css ==== */
/* Input Panel Styling */
.input-panel {
    background-color: var(--bg-footer);
    border-top: 1px solid var(--border-color);
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Query container so the metrics row can hide based on the panel's real width
       (sidebar/console state included), not just the viewport. */
    container-type: inline-size;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.voice-controls,
.playback-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Toggle Switch */
.toggle-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
}

.toggle-container input {
    display: none;
}

.toggle-slider {
    width: 32px;
    height: 16px;
    background-color: var(--border-color);
    border-radius: 8px;
    margin-right: 8px;
    position: relative;
    transition: background-color 0.2s ease;
    border: 1px solid var(--border-color);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--text-muted);
    border-radius: 50%;
    left: 2px;
    top: 2px;
    transition:
        transform 0.2s ease,
        background-color 0.2s ease;
}

.toggle-container input:checked + .toggle-slider {
    background-color: var(--accent-primary-dim);
    border-color: var(--accent-primary);
}

.toggle-container input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background-color: var(--accent-primary);
}

.toggle-container input:checked ~ .toggle-label {
    color: var(--accent-primary);
}

/* Push to Talk Button */
.ptt-btn {
    background-color: var(--border-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 14px;
    font-size: 9px;
    font-weight: bold;
    border-radius: var(--input-border-radius);
    cursor: not-allowed;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}

.ptt-btn.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    cursor: pointer;
    border-color: var(--border-color);
}

.ptt-btn.active.pressed {
    background-color: var(--accent-primary-dim);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary-dim);
}

/* HOLD TO SPEAK only exists while PTT is active (sync.js adds .active). */
.ptt-btn:not(.active) {
    display: none;
}

/* STOP SPK only appears while TTS is actually playing (audio-player.js toggles .tts-active). */
#stop-playback-btn:not(.tts-active) {
    display: none;
}

/* Collapse the whole control row when neither HOLD TO SPEAK nor STOP SPK is showing, so the input
   row sits flush against the feed (no phantom gap) — the common idle/typing case. */
.panel-header:not(:has(.ptt-btn.active)):not(:has(#stop-playback-btn.tts-active)) {
    display: none;
}

.control-btn {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 10px;
    font-size: 9px;
    font-weight: bold;
    border-radius: var(--input-border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-muted);
}

.control-btn.warning:hover {
    border-color: var(--accent-error);
    color: var(--accent-error);
    box-shadow: 0 0 6px var(--accent-error-dim);
}

/* Text Input Row */
.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-row textarea {
    flex-grow: 1;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 12px;
    border-radius: var(--input-border-radius);
    outline: none;
    resize: none;
    min-height: 38px;
    max-height: 150px;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.input-row textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary-dim);
}

.input-row textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.9;
}

.send-btn {
    background-color: var(--send-btn-gradient);
    border: var(--send-btn-border);
    color: var(--send-btn-color);
    padding: 10px 18px;
    font-size: 11px;
    font-weight: bold;
    border-radius: var(--btn-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    height: 38px;
    flex-shrink: 0;
    text-shadow: var(--send-btn-text-shadow);
}

.send-btn:hover {
    background-color: var(--btn-ok-hover-bg);
    color: var(--btn-ok-hover-color);
    box-shadow: 0 0 10px color-mix(in srgb, var(--btn-ok-bg) 40%, transparent);
}

.send-btn.stop {
    background-color: var(--accent-error-dim);
    border-color: var(--accent-error);
    color: var(--accent-error);
}

.send-btn.stop:hover {
    background-color: var(--accent-error);
    color: #ffffff;
    box-shadow: 0 0 10px var(--accent-error-dim);
}

/* Panel Footer & Metrics (latency timers only — AUTO-SCROLL lives in .playback-controls) */
.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

.metrics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    /* Live-ticking timers: fixed-width digits so values don't jitter under proportional
       fonts (Plus Jakarta Sans defaults to proportional figures; this enables its tnum set). */
    font-variant-numeric: tabular-nums;
}

/* Hide the metrics row before its items start wrapping onto a second line.
   ~610px fits all six metrics in one row at the current font/gap. */
@container (max-width: 640px) {
    .panel-footer {
        display: none;
    }
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 8.5px;
    cursor: help;
}

.metric-lbl {
    color: var(--text-muted);
    font-weight: bold;
}

.metric-val {
    color: var(--accent-secondary);
    font-weight: bold;
}

/* Custom Checkbox */
.checkbox-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 9px;
    color: var(--text-muted);
    font-weight: bold;
}

.checkbox-container input {
    display: none;
}

.checkmark {
    width: 12px;
    height: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    margin-right: 6px;
    border-radius: 2px;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-container input:checked + .checkmark {
    background-color: var(--accent-primary-dim);
    border-color: var(--accent-primary);
}

.checkbox-container input:checked + .checkmark::after {
    content: "✓";
    position: absolute;
    color: var(--accent-primary);
    font-size: 9px;
    left: 2px;
    top: -1px;
}

.checkbox-container input:checked ~ .scroll-lbl {
    color: var(--accent-primary);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==== css/settings.css ==== */
/* --- Phase 5: Settings Dashboard Styles --- */

.settings-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: bold;
    color: var(--accent-warning);
    border-color: var(--accent-warning-dim);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.settings-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent-warning);
    box-shadow: 0 0 6px var(--accent-warning-dim);
}

.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.settings-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.settings-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(4, 5, 8, 0.7);
    backdrop-filter: blur(10px);
}

.settings-drawer {
    position: relative;
    width: 92%;
    height: 88%;
    max-width: 1200px;
    max-height: 800px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(0, 255, 102, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
}

.settings-drawer.small-drawer {
    width: min(540px, calc(100vw - 32px));
    height: auto;
    max-height: calc(100vh - 40px);
}

.settings-drawer.small-drawer .drawer-body {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow-y: auto;
    padding: 20px;
    gap: 15px;
}

.settings-drawer.small-drawer input[type="text"],
.settings-drawer.small-drawer select {
    background-color: var(--bg-darker);
}

.settings-modal.hidden .settings-drawer {
    transform: scale(0.96);
}

.drawer-header {
    height: 50px;
    background-color: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.drawer-header h2 {
    font-size: 13px;
    font-weight: bold;
    color: var(--accent-primary);
    letter-spacing: 1.5px;
    text-shadow: 0 0 8px var(--accent-primary-dim);
}

.close-drawer-btn {
    background: var(--close-btn-bg, none);
    border: var(--close-btn-border, 1px solid var(--border-color));
    color: var(--close-btn-color, var(--text-muted));
    font-size: 14px;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-drawer-btn:hover {
    background-color: var(--close-btn-hover-bg, var(--accent-error-dim));
    border-color: var(--close-btn-hover-border, var(--accent-error));
    color: var(--close-btn-hover-color, var(--accent-error));
}

.drawer-body {
    flex-grow: 1;
    display: flex;
    height: calc(100% - 105px); /* Offset header + footer */
    overflow: hidden;
}

.drawer-tabs {
    width: 220px;
    flex-shrink: 0;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 15px 0;
    gap: 4px;
    overflow-y: auto;
}

.tab-btn {
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: bold;
    text-align: left;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    color: var(--accent-primary);
    background-color: var(--accent-primary-dim);
    border-left-color: var(--accent-primary);
    text-shadow: 0 0 8px var(--accent-primary-dim);
}

.drawer-content {
    flex-grow: 1;
    background-color: var(--bg-main);
    overflow: hidden;
    position: relative;
}

.tab-panel {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

/* Config Layout Splits */
.config-split {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.config-sidebar {
    width: 250px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.panel-label {
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.list-container {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    background-color: var(--bg-inner);
    border-radius: 4px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preset-item {
    font-size: 10px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    line-height: 1.3;
}

.preset-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.preset-item.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background-color: var(--accent-primary-dim);
    font-weight: bold;
    text-shadow: 0 0 8px var(--accent-primary-dim);
}

.preset-item.active-profile {
    border-right: 3px solid var(--accent-secondary);
}

.crud-toolbar {
    margin-top: 10px;
    display: flex;
    gap: 6px;
}

.crud-btn {
    flex-grow: 1;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 6px 0;
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.crud-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.crud-btn.success {
    color: var(--accent-primary);
    border-color: var(--accent-primary-dim);
}
.crud-btn.success:hover {
    border-color: var(--accent-primary);
    background-color: var(--accent-primary-dim);
}

.crud-btn.warning {
    color: var(--accent-error);
    border-color: var(--accent-error-dim);
}
.crud-btn.warning:hover {
    border-color: var(--accent-error);
    background-color: var(--accent-error-dim);
}

.config-main {
    flex-grow: 1;
    padding: 20px 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-scroll-area {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Forms styling */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}

.form-group label {
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 11px;
    outline: none;
    transition: all 0.2s ease;
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: var(--select-arrow-svg);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    padding-right: 32px;
}

.form-group input[type="number"] {
    padding-right: 24px;
    -moz-appearance: textfield;
    background-image: var(--spin-buttons-svg);
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 14px;
}

/* Hide default WebKit/Blink spin buttons */
.form-group input[type="number"]::-webkit-inner-spin-button,
.form-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary-dim);
    background-color: var(--bg-hover);
}

.form-group input.dim {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-group-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group-row .form-group {
    flex: 1;
}

.input-action-row {
    display: flex;
    gap: 10px;
}

.input-action-row input,
.input-action-row select {
    flex-grow: 1;
}

.action-btn {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--accent-secondary);
    border-color: var(--accent-secondary-dim);
    font-size: 9px;
    font-weight: bold;
    padding: 0 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background-color: var(--accent-secondary-dim);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 6px var(--accent-secondary-dim);
}

.test-feedback {
    font-size: 9px;
    font-weight: bold;
}
.test-feedback.success {
    color: var(--accent-primary);
}
.test-feedback.failed {
    color: var(--accent-error);
}

/* Slide control styling */
.slider-group input[type="range"],
.vis-control input[type="range"] {
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background-color: var(--border-color);
    outline: none;
    margin: 10px 0;
}

/* Firefox Range Slider Thumbs */
@supports (selector(::-moz-range-thumb:hover)) {
    .slider-group input[type="range"]::-moz-range-thumb,
    .vis-control input[type="range"]::-moz-range-thumb {
        border: none;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background-color: var(--accent-primary);
        cursor: pointer;
        box-shadow: 0 0 6px var(--accent-primary);
        transition: all 0.15s ease;
    }

    .slider-group input[type="range"]::-moz-range-thumb:hover,
    .vis-control input[type="range"]::-moz-range-thumb:hover {
        transform: scale(1.2);
        box-shadow: 0 0 10px var(--accent-primary);
    }
}

/* Memories & Scroll Sections */
.memories-section {
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.memories-section h3 {
    font-size: 10px;
    font-weight: bold;
    color: var(--accent-secondary);
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.divider,
.admin-only .divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--border-color) 35%, transparent) 20%,
        color-mix(in srgb, var(--border-color) 35%, transparent) 80%,
        transparent
    );
    margin: 20px 0;
    width: 100%;
    display: block !important;
}

.tab-panel h3 {
    font-size: 11px;
    font-weight: bold;
    color: var(--accent-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    text-shadow: 0 0 8px var(--accent-secondary-dim);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.checkbox-grid .checkbox-container {
    padding: 6px 0;
}

.hidden-panel {
    display: none;
    flex-direction: column;
    gap: 15px;
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 15px;
    margin-top: 5px;
}

.hidden-panel.visible {
    display: flex;
}

.placeholder-text {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    line-height: 1.4;
    padding: 8px 14px;
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-header h3 {
    margin-bottom: 0;
}

.section-desc {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}

.desc-text {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 4px;
}

/* Footer & Actions */
.drawer-footer {
    height: 55px;
    background-color: var(--bg-darker);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.save-status-feedback {
    font-size: 10px;
    font-weight: bold;
}
.save-status-feedback.success {
    color: var(--accent-primary);
    text-shadow: 0 0 6px var(--accent-primary-dim);
}
.save-status-feedback.error {
    color: var(--accent-error);
    text-shadow: 0 0 6px var(--accent-error-dim);
}

.footer-actions {
    display: flex;
    gap: 10px;
}

.btn {
    font-size: 10px;
    font-weight: bold;
    padding: 8px 20px;
    border-radius: var(--btn-radius);
    background-color: var(--btn-gradient);
    border: var(--btn-border);
    color: var(--btn-color);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    box-shadow: var(--btn-shadow);
}

.btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn.primary {
    background-color: var(--btn-ok-bg);
    border: 1px solid var(--btn-ok-border);
    color: var(--btn-ok-color);
    box-shadow: 0 0 6px color-mix(in srgb, var(--btn-ok-bg) 35%, transparent);
}

.btn.primary:hover {
    background-color: var(--btn-ok-hover-bg);
    color: var(--btn-ok-hover-color);
    border-color: var(--btn-ok-border);
    box-shadow: 0 0 12px color-mix(in srgb, var(--btn-ok-bg) 60%, transparent);
}

.btn.secondary {
    background-color: var(--btn-cancel-bg);
    border: 1px solid var(--btn-cancel-border);
    color: var(--btn-cancel-color);
}

.btn.secondary:hover {
    background-color: var(--btn-cancel-hover-bg);
    border-color: var(--btn-cancel-border);
    color: var(--btn-cancel-hover-color);
}

/* Close/dismiss variant — semantically “I’m done” rather than “I changed my mind”.
   Defaults to the same appearance as .btn.secondary but responds to --btn-close-* overrides. */
.btn.close-action {
    background-color: var(--btn-close-bg);
    border: 1px solid var(--btn-close-border);
    color: var(--btn-close-color);
}

.btn.close-action:hover {
    background-color: var(--btn-close-hover-bg);
    border-color: var(--btn-close-border);
    color: var(--btn-close-hover-color);
}

/* ==========================================================================
   Settings tab elements (migrated from inline styles)
   ========================================================================== */

.config-mt-sm {
    margin-top: 5px;
}
.config-mt-md {
    margin-top: 15px;
}

#memory-longterm-container {
    max-height: 200px;
    overflow-y: auto;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
}

.tools-help-text {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 10px;
}

.tools-help-text strong {
    color: var(--accent-secondary);
}

.tools-grid-header {
    display: grid;
    grid-template-columns: 1fr 100px 120px;
    gap: 10px;
    padding: 8px 12px;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 4px 4px 0 0;
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.tools-grid-header .col-center {
    text-align: center;
}

#prompt-tools-list {
    max-height: 380px;
    overflow-y: auto;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

#sys-theme {
    width: 100%;
    max-width: 300px;
    padding: 6px;
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
}

/* --- Accounts tab --- */
.acct-user-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}
.acct-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-hover);
}
.acct-user-row .acct-user-name {
    flex: 1 1 auto;
    font-family: var(--font-mono);
    color: var(--text-primary);
}
.acct-user-row.acct-disabled {
    opacity: 0.55;
}
.acct-user-row select {
    padding: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
}
.btn.small {
    padding: 4px 8px;
    font-size: 0.78em;
}
.btn.danger {
    color: var(--accent-error, #ff5470);
    border: 1px solid var(--accent-error-dim, rgba(255, 84, 112, 0.15));
    background-color: var(--bg-panel);
}
.btn.danger:hover {
    background-color: var(--accent-error-dim, rgba(255, 84, 112, 0.15));
    border-color: var(--accent-error, #ff5470);
    box-shadow: 0 0 10px var(--accent-error-dim, rgba(255, 84, 112, 0.15));
}

/* ── MCP servers tab ─────────────────────────────────────────────────────── */
.mcp-status-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.mcp-status-empty {
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 4px;
}
.mcp-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}
.mcp-status-row.mcp-disabled {
    opacity: 0.55;
}
.mcp-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
    background-color: var(--text-muted);
}
.mcp-dot-ok {
    background-color: #3fb950;
    box-shadow: 0 0 6px #3fb95088;
}
.mcp-dot-err {
    background-color: var(--accent-error, #ff5470);
    box-shadow: 0 0 6px var(--accent-error-dim, #ff547044);
}
.mcp-dot-off {
    background-color: var(--text-muted);
}
.mcp-srv-name {
    color: var(--text-primary);
    font-weight: 600;
}
.mcp-srv-meta {
    color: var(--text-muted);
    font-size: 0.82em;
    margin-left: auto;
}
.mcp-config-editor {
    width: 100%;
    min-height: 280px;
    resize: vertical;
    font-family: var(--font-mono, monospace);
    font-size: 0.85em;
    line-height: 1.45;
    color: var(--text-primary);
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    white-space: pre;
    overflow: auto;
}
.mcp-config-editor:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary-dim);
}
.mcp-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 4px;
}

/* ── Tool Permission Dialog ──────────────────────────────────────────────── */
.tool-perm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}
.tool-perm-box {
    background: var(--bg-panel);
    border: 1px solid var(--accent-warning, #e5a000);
    border-radius: 8px;
    padding: 24px 28px;
    min-width: 380px;
    max-width: 560px;
    width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    font-family: var(--font-mono, monospace);
}
.tool-perm-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}
.tool-perm-icon {
    color: var(--accent-warning, #e5a000);
    font-size: 1.3em;
}
.tool-perm-title {
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent-warning, #e5a000);
}
.tool-perm-label {
    font-size: 0.78em;
    color: var(--text-muted);
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.tool-perm-func {
    margin-bottom: 14px;
}
.tool-perm-purpose {
    background: var(--bg-darker);
    border-left: 3px solid var(--accent-secondary);
    padding: 6px 10px;
    margin-bottom: 14px;
    border-radius: 0 3px 3px 0;
    font-size: 0.9em;
    color: var(--text-primary);
}
.tool-perm-func code {
    font-size: 0.95em;
    color: var(--text-primary);
    background: var(--bg-darker);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}
.tool-perm-sep {
    color: var(--text-muted);
}
.tool-perm-args {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    font-size: 0.82em;
    color: var(--text-secondary);
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0 0 20px;
}
.tool-perm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.tool-perm-btn {
    font-family: var(--font-mono, monospace);
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: opacity 0.15s;
}
.tool-perm-btn:hover {
    opacity: 0.85;
}
.tool-perm-btn.deny {
    background: transparent;
    border-color: var(--accent-danger, #e55);
    color: var(--accent-danger, #e55);
}
.tool-perm-btn.allow {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}
.tool-perm-btn.always-allow {
    background: transparent;
    border-color: var(--text-muted);
    color: var(--text-muted);
}

/* --- TTS Engines (schema-driven config; docs/tts_engine_spec.md) --- */
#tts-engine-params,
#prompt-tts-params,
#valves-form-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Inline qualifier appended to a <label> (e.g. "*requires restart"). */
.form-hint-inline {
    font-size: 10px;
    font-weight: normal;
    color: var(--text-muted);
    font-style: italic;
}

#tts-engine-edit-title {
    margin: 0 0 12px 0;
    color: var(--accent-primary);
    font-size: 13px;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px var(--accent-primary-dim);
}

.tts-param .tts-override-label {
    font-weight: normal;
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 8px;
    cursor: pointer;
}

.tts-param .tts-override-chk {
    vertical-align: middle;
    margin-right: 3px;
}

.tts-param-input:disabled {
    opacity: 0.5;
}

/* Specific sizing overrides for push notification and geolocation control buttons */
#push-toggle-btn,
#push-test-btn,
#location-toggle-btn {
    height: 26px;
    line-height: 24px;
    padding: 0 14px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ==== css/attachments.css ==== */
/* ==========================================================================
   Phase A: Attachment Previews, Emoji Picker & Lightbox Styles
   ========================================================================== */

/* Hidden element helper */
.hidden {
    display: none !important;
}

/* Attachment Preview Bar */
.attachment-preview-container {
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    max-height: 120px;
    overflow-y: auto;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 8px var(--accent-secondary-dim);
}

/* Image Thumbnail Preview */
.preview-thumb {
    width: 64px;
    height: 64px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    background-color: var(--bg-inner);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumb:hover {
    border-color: var(--accent-warning);
    box-shadow: 0 0 8px var(--accent-warning-dim);
}

/* Attachment Close/Delete Button */
.attachment-remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 10;
}

.attachment-remove-btn:hover {
    background-color: var(--accent-error-dim);
    border-color: var(--accent-error);
    color: var(--accent-error);
    text-shadow: 0 0 4px var(--accent-error);
    transform: scale(1.1);
}

/* Document File Chip Preview */
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    position: relative;
    max-width: 220px;
    transition: all 0.2s ease;
}

.file-chip:hover {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary-dim);
}

.file-chip .file-icon {
    font-size: 12px;
    color: var(--accent-secondary);
    filter: drop-shadow(0 0 3px var(--accent-secondary-dim));
}

.file-chip .file-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-chip .file-name {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-chip .file-size {
    font-size: 8px;
    color: var(--text-muted);
}

.file-chip .chip-remove-btn {
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    margin-left: 6px;
    font-weight: bold;
    transition: color 0.15s ease;
}

.file-chip .chip-remove-btn:hover {
    color: var(--accent-error);
    text-shadow: 0 0 4px var(--accent-error);
}

/* Emoji Picker Popover */
.emoji-picker-popover {
    position: absolute;
    bottom: 82px;
    left: 18px;
    width: 320px;
    height: 320px;
    background: var(--bg-panel);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow:
        0 10px 30px var(--accent-secondary-dim),
        0 0 15px var(--accent-secondary-dim);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.emoji-picker-header {
    display: flex;
    background: var(--bg-inner);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.emoji-tab-btn {
    flex-grow: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 6px;
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    letter-spacing: 0.5px;
    transition: all 0.15s ease;
}

.emoji-tab-btn:hover {
    color: var(--text-bright);
    background-color: var(--bg-hover);
}

.emoji-tab-btn.active {
    color: var(--accent-secondary);
    border-bottom-color: var(--accent-secondary);
    text-shadow: 0 0 6px var(--accent-secondary-dim);
}

.emoji-grid {
    flex-grow: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 12px;
}

.emoji-item {
    background: none;
    border: none;
    font-size: 20px;
    padding: 6px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
}

.emoji-item:hover {
    background-color: var(--bg-hover);
    transform: scale(1.2);
}

/* Custom Smiley Trigger button in input-row (38px = textarea min-height + send-btn height) */
.emoji-trigger-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    /* The themeable sprite icon strokes with currentColor, so set a visible base colour
       (the old 😀 emoji was self-coloured and didn't need this). */
    color: var(--text-muted);
}

.emoji-trigger-btn:hover {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary-dim);
    transform: scale(1.05);
}

/* Inline parsed images inside chat bubble */
.message-image-container {
    margin: 12px 0;
    max-width: 100%;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.4),
        0 0 10px rgba(0, 255, 102, 0.05);
    display: inline-block;
    transition: all 0.25s ease;
}

.message-image-container:hover {
    border-color: var(--accent-primary);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(0, 255, 102, 0.15);
}

.message-inline-image {
    max-width: 100%;
    max-height: 280px;
    display: block;
    object-fit: contain;
    cursor: zoom-in;
    transition: filter 0.2s ease;
}

.message-inline-image:hover {
    filter: brightness(1.05);
}

/* Inline parsed videos inside chat bubble */
.message-video-container {
    margin: 12px 0;
    max-width: 100%;
    width: 480px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: var(--bg-inner);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.4),
        0 0 10px rgba(0, 255, 102, 0.05);
    display: inline-block;
    transition: all 0.25s ease;
}

.message-video-container:hover {
    border-color: var(--accent-primary);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(0, 255, 102, 0.15);
}

.message-inline-video {
    width: 100%;
    max-height: 280px;
    display: block;
    object-fit: contain;
    background-color: #000000;
}

.message-inline-video-iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    display: block;
    background-color: #000000;
}

.message-video-caption {
    font-size: 9px;
    padding: 6px 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Fullscreen Lightbox Modal */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.25s ease-out;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 8, 12, 0.85);
    backdrop-filter: blur(12px);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 2010;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-inner);
    box-shadow:
        0 0 35px rgba(0, 0, 0, 0.8),
        0 0 25px var(--accent-primary-dim);
}

#lightbox-img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    display: block;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 22px;
    color: var(--text-muted);
    background: rgba(17, 20, 30, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.lightbox-close:hover {
    background-color: var(--accent-error-dim);
    border-color: var(--accent-error);
    color: var(--accent-error);
    text-shadow: 0 0 6px var(--accent-error);
}

/* Dynamic Animation for popovers */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Debug & Network Console Sidebar Styling
   ========================================================================== */

.debug-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: bold;
    color: var(--accent-secondary);
    border-color: var(--accent-secondary-dim);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.debug-btn:hover,
.debug-btn.active {
    background-color: var(--bg-hover);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 6px var(--accent-secondary-dim);
}

.debug-console,
.debug-console * {
    /* Raw request/response payloads: keep monospace under proportional UI fonts.
       Descendant selector needed because the global * rule sets --font-mono per-element. */
    font-family: var(--font-code);
}

.debug-console {
    width: 420px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.debug-console.hidden {
    width: 0 !important;
    display: none !important;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.console-title {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--accent-secondary);
    filter: drop-shadow(0 0 4px var(--accent-secondary-dim));
}

.console-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.close-console-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.15s ease;
    font-weight: bold;
}

.close-console-btn:hover {
    color: var(--accent-error);
    text-shadow: 0 0 4px var(--accent-error);
}

.console-log {
    flex-grow: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 10px;
}

.log-entry {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.4;
}

.log-entry.outbound {
    border-color: var(--accent-secondary-dim);
    color: var(--accent-secondary);
    background-color: var(--accent-secondary-dim);
}

.log-entry.inbound {
    border-color: var(--accent-primary-dim);
    color: var(--text-primary);
}

.log-entry.system {
    border-color: var(--border-color);
    color: var(--text-muted);
}

/* ==== css/login.css ==== */
/* IPC Connection Overlay Modal */
.ipc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ipc-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ipc-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(4, 5, 8, 0.85);
    backdrop-filter: blur(12px);
}

.ipc-panel {
    position: relative;
    width: 90%;
    max-width: 480px;
    background-color: var(--bg-panel);
    border: 1px solid var(--accent-secondary-dim);
    border-radius: 6px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.7),
        0 0 30px var(--accent-secondary-dim);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ipc-header {
    background: linear-gradient(90deg, rgba(0, 240, 255, 0.1), transparent);
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
    padding: 16px;
}

.ipc-header h2 {
    color: var(--accent-secondary);
    font-size: 14px;
    letter-spacing: 1px;
    margin: 0;
    text-shadow: 0 0 8px var(--accent-secondary-dim);
}

.ipc-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ipc-instructions {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 4px 0;
}

.ipc-status-info {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.ipc-status-info.connected {
    color: var(--accent-primary);
    border-color: var(--accent-primary-dim);
    background-color: rgba(0, 255, 102, 0.02);
}

.ipc-status-info.connecting {
    color: var(--accent-warning);
    border-color: var(--accent-warning-dim);
    background-color: rgba(255, 204, 0, 0.02);
}

.ipc-status-info.error {
    color: var(--accent-error);
    border-color: var(--accent-error-dim);
    background-color: rgba(255, 51, 102, 0.02);
}

.ipc-footer {
    padding: 16px 20px;
    background-color: var(--bg-footer);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.ipc-footer .btn {
    width: 100%;
}

/* ==== css/file-browser.css ==== */
/* ==========================================================================
   General-Purpose Right File Browser Sidebar Styling
   ========================================================================== */

.file-browser-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: bold;
    color: var(--accent-primary);
    border-color: var(--accent-primary-dim);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.file-browser-btn:hover,
.file-browser-btn.active {
    background-color: var(--bg-hover);
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--accent-primary-dim);
}

.file-browser-sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.file-browser-sidebar.hidden {
    width: 0 !important;
    display: none !important;
}

/* Drag & drop upload affordance: highlight the whole panel while files hover over it */
.file-browser-sidebar.fb-drag-over {
    position: relative;
}

.file-browser-sidebar.fb-drag-over::after {
    content: "⬇ DROP TO UPLOAD";
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--accent-primary);
    background-color: rgba(0, 0, 0, 0.55);
    border: 2px dashed var(--accent-primary);
    box-shadow: inset 0 0 25px var(--accent-primary-dim);
    pointer-events: none;
}

.fb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: linear-gradient(90deg, rgba(0, 255, 102, 0.05), transparent);
}

.fb-title {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--accent-primary);
    text-shadow: 0 0 5px var(--accent-primary-dim);
}

.fb-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.fb-icon-btn,
.close-fb-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: bold;
}

.fb-icon-btn:hover {
    color: var(--accent-secondary);
    text-shadow: 0 0 4px var(--accent-secondary);
}

.close-fb-btn:hover {
    color: var(--accent-error);
    text-shadow: 0 0 4px var(--accent-error);
}

.fb-toolbar {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.01);
    flex-shrink: 0;
}

.fb-item-row {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-mono);
    font-size: 11px;
    user-select: none;
    gap: 8px;
}

.fb-item-row:hover {
    background-color: var(--bg-hover);
    box-shadow: inset 2px 0 0 var(--accent-secondary);
}

.fb-item-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.fb-item-icon.folder {
    color: #ffcc00;
    text-shadow: 0 0 3px rgba(255, 204, 0, 0.4);
}

.fb-item-icon.file {
    color: #00d8ff;
    text-shadow: 0 0 3px rgba(0, 216, 255, 0.4);
}

.fb-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.fb-item-row:hover .fb-item-name {
    color: var(--text-bright);
}

.fb-item-size {
    font-size: 8px;
    color: var(--text-muted);
    margin-right: 6px;
}

.fb-item-actions {
    display: flex;
    gap: 6px;
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

.fb-item-row:hover .fb-item-actions {
    opacity: 1;
}

.fb-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
    transition: all 0.15s ease;
}

.fb-action-btn:hover {
    transform: scale(1.15);
}

.fb-action-btn.download:hover {
    color: var(--accent-primary);
    text-shadow: 0 0 3px var(--accent-primary);
}

.fb-action-btn.preview:hover {
    color: var(--accent-secondary);
    text-shadow: 0 0 3px var(--accent-secondary);
}

/* Unpin = remove-from-context. Distinct from the red delete action: it's an accent colour,
   never error red, because the file is NOT deleted from disk. */
.fb-action-btn.unpin:hover {
    color: var(--accent-secondary);
    text-shadow: 0 0 3px var(--accent-secondary);
}

/* Mode tabs (Files | Pinned) */
.fb-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.fb-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 7px 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.fb-tab:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.fb-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.fb-tab-badge {
    min-width: 15px;
    padding: 0 4px;
    border-radius: 8px;
    background-color: var(--accent-primary-dim);
    color: var(--text-bright);
    font-size: 9px;
    line-height: 15px;
    text-align: center;
}

/* Artifacts: per-file +/- diffstat indicator (cheap sum — an indicator, not an audit) */
.fb-diffstat {
    font-family: var(--font-mono);
    font-size: 9px;
    margin-right: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.fb-diff-add {
    color: var(--accent-success, #3fb950);
}

.fb-diff-del {
    color: var(--accent-error, #f85149);
}

.fb-action-btn.diff:hover {
    color: var(--accent-primary);
    text-shadow: 0 0 3px var(--accent-primary);
}

/* diff2html side-by-side view inside the file-viewer modal — dark-themed + compact.
   Overrides diff2html.min.css (default light theme); scoped under .fb-diff-view to win specificity. */
.fb-diff-view {
    overflow: auto;
    max-width: 100%;
    min-width: 0; /* flex child of #fv-content-container — allow it to shrink + scroll, not escape */
    max-height: 100%;
    font-size: 11px;
    line-height: 1.45;
}

.fb-diff-view .d2h-wrapper {
    background: transparent;
}

.fb-diff-view .d2h-file-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-inner);
    margin-bottom: 0;
    /* diff2html ships NO positioned ancestor for its absolute line-numbers, so they'd anchor to
       the non-scrolling .fv-drawer and escape the modal bottom. Make this in-scroll wrapper their
       containing block so the numbers scroll with the diff content. */
    position: relative;
}

.fb-diff-view .d2h-file-header {
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 10px;
}

.fb-diff-view .d2h-file-name {
    color: var(--text-bright);
    font-size: 11px;
}

.fb-diff-view .d2h-tag {
    display: none; /* hide the "CHANGED" pill — redundant in this compact view */
}

.fb-diff-view .d2h-diff-table {
    font-family: var(--font-mono);
    font-size: 11px;
}

.fb-diff-view td {
    color: var(--text-primary);
}

/* Gutter line numbers */
.fb-diff-view .d2h-code-linenumber,
.fb-diff-view .d2h-code-side-linenumber {
    background: var(--bg-sidebar);
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* NOTE: do NOT override .d2h-code-side-line padding — diff2html uses padding-left:4.5em to
   clear its absolutely-positioned line-number gutter; overriding it makes text overlap the numbers. */

/* Row backgrounds (stronger than diff2html's near-white defaults) */
.fb-diff-view .d2h-del,
.fb-diff-view .d2h-deletion {
    background: rgba(248, 81, 73, 0.18);
}

.fb-diff-view .d2h-ins,
.fb-diff-view .d2h-addition {
    background: rgba(63, 185, 80, 0.18);
}

/* "Change" rows (paired del+ins) — diff2html's stock selectors carry an extra class of
   specificity over the plain .d2h-del/.d2h-ins overrides above, so without these they
   keep their light-theme cream/pale-green backgrounds. */
.fb-diff-view .d2h-file-diff .d2h-del.d2h-change {
    background: rgba(210, 153, 34, 0.15);
}

.fb-diff-view .d2h-file-diff .d2h-ins.d2h-change {
    background: rgba(63, 185, 80, 0.18);
}

.fb-diff-view .d2h-info {
    background: var(--bg-hover);
    color: var(--text-muted);
}

.fb-diff-view .d2h-emptyplaceholder,
.fb-diff-view .d2h-code-side-emptyplaceholder {
    background: var(--bg-sidebar);
    border-color: var(--border-color);
}

/* Intra-line change highlights. The extra .d2h-code*-line classes out-specify the stock
   ".d2h-code-line del" rules — needed because diff2html.min.css loads AFTER the app bundle
   (it sits outside the BUILD:CSS block), so an equal-specificity tie goes to the bright
   stock colors. */
.fb-diff-view .d2h-code-line del,
.fb-diff-view .d2h-code-side-line del {
    background: rgba(248, 81, 73, 0.4);
    color: var(--text-bright);
    text-decoration: none;
}

.fb-diff-view .d2h-code-line ins,
.fb-diff-view .d2h-code-side-line ins {
    background: rgba(63, 185, 80, 0.4);
    color: var(--text-bright);
    text-decoration: none;
}

/* Widen the preview modal while showing a diff so side-by-side fits with little scrolling */
.fv-diff-wide .fv-drawer {
    max-width: 1200px;
    width: 92vw;
}

/* Pinned-mode footer: total context weight */
.fb-footer {
    flex-shrink: 0;
    padding: 7px 16px;
    border-top: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    text-align: right;
}

/* Titlebar dot indicating the viewed conversation has pinned context */
.fb-trigger-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 5px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    box-shadow: 0 0 4px var(--accent-primary);
    vertical-align: middle;
}

.fb-tab-badge.hidden,
.fb-footer.hidden,
.fb-trigger-dot.hidden {
    display: none;
}

.fb-loading-spinner {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   File Browser controls & preview modal (migrated from inline styles)
   ========================================================================== */

.fb-toolbar .form-group {
    margin-bottom: 0;
}

.fb-select-label {
    font-size: 9px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 4px;
    display: block;
}

.fb-dropdown {
    width: 100%;
    padding: 4px 24px 4px 8px;
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    outline: none;
    border-radius: 4px;
    appearance: none;
    background-image: var(--select-arrow-svg);
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
    cursor: pointer;
}

.fb-path-bar {
    background-color: var(--bg-inner);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent-secondary);
    white-space: nowrap;
    overflow-x: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fb-path-root {
    cursor: pointer;
    font-weight: bold;
    color: var(--accent-primary);
}

#fb-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fb-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

/* File viewer / preview modal */
.fv-drawer {
    max-width: 800px;
    height: 80vh;
}

.fv-body {
    padding: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#fv-content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: auto;
}

#fv-textarea {
    flex: 1;
    width: 100%;
    height: 100%;
    background-color: var(--bg-inner);
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 12px;
    resize: none;
    border-radius: 4px;
    box-shadow: inset 0 0 10px color-mix(in srgb, var(--accent-primary) 10%, transparent);
    outline: none;
}

.fv-footer {
    padding: 10px 15px;
}

.fv-footer .footer-actions {
    margin-left: auto;
}

/* Media preview loading state (built by file-browser.js previewFile) */
.fv-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    min-height: 250px;
}

.fv-loading-spinner {
    border: 3px solid color-mix(in srgb, var(--accent-primary) 10%, transparent);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.fv-loading-title {
    text-shadow: 0 0 5px var(--accent-primary);
}

.fv-loading-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 5px;
    text-transform: uppercase;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.fb-loading-spinner.error {
    color: var(--accent-error);
}
.fb-loading-spinner.muted {
    color: var(--text-muted);
}

/* ==========================================================================
   Media preview stages (audio / video / image / error) — migrated from the
   inline styles previously built in file-browser.js previewFile().
   NOTE: the audio disc's live transform / border-color / box-shadow are set
   inline by JS during playback and intentionally override these base rules.
   ========================================================================== */

.fv-media-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-inner);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    min-height: 250px;
}

.fv-media-stage.audio {
    min-height: 320px;
    padding: 20px;
    box-shadow: inset 0 0 15px color-mix(in srgb, var(--accent-primary) 6%, transparent);
    position: relative;
    overflow: hidden;
}

.fv-media-stage.video {
    padding: 10px;
}

.fv-media-stage.image {
    padding: 15px;
    overflow: auto;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.fv-media-stage.error {
    color: var(--accent-error);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 25px;
    text-align: center;
}

/* Audio visualizer sub-elements */
.fv-audio-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(185deg, color-mix(in srgb, var(--accent-primary) 4%, transparent) 0%, transparent 70%);
    pointer-events: none;
}

.fv-audio-disc {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        color-mix(in srgb, var(--accent-primary) 8%, var(--bg-inner)) 30%,
        var(--bg-inner) 100%
    );
    border: 3px dashed var(--accent-primary);
    margin-bottom: 20px;
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent-primary) 15%, transparent);
    transition: transform 0.05s linear;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
}

.fv-audio-disc-center {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    box-shadow: inset 0 0 5px var(--bg-inner);
}

.fv-audio-filename {
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 5px;
    text-shadow: 0 0 5px var(--accent-primary);
    text-align: center;
    max-width: 100%;
    word-break: break-all;
    z-index: 1;
}

.fv-audio-canvas {
    width: 320px;
    height: 60px;
    background-color: color-mix(in srgb, var(--bg-inner) 70%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-primary) 20%, transparent);
    border-radius: 4px;
    margin-bottom: 15px;
    box-shadow: 0 0 10px color-mix(in srgb, var(--accent-primary) 5%, transparent);
    z-index: 1;
}

.fv-audio-status {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    margin-bottom: 15px;
    text-transform: uppercase;
    z-index: 1;
}

.fv-audio-player {
    width: 100%;
    max-width: 450px;
    filter: hue-rotate(40deg) brightness(1.1);
    outline: none;
    z-index: 1;
}

/* Video / image preview elements */
.fv-media-video {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 3px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    outline: none;
}

.fv-media-img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border-color);
}

.fv-media-caption {
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    margin-top: 10px;
    opacity: 0.8;
}

/* Error / fallback state */
.fv-media-error-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.fv-media-error-title {
    font-weight: bold;
    text-shadow: 0 0 5px color-mix(in srgb, var(--accent-error) 30%, transparent);
    margin-bottom: 8px;
}

.fv-media-error-msg {
    color: var(--text-muted);
    font-size: 11px;
    max-width: 400px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.fv-media-error-btn {
    background-color: var(--accent-error);
    border-color: var(--accent-error);
    box-shadow: 0 0 10px color-mix(in srgb, var(--accent-error) 40%, transparent);
}

/* ==== css/diff-panel.css ==== */
/* ============================================================
   Diff side panel (#diff-panel) + compact chat diff cards
   Panel: flex sibling of the chat area, styled to match the
   file-browser sidebar; fullscreen on mobile via responsive.css.
   Diff body theming is shared with the modal via .fb-diff-view
   (file-browser.css) — only panel chrome + unified-mode extras
   live here.
   ============================================================ */

.diff-panel {
    width: clamp(380px, 42vw, 760px);
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.diff-panel.hidden {
    width: 0 !important;
    display: none !important;
}

/* Header — mirrors .fb-header so the two panels read as siblings */
.dp-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: linear-gradient(90deg, rgba(0, 255, 102, 0.05), transparent);
    min-width: 0;
}

.dp-title {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--accent-primary);
    text-shadow: 0 0 5px var(--accent-primary-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.dp-subtitle {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.dp-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.dp-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: bold;
}

.dp-icon-btn:hover {
    color: var(--accent-secondary);
    text-shadow: 0 0 4px var(--accent-secondary);
}

#dp-close-btn:hover {
    color: var(--accent-error);
    text-shadow: 0 0 4px var(--accent-error);
}

/* Scrolling diff body */
.dp-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 8px;
}

.dp-fallback {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* NOTE: unified-mode diff theming is fully covered by the shared .fb-diff-view rules in
   file-browser.css — its non-side classes (.d2h-code-linenumber, .d2h-del/.d2h-ins, the
   .d2h-file-wrapper position:relative gutter anchor) apply to line-by-line output too.
   Like side-by-side, do NOT override .d2h-code-line padding: it clears the absolute
   line-number gutter. */

/* ------------------------------------------------------------
   Compact diff card — replaces the raw diff dump inside chat
   tool boxes for file_editor results (built in markdown.js).
   ------------------------------------------------------------ */

.diff-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 6px 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-inner);
    min-width: 0;
}

.diff-card-icon {
    flex-shrink: 0;
    color: var(--accent-primary);
}

.diff-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.diff-card-name {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.diff-card-meta {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.diff-card-view {
    font-family: var(--font-code);
    font-size: 10px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 3px;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    background: transparent;
    cursor: pointer;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    transition:
        background 0.15s,
        color 0.15s;
}

.diff-card-view:hover {
    background: var(--accent-primary-dim);
    color: var(--text-bright);
}

/* ==== css/notes.css ==== */
/* ==========================================================================
   Notes — Sidebar accordion + full-screen markdown editor
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sidebar accordion — the collapsible header shell (group/toggle/chevron/label/
   count + body padding) is shared across all sidebar sections and lives in
   layout.css ("Sidebar accordion shell"). Only note-specific body styling
   (list, items, editor) lives here.
   -------------------------------------------------------------------------- */

.notes-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.notes-header-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.notes-new-btn {
    padding: 3px 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.06em;
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.notes-new-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-main);
}

.notes-list {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.notes-item {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
    margin-bottom: 2px;
    gap: 2px;
}

.notes-item:hover {
    background-color: var(--bg-hover);
    border-left-color: var(--accent-primary);
}

.notes-item.active {
    background-color: var(--accent-primary-dim);
    border-left-color: var(--accent-primary);
}

.notes-item.empty {
    cursor: default;
    color: var(--text-muted);
    font-size: 10px;
    font-style: italic;
    border-left-color: transparent;
}

.notes-item.empty:hover {
    background: none;
}

.notes-item-title {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-item-date {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Editor overlay — confined to the chat feed area (its offset parent is
   .feed-container, which is position:relative and sits above .input-panel),
   so the message input below stays visible and usable.
   -------------------------------------------------------------------------- */

.note-editor-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
}

.note-editor-overlay.hidden {
    display: none;
}

.note-editor-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.note-editor-title-input {
    flex-grow: 1;
    min-width: 0; /* allow the input to shrink so the action buttons never overflow off-screen */
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    text-transform: uppercase;
    background: none;
    border: none;
    outline: none;
    padding: 4px 6px;
    border-bottom: 1px dashed transparent;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.note-editor-title-input:focus {
    border-bottom-color: var(--accent-primary);
    box-shadow: 0 1px 4px var(--accent-primary-dim);
}

.note-editor-title-input::placeholder {
    color: var(--text-muted);
    opacity: 0.4;
}

.note-editor-topbar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Compact icon buttons (preview / delete / close / save) — replace the old text
   buttons so the action row stays short now that the editor lives in the narrower
   chat column. Icon-only; the accessible label lives in title/aria-label. */
.note-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 15px;
    background: none;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition:
        color 0.15s ease,
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.note-action-btn:hover {
    color: var(--accent-primary);
    background: var(--accent-primary-dim);
    border-color: var(--accent-primary);
}

.note-action-btn.danger:hover {
    color: var(--accent-error);
    background: color-mix(in srgb, var(--accent-error) 15%, transparent);
    border-color: var(--accent-error);
}

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */

.note-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 10px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.note-tool-btn {
    padding: 3px 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    background: none;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition:
        color 0.15s,
        background-color 0.15s,
        border-color 0.15s;
    line-height: 1.4;
}

.note-tool-btn:hover {
    color: var(--accent-primary);
    background-color: var(--accent-primary-dim);
    border-color: var(--accent-primary);
}

.note-tool-btn b {
    font-weight: 800;
}
.note-tool-btn i {
    font-style: italic;
}
.note-tool-btn s {
    text-decoration: line-through;
}

.note-tool-sep {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 4px;
}

/* --------------------------------------------------------------------------
   Editor body — textarea + preview
   -------------------------------------------------------------------------- */

.note-editor-panes {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    position: relative; /* anchor for the .note-generating overlay */
}

.note-textarea {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    padding: 16px 20px;
    background: var(--bg-main);
    color: var(--text-primary);
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    tab-size: 4;
    overflow-y: auto;
    caret-color: var(--accent-primary);
}

.note-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.note-preview-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 24px;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   "Improving note" generating overlay (Notes Part 3)
   -------------------------------------------------------------------------- */

.note-generating {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--bg-main) 78%, transparent);
    backdrop-filter: blur(1.5px);
}

.note-generating.hidden {
    display: none;
}

.note-generating-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 24px 32px;
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    background: var(--bg-panel);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
}

.note-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--accent-primary-dim);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: note-spin 0.8s linear infinite;
}

@keyframes note-spin {
    to {
        transform: rotate(360deg);
    }
}

.note-generating-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--accent-primary);
    text-transform: uppercase;
}

.note-generating-cancel {
    padding: 4px 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition:
        color 0.15s ease,
        border-color 0.15s ease,
        background-color 0.15s ease;
}

.note-generating-cancel:hover {
    color: var(--accent-error);
    border-color: var(--accent-error);
    background: color-mix(in srgb, var(--accent-error) 15%, transparent);
}

/* Toolbar is inert while an improvement is generating. */
.note-toolbar.disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* Scope chip above the chat input: shows whether "improve" targets the selection or whole note.
   Lives inside .input-panel (inserted before .input-row by notes.js). */
.note-scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    max-width: 100%;
    padding: 3px 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.note-scope-chip.hidden {
    display: none;
}

/* Highlighted when a specific selection is targeted (vs the whole note). */
.note-scope-chip.scoped {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
}

.note-scope-chip .ui-icon {
    width: 12px;
    height: 12px;
}

/* --------------------------------------------------------------------------
   Status bar
   -------------------------------------------------------------------------- */

.note-editor-statusbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 4px 14px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.note-save-status {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.note-save-status.error {
    color: var(--accent-error);
}

/* Collapsed sidebar rail: notes render as a launcher icon — see the "section launchers"
   block in layout.css. */

/* --------------------------------------------------------------------------
   Responsive — narrow / mobile
   -------------------------------------------------------------------------- */

@media (max-width: 600px) {
    /* The icon action buttons are compact enough to stay on the title row even on
       narrow/portrait screens — the title shrinks (min-width:0) and the icons keep
       their fixed size. */
    .note-toolbar {
        gap: 1px;
        padding: 3px 6px;
    }

    .note-tool-btn {
        padding: 2px 5px;
        font-size: 9px;
    }

    .note-textarea {
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* ==== css/email.css ==== */
/* ==========================================================================
   Email — sidebar accounts/folders tree + main-window client panel + compose
   + settings tab bits. Sidebar accordion shell (group/toggle/chevron/count)
   is shared and lives in layout.css; the email group reuses the notes shell
   classes. Theme tokens only (tokens.css) — no hardcoded palette colors.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sidebar: accounts → folders tree
   -------------------------------------------------------------------------- */

.email-accounts-tree {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.email-account-node {
    margin-bottom: 2px;
}

.email-account-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-primary);
    text-align: left;
    transition: background-color 0.15s ease;
}

.email-account-header:hover {
    background-color: var(--bg-hover);
    border-left-color: var(--accent-primary);
}

.email-account-header .email-acct-chevron .ui-icon {
    width: 10px;
    height: 10px;
    transition: transform 0.15s ease;
}

.email-account-node.open .email-acct-chevron .ui-icon {
    transform: rotate(90deg);
}

.email-account-label {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-account-unread,
.email-folder-unread {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--accent-primary);
    background: var(--accent-primary-dim);
    border-radius: 8px;
    padding: 1px 6px;
}

.email-folder-list {
    margin-left: 14px;
}

.email-folder-list.hidden {
    display: none;
}

.email-folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 8px;
    border-left: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    transition: background-color 0.15s ease;
}

.email-folder-item:hover {
    background-color: var(--bg-hover);
    border-left-color: var(--accent-primary);
}

.email-folder-item.active {
    background-color: var(--accent-primary-dim);
    border-left-color: var(--accent-primary);
    color: var(--text-primary);
}

.email-folder-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Main panel — overlay confined to the chat feed area, like the note editor
   (offset parent .feed-container; the chat input below stays usable).
   -------------------------------------------------------------------------- */

.email-panel {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
}

.email-panel.hidden {
    display: none;
}

/* Slim header above the message list: mailbox crumb + refresh/compose icons.
   (No panel-wide topbar or X button — the panel closes via Esc or when another
   sidebar surface is opened.) */
.email-list-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px 6px 10px;
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.email-crumb {
    flex: 1 1 auto;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Compact icon-only action buttons (compose/refresh/reply). */
.email-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    flex: 0 0 auto;
    background: none;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.email-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
    border-color: var(--border-color);
}

.email-icon-btn .ui-icon {
    width: 14px;
    height: 14px;
}

.email-panes {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.email-list-pane {
    display: flex;
    flex-direction: column;
    flex: 0 0 320px;
    min-width: 220px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.email-msg-list {
    flex: 1 1 auto;
}

.email-msg-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.email-msg-item:hover {
    background-color: var(--bg-hover);
}

.email-msg-item.active {
    background-color: var(--accent-primary-dim);
    border-left-color: var(--accent-primary);
}

.email-msg-row1,
.email-msg-row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.email-msg-from {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-msg-date {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    flex: 0 0 auto;
}

.email-msg-subject {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-msg-item.unseen .email-msg-from,
.email-msg-item.unseen .email-msg-subject {
    font-weight: 700;
    color: var(--text-primary);
}

.email-msg-attach {
    width: 11px;
    height: 11px;
    color: var(--text-muted);
    flex: 0 0 auto;
}

.email-msg-empty {
    padding: 16px;
    font-size: 11px;
    font-style: italic;
    color: var(--text-muted);
}

.email-load-older {
    margin: 8px;
    padding: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 3px;
    cursor: pointer;
}

.email-load-older.hidden {
    display: none;
}

/* Reading pane */

.email-read-pane {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.email-read-empty {
    margin: auto;
    font-size: 12px;
    font-style: italic;
    color: var(--text-muted);
}

.email-read-empty.hidden,
.email-read-content.hidden {
    display: none;
}

.email-read-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.email-read-headers-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.email-read-headers {
    flex: 1 1 auto;
    min-width: 0;
}

.email-read-subject {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.email-read-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.email-read-to {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-images-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.email-images-bar.hidden {
    display: none;
}

.email-images-bar button {
    padding: 2px 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 3px;
    cursor: pointer;
}

.email-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 14px;
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.email-attachments.hidden {
    display: none;
}

.email-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.email-attachment-chip .ui-icon {
    width: 10px;
    height: 10px;
}

.email-attachment-chip .dim {
    color: var(--text-muted);
}

/* The message body renders inside a sandboxed iframe; a light background is
   intentional (HTML email is designed for light mode). */
.email-body-frame {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    border: none;
    background: #ffffff; /* iframe content background, not themed UI */
}

.email-loading {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    z-index: 60;
}

.email-loading.hidden {
    display: none;
}

/* --------------------------------------------------------------------------
   Compose overlay (covers the panel panes; chat bar stays usable for improve)
   -------------------------------------------------------------------------- */

.email-compose-overlay {
    position: absolute;
    inset: 0;
    z-index: 55;
    display: flex;
    background: var(--bg-main);
}

.email-compose-overlay.hidden {
    display: none;
}

.email-compose-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 16px;
    gap: 8px;
}

.email-compose-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.email-compose-row label {
    flex: 0 0 60px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.email-compose-row input {
    flex: 1 1 auto;
    padding: 6px 8px;
    font-size: 12px;
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.email-compose-body {
    flex: 1 1 auto;
    min-height: 0;
    resize: none;
    padding: 10px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.email-compose-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}

/* Text action buttons (SEND / DISCARD) — sized to their label, unlike the
   fixed-square .note-action-btn. */
.email-text-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.email-text-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-main);
}

.email-text-btn.danger {
    background: none;
    color: var(--text-muted);
    border-color: var(--border-color);
}

.email-text-btn.danger:hover {
    color: var(--accent-error);
    background: color-mix(in srgb, var(--accent-error) 15%, transparent);
    border-color: var(--accent-error);
}

.email-text-btn .ui-icon {
    width: 12px;
    height: 12px;
}

/* --------------------------------------------------------------------------
   Settings tab bits (device-code display)
   -------------------------------------------------------------------------- */

.email-oauth-user-code {
    font-family: var(--font-mono);
    font-size: 22px;
    letter-spacing: 0.3em;
    color: var(--accent-primary);
    padding: 8px 0;
    user-select: all;
}

/* --------------------------------------------------------------------------
   Responsive: stack the panes on narrow viewports
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .email-panes {
        flex-direction: column;
    }
    .email-list-pane {
        flex: 0 0 45%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

/* ==== css/market.css ==== */
/* Market tracker — sidebar accordion rows + main-window panel.
   Reuses the notes accordion shell (sidebar-notes-group) for the sidebar;
   everything here is token-driven — no literal colors (13+ themes). Up/down
   moves use the theme-independent --indicator-online/offline pair. */

/* ---------------------------------------------------------------- sidebar */

.market-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 22px;
    font-size: 0.78rem;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

.market-item:hover {
    background: var(--bg-hover);
}

.market-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.market-item-price {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ panel */

.market-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.market-panel.hidden {
    display: none;
}

.market-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.market-crumb {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: var(--accent-primary);
}

.market-total {
    font-size: 1.05rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.market-header .market-icon-btn {
    align-self: center;
}

.market-header-spacer {
    flex: 1;
}

.market-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.market-icon-btn:hover {
    color: var(--accent-primary);
    border-color: var(--border-color);
    background: var(--bg-hover);
}

.market-icon-btn .ui-icon {
    width: 14px;
    height: 14px;
}

/* Change badges (shared by sidebar, table, header, detail) */
.market-change {
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
}

.market-change.up {
    color: var(--indicator-online);
}

.market-change.down {
    color: var(--indicator-offline);
}

.market-err {
    color: var(--accent-error, var(--indicator-offline));
    font-size: 0.7rem;
    cursor: help;
}

.market-watch {
    color: var(--text-muted);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
}

/* ------------------------------------------------------------------ table */

.market-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 12px 12px;
}

.market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.market-table th {
    text-align: left;
    padding: 6px 8px;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    font-weight: normal;
}

.market-table td {
    padding: 6px 8px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color-dim, var(--border-color));
    font-variant-numeric: tabular-nums;
}

.market-table tbody tr {
    cursor: pointer;
}

.market-table tbody tr:hover {
    background: var(--bg-hover);
}

.market-table tbody tr.active {
    background: var(--accent-primary-dim, var(--bg-hover));
}

.market-sym {
    display: block;
}

.market-sym-sub {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.market-row-edit {
    display: inline-flex;
    background: none;
    border: none;
    padding: 2px;
    color: var(--text-muted);
    cursor: pointer;
}

.market-row-edit:hover {
    color: var(--accent-primary);
}

.market-row-edit .ui-icon {
    width: 12px;
    height: 12px;
}

.market-empty {
    padding: 24px 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ----------------------------------------------------------------- detail */

.market-detail {
    border-top: 1px solid var(--border-color);
    padding: 8px 12px 10px;
}

.market-detail-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}

.market-detail-label {
    color: var(--text-primary);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
}

.market-detail-meta {
    flex: 1;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.market-ranges {
    display: inline-flex;
    gap: 4px;
}

.market-ranges button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.65rem;
    padding: 2px 8px;
    cursor: pointer;
    letter-spacing: 0.08em;
}

.market-ranges button:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.market-ranges button.active {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.market-chart {
    display: block;
    width: 100%;
    height: 180px;
}

.market-chart-status {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
}

/* --------------------------------------------- add/edit form + settings pop */

.market-form,
.market-settings-pop {
    position: absolute;
    top: 44px;
    right: 12px;
    z-index: 5;
    width: min(320px, calc(100% - 24px));
    background: var(--bg-panel);
    border: 1px solid var(--accent-primary);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 4px 18px var(--shadow-color, transparent);
}

.market-form.hidden,
.market-settings-pop.hidden {
    display: none;
}

.market-form-title {
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--accent-primary);
}

.market-form label,
.market-settings-pop label {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.market-form input,
.market-form select,
.market-settings-pop input {
    width: 100%;
    background: var(--bg-input, var(--bg-panel));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.78rem;
    padding: 4px 6px;
}

.market-form input:focus,
.market-form select:focus,
.market-settings-pop input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.market-form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.market-form-status {
    flex: 1;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.market-text-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    cursor: pointer;
}

.market-text-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.market-text-btn.danger:hover {
    border-color: var(--accent-error, var(--indicator-offline));
    color: var(--accent-error, var(--indicator-offline));
}

/* Phone: table sheds the gain + market-cap columns via CSS (qty/value stay) */
@media (max-width: 550px) {
    .market-table th:nth-child(6),
    .market-table td:nth-child(6),
    .market-table th:nth-child(7),
    .market-table td:nth-child(7) {
        display: none;
    }
}

/* ==== css/projects.css ==== */
/* ==========================================================================
   Projects — Sidebar accordion + project editor modal
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sidebar accordion — the collapsible header shell (group/toggle/chevron/label/
   count + body padding) is shared across all sidebar sections and lives in
   layout.css ("Sidebar accordion shell"). Only project-specific body styling
   (list, items, nested conversations, editor modal) lives here.
   -------------------------------------------------------------------------- */

.projects-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.projects-header-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.projects-new-btn {
    padding: 3px 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.06em;
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.projects-new-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-main);
}

.projects-new-btn.hidden {
    display: none;
}

.projects-list {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.projects-item {
    border-radius: 4px;
    border-left: 2px solid transparent;
    margin-bottom: 2px;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.projects-item.expanded {
    background-color: var(--accent-primary-dim);
    border-left-color: var(--accent-primary);
}

.projects-item.empty {
    cursor: default;
    color: var(--text-muted);
    font-size: 10px;
    font-style: italic;
    padding: 6px 8px;
}

.projects-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    cursor: pointer;
}

.projects-item:not(.expanded) .projects-item-row:hover {
    background-color: var(--bg-hover);
}

.projects-item-icon {
    font-size: 11px;
    flex: 0 0 auto;
}

.projects-item-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-primary);
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hover actions (assign chat / edit) */
.projects-item-action {
    flex: 0 0 auto;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    cursor: pointer;
    padding: 0 2px;
    transition:
        opacity 0.15s ease,
        color 0.15s ease;
}

.projects-item-row:hover .projects-item-action {
    opacity: 1;
}

.projects-item-action:hover {
    color: var(--accent-primary);
}

/* Nested conversation list of the expanded project */
.projects-conv-list {
    padding: 0 4px 6px 18px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.projects-conv-item {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-primary);
    padding: 4px 6px;
    border-radius: 3px;
    border-left: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.projects-conv-item:hover {
    background-color: var(--bg-hover);
    border-left-color: var(--accent-primary);
}

.projects-conv-item.active {
    background-color: var(--bg-hover);
    border-left-color: var(--accent-primary);
}

.projects-conv-item.new-chat {
    color: var(--accent-primary);
}

.projects-conv-item.empty {
    cursor: default;
    color: var(--text-muted);
    font-style: italic;
}

.projects-conv-item.empty:hover {
    background: none;
    border-left-color: transparent;
}

/* --------------------------------------------------------------------------
   Project editor modal
   -------------------------------------------------------------------------- */

.project-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.project-editor-overlay.hidden {
    display: none;
}

.project-editor-modal {
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
}

.project-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
}

.project-editor-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
}

.project-field-label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-top: 8px;
}

.project-field-label:first-child {
    margin-top: 0;
}

.project-field-input,
.project-field-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
}

.project-field-input:focus,
.project-field-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.project-field-textarea {
    resize: vertical;
    min-height: 60px;
}

.project-context-checks {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
}

.project-check-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.project-check-label input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--accent-primary);
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.project-editor-hint {
    margin-top: 10px;
    font-family: var(--font-mono);
    font-size: 9px;
    line-height: 1.5;
    color: var(--text-muted);
}

.project-editor-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
}

.project-editor-footer .hidden {
    display: none;
}

.project-editor-spacer {
    flex: 1 1 auto;
}

.project-save-status {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
}

.project-save-status.error {
    color: var(--accent-danger, #e05555);
}

/* ==== css/visuals.css ==== */
/* Selectable backgrounds & overlays. All background-related styling is isolated here so the
 * feature is easy to reason about and revert. Hosts are mounted by js/visuals/visual-layer.js.
 * Nothing here applies unless body.has-custom-bg is set (background != "none"). */

/* --- Fixed layer hosts (non-interactive) --- */
#visual-bg-host,
#visual-bg-scrim,
#visual-overlay-host {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
#visual-bg-host {
    z-index: 0;
    background-color: var(--bg-main);
}
#visual-bg-scrim {
    z-index: 1;
    background: #000;
    opacity: 0;
    transition: opacity 0.15s linear;
}
#visual-overlay-host {
    z-index: 9000;
}

/* Hosts are inert until a real background is chosen, so "none" is byte-for-byte today's look. */
body:not(.has-custom-bg) #visual-bg-host,
body:not(.has-custom-bg) #visual-bg-scrim,
body:not(.has-custom-bg) #visual-overlay-host {
    display: none;
}

.visual-canvas,
.visual-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.visual-media {
    object-fit: cover;
}

/* --- Surface translucency so the backdrop shows through. Bubbles, code blocks and other
 *     small panels keep their opaque backgrounds for readability; only the big full-bleed
 *     surfaces are thinned. color-mix needs a modern Chromium/WebView2 (fine on Win11). --- */
body.has-custom-bg {
    background-color: transparent;
    /* base.css frames the app with a 1px body border. The fixed bg canvas paints over
     * it while the UI lays out inside it, leaving a 1px canvas-only sliver at every
     * window edge (2-3 device px on mobile DPR). The frame is invisible under a custom
     * background anyway, so drop it and let the UI reach the true edge. */
    border: none;
}
body.has-custom-bg .app-container {
    z-index: 2;
}
body.has-custom-bg .chat-area {
    background-color: color-mix(in srgb, var(--bg-main) calc(var(--ui-opacity, 0.6) * 100%), transparent);
}
/* Sidebar, titlebar and message bubbles are the surfaces you READ text on, so they follow
 * --panel-opacity, decoupled from the chat backdrop above. Keeping them opaque while the
 * chat-area stays translucent is the whole point of the split. */
body.has-custom-bg .sidebar,
body.has-custom-bg .file-browser-sidebar,
body.has-custom-bg .debug-console {
    background-color: color-mix(
        in srgb,
        var(--bg-sidebar) calc(var(--opacity-sidebar, var(--panel-opacity, 0.72)) * 100%),
        transparent
    );
}
body.has-custom-bg .titlebar {
    background-color: color-mix(
        in srgb,
        var(--bg-header) calc(var(--opacity-header, var(--panel-opacity, 0.72)) * 100%),
        transparent
    );
}
/* Message bubbles: the theme's bubble tint (e.g. Crystal Palace's amber/blue) is kept as the
 * TOP background-image layer, over an opaque panel base scaled by --panel-opacity. Layering
 * instead of replacing preserves each theme's bubble identity while giving the text a solid
 * enough backing to read over the map. Coloured/opaque theme bubbles (no alpha) are unaffected
 * visually — the base just sits fully behind them. */
body.has-custom-bg .message.user .message-bubble {
    background-image:
        linear-gradient(var(--user-bubble-bg), var(--user-bubble-bg)),
        linear-gradient(
            color-mix(in srgb, var(--bg-panel) calc(var(--panel-opacity, 0.72) * 100%), transparent),
            color-mix(in srgb, var(--bg-panel) calc(var(--panel-opacity, 0.72) * 100%), transparent)
        );
}
body.has-custom-bg .message.assistant .message-bubble {
    background-image:
        linear-gradient(var(--assistant-bubble-bg), var(--assistant-bubble-bg)),
        linear-gradient(
            color-mix(in srgb, var(--bg-panel) calc(var(--panel-opacity, 0.72) * 100%), transparent),
            color-mix(in srgb, var(--bg-panel) calc(var(--panel-opacity, 0.72) * 100%), transparent)
        );
}
body.has-custom-bg .input-panel {
    background-color: color-mix(in srgb, var(--bg-footer) calc(var(--opacity-footer, 1) * 100%), transparent);
}
/* The "AI-CLIENT ONLINE" welcome card is the centerpiece of an empty chat — thin it too
 * so the chosen backdrop reads through instead of a solid slab. */
body.has-custom-bg .welcome-box {
    background-color: color-mix(in srgb, var(--bg-panel) calc(var(--ui-opacity, 0.6) * 100%), transparent);
}

/* --- Overlays --- */
.visual-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.visual-overlay-scanlines {
    mix-blend-mode: multiply;
}
.visual-overlay-vignette {
    mix-blend-mode: multiply;
}
.visual-overlay-bloom {
    mix-blend-mode: screen;
}
/* Icarus Dust: luminous motes on a transparent canvas; screen blend so they read as light
 * over whatever background/theme is underneath without ever darkening it. */
.visual-overlay-dust {
    mix-blend-mode: screen;
}

/* Flicker: a faint veil whose opacity flutters. --flicker-amount sets the veil strength;
 * animation-duration is set inline from the "speed" setting. */
.visual-overlay-flicker {
    background: rgba(255, 255, 255, calc(var(--flicker-amount, 0.12) * 0.5));
    mix-blend-mode: screen;
    animation-name: visual-flicker-kf;
    animation-duration: 0.25s;
    animation-iteration-count: infinite;
    animation-timing-function: steps(2, end);
}
@keyframes visual-flicker-kf {
    0% {
        opacity: 0.25;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.4;
    }
}

/* --- Visuals settings tab controls --- */
/* Vertical rhythm between manifest-built controls so e.g. a checkbox (which has no top label of
   its own) doesn't crowd the dropdown above it. */
.vis-control {
    margin-top: 12px;
}
.vis-control:first-child {
    margin-top: 0;
}
.vis-control .vis-range-val {
    color: var(--accent-primary);
    margin-left: 6px;
}
/* Data-source credits (schema/def `attribution`) — visible but unobtrusive. */
.vis-attribution {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 3px;
}
.vis-control input[type="color"] {
    width: 48px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.vis-icon-btn {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 4px 8px;
    cursor: pointer;
}
.vis-icon-btn:hover:not(:disabled) {
    border-color: var(--border-glow);
    color: var(--text-bright);
}
.vis-icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.vis-overlay-card {
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    margin-bottom: 8px;
    background: var(--bg-panel);
}
.vis-overlay-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.vis-overlay-card-btns {
    display: flex;
    gap: 4px;
}

.vis-media-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.vis-media-name {
    flex: 1;
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Workspace media picker modal */
.vis-picker-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.vis-picker-box {
    width: min(520px, 90vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-glow);
}
.vis-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}
.vis-picker-title {
    color: var(--accent-primary);
    font-weight: bold;
    letter-spacing: 1px;
}
.vis-picker-path {
    padding: 6px 12px;
    color: var(--accent-secondary);
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
}
.vis-picker-list {
    overflow-y: auto;
    padding: 6px;
}
.vis-picker-item {
    padding: 7px 10px;
    cursor: pointer;
    border: 1px solid transparent;
}
.vis-picker-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}
.vis-picker-dir {
    color: var(--accent-warning);
}

/* --- Performance Toggles: Disable Backdrop Blur --- */
body.no-backdrop-blur .settings-backdrop,
body.no-backdrop-blur .attachment-preview-container,
body.no-backdrop-blur .emoji-picker-popover,
body.no-backdrop-blur .lightbox-backdrop {
    backdrop-filter: none !important;
}

/* ==== css/responsive.css ==== */
/* ==========================================
   RESPONSIVE DESIGN & VERTICAL DISPLAY SUPPORT
   ========================================== */

/* Viewport Scroll Lock to prevent horizontal jiggling */
@media (max-width: 768px) {
    body,
    .titlebar,
    .app-container {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}

/* 1. Tablet & Moderate Vertical Screens Breakpoint (max-width: 900px) */
/* Handled via JS startup narrow-screen detection to default to collapsed, permitting full landscape expand-sliding */

/* 1.5 Intermediate width: collapse FILES/DEBUG/SETTINGS to icon-only BEFORE the
   prompt dropdown or status lamps give up any space (the triggers are the
   cheapest thing to shrink). Mobile (≤768px) takes over with its own compact
   circular treatment, so this band stops there. */
@media (max-width: 1100px) and (min-width: 769px) {
    .titlebar-controls-left .tb-btn-label {
        display: none;
    }
    .titlebar-controls-left .file-browser-btn,
    .titlebar-controls-left .debug-btn,
    .titlebar-controls-left .settings-btn {
        padding: 2px 7px;
    }
    .titlebar-controls-left {
        gap: 12px;
    }
}

/* 2. Narrow Portrait/Mobile Breakpoint (max-width: 768px) */
@media (max-width: 768px) {
    /* Titlebar modifications */
    .titlebar {
        padding: 0 6px;
        gap: 4px;
    }
    .app-title {
        letter-spacing: 0.5px;
        font-size: 9px;
    }
    .titlebar-drag-region {
        flex: 0 0 auto;
        min-width: 0;
        padding-left: 4px;
    }
    .titlebar-controls-left {
        /* Each group (.status-indicators / .titlebar-actions) is evenly spaced at 6px internally;
           this gap is the larger separation between the two groups. */
        gap: 12px;
        margin-left: 2px;
        margin-right: 0;
    }
    .titlebar-prompt-slot {
        justify-content: flex-end;
        flex: 1 1 0;
        margin-left: 0;
        margin-right: 0;
        padding-right: 8px;
        border-right: 1px solid var(--border-color);
    }
    .preset-container {
        flex: 1 1 auto;
        width: auto;
        max-width: 200px;
        min-width: 0;
    }
    .preset-dropdown {
        flex: 1 1 auto;
        padding: 2px 4px;
        font-size: 9px;
    }

    /* Hide pin button on narrow screens to allocate space to status lamps */
    #set-default-prompt-btn {
        display: none !important;
    }

    /* Compact circular status lamps — swap the dot for the identifying icon
       (status-coloured via currentColor), hide the text label. */
    .status-indicators .status-btn {
        width: 22px;
        height: 22px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        border-color: var(--border-color);
        position: relative;
        touch-action: none;
    }
    .status-indicators .status-lbl,
    .status-indicators .status-btn .status-dot {
        display: none;
    }
    .status-indicators .status-icon {
        display: inline-block;
        font-size: 13px;
    }

    /* Compact circular trigger buttons — show the SVG icon, hide the text label. */
    .titlebar-controls-left .tb-btn-label {
        display: none !important;
    }
    .titlebar-controls-left .file-browser-btn,
    .titlebar-controls-left .debug-btn,
    .titlebar-controls-left .settings-btn {
        width: 22px;
        height: 22px;
        padding: 0;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-left: 0;
        position: relative;
        touch-action: none;
    }
    .titlebar-controls-left .file-browser-btn .ui-icon,
    .titlebar-controls-left .debug-btn .ui-icon,
    .titlebar-controls-left .settings-btn .ui-icon {
        font-size: 14px;
    }

    /* Position the File Browser badge dot absolutely at the top-right of the circular button on mobile */
    .titlebar-controls-left .file-browser-btn .fb-trigger-dot {
        position: absolute;
        top: -2px;
        right: -2px;
        margin-left: 0;
        border: 1px solid var(--bg-darker);
        z-index: 5;
    }

    /* Expand tap targets for all compact circular buttons in titlebar to prevent missed touches */
    .status-indicators .status-btn::after,
    .titlebar-controls-left .file-browser-btn::after,
    .titlebar-controls-left .debug-btn::after,
    .titlebar-controls-left .settings-btn::after {
        content: "";
        position: absolute;
        top: -12px;
        bottom: -12px;
        left: -2px;
        right: -2px;
    }

    /* Footer changes */
    .input-panel {
        padding: 10px 12px;
    }

    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .voice-controls {
        width: 100%;
        justify-content: space-between;
    }

    .ptt-btn {
        flex-grow: 1;
        max-width: none;
    }

    .playback-controls {
        width: 100%;
        justify-content: flex-end;
    }

    #stop-playback-btn {
        width: 100%;
        justify-content: center;
    }

    /* Hide Panel Footer (metrics) on vertical to maximize screen real estate; the
       AUTO-SCROLL toggle (now in .playback-controls) stays hidden here as it always was */
    .panel-footer,
    .playback-controls .scroll-lock {
        display: none !important;
    }

    /* Full-screen overlay panels for File Browser, Diff Panel, and Debug Console on mobile */
    .file-browser-sidebar,
    .diff-panel,
    .debug-console {
        position: absolute !important;
        top: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-left: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 180 !important;
    }

    /* Hide the chat area behind the full-screen Debug Console or File Browser on mobile to prevent overlapping/bleeding text */
    .app-container:has(.debug-console:not(.hidden)) .chat-area,
    .app-container:has(.file-browser-sidebar:not(.hidden)) .chat-area,
    .app-container:has(.diff-panel:not(.hidden)) .chat-area {
        display: none !important;
    }

    /* The side-by-side expand handoff is pointless on a vertical screen */
    #dp-expand-btn {
        display: none !important;
    }
}

/* 3. Phone Portrait Breakpoint (max-width: 550px) */
@media (max-width: 550px) {
    /* Hide draggable titlebar title to maximize controls width */
    .titlebar-drag-region .app-title {
        display: none !important;
    }
    .titlebar-drag-region {
        display: none;
    }

    /* Condense dropdown more on tiny screens */
    .titlebar-prompt-slot {
        justify-content: flex-end;
        margin-left: 0;
        margin-right: 2px;
        padding-right: 6px;
    }
    .preset-container {
        width: auto;
        max-width: 200px;
        min-width: 0;
    }

    /* Slide-out Overlay Drawer Sidebar Pattern for Phone view */
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 200;
        height: 100%;
        width: 260px !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.7);
        background-color: var(--bg-sidebar);
    }

    .sidebar.collapsed {
        width: 0px !important;
        border-right: none !important;
        box-shadow: none !important;
        pointer-events: none;
    }

    /* Dim the chat behind the open drawer so the (intentionally translucent) sidebar stays
       readable over it; tapping the scrim closes the drawer (js/chat/events.js). Sits below
       the drawer (z 200) but above the chat area. */
    .sidebar:not(.collapsed) ~ .sidebar-scrim {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 150;
        background: rgba(0, 0, 0, 0.65);
    }

    /* Reclaim vertical space in the phone drawer — drop the ambient visualizer. */
    .sidebar-viz {
        display: none !important;
    }

    /* Show standard history item layouts in phone drawer when open */
    .sidebar:not(.collapsed) .sidebar-title,
    .sidebar:not(.collapsed) .sidebar-header .icon-btn,
    .sidebar:not(.collapsed) .sidebar-search input,
    .sidebar:not(.collapsed) .history-item-label,
    .sidebar:not(.collapsed) .history-item-tag,
    .sidebar:not(.collapsed) .history-separator {
        display: inline-block !important;
    }
    .sidebar:not(.collapsed) .sidebar-search {
        display: block !important;
        padding: 8px 12px !important;
    }
    .sidebar:not(.collapsed) .search-input-wrapper {
        display: flex !important;
        width: 100% !important;
    }
    .sidebar:not(.collapsed) .search-icon {
        position: absolute !important;
        left: 8px !important;
        font-size: 11px !important;
    }
    .sidebar:not(.collapsed) .history-item {
        justify-content: space-between !important;
        padding: 8px 16px !important;
        border-left: 2px solid transparent !important;
        border-bottom: none !important;
        margin: 0 !important;
    }
    .sidebar:not(.collapsed) .history-item-icon {
        margin-right: 10px !important;
        font-size: 12px !important;
    }
    .sidebar:not(.collapsed) .history-list {
        padding: 8px 0 !important;
    }
    .sidebar:not(.collapsed) .sidebar-header {
        justify-content: space-between !important;
        padding: 12px !important;
    }
    .sidebar:not(.collapsed) .sidebar-toggle-btn {
        transform: none !important;
    }

    /* Compact message bubbles for phone screen */
    .message-bubble {
        padding: 10px 12px;
        font-size: 11px;
    }
    .messages-feed {
        padding: 12px;
        gap: 12px;
    }
}

/* Prompt Sub-Tabs & Tool Grid Styles */
.prompt-tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.prompt-tab-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 6px 12px;
    font-size: 9px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-mono);
}

.prompt-tab-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.prompt-tab-btn.active {
    background-color: var(--accent-secondary-dim);
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
    box-shadow: 0 0 6px var(--accent-secondary-dim);
    text-shadow: 0 0 8px var(--accent-secondary-dim);
}

.prompt-tab-panel {
    display: none;
    flex-direction: column;
    gap: 15px;
}

.prompt-tab-panel.active {
    display: flex;
}

.prompt-tool-row {
    display: grid;
    grid-template-columns: 1fr 100px 120px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    background-color: var(--bg-panel);
    transition: background-color 0.15s ease;
}

.prompt-tool-row:hover {
    background-color: var(--bg-hover);
}

.prompt-tool-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.prompt-tool-name {
    font-size: 10px;
    font-weight: bold;
    color: var(--text-primary);
}

.prompt-tool-desc {
    font-size: 8.5px;
    color: var(--text-muted);
    line-height: 1.3;
    /* Always show the full description (wrapped); previously truncated to one line
       with an ellipsis that only expanded on row hover, which was confusing. */
    white-space: normal;
}

.prompt-tool-checkbox-cell {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- 1. Vertical Mobile Portrait Adaptation (width <= 768px AND height > 550px) --- */
@media (max-width: 768px) and (min-height: 551px) {
    /* Full-screen vertical stacked layout */
    .settings-drawer {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .drawer-header,
    .drawer-footer {
        flex-shrink: 0 !important;
    }

    .drawer-header {
        height: 48px;
        padding: 0 16px;
    }

    .drawer-header h2 {
        font-size: 11px;
        letter-spacing: 1px;
    }

    .close-drawer-btn {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .drawer-body {
        flex-direction: column !important;
        flex-grow: 1 !important;
        height: auto !important;
        overflow: hidden !important;
    }

    .drawer-tabs {
        width: 100% !important;
        height: 40px !important;
        flex-direction: row !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
    }

    .drawer-tabs::-webkit-scrollbar {
        display: none !important;
    }

    .tab-btn {
        padding: 0 16px !important;
        height: 100% !important;
        border-left: none !important;
        border-bottom: 2px solid transparent !important;
        display: inline-flex !important;
        align-items: center !important;
        white-space: nowrap !important;
        font-size: 9px !important;
        letter-spacing: 0.5px !important;
    }

    .tab-btn.active {
        border-left-color: transparent !important;
        border-bottom-color: var(--accent-primary) !important;
        background-color: rgba(0, 255, 102, 0.05) !important;
        text-shadow: 0 0 4px var(--accent-primary-dim);
    }

    .config-split {
        flex-direction: column !important;
    }

    .config-sidebar {
        width: 100% !important;
        height: auto !important;
        max-height: 180px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        padding: 8px 12px !important;
        flex-shrink: 0 !important;
    }

    .config-sidebar .panel-label {
        font-size: 8px !important;
        margin-bottom: 4px !important;
    }

    .config-sidebar .list-container {
        max-height: 110px !important;
        padding: 4px !important;
        gap: 3px !important;
    }

    .config-sidebar .preset-item {
        padding: 7px 10px !important;
        font-size: 9.5px !important;
        flex-shrink: 0 !important;
        line-height: 1.3 !important;
    }

    .config-sidebar .crud-toolbar {
        margin-top: 6px !important;
        gap: 4px !important;
    }

    .config-sidebar .crud-btn {
        padding: 4px 0 !important;
        font-size: 8px !important;
    }

    .config-main {
        flex-grow: 1 !important;
        padding: 12px 16px !important;
        gap: 12px !important;
        overflow-y: auto !important;
    }

    .config-scroll-area {
        padding: 12px 16px !important;
        gap: 12px !important;
    }

    .config-scroll-area h3,
    .tab-panel h3 {
        font-size: 10px !important;
        margin-bottom: 4px !important;
    }

    .form-group {
        gap: 4px !important;
    }

    .form-group label {
        font-size: 8px !important;
    }

    .form-group input[type="text"],
    .form-group input[type="number"],
    .form-group input[type="password"],
    .form-group select,
    .form-group textarea {
        padding: 6px 10px !important;
        font-size: 10.5px !important;
    }

    .form-group-row {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .input-action-row {
        gap: 6px !important;
    }

    .action-btn {
        padding: 0 10px !important;
        font-size: 8px !important;
    }

    .prompt-tabs-nav {
        gap: 4px !important;
        margin-bottom: 10px !important;
        padding-bottom: 6px !important;
    }

    .prompt-tab-btn {
        padding: 4px 8px !important;
        font-size: 8.5px !important;
        flex: 1;
        text-align: center;
    }

    .checkbox-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .slider-group,
    .vis-control {
        margin-bottom: 6px !important;
    }
    .slider-group input[type="range"],
    .vis-control input[type="range"] {
        margin: 6px 0 !important;
    }

    .tools-grid-header,
    .prompt-tool-row {
        grid-template-columns: 1fr 48px 72px !important;
        gap: 8px !important;
        padding: 8px 10px !important;
    }

    .tools-grid-header {
        font-size: 8px !important;
    }

    .prompt-tool-name {
        font-size: 9.5px !important;
    }
    .prompt-tool-desc {
        font-size: 8px !important;
    }

    .drawer-footer {
        height: 55px;
        padding: 0 16px;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 4px !important;
    }

    .save-status-feedback {
        font-size: 8.5px !important;
        text-align: center;
        line-height: 1;
    }

    .footer-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .footer-actions .btn {
        flex: 1;
        padding: 6px 0 !important;
        font-size: 9.5px !important;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* --- 2. Mobile Landscape & Short Viewports Adaptation (height <= 550px) --- */
@media (max-height: 550px) {
    /* Full-screen absolute canvas pinning to strictly respect dynamic viewport height */
    .settings-drawer {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .drawer-header,
    .drawer-footer {
        flex-shrink: 0 !important; /* LOCK headers and footers to strictly prevent height overflow bleeding */
    }

    .drawer-header {
        height: 38px !important;
        padding: 0 12px !important;
    }

    .drawer-header h2 {
        font-size: 9.5px !important;
        letter-spacing: 0.5px !important;
    }

    .close-drawer-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 9px !important;
    }

    /* Body flex-grow side-by-side with locked dimensions to contain sidebars inside screen */
    .drawer-body {
        display: flex !important;
        flex-direction: row !important;
        flex-grow: 1 !important;
        height: auto !important;
        overflow: hidden !important;
    }

    /* Highly compact vertical tabs bar */
    .drawer-tabs {
        width: 115px !important;
        flex-shrink: 0 !important;
        padding: 6px 0 !important;
        gap: 1px !important;
        border-right: 1px solid var(--border-color) !important;
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .tab-btn {
        padding: 6px 10px !important;
        font-size: 7.5px !important;
        border-left: 2px solid transparent !important;
        border-bottom: none !important;
        display: block !important;
        width: 100% !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    .tab-btn.active {
        border-left-color: var(--accent-primary) !important;
        border-bottom-color: transparent !important;
        background-color: var(--accent-primary-dim) !important;
    }

    /* Content panel flexbox container */
    .drawer-content {
        flex-grow: 1 !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    .tab-panel {
        height: 100% !important;
        overflow: hidden !important;
    }

    .tab-panel.active {
        display: block !important;
        height: 100% !important;
    }

    /* Split layout strictly respects height bounds */
    .config-split {
        display: flex !important;
        flex-direction: row !important;
        height: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    /* Force preset list vertical flex containment to fully reveal CRUD buttons */
    .config-sidebar {
        width: 140px !important;
        flex-shrink: 0 !important;
        border-right: 1px solid var(--border-color) !important;
        border-bottom: none !important;
        padding: 6px !important;
        height: 100% !important;
        max-height: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .config-sidebar .panel-label {
        font-size: 7.5px !important;
        margin-bottom: 3px !important;
    }

    .config-sidebar .list-container {
        flex-grow: 1 !important;
        flex-shrink: 1 !important; /* Force lists to contract to fit exactly inside screen */
        max-height: none !important;
        height: auto !important;
        overflow-y: auto !important;
        gap: 2px !important;
        padding: 3px !important;
    }

    .config-sidebar .preset-item {
        padding: 5px 8px !important;
        font-size: 8.5px !important;
        line-height: 1.2 !important;
        flex-shrink: 0 !important;
    }

    /* CRUD toolbar is securely anchored at the absolute bottom of sidebar */
    .config-sidebar .crud-toolbar {
        margin-top: 6px !important;
        gap: 3px !important;
        flex-shrink: 0 !important; /* Crucial: toolbar never shrinks or clips */
    }

    .config-sidebar .crud-btn {
        padding: 4px 0 !important;
        font-size: 7.5px !important;
        border-radius: 2px !important;
    }

    /* Details edit form container */
    .config-main {
        flex-grow: 1 !important;
        padding: 8px 12px !important;
        gap: 10px !important;
        overflow-y: auto !important;
        height: 100% !important;
    }

    .config-scroll-area {
        padding: 8px 12px !important;
        gap: 10px !important;
        overflow-y: auto !important;
        height: 100% !important;
    }

    .config-scroll-area h3,
    .tab-panel h3 {
        font-size: 9px !important;
        margin-bottom: 3px !important;
    }

    .config-scroll-area .divider,
    .tab-panel .divider {
        margin: 6px 0 !important;
    }

    /* Scaling Form group controls for landscape compact view */
    .form-group {
        gap: 3px !important;
    }

    .form-group label {
        font-size: 7.5px !important;
    }

    .form-group input[type="text"],
    .form-group input[type="number"],
    .form-group input[type="password"],
    .form-group select,
    .form-group textarea {
        padding: 4px 8px !important;
        font-size: 9.5px !important;
        border-radius: 3px !important;
    }

    @media (max-width: 900px) {
        .form-group-row {
            flex-direction: column !important;
            gap: 8px !important;
        }
    }

    .input-action-row {
        gap: 4px !important;
    }

    .action-btn {
        padding: 0 8px !important;
        font-size: 7.5px !important;
    }

    /* Prompt Identity sub-tab buttons horizontal row */
    .prompt-tabs-nav {
        gap: 3px !important;
        margin-bottom: 8px !important;
        padding-bottom: 4px !important;
    }

    .prompt-tab-btn {
        padding: 3px 6px !important;
        font-size: 8px !important;
        flex: 1;
        text-align: center;
    }

    /* Multi-column grid adjustments */
    .checkbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)) !important;
        gap: 6px !important;
    }

    .slider-group,
    .vis-control {
        margin-bottom: 4px !important;
    }
    .slider-group input[type="range"],
    .vis-control input[type="range"] {
        margin: 3px 0 !important;
    }

    /* Tools matrix padding optimizations */
    .tools-grid-header,
    .prompt-tool-row {
        grid-template-columns: 1fr 44px 68px !important;
        gap: 6px !important;
        padding: 5px 6px !important;
    }

    .prompt-tool-name {
        font-size: 8.5px !important;
    }
    .prompt-tool-desc {
        font-size: 7.5px !important;
    }

    /* Securely docked compact footer bar containing Save/Apply button */
    .drawer-footer {
        height: 42px !important;
        padding: 0 12px !important;
    }

    .save-status-feedback {
        font-size: 8px !important;
    }

    .footer-actions {
        display: flex;
        gap: 6px;
    }

    .footer-actions .btn {
        padding: 4px 12px !important;
        font-size: 8.5px !important;
        height: 24px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        letter-spacing: 0.2px !important;
    }

    /* --- Main Screen Landscape Usability Adjustments --- */

    /* 1. Redefine titlebar height variable for automatic dynamic resizing of layouts */
    :root {
        --titlebar-height: 32px !important;
    }

    /* 2. Hide latency stats and auto-scroll checkbox on short viewports */
    .panel-footer,
    .playback-controls .scroll-lock {
        display: none !important;
    }

    /* 2b. The whole sidebar becomes ONE vertical scroll column. On tall screens each
       expanded accordion flexes to fill the sidebar and scrolls internally; at phone-
       landscape heights that leaves each list a sliver, so instead let lists render
       full height and scroll the sidebar itself. Gated on viewport height — desktop
       keeps the no-scroll push-down behavior. */
    .sidebar {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .sidebar > * {
        flex-shrink: 0;
    }

    .sidebar-history-group,
    .sidebar-schedule-group,
    .sidebar-projects-group,
    .sidebar-notes-group {
        flex: 0 0 auto !important;
    }

    .history-list,
    .schedule-content,
    .projects-list,
    .notes-list {
        flex-grow: 0 !important;
        overflow-y: visible !important;
        max-height: none !important;
    }

    /* No room for the ambient viz disc on short viewports. */
    .sidebar-viz {
        display: none !important;
    }

    /* 3. Compact Titlebar layout */
    .titlebar {
        padding: 0 8px !important;
        gap: 6px !important;
    }

    /* Hide draggable app title space in titlebar to maximize control width */
    .titlebar-drag-region {
        display: none !important;
    }

    .titlebar-prompt-slot {
        justify-content: flex-start !important;
        margin-left: 0 !important;
        margin-right: 4px !important;
        flex: 1 1 auto !important;
    }

    .preset-container {
        max-width: 140px !important;
    }

    #set-default-prompt-btn {
        display: none !important; /* Hide default pin button */
    }

    /* Circular compact status indicators in titlebar — icon replaces the dot */
    .status-indicators .status-btn {
        width: 18px !important;
        height: 18px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        justify-content: center !important;
        border-color: var(--border-color) !important;
        position: relative !important;
        touch-action: none !important;
    }
    .status-indicators .status-lbl,
    .status-indicators .status-btn .status-dot {
        display: none !important;
    }
    .status-indicators .status-icon {
        display: inline-block !important;
        font-size: 11px !important;
    }

    /* Circular settings/debug trigger buttons in titlebar */
    .titlebar-controls-left .tb-btn-label {
        display: none !important;
    }
    .titlebar-controls-left .file-browser-btn,
    .titlebar-controls-left .debug-btn,
    .titlebar-controls-left .settings-btn {
        width: 18px !important;
        height: 18px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-left: 0 !important;
        position: relative !important;
        touch-action: none !important;
    }
    .titlebar-controls-left .file-browser-btn .ui-icon,
    .titlebar-controls-left .debug-btn .ui-icon,
    .titlebar-controls-left .settings-btn .ui-icon {
        font-size: 12px !important;
    }
    /* Position the File Browser badge dot absolutely at the top-right of the tiny 18px circular button on short screens */
    .titlebar-controls-left .file-browser-btn .fb-trigger-dot {
        position: absolute !important;
        top: -3px !important;
        right: -3px !important;
        margin-left: 0 !important;
        border: 1px solid var(--bg-darker) !important;
        z-index: 5 !important;
    }
    /* Larger separation between the status and action groups (each is 6px internally). */
    .titlebar-controls-left {
        gap: 12px !important;
    }

    /* Expand tap targets for all compact circular buttons in titlebar on short screens */
    .status-indicators .status-btn::after,
    .titlebar-controls-left .file-browser-btn::after,
    .titlebar-controls-left .debug-btn::after,
    .titlebar-controls-left .settings-btn::after {
        content: "" !important;
        position: absolute !important;
        top: -12px !important;
        bottom: -12px !important;
        left: -2px !important;
        right: -2px !important;
    }

    /* 4. Compact message feed and spacing */
    .messages-feed {
        padding: 8px 12px !important;
        gap: 8px !important;
    }

    .message {
        margin-bottom: 4px !important;
    }

    .message-bubble {
        padding: 6px 10px !important;
        font-size: 11px !important;
        line-height: 1.35 !important;
        border-radius: 4px !important;
    }

    .message.assistant .message-bubble {
        padding-left: 10px !important;
    }

    .message-header {
        font-size: 8px !important;
        margin-bottom: 2px !important;
    }

    /* Welcome display adjustments */
    .system-welcome {
        max-width: 400px !important;
    }
    .welcome-box {
        padding: 8px 12px !important;
    }
    .welcome-box h2 {
        font-size: 10px !important;
        margin-bottom: 4px !important;
    }
    .welcome-box p {
        font-size: 7.5px !important;
    }
    .welcome-box .ascii-art {
        font-size: 6px !important;
        line-height: 1.1 !important;
        margin-top: 4px !important;
    }

    /* 5. Highly condensed message input panel */
    .input-panel {
        padding: 6px 12px !important;
        gap: 4px !important;
    }

    .panel-header {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .voice-controls,
    .playback-controls {
        gap: 8px !important;
    }

    .toggle-container {
        font-size: 7.5px !important;
    }

    .toggle-slider {
        width: 24px !important;
        height: 12px !important;
        border-radius: 6px !important;
        margin-right: 4px !important;
    }

    .toggle-slider::before {
        width: 8px !important;
        height: 8px !important;
        left: 1px !important;
        top: 1px !important;
    }

    .toggle-container input:checked + .toggle-slider::before {
        transform: translateX(12px) !important;
    }

    .ptt-btn {
        padding: 2px 8px !important;
        font-size: 7.5px !important;
        border-radius: 2px !important;
    }

    .control-btn {
        padding: 2px 6px !important;
        font-size: 7.5px !important;
        border-radius: 2px !important;
    }

    /* Input textarea and send buttons */
    .input-row {
        gap: 8px !important;
    }

    .input-row textarea {
        min-height: 28px !important;
        padding: 5px 8px !important;
        font-size: 11px !important;
        border-radius: 3px !important;
    }

    .send-btn {
        height: 28px !important;
        padding: 4px 10px !important;
        font-size: 9px !important;
        border-radius: 3px !important;
    }
}

/* Adjust grid container to scale when sidebar opens */
@media (min-width: 769px) {
    .app-container {
        display: flex;
        flex-direction: row;
        overflow: hidden;
    }

    .chat-area {
        flex: 1;
        min-width: 0;
    }
}
