/* ═══════════════════════════════════════════════════════════════
   NebulaDrive — Design System
   Dark glassmorphism theme with purple-blue gradient accents
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --bg-primary: #07070d;
    --bg-secondary: #0e0e18;
    --bg-tertiary: #141422;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-card-active: rgba(255, 255, 255, 0.09);

    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 16px;
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    --accent-primary: #7c3aed;
    --accent-secondary: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #3b82f6 50%, #06b6d4 100%);
    --accent-gradient-hover: linear-gradient(135deg, #8b5cf6 0%, #60a5fa 50%, #22d3ee 100%);
    --accent-glow: rgba(124, 58, 237, 0.3);
    --accent-glow-blue: rgba(59, 130, 246, 0.2);

    --text-primary: #f1f1f6;
    --text-secondary: #a0a0b8;
    --text-tertiary: #6b6b80;
    --text-accent: #a78bfa;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.10);
    --border-accent: rgba(124, 58, 237, 0.3);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
}

/* ── Light Theme ────────────────────────────────────────── */
[data-theme="light"] {
    --bg-primary: #f0f0f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8f0;
    --bg-card: rgba(0, 0, 0, 0.03);
    --bg-card-hover: rgba(0, 0, 0, 0.06);
    --bg-card-active: rgba(0, 0, 0, 0.09);

    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);

    --accent-glow: rgba(124, 58, 237, 0.12);
    --accent-glow-blue: rgba(59, 130, 246, 0.08);

    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-tertiary: #8888a0;
    --text-accent: #6d28d9;

    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.12);
    --border-accent: rgba(124, 58, 237, 0.25);
}

[data-theme="light"] body::before {
    opacity: 0.15 !important;
}

[data-theme="light"] body::after {
    opacity: 0.1 !important;
}

[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .login-card {
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .modal {
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .toast {
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] select,
[data-theme="light"] select option {
    background: #ffffff;
    color: #1a1a2e;
}

[data-theme="light"] input,
[data-theme="light"] textarea {
    background: rgba(0, 0, 0, 0.03);
    color: #1a1a2e;
}

[data-theme="light"] .message-composer textarea {
    background: #f5f5fa;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
    transition: background var(--transition-base), color var(--transition-base);
}

/* Background ambient glow */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: ambientPulse 8s ease-in-out infinite alternate;
}

body::after {
    content: '';
    position: fixed;
    bottom: -200px;
    left: -100px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-glow-blue) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: ambientPulse 10s ease-in-out infinite alternate-reverse;
}

@keyframes ambientPulse {
    0% {
        opacity: 0.4;
        transform: scale(1);
    }

    100% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

a {
    color: var(--text-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    color: inherit;
}

input,
textarea,
select {
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-base), color var(--transition-base);
    width: 100%;
}

/* Dark mode select/dropdown fix */
select {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
}

select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 8px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── App Layout ────────────────────────────────────────────── */
.app {
    display: flex;
    height: 100vh;
    position: relative;
    z-index: 1;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    transition: width var(--transition-base);
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 0 24px;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.sidebar-logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-tertiary);
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
    margin-bottom: 2px;
    user-select: none;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(124, 58, 237, 0.12);
    color: var(--text-accent);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
}

.nav-item .icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.sidebar-user:hover {
    background: var(--bg-card-hover);
}

.sidebar-user .avatar {
    width: 34px;
    height: 34px;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.sidebar-user .user-role {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

/* ── Main Content ──────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Header ────────────────────────────────────────────────── */
.header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    flex-shrink: 0;
    background: rgba(7, 7, 13, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.header-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.header-search input {
    padding-left: 40px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    height: 40px;
    font-size: 0.85rem;
}

.header-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 0.9rem;
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ── Content Area ──────────────────────────────────────────── */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: pageIn 0.3s ease;
}

#page-ai-chat.active {
    display: flex;
    flex-direction: column;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Glass Card ────────────────────────────────────────────── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-base);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    box-shadow: 0 6px 24px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
}

.btn-ghost {
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

/* ── Dashboard ─────────────────────────────────────────────── */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-base);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.purple {
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.stat-icon.amber {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-info p {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Recent activity */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

/* ── Upload Zone ───────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 60px 40px;
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: var(--glass-bg);
}

.upload-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.05);
}

.upload-zone.drag-over::before {
    opacity: 0.05;
}

.upload-zone.drag-over .upload-icon {
    transform: scale(1.1);
    color: var(--accent-primary);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--text-tertiary);
    transition: all var(--transition-base);
    position: relative;
    z-index: 1;
}

.upload-zone h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.upload-zone p {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

.upload-zone .browse-link {
    color: var(--text-accent);
    cursor: pointer;
    font-weight: 600;
}

.upload-zone .browse-link:hover {
    text-decoration: underline;
}

/* Upload settings */
.upload-settings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
}

.upload-settings .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.upload-settings label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Upload progress */
.upload-queue {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upload-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.upload-item .file-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.upload-item .file-info {
    flex: 1;
    min-width: 0;
}

.upload-item .file-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-item .file-size {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.upload-item .progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    margin-top: 8px;
    overflow: hidden;
}

.upload-item .progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

.upload-item .status-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.upload-item .status-icon.success {
    color: var(--success);
}

.upload-item .status-icon.error {
    color: var(--error);
}

.upload-item .status-icon.pending {
    color: var(--text-tertiary);
}

/* ── File Browser ──────────────────────────────────────────── */
.files-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.files-toolbar .view-toggle {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.files-toolbar .view-toggle button {
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.files-toolbar .view-toggle button.active {
    background: var(--accent-primary);
    color: white;
}

.files-toolbar .filter-select {
    width: auto;
    min-width: 160px;
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Grid view */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.file-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.file-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.file-card .file-type-icon {
    font-size: 2.2rem;
    margin-bottom: 14px;
}

.file-card .file-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-word;
    line-height: 1.3;
}

.file-card .file-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-card .file-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    display: flex;
    gap: 4px;
}

.file-card:hover .file-actions {
    opacity: 1;
}

.file-card .visibility-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.visibility-badge.public {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.visibility-badge.private {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* List view */
.files-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-row {
    display: grid;
    grid-template-columns: auto 1fr 120px 100px 100px 60px;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    cursor: pointer;
    font-size: 0.85rem;
}

.file-row:hover {
    background: var(--bg-card-hover);
}

.file-row .file-icon {
    font-size: 1.3rem;
}

.file-row .file-name {
    font-weight: 500;
}

.file-row .file-category {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.file-row .file-size {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    text-align: right;
}

.file-row .file-date {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    text-align: right;
}

/* ── Icon View ─────────────────────────────────────────────── */
.files-icons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    padding: 8px 0;
}

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    text-align: center;
    position: relative;
}

.icon-item:hover {
    background: var(--bg-card-hover);
}

.icon-item.selected {
    background: rgba(124, 58, 237, 0.15);
    border: 2px solid var(--accent-primary);
    padding: 12px 6px 8px;
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.icon-item .icon-file-icon {
    font-size: 3rem;
    margin-bottom: 6px;
    transition: transform var(--transition-fast);
}

.icon-item:hover .icon-file-icon {
    transform: scale(1.08);
}

.icon-item .icon-file-name {
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.25;
    word-break: break-word;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-primary);
}

/* ── Canvas View ───────────────────────────────────────────── */
.canvas-area {
    position: relative;
    min-height: 600px;
    background:
        radial-gradient(circle at 1px 1px, var(--border-subtle) 1px, transparent 0);
    background-size: 40px 40px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.canvas-item {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 10px 8px;
    border-radius: var(--radius-md);
    cursor: grab;
    user-select: none;
    text-align: center;
    width: 110px;
    transition: box-shadow var(--transition-fast);
    z-index: 1;
}

.canvas-item:hover {
    background: var(--bg-card-hover);
    z-index: 10;
}

.canvas-item.dragging {
    cursor: grabbing;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    z-index: 100;
    opacity: 0.9;
}

.canvas-item.selected {
    background: rgba(124, 58, 237, 0.15);
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.canvas-item .canvas-file-icon {
    font-size: 2.8rem;
    margin-bottom: 4px;
    pointer-events: none;
}

.canvas-item .canvas-file-name {
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.2;
    word-break: break-word;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    pointer-events: none;
}

/* ── Selection Bar ─────────────────────────────────────────── */
.selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--accent-primary);
    color: white;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    animation: slideDown 0.2s ease;
}

.selection-bar.hidden {
    display: none;
}

.selection-actions {
    display: flex;
    gap: 8px;
}

.selection-bar .btn {
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.selection-bar .btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Icon Tabs (Category Modal) ────────────────────────────── */
.icon-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 4px;
}

.icon-tab {
    flex: 1;
    padding: 7px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    text-align: center;
}

.icon-tab:hover {
    color: var(--text-primary);
}

.icon-tab.active {
    background: var(--accent-primary);
    color: white;
}

.icon-tab-content {
    display: none;
}

.icon-tab-content.active {
    display: block;
}

.icon-preset-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.icon-preset {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-card);
    border: 2px solid transparent;
}

.icon-preset:hover {
    background: var(--bg-card-hover);
    transform: scale(1.1);
}

.icon-preset.selected {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.15);
}

.custom-icon-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.custom-icon-preview {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-icon-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Categories ────────────────────────────────────────────── */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.category-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--cat-color, var(--accent-gradient));
}

.category-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.category-card .cat-icon {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.category-card .cat-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.category-card .cat-count {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.category-card .cat-actions {
    position: absolute;
    top: 16px;
    right: 16px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    display: flex;
    gap: 4px;
}

.category-card:hover .cat-actions {
    opacity: 1;
}

/* Add category card */
.category-card.add-new {
    border-style: dashed;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    color: var(--text-tertiary);
}

.category-card.add-new:hover {
    color: var(--text-accent);
    border-color: var(--accent-primary);
}

.category-card.add-new .add-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

/* ── Messages / Notes ──────────────────────────────────────── */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-composer {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.message-composer textarea {
    min-height: 100px;
    resize: vertical;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
}

.message-composer .composer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.message-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-fast);
}

.message-card:hover {
    background: var(--bg-card-hover);
}

.message-card .msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.message-card .msg-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.message-card .msg-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.message-card .msg-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.message-card:hover .msg-actions {
    opacity: 1;
}

/* ── Login Modal ───────────────────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.login-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s var(--transition-spring);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .login-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: var(--accent-gradient);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px var(--accent-glow);
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.login-card .login-subtitle {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-form label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.login-form input {
    height: 44px;
    background: var(--bg-card);
}

.login-form .btn-primary {
    height: 44px;
    font-size: 0.9rem;
    margin-top: 8px;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--error);
    display: none;
}

.login-error.show {
    display: block;
}

/* ── Modal (Generic) ──────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.modal h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal .form-group {
    margin-bottom: 16px;
}

.modal .form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ── Toggle / Switch ──────────────────────────────────────── */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle.active::after {
    left: 23px;
    background: white;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.85rem;
    max-width: 360px;
    margin: 0 auto;
}

/* ── Toast / Notification ──────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-size: 0.85rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    min-width: 300px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast.info {
    border-left: 3px solid var(--info);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ── Loading Spinner ───────────────────────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-medium);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(7, 7, 13, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 5;
}

/* ── Color Picker ──────────────────────────────────────────── */
.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.selected {
    border-color: white;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -var(--sidebar-width);
        z-index: 100;
        transition: left var(--transition-base);
    }

    .sidebar.open {
        left: 0;
    }

    .header {
        padding: 0 16px;
    }

    .content {
        padding: 16px;
    }

    .upload-settings {
        grid-template-columns: 1fr;
    }

    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .file-row {
        grid-template-columns: auto 1fr auto;
    }

    .file-row .file-category,
    .file-row .file-date {
        display: none;
    }
}

/* ── Utility ───────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.gap-sm {
    gap: 8px;
}

.gap-md {
    gap: 16px;
}

.mt-sm {
    margin-top: 8px;
}

.mt-md {
    margin-top: 16px;
}

.mt-lg {
    margin-top: 24px;
}

.mb-md {
    margin-bottom: 16px;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-tertiary);
}

.text-sm {
    font-size: 0.8rem;
}

.fw-600 {
    font-weight: 600;
}

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── User Management ──────────────────────────────────────── */
.category-access-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 16px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px 0;
}

select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

select:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#userRole {
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
/* ── AI Settings Grid ──────────────────────────────────────── */
.settings-card {
    max-width: 900px;
    margin: 0 auto;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-top: 24px;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-settings-layout {
    max-width: 980px;
    margin: 0 auto;
    align-items: start;
}

.ai-settings-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    min-height: 100%;
}

.ai-settings-panel .form-group {
    display: block;
    width: 100%;
}

.ai-settings-panel .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-settings-panel .form-group input,
.ai-settings-panel .form-group select,
.ai-settings-panel .form-group textarea {
    display: block;
    width: 100%;
    max-width: 100%;
}

.ai-settings-panel .form-group small {
    display: block;
    line-height: 1.5;
}

#groupHfToken {
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: var(--radius-lg);
    padding: 20px;
}

#groupHfToken label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.token-input-wrap {
    position: relative;
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: nowrap;
}

.token-input-wrap input {
    flex: 1;
    min-height: 50px;
    padding: 12px 16px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.token-input-wrap input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
}

.token-toggle {
    width: 44px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.token-toggle:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.token-help-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    display: block;
    width: 100%;
    margin-top: 12px;
}

.token-help-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.token-help-steps {
    font-size: 0.82rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.token-help-steps a {
    color: var(--text-accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.token-help-steps a:hover {
    color: #a78bfa;
}

.token-help-steps strong {
    color: var(--text-primary);
    font-weight: 600;
}

.settings-subtitle {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.model-preview {
    margin-top: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.model-preview-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.model-preview-top a {
    color: var(--text-accent);
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.model-preview-top a:hover {
    text-decoration: underline;
}

.model-chip {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #dbeafe;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.45), rgba(6, 182, 212, 0.45));
    border: 1px solid rgba(125, 211, 252, 0.45);
    border-radius: var(--radius-full);
    padding: 3px 8px;
}

.model-preview-note {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.text-warning {
    color: var(--warning);
}

@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .model-preview-top {
        flex-direction: column;
        align-items: flex-start;
    }
}

.chat-container-fullscreen {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-input-area {
    padding: 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area textarea:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.chat-input-area .btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
    transform: none;
}

.chat-input-area .btn.is-loading {
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.ai-gen-state {
    color: var(--text-accent);
    margin-top: 2px;
}

.ai-gen-state::after {
    content: '...';
    display: inline-block;
    width: 12px;
    overflow: hidden;
    vertical-align: bottom;
    animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
    from { width: 0; }
    to { width: 12px; }
}

.chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    line-height: 1.5;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-msg.ai {
    align-self: flex-start;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 2px;
}

.chat-msg.loading {
    opacity: 0.7;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 14px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typingPulse 1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.16s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes typingPulse {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-msg.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
    align-self: center;
    max-width: 90%;
}

.chat-msg p {
    margin-bottom: 0.5em;
}

.chat-msg p:last-child {
    margin-bottom: 0;
}

.chat-msg code {
    background: rgba(0,0,0,0.3);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

.chat-msg pre {
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
