* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    transition: background-color 0.3s;
}

/* СВЕТЛАЯ ТЕМА */
body.light-theme {
    --bg: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --text: #1A1A1A;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border: #E5E5E5;
    --divider: #F0F0F0;
    --message-own: #667eea;
    --message-other: #F0F0F0;
    --online: #4CAF50;
    --input-bg: #FFFFFF;
    --input-border: #E0E0E0;
    --button: #667eea;
}

/* ТЁМНАЯ ТЕМА */
body.dark-theme {
    --bg: #1A1A1A;
    --bg-secondary: #121212;
    --text: #FFFFFF;
    --text-secondary: #AAAAAA;
    --text-tertiary: #777777;
    --border: #333333;
    --divider: #2A2A2A;
    --message-own: #667eea;
    --message-other: #2A2A2A;
    --online: #4CAF50;
    --input-bg: #2A2A2A;
    --input-border: #3A3A3A;
    --button: #667eea;
}

body {
    background-color: var(--bg);
    color: var(--text);
}

/* СТРАНИЦЫ */
.page {
    display: none;
    min-height: 100vh;
    background-color: var(--bg);
}
.page.active {
    display: block;
}

/* ========== ОНБОРДИНГ ========== */
.onboarding-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.onboarding-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}
.onboarding-illustration {
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.onboarding-img {
    width: 200px;
    height: auto;
    max-width: 80%;
    object-fit: contain;
}
@media (min-width: 768px) {
    .onboarding-img {
        width: 260px;
    }
}
.onboarding-content h1 {
    font-size: 32px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 48px;
}
.btn-start {
    background-color: var(--button);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 14px 40px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 48px;
}
.onboarding-footer {
    margin-top: auto;
    padding-bottom: 32px;
}
.terms-link {
    color: var(--text-tertiary);
    font-size: 12px;
    text-decoration: none;
}

/* ========== АВТОРИЗАЦИЯ ========== */
.auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.auth-content {
    flex: 1;
    padding: 24px;
}
.auth-content h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.3;
}
.auth-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 48px;
    line-height: 1.4;
}
.phone-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 32px;
}
.country-code {
    font-size: 18px;
    font-weight: 500;
    margin-right: 12px;
}
.phone-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 18px;
    outline: none;
    color: var(--text);
}
.phone-input::placeholder {
    color: var(--text-tertiary);
}
.btn-primary {
    background-color: var(--button);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 14px 24px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-large {
    padding: 16px;
    font-size: 18px;
}
.btn-link {
    background: none;
    border: none;
    color: var(--button);
    font-size: 14px;
    margin-top: 16px;
    cursor: pointer;
    width: 100%;
    text-align: center;
}
.timer-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-tertiary);
    margin-top: 16px;
}

/* КОД ПОДТВЕРЖДЕНИЯ — 6 ОТДЕЛЬНЫХ ПОЛЕЙ */
.code-digits-wrapper {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 32px 0;
}
.code-digit {
    width: 50px;
    height: 60px;
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    background-color: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: 12px;
    outline: none;
    color: var(--text);
    font-family: monospace;
}
.code-digit:focus {
    border-color: var(--button);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}
@media (max-width: 480px) {
    .code-digit {
        width: 45px;
        height: 55px;
        font-size: 24px;
    }
    .code-digits-wrapper {
        gap: 8px;
    }
}

/* ========== ПРОФИЛЬ ========== */
.profile-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.profile-content {
    flex: 1;
    padding: 24px;
}
.profile-content h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 48px;
    text-align: center;
}
.profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 48px;
    position: relative;
}
.avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    color: white;
    background-size: cover;
    background-position: center;
}
.add-photo-btn {
    position: absolute;
    bottom: 0;
    right: 120px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--button);
    color: white;
    border: 2px solid var(--bg);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.input-group {
    margin-bottom: 24px;
}
.profile-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    outline: none;
    color: var(--text);
}
.profile-input::placeholder {
    color: var(--text-tertiary);
}
.input-error {
    font-size: 12px;
    color: #ff4444;
    margin-top: 8px;
}

/* ========== СПИСОК ЧАТОВ ========== */
.chats-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.chats-header {
    padding: 16px 20px;
}
.chats-header h1 {
    font-size: 28px;
    font-weight: 700;
}
.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-secondary);
    margin: 12px 16px;
    padding: 12px 16px;
    border-radius: 12px;
}
.search-icon {
    margin-right: 8px;
    color: var(--text-tertiary);
}
.search-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 16px;
    color: var(--text);
}
.search-input::placeholder {
    color: var(--text-tertiary);
}
.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
}
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
}
.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
    cursor: pointer;
}
.chat-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    color: white;
    margin-right: 14px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}
.chat-info {
    flex: 1;
}
.chat-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}
.chat-status {
    font-size: 13px;
    color: var(--text-tertiary);
}
.chat-status.online {
    color: var(--online);
}
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    background-color: var(--bg);
}
.nav-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 8px 24px;
    color: var(--text-tertiary);
}
.nav-btn.active {
    color: var(--button);
}

/* ========== ЭКРАН ЧАТА ========== */
.chat-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.back-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text);
}
.chat-user-info {
    flex: 1;
    text-align: center;
}
.chat-user-name {
    font-weight: 600;
    font-size: 17px;
}
.chat-header-actions {
    display: flex;
    gap: 16px;
}
.search-chat-btn, .menu-chat-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.message-own {
    align-self: flex-end;
}
.message-other {
    align-self: flex-start;
}
.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
}
.message-own .message-bubble {
    background-color: var(--message-own);
    color: white;
    border-bottom-right-radius: 4px;
}
.message-other .message-bubble {
    background-color: var(--message-other);
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.message-time {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 4px;
    margin-left: 8px;
}
.chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    gap: 12px;
}
.chat-input {
    flex: 1;
    padding: 12px 16px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 24px;
    outline: none;
    font-size: 16px;
    color: var(--text);
}
.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--button);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

/* ========== НАСТРОЙКИ ========== */
.settings-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.settings-header {
    padding: 16px 20px;
}
.settings-header h1 {
    font-size: 28px;
    font-weight: 700;
}
.settings-list {
    flex: 1;
    padding: 0 16px;
}
.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    cursor: pointer;
    font-size: 16px;
}
.settings-divider {
    height: 1px;
    background-color: var(--divider);
    margin: 8px 0;
}
.settings-value {
    color: var(--text-tertiary);
    font-size: 14px;
}
.settings-arrow {
    color: var(--text-tertiary);
}
#settings-logout-item {
    color: #ff4444;
}

/* АДАПТАЦИЯ ДЛЯ ПК */
@media (min-width: 768px) {
    .auth-content, .profile-content {
        max-width: 400px;
        margin: 0 auto;
        width: 100%;
    }
    
    .chats-container, .chat-container, .settings-container {
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    
    body {
        background-color: var(--bg-secondary);
    }
}