/* Neural Intelligence - Utilitarian + Flashy Design */

:root {
    --bg-primary: #07070a;
    --bg-surface: rgba(18, 18, 24, 0.85);
    --bg-elevated: rgba(28, 28, 38, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(139, 92, 246, 0.4);
    
    --text-primary: #f5f5fa;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    
    --accent-primary: #8b5cf6;
    --accent-secondary: #6366f1;
    --accent-cyan: #06b6d4;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    
    --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #06b6d4 100%);
    --gradient-glow: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(6, 182, 212, 0.3) 100%);
    --gradient-bg: radial-gradient(ellipse at top, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
                   radial-gradient(ellipse at bottom right, rgba(6, 182, 212, 0.05) 0%, transparent 40%);
    
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.2);
    --shadow-glow-strong: 0 0 30px rgba(139, 92, 246, 0.4);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    
    --transition-fast: 0.15s ease;
    --transition: 0.25s ease;
    --transition-slow: 0.4s ease;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-primary);
    background-image: var(--gradient-bg);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    line-height: 1.6;
}

/* Animated background grid */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(139, 92, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139, 92, 246, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
}

/* Layout */
.main-container {
    max-width: 1280px;
    margin: 0 auto;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 960px) {
    .content-grid { grid-template-columns: 1fr; }
}

/* Header - Clean with gradient accent */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 120px;
    height: 2px;
    background: var(--gradient-primary);
    border-radius: 1px;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header h1 i {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.5));
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.user-menu {
    position: relative;
    margin-left: 10px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition);
}

.user-profile:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent-primary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary);
}

.user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.user-name {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    min-width: 200px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-header strong {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.dropdown-header small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.dropdown-item:hover {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-primary);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.dropdown-item:hover i {
    color: var(--accent-primary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

/* Buttons - Glass effect with glow */
.btn {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-glow);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary::before {
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow-strong);
    transform: translateY(-2px);
}

.btn-danger {
    color: var(--accent-danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-danger);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

/* Cards - Glassmorphism */
.card {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.2);
}

.card-header i {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card-body {
    padding: 18px;
}

/* Sense Status Grid - Animated indicators */
.sense-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.sense-item {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    font-size: 0.75rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.sense-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-glow);
    opacity: 0;
    transition: opacity var(--transition);
}

.sense-item i {
    display: block;
    font-size: 18px;
    margin-bottom: 6px;
    color: var(--text-muted);
    transition: all var(--transition);
    position: relative;
    z-index: 1;
}

.sense-item span {
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.sense-item:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
}

.sense-item:hover i {
    color: var(--accent-primary);
}

/* Active state with pulse animation */
.sense-item.active {
    border-color: var(--accent-primary);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.sense-item.active::before {
    opacity: 1;
}

.sense-item.active i {
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px var(--accent-primary));
    animation: pulse-icon 1s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.5); }
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.sense-item.success {
    border-color: var(--accent-success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.sense-item.success::before {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(6, 182, 212, 0.1) 100%);
    opacity: 1;
}

.sense-item.success i {
    color: var(--accent-success);
    filter: drop-shadow(0 0 6px var(--accent-success));
}

.sense-item.error {
    border-color: var(--accent-danger);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.sense-item.error i {
    color: var(--accent-danger);
}

/* Query Input */
.query-section {
    margin-bottom: 18px;
}

.query-section label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

textarea {
    width: 100%;
    min-height: 90px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: all var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15), var(--shadow-glow);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.controls-enhanced {
    margin-bottom: 18px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.file-upload-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.file-upload-btn i {
    font-size: 1.1rem;
}

.magic-wand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 8px;
    color: #fbbf24;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.magic-wand-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(251, 191, 36, 0.1), transparent);
    transform: rotate(45deg);
    animation: wand-shimmer 3s ease-in-out infinite;
}

@keyframes wand-shimmer {
    0%, 100% { transform: translateX(-100%) rotate(45deg); }
    50% { transform: translateX(100%) rotate(45deg); }
}

.magic-wand-btn:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.2));
    border-color: #fbbf24;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
    transform: scale(1.05);
}

.magic-wand-btn i {
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
}

.magic-wand-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.magic-wand-modal.active {
    display: flex;
}

.magic-wand-content {
    background: var(--card-bg);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 0 40px rgba(251, 191, 36, 0.2);
}

.magic-wand-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.magic-wand-header i {
    font-size: 1.5rem;
    color: #fbbf24;
}

.magic-wand-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
}

.clarity-score {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.clarity-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.clarity-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.assumptions-list {
    margin-bottom: 20px;
}

.assumption-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    margin-bottom: 8px;
}

.assumption-category {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    background: rgba(139, 92, 246, 0.2);
    border-radius: 4px;
    color: #a78bfa;
    white-space: nowrap;
}

.assumption-text {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.assumption-confidence {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.enhanced-prompt {
    padding: 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    margin-bottom: 20px;
}

.enhanced-prompt label {
    display: block;
    font-size: 0.8rem;
    color: #10b981;
    margin-bottom: 8px;
    font-weight: 600;
}

.enhanced-prompt-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.magic-wand-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.media-type-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 120px;
}

.media-type-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.media-option-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.query-input-wrapper {
    position: relative;
}

.query-attachments {
    padding: 10px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-top: none;
    border-radius: 0 0 10px 10px;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.attachment-item i {
    color: var(--accent-primary);
}

.attachment-item .remove-attachment {
    cursor: pointer;
    color: var(--text-muted);
    margin-left: 4px;
}

.attachment-item .remove-attachment:hover {
    color: var(--accent-danger);
}

.attachment-preview {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

/* Generated media in chat */
.chat-media {
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.chat-media img {
    max-width: 100%;
    display: block;
    border-radius: 12px;
}

.chat-media audio {
    width: 100%;
    margin-top: 8px;
}

.chat-media video {
    max-width: 100%;
    border-radius: 12px;
}

.chat-media-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

/* Mode Toggle - Pill style with glow */
.mode-toggle {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 4px;
}

.mode-toggle input { display: none; }

.mode-toggle label {
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 7px;
    transition: all var(--transition);
}

.mode-toggle label:hover {
    color: var(--text-primary);
}

.mode-toggle input:checked + label {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.4);
}

/* Processing Indicator - Animated rings */
.processing {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 24px;
    margin: 18px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.processing::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: conic-gradient(from 0deg, transparent, var(--accent-primary), transparent);
    animation: rotate-glow 3s linear infinite;
    opacity: 0.3;
}

@keyframes rotate-glow {
    to { transform: rotate(360deg); }
}

.processing .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

/* Live Stream - Terminal with glow */
.stream-panel {
    background: rgba(5, 5, 8, 0.9);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin: 18px 0;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}

.stream-header {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.1), transparent);
    padding: 10px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.stream-header .dot {
    width: 8px;
    height: 8px;
    background: var(--accent-success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-success);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--accent-success); }
    50% { opacity: 0.4; box-shadow: 0 0 5px var(--accent-success); }
}

.stream-body {
    padding: 12px;
    font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    font-size: 0.75rem;
    max-height: 180px;
    overflow-y: auto;
}

.stream-entry {
    padding: 4px 0;
    color: var(--text-secondary);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.stream-entry .tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    margin-right: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag.start { 
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); 
    color: white; 
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}
.tag.success { 
    background: var(--accent-success); 
    color: white; 
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}
.tag.error { 
    background: var(--accent-danger); 
    color: white; 
}
.tag.complete { 
    background: var(--accent-cyan); 
    color: white; 
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}
.tag.done { 
    background: var(--text-muted); 
    color: white; 
}

/* Metrics - Glowing cards */
.metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 18px 0;
}

.metric {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.metric:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.metric-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 6px;
}

.metric.resonance .metric-value { 
    color: var(--accent-success); 
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}
.metric.senses .metric-value { 
    color: var(--accent-primary); 
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}
.metric.fusion .metric-value { 
    color: var(--accent-warning); 
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

/* Response - Success glow */
.response {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--accent-success);
    border-radius: 12px;
    margin: 18px 0;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
    animation: slideUp 0.4s ease;
}

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

.response-header {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), transparent);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.response-header i {
    color: var(--accent-success);
    filter: drop-shadow(0 0 6px var(--accent-success));
}

.response-body {
    padding: 16px;
}

.response-content {
    font-size: 0.95rem;
    line-height: 1.7;
}

.response-content code {
    background: rgba(139, 92, 246, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
}

.response-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Error */
.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-danger);
    border-radius: 12px;
    padding: 16px;
    margin: 18px 0;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error h5 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--accent-danger);
    display: flex;
    align-items: center;
    gap: 8px;
}

.error p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Sidebar Cards */
.sidebar .card {
    margin-bottom: 16px;
}

/* History - Clean with hover effects */
.history-list {
    max-height: 350px;
    overflow-y: auto;
}

.history-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition);
}

.history-item:hover {
    background: rgba(139, 92, 246, 0.05);
}

.history-item:hover::before {
    opacity: 1;
}

.history-item.active {
    background: rgba(139, 92, 246, 0.1);
}

.history-item.active::before {
    opacity: 1;
}

.history-item:last-child {
    border-bottom: none;
}

.history-query {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-response {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Modal */
.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.status-item {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px;
    transition: all var(--transition);
}

.status-item:hover {
    border-color: var(--border-glow);
}

.status-item h6 {
    margin: 0 0 8px 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.status-badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.status-badge.danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

/* Scrollbar - Sleek */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Responsive */
@media (max-width: 600px) {
    body { padding: 12px; }
    .sense-grid { grid-template-columns: repeat(4, 1fr); }
    .metrics { grid-template-columns: 1fr; }
    .controls { flex-direction: column; align-items: stretch; }
    .status-grid { grid-template-columns: 1fr; }
}

/* Focus states for accessibility */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Brain Visualization */
/* Compact Brain Visualizer */
.query-header-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(15,15,25,0.9) 0%, rgba(20,12,35,0.85) 100%);
    border-radius: 12px;
    border: 1px solid rgba(139,92,246,0.2);
}

.compact-brain {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#brainCanvas {
    width: 500px;
    height: 320px;
    border-radius: 12px;
}

.brain-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 240px;
    height: 200px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}

.brain-pulse-ring.active {
    animation: brainPulseRing 1.5s ease-out;
}

@keyframes brainPulseRing {
    0% { 
        opacity: 0.8; 
        transform: translate(-50%, -50%) scale(0.8);
        box-shadow: 0 0 20px rgba(6,182,212,0.8), inset 0 0 20px rgba(139,92,246,0.5);
    }
    100% { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(1.5);
        box-shadow: 0 0 40px rgba(6,182,212,0), inset 0 0 40px rgba(139,92,246,0);
    }
}

.brain-activity-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.activity-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(16, 185, 129, 0.9);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.activity-label.processing {
    color: rgba(6, 182, 212, 0.95);
    text-shadow: 0 0 15px rgba(6, 182, 212, 0.7);
    animation: activityPulse 0.8s ease-in-out infinite;
}

.activity-regions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.activity-region {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(139, 92, 246, 0.2);
    color: rgba(255,255,255,0.8);
    font-weight: 500;
    animation: regionGlow 1s ease-in-out infinite;
}

@keyframes regionGlow {
    0%, 100% { box-shadow: 0 0 4px rgba(139,92,246,0.3); }
    50% { box-shadow: 0 0 10px rgba(6,182,212,0.6); }
}

@keyframes activityPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Pulse effect overlay */
.pulse-overlay {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: pulseExpand 1s ease-out forwards;
}

@keyframes pulseExpand {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

/* Image Editor Modal */
.image-editor-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-editor-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-glow);
    border-radius: 12px;
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    max-width: 1400px;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-glow-strong);
}

.image-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
}

.image-editor-header h3 {
    margin: 0;
    font-size: 1.1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.image-editor-header h3 i {
    margin-right: 8px;
    -webkit-text-fill-color: var(--accent-primary);
}

.image-editor-actions {
    display: flex;
    gap: 10px;
}

#tui-image-editor {
    flex: 1;
    min-height: 0;
}

/* Override TUI Image Editor styles for dark theme */
.tui-image-editor-container {
    background: #1a1a2e !important;
}

.tui-image-editor-container .tui-image-editor-main {
    background: #1a1a2e !important;
}

.tui-image-editor-container .tui-image-editor-submenu {
    background: #1a1a2e !important;
}

.tui-image-editor-container .tui-image-editor-menu > .tui-image-editor-item {
    background: transparent !important;
}

.tui-image-editor-container .tui-image-editor-menu > .tui-image-editor-item.active {
    background: rgba(139, 92, 246, 0.2) !important;
}

/* Chat media edit button */
.chat-media {
    position: relative;
}

.chat-media:hover .edit-image-btn {
    opacity: 1;
}

.edit-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(139, 92, 246, 0.9);
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.edit-image-btn:hover {
    background: var(--accent-primary);
}

.chat-media img {
    cursor: pointer;
}

.chat-media img:hover {
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

/* ==================== Media Window ==================== */
.media-window {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 450px;
    max-width: calc(100vw - 40px);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: var(--shadow-card), 0 0 40px rgba(139, 92, 246, 0.15);
    z-index: 999;
    overflow: hidden;
    backdrop-filter: blur(20px);
    transition: all 0.3s ease;
}

.media-window.expanded {
    width: 700px;
    height: 80vh;
    bottom: 10vh;
    right: calc(50% - 350px);
}

.media-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
    border-bottom: 1px solid var(--border-subtle);
    cursor: move;
}

.media-window-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.media-window-title i {
    color: var(--accent-primary);
}

.media-window-controls {
    display: flex;
    gap: 4px;
}

.media-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.media-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.media-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.media-window-content {
    padding: 16px;
    min-height: 200px;
    max-height: 400px;
    overflow: auto;
}

.media-window.expanded .media-window-content {
    max-height: calc(80vh - 140px);
}

.media-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#mediaImage {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.media-window.expanded #mediaImage {
    max-height: 60vh;
}

#mediaVideo {
    width: 100%;
    max-height: 300px;
    border-radius: 8px;
    background: #000;
}

.media-window.expanded #mediaVideo {
    max-height: 60vh;
}

.image-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-radius: 8px;
}

#zoomLevel {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

/* Audio Visualizer */
.audio-visualizer {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--border-subtle);
}

#audioWaveform, #audioFrequency {
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
}

.audio-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

#audioTime {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.visualizer-mode {
    display: flex;
    gap: 4px;
}

/* Empty State */
.media-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    text-align: center;
}

.media-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.media-empty p {
    margin: 0;
    font-size: 1rem;
}

.media-empty small {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Media History Footer */
.media-window-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
}

.media-history {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
}

.media-history::-webkit-scrollbar {
    height: 4px;
}

.media-history::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}

.media-thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-thumb:hover {
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.media-thumb.active {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-thumb i {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* Toggle Button */
.media-window-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: var(--shadow-glow-strong), 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-window-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
}

.media-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent-danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Responsive */
@media (max-width: 600px) {
    .media-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 70px;
    }
    
    .media-window.expanded {
        width: calc(100vw - 20px);
        right: 10px;
    }
}

/* Media Load Controls */
.media-load-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.media-url-input {
    display: flex;
    gap: 8px;
}

.media-url-input input {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.media-url-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.media-divider {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.media-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.media-upload-btn:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-glow);
}

/* Media Load Bar (compact) */
.media-load-bar {
    display: flex;
    gap: 6px;
    padding: 8px 0;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.media-load-bar input {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 0.8rem;
    min-width: 0;
}

.media-load-bar input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.media-load-bar label {
    cursor: pointer;
}

/* ================================ */
/* Full-Screen Media Viewer Modal   */
/* ================================ */

.media-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.media-viewer-modal {
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.media-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    border-radius: 16px 16px 0 0;
}

.media-viewer-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.media-viewer-controls {
    display: flex;
    gap: 8px;
}

.viewer-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.viewer-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.viewer-btn.close-btn {
    background: rgba(220, 53, 69, 0.2);
    border-color: rgba(220, 53, 69, 0.5);
}

.viewer-btn.close-btn:hover {
    background: #dc3545;
    border-color: #dc3545;
}

.media-viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
    background: var(--bg-primary);
}

.viewer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.viewer-container img {
    max-width: 100%;
    max-height: calc(100% - 60px);
    object-fit: contain;
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.viewer-container video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    background: #000;
}

.viewer-image-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--bg-elevated);
    border-radius: 25px;
    border: 1px solid var(--border-subtle);
}

.viewer-image-controls span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
}

.viewer-audio-visual {
    width: 100%;
    max-width: 600px;
    height: 150px;
    background: var(--bg-elevated);
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
}

.viewer-audio-visual canvas {
    width: 100%;
    height: 100%;
}

.viewer-audio-info {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.media-viewer-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    border-radius: 0 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.viewer-history {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
}

.viewer-history::-webkit-scrollbar {
    height: 4px;
}

.viewer-thumb {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-thumb:hover {
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.viewer-thumb.active {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

.viewer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.viewer-thumb i {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.viewer-load-controls {
    display: flex;
    gap: 8px;
}

.viewer-load-controls input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.viewer-load-controls input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.viewer-load-controls label {
    cursor: pointer;
}

/* Floating Toggle Button */
.media-viewer-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
}

.media-viewer-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(139, 92, 246, 0.6);
}

.viewer-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Hide old media window elements */
.media-window, .media-window-toggle {
    display: none !important;
}

/* Clickable Media in Chat */
.clickable-media {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    overflow: hidden;
}

.clickable-media:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.3);
}

.clickable-media:hover .media-overlay {
    opacity: 1;
}

.media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    pointer-events: none;
}

.media-overlay i {
    font-size: 1.5rem;
}

.audio-preview {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
    border-radius: 12px;
}

.audio-preview i {
    font-size: 2rem;
    color: var(--accent-primary);
}

.media-prompt {
    font-size: 11px;
    color: var(--text-muted);
    padding: 8px;
    font-style: italic;
    border-top: 1px solid var(--border-subtle);
}

.chat-media-caption {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-elevated);
}

/* Gallery Tabs */
.gallery-tab {
    padding: 10px 20px;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    color: var(--text-muted, #888);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.gallery-tab:hover {
    background: var(--bg-elevated, #252540);
    color: var(--text-primary, #fff);
}

.gallery-tab.active {
    background: var(--accent-primary, #8b5cf6);
    color: white;
    border-color: var(--accent-primary, #8b5cf6);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

