:root {
    --bg-color: #000000;
    --surface-color: #121212;
    --surface-border: #2a2a2a;
    --primary-accent: #ff2a55;
    --text-main: #f0f2f5;
    --text-muted: #8e8e93;
    --header-height: 56px;
    --bottom-nav-height: 64px;
}

body.light-mode {
    --bg-color: #f7f7f8;
    --surface-color: #ffffff;
    --surface-border: #e0e0e0;
    --text-main: #121212;
    --text-muted: #666666;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overscroll-behavior-y: none;
}

body {
    font-family: 'Roboto', -apple-system, system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.flex-center {
    justify-content: center;
    align-items: center;
}

.hidden {
    display: none !important;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* Login */
.login-box {
    text-align: center;
    padding: 30px;
    background: var(--surface-color);
    border-radius: 24px;
    border: 1px solid var(--surface-border);
    width: 85%;
    max-width: 320px;
    position: relative;
    z-index: 50;
}

.logo-title {
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 5px;
}

.subtitle {
    color: var(--primary-accent);
    font-size: 14px;
    margin: 0 0 30px;
}

.btn-primary {
    background: var(--text-main);
    color: var(--bg-color);
    border: none;
    padding: 14px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 15px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.btn-primary svg {
    pointer-events: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    margin-bottom: 8px;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
}

/* Header */
.app-header {
    height: var(--header-height);
    background: var(--primary-accent);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
}

.app-header h2 {
    font-size: 20px;
    margin: 0;
    font-weight: 500;
    flex: 1;
    color: #fff;
}

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

.header-icon {
    width: 44px;
    height: 44px;
    color: #ffffff !important;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--primary-accent);
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-icon svg {
    pointer-events: none;
}

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

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Bottom Tabs */
.tabs {
    display: flex;
    background: var(--surface-color);
    border-top: 1px solid var(--surface-border);
    height: var(--bottom-nav-height);
    flex-shrink: 0;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 0;
}

.tab-icon {
    margin-bottom: 4px;
}

.tab.active {
    color: var(--primary-accent);
}

.tab.active .tab-label {
    font-weight: 700;
}

.tab-label {
    font-size: 12px;
}

/* Views */
.view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
}

.bubble.left {
    background: var(--surface-color);
    align-self: flex-start;
    border-bottom-left-radius: 18px;
}

.bubble.right {
    background: var(--primary-accent);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 18px;
}

.bubble-sender {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.bubble.right .bubble-sender { display: none; }

/* Input Area */
.input-area {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface-color);
    border-top: 1px solid var(--surface-border);
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}

.input-area input[type="text"] {
    flex: 1;
    background: var(--bg-color);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    padding: 0 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    height: 40px;
}

.btn-send {
    background: var(--primary-accent);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #fff;
    margin-left: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* Users List */
.users-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.user-row {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--surface-color);
    cursor: pointer;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--surface-border);
    background-size: cover;
    background-position: center;
    margin-right: 16px;
}

.user-name {
    font-weight: 500;
    font-size: 16px;
    color: var(--text-main);
}

.user-status {
    font-size: 13px;
    color: var(--primary-accent);
}

/* Profile Content */
.profile-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    overflow-y: auto;
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--surface-border);
    margin-bottom: 16px;
    background-size: cover;
    background-position: center;
}

.profile-content h3 { margin: 0 0 5px; font-size: 22px; font-weight: 500; }
.profile-content p { margin: 0; color: var(--text-muted); font-size: 14px;}

.profile-input {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
}

.profile-input:focus {
    border-color: var(--primary-accent);
}

/* Settings */
.settings-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.settings-section-title {
    color: var(--primary-accent);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
    margin-top: 0;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--surface-border);
    font-size: 16px;
}

.theme-colors {
    display: flex;
    gap: 16px;
    margin-top: 10px;
}

.color-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
}

.color-dot.active {
    border: 2px solid var(--text-main);
    transform: scale(1.1);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px; width: 20px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s;
}
input:checked + .slider { background-color: var(--primary-accent); }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 28px; }
.slider.round:before { border-radius: 50%; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 5px; }
