@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ════════════════════════════════════════════════════════════════
   LS NEXUS 2.0 — "LS Monogram" Premium Design System
   Obsidian dark · Cream light · Violet → Indigo → Cyan accent
   Multi-layer atmosphere · Glassmorphism · Micro-interactions
   ════════════════════════════════════════════════════════════════ */

/* ── CSS Reset ────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; height: 100%; }

/* ════════════════════════════════════════════════════════════════
   TIER 1 — Primitive Tokens
   ════════════════════════════════════════════════════════════════ */
:root {
    /* ── Brand hues ── */
    --hue-accent: 245;
    --hue-accent-2: 265;
    --hue-accent-3: 200;

    /* ── Type roles ── */
    --font-display: 'Space Grotesk', sans-serif;
    --font-sans: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

    /* ── Modular type scale (1.25 ratio) ── */
    --fs-3xl: clamp(2.4rem, 5.5vw, 3.2rem);
    --fs-2xl: 1.95rem;
    --fs-xl: 1.56rem;
    --fs-lg: 1.25rem;
    --fs-md: 1rem;
    --fs-base: 0.875rem;
    --fs-sm: 0.8rem;
    --fs-xs: 0.72rem;
    --fs-2xs: 0.64rem;

    /* ── Line-height tokens ── */
    --lh-tight: 1.2;
    --lh-compact: 1.35;
    --lh-body: 1.5;
    --lh-prose: 1.7;

    /* ── Font-weight tokens ── */
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* ── Letter-spacing tokens ── */
    --ls-tight: -0.02em;
    --ls-normal: -0.006em;
    --ls-wide: 0.04em;
    --ls-ultrawide: 0.12em;

    /* ── Spacing scale ── */
    --space-0: 0;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* ── Radii ── */
    --radius-xs: 5px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* ── Motion language ── */
    --ease-quiet: cubic-bezier(0.32, 0.72, 0, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.2, 0.9, 0.3, 1.3);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --dur-instant: 0.08s;
    --dur-fast: 0.15s;
    --dur: 0.22s;
    --dur-slow: 0.38s;
    --dur-glacial: 28s;
    --spring: 0.42s cubic-bezier(0.32, 0.72, 0, 1);

    /* ── Sizing ── */
    --costing-w: 420px;
    --rail-w: 236px;
    --inspector-w: 264px;
}

/* ════════════════════════════════════════════════════════════════
   TIER 2 — Semantic Tokens (DARK "Obsidian" — default)
   ════════════════════════════════════════════════════════════════ */
:root {
    /* ── Surface elevations ── */
    --color-surface-ground: #050508;
    --color-surface-elevated: #0B0B12;
    --color-surface-overlay: #111118;
    --color-surface-sunken: #030305;
    --color-surface-hover: #16161F;

    /* ── Borders ── */
    --color-border-subtle: rgba(255, 255, 255, 0.06);
    --color-border-default: rgba(255, 255, 255, 0.10);
    --color-border-strong: rgba(255, 255, 255, 0.16);
    --color-border-accent: rgba(139, 92, 246, 0.40);

    /* ── Text ── */
    --color-text-primary: #EDEDF0;
    --color-text-secondary: #A0A0AB;
    --color-text-tertiary: #6B6B78;
    --color-text-disabled: #484852;

    /* ── Accent ── */
    --color-accent-text: #A78BFA;
    --color-accent-fill: #7C3AED;
    --color-accent-hover: #6D28D9;
    --color-accent-pressed: #5B21B6;
    --color-accent-soft: rgba(139, 92, 246, 0.14);
    --color-accent-glow: rgba(139, 92, 246, 0.28);

    /* ── Status ── */
    --color-success: #34D399;
    --color-success-soft: rgba(52, 211, 153, 0.13);
    --color-warning: #FBBF24;
    --color-warning-soft: rgba(251, 191, 36, 0.13);
    --color-error: #F87171;
    --color-error-soft: rgba(248, 113, 113, 0.13);
    --color-info: #38BDF8;
    --color-info-soft: rgba(56, 189, 248, 0.13);

    /* ── Shadows (dark) ── */
    --shadow-micro: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-elevated: 0 2px 4px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 4px 12px rgba(0, 0, 0, 0.45), 0 20px 56px rgba(0, 0, 0, 0.6);
    --shadow-accent: 0 4px 16px rgba(124, 58, 237, 0.35), 0 8px 32px rgba(99, 102, 241, 0.2);
    --ring-top: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --ring-bottom: inset 0 -1px 0 rgba(0, 0, 0, 0.2);

    /* ── Gradients ── */
    --brand-grad: linear-gradient(120deg, #8B5CF6 0%, #6366F1 50%, #38BDF8 100%);
    --brand-grad-vertical: linear-gradient(180deg, #8B5CF6 0%, #6366F1 50%, #38BDF8 100%);
    --brand-orb-grad: linear-gradient(150deg, #8B5CF6 0%, #7C6CF6 40%, #6366F1 72%, #4F46E5 100%);
    --brand-ls-grad: linear-gradient(135deg, #7C3AED 0%, #6366F1 100%);
    --brand-nexus-grad: linear-gradient(110deg, #8B5CF6 0%, #6366F1 42%, #38BDF8 100%);
    --accent-grad: var(--brand-grad);

    /* ── Legacy aliases (main.js compatibility) ── */
    --ground: var(--color-surface-ground);
    --ground-grain: var(--color-surface-elevated);
    --panel: var(--color-surface-elevated);
    --panel-2: var(--color-surface-overlay);
    --surface-1: var(--color-surface-elevated);
    --surface-2: var(--color-surface-overlay);
    --hover: rgba(255, 255, 255, 0.07);
    --line: var(--color-border-default);
    --line-strong: var(--color-border-strong);
    --text: var(--color-text-primary);
    --text-main: var(--color-text-primary);
    --text-dim: var(--color-text-secondary);
    --text-faint: var(--color-text-tertiary);
    --accent: var(--color-accent-text);
    --accent-fill: var(--color-accent-fill);
    --accent-press: var(--color-accent-pressed);
    --accent-soft: var(--color-accent-soft);
    --accent-line: var(--color-border-accent);
    --accent-ink: #FFFFFF;
    --cyan: var(--color-info);
    --purple: #A78BFA;
    --green: var(--color-success);
    --red: var(--color-error);
    --amber: var(--color-warning);
    --green-soft: var(--color-success-soft);
    --red-soft: var(--color-error-soft);
    --amber-soft: var(--color-warning-soft);
    --cyan-soft: var(--color-info-soft);
    --purple-soft: rgba(167, 139, 250, 0.13);
    --bg-deep: var(--color-surface-ground);
    --bg-card: var(--color-surface-elevated);
    --glass: var(--color-surface-elevated);
    --border-subtle: var(--color-border-subtle);
    --border-glow: var(--color-border-accent);
    --shadow-card: var(--shadow-card);
    --shadow-1: var(--shadow-micro);
    --shadow-2: var(--shadow-elevated);
    --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px;

    color-scheme: dark;
}

/* ════════════════════════════════════════════════════════════════
   LIGHT Theme — "Cream"
   ════════════════════════════════════════════════════════════════ */
[data-theme="light"] {
    --color-surface-ground: #FCFCFA;
    --color-surface-elevated: #FFFFFF;
    --color-surface-overlay: #F8F8F5;
    --color-surface-sunken: #F2F2EE;
    --color-surface-hover: #F0F0EA;

    --color-border-subtle: rgba(26, 26, 24, 0.06);
    --color-border-default: rgba(26, 26, 24, 0.10);
    --color-border-strong: rgba(26, 26, 24, 0.16);
    --color-border-accent: rgba(139, 92, 246, 0.30);

    --color-text-primary: #1A1A18;
    --color-text-secondary: #5E5E5A;
    --color-text-tertiary: #94948E;
    --color-text-disabled: #C0C0BA;

    --color-accent-text: #7C3AED;
    --color-accent-fill: #6366F1;
    --color-accent-hover: #4F46E5;
    --color-accent-pressed: #4338CA;
    --color-accent-soft: rgba(99, 102, 241, 0.09);
    --color-accent-glow: rgba(99, 102, 241, 0.18);

    --color-success: #0F8A5F;
    --color-success-soft: rgba(15, 138, 95, 0.10);
    --color-warning: #B7791F;
    --color-warning-soft: rgba(183, 121, 31, 0.10);
    --color-error: #D6453D;
    --color-error-soft: rgba(214, 69, 61, 0.10);
    --color-info: #0E7490;
    --color-info-soft: rgba(14, 116, 144, 0.10);

    --shadow-micro: 0 1px 1px rgba(26, 26, 24, 0.04);
    --shadow-card: 0 1px 2px rgba(26, 26, 24, 0.04), 0 4px 10px rgba(26, 26, 24, 0.06);
    --shadow-elevated: 0 1px 2px rgba(26, 26, 24, 0.05), 0 6px 16px rgba(26, 26, 24, 0.07);
    --shadow-pop: 0 12px 40px rgba(26, 26, 24, 0.16), 0 4px 12px rgba(26, 26, 24, 0.08);
    --shadow-accent: 0 4px 14px rgba(99, 102, 241, 0.20), 0 8px 28px rgba(139, 92, 246, 0.12);
    --ring-top: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --ring-bottom: inset 0 -1px 0 rgba(0, 0, 0, 0.04);

    --brand-orb-grad: linear-gradient(150deg, #8B5CF6 0%, #7C6CF6 40%, #6366F1 72%, #4F46E5 100%);
    --brand-ls-grad: linear-gradient(135deg, #7C3AED 0%, #6366F1 100%);
    --brand-nexus-grad: linear-gradient(110deg, #8B5CF6 0%, #6366F1 42%, #38BDF8 100%);

    --hover: rgba(26, 26, 24, 0.05);
    --accent-ink: #FFFFFF;
    --purple: #7C3AED;
    --purple-soft: rgba(124, 58, 237, 0.10);

    /* Re-map legacy aliases for light */
    --ground: var(--color-surface-ground);
    --panel: var(--color-surface-elevated);
    --panel-2: var(--color-surface-overlay);
    --surface-1: var(--color-surface-sunken);
    --surface-2: var(--color-surface-elevated);
    --line: var(--color-border-default);
    --line-strong: var(--color-border-strong);
    --text: var(--color-text-primary);
    --text-main: var(--color-text-primary);
    --text-dim: var(--color-text-secondary);
    --text-faint: var(--color-text-tertiary);
    --accent: var(--color-accent-text);
    --accent-fill: var(--color-accent-fill);
    --accent-press: var(--color-accent-pressed);
    --accent-soft: var(--color-accent-soft);
    --accent-line: var(--color-border-accent);
    --cyan: var(--color-info);
    --green: var(--color-success);
    --red: var(--color-error);
    --amber: var(--color-warning);
    --green-soft: var(--color-success-soft);
    --red-soft: var(--color-error-soft);
    --amber-soft: var(--color-warning-soft);
    --cyan-soft: var(--color-info-soft);
    --bg-deep: var(--color-surface-ground);
    --bg-card: var(--color-surface-elevated);
    --glass: var(--color-surface-elevated);
    --border-subtle: var(--color-border-subtle);
    --border-glow: var(--color-border-accent);
    --shadow-card: var(--shadow-card);
    --shadow-1: var(--shadow-micro);
    --shadow-2: var(--shadow-elevated);

    color-scheme: light;
}

/* ════════════════════════════════════════════════════════════════
   GLOBAL STYLES
   ════════════════════════════════════════════════════════════════ */
html {
    transition: background-color 0.4s var(--ease-out);
}
body {
    font-family: var(--font-sans);
    background: var(--color-surface-ground);
    color: var(--color-text-primary);
    min-height: 100vh; height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-variant-numeric: tabular-nums;
    letter-spacing: var(--ls-normal);
    line-height: var(--lh-body);
    font-size: var(--fs-base);
    display: flex; flex-direction: column;
    transition: background-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

/* ── Selection ── */
::selection { background: var(--color-accent-soft); color: var(--color-accent-text); }
code::selection, pre::selection { background: var(--color-info-soft); color: var(--color-info); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }
::-webkit-scrollbar-corner { background: transparent; }

/* ── Focus visibility (a11y) ── */
:focus-visible { outline: 2px solid var(--color-accent-text); outline-offset: 2px; border-radius: var(--radius-xs); }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }

/* ── Figures / codes / money → mono ── */
.card-value, .cm-stat-value, .kb-count, .complete-stat-value,
.rc-stat b, .download-version, .proc-meta, .td-mono {
    font-variant-numeric: tabular-nums;
}

/* ════════════════════════════════════════════════════════════════
   BACKGROUND ATMOSPHERE — Multi-layer
   ════════════════════════════════════════════════════════════════ */

/* Layer 1: Ambient orbs — slow drift */
.bg-ambient {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(900px 500px at 110% -15%, rgba(99, 102, 241, 0.13), transparent 60%),
        radial-gradient(700px 450px at -10% 105%, rgba(139, 92, 246, 0.10), transparent 55%),
        radial-gradient(600px 400px at 50% 50%, rgba(56, 189, 248, 0.06), transparent 65%);
    animation: ambientDrift 28s ease-in-out infinite;
}
[data-theme="light"] .bg-ambient {
    background:
        radial-gradient(900px 500px at 110% -15%, rgba(99, 102, 241, 0.07), transparent 60%),
        radial-gradient(700px 450px at -10% 105%, rgba(139, 92, 246, 0.05), transparent 55%),
        radial-gradient(600px 400px at 50% 50%, rgba(56, 189, 248, 0.04), transparent 65%);
}

/* Layer 2: Dot grid — subtle tech texture */
.bg-grid {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image: radial-gradient(circle, var(--color-border-subtle) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.5;
}
[data-theme="light"] .bg-grid { opacity: 0.7; }

/* Layer 3: Grain overlay — breaks digital flatness */
.bg-grain {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    opacity: 0.022;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ════════════════════════════════════════════════════════════════
   GLASS PANEL — consistent blur across all surfaces
   ════════════════════════════════════════════════════════════════ */
.glass-panel {
    background: var(--color-surface-elevated);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--ring-top), var(--shadow-card);
    transition: border-color var(--dur) var(--ease-quiet), box-shadow var(--dur) var(--ease-quiet);
}
.glass-panel:hover { border-color: var(--color-border-strong); }

/* ── Section headings ── */
h2 {
    font-family: var(--font-display); font-size: var(--fs-lg); font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-tight); line-height: var(--lh-tight);
    display: flex; align-items: center; gap: var(--space-2);
    padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border-default);
    margin-bottom: var(--space-4); color: var(--color-text-primary);
}
h2 svg { color: var(--color-accent-text); }

/* ════════════════════════════════════════════════════════════════
   LOGO MARK — "LS Monogram"
   3D extruded LS monogram with brand gradient
   ════════════════════════════════════════════════════════════════ */
.logo-mark {
    position: relative; overflow: hidden;
    width: 34px; height: 34px;
    background: var(--brand-orb-grad);
    border-radius: 12px;
    box-shadow:
        var(--ring-top),
        inset 0 -3px 8px rgba(40, 20, 80, 0.35),
        0 4px 14px var(--color-accent-glow),
        0 6px 20px rgba(124, 58, 237, 0.28);
    display: flex; align-items: center; justify-content: center;
    color: #fff; line-height: 1; user-select: none; flex-shrink: 0;
    animation: logoGlow 6s ease-in-out infinite;
}
.logo-mark::after {
    content: ''; position: absolute; left: -25%; right: -25%; top: -60%; height: 95%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    border-radius: 50%; transform: rotate(-8deg); pointer-events: none;
}
.logo-mark svg { position: relative; z-index: 1; width: 62%; height: 62%; }

/* Brand text gradients */
.logo-ls {
    background: var(--brand-ls-grad);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.logo-nexus {
    background: var(--brand-nexus-grad); background-size: 220% auto;
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    animation: brandShimmer 7s ease-in-out infinite;
}

/* ════════════════════════════════════════════════════════════════
   WORKSPACE SHELL
   ════════════════════════════════════════════════════════════════ */
.app-shell {
    flex: 1; min-height: 0;
    display: grid; grid-template-columns: var(--rail-w) 1fr; grid-template-rows: 1fr;
    position: relative; z-index: 1;
}
.shell-main {
    display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative;
}

/* ════════════════════════════════════════════════════════════════
   LEFT RAIL — Navigation sidebar
   ════════════════════════════════════════════════════════════════ */
.rail {
    display: flex; flex-direction: column; gap: var(--space-1);
    background: var(--color-surface-overlay);
    border-right: 1px solid var(--color-border-default);
    padding: var(--space-3) var(--space-3);
    min-height: 0; overflow-y: auto;
    position: relative; z-index: 2;
}
.rail-brand {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-1) var(--space-2) var(--space-4);
}
.rail-brand .logo-mark { width: 30px; height: 30px; border-radius: 10px; }
.rail-brand .rb-text b {
    font-family: var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-bold);
    letter-spacing: var(--ls-tight); display: block; line-height: var(--lh-tight);
}
.rail-brand .rb-text small {
    font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-ultrawide);
    text-transform: uppercase; color: var(--color-text-tertiary);
}

/* Rail section labels */
.rail-section {
    font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-ultrawide);
    text-transform: uppercase; color: var(--color-text-tertiary);
    padding: var(--space-4) var(--space-2) var(--space-1);
}

/* Rail nav items */
.rail-item {
    position: relative; display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
    border: 1px solid transparent; background: transparent;
    width: 100%; text-align: left; cursor: pointer;
    color: var(--color-text-secondary); font-family: var(--font-sans);
    font-size: var(--fs-sm); font-weight: var(--fw-medium);
    transition: background var(--dur-fast) var(--ease-quiet),
                color var(--dur-fast) var(--ease-quiet),
                transform var(--dur-fast) var(--ease-quiet);
}
.rail-item svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.8; }
.rail-item::before {
    content: ''; position: absolute; left: -0.7rem; top: 50%; transform: translateY(-50%) scaleY(0);
    width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--brand-grad-vertical);
    transition: transform var(--dur) var(--ease-spring); opacity: 0;
}
.rail-item:hover { background: var(--hover); color: var(--color-text-primary); }
.rail-item.active {
    background: var(--color-accent-soft); color: var(--color-accent-text); font-weight: var(--fw-semibold);
}
.rail-item.active::before { transform: translateY(-50%) scaleY(1); opacity: 1; }
.rail-item.active svg { color: var(--color-accent-text); }

.rail-spacer { flex: 1; }
.rail-foot {
    display: flex; flex-direction: column; gap: var(--space-1);
    padding-top: var(--space-3); border-top: 1px solid var(--color-border-default);
}

/* Theme toggle icons */
.theme-toggle { position: relative; }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="light"] .theme-toggle .sun { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }

/* ════════════════════════════════════════════════════════════════
   TOP BAR — Header
   ════════════════════════════════════════════════════════════════ */
header.topbar {
    position: relative; z-index: 5; flex-shrink: 0;
    display: flex; align-items: center; gap: var(--space-4);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--color-border-default);
    background: color-mix(in srgb, var(--color-surface-overlay) 82%, transparent);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
}
.tb-crumb {
    font-size: var(--fs-sm); color: var(--color-text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-crumb b { color: var(--color-text-primary); font-weight: var(--fw-semibold); }

/* Search bar */
.tb-search {
    flex: 1; max-width: 380px; display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm); background: var(--color-surface-sunken);
    color: var(--color-text-tertiary); cursor: text;
    font-size: var(--fs-sm); transition: all var(--dur) var(--ease-quiet);
}
.tb-search:hover { border-color: var(--color-border-accent); color: var(--color-text-secondary); }
.tb-search:focus-within {
    border-color: var(--color-accent-text);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
    color: var(--color-text-primary);
}
.tb-search svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Keyboard shortcut badge */
.tb-kbd {
    font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    color: var(--color-text-secondary); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-xs); padding: 0.1rem 0.36rem;
    background: var(--color-surface-elevated); white-space: nowrap;
}
.tb-search .tb-kbd { margin-left: auto; }

.tb-right { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.tb-cta { white-space: nowrap; }

/* Mobile rail toggle */
.rail-toggle {
    display: none; background: var(--color-surface-sunken); border: 1px solid var(--color-border-default);
    color: var(--color-text-secondary); border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-2); cursor: pointer;
}
.rail-scrim { display: none; }

/* ── System status pill ── */
.system-status {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--color-surface-sunken); border-radius: var(--radius-pill);
    border: 1px solid var(--color-border-default);
    font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary);
    font-weight: var(--fw-medium);
}
.status-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--color-warning);
    box-shadow: 0 0 0 3px var(--color-warning-soft);
    animation: statusPulse 3s ease-in-out infinite;
}
.status-dot.connected { background: var(--color-success); box-shadow: 0 0 0 3px var(--color-success-soft); }
.status-dot.disconnected { background: var(--color-error); box-shadow: 0 0 0 3px var(--color-error-soft); }

/* ── Icon buttons ── */
.icon-btn {
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-default);
    color: var(--color-text-secondary); border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-2); cursor: pointer;
    transition: all var(--dur) var(--ease-quiet);
    display: flex; align-items: center;
}
.icon-btn:hover { background: var(--hover); color: var(--color-accent-text); border-color: var(--color-border-accent); }

/* ════════════════════════════════════════════════════════════════
   BUTTONS — Premium multi-state system
   ════════════════════════════════════════════════════════════════ */
.btn {
    position: relative; overflow: hidden;
    background: var(--color-accent-fill); border: 1px solid transparent;
    border-radius: var(--radius-sm); color: var(--accent-ink);
    padding: var(--space-2) var(--space-5); font-family: var(--font-sans);
    font-weight: var(--fw-semibold); cursor: pointer;
    font-size: var(--fs-sm); letter-spacing: var(--ls-normal);
    transition: background var(--dur-fast) var(--ease-quiet),
                border-color var(--dur-fast) var(--ease-quiet),
                transform var(--dur-instant) var(--ease-quiet),
                box-shadow var(--dur) var(--ease-quiet);
    display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap;
    box-shadow: var(--ring-top), 0 1px 2px rgba(0, 0, 0, 0.18), 0 4px 12px var(--color-accent-glow);
}
/* Sheen sweep on hover */
.btn::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.22) 50%, transparent 70%);
    transform: translateX(-120%); transition: transform 0.6s var(--ease-quiet);
}
.btn:hover { background: var(--color-accent-hover); transform: translateY(-1px); box-shadow: var(--ring-top), var(--shadow-accent); }
.btn:hover::after { transform: translateX(120%); }
.btn:active { transform: translateY(0) scale(0.97); box-shadow: var(--ring-top), 0 1px 2px rgba(0,0,0,0.2); }
.btn:focus-visible { outline: none; box-shadow: var(--ring-top), 0 0 0 3px var(--color-accent-soft), 0 4px 12px var(--color-accent-glow); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:disabled::after { display: none; }

/* Ghost variant */
.btn-ghost {
    background: transparent; border: 1px solid var(--color-border-strong);
    color: var(--color-text-primary); box-shadow: none;
}
.btn-ghost:hover { background: var(--color-accent-soft); border-color: var(--color-border-accent); color: var(--color-accent-text); box-shadow: none; }
.btn-ghost:active { background: var(--color-accent-soft); transform: scale(0.97); }

/* Subtle variant */
.btn-subtle { background: transparent; border: none; color: var(--color-text-secondary); box-shadow: none; padding: var(--space-2) var(--space-3); }
.btn-subtle:hover { background: var(--hover); color: var(--color-accent-text); transform: none; }
.btn-subtle::after { display: none; }

/* Approval buttons */
.btn-approve { background: var(--color-success-soft); border: 1px solid var(--color-success); color: var(--color-success); box-shadow: none; }
.btn-approve:hover { background: var(--color-success); color: #fff; }
.btn-reject { background: var(--color-error-soft); border: 1px solid var(--color-error); color: var(--color-error); box-shadow: none; }
.btn-reject:hover { background: var(--color-error); color: #fff; }
.btn-reject-confirm {
    background: var(--color-error-soft); border: 1px solid var(--color-error); color: var(--color-error);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); cursor: pointer; margin-top: var(--space-2);
}
.btn-reject-confirm:hover { background: var(--color-error); color: #fff; }

.download-btn { text-decoration: none; }

/* ════════════════════════════════════════════════════════════════
   DROPZONE
   ════════════════════════════════════════════════════════════════ */
.dropzone {
    border: 1.5px dashed var(--color-border-strong); border-radius: var(--radius-md);
    padding: var(--space-8) var(--space-6); cursor: pointer;
    transition: all var(--dur) var(--ease-quiet);
    background: var(--color-surface-sunken);
    display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--color-accent-text); background: var(--color-accent-soft);
    transform: translateY(-1px);
}
.dropzone-icon svg { stroke: var(--color-text-secondary); transition: stroke var(--dur) var(--ease-quiet); }
.dropzone:hover .dropzone-icon svg, .dropzone.dragover .dropzone-icon svg { stroke: var(--color-accent-text); }
.dropzone p { font-size: var(--fs-sm); color: var(--color-text-secondary); }
.dropzone p strong { color: var(--color-text-primary); }
.dropzone span { font-size: var(--fs-xs); color: var(--color-text-tertiary); }
input[type="file"] { display: none; }

/* ── File info bar ── */
.file-info-bar {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-accent-soft); border: 1px solid var(--color-border-accent);
    border-radius: var(--radius-sm); margin-top: var(--space-3);
}
.file-icon { font-size: 1.4rem; }
.file-details p { font-size: var(--fs-sm); font-weight: var(--fw-semibold); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-details span { font-size: var(--fs-xs); color: var(--color-text-secondary); }
.file-status {
    font-family: var(--font-mono); font-size: var(--fs-2xs); padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-xs); background: var(--color-success-soft); color: var(--color-success);
    margin-left: auto; white-space: nowrap;
}
.file-status.processing { background: var(--color-info-soft); color: var(--color-info); }
.file-status.failed { background: var(--color-error-soft); color: var(--color-error); }
.process-btn { width: 100%; margin-top: var(--space-3); justify-content: center; }

/* ════════════════════════════════════════════════════════════════
   PIPELINE — Timeline & Progress
   ════════════════════════════════════════════════════════════════ */
.pipeline-progress { margin-bottom: var(--space-4); }
.progress-bar-container {
    height: 5px; background: var(--color-surface-sunken); border-radius: var(--radius-pill);
    overflow: hidden; border: 1px solid var(--color-border-default);
}
.progress-bar-fill {
    height: 100%; width: 0%; background: var(--brand-grad);
    transition: width 0.5s var(--ease-out); border-radius: var(--radius-pill);
}
.progress-text {
    font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary);
    margin-top: var(--space-2); display: block;
}

/* Timeline steps */
.timeline-container {
    counter-reset: rail; display: flex; flex-direction: column; gap: var(--space-1);
    position: relative;
}
.timeline-step {
    counter-increment: rail; display: flex; align-items: center; gap: var(--space-3);
    opacity: 0.45; transition: all var(--dur) var(--ease-quiet);
    position: relative; padding: var(--space-2) var(--space-2);
    border-radius: var(--radius-sm); border: 1px solid transparent;
}
.timeline-step.active { opacity: 1; background: var(--color-accent-soft); border-color: var(--color-border-accent); }
.timeline-step.completed { opacity: 0.9; }
.timeline-step.failed { opacity: 1; background: var(--color-error-soft); border-color: var(--color-error); }

.node {
    width: 26px; height: 26px; border-radius: var(--radius-sm); flex-shrink: 0;
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-strong);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    color: var(--color-text-tertiary); transition: all var(--dur) var(--ease-quiet);
    position: relative; z-index: 1; box-shadow: var(--ring-top);
}
.node::before { content: counter(rail, decimal-leading-zero); }
.timeline-step.active .node {
    background: var(--brand-grad); border-color: transparent; color: #fff;
    box-shadow: 0 4px 12px var(--color-accent-glow);
}
.timeline-step.completed .node { background: var(--color-success); border-color: transparent; color: #fff; }
.timeline-step.completed .node::before { content: '✓'; font-size: 0.8rem; }
.timeline-step.failed .node { background: var(--color-error); border-color: transparent; color: #fff; }
.timeline-step.failed .node::before { content: '!'; }

.step-info { display: flex; flex-direction: column; }
.step-info .name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.step-info .desc { font-size: var(--fs-xs); color: var(--color-text-secondary); }

/* ════════════════════════════════════════════════════════════════
   KNOWLEDGE BASE SECTION
   ════════════════════════════════════════════════════════════════ */
.kb-grid { display: flex; flex-direction: column; gap: var(--space-2); }
.kb-card {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-sunken); border-radius: var(--radius-sm);
    font-size: var(--fs-sm); border: 1px solid var(--color-border-default);
    transition: all var(--dur) var(--ease-quiet);
}
.kb-card:hover { border-color: var(--color-border-strong); }
.kb-card.skeleton { justify-content: center; color: var(--color-text-secondary); }
.kb-card .kb-name { font-weight: var(--fw-medium); }
.kb-card .kb-count { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-accent-text); }
.kb-card .kb-status {
    font-family: var(--font-mono); font-size: var(--fs-2xs); padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-xs); text-transform: uppercase; letter-spacing: var(--ls-wide);
}
.kb-card .kb-status.ready { background: var(--color-success-soft); color: var(--color-success); }

/* ════════════════════════════════════════════════════════════════
   SUMMARY CARDS
   ════════════════════════════════════════════════════════════════ */
.summary-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-3); }
.card {
    position: relative; overflow: hidden;
    background: var(--color-surface-elevated); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md); padding: var(--space-4) var(--space-4);
    display: flex; align-items: center; gap: var(--space-3);
    transition: transform var(--dur) var(--ease-quiet),
                border-color var(--dur) var(--ease-quiet),
                box-shadow var(--dur) var(--ease-quiet);
    box-shadow: var(--ring-top), var(--shadow-micro);
}
.card::before {
    content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
    background: var(--brand-grad-vertical); opacity: 0; transition: opacity var(--dur) var(--ease-quiet);
}
.card:hover {
    transform: translateY(-1px); border-color: var(--color-border-accent);
    box-shadow: var(--ring-top), var(--shadow-card), 0 0 30px var(--color-accent-soft);
}
.card:hover::before { opacity: 1; }
.card-icon {
    font-size: 1.2rem; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); flex-shrink: 0;
    background: var(--color-surface-sunken); box-shadow: var(--ring-top);
}
.card-icon svg { width: 20px; height: 20px; stroke-width: 1.75; }
.card-body { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.card-label {
    font-size: var(--fs-2xs); color: var(--color-text-secondary);
    text-transform: uppercase; letter-spacing: var(--ls-wide); font-weight: var(--fw-semibold);
}
.card-value {
    font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: var(--fw-semibold);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-value.highlight { color: var(--color-accent-text); }
.card-value.green { color: var(--color-success); }
.card-value.red { color: var(--color-error); }
.card-value.amber { color: var(--color-warning); }

/* ════════════════════════════════════════════════════════════════
   TABS
   ════════════════════════════════════════════════════════════════ */
.workspace-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs-header {
    display: flex; gap: var(--space-1); flex-wrap: wrap;
    border-bottom: 1px solid var(--color-border-default);
    padding-bottom: var(--space-2); margin-bottom: var(--space-3);
}
.tab-btn {
    background: transparent; border: none; color: var(--color-text-secondary);
    padding: var(--space-2) var(--space-3); cursor: pointer;
    font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: var(--fw-medium);
    border-radius: var(--radius-sm); transition: all var(--dur-fast) var(--ease-quiet);
    white-space: nowrap;
}
.tab-btn:hover { color: var(--color-text-primary); background: var(--hover); }
.tab-btn.active { color: var(--color-accent-text); background: var(--color-accent-soft); }
.tab-content { padding: var(--space-4) 0; display: none; overflow-y: auto; flex: 1; animation: fadeIn 0.3s var(--ease-out); }
.tab-content.active { display: block; }

/* ════════════════════════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════════════════════════ */
.table-wrapper {
    overflow-x: auto; border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-default);
    background: var(--color-surface-elevated);
}
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
    background: var(--color-surface-overlay); color: var(--color-text-secondary);
    font-weight: var(--fw-semibold); padding: var(--space-2) var(--space-3);
    text-align: left; border-bottom: 1px solid var(--color-border-strong);
    font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-wide);
    white-space: nowrap; position: sticky; top: 0; z-index: 1;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border-subtle); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--dur-fast) var(--ease-quiet); }
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }
[data-theme="light"] tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.015); }
tbody tr:hover td { background: var(--hover); }
.empty-row td { text-align: center; color: var(--color-text-secondary); padding: var(--space-10) 0; }
.empty-row td:hover, tbody tr.empty-row:hover td { background: transparent; }
tbody tr.empty-row:nth-child(even) td { background: transparent; }

/* Table cell utilities */
.td-strong { font-weight: var(--fw-semibold); }
.td-mono { font-family: var(--font-mono); font-size: var(--fs-xs); }
.td-dim { color: var(--color-text-secondary); }
.td-accent { color: var(--color-info); font-weight: var(--fw-semibold); }
.td-sm { font-size: var(--fs-xs); }

/* ════════════════════════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════════════════════════ */
.badge {
    font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    padding: var(--space-1) var(--space-2); border-radius: var(--radius-xs);
    text-transform: uppercase; letter-spacing: var(--ls-wide); display: inline-block;
}
.badge-ok { background: var(--color-success-soft); color: var(--color-success); }
.badge-warn { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-err { background: var(--color-error-soft); color: var(--color-error); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }

/* ════════════════════════════════════════════════════════════════
   EDITOR — Missing data
   ════════════════════════════════════════════════════════════════ */
.editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.editor-header span { font-size: var(--fs-sm); color: var(--color-text-secondary); }
.editor-grid { display: flex; flex-direction: column; gap: var(--space-3); }
.editor-row {
    display: grid; grid-template-columns: 2fr 1fr 100px 100px auto; align-items: center; gap: var(--space-3);
    padding: var(--space-3); background: var(--color-surface-sunken);
    border: 1px solid var(--color-border-default); border-radius: var(--radius-sm);
    transition: all var(--dur) var(--ease-quiet);
}
.editor-row:hover { border-color: var(--color-border-strong); }
.editor-row .item-name { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.editor-row .item-meta { font-size: var(--fs-xs); color: var(--color-text-secondary); }
.editor-row input {
    background: var(--color-surface-elevated); border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-xs); color: var(--color-text-primary);
    padding: var(--space-2) var(--space-2); font-size: var(--fs-sm); width: 100%;
    font-family: var(--font-mono); transition: all var(--dur) var(--ease-quiet);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
.editor-row input:focus { outline: none; border-color: var(--color-accent-text); box-shadow: 0 0 0 3px var(--color-accent-soft), inset 0 1px 2px rgba(0,0,0,0.1); }
.empty-state { text-align: center; color: var(--color-text-secondary); padding: var(--space-8) 0; }

/* ════════════════════════════════════════════════════════════════
   APPROVAL SECTION
   ════════════════════════════════════════════════════════════════ */
.approval-section { margin-top: var(--space-6); border-top: 1px solid var(--color-border-default); padding-top: var(--space-4); }
.approval-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.approval-header h3 { font-family: var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.approval-badge {
    font-family: var(--font-mono); font-size: var(--fs-xs); padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-xs); background: var(--color-warning-soft); color: var(--color-warning);
}
.approval-badge.passed { background: var(--color-success-soft); color: var(--color-success); }
.approval-badge.failed { background: var(--color-error-soft); color: var(--color-error); }
.approval-actions { display: flex; gap: var(--space-3); }
.reject-reason-box { margin-top: var(--space-4); }
.glass-textarea {
    width: 100%; background: var(--color-surface-sunken); border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm); color: var(--color-text-primary); padding: var(--space-3);
    font-family: var(--font-sans); font-size: var(--fs-sm); resize: vertical;
    transition: all var(--dur) var(--ease-quiet);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
.glass-textarea:focus { outline: none; border-color: var(--color-accent-text); box-shadow: 0 0 0 3px var(--color-accent-soft), inset 0 1px 2px rgba(0,0,0,0.1); }

/* ════════════════════════════════════════════════════════════════
   COST SUMMARY
   ════════════════════════════════════════════════════════════════ */
.cost-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.cost-block {
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-sm); padding: var(--space-4); box-shadow: var(--ring-top);
}
.cost-block h3 {
    font-family: var(--font-display); font-size: var(--fs-sm); font-weight: var(--fw-semibold);
    margin-bottom: var(--space-3); color: var(--color-accent-text);
    display: flex; align-items: center; gap: var(--space-2);
}
.cost-block .line {
    display: flex; justify-content: space-between; padding: var(--space-1) 0;
    border-bottom: 1px solid var(--color-border-subtle); font-size: var(--fs-sm);
}
.cost-block .line span:last-child { font-family: var(--font-mono); }
.cost-block .line.total {
    font-weight: var(--fw-bold); font-size: var(--fs-md); margin-top: var(--space-2);
    padding-top: var(--space-2); border-top: 2px solid var(--color-border-strong);
    border-bottom: none; color: var(--color-text-primary);
}
.cost-block .line fob {
    font-family: var(--font-mono); font-size: var(--fs-lg); color: var(--color-accent-text); font-weight: var(--fw-bold);
}

/* ════════════════════════════════════════════════════════════════
   DOWNLOAD BAR
   ════════════════════════════════════════════════════════════════ */
.download-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: var(--space-5); margin-top: var(--space-4);
    border-top: 1px solid var(--color-border-default);
}
.download-info { display: flex; flex-direction: column; }
.download-info span { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--color-success); }
.download-version { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary); }

/* ════════════════════════════════════════════════════════════════
   MODALS — Overlay + Panel system
   ════════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(5, 5, 8, 0.6); backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s var(--ease-out);
}
[data-theme="light"] .modal-overlay { background: rgba(24, 24, 26, 0.35); }

.modal, .settings-modal {
    background: var(--color-surface-elevated); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg); box-shadow: var(--ring-top), var(--shadow-pop);
    padding: var(--space-6); animation: popIn 0.28s var(--ease-spring);
}
.settings-modal { width: 540px; max-height: 90vh; overflow-y: auto; }
.settings-modal h2 { border-bottom: 1px solid var(--color-border-default); padding-bottom: var(--space-3); margin-bottom: var(--space-4); }

.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.modal-close {
    background: none; border: none; color: var(--color-text-secondary); cursor: pointer;
    padding: var(--space-2); border-radius: var(--radius-sm); transition: all var(--dur) var(--ease-quiet);
}
.modal-close:hover { color: var(--color-text-primary); background: var(--hover); }
.modal-body { padding: var(--space-2) 0; }
.modal-footer {
    padding-top: var(--space-4); border-top: 1px solid var(--color-border-default);
    display: flex; justify-content: flex-end; gap: var(--space-3);
}

/* ── Settings ── */
.settings-group { margin-bottom: var(--space-6); }
.settings-group-title {
    font-family: var(--font-display); font-size: var(--fs-sm); font-weight: var(--fw-semibold);
    color: var(--color-accent-text); margin-bottom: var(--space-3);
}
.settings-row { margin-bottom: var(--space-3); }
.settings-row label { display: block; font-size: var(--fs-xs); color: var(--color-text-secondary); margin-bottom: var(--space-1); font-weight: var(--fw-medium); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

.glass-input, .glass-select {
    width: 100%; background: var(--color-surface-sunken); border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm); color: var(--color-text-primary);
    padding: var(--space-2) var(--space-3); font-size: var(--fs-sm);
    font-family: var(--font-sans); transition: all var(--dur) var(--ease-quiet);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
.glass-input:focus, .glass-select:focus {
    outline: none; border-color: var(--color-accent-text);
    box-shadow: 0 0 0 3px var(--color-accent-soft), inset 0 1px 2px rgba(0,0,0,0.1);
}
.glass-input::placeholder { color: var(--color-text-tertiary); }
.glass-select {
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239B95FF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.8rem center; padding-right: 2rem;
}
[data-theme="light"] .glass-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B4BFF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ════════════════════════════════════════════════════════════════
   TOASTS
   ════════════════════════════════════════════════════════════════ */
.toast-container { position: fixed; top: var(--space-4); right: var(--space-4); z-index: 1000; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
    position: relative; padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
    font-size: var(--fs-sm); font-weight: var(--fw-medium);
    background: var(--color-surface-elevated); border: 1px solid var(--color-border-default);
    box-shadow: var(--ring-top), var(--shadow-pop); color: var(--color-text-primary);
    animation: slideInRight 0.32s var(--ease-spring); min-width: 280px;
    display: flex; align-items: center; gap: var(--space-2); border-left-width: 3px;
    overflow: hidden;
}
.toast::after {
    content: ''; position: absolute; bottom: 0; left: 0; height: 2px;
    background: var(--color-accent-text); animation: toastTimer 4s linear forwards;
}
.toast.success { border-left-color: var(--color-success); }
.toast.success::after { background: var(--color-success); }
.toast.error { border-left-color: var(--color-error); }
.toast.error::after { background: var(--color-error); }
.toast.info { border-left-color: var(--color-accent-text); }

/* ════════════════════════════════════════════════════════════════
   COMPLETION MODAL
   ════════════════════════════════════════════════════════════════ */
.complete-overlay { z-index: 1001; }
.complete-modal {
    width: 460px; max-width: 92vw; text-align: center; padding: var(--space-8) var(--space-8) var(--space-6);
    position: relative; animation: popIn 0.4s var(--ease-spring);
}
.complete-close {
    position: absolute; top: var(--space-4); right: var(--space-4);
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-default);
    color: var(--color-text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--dur) var(--ease-quiet); z-index: 2;
}
.complete-close:hover { background: var(--color-error-soft); color: var(--color-error); border-color: var(--color-error); }
.complete-icon { font-size: 3rem; line-height: 1; margin-bottom: var(--space-3); }
.complete-title {
    font-family: var(--font-display); font-size: var(--fs-xl); font-weight: var(--fw-bold);
    margin-bottom: var(--space-1); color: var(--color-text-primary); letter-spacing: var(--ls-tight);
}
.complete-sub { font-size: var(--fs-sm); color: var(--color-text-secondary); margin-bottom: var(--space-5); }
.complete-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-bottom: var(--space-6); }
.complete-stat {
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md); padding: var(--space-3) var(--space-2);
    display: flex; flex-direction: column; gap: var(--space-1); box-shadow: var(--ring-top);
}
.complete-stat-label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-wide); color: var(--color-text-secondary); font-weight: var(--fw-semibold); }
.complete-stat-value { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--color-accent-text); }
.complete-qa { font-family: var(--font-mono); font-size: var(--fs-md); font-weight: var(--fw-bold); padding: var(--space-1) 0; }
.complete-qa.green { color: var(--color-success); } .complete-qa.amber { color: var(--color-warning); } .complete-qa.red { color: var(--color-error); }
.complete-actions { display: flex; gap: var(--space-3); justify-content: center; margin-bottom: var(--space-4); }
.complete-actions .btn { padding: var(--space-3) var(--space-5); }
.complete-hint { font-size: var(--fs-xs); color: var(--color-text-secondary); }
.complete-hint code {
    background: var(--color-surface-sunken); padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-xs); font-family: var(--font-mono); color: var(--color-accent-text);
}

/* ════════════════════════════════════════════════════════════════
   COST MASTER IMPORT MODAL
   ════════════════════════════════════════════════════════════════ */
.cm-desc { font-size: var(--fs-sm); color: var(--color-text-secondary); line-height: var(--lh-prose); margin-bottom: var(--space-5); }
.cm-desc code {
    background: var(--color-surface-sunken); padding: var(--space-1) var(--space-1);
    border-radius: var(--radius-xs); font-family: var(--font-mono); color: var(--color-accent-text); font-size: var(--fs-xs);
}
.cm-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-5); }
.cm-stat {
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md); padding: var(--space-3); display: flex; flex-direction: column;
    gap: var(--space-1); box-shadow: var(--ring-top);
}
.cm-stat-label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-wide); color: var(--color-text-secondary); font-weight: var(--fw-semibold); }
.cm-stat-value { font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: var(--fw-bold); color: var(--color-accent-text); }
.cm-dropzone { margin-bottom: var(--space-4); padding: var(--space-5); }
.cm-result { margin-top: var(--space-4); padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-surface-sunken); border: 1px solid var(--color-border-default); font-size: var(--fs-sm); }
.cm-result-ok { color: var(--color-success); font-weight: var(--fw-semibold); margin-bottom: var(--space-2); }
.cm-result-err { color: var(--color-error); font-weight: var(--fw-semibold); }
.cm-result-grid { display: flex; flex-direction: column; gap: var(--space-1); color: var(--color-text-primary); }
.cm-footer { display: flex; gap: var(--space-3); justify-content: space-between; }

/* ════════════════════════════════════════════════════════════════
   CONVERSATION HISTORY
   ════════════════════════════════════════════════════════════════ */
.history-list { display: flex; flex-direction: column; gap: var(--space-2); max-height: 55vh; overflow-y: auto; }
.history-item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md); cursor: pointer;
    background: var(--color-surface-sunken); transition: all var(--dur) var(--ease-quiet);
}
.history-item:hover { background: var(--hover); border-color: var(--color-border-accent); transform: translateY(-1px); }
.history-item.active { border-color: var(--color-accent-text); background: var(--color-accent-soft); }
.hi-main { display: flex; flex-direction: column; gap: var(--space-1); overflow: hidden; }
.hi-title { font-weight: var(--fw-semibold); font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary); }
.hi-del {
    background: none; border: none; color: var(--color-text-secondary); cursor: pointer;
    padding: var(--space-1); border-radius: var(--radius-xs); flex-shrink: 0;
    transition: all var(--dur) var(--ease-quiet);
}
.hi-del:hover { color: var(--color-error); background: var(--color-error-soft); }

/* ════════════════════════════════════════════════════════════════
   CHAT LAYOUT
   ════════════════════════════════════════════════════════════════ */
.chat-app { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; }
.chat-app.drag-active::after {
    content: '📎  Thả Tech Pack PDF vào đây để xử lý'; position: absolute; inset: var(--space-4); z-index: 50;
    display: flex; align-items: center; justify-content: center; font-size: var(--fs-lg); font-weight: var(--fw-semibold);
    color: var(--color-accent-text); border: 2px dashed var(--color-accent-text);
    border-radius: var(--radius-lg); background: var(--color-accent-soft);
    backdrop-filter: blur(4px); pointer-events: none; animation: fadeIn 0.2s var(--ease-out);
}
.chat-scroll { flex: 1; overflow-y: auto; padding: var(--space-6) var(--space-4) 0; scroll-behavior: smooth; }
.chat-thread { max-width: 840px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-5); padding-bottom: var(--space-6); }

/* ════════════════════════════════════════════════════════════════
   WELCOME HERO
   ════════════════════════════════════════════════════════════════ */
.chat-welcome { text-align: center; display: flex; flex-direction: column; align-items: center; padding: var(--space-10) var(--space-4) var(--space-4); animation: riseIn 0.5s var(--ease-out); }
.welcome-hero { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); margin-bottom: var(--space-5); }
.welcome-orb-wrap { position: relative; width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-6); }
.welcome-orb-wrap::before {
    content: ''; position: absolute; width: 150px; height: 150px; border-radius: 50%;
    background: radial-gradient(circle, var(--color-accent-soft) 0%, transparent 68%);
    filter: blur(12px); z-index: 0; animation: orbGlowPulse 4s ease-in-out infinite;
}
.welcome-orb-ring {
    position: absolute; inset: -8px; border-radius: var(--radius-xl);
    border: 1px solid var(--color-border-accent); opacity: 0.5;
    animation: ringPulse 3s ease-in-out infinite;
}
.welcome-orb-ring.ring-2 {
    inset: -18px; opacity: 0.25; animation-delay: 0.6s;
}
.welcome-orb {
    position: relative; z-index: 1; width: 76px; height: 76px;
    display: flex; align-items: center; justify-content: center; color: #fff;
    background: var(--brand-orb-grad); border-radius: var(--radius-xl);
    box-shadow: var(--ring-top), inset 0 -6px 16px rgba(40, 20, 80, 0.4),
                0 12px 28px var(--color-accent-glow), 0 22px 56px rgba(124, 58, 237, 0.32);
    animation: orbFloat 5.5s ease-in-out infinite; overflow: hidden;
}
.welcome-orb svg { width: 48%; height: 48%; position: relative; z-index: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25)); }
.welcome-orb::after {
    content: ''; position: absolute; left: -25%; right: -25%; top: -60%; height: 95%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    border-radius: 50%; transform: rotate(-8deg); pointer-events: none;
}

.cw-brand { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.cw-eyebrow {
    font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-ultrawide); text-transform: uppercase;
    color: var(--color-accent-text); background: var(--color-accent-soft);
    border: 1px solid var(--color-border-accent);
    padding: var(--space-1) var(--space-4) var(--space-1) var(--space-4);
    border-radius: var(--radius-pill);
}
.cw-title {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: var(--space-2) var(--space-2); font-family: var(--font-display);
    font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: var(--lh-tight);
    border: none; padding: 0; margin: 0; letter-spacing: var(--ls-tight);
}
.cw-ls { background: var(--brand-ls-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.cw-nexus {
    background: var(--brand-nexus-grad); background-size: 220% auto;
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    animation: brandShimmer 7s ease-in-out infinite;
}
.cw-agent-badge {
    font-family: var(--font-mono); font-size: 0.33em; font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-ultrawide); text-transform: uppercase;
    color: #fff; -webkit-text-fill-color: #fff;
    padding: 0.45em 0.9em; border-radius: var(--radius-pill);
    background: var(--brand-grad); box-shadow: var(--ring-top), 0 4px 12px var(--color-accent-glow);
    align-self: center; transform: translateY(-0.12em);
}
.cw-sub { font-size: var(--fs-md); color: var(--color-text-secondary); max-width: 580px; line-height: var(--lh-prose); margin-bottom: var(--space-8); }
.cw-sub strong { color: var(--color-accent-text); font-weight: var(--fw-semibold); }
.cw-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); width: 100%; max-width: 620px; }
.cw-card {
    display: flex; gap: var(--space-3); align-items: flex-start; text-align: left; cursor: pointer;
    background: var(--color-surface-elevated); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md); padding: var(--space-4) var(--space-4);
    transition: all var(--dur) var(--ease-quiet); color: var(--color-text-primary);
    font-family: inherit; box-shadow: var(--ring-top), var(--shadow-micro);
    animation: riseIn 0.5s var(--ease-out) backwards;
}
.cw-card:nth-child(1) { animation-delay: 0.05s; }
.cw-card:nth-child(2) { animation-delay: 0.12s; }
.cw-card:nth-child(3) { animation-delay: 0.19s; }
.cw-card:nth-child(4) { animation-delay: 0.26s; }
.cw-card:hover { border-color: var(--color-border-accent); transform: translateY(-2px); box-shadow: var(--ring-top), var(--shadow-card), 0 0 24px var(--color-accent-soft); }
.cw-card:active { transform: translateY(0) scale(0.985); }
.cw-ic {
    width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); background: var(--color-accent-soft); color: var(--color-accent-text);
}
.cw-ic svg { width: 18px; height: 18px; stroke-width: 1.75; }
.cw-card-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.cw-h { font-weight: var(--fw-semibold); font-size: var(--fs-base); }
.cw-d { font-size: var(--fs-xs); color: var(--color-text-secondary); }

/* ════════════════════════════════════════════════════════════════
   CHAT MESSAGES
   ════════════════════════════════════════════════════════════════ */
.msg-row { display: flex; gap: var(--space-3); align-items: flex-start; animation: riseIn 0.35s var(--ease-out); }
.msg-row.user { justify-content: flex-end; }
.msg-avatar {
    width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-size: var(--fs-xs); font-weight: var(--fw-bold);
    color: #fff; box-shadow: var(--ring-top);
}
.msg-row.bot .msg-avatar { background: var(--brand-grad); }
.msg-row.user .msg-avatar { background: var(--color-surface-sunken); border: 1px solid var(--color-border-default); color: var(--color-text-secondary); order: 2; }
.msg-bubble {
    max-width: 80%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
    font-size: var(--fs-base); line-height: var(--lh-prose); word-wrap: break-word; overflow-wrap: anywhere;
}
.msg-row.bot .msg-bubble {
    background: var(--color-surface-elevated); border: 1px solid var(--color-border-default);
    border-top-left-radius: 5px; box-shadow: var(--ring-top), var(--shadow-micro);
}
.msg-row.user .msg-bubble {
    background: var(--color-accent-soft); border: 1px solid var(--color-border-accent);
    border-top-right-radius: 5px;
}
.msg-bubble p { margin: 0 0 var(--space-2); } .msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: var(--space-1) 0 var(--space-2) 1.1rem; display: flex; flex-direction: column; gap: var(--space-1); }
.msg-bubble code {
    background: var(--color-surface-sunken); padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-xs); font-family: var(--font-mono); font-size: 0.82em; color: var(--color-accent-text);
}
.msg-file {
    display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3); background: var(--color-surface-sunken);
    border: 1px solid var(--color-border-default); border-radius: var(--radius-sm);
    box-shadow: var(--ring-top);
}
.msg-file .mf-ic { font-size: 1.3rem; }
.msg-file .mf-name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.msg-file .mf-size { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary); }

/* ════════════════════════════════════════════════════════════════
   TYPING INDICATOR
   ════════════════════════════════════════════════════════════════ */
.chat-typing { display: inline-flex; align-items: center; gap: 5px; padding: var(--space-1) 0; }
.chat-typing i {
    width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent-text);
    animation: typingDot 1.2s var(--ease-quiet) infinite;
}
.chat-typing i:nth-child(2) { animation-delay: 0.18s; }
.chat-typing i:nth-child(3) { animation-delay: 0.36s; }

/* ════════════════════════════════════════════════════════════════
   PROCESSING CARD (in-chat pipeline progress)
   ════════════════════════════════════════════════════════════════ */
.proc-card { display: flex; flex-direction: column; gap: var(--space-3); }
.proc-head { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-semibold); font-size: var(--fs-base); }
.proc-spinner {
    width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--color-accent-soft); border-top-color: var(--color-accent-text);
    animation: spin 0.8s linear infinite;
}
.proc-bar { height: 5px; background: var(--color-surface-sunken); border-radius: var(--radius-pill); overflow: hidden; border: 1px solid var(--color-border-default); }
.proc-fill { height: 100%; background: var(--brand-grad); border-radius: var(--radius-pill); transition: width 0.6s var(--ease-out); }
.proc-agent { font-size: var(--fs-base); color: var(--color-accent-text); line-height: var(--lh-compact); }
.proc-agent strong { font-weight: var(--fw-bold); color: var(--color-accent-text); }
.proc-task { font-size: var(--fs-sm); color: var(--color-text-primary); font-weight: var(--fw-medium); }
.proc-hint { font-size: var(--fs-xs); color: var(--color-text-secondary); font-style: italic; padding-left: var(--space-1); }
.proc-long-note {
    font-size: var(--fs-xs); color: var(--color-warning);
    background: var(--color-warning-soft); border: 1px solid var(--color-warning);
    border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); line-height: var(--lh-body);
}
.proc-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary); }
.proc-step { font-size: var(--fs-sm); color: var(--color-text-secondary); }

/* ════════════════════════════════════════════════════════════════
   RESULT CARD (in-chat completion)
   ════════════════════════════════════════════════════════════════ */
.result-card { display: flex; flex-direction: column; gap: var(--space-3); animation: riseIn 0.4s var(--ease-out); }
.rc-title { font-family: var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.rc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.rc-stat {
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md); padding: var(--space-3) var(--space-3);
    display: flex; flex-direction: column; gap: var(--space-1); box-shadow: var(--ring-top);
}
.rc-stat span { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-wide); color: var(--color-text-secondary); font-weight: var(--fw-semibold); }
.rc-stat b { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.rc-stat b.grad { color: var(--color-accent-text); }
.rc-stat b.green { color: var(--color-success); } .rc-stat b.amber { color: var(--color-warning); } .rc-stat b.red { color: var(--color-error); }
.rc-warn {
    font-size: var(--fs-sm); color: var(--color-warning);
    background: var(--color-warning-soft); border: 1px solid var(--color-warning);
    border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
}
.rc-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.rc-actions .btn { padding: var(--space-2) var(--space-4); font-size: var(--fs-sm); }
.result-fail { color: var(--color-error); font-size: var(--fs-base); }
.result-trace {
    margin-top: var(--space-2); padding: var(--space-2); background: var(--color-surface-sunken);
    border: 1px solid var(--color-border-default); border-radius: var(--radius-sm);
    font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary);
    white-space: pre-wrap; max-height: 160px; overflow: auto;
}

/* ════════════════════════════════════════════════════════════════
   COMPOSER — Chat input
   ════════════════════════════════════════════════════════════════ */
.composer-wrap { padding: var(--space-2) var(--space-4) var(--space-4); position: relative; z-index: 2; }
.composer {
    max-width: 840px; margin: 0 auto;
    background: var(--color-surface-elevated);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-xl);
    box-shadow: var(--ring-top), var(--shadow-elevated);
    padding: var(--space-2); transition: all var(--dur) var(--ease-quiet);
}
.composer:focus-within {
    border-color: var(--color-accent-text);
    box-shadow: var(--ring-top), 0 0 0 4px var(--color-accent-soft), var(--shadow-elevated);
}
.composer-attachment {
    display: flex; align-items: center; gap: var(--space-2);
    margin: var(--space-1) var(--space-2) 0;
    padding: var(--space-2) var(--space-3);
    background: var(--color-accent-soft); border: 1px solid var(--color-border-accent);
    border-radius: var(--radius-md);
}
.composer-attachment .att-icon { font-size: 1.3rem; }
.composer-attachment .att-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.composer-attachment .att-name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-attachment .att-size { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--color-text-secondary); }
.att-remove {
    background: var(--color-surface-sunken); border: none; color: var(--color-text-secondary);
    cursor: pointer; border-radius: var(--radius-sm); width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center; transition: all var(--dur) var(--ease-quiet);
}
.att-remove:hover { background: var(--color-error-soft); color: var(--color-error); }
.composer-input-row { display: flex; align-items: flex-end; gap: var(--space-2); }
.composer-input-row textarea {
    flex: 1; resize: none; max-height: 200px; min-height: 28px;
    background: transparent; border: none; color: var(--color-text-primary);
    padding: var(--space-2) var(--space-2); font-size: var(--fs-md);
    font-family: var(--font-sans); outline: none; line-height: var(--lh-body);
    transition: height 0.15s var(--ease-out);
}
.composer-input-row textarea::placeholder { color: var(--color-text-tertiary); }
.composer-btn {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: var(--radius-md);
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--dur) var(--ease-quiet);
}
.composer-btn.attach { background: var(--color-surface-sunken); color: var(--color-text-secondary); box-shadow: var(--ring-top); }
.composer-btn.attach:hover { background: var(--hover); color: var(--color-accent-text); }
.composer-btn.send {
    background: var(--brand-grad); color: #fff;
    box-shadow: var(--ring-top), 0 4px 14px var(--color-accent-glow);
}
.composer-btn.send:hover { transform: scale(1.05); box-shadow: var(--ring-top), var(--shadow-accent); }
.composer-btn.send:active { transform: scale(0.95); }
.composer-hint { text-align: center; font-size: var(--fs-xs); color: var(--color-text-secondary); margin-top: var(--space-2); }

/* ════════════════════════════════════════════════════════════════
   DETAIL DRAWER
   ════════════════════════════════════════════════════════════════ */
.drawer-overlay {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(5, 5, 8, 0.5); backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease-out);
}
[data-theme="light"] .drawer-overlay { background: rgba(24, 24, 26, 0.35); }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.detail-drawer {
    position: fixed; top: 0; right: 0; z-index: 901; width: 760px; max-width: 96vw; height: 100vh;
    background: var(--color-surface-ground); border-left: 1px solid var(--color-border-default);
    box-shadow: -16px 0 56px rgba(0, 0, 0, 0.5);
    transform: translateX(100%); transition: transform 0.4s var(--ease-spring);
    display: flex; flex-direction: column;
}
[data-theme="light"] .detail-drawer { box-shadow: -16px 0 56px rgba(26, 26, 24, 0.18); }
.detail-drawer.open { transform: translateX(0); }
.drawer-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--color-border-default);
    background: var(--color-surface-overlay); flex-shrink: 0;
}
.drawer-header h2 { border: none; padding: 0; margin: 0; font-size: var(--fs-lg); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--space-5) var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }
.detail-drawer .summary-cards { grid-template-columns: repeat(2, 1fr); }
.detail-drawer .workspace-panel { flex: none; }
.pipeline-section { padding: var(--space-5); }

/* ════════════════════════════════════════════════════════════════
   CHAT FAB (legacy compat)
   ════════════════════════════════════════════════════════════════ */
.chat-fab {
    position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 1002;
    width: 58px; height: 58px; border-radius: var(--radius-md); border: none;
    cursor: pointer; color: #fff; background: var(--brand-grad);
    box-shadow: var(--ring-top), 0 8px 24px var(--color-accent-glow);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--dur) var(--ease-quiet);
}
.chat-fab:hover { transform: scale(1.06); box-shadow: var(--ring-top), var(--shadow-accent); }
.chat-fab.hidden { display: none; }

/* ════════════════════════════════════════════════════════════════
   INSPECTOR — Right dock
   ════════════════════════════════════════════════════════════════ */
.inspector {
    width: 0; flex-shrink: 0; overflow: hidden;
    border-left: 1px solid transparent; background: var(--color-surface-overlay);
    transition: width var(--spring); display: flex; flex-direction: column;
}
.shell-canvas.with-inspector .inspector { width: var(--inspector-w); border-left-color: var(--color-border-default); }
.shell-canvas { flex: 1; min-height: 0; display: flex; position: relative; }
.shell-canvas .chat-app { flex: 1; min-width: 0; }
.insp-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-4) var(--space-4); border-bottom: 1px solid var(--color-border-default);
    flex-shrink: 0;
}
.insp-head .h {
    font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-ultrawide);
    text-transform: uppercase; color: var(--color-text-tertiary);
}
.insp-head button {
    background: none; border: none; color: var(--color-text-tertiary); cursor: pointer;
    padding: var(--space-1); border-radius: var(--radius-xs); transition: all var(--dur) var(--ease-quiet);
}
.insp-head button:hover { color: var(--color-text-primary); background: var(--hover); }
.insp-body { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.insp-rail { display: flex; flex-direction: column; gap: var(--space-1); }
.insp-step {
    display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm); font-size: var(--fs-sm); color: var(--color-text-secondary);
    transition: all var(--dur) var(--ease-quiet);
}
.insp-step .n {
    width: 22px; height: 22px; border-radius: var(--radius-xs); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-strong);
    color: var(--color-text-tertiary); transition: all var(--dur) var(--ease-quiet);
}
.insp-step.completed .n { background: var(--color-success); border-color: transparent; color: #fff; }
.insp-step.active { color: var(--color-text-primary); font-weight: var(--fw-semibold); background: var(--color-accent-soft); }
.insp-step.active .n { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 3px 10px var(--color-accent-glow); }
.insp-step.failed .n { background: var(--color-error); border-color: transparent; color: #fff; }
.insp-stats { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--color-border-default); }
.insp-stat {
    padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md); background: var(--color-surface-elevated); box-shadow: var(--ring-top);
}
.insp-stat span { display: block; font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--color-text-tertiary); }
.insp-stat b { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--color-accent-text); }
.insp-empty { color: var(--color-text-tertiary); font-size: var(--fs-sm); text-align: center; padding: var(--space-8) var(--space-2); line-height: var(--lh-body); }

/* ════════════════════════════════════════════════════════════════
   COMMAND PALETTE (⌘K)
   ════════════════════════════════════════════════════════════════ */
.cmdk-overlay {
    position: fixed; inset: 0; z-index: 1100; display: none;
    align-items: flex-start; justify-content: center; padding-top: 14vh;
    background: rgba(5, 5, 8, 0.55); backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
[data-theme="light"] .cmdk-overlay { background: rgba(24, 24, 26, 0.35); }
.cmdk-overlay.open { display: flex; animation: fadeIn 0.2s var(--ease-out); }
.cmdk {
    width: 560px; max-width: 92vw; background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-lg);
    box-shadow: var(--ring-top), var(--shadow-pop); overflow: hidden;
    animation: popIn 0.22s var(--ease-spring);
}
.cmdk-input-row {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-4) var(--space-4); border-bottom: 1px solid var(--color-border-default);
}
.cmdk-input-row svg { width: 17px; height: 17px; color: var(--color-text-tertiary); flex-shrink: 0; }
.cmdk-input-row input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--color-text-primary); font-family: var(--font-sans); font-size: var(--fs-md);
}
.cmdk-input-row input::placeholder { color: var(--color-text-tertiary); }
.cmdk-list { max-height: 340px; overflow-y: auto; padding: var(--space-2); }
.cmdk-item {
    display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm); cursor: pointer; color: var(--color-text-secondary);
    font-size: var(--fs-base); transition: all var(--dur-fast) var(--ease-quiet);
}
.cmdk-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.8; }
.cmdk-item .hint { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--color-text-tertiary); }
.cmdk-item.sel, .cmdk-item:hover { background: var(--color-accent-soft); color: var(--color-accent-text); }
.cmdk-empty { padding: var(--space-6); text-align: center; color: var(--color-text-tertiary); font-size: var(--fs-sm); }

/* ════════════════════════════════════════════════════════════════
   COSTING SHEET — Resizable docked side panel
   ════════════════════════════════════════════════════════════════ */
#intakeOverlay {
    position: relative; inset: auto; z-index: 6; flex-shrink: 0;
    align-items: stretch; justify-content: stretch;
    background: none; backdrop-filter: none; -webkit-backdrop-filter: none;
    width: 0; overflow: hidden; border-left: 1px solid transparent;
    transition: width var(--spring); animation: none;
}
#intakeOverlay.open { display: flex !important; width: var(--costing-w); border-left-color: var(--color-border-default); }
#intakeOverlay.minimized.open { width: 52px; }

#intakeOverlay .settings-modal {
    width: 100% !important; max-width: none !important; height: 100%;
    border: none; border-radius: 0; box-shadow: none;
    background: var(--color-surface-overlay); display: flex; flex-direction: column;
    padding: 0; overflow: hidden; animation: none;
}
#intakeOverlay .modal-header {
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border-default);
    flex-shrink: 0; background: var(--color-surface-elevated);
}
#intakeOverlay .modal-header h2 { font-size: var(--fs-md); }
#intakeOverlay .modal-body { padding: var(--space-4) var(--space-4); overflow-y: auto; flex: 1; }
#intakeOverlay .modal-footer {
    padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border-default);
    flex-shrink: 0; background: var(--color-surface-elevated);
}

.costing-head-actions { display: flex; align-items: center; gap: var(--space-1); }
.costing-icon-btn {
    background: none; border: none; color: var(--color-text-secondary); cursor: pointer;
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--dur) var(--ease-quiet);
}
.costing-icon-btn:hover { background: var(--hover); color: var(--color-text-primary); }
.costing-resize { position: absolute; left: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 8; }
.costing-resize::after {
    content: ''; position: absolute; left: 3px; top: 0; bottom: 0; width: 1px;
    background: transparent; transition: all var(--dur) var(--ease-quiet);
}
.costing-resize:hover::after, body.costing-resizing .costing-resize::after { background: var(--color-accent-text); width: 2px; left: 2px; }
body.costing-resizing { cursor: col-resize; user-select: none; }

#intakeOverlay.minimized .modal-body,
#intakeOverlay.minimized .modal-footer,
#intakeOverlay.minimized .costing-title-text,
#intakeOverlay.minimized .costing-resize { display: none; }
#intakeOverlay.minimized .modal-header {
    flex-direction: column; gap: var(--space-2); padding: var(--space-3) 0;
    height: 100%; justify-content: flex-start; background: var(--color-surface-overlay);
}
.costing-minlabel { display: none; }
#intakeOverlay.minimized .costing-minlabel {
    display: block; writing-mode: vertical-rl; transform: rotate(180deg);
    font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: var(--ls-ultrawide);
    text-transform: uppercase; color: var(--color-accent-text); margin-top: var(--space-2); cursor: pointer;
}

/* ── Intake step rows ── */
.intake-step-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2); border-bottom: 1px solid var(--color-border-subtle); font-size: var(--fs-sm); }
.intake-step-row:last-child { border-bottom: none; }
.intake-step-num {
    width: 1.5rem; height: 1.5rem; flex-shrink: 0; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
    background: var(--color-surface-sunken); border: 1px solid var(--color-border-strong);
    color: var(--color-text-secondary); transition: all var(--dur) var(--ease-quiet);
}
.intake-step-row.done .intake-step-num { background: var(--color-success); border-color: transparent; color: #fff; }
.intake-step-label { flex: 1; min-width: 0; }
.intake-step-file { color: var(--color-text-secondary); font-size: var(--fs-xs); }
.intake-step-badge { font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); }
.intake-step-badge.done { color: var(--color-success); }
.intake-step-badge.todo { color: var(--color-warning); }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 64px 1fr; }
    .rail-item span, .rail-brand .rb-text, .rail-section { display: none; }
    .rail-item { justify-content: center; padding: var(--space-2); }
    .rail-item::before { display: none; }
    .rail-brand { justify-content: center; padding: var(--space-2) 0 var(--space-3); }
    .shell-canvas.with-inspector .inspector { width: 232px; }
}
@media (max-width: 1000px) {
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .editor-row { grid-template-columns: 1fr 100px auto; }
}
@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .rail {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 1050; width: 250px;
        transform: translateX(-100%); transition: transform 0.3s var(--ease-out);
        box-shadow: var(--shadow-pop);
    }
    .rail.open { transform: translateX(0); }
    .rail-item span, .rail-brand .rb-text, .rail-section { display: revert; }
    .rail-item { justify-content: flex-start; padding: var(--space-2) var(--space-3); }
    .rail-item::before { display: block; }
    .rail-brand { justify-content: flex-start; }
    .rail-scrim.open { display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(0, 0, 0, 0.5); }
    .rail-toggle { display: inline-flex; align-items: center; }
    .tb-search { max-width: none; }
    .tb-crumb { display: none; }
    .shell-canvas.with-inspector .inspector { position: fixed; right: 0; top: 0; bottom: 0; z-index: 1045; width: 280px; max-width: 88vw; box-shadow: var(--shadow-pop); }
    .msg-bubble { max-width: 88%; }
    .rc-grid { grid-template-columns: repeat(2, 1fr); }
    .cw-cards { grid-template-columns: 1fr; }
    #intakeOverlay.open { position: fixed; right: 0; top: 0; bottom: 0; z-index: 1060; width: 92vw; box-shadow: var(--shadow-pop); }
    #intakeOverlay.minimized.open { width: 46px; }
}
@media (max-width: 700px) {
    .header-text-btn span, .header-text-btn { font-size: var(--fs-xs); }
}

/* ════════════════════════════════════════════════════════════════
   ANIMATIONS — Keyframes
   ════════════════════════════════════════════════════════════════ */
@keyframes ambientDrift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-1.5%, 1%) scale(1.03); }
    66% { transform: translate(1%, -0.5%) scale(0.98); }
}
@keyframes logoGlow {
    0%, 100% { box-shadow: var(--ring-top), inset 0 -3px 8px rgba(40,30,120,0.35), 0 4px 14px var(--color-accent-glow), 0 6px 20px rgba(99,102,241,0.28); }
    50% { box-shadow: var(--ring-top), inset 0 -3px 8px rgba(40,30,120,0.35), 0 6px 22px var(--color-accent-glow), 0 10px 32px rgba(99,102,241,0.40); }
}
@keyframes orbFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-5px) rotate(-1deg); }
}
@keyframes orbGlowPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}
@keyframes ringPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.04); }
}
@keyframes brandShimmer {
    0%, 100% { background-position: 0% center; }
    50% { background-position: 100% center; }
}
@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--color-accent-soft); }
    50% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-6px); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes popOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.95); } }
@keyframes slideInRight { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }
@keyframes toastTimer { from { width: 100%; } to { width: 0%; } }
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ── Skeleton loading ── */
.skeleton {
    background: linear-gradient(90deg, var(--color-surface-sunken) 25%, var(--color-surface-hover) 50%, var(--color-surface-sunken) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* ════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .bg-ambient { animation: none; }
    .bg-grain { display: none; }
}
