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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;
    --border: #2d2d44;
    --success: #10b981;
    --error: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Connection Status */
.connection-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    background: var(--bg-primary);
    white-space: nowrap;
}

.connection-status.connected {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.connection-status.connecting {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.connection-status.offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
}

.header-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

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

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.welcome-message h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 0.95rem;
}

/* Messages */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--success), #059669);
}

.message-content {
    background: var(--bg-tertiary);
    padding: 0.875rem 1rem;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--primary);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 0.5rem;
}

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

.message-content pre {
    background: var(--bg-primary);
    padding: 0.75rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.85rem;
}

.message-content code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
}

.message-content :not(pre) > code {
    background: var(--bg-primary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}

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

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Input Container */
.input-container {
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 0.5rem;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

#message-input:focus {
    outline: none;
}

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

#message-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn {
    background: var(--primary);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
}

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

/* Voice Recording Button */
.voice-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    flex-shrink: 0;
}

.voice-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.voice-btn.recording {
    background: var(--error);
    border-color: var(--error);
    color: white;
    animation: pulse 1.5s infinite;
}

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

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

/* Recording indicator */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
    color: var(--error);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

/* Voice message styling */
.message.voice .message-content {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.05));
    border-left: 3px solid var(--primary);
}

/* Media Content Styles */
.message-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-content img:hover {
    transform: scale(1.02);
}

.message-content video {
    max-width: 100%;
    border-radius: 8px;
    margin: 0.5rem 0;
}

.message-content .media-container {
    margin: 0.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-primary);
}

.message-content .audio-player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 8px;
    margin: 0.5rem 0;
}

.message-content .audio-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.message-content audio {
    flex: 1;
    height: 40px;
    border-radius: 4px;
}

/* Audio player custom styling for webkit */
.message-content audio::-webkit-media-controls-panel {
    background: var(--bg-tertiary);
}

/* Image lightbox */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.image-lightbox.show {
    opacity: 1;
    visibility: visible;
}

.image-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.image-lightbox .close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-lightbox .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Media loading placeholder */
.media-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-primary);
    border-radius: 8px;
    color: var(--text-muted);
}

.media-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.5rem;
}

/* Media error state */
.media-error {
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
    color: var(--error);
    font-size: 0.875rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}

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

.toast.error {
    border-color: var(--error);
    color: var(--error);
}

.toast.success {
    border-color: var(--success);
    color: var(--success);
}

/* Responsive */
@media (max-width: 640px) {
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }

    .header {
        padding: 0.875rem 1rem;
    }

    .chat-container {
        padding: 1rem;
    }

    .input-container {
        padding: 0.75rem 1rem;
    }

    .message {
        max-width: 90%;
    }
}

/* Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: none;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 999;
}

.install-prompt.show {
    display: flex;
}

.install-prompt-content {
    flex: 1;
}

.install-prompt h3 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.install-prompt p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.install-prompt button {
    background: var(--primary);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}

.install-prompt .dismiss-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: var(--bg-primary);
}

.login-screen[hidden] {
    display: none;
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.login-error {
    color: var(--error);
    font-size: 0.875rem;
    min-height: 1.25rem;
    text-align: center;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-loader[hidden] {
    display: none;
}

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

.login-footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-footer p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.login-footer code {
    background: var(--bg-primary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
}

/* Login Divider */
.login-divider {
    display: flex;
    align-items: center;
    margin: 1.25rem 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-divider span {
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Auth Switch (login <-> register) */
.auth-switch {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.auth-switch-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
}

.auth-switch-btn:hover {
    text-decoration: underline;
}

/* Auth links row */
.auth-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* Verify email result */
.verify-result-content {
    text-align: center;
    padding: 1rem 0;
}

.verify-result-content .success-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.verify-result-content h3 {
    margin-bottom: 0.5rem;
}

.verify-result-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Google Login Button */
.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #3c4043;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.google-login-btn:hover:not(:disabled) {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.google-login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.google-login-btn .google-icon {
    flex-shrink: 0;
}

/* Yandex Login Button */
.yandex-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #3c4043;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.yandex-login-btn:hover:not(:disabled) {
    background: #fff5f2;
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.yandex-login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.yandex-login-btn .yandex-icon {
    flex-shrink: 0;
}

/* Header Right Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 12px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive for login */
@media (max-width: 640px) {
    .login-container {
        padding: 1.5rem;
    }

    .user-name {
        display: none;
    }
}

/* Message Reactions */
.reactions-container {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.reactions-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.4rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reaction-badge:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
}

.reaction-badge.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

.reactions-picker {
    display: flex;
    gap: 0.125rem;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 0.25rem;
}

.message.assistant:hover .reactions-picker {
    opacity: 1;
}

.reaction-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.2rem 0.35rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.7;
}

.reaction-btn:hover {
    background: var(--bg-primary);
    border-color: var(--border);
    opacity: 1;
    transform: scale(1.15);
}

.reaction-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    opacity: 1;
}

/* Show reactions picker on mobile (always visible) */
@media (max-width: 640px) {
    .reactions-picker {
        opacity: 0.7;
    }

    .reaction-btn {
        padding: 0.15rem 0.3rem;
        font-size: 0.85rem;
    }
}

/* Touch device - make reactions more accessible */
@media (hover: none) {
    .reactions-picker {
        opacity: 1;
    }
}

/* Ensure recording indicator is hidden when not recording */
.recording-indicator[hidden] {
    display: none !important;
}

/* Clean Social Login Buttons */
.social-login-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    justify-content: center;
}

.social-divider {
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    position: relative;
    margin: 0.5rem 0;
}
.social-divider::before,
.social-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: var(--border-color);
}
.social-divider::before { left: 0; }
.social-divider::after { right: 0; }

.social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.social-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.social-icon {
    width: 22px;
    height: 22px;
}

.google-btn:hover {
    border-color: #4285F4;
}

.yandex-btn:hover {
    border-color: #FC3F1D;
}

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-layout[hidden] {
    display: none;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 240px;
    height: 100vh;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 1.5rem;
}

.sidebar-brand {
    font-size: 1.125rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    user-select: none;
}

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

.sidebar-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.sidebar-item.active svg {
    stroke: var(--primary-light);
}

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

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    background: none;
    border: none;
    width: 100%;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-family: inherit;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    height: 100vh;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

/* ===== App Sections ===== */
.app-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-section[hidden] {
    display: none !important;
}

/* ===== Section Content ===== */
.section-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.section-content::-webkit-scrollbar {
    width: 6px;
}

.section-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.section-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ===== Placeholder Sections ===== */
.placeholder-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.placeholder-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.placeholder-section p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    transition: opacity 0.3s;
}

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

/* ===== Sidebar Toggle (hidden on desktop) ===== */
.sidebar-toggle {
    display: none;
}

/* ===== Responsive: Mobile (< 768px) ===== */
@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: 200;
    }

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

    .sidebar-toggle {
        display: flex;
    }

    .main-content {
        width: 100%;
    }
}

/* ===== Desktop ===== */
@media (min-width: 768px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* ===== Settings / Profile Styles ===== */
.settings-profile {
    max-width: 600px;
    margin: 0 auto;
}

.settings-profile .profile-header {
    text-align: center;
    margin-bottom: 2rem;
}

.settings-profile .profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1rem;
}

.settings-profile .profile-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.settings-profile .user-id {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}

.settings-profile .profile-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.settings-profile .profile-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.settings-profile .profile-card-header .icon {
    font-size: 1.25rem;
}

.settings-profile .profile-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.settings-profile .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.settings-profile .stat-item {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 0.875rem;
    text-align: center;
}

.settings-profile .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.settings-profile .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.settings-profile .subscription-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
}

.settings-profile .subscription-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.settings-profile .subscription-badge.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
}

.settings-profile .subscription-info {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.settings-profile .subscription-info p {
    margin-bottom: 0.375rem;
}

.settings-profile .subscription-info p:last-child {
    margin-bottom: 0;
}

.settings-profile .btn {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.settings-profile .btn-primary {
    background: var(--primary);
    color: white;
}

.settings-profile .btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.settings-profile .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.settings-profile .btn-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.settings-profile .form-group .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Settings toggle */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.setting-row .setting-label strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.setting-row .setting-label .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary, #6366f1);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.settings-profile .error-message,
.settings-profile .success-message {
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.settings-profile .error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.settings-profile .success-message {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.settings-profile .profile-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-muted);
}

.settings-profile .loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@media (max-width: 640px) {
    .settings-profile .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .user-name {
        display: none;
    }
}

/* ===== Pricing Cards ===== */
.pricing-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.pricing-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
}

.pricing-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.pricing-card.featured {
    border-color: var(--primary);
    position: relative;
}

.pricing-card.featured::before {
    content: 'Популярный';
    position: absolute;
    top: -0.625rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.75rem;
    border-radius: 10px;
    font-weight: 500;
}

.pricing-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.pricing-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.pricing-price .currency {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.pricing-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.pricing-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    flex: 1;
}

.pricing-features li {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.3rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pricing-features li::before {
    content: '✓';
    color: var(--success);
    font-weight: 600;
}

.pricing-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.pricing-btn:hover {
    background: var(--primary-dark);
}

.pricing-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pricing-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-muted);
}

/* ===== Modal Overlay ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

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

.modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.modal-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.modal-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal-card .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.modal-card .btn-primary {
    background: var(--primary);
    color: white;
}

.modal-card .btn-primary:hover {
    background: var(--primary-dark);
}

/* ===== Subscription CTA ===== */
.subscription-cta {
    margin-top: 0.75rem;
}

.subscription-cta .btn {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
    background: var(--primary);
    color: white;
}

.subscription-cta .btn:hover {
    background: var(--primary-dark);
}

/* ===== Responsive: Pricing ===== */
@media (max-width: 640px) {
    .pricing-cards {
        grid-template-columns: 1fr;
    }
}

/* ===== Practice Cards ===== */
.practices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto;
}

.practice-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
}

.practice-card:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.practice-card:active {
    transform: scale(0.97);
    opacity: 0.85;
}

.practice-emoji {
    font-size: 1.75rem;
    line-height: 1;
}

.practice-name {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}

.practice-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

@media (max-width: 640px) {
    .practices-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem;
    }

    .practice-card {
        padding: 0.875rem 0.5rem;
    }

    .practice-emoji {
        font-size: 1.5rem;
    }

    .practice-name {
        font-size: 0.8rem;
    }
}

/* ===== Onboarding ===== */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.onboarding-overlay[hidden] {
    display: none;
}

.onboarding-container {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
}

.onboarding-progress {
    display: flex;
    gap: 0.5rem;
}

.onboarding-step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s;
}

.onboarding-step-dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}

.onboarding-content {
    width: 100%;
}

.onboarding-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.onboarding-illustration {
    font-size: 4rem;
    line-height: 1;
}

.onboarding-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin: 0;
}

.onboarding-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.onboarding-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.onboarding-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.onboarding-tag {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.onboarding-tag:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.onboarding-tag.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.onboarding-actions {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
    flex-direction: column;
    align-items: center;
}

.onboarding-btn {
    padding: 0.75rem 2rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    border: none;
    width: 100%;
    max-width: 280px;
}

.onboarding-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.onboarding-btn-next {
    background: var(--primary);
    color: white;
}

.onboarding-btn-next:hover:not(:disabled) {
    background: var(--primary-dark);
}

.onboarding-btn-back {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.onboarding-btn-back:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.onboarding-legal {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
    margin-top: 0.25rem;
}

.onboarding-link {
    color: var(--primary-light);
    text-decoration: none;
}

.onboarding-link:hover {
    text-decoration: underline;
}

/* Mood Slider */
.mood-selector {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0;
}

.mood-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.mood-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    cursor: pointer;
}

.mood-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid var(--primary-light);
}

.mood-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid var(--primary-light);
}

.mood-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.mood-response {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.75rem;
    text-align: center;
    font-style: italic;
}

/* Onboarding Loading */
.onboarding-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 0;
    color: var(--text-secondary);
}

.onboarding-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: onboarding-spin 0.8s linear infinite;
}

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

@media (max-width: 640px) {
    .onboarding-container {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }

    .onboarding-title {
        font-size: 1.1rem;
    }

    .onboarding-tag {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }
}

/* ===== Invite Banner ===== */
.invite-banner {
    text-align: center;
    padding: 1rem 0;
    animation: fadeIn 0.3s ease;
}

.invite-banner[hidden] {
    display: none;
}

.invite-banner-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.invite-banner-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 0.25rem;
}

.invite-banner-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
