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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #a855f7;
    --primary-rgb: 99, 102, 241;
    --secondary-rgb: 168, 85, 247;
    --bg-color: #0a0a0f;
    --sidebar-bg: rgba(14, 14, 22, 0.98);
    --chat-bg: #0a0a0f;
    --message-user-bg: #1e1e2e;
    --message-ai-bg: #13131f;
    --border-color: rgba(255, 255, 255, 0.06);
    --text-primary: #e2e8f0;
    --text-secondary: #64748b;
    --text-muted: #475569;
    --hover-bg: rgba(255, 255, 255, 0.05);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Color Themes === */
[data-theme="blue"] {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #1565C0;
    --primary-rgb: 33, 150, 243;
    --secondary-rgb: 21, 101, 192;
    --accent-gradient: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
}

[data-theme="green"] {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #2E7D32;
    --primary-rgb: 76, 175, 80;
    --secondary-rgb: 46, 125, 50;
    --accent-gradient: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
}

[data-theme="yellow"] {
    --primary-color: #FFC107;
    --primary-dark: #FFA000;
    --secondary-color: #FF8F00;
    --primary-rgb: 255, 193, 7;
    --secondary-rgb: 255, 143, 0;
    --accent-gradient: linear-gradient(135deg, #FFC107 0%, #FF8F00 100%);
}

[data-theme="red"] {
    --primary-color: #f44336;
    --primary-dark: #D32F2F;
    --secondary-color: #C62828;
    --primary-rgb: 244, 67, 54;
    --secondary-rgb: 198, 40, 40;
    --accent-gradient: linear-gradient(135deg, #f44336 0%, #C62828 100%);
}

[data-theme="monochrome"] {
    --primary-color: #ffffff;
    --primary-dark: #e0e0e0;
    --secondary-color: #9e9e9e;
    --primary-rgb: 255, 255, 255;
    --secondary-rgb: 158, 158, 158;
    --accent-gradient: linear-gradient(135deg, #ffffff 0%, #9e9e9e 100%);
}

/* === Theme Picker Circles === */
.theme-option {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: all 0.2s ease;
    overflow: hidden;
    display: flex;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.theme-half {
    width: 50%;
    height: 100%;
    display: block;
}

.theme-option:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.theme-option.active {
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3), 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Skill Container Styles */
.skill-container {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideInUp 0.3s ease-out;
}

.skill-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Skill Badge Styles */
.skill-badge {
    padding: 4px 10px;
    background: var(--accent-gradient);
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.25);
}

.skill-badge-icon {
    font-size: 11px;
}

.skill-badge-text {
    color: white;
    font-size: 11px;
    font-weight: 500;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
}

.logo span {
    font-size: 16px;
    font-weight: 700;
    color: #e2e8f0;
    -webkit-text-fill-color: #e2e8f0;
    background: none;
    background-clip: unset;
    -webkit-background-clip: unset;
}

.new-chat-btn {
    width: 100%;
    padding: 11px 16px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.3);
}

.new-chat-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

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

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Sidebar Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 20px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    border-color: transparent;
}

.nav-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.nav-item svg,
.nav-item .material-symbols-outlined {
    flex-shrink: 0;
}

.nav-badge {
    background-color: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 0 4px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding: 0 8px;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.chat-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.chat-item.active {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.chat-item svg {
    flex-shrink: 0;
}

.chat-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.delete-chat-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Auth Section */
.auth-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.auth-login-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.auth-login-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Desktop Section */
.desktop-section {
    margin-top: 12px;
}

.desktop-open-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
}

.desktop-open-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.auth-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.auth-login-btn svg {
    flex-shrink: 0;
}

/* Auth User Block */
.auth-user-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--hover-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.auth-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.auth-user-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.auth-user-info:hover .auth-user-name {
    color: var(--primary-color);
}

.auth-user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s;
}

.auth-user-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.auth-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
    position: relative;
    min-width: 0;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: relative;
}

.model-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    position: relative;
}

.model-badge:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary-color);
}

.model-badge.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.model-icon {
    font-size: 16px;
}

.model-text {
    color: var(--text-primary);
    font-weight: 500;
}

.model-dropdown-arrow {
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.model-badge.active .model-dropdown-arrow {
    transform: rotate(180deg);
}

.model-dropdown {
    position: fixed;
    top: 60px;
    right: 24px;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 320px;
    max-height: 450px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    padding: 8px 0;
}

.model-dropdown.show {
    display: block;
}

.model-dropdown-header {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.model-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.model-dropdown-item:hover {
    background-color: var(--hover-bg);
}

.model-dropdown-item.active {
    background-color: rgba(var(--primary-rgb), 0.1);
}

.model-dropdown-item-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.model-dropdown-item-info {
    flex: 1;
}

.model-dropdown-item-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.model-dropdown-item-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.model-dropdown-item-check {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.model-dropdown-item.active .model-dropdown-item-check {
    opacity: 1;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.model-badge:has(~ .model-dropdown.show) {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.model-badge:has(~ .model-dropdown.show) .model-text {
    color: white;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 14px;
}

.message.user .message-avatar {
    background: var(--accent-gradient);
    color: white;
}

.message.ai .message-avatar {
    background-color: var(--message-ai-bg);
    border: 1px solid var(--border-color);
}

.message-content {
    flex: 1;
    padding-top: 6px;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.message-author {
    font-weight: 600;
    font-size: 14px;
}

.message-time {
    font-size: 12px;
    color: var(--text-muted);
}

.message-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message-text a {
    overflow-wrap: anywhere;
    word-break: break-all;
    color: var(--primary-color);
}

.message-text img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 12px 0;
    display: block;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}

.message-text p {
    margin-bottom: 12px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text pre {
    background-color: #1e1e1e;
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text code {
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
}

.message-text code:not(pre code) {
    background-color: rgba(102, 126, 234, 0.15);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-text ul,
.message-text ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 6px;
}

.message-text blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
}

.welcome-icon {
    margin-bottom: 24px;
}

.welcome-content h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.chip {
    padding: 12px 20px;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* Input Area */
.input-area {
    padding: 24px;
    background-color: var(--chat-bg);
    border-top: 1px solid var(--border-color);
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4px;
    transition: var(--transition);
}

.input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#messageInput {
    width: 100%;
    min-height: 56px;
    max-height: 200px;
    padding: 16px 60px 16px 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
}

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

.send-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    opacity: 0.5;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

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

/* Attach Button */
.attach-btn {
    position: absolute;
    left: 12px;
    bottom: 12px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.attach-btn:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
}

#messageInput {
    padding-left: 60px;
    /* Make room for attach button */
}

/* Attached File Preview */
.attached-file-preview {
    max-width: 900px;
    margin: 8px auto 0;
    padding: 8px 12px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 8px;
}

.attached-file-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-attachment {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.remove-attachment:hover {
    color: var(--error-color);
}

/* File Picker Modal */
.file-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
}

.file-picker-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.file-picker-content {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
}

.file-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.file-picker-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.file-picker-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.file-picker-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.file-picker-body {
    padding: 8px;
    overflow-y: auto;
    max-height: 400px;
}

.file-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-picker-item:hover {
    background: var(--hover-bg);
}

.file-picker-icon {
    font-size: 24px;
}

.file-picker-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-picker-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.file-picker-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.input-footer {
    max-width: 900px;
    margin: 12px auto 0;
    text-align: center;
}

.input-footer span {
    font-size: 12px;
    color: var(--text-muted);
}

.input-learning-tip {
    max-width: 900px;
    margin: 8px auto 0;
    text-align: center;
}

.input-learning-tip span {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-group input[type="password"],
.form-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.form-group small a {
    color: var(--primary-color);
    text-decoration: none;
}

.form-group small a:hover {
    text-decoration: underline;
}

.form-group input[type="range"] {
    width: 100%;
    margin-top: 8px;
}

#temperatureValue {
    display: inline-block;
    margin-left: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-footer {
    padding: 0 24px 24px;
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 0;
}

.loading-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Thinking indicator - Агент думает... */
.thinking-indicator {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.thinking-text {
    font-size: 15px;
    font-weight: 500;
    background: linear-gradient(90deg,
            var(--text-secondary) 0%,
            var(--primary-color) 25%,
            var(--secondary-color) 50%,
            var(--primary-color) 75%,
            var(--text-secondary) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 2s infinite linear;
}

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

.thinking-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: thinkingPulse 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

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

@keyframes shimmer {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: -100% 0;
    }
}

@keyframes thinkingPulse {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100vh;
        z-index: 100;
    }

    .sidebar.open {
        left: 0;
    }

    .chat-container {
        padding: 16px;
    }

    .suggestion-chips {
        flex-direction: column;
        align-items: stretch;
    }

    .chip {
        text-align: center;
    }
}

/* Animations for notifications */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

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

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


/* Family Module Styles */
.family-create-section {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
}

.family-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

.family-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.family-create-form {
    margin-top: 30px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.family-create-form input {
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    min-width: 200px;
}

.family-management-section {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.family-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.family-stats {
    display: flex;
    gap: 10px;
}

.stat-badge {
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.family-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.invite-link-section {
    background: #f0f7ff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.invite-link-box {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.invite-link-box input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
}

.invite-expires {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
}

.family-members h3 {
    margin-bottom: 15px;
    color: #333;
}

.member-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s;
}

.member-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.member-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    color: white;
    font-weight: bold;
    font-size: 18px;
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    margin-bottom: 4px;
}

.member-meta {
    font-size: 14px;
    color: #666;
    display: flex;
    gap: 10px;
    align-items: center;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.pending {
    background: #fff4e6;
    color: #ff9800;
}

.member-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f0f0f0;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
}

/* ============ FAMILY SPACE STYLES ============ */

/* === Layout === */
.family-create-section,
.family-management {
    padding: 24px;
    max-width: 680px;
    margin: 0 auto;
    font-family: var(--font-family, "Inter", sans-serif);
}

/* === Empty State / Create === */
.family-empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 20px;
}

.family-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.family-empty-icon svg {
    width: 100%;
    height: 100%;
}

.family-empty-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin: 0 0 10px;
}

.family-empty-desc {
    font-size: 14px;
    color: var(--text-secondary, #a0a0a0);
    margin: 0 auto 32px;
    max-width: 380px;
    line-height: 1.6;
}

.family-create-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 360px;
    margin: 0 auto 24px;
}

.family-create-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
}

/* === Header === */
.family-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 16px;
}

.family-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.family-avatar-big {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.family-avatar-big svg {
    width: 100%;
    height: 100%;
}

.family-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin: 0 0 4px;
}

.family-meta {
    font-size: 13px;
    color: var(--text-secondary, #a0a0a0);
}

.family-pending-badge {
    color: #f59e0b;
    font-weight: 500;
}

/* === Action Bar === */
.family-actions-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* === Invite Section === */
.family-invite-section {
    background: var(--sidebar-bg, #161616);
    border: 1px solid color-mix(in srgb, var(--primary-color) 33%, transparent);
    border-radius: 16px;
    margin-bottom: 20px;
    overflow: hidden;
    animation: family-slide-down 0.2s ease;
}

@keyframes family-slide-down {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.family-invite-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color, #2a2a2a);
}

.family-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.family-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.family-invite-body {
    padding: 16px;
}

.family-invite-link-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.family-invite-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 10px;
    color: var(--text-primary, #fff);
    padding: 10px 12px;
    font-size: 13px;
    font-family: monospace;
    min-width: 0;
}

.family-btn-copy {
    padding: 10px 14px;
    font-size: 16px;
    flex-shrink: 0;
}

.family-invite-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.family-invite-expires {
    font-size: 12px;
    color: #f59e0b;
}

.family-qr-section {
    text-align: center;
    padding: 12px 0 4px;
}

.family-qr-label {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
    margin-bottom: 10px;
}

.family-qr-img {
    width: 160px;
    height: 160px;
    border-radius: 12px;
    border: 2px solid color-mix(in srgb, var(--primary-color) 27%, transparent);
}

.family-invite-hint {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
    margin-top: 10px;
    line-height: 1.5;
    padding: 10px;
    background: rgba(102, 126, 234, 0.06);
    border-radius: 8px;
}

/* === Members Section === */
.family-members-section {
    margin-bottom: 20px;
}

.family-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #a0a0a0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.family-members-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.family-empty-members {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary, #a0a0a0);
    font-size: 13px;
    background: var(--sidebar-bg, #161616);
    border: 1px dashed var(--border-color, #2a2a2a);
    border-radius: 12px;
}

/* === Member Card === */
.family-member-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 14px;
    transition: border-color 0.2s, background 0.2s;
}

.family-member-card:hover {
    border-color: color-mix(in srgb, var(--primary-color) 27%, transparent);
    background: rgba(102, 126, 234, 0.04);
}

.family-member-avatar {
    flex-shrink: 0;
}

.family-member-photo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid color-mix(in srgb, var(--primary-color) 27%, transparent);
}

.family-member-initials {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.family-member-initials.sm {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.family-member-info {
    flex: 1;
    min-width: 0;
}

.family-member-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.family-member-meta {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.family-status-badge {
    color: #f59e0b;
    font-size: 11px;
}

.family-member-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.family-action-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 8px;
    color: var(--text-primary, #fff);
    cursor: pointer;
    font-size: 16px;
    padding: 7px 10px;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
}

.family-action-btn:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: color-mix(in srgb, var(--primary-color) 40%, transparent);
}

.family-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef444466;
}

/* === Buttons === */
.family-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.family-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.family-btn-primary {
    background: var(--accent-gradient);
    color: #fff;
}

.family-btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.family-btn-secondary {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-color, #2a2a2a);
}

.family-btn-secondary:hover:not(:disabled) {
    background: rgba(102, 126, 234, 0.12);
    border-color: color-mix(in srgb, var(--primary-color) 33%, transparent);
}

.family-btn-ghost {
    background: transparent;
    color: var(--text-secondary, #a0a0a0);
    border: 1px solid var(--border-color, #2a2a2a);
}

.family-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
}

.family-btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}

/* ============ MEMORY PAGE STYLES ============ */

.memory-page {
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    min-height: 100%;
}

/* Header */
.memory-header {
    margin-bottom: 24px;
}

.memory-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin-bottom: 6px;
}

.memory-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #a0a0a0);
}

/* Scope Selector */
.memory-scope-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 12px;
    padding: 4px;
}

.scope-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary, #a0a0a0);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.scope-btn.active {
    background: var(--accent-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.scope-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #fff);
}

.scope-icon {
    font-size: 16px;
}

/* Content */
.memory-content {
    margin-bottom: 80px;
}

.memory-section {
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 16px;
    padding: 20px;
}

.memory-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.memory-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.memory-count {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 10px;
    border-radius: 20px;
}

/* Chips */
.memory-chips {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.memory-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 12px;
    padding: 12px 14px;
    transition: border-color 0.2s, background 0.2s;
}

.memory-chip:hover {
    border-color: rgba(102, 126, 234, 0.3);
    background: rgba(102, 126, 234, 0.04);
}

.memory-chip--family {
    border-color: rgba(118, 75, 162, 0.3);
}

.chip-content {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.chip-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary, #fff);
    line-height: 1.5;
}

.chip-badge {
    flex-shrink: 0;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
}

.chip-badge--personal {
    background: rgba(102, 126, 234, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.chip-badge--family {
    background: rgba(118, 75, 162, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(118, 75, 162, 0.2);
}

.chip-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chip-strength {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.chip-strength-bar {
    height: 100%;
    background: var(--accent-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    border-radius: 2px;
    transition: width 0.3s;
}

.chip-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.memory-chip:hover .chip-actions {
    opacity: 1;
}

.chip-edit-btn,
.chip-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: var(--text-secondary, #a0a0a0);
    transition: all 0.15s;
    display: flex;
    align-items: center;
}

.chip-edit-btn:hover {
    background: rgba(102, 126, 234, 0.15);
    color: #a5b4fc;
}

.chip-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* Loading */
.memory-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-secondary, #a0a0a0);
    font-size: 14px;
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color, #667eea);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty state */
.memory-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--text-secondary, #a0a0a0);
    text-align: center;
}

.memory-empty svg {
    opacity: 0.3;
}

.memory-empty p {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.memory-empty span {
    font-size: 13px;
    max-width: 280px;
    line-height: 1.5;
}

/* FAB */
.memory-fab {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--accent-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.2s;
    z-index: 100;
}

.memory-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

.memory-fab:active {
    transform: translateY(0);
}

/* Modal */
.memory-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.memory-modal {
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.memory-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.memory-modal-header h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.memory-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #a0a0a0);
    padding: 4px;
    border-radius: 8px;
    transition: all 0.15s;
    display: flex;
}

.memory-modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #fff);
}

.modal-step-label {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Type selector */
.modal-type-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.modal-type-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    color: var(--text-primary, #fff);
}

.modal-type-btn.active {
    border-color: var(--primary-color, #667eea);
    background: rgba(102, 126, 234, 0.1);
}

.modal-type-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.06);
}

.type-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.modal-type-btn strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.modal-type-btn span {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
}

/* Content input */
.modal-content-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--text-primary, #fff);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.modal-content-input:focus {
    outline: none;
    border-color: var(--primary-color, #667eea);
}

.modal-content-input::placeholder {
    color: var(--text-muted, #666);
}

/* Scope selector in modal */
.modal-scope-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.modal-scope-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-scope-option:has(input:checked) {
    border-color: var(--primary-color, #667eea);
    background: rgba(102, 126, 234, 0.1);
}

.modal-scope-option input[type="radio"] {
    display: none;
}

.scope-option-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.scope-option-icon {
    font-size: 24px;
}

.scope-option-content strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin-bottom: 2px;
}

.scope-option-content span {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
}

/* Disabled state for family option when no family space exists */
.modal-scope-option.disabled {
    opacity: 0.5;
}

.modal-scope-option.disabled input[type="radio"] {
    cursor: not-allowed;
}

.modal-scope-option.disabled .scope-option-content strong,
.modal-scope-option.disabled .scope-option-content span {
    color: var(--text-secondary, #888);
}

/* Ensure radio is always clickable */
.modal-scope-option input[type="radio"] {
    pointer-events: auto;
}

/* Modal actions */
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modal-btn-secondary {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 10px;
    color: var(--text-secondary, #a0a0a0);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #fff);
}

.modal-btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--accent-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.modal-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Toast */
.memory-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.memory-toast--success {
    background: #1a2e1a;
    border: 1px solid #22c55e55;
    color: #86efac;
}

.memory-toast--error {
    background: #2e1a1a;
    border: 1px solid #ef444455;
    color: #fca5a5;
}

.memory-toast--info {
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    color: var(--text-primary, #fff);
}

.family-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.15s;
}

.family-btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* === Form Controls === */
.family-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.family-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #a0a0a0);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.family-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 10px;
    color: var(--text-primary, #fff);
    padding: 11px 14px;
    font-size: 14px;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.family-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.06);
}

.family-textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 10px;
    color: var(--text-primary, #fff);
    padding: 11px 14px;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.family-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.06);
}

.family-char-count {
    text-align: right;
    font-size: 11px;
    color: var(--text-secondary, #a0a0a0);
}

.family-file-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 8px;
    color: var(--text-secondary, #a0a0a0);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.family-file-label:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-primary, #fff);
}
.family-file-clear {
    background: none;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    cursor: pointer;
    font-size: 13px;
    padding: 0 4px;
    margin-left: 4px;
    line-height: 1;
    vertical-align: middle;
}
.family-file-clear:hover { color: #ef4444; }

/* === Modal === */
.family-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: family-fade-in 0.2s ease;
}

@keyframes family-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.family-modal {
    background: var(--sidebar-bg, #161616);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 20px;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    animation: family-modal-in 0.25s ease;
}

@keyframes family-modal-in {
    from {
        transform: scale(0.94) translateY(10px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.family-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-color, #2a2a2a);
}

.family-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.family-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.family-modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

.family-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.family-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 20px 18px;
    border-top: 1px solid var(--border-color, #2a2a2a);
}

.family-member-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid color-mix(in srgb, var(--primary-color) 20%, transparent);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #fff);
}

.family-tg-handle {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
}

.family-modal-hint {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    line-height: 1.5;
}

.family-quick-times {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.family-quick-label {
    font-size: 12px;
    color: var(--text-secondary, #a0a0a0);
}

.family-quick-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 8px;
    color: var(--text-primary, #fff);
    cursor: pointer;
    font-size: 12px;
    padding: 5px 10px;
    transition: background 0.15s;
}

.family-quick-btn:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: color-mix(in srgb, var(--primary-color) 33%, transparent);
}

/* === Toast === */
.family-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e1e2e;
    border: 1px solid var(--border-color, #2a2a2a);
    color: var(--text-primary, #fff);
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    white-space: nowrap;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.family-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.family-toast-success {
    border-color: #22c55e55;
}

.family-toast-error {
    border-color: #ef444455;
    color: #fca5a5;
}

/* === Family Role Styles === */
.family-member-avatar {
    position: relative;
    flex-shrink: 0;
}

.family-avatar-editable {
    cursor: pointer;
}
.family-avatar-upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}
.family-avatar-editable:hover .family-avatar-upload-overlay {
    opacity: 1;
}

.family-role-icon {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--sidebar-bg, #161616);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color, #2a2a2a);
    color: var(--text-secondary, #a0a0a0);
}

.family-role-icon svg {
    width: 14px;
    height: 14px;
}

.family-role-row {
    margin-top: 5px;
}

.family-role-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 7px;
    color: var(--text-primary, #fff);
    font-size: 12px;
    padding: 3px 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    max-width: 140px;
}

.family-role-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.08);
}

.family-role-select option {
    background: #1e1e2e;
    color: #fff;
}

/* Styled select for automation recipient (Кому отправлять?) */
.automation-recipient-select {
    width: 100%;
    padding: 10px 36px 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--text-primary, #f1f5f9);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.2s, background-color 0.2s;
}
.automation-recipient-select:focus {
    outline: none;
    border-color: var(--primary-color, #e8a020);
    background-color: rgba(255, 255, 255, 0.09);
}
.automation-recipient-select:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background-color: rgba(255, 255, 255, 0.09);
}
.automation-recipient-select option {
    background: #1a1a2e;
    color: #f1f5f9;
}

/* ═══════════════════════════════════════════════════════════════════════
   GLASSMORPHISM CHAT — matches HomeDashboard visual language
   Uses --primary-rgb / --secondary-rgb so all theme colors work.
   ═══════════════════════════════════════════════════════════════════════ */

/* Ambient glow in the chat background */
.main-content {
    background:
        radial-gradient(circle at 15% 25%, rgba(var(--primary-rgb), 0.18) 0%, transparent 42%),
        radial-gradient(circle at 85% 75%, rgba(var(--secondary-rgb), 0.13) 0%, transparent 42%),
        #0a0a0f;
}

/* ── Header ──────────────────────────────────────────────────────── */
.chat-header {
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Model badge — glass pill */
.model-badge {
    background: rgba(20, 20, 35, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
}

.model-badge:hover {
    background: rgba(var(--primary-rgb), 0.12);
    border-color: rgba(var(--primary-rgb), 0.3);
}

/* Model dropdown — glass panel */
.model-dropdown {
    background: rgba(14, 14, 24, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(var(--primary-rgb), 0.06);
}

.model-dropdown-item:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

.model-dropdown-item.active {
    background: rgba(var(--primary-rgb), 0.12);
}

/* ── Message bubbles — glass cards ──────────────────────────────── */
.message {
    border-radius: 22px;
    padding: 20px 24px;
    gap: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ── Avatars ─────────────────────────────────────────────────────── */
.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 15px;
}

.message.user .message-avatar {
    background: var(--accent-gradient);
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.4);
    border: none;
}

.message.ai .message-avatar {
    background: rgba(var(--primary-rgb), 0.15);
    border: 1px solid rgba(var(--primary-rgb), 0.22);
    color: var(--primary-color);
}

/* Author label — gradient for user */
.message.user .message-author {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Code blocks inside messages ─────────────────────────────────── */
.message-text pre {
    background: rgba(8, 8, 18, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 18px 20px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ── Thinking indicator — glass card ────────────────────────────── */
.thinking-indicator {
    background: rgba(18, 18, 30, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 22px;
    padding: 18px 24px;
}

/* ── Input area — glass panel ───────────────────────────────────── */
.input-area {
    background: rgba(10, 10, 15, 0.80);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 20px 24px 24px;
}

.input-container {
    background: rgba(18, 18, 32, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    padding: 6px;
}

.input-container:focus-within {
    border-color: rgba(var(--primary-rgb), 0.45);
    box-shadow:
        0 0 0 3px rgba(var(--primary-rgb), 0.08),
        0 8px 32px rgba(var(--primary-rgb), 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Send button — stronger glow on hover */
.send-btn:not(:disabled):hover {
    box-shadow: 0 4px 18px rgba(var(--primary-rgb), 0.55);
}

/* Attached file preview — glass */
.attached-file-preview {
    background: rgba(18, 18, 32, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
}

/* ── Welcome screen ─────────────────────────────────────────────── */
.welcome-screen {
    position: relative;
    overflow: hidden;
}

/* Ambient orbs behind welcome content */
.welcome-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 30% 35%, rgba(var(--primary-rgb), 0.14) 0%, transparent 50%),
        radial-gradient(circle at 70% 65%, rgba(var(--secondary-rgb), 0.10) 0%, transparent 50%);
}

.welcome-content {
    position: relative;
    z-index: 1;
}

.welcome-content h1 {
    font-size: 38px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
}

.welcome-subtitle {
    font-size: 15px;
    color: rgba(148, 163, 184, 0.75);
    margin-bottom: 36px;
}

/* Suggestion chips — glass pills */
.chip {
    background: rgba(18, 18, 32, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    color: #94a3b8;
    font-size: 13px;
    padding: 10px 20px;
    transition: all 0.2s ease;
}

.chip:hover {
    background: rgba(var(--primary-rgb), 0.13);
    border-color: rgba(var(--primary-rgb), 0.38);
    color: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 18px rgba(var(--primary-rgb), 0.22);
}

/* Skill badge — glass glow */
.skill-badge {
    box-shadow: 0 2px 14px rgba(var(--primary-rgb), 0.35);
}

/* Chat scrollbar — thin & styled */
.chat-container::-webkit-scrollbar {
    width: 4px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb), 0.22);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--primary-rgb), 0.45);
}

/* ══════════════════════════════════════════════════════════════════
   Message Forward Button + Forward-to-Telegram Modal
   ══════════════════════════════════════════════════════════════════ */

/* Relative context for absolute-positioned forward button */
.message.ai .message-content {
    position: relative;
}

.msg-forward-btn {
    position: absolute;
    bottom: -12px;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    background: var(--bg-secondary, rgba(22,22,40,0.95));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 20px;
    color: var(--text-muted, #94a3b8);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s, color 0.18s, border-color 0.18s, background 0.18s;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    z-index: 5;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.msg-forward-btn svg { flex-shrink: 0; }
.message.ai:hover .msg-forward-btn {
    opacity: 1;
    pointer-events: auto;
}
.msg-forward-btn:hover {
    color: var(--primary-color, #6366f1);
    border-color: rgba(var(--primary-rgb,99,102,241),0.55);
    background: rgba(var(--primary-rgb,99,102,241),0.1);
}

/* ── Forward Modal ── */
.fwd-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fwd-fadein 0.18s ease;
}
@keyframes fwd-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.fwd-modal {
    background: rgba(16, 16, 30, 0.98);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 28px;
    width: 90%;
    max-width: 480px;
    max-height: 86vh;
    overflow-y: auto;
    box-shadow: 0 28px 70px rgba(0,0,0,0.65);
    animation: fwd-slideup 0.22s ease;
}
@keyframes fwd-slideup {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fwd-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 4px;
}
.fwd-modal-sub {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 22px;
}
.fwd-section-label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}
/* Member chips */
.fwd-members-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    min-height: 36px;
}
.fwd-chip-avatar {
    width: 22px; height: 22px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0; margin-right: 6px;
}
.fwd-chip-avatar-init {
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg,rgba(139,92,246,.5),rgba(59,130,246,.5));
    font-size: 11px; font-weight: 700; color: #fff;
}
.fwd-member-chip {
    padding: 6px 13px;
    border-radius: 99px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    display: inline-flex;
    align-items: center;
}
.fwd-member-chip:hover {
    border-color: rgba(var(--primary-rgb,99,102,241),0.45);
    color: #e2e8f0;
}
.fwd-member-chip.selected {
    background: rgba(var(--primary-rgb,99,102,241),0.18);
    border-color: var(--primary-color,#6366f1);
    color: #fff;
    font-weight: 600;
}
.fwd-members-empty {
    font-size: 13px;
    color: #475569;
    padding: 4px 0;
}
/* Textarea */
.fwd-textarea {
    width: 100%;
    min-height: 110px;
    max-height: 200px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 12px 14px;
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.65;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}
.fwd-textarea:focus { border-color: rgba(var(--primary-rgb,99,102,241),0.5); }
/* Media thumbs */
.fwd-media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.fwd-media-thumb {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.fwd-media-thumb img,
.fwd-media-thumb video {
    width: 100%; height: 100%; object-fit: cover;
    display: block;
}
.fwd-media-badge {
    position: absolute;
    bottom: 3px; right: 3px;
    background: rgba(0,0,0,0.6);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 9px;
    color: #fff;
    text-transform: uppercase;
    font-weight: 700;
}
.fwd-media-remove {
    position: absolute;
    top: 3px; right: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    border: none;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}
.fwd-media-thumb:hover .fwd-media-remove { opacity: 1; }
/* Status */
.fwd-status {
    font-size: 12px;
    color: #64748b;
    min-height: 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.fwd-status.error   { color: #f87171; }
.fwd-status.success { color: #34d399; }
.fwd-status.sending { color: #94a3b8; }
/* Actions */
.fwd-actions {
    display: flex;
    gap: 10px;
}
.fwd-cancel-btn {
    flex: 1;
    padding: 11px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.fwd-cancel-btn:hover { background: rgba(255,255,255,0.09); }
.fwd-send-btn {
    flex: 2;
    padding: 11px;
    background: rgba(var(--primary-rgb,99,102,241),0.85);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}
.fwd-send-btn:hover { opacity: 0.88; }
.fwd-send-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Sidebar ambient glow ──────────────────────────────────────── */

/* Radial gradient glow layer stacked over sidebar background-color */
.sidebar {
    background-image: radial-gradient(circle at 50% 42%,
            rgba(var(--primary-rgb), 0.13) 0%,
            transparent 25%);
}

/* Active nav item — outer glow halo */
.nav-item.active {
    box-shadow:
        0 0 20px rgba(var(--primary-rgb), 0.2),
        inset 0 0 12px rgba(var(--primary-rgb), 0.06);
}