/* ============================================================
   AI Demo - Desktop OS + AI Chat + File Browser Styles
   Forked from sistemica website, extended for AI demo app.
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Brown/Gold Desktop Palette */
    --color-brown-dark: #8B4513;
    --color-brown-mid: #A0522D;
    --color-gold: #B8860B;
    --color-gold-light: #DAA520;
    --color-moccasin: #FFE4B5;
    --color-moccasin-dim: rgba(255, 228, 181, 0.9);
    --color-moccasin-faint: rgba(255, 228, 181, 0.4);

    /* UI Surface Colors */
    --surface-dark: rgba(0, 0, 0, 0.3);
    --surface-darker: rgba(0, 0, 0, 0.5);
    --surface-window: rgba(20, 20, 20, 0.95);
    --surface-header: rgba(240, 240, 240, 0.8);
    --surface-panel: #ffffff;
    --surface-panel-alt: #f8f9fa;
    --surface-inspector: #2a1a0e;

    /* Traffic Light Controls */
    --control-close: #ff5f57;
    --control-minimize: #ffbd2e;
    --control-maximize: #28ca42;

    /* Chat Bubbles */
    --bubble-user-start: #8B4513;
    --bubble-user-end: #DAA520;
    --bubble-assistant: #f0f0f0;
    --bubble-assistant-text: #1a1a1a;

    /* Context Inspector Role Colors (warm palette) */
    --role-system: #DAA520;
    --role-system-bg: rgba(218, 165, 32, 0.12);
    --role-system-border: rgba(218, 165, 32, 0.3);
    --role-user: #C19A6B;
    --role-user-bg: rgba(193, 154, 107, 0.12);
    --role-user-border: rgba(193, 154, 107, 0.3);
    --role-assistant: #A0826D;
    --role-assistant-bg: rgba(160, 130, 109, 0.12);
    --role-assistant-border: rgba(160, 130, 109, 0.3);
    --role-tool: #E8A838;
    --role-tool-bg: rgba(232, 168, 56, 0.12);
    --role-tool-border: rgba(232, 168, 56, 0.3);
    --role-summary: #B8860B;
    --role-summary-bg: rgba(184, 134, 11, 0.12);
    --role-summary-border: rgba(184, 134, 11, 0.3);

    /* Toggle Colors */
    --toggle-on: #22c55e;
    --toggle-off: #9ca3af;

    /* File Browser */
    --tree-bg: #f8f9fa;
    --tree-border: #e5e7eb;
    --tree-hover: #eef2ff;
    --tree-selected: #dbeafe;
    --badge-default: #3b82f6;
    --badge-modified: #f59e0b;

    /* Typography */
    --font-family: 'Varela Round', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;

    /* Sizing */
    --topbar-height: 32px;
    --taskbar-width: 64px;
    --window-header-height: 40px;
    --toolbar-height: 44px;
    --token-bar-height: 36px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-smooth: 0.3s ease-out;
}


/* ============================================================
   1. RESET & BASE
   ============================================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    width: 100%;
    height: 100%;
    font-family: var(--font-family);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ============================================================
   2. DESKTOP / OS CHROME
   ============================================================ */

/* --- Desktop Background --- */

.desktop {
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom right, var(--color-brown-dark), var(--color-gold), var(--color-gold-light));
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Star Background Layer */
.star-background {
    position: absolute;
    inset: 0;
    z-index: 10;
    overflow: hidden;
    pointer-events: none;
}

.star-background::before,
.star-background::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--color-moccasin);
    border-radius: 50%;
    box-shadow:
        100px 100px 0 var(--color-moccasin),
        200px 150px 0 var(--color-moccasin),
        300px 80px 0 var(--color-moccasin),
        450px 200px 0 var(--color-moccasin),
        600px 120px 0 var(--color-moccasin),
        750px 180px 0 var(--color-moccasin),
        900px 90px 0 var(--color-moccasin),
        1050px 250px 0 var(--color-moccasin),
        1200px 160px 0 var(--color-moccasin),
        150px 300px 0 var(--color-moccasin),
        350px 400px 0 var(--color-moccasin),
        550px 350px 0 var(--color-moccasin),
        750px 450px 0 var(--color-moccasin),
        950px 380px 0 var(--color-moccasin),
        1150px 420px 0 var(--color-moccasin),
        100px 500px 0 var(--color-moccasin),
        300px 600px 0 var(--color-moccasin),
        500px 550px 0 var(--color-moccasin),
        700px 650px 0 var(--color-moccasin),
        900px 580px 0 var(--color-moccasin),
        1100px 620px 0 var(--color-moccasin),
        1300px 520px 0 var(--color-moccasin),
        200px 700px 0 var(--color-moccasin),
        400px 750px 0 var(--color-moccasin),
        600px 680px 0 var(--color-moccasin),
        800px 720px 0 var(--color-moccasin),
        1000px 690px 0 var(--color-moccasin),
        1200px 730px 0 var(--color-moccasin);
    animation: twinkle 4s ease-in-out infinite;
}

.star-background::after {
    left: 50px;
    top: 50px;
    animation-delay: 2s;
}

/* Star Constellations */
.star-constellations {
    position: absolute;
    inset: 0;
    z-index: 20;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.3;
}

/* Film Grain Effect */
.film-grain {
    position: absolute;
    inset: 0;
    z-index: 30;
    opacity: 0.35;
    mix-blend-mode: overlay;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    filter: contrast(180%) brightness(150%);
    background-size: 150px 150px;
}

/* Blur/Glow Overlay */
.blur-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    backdrop-filter: blur(3px);
    background: rgba(0, 0, 0, 0.1);
    mix-blend-mode: overlay;
    pointer-events: none;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.2);
}


/* --- Top Bar --- */

.top-bar {
    height: var(--topbar-height);
    background: var(--surface-dark);
    color: var(--color-moccasin-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 14px;
    backdrop-filter: blur(20px);
    z-index: 1000;
    width: 100vw;
    border-bottom: 1px solid rgba(255, 228, 181, 0.1);
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.top-bar-center {
    display: flex;
    align-items: center;
}

.top-bar-right {
    display: flex;
    align-items: center;
}

.system-indicators {
    display: flex;
    align-items: center;
    gap: 12px;
}

.indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-normal);
}

.indicator:hover {
    background: rgba(255, 228, 181, 0.1);
}

.indicator svg {
    opacity: 0.9;
    fill: rgba(255, 228, 181, 0.8);
}

.battery-level {
    font-size: 12px;
    font-weight: 500;
}

.datetime {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    line-height: 1.2;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-normal);
}

.datetime:hover {
    background: rgba(255, 228, 181, 0.1);
}

.time {
    font-weight: 600;
    font-size: 13px;
}

.date {
    font-size: 11px;
    opacity: 0.8;
}


/* --- Taskbar (Left Side Dock) --- */

.taskbar {
    width: var(--taskbar-width);
    height: 85vh;
    background: var(--surface-dark);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    z-index: 1000;
    position: fixed;
    left: 12px;
    top: 7.5vh;
    border-radius: 16px;
    border: 1px solid rgba(255, 228, 181, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.taskbar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.app-launcher {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-gold-light), var(--color-moccasin));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 8px rgba(218, 165, 32, 0.3);
    margin-bottom: 12px;
}

.app-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(218, 165, 32, 0.4);
}

.app-launcher:active {
    transform: translateY(0);
}

.app-icons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.app-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 228, 181, 0.1);
    /* Touch friendly */
    min-width: 44px;
    min-height: 44px;
}

.app-icon:hover {
    background: rgba(255, 228, 181, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 228, 181, 0.2);
    border-color: rgba(255, 228, 181, 0.3);
}

.app-icon:active {
    transform: translateY(0);
}

.app-icon svg {
    transition: transform var(--transition-normal);
    color: var(--color-moccasin-dim);
}

.app-icon:hover svg {
    transform: scale(1.1);
    color: var(--color-moccasin);
}

/* App icon variants */
.app-icon.eliza {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.3), rgba(184, 134, 11, 0.3));
}

.app-icon.files {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.3), rgba(230, 126, 34, 0.3));
}

.app-icon.presentation {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.3), rgba(142, 68, 173, 0.3));
}

.app-icon.shell {
    background: linear-gradient(135deg, rgba(52, 73, 94, 0.3), rgba(44, 62, 80, 0.3));
}

.app-icon.notes {
    background: linear-gradient(135deg, rgba(142, 68, 173, 0.3), rgba(155, 89, 182, 0.3));
}

.app-icon.browser {
    background: linear-gradient(135deg, rgba(3, 102, 214, 0.3), rgba(0, 81, 162, 0.3));
}

.app-icon.showcase {
    background: linear-gradient(135deg, rgba(233, 30, 99, 0.3), rgba(194, 24, 91, 0.3));
}

/* App icon tooltip */
.app-icon::before {
    content: attr(title);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(60, 60, 60, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.app-icon:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(4px);
}

.taskbar-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.taskbar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.system-tray {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tray-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color var(--transition-normal);
}

.tray-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tray-icon svg {
    opacity: 0.7;
    transition: opacity var(--transition-normal);
}

.tray-icon:hover svg {
    opacity: 1;
}

/* Desktop Content Area */
.desktop-content {
    flex: 1;
    position: relative;
    padding: 20px;
    margin-left: 0;
}


/* --- Language Switcher (i18n) --- */

.language-switcher {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 228, 181, 0.1);
}

.lang-option {
    width: 32px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-moccasin-faint);
    cursor: pointer;
    transition: all var(--transition-normal);
    border-radius: 4px;
    /* Touch friendly */
    min-width: 44px;
    min-height: 44px;
}

.lang-option:hover {
    color: rgba(255, 228, 181, 0.7);
    background: rgba(255, 228, 181, 0.05);
}

.lang-option.active {
    color: var(--color-moccasin-dim);
    background: rgba(255, 228, 181, 0.1);
}

/* Bottom icons area */
.bottom-icons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bottom-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    border-radius: 6px;
    position: relative;
    /* Touch friendly */
    min-width: 44px;
    min-height: 44px;
}

.bottom-icon:hover {
    background: rgba(255, 228, 181, 0.1);
    transform: translateY(-1px);
}

.bottom-icon:hover svg {
    fill: var(--color-moccasin-dim);
}

.bottom-icon:active {
    transform: translateY(0);
}

.bottom-icon[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    background: rgba(42, 42, 42, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-out 0.3s forwards;
}


/* ============================================================
   3. WINDOW SYSTEM
   ============================================================ */

.window {
    position: absolute;
    min-width: 600px;
    min-height: 500px;
    width: 900px;
    height: 750px;
    background: var(--surface-window);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    z-index: auto;
    overflow: hidden;
    resize: none;
    border: 1px solid rgba(255, 228, 181, 0.1);
    top: 60px;
    left: 120px;
}

.window.dragging {
    opacity: 0.92;
    cursor: move;
}

.window.resizing {
    opacity: 0.95;
}

/* Window Header (Title Bar) */
.window-header {
    height: var(--window-header-height);
    background: var(--surface-header);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: move;
    user-select: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* macOS Traffic Light Controls */
.window-controls {
    display: flex;
    gap: 8px;
}

.window-control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity var(--transition-normal);
    border: none;
    /* Touch friendly invisible hit area */
    position: relative;
}

.window-control::after {
    content: '';
    position: absolute;
    inset: -6px;
}

.window-control:hover {
    opacity: 0.8;
}

.window-control.close {
    background: var(--control-close);
}

.window-control.minimize {
    background: var(--control-minimize);
}

.window-control.maximize {
    background: var(--control-maximize);
}

.window-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: rgba(60, 60, 60, 0.8);
}

.window-spacer {
    width: 60px;
}

.window-content {
    height: calc(100% - var(--window-header-height));
    overflow: hidden;
    position: relative;
}



/* --- Resize Handles --- */

.resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10;
}

.resize-n  { top: 0; left: 8px; right: 8px; height: 4px; cursor: n-resize; }
.resize-e  { top: 8px; right: 0; bottom: 8px; width: 4px; cursor: e-resize; }
.resize-s  { bottom: 0; left: 8px; right: 8px; height: 4px; cursor: s-resize; }
.resize-w  { top: 8px; left: 0; bottom: 8px; width: 4px; cursor: w-resize; }
.resize-ne { top: 0; right: 0; width: 8px; height: 8px; cursor: ne-resize; }
.resize-nw { top: 0; left: 0; width: 8px; height: 8px; cursor: nw-resize; }
.resize-se { bottom: 0; right: 0; width: 8px; height: 8px; cursor: se-resize; }
.resize-sw { bottom: 0; left: 0; width: 8px; height: 8px; cursor: sw-resize; }


/* ============================================================
   4. AI DEMO WINDOW (ELIZA)
   ============================================================ */

/* --- Split Layout --- */

.eliza-container {
    display: flex;
    height: 100%;
    background: var(--surface-panel);
}

.eliza-chat-panel {
    flex: 0 0 60%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--tree-border);
    min-width: 0;
}

.eliza-context-panel {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    background: var(--surface-inspector);
    min-width: 0;
}


/* --- Toolbar Row --- */

.eliza-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    min-height: var(--toolbar-height);
    background: var(--surface-panel-alt);
    border-bottom: 1px solid var(--tree-border);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--tree-border);
    margin: 0 4px;
}

/* Toggle Buttons (Pill-shaped) */
.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1.5px solid var(--toggle-off);
    background: transparent;
    color: #555;
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    min-height: 32px;
    /* Touch friendly */
    min-width: 44px;
}

.toggle-btn:hover {
    border-color: #777;
    background: rgba(0, 0, 0, 0.03);
}

.toggle-btn.active {
    border-color: var(--toggle-on);
    background: rgba(34, 197, 94, 0.08);
    color: #166534;
}

.toggle-btn .toggle-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--toggle-off);
    transition: background var(--transition-fast);
}

.toggle-btn.active .toggle-indicator {
    background: var(--toggle-on);
}

.toggle-btn .toggle-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Toolbar Dropdown (Prompt Selector) */
.toolbar-select {
    padding: 4px 28px 4px 10px;
    border-radius: 8px;
    border: 1.5px solid var(--tree-border);
    background: var(--surface-panel);
    font-family: var(--font-family);
    font-size: 12px;
    color: #333;
    cursor: pointer;
    min-height: 32px;
    appearance: none;
    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='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    max-width: 180px;
    /* Touch friendly */
    min-width: 44px;
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--color-gold-light);
    box-shadow: 0 0 0 2px rgba(218, 165, 32, 0.15);
}

/* Toolbar Buttons (Reset, Clear) */
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1.5px solid var(--tree-border);
    background: var(--surface-panel);
    font-family: var(--font-family);
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 32px;
    /* Touch friendly */
    min-width: 44px;
}

.toolbar-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.toolbar-btn.danger {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.3);
}

.toolbar-btn.danger:hover {
    background: rgba(220, 38, 38, 0.05);
    border-color: rgba(220, 38, 38, 0.5);
}

.toolbar-btn svg {
    width: 14px;
    height: 14px;
}

/* Toolbar Status Indicators (tiny pill badges) */
.toolbar-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.toolbar-status:empty {
    display: none;
}

.toolbar-status-ok {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
}

.toolbar-status-warn {
    background: rgba(234, 179, 8, 0.12);
    color: #92400e;
}

.toolbar-status-waiting {
    background: rgba(0, 0, 0, 0.05);
    color: #888;
}

/* Cog button */
.toolbar-cog {
    padding: 4px 6px;
    min-width: 32px;
}

.toolbar-cog svg {
    transition: transform 0.3s ease;
}

.toolbar-cog:hover svg {
    transform: rotate(60deg);
}

/* Settings popover panel */
.settings-panel {
    position: absolute;
    z-index: 100;
    background: var(--surface-panel);
    border: 1px solid var(--tree-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 12px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fadeIn 0.15s ease-out;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.settings-value {
    font-size: 12px;
    color: #888;
    font-family: var(--font-mono);
}

.settings-select {
    flex: 1;
    padding: 4px 24px 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--tree-border);
    background: var(--surface-panel-alt);
    font-family: var(--font-family);
    font-size: 12px;
    color: #333;
    cursor: pointer;
    min-height: 30px;
    appearance: none;
    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='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.settings-select:focus {
    outline: none;
    border-color: var(--color-gold-light);
}

.settings-separator {
    height: 1px;
    background: var(--tree-border);
    margin: 4px 0;
}

.settings-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--tree-border);
    background: var(--surface-panel);
    font-family: var(--font-family);
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.settings-action:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.settings-section-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
}

.settings-model-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.settings-model-row:hover {
    background: var(--tree-hover);
}

.settings-model-row.active {
    background: var(--tree-selected);
    border-left: 3px solid var(--color-gold-light);
}

.settings-model-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.settings-model-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.settings-model-meta {
    font-size: 11px;
    color: #999;
    font-family: var(--font-mono);
}

.settings-model-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.settings-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 6px;
    border-radius: 999px;
}

.settings-badge.cached {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
}

.settings-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #999;
    transition: all var(--transition-fast);
}

.settings-icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #555;
}

.settings-icon-btn.danger:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}


/* --- Chat Messages Area --- */

.eliza-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageIn 0.25s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User Messages (right aligned, brown/gold gradient) */
.chat-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message.user .chat-bubble {
    background: linear-gradient(135deg, var(--bubble-user-start), var(--bubble-user-end));
    color: white;
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.2);
}

/* Assistant Messages (left aligned, light gray) */
.chat-message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-message.assistant .chat-bubble {
    background: var(--bubble-assistant);
    color: var(--bubble-assistant-text);
    border-radius: 16px 16px 16px 4px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chat-message .chat-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 4px;
    padding: 0 4px;
}

.chat-message.user .chat-role {
    color: rgba(139, 69, 19, 0.5);
}

/* Tool call messages */
.chat-message.tool {
    align-self: flex-start;
    align-items: flex-start;
    max-width: 90%;
}

.chat-message.tool .chat-bubble {
    background: var(--role-tool-bg);
    border: 1px solid var(--role-tool-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.4;
    color: #333;
    word-wrap: break-word;
}

/* System status messages */
.chat-message.system-status {
    align-self: center;
    max-width: 90%;
}

.chat-message.system-status .chat-bubble {
    background: var(--role-system-bg);
    border: 1px solid var(--role-system-border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: #1e40af;
    text-align: center;
}


/* --- Thinking Dots Animation --- */

.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bubble-assistant);
    border-radius: 16px 16px 16px 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-brown-dark);
    opacity: 0.4;
    animation: thinkingBounce 1.4s infinite ease-in-out;
}

.thinking-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingBounce {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

.thinking-label {
    font-size: 12px;
    color: #888;
    font-style: italic;
}


/* --- Loading Progress Bar (Model Download) --- */

.model-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 24px;
    flex: 1;
}

.model-loading-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.model-loading-subtitle {
    font-size: 13px;
    color: #888;
    text-align: center;
    max-width: 300px;
}

.progress-bar-track {
    width: 100%;
    max-width: 320px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-brown-dark), var(--color-gold-light));
    border-radius: 999px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-bar-fill.indeterminate {
    width: 30%;
    animation: indeterminateSlide 1.5s ease-in-out infinite;
}

@keyframes indeterminateSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.progress-bar-label {
    font-size: 12px;
    color: #888;
    font-variant-numeric: tabular-nums;
}


/* --- Chat Input Area --- */

.eliza-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--tree-border);
    background: var(--surface-panel);
}

.eliza-input {
    flex: 1;
    padding: 8px 14px;
    border: 1.5px solid var(--tree-border);
    border-radius: 999px;
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
    background: var(--surface-panel-alt);
    color: #333;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 40px;
}

.eliza-input:focus {
    border-color: var(--color-gold-light);
    box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.12);
}

.eliza-input::placeholder {
    color: #aaa;
}

.eliza-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.eliza-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--color-brown-dark), var(--color-gold-light));
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 6px rgba(139, 69, 19, 0.3);
}

.eliza-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.4);
}

.eliza-send-btn:active {
    transform: scale(0.95);
}

.eliza-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.eliza-send-btn svg {
    width: 18px;
    height: 18px;
}


/* --- Context Inspector Panel --- */

.context-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.context-header-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.context-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Context Blocks - colored per role */
.context-block {
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.5;
    font-family: var(--font-mono);
    word-wrap: break-word;
    border-left: 3px solid;
    position: relative;
}

.context-block .context-role {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.context-block .context-content {
    color: rgba(255, 255, 255, 0.6);
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

/* System role - blue */
.context-block.role-system {
    background: var(--role-system-bg);
    border-left-color: var(--role-system);
}

.context-block.role-system .context-role {
    color: var(--role-system);
}

/* User role - green */
.context-block.role-user {
    background: var(--role-user-bg);
    border-left-color: var(--role-user);
}

.context-block.role-user .context-role {
    color: var(--role-user);
}

/* Assistant role - gray */
.context-block.role-assistant {
    background: var(--role-assistant-bg);
    border-left-color: var(--role-assistant);
}

.context-block.role-assistant .context-role {
    color: var(--role-assistant);
}

/* Tool role - orange */
.context-block.role-tool {
    background: var(--role-tool-bg);
    border-left-color: var(--role-tool);
}

.context-block.role-tool .context-role {
    color: var(--role-tool);
}

/* Summary role - purple */
.context-block.role-summary {
    background: var(--role-summary-bg);
    border-left-color: var(--role-summary);
}

.context-block.role-summary .context-role {
    color: var(--role-summary);
}

/* Token Counter Bar */
.token-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    min-height: var(--token-bar-height);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.token-count-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.token-count-value {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}

.token-count-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin: 0 12px;
    overflow: hidden;
}

.token-count-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--toggle-on), var(--color-gold-light));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.token-count-bar-fill.warning {
    background: linear-gradient(90deg, var(--badge-modified), #ef4444);
}


/* ============================================================
   5. FILE BROWSER WINDOW
   ============================================================ */

.file-browser-container {
    display: flex;
    height: 100%;
    background: var(--surface-panel);
}

/* Tree Panel (left) */
.file-tree-panel {
    width: 250px;
    min-width: 200px;
    max-width: 350px;
    background: var(--tree-bg);
    border-right: 1px solid var(--tree-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--tree-border);
    min-height: var(--toolbar-height);
}

.file-tree-title {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.file-tree-actions {
    display: flex;
    gap: 4px;
}

.file-tree-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: #888;
    cursor: pointer;
    transition: all var(--transition-fast);
    /* Touch friendly */
    min-width: 44px;
    min-height: 44px;
}

.file-tree-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--tree-border);
    color: #555;
}

.file-tree-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Tree View */
.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.tree-node {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
    white-space: nowrap;
    min-height: 30px;
}

.tree-node:hover {
    background: var(--tree-hover);
}

.tree-node.selected {
    background: var(--tree-selected);
}

.tree-node.selected:hover {
    background: #c7d7f5;
}

/* Indentation (set via inline style or data attribute) */
.tree-node .tree-indent {
    display: inline-block;
    width: 16px;
    flex-shrink: 0;
}

/* Expand/Collapse Arrow */
.tree-node .tree-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #aaa;
    transition: transform var(--transition-fast);
    font-size: 10px;
}

.tree-node .tree-arrow.expanded {
    transform: rotate(90deg);
}

.tree-node .tree-arrow.hidden {
    visibility: hidden;
}

/* File/Folder Icons */
.tree-node .tree-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-right: 6px;
    font-size: 14px;
}

.tree-node .tree-icon.folder {
    color: var(--badge-modified);
}

.tree-node .tree-icon.file {
    color: #6b7280;
}

/* Node Name */
.tree-node .tree-name {
    font-size: 13px;
    color: #333;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badges */
.tree-node .tree-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: 6px;
    flex-shrink: 0;
}

.tree-badge.badge-default {
    background: rgba(59, 130, 246, 0.12);
    color: var(--badge-default);
}

.tree-badge.badge-modified {
    background: rgba(245, 158, 11, 0.12);
    color: var(--badge-modified);
}


/* Content Panel (right) */
.file-content-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.file-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--tree-border);
    min-height: var(--toolbar-height);
    background: var(--surface-panel-alt);
}

.file-content-path {
    font-size: 13px;
    font-family: var(--font-mono);
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-content-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Action Buttons (edit, save, delete, reset) */
.file-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--tree-border);
    background: var(--surface-panel);
    font-family: var(--font-family);
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    /* Touch friendly */
    min-height: 32px;
    min-width: 44px;
}

.file-action-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.file-action-btn.primary {
    background: var(--color-gold-light);
    color: white;
    border-color: var(--color-gold);
}

.file-action-btn.primary:hover {
    background: var(--color-gold);
}

.file-action-btn.danger {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.3);
}

.file-action-btn.danger:hover {
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.5);
}

.file-action-btn svg {
    width: 14px;
    height: 14px;
}

/* File Content Viewer/Editor */
.file-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.file-content-view {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.file-content-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #aaa;
    font-size: 14px;
    font-style: italic;
}

/* File Editor Textarea */
.file-editor-textarea {
    width: 100%;
    height: 100%;
    min-height: 200px;
    padding: 16px;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    background: var(--surface-panel);
}

.file-editor-textarea:focus {
    box-shadow: inset 0 0 0 2px rgba(218, 165, 32, 0.2);
}


/* ============================================================
   6. SCROLLBAR STYLING
   ============================================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Dark panel scrollbars */
.eliza-context-panel ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.eliza-context-panel ::-webkit-scrollbar-thumb {
    background: rgba(255, 228, 181, 0.2);
}

.eliza-context-panel ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 228, 181, 0.35);
}

/* Firefox scrollbar */
.eliza-messages,
.context-messages,
.file-tree,
.file-content-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.eliza-context-panel .context-messages {
    scrollbar-color: rgba(255, 228, 181, 0.2) rgba(0, 0, 0, 0.3);
}


/* ============================================================
   7. ANIMATIONS
   ============================================================ */

/* Twinkle */
@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.twinkle-star {
    animation: twinkle 4s ease-in-out infinite;
}

/* Constellation Drift (GPU accelerated) */
@keyframes constellationDrift {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
    33%  { transform: translate3d(30px, -20px, 0) rotate(120deg); }
    66%  { transform: translate3d(-20px, 30px, 0) rotate(240deg); }
    100% { transform: translate3d(0, 0, 0) rotate(360deg); }
}

/* Fade In (general) */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Pulse */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Window Open/Close */
.window.opening {
    animation: windowOpen 0.3s ease-out;
}

.window.closing {
    animation: windowClose 0.2s ease-in forwards;
}

@keyframes windowOpen {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes windowClose {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
}

/* Tooltip fade */
@keyframes tooltipFadeIn {
    to { opacity: 1; }
}

/* Spinner */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(139, 69, 19, 0.2);
    border-left-color: var(--color-brown-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cursor Blink (terminal) */
@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .constellation-group,
    .twinkle-star {
        animation: none !important;
    }
    .window.opening,
    .window.closing {
        animation-duration: 0.01s !important;
    }
    .thinking-dots .dot {
        animation: none !important;
        opacity: 0.6;
    }
    .progress-bar-fill.indeterminate {
        animation: none !important;
    }
    .chat-message {
        animation: none !important;
    }
}


/* ============================================================
   8. TERMINAL STYLES (for shell window if needed)
   ============================================================ */

.terminal {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.4;
    height: 100%;
    padding: 16px;
    overflow-y: auto;
}

.terminal-output {
    margin-bottom: 16px;
}

.terminal-line {
    margin-bottom: 4px;
    display: flex;
    flex-wrap: wrap;
}

.terminal-prompt {
    color: #4ec9b0;
    font-weight: 600;
    margin-right: 8px;
}

.terminal-command {
    color: #dcdcaa;
}

.terminal-text {
    color: #d4d4d4;
}

.terminal-ascii {
    font-family: var(--font-mono) !important;
    white-space: pre !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    position: relative;
    margin-top: 8px;
}

.terminal-input {
    background: transparent;
    border: none;
    outline: none;
    color: #dcdcaa;
    font-family: inherit;
    font-size: inherit;
    flex: 1;
    caret-color: #d4d4d4;
}

.terminal-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: #d4d4d4;
    animation: cursorBlink 1s infinite;
    margin-left: 2px;
}

/* Typing dots (kept for backward compat, used in terminal) */
.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-brown-dark);
    opacity: 0.4;
    animation: thinkingBounce 1.4s infinite ease-in-out;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}


/* ============================================================
   9. RESPONSIVE DESIGN
   ============================================================ */

/* --- Tablet (below 1024px) --- */
@media (max-width: 1024px) {

    /* AI Demo: single column layout */
    .eliza-container {
        flex-direction: column;
    }

    .eliza-chat-panel {
        flex: 1;
        border-right: none;
        border-bottom: 1px solid var(--tree-border);
    }

    .eliza-context-panel {
        flex: 0 0 auto;
        max-height: 40vh;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    /* Context panel becomes collapsible bottom panel */
    .eliza-context-panel.collapsed {
        max-height: var(--toolbar-height);
        overflow: hidden;
    }

    .eliza-context-panel .context-header {
        cursor: pointer;
    }

    .eliza-context-panel .context-header::after {
        content: '';
        display: inline-block;
        width: 0;
        height: 0;
        margin-left: 8px;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-bottom: 5px solid rgba(255, 255, 255, 0.5);
        transition: transform var(--transition-fast);
    }

    .eliza-context-panel.collapsed .context-header::after {
        transform: rotate(180deg);
    }

    /* File browser: tree panel narrower */
    .file-tree-panel {
        width: 200px;
        min-width: 160px;
    }

    /* Toolbar wraps */
    .eliza-toolbar {
        gap: 6px;
    }

    .toolbar-separator {
        display: none;
    }

    /* Slightly smaller windows */
    .window {
        min-width: 400px;
        min-height: 350px;
    }
}


/* --- Phone (below 768px) --- */
@media (max-width: 768px) {

    /* Taskbar becomes bottom horizontal bar */
    .taskbar {
        width: 100vw;
        height: 56px;
        position: fixed;
        left: 0;
        top: auto;
        bottom: 0;
        border-radius: 0;
        flex-direction: row;
        padding: 0 12px;
        border-top: 1px solid rgba(255, 228, 181, 0.1);
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .taskbar-top,
    .taskbar-center {
        flex-direction: row;
    }

    .taskbar-bottom {
        flex-direction: row;
    }

    .app-icons {
        flex-direction: row;
        margin-top: 0;
        gap: 8px;
    }

    .app-icon {
        width: 40px;
        height: 40px;
    }

    /* Hide app icon tooltips on mobile (not useful) */
    .app-icon::before {
        display: none;
    }

    /* Language switcher horizontal */
    .language-switcher {
        flex-direction: row;
        margin-bottom: 0;
        padding: 0;
        border-bottom: none;
        border-left: 1px solid rgba(255, 228, 181, 0.1);
        padding-left: 8px;
    }

    .bottom-icons {
        flex-direction: row;
    }

    .bottom-icon[title]:hover::after {
        display: none;
    }

    /* Desktop content adjusts for bottom taskbar */
    .desktop-content {
        padding: 10px;
        padding-bottom: 66px; /* space for bottom taskbar */
    }

    /* Windows go full-screen */
    .window {
        position: fixed !important;
        top: var(--topbar-height) !important;
        left: 0 !important;
        width: 100vw !important;
        height: calc(100vh - var(--topbar-height) - 56px) !important;
        min-width: 0 !important;
        min-height: 0 !important;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    /* Hide resize handles on mobile */
    .resize-handle {
        display: none;
    }

    /* Window header adjustments */
    .window-header {
        height: 36px;
        padding: 0 10px;
    }

    .window-title {
        font-size: 13px;
    }

    .window-content {
        height: calc(100% - 36px);
    }

    /* AI Demo: full stack layout */
    .eliza-container {
        flex-direction: column;
    }

    .eliza-chat-panel {
        flex: 1;
        border-right: none;
    }

    .eliza-context-panel {
        flex: 0 0 auto;
        max-height: 35vh;
    }

    .eliza-context-panel.collapsed {
        max-height: var(--toolbar-height);
    }

    /* Toolbar stacks on narrow screens */
    .eliza-toolbar {
        padding: 6px 8px;
        gap: 4px;
    }

    .toggle-btn {
        padding: 3px 8px;
        font-size: 11px;
        min-height: 28px;
    }

    .toolbar-select {
        font-size: 11px;
        max-width: 120px;
    }

    /* File browser: single column */
    .file-browser-container {
        flex-direction: column;
    }

    .file-tree-panel {
        width: 100%;
        max-width: none;
        max-height: 40%;
        border-right: none;
        border-bottom: 1px solid var(--tree-border);
    }

    .file-content-panel {
        flex: 1;
    }

    /* Chat bubbles wider */
    .chat-message {
        max-width: 90%;
    }

    /* Larger tap targets */
    .eliza-send-btn {
        width: 44px;
        height: 44px;
    }

    .eliza-input {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
}

/* --- Very small screens (below 480px) --- */
@media (max-width: 480px) {

    .eliza-toolbar {
        padding: 4px 6px;
    }

    .toggle-btn {
        padding: 2px 6px;
        font-size: 10px;
    }

    .toggle-btn .toggle-label {
        display: none;
    }

    .toolbar-select {
        max-width: 90px;
    }

    .toolbar-btn {
        padding: 2px 6px;
        font-size: 11px;
    }

    .chat-message {
        max-width: 95%;
    }

    .chat-message .chat-bubble {
        font-size: 13px;
    }

    .file-tree-panel {
        max-height: 35%;
    }
}


/* ============================================================
   10. UTILITY & MISC
   ============================================================ */

/* Fullscreen overlay (for modals, etc.) */
.fullscreen-overlay {
    animation: fadeIn 0.3s ease;
}

.fullscreen-close {
    animation: fadeIn 0.5s ease 0.2s both;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Text overflow */
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Focus visible for keyboard nav */
:focus-visible {
    outline: 2px solid var(--color-gold-light);
    outline-offset: 2px;
}

/* Prevent text selection during drag */
.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* Context Inspector - Empty state */
.context-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

/* Tool call details in chat */
.tool-call-header {
    font-weight: 600;
    font-size: 12px;
    color: var(--role-tool);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tool-call-args,
.tool-call-result {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 4px;
    padding: 6px 8px;
    margin: 4px 0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.tool-call-result-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    margin-top: 4px;
}

/* Thinking indicator (inherits from chat-message assistant) */
.eliza-thinking .chat-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Eliza window specific: toolbar sits between header and content */
.eliza-window {
    display: flex;
    flex-direction: column;
}

.eliza-window .window-content {
    height: auto;
    flex: 1;
    min-height: 0;
}

/* Print: hide OS chrome */
@media print {
    .desktop,
    .taskbar,
    .top-bar,
    .star-background,
    .star-constellations,
    .film-grain,
    .blur-overlay {
        display: none !important;
    }
}
