/* ============================================
   FortyFox — Design System
   ============================================ */

:root {
    /* Light Mode (Modern Premium) */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --bg-app: #ffffff;
    --bg-sidebar: #f8f8fc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f2f6;
    --bg-input: #f8f8fc;

    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;

    --border: #e4e4e7;
    --border-hover: #d4d4d8;

    --accent: #f59e0b;
    /* Warm Amber (Brand) */
    --accent-dim: rgba(245, 158, 11, 0.1);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --fast: 0.15s ease;

    /* Semantic Colors */
    --green: #10b981;
    --red: #ef4444;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --orange: #f97316;
}

[data-theme="dark"] {
    /* Dark Mode (Deep Premium) */
    --bg-app: #09090b;
    --bg-sidebar: #111113;
    --bg-surface: #18181b;
    --bg-surface-hover: #27272a;
    --bg-input: #18181b;

    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    --border: #27272a;
    --border-hover: #3f3f46;

    --accent: #fbbf24;
    --accent-dim: rgba(251, 191, 36, 0.1);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    transition: background var(--fast), color var(--fast);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Background Effect (Subtle glow) */
.app-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(circle at 50% 0%, var(--accent-dim), transparent 60%);
    opacity: 0.6;
}

.app-container {
    display: flex;
    height: 100%;
    position: relative;
    z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform var(--fast), width var(--fast);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(239, 68, 68, 0.15));
    background-clip: padding-box;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

/* Theme-switched logo */
[data-theme="light"] .brand-logo {
    content: url('logo-dark.png');
}

.brand-logo {
    transition: opacity var(--fast);
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.credit-text {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    margin-top: 3px;
    letter-spacing: 0.2px;
    transition: color var(--fast);
}

.credit-text:hover {
    color: var(--accent);
}

.header-actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    background: none;
    border: none;
    padding: 6px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--fast);
    display: flex;
    align-items: center;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.icon-btn .sun-icon {
    display: block;
}

.icon-btn .moon-icon {
    display: none;
}

[data-theme="light"] .icon-btn .sun-icon {
    display: none;
}

[data-theme="light"] .icon-btn .moon-icon {
    display: block;
}

.icon-btn-sm {
    background: transparent;
    border: none;
    padding: 6px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn-sm:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

/* Sidebar Sections */
.sidebar-section {
    padding: 12px 16px;
}

.sidebar-section.compact {
    padding: 8px 16px;
}

.sidebar-section.flex-grow {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* API Key & Username Inputs */
.api-key-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--fast);
}

.api-key-bar:hover {
    border-color: var(--border-hover);
    background: var(--bg-surface-hover);
}

.api-key-panel {
    padding-top: 8px;
}

.api-key-input-wrap,
.username-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    transition: all var(--fast);
}

.api-key-input-wrap:focus-within,
.username-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.api-key-input,
.username-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    outline: none;
}

.username-input {
    font-family: var(--font-sans);
    font-size: 12px;
}

.apply-key-btn {
    background: var(--green);
    border: none;
    color: white;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: transform var(--fast);
}

.apply-key-btn:hover {
    transform: scale(1.1);
}

.ap.primary-btn:active {
    transform: translateY(0);
}

/* --- Retro Terminal Loader --- */
.retro-loader {
    position: fixed;
    inset: 0;
    background: #09090b;
    z-index: 9999;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.retro-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.terminal-content {
    width: 100%;
    max-width: 600px;
    padding: 20px;
}

#loaderAscii {
    font-size: 8px;
    line-height: 8px;
    font-weight: 700;
    color: var(--accent);
    /* Amber */
    margin-bottom: 2rem;
    white-space: pre;
    overflow-x: hidden;
}

.terminal-logs {
    height: 120px;
    overflow: hidden;
    font-size: 13px;
    color: #10b981;
    /* Green */
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-left: 2px solid #333;
    padding-left: 12px;
}

.terminal-input-line {
    display: flex;
    gap: 8px;
    font-size: 14px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

.prompt {
    color: var(--accent);
    font-weight: bold;
}

.cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: #10b981;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

.apply-key-btn.applied {
    background: var(--text-muted);
    pointer-events: none;
}

.api-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
}

.status-dot.active {
    background: var(--green);
    box-shadow: 0 0 4px var(--green);
}

.status-dot.error {
    background: var(--red);
}

.status-dot.testing {
    background: var(--accent);
    animation: pulse 1s infinite;
}

/* Model Dropdown */
.model-dropdown-wrap {
    position: relative;
}

.model-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--fast);
}

.model-dropdown-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-surface-hover);
}

.model-dropdown-arrow {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform var(--fast);
}

.model-dropdown-btn.open .model-dropdown-arrow {
    transform: rotate(180deg);
}

.model-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
}

.model-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 2;
    margin: -6px -6px 4px -6px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.model-search-input {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: all var(--fast);
}

.model-option:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.model-option.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.model-option-info {
    flex: 1;
}

.model-option-name {
    display: block;
    font-weight: 500;
}

.model-option-provider {
    font-size: 10px;
    color: var(--text-muted);
    display: block;
}

.model-option-check {
    opacity: 0;
    color: var(--accent);
}

.model-option.active .model-option-check {
    opacity: 1;
}

.pill-badge {
    background: linear-gradient(135deg, var(--accent), var(--red));
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 100px;
    margin-left: auto;
}

/* Chat List & Categories */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    color: var(--text-muted);
    transition: all var(--fast);
}

.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
    color: var(--text-primary);
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.filter-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.filter-chip {
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--fast);
}

.filter-chip:hover {
    border-color: var(--border-hover);
    background: var(--bg-surface-hover);
}

.filter-chip.active {
    background: var(--text-primary);
    color: var(--bg-app);
    border-color: transparent;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
}

/* Chat Groups */
/* Chat Groups */
.cat-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    /* Orange-yellowish */
    padding: 12px 16px 4px;
    position: sticky;
    top: 0;
    background: var(--bg-sidebar);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Right aligned */
    gap: 6px;
}

/* Compact Chat Item */
.chat-item {
    display: block;
    width: 100%;
    padding: 4px 8px;
    /* Reduced from 6px 12px */
    margin-bottom: 2px;
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--fast);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid transparent;
    height: 32px;
    /* Fixed height for consistency */
    display: flex;
    /* Use flex for alignment */
    align-items: center;
}

.chat-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.chat-item.active {
    background: linear-gradient(90deg, var(--bg-surface), transparent);
    color: var(--text-primary);
    font-weight: 500;
    border-left-color: var(--accent);
}

.chat-item-star {
    position: absolute;
    right: 8px;
    top: 10px;
    color: var(--accent);
    display: none;
}

.chat-item.starred .chat-item-star {
    display: block;
}

.chat-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.chat-item-title {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.chat-item.active .chat-item-title {
    color: var(--text-primary);
}

.chat-item-meta {
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.chat-item-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 6px;
    opacity: 0;
    transition: opacity var(--fast);
}

.chat-item:hover .chat-item-actions {
    opacity: 1;
}

.chat-item-action-btn {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    transition: all var(--fast);
    cursor: pointer;
}

.chat-item-action-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.chat-item-action-btn.del:hover {
    color: var(--red);
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.footer-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--fast);
}

.footer-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.footer-btn.danger:hover {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

/* --- Chat Main --- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-app);
}

.chat-header {
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(var(--bg-app), 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.header-model {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-model-label {
    font-size: 10px;
    color: var(--text-muted);
    display: block;
    text-transform: uppercase;
}

.header-model-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.model-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--fast);
}

.category-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.category-selector {
    position: relative;
}

.category-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: var(--shadow-lg);
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 50;
}

.cat-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

.cat-option:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.cat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.token-pill {
    padding: 4px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Messages */
.messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    scroll-behavior: smooth;
}

.messages-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 16px;
    font-size: 15px;
    line-height: 1.6;
}

.message.user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.message.assistant .msg-avatar {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--accent);
}

.message.user .msg-avatar {
    background: var(--text-primary);
    color: var(--bg-app);
}

.msg-content {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message.user .msg-content {
    align-items: flex-end;
}

.msg-header {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.markdown-body {
    background: var(--bg-surface);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.message.user .markdown-body {
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-md) 2px 2px var(--radius-md);
}

.markdown-body pre {
    background: #0d0d0d;
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    margin: 10px 0;
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

/* Welcome Screen */
.welcome-view {
    text-align: center;
    margin: auto 0;
    padding: 40px 0;
}

.welcome-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.welcome-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-sub {
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.prompt-card {
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: left;
    cursor: pointer;
    transition: all var(--fast);
    display: flex;
    gap: 12px;
    align-items: center;
}

.prompt-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.prompt-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.prompt-card-text {
    flex: 1;
}

.prompt-card-title {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.prompt-card-desc {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Input Area */
.input-area {
    padding: 24px;
    max-width: 840px;
    margin: 0 auto;
    width: 100%;
}

.input-wrap {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all var(--fast);
}

.input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.msg-input {
    width: 100%;
    border: none;
    background: none;
    resize: none;
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--text-primary);
    max-height: 200px;
    outline: none;
}

.input-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.char-counter {
    font-size: 11px;
    color: var(--text-muted);
}

.send-btn,
.stop-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--fast);
}

.send-btn {
    background: var(--text-primary);
    color: var(--bg-app);
}

.send-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.stop-btn {
    background: var(--red);
    color: white;
}

.input-tip {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
}

kbd {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 4px;
    font-family: var(--font-mono);
    font-size: 10px;
}



/* Utilities */
.hidden {
    display: none !important;
}

.mobile-only {
    display: none;
}

@keyframes pulse {
    50% {
        opacity: 0.5;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-only {
        display: flex;
    }
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Username Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--fast);
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform var(--fast);
}

.modal-overlay:not(.hidden) .modal-card {
    transform: scale(1);
}

.modal-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-sidebar);
    border-radius: 50%;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    border: 1px solid var(--border);
}

.modal-icon svg {
    width: 24px;
    height: 24px;
}

.modal-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
    font-size: 15px;
    transition: all var(--fast);
}

.modal-input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.primary-btn {
    width: 100%;
    padding: 12px;
    background: var(--text-primary);
    /* Keep contrast per request or revert to accent? I'll use text-primary (black/white) as it fits 'Minimal Premium' best */
    color: var(--bg-app);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--fast);
}

.primary-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* --- Retro Terminal Loader --- */
.retro-loader {
    position: fixed;
    inset: 0;
    background: #09090b;
    z-index: 9999;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.retro-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.terminal-content {
    width: 100%;
    max-width: 600px;
    padding: 20px;
}

#loaderAscii {
    font-size: 8px;
    line-height: 8px;
    font-weight: 700;
    color: var(--accent);
    /* Amber */
    margin-bottom: 2rem;
    white-space: pre;
    overflow-x: hidden;
}

.terminal-logs {
    height: 120px;
    overflow: hidden;
    font-size: 13px;
    color: #10b981;
    /* Green */
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-left: 2px solid #333;
    padding-left: 12px;
}

.terminal-input-line {
    display: flex;
    gap: 8px;
    font-size: 14px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

.prompt {
    color: var(--accent);
    font-weight: bold;
}

.cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: #10b981;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* Loader Credit */
.loader-credit {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #6fb981;
    /* Dim green */
    text-align: right;
    width: 100%;
    margin-top: -1.5rem;
    margin-bottom: 1.5rem;
    padding-right: 20px;
    opacity: 0.8;
}

/* Circular Delete Button */
.chat-item-del {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    transition: all var(--fast);
    opacity: 0;
    /* Show on hover for clean look */
}

.chat-item:hover .chat-item-del {
    opacity: 1;
}

.chat-item-del:hover {
    background: var(--bg-input);
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Desktop Sidebar Collapse */
@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar {
        width: 0;
        min-width: 0;
        padding: 0;
        overflow: hidden;
        border-right: none;
        opacity: 0;
        visibility: hidden;
        transition: all var(--fast);
    }

    /* Show Open Button on Desktop when collapsed */
    body.sidebar-collapsed #sidebarOpen {
        display: flex !important;
    }
}

/* --- Floating Action Button (New Chat) --- */
.fab-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--fast);
    z-index: 100;
}

.fab-btn:hover {
    transform: scale(1.05) rotate(90deg);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

.fab-btn svg {
    width: 20px;
    height: 20px;
}