* {
    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);
    /* Semantic colors */
    --color-error: #ef4444;
    --color-warning: #ff9800;
    --color-success: #22c55e;
    /* Code blocks */
    --code-bg: #1e1e1e;
    --code-inline-bg: rgba(var(--primary-rgb), 0.15);
    /* Surface for legacy light-only components */
    --surface-secondary: rgba(255, 255, 255, 0.04);
    --surface-tertiary: rgba(255, 255, 255, 0.02);
}

/* === Light Mode === */
[data-mode="light"] {
    --bg-color: #f8fafc;
    --sidebar-bg: rgba(255, 255, 255, 0.9);
    --chat-bg: #ffffff;
    --message-user-bg: #e2e8f0;
    --message-ai-bg: #f1f5f9;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --hover-bg: rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --code-bg: #f1f5f9;
    --code-inline-bg: rgba(var(--primary-rgb), 0.1);
    --surface-secondary: rgba(0, 0, 0, 0.03);
    --surface-tertiary: rgba(0, 0, 0, 0.015);
}

/* === 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: var(--accent-gradient);
    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: var(--text-primary);
    -webkit-text-fill-color: var(--text-primary);
    background: none;
    background-clip: unset;
    -webkit-background-clip: unset;
}

.new-chat-btn {
    width: 100%;
    padding: 11px 16px;
    background: var(--primary-color);
    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: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    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: var(--color-error);
    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: var(--color-error);
}

.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: var(--color-error);
}

/* 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);
}

.msg-model-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-color);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    white-space: nowrap;
    margin-left: auto;
    opacity: 0.85;
}

.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: var(--code-bg);
    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: var(--code-inline-bg);
    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(var(--primary-rgb), 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: 45px;
    bottom: 7px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 100%;
    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);
}

/* 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);
}

/* ── Skill pills under chat input ── */
.chat-skill-pills {
    max-width: 900px;
    margin: 8px auto 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 0 16px;
}

.chat-skill-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 100px;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
}

.chat-skill-pill:hover {
    background: rgba(var(--primary-rgb),0.12);
    border-color: rgba(var(--primary-rgb),0.3);
    color: #a5b4fc;
}

.chat-skill-pill:active {
    transform: scale(0.95);
}

.chat-skill-pill .pill-icon {
    font-size: 13px;
    line-height: 1;
}

.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;
    }
}

/* SSE Streaming cursor */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary-color);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: streamBlink 0.7s infinite;
}

.message.streaming .message-text {
    min-height: 1.5em;
}

@keyframes streamBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 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: var(--surface-secondary);
    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 var(--border-color);
    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 var(--border-color);
}

.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: var(--surface-secondary);
    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 var(--border-color);
    border-radius: 6px;
    font-family: monospace;
}

.invite-expires {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 10px;
}

.family-members h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.member-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    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: var(--text-primary);
    margin-bottom: 4px;
}

.member-meta {
    font-size: 14px;
    color: var(--text-secondary);
    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: rgba(255, 152, 0, 0.1);
    color: var(--color-warning);
}

.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: var(--hover-bg);
}

.btn-secondary {
    background: var(--surface-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    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: var(--hover-bg);
    border-color: var(--border-color);
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-style: italic;
}

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

/* === Layout === */
.family-view {
    position: fixed;
    inset: 0 0 0 260px;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
    z-index: 10;
    display: none;
    font-family: 'Inter', -apple-system, sans-serif;
}

.family-view.visible {
    display: block;
}

.family-view::before {
    content: '';
    position: fixed;
    inset: 0 0 0 260px;
    background: rgba(0, 0, 0, 0.45);
    z-index: -1;
}

.family-glow {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: 
        radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 35%),
        radial-gradient(circle at 15% 85%, rgba(168, 85, 247, 0.1) 0%, transparent 35%);
}

.family-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 40px 100px;
    position: relative;
}

.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(var(--primary-rgb), 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(var(--primary-rgb), 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(var(--primary-rgb), 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: color-mix(in srgb, var(--color-error) 40%, transparent);
}

/* === 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(var(--primary-rgb), 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;
}

/* === Task Counts on Member Card === */
.family-task-counts {
    display: none;
    align-items: center;
    gap: 12px;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    flex-wrap: wrap;
}

.family-task-today,
.family-task-total {
    display: flex;
    align-items: center;
    gap: 3px;
}

.family-task-today strong,
.family-task-total strong {
    color: var(--text-primary, #fff);
    font-weight: 600;
    font-size: 13px;
}

/* === Assign Task Button === */
.family-assign-task-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    background: none;
    border: none;
    color: #60a5fa;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 0;
    transition: color 0.15s, opacity 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.family-assign-task-btn:hover {
    color: #93c5fd;
    opacity: 0.9;
}

.family-assign-task-btn svg {
    flex-shrink: 0;
    opacity: 0.85;
}

/* === Assign Task Overlay / Modal === */
.family-assign-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
    animation: fam-fade-in 0.18s ease;
}

@keyframes fam-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.family-assign-modal {
    background: var(--chat-bg, #1a1a2e);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 18px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: fam-slide-up 0.2s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 24px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
    overflow: hidden;
}

.family-assign-modal--create {
    max-width: 440px;
}

@keyframes fam-slide-up {
    from { transform: translateY(20px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.family-assign-modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #2a2a2a);
    flex-shrink: 0;
}

.family-assign-modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.family-assign-modal-sub {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
}

.family-assign-modal-close {
    background: none;
    border: none;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

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

/* Search */
.family-assign-modal-search-wrap {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border-color, #2a2a2a);
    flex-shrink: 0;
}

.family-assign-search {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 10px;
    color: var(--text-primary, #fff);
    font-size: 13px;
    padding: 8px 12px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.family-assign-search:focus {
    border-color: rgba(var(--primary-rgb), 0.5);
    background: rgba(var(--primary-rgb), 0.05);
}

.family-assign-search::placeholder {
    color: var(--text-muted, #6b7280);
}

/* Body / Task list */
.family-assign-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.family-assign-modal-body::-webkit-scrollbar {
    width: 4px;
}

.family-assign-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.family-assign-modal-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.fam-task-list {
    padding: 8px 0;
}

.fam-task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid var(--border-color, #1e1e1e);
}

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

.fam-task-item:hover {
    background: rgba(var(--primary-rgb), 0.06);
}

.fam-task-item--checked {
    background: rgba(var(--primary-rgb), 0.08);
}

.fam-task-item--overdue {
    opacity: 0.65;
}

.fam-task-cb {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: #667eea;
    cursor: pointer;
}

.fam-task-item-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.fam-task-item-title {
    font-size: 13.5px;
    color: var(--text-primary, #fff);
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word;
}

.fam-task-item-due {
    font-size: 11.5px;
    color: var(--text-muted, #6b7280);
}

.fam-task-item-due.overdue {
    color: var(--color-error);
}

/* Footer */
.family-assign-modal-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #2a2a2a);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Create Task form */
.family-create-task-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.family-create-task-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

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

.family-create-task-input:focus {
    border-color: rgba(var(--primary-rgb), 0.5);
    background: rgba(var(--primary-rgb), 0.05);
}

.family-create-task-input::placeholder {
    color: var(--text-muted, #6b7280);
}

.family-create-task-textarea {
    resize: vertical;
    min-height: 60px;
}

.family-create-task-row {
    display: flex;
    gap: 12px;
}

.family-create-task-row .family-create-task-field {
    flex: 1;
}

input[type="date"].family-create-task-input,
input[type="time"].family-create-task-input {
    color-scheme: dark;
}

.family-create-task-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 13px;
    padding: 8px 12px;
    margin-top: 4px;
}

/* ============ 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(var(--primary-rgb), 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(var(--primary-rgb), 0.3);
    background: rgba(var(--primary-rgb), 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(var(--primary-rgb), 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(var(--primary-rgb), 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(var(--primary-rgb), 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(var(--primary-rgb), 0.4);
    transition: all 0.2s;
    z-index: 100;
}

.memory-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(var(--primary-rgb), 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(var(--primary-rgb), 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(var(--primary-rgb), 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 color-mix(in srgb, var(--color-error) 33%, transparent);
    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(var(--primary-rgb), 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(var(--primary-rgb), 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: var(--color-error);
}

/* === 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(var(--primary-rgb), 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(var(--primary-rgb), 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: color-mix(in srgb, var(--color-error) 33%, transparent);
    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(var(--primary-rgb), 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 8px;
    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);
    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: var(--text-primary);
    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: var(--text-primary);
    margin-bottom: 4px;
}

.fwd-modal-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 22px;
}

.fwd-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    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: var(--text-primary);
}

.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: var(--text-primary);
    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: var(--text-secondary);
    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);
}

/* ── Mobile Bottom Navigation ── */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(10, 10, 15, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 200;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 2px !important;
        padding: 6px 4px !important;
        cursor: pointer;
        transition: color 0.2s;
        border-radius: 0 !important;
        min-height: 44px;
    }

    .bottom-nav-item .material-symbols-outlined {
        font-size: 22px !important;
    }

    .bottom-nav-item>span:last-child {
        font-size: 10px !important;
        font-weight: 500 !important;
        line-height: 1 !important;
    }

    .bottom-nav-item.active {
        color: var(--primary-color, #6366f1) !important;
        background: transparent !important;
    }

    /* ── Sidebar как overlay ── */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        z-index: 300 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 299;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* ── Контент на полную ширину ── */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }

    /* ── Чат ── */
    .chat-container {
        height: calc(100vh - 60px - env(safe-area-inset-bottom)) !important;
        height: calc(100dvh - 60px - env(safe-area-inset-bottom)) !important;
    }

    .messages {
        padding: 12px 8px 130px !important;
    }

    .message {
        padding: 14px !important;
        border-radius: 18px !important;
        max-width: 95% !important;
    }

    .message-text {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }

    /* ── Input на полную ширину, sticky ── */
    .input-container,
    .message-input-container {
        position: fixed !important;
        bottom: calc(60px + env(safe-area-inset-bottom)) !important;
        left: 0 !important;
        right: 0 !important;
        padding: 8px 12px !important;
        background: rgba(10, 10, 15, 0.95) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        z-index: 100 !important;
    }

    .input-text,
    .message-input {
        font-size: 16px !important; /* Предотвращает zoom на iOS */
        min-height: 44px !important;
    }

    /* ── Skill pills: фиксируем над input на мобилке ── */
    .chat-skill-pills {
        position: fixed !important;
        bottom: calc(60px + 125px + env(safe-area-inset-bottom)) !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 101 !important;
        padding: 6px 12px !important;
        margin: 0 !important;
        background: rgba(10, 10, 15, 0.92) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        gap: 6px !important;
        -webkit-overflow-scrolling: touch;
        border-top: 1px solid rgba(255,255,255,0.07) !important;
    }

    .send-btn {
        min-width: 44px !important;
        min-height: 44px !important;
    }

    /* ── Dashboard ── */
    .hdb-grid {
        grid-template-columns: 1fr !important;
    }

    .hdb-hero {
        padding: 20px 16px !important;
    }

    .hdb-hero-greeting {
        font-size: 22px !important;
    }

    .hdb-quick-actions {
        flex-wrap: wrap !important;
    }

    .hdb-card {
        border-radius: 16px !important;
        padding: 16px !important;
    }

    /* ── Family View ── */
    #family-view {
        padding: 12px !important;
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }

    /* ── Settings View ── */
    #settings-view {
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }

    .ags-wrap {
        grid-template-columns: 1fr !important;
        padding: 12px 12px calc(80px + env(safe-area-inset-bottom)) !important;
    }

    /* ── Touch targets: все кнопки минимум 44px ── */
    button, .nav-item, [role="button"] {
        min-height: 44px;
    }

    /* ── Отступ снизу для всех основных видов ── */
    #family-view,
    #settings-view,
    #memory-view,
    #admin-view,
    #skill-constructor-view {
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }
}




/* --- DIGITAL HEARTH DYNAMIC BACKGROUND --- */
:root {
    --bg-url: none;
    --bg-overlay: rgba(0, 0, 0, 0.45);
}
body {
    background-color: #0a0a0f; /* Solid fallback until JS sets the image */
    background: linear-gradient(var(--bg-overlay), var(--bg-overlay)), var(--bg-url) no-repeat center center fixed !important;
    background-size: cover !important;
    /* No transition — cannot interpolate between image URLs, causes flash */
}

.app-container,
.main-content,
.dashboard-view,
.hdb-view,
.dashboard-layout {
    background: transparent !important;
    background-color: transparent !important;
}

.sidebar {
    background: rgba(0, 0, 0, 0.2) !important;
    backdrop-filter: blur(40px) !important;
}

/* --- DIGITAL HEARTH CHAT DESIGN --- */
.chat-header {
    background: rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.chat-container {
    background: transparent !important;
}

.message {
    padding: 20px !important;
    border-radius: 24px !important;
    transition: all 0.3s ease !important;
    margin-bottom: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.03) !important;
}

.message.ai {
    background: rgba(0, 0, 0, 0.25) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2) !important;
}

.message.user {
    background: rgba(255, 255, 255, 0.03) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
}

.input-area {
    background: transparent !important;
    border-top: none !important;
    padding-bottom: 40px !important;
}

.input-container {
    background: rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(30px) !important;
    -webkit-backdrop-filter: blur(30px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 28px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
}

#messageInput {
    color: #fff !important;
}

.welcome-screen {
    background: transparent !important;
}

.chip {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.8) !important;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--primary-color) !important;
}
/* --- DIGITAL HEARTH MODAL SYSTEM --- */
/* Fullscreen Centering Containers (Pure Flex, No Background) */
.modal.active, .hdb-loc-modal.open, .dashboard-modal, .auth-modal, #auth-modal.active, #logout-confirm-dialog {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    background: transparent !important;
}

/* Background Overlays (Provide Blur & Darkening) */
/* Note: hdb-msg/notif-overlay ARE the containers in some modules, so we handle them specially */
.hdb-msg-overlay, .fwd-overlay, .hdb-notif-overlay, .dashboard-modal-overlay, .auth-modal-overlay, #auth-overlay {
    background: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 9998 !important; /* One level below the main containers or content */
    pointer-events: auto !important;
}

/* Base states (hidden by default) */
.modal, .hdb-loc-modal, #auth-modal {
    display: none !important;
}
.modal.active, .hdb-loc-modal.open, .dashboard-modal, .auth-modal, #auth-modal.active, #logout-confirm-dialog {
    display: flex !important;
}

/* Ensure content is always above blur */
.modal-content, .hdb-msg-modal, .hdb-loc-modal-inner, #logout-confirm-dialog > div, .fwd-modal, .hdb-notif-modal, .dashboard-modal-content, .auth-modal-content {
    background: rgba(20, 20, 35, 0.85) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    border-radius: 36px !important;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8) !important;
    color: #fff !important;
    padding: 40px !important;
    width: 460px !important;
    max-width: 95% !important;
    position: relative !important;
    margin: auto !important;
    z-index: 10000 !important; /* Higher than overlays */
    display: block !important;
    pointer-events: auto !important;
}

.hdb-loc-modal-inner {
    width: 85vw !important;
    height: 80vh !important;
}

.modal-header h2, .hdb-msg-modal-title, .fwd-modal-title, .hdb-notif-modal-title, .auth-modal-title {
    color: #fff !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    margin-bottom: 8px !important;
    margin-top: 0 !important;
    letter-spacing: -0.02em !important;
}

.form-group label, .fwd-section-label, .hdb-section-label {
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 700 !important;
    margin-bottom: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.12em !important;
    font-size: 11px !important;
    display: block !important;
}

.form-group input, .form-group textarea, .form-group select, .fwd-textarea, .hdb-msg-textarea, .auth-form-group input {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 16px !important;
    color: #fff !important;
    padding: 14px 20px !important;
    transition: all 0.3s ease !important;
    font-family: inherit !important;
    width: 100% !important;
    box-sizing: border-box !important;
    outline: none !important;
}

.form-group input:focus, .fwd-textarea:focus, .hdb-msg-textarea:focus, .auth-form-group input:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18) !important;
}

.modal-footer, .hdb-msg-modal-footer, .fwd-actions, .auth-modal-footer {
    padding-top: 24px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    display: flex !important;
    gap: 14px !important;
    margin-top: 24px !important;
}

.btn-secondary, #logout-cancel, .hdb-btn-secondary, .fwd-cancel-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    border-radius: 18px !important;
    font-weight: 600 !important;
    padding: 12px 28px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    flex: 1 !important;
    text-align: center !important;
}

.btn-secondary:hover, #logout-cancel:hover, .hdb-btn-secondary:hover, .fwd-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.18) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.btn-primary, .hdb-btn-primary, .fwd-send-btn, .auth-btn-primary {
    background: var(--primary-color) !important;
    border: none !important;
    color: #fff !important;
    border-radius: 18px !important;
    font-weight: 700 !important;
    padding: 12px 28px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    flex: 2 !important;
    text-align: center !important;
    box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.3) !important;
}

.btn-primary:hover, .hdb-btn-primary:hover, .fwd-send-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 32px rgba(var(--primary-rgb), 0.4) !important;
    opacity: 0.9 !important;
}

/* --- FINAL GLASS RELOADED --- */
html body .modal-content, html body .hdb-msg-modal, html body .hdb-loc-modal-inner, html body #logout-confirm-dialog > div {
    background: rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(45px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(45px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 36px !important;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.7) !important;
    color: #fff !important;
}

/* --- AUTH MODAL SPECIFIC --- */
#auth-overlay, .auth-modal-overlay {
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    position: absolute !important;
    inset: 0 !important;
    z-index: -1 !important;
}

.auth-modal-content {
    /* Inherits from standard modal, but let's be explicit */
    z-index: 1 !important;
}
.auth-form-group input {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 14px !important;
    color: #fff !important;
}

.auth-success-message {
    background: rgba(34, 197, 94, 0.1) !important;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    color: #22c55e !important;
    padding: 12px 16px !important;
    border-radius: 12px !important;
    margin-bottom: 20px !important;
    font-size: 14px !important;
    text-align: center !important;
}
