:root {
    --bg-primary: #0e1621;
    --bg-secondary: #17212b;
    --bg-tertiary: #242f3d;
    --bg-hover: #2b5278;
    --accent: #2AABEE;
    --accent-hover: #229ED9;
    --text-primary: #ffffff;
    --text-secondary: #8b9bab;
    --text-muted: #6c7883;
    --border: #0e1621;
    --online: #4dcd5e;
    --verified: #2AABEE;
    --premium: #e2a03f;
    --danger: #e53935;
    --success: #4caf50;
    --bubble-out: #2b5278;
    --bubble-in: #182533;
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== AUTH ===== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(160deg, #0e1621 0%, #1a2a3a 100%);
}

.auth-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo svg {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
}

.auth-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

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

.btn-ghost {
    background: transparent;
    color: var(--accent);
    width: 100%;
    margin-top: 12px;
}

.btn-ghost:hover {
    background: rgba(42,171,238,0.1);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* ===== APP LAYOUT ===== */
.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header .menu-btn:hover {
    background: var(--bg-tertiary);
}

.search-box {
    flex: 1;
    position: relative;
}

.search-box input {
    width: 100%;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    padding: 10px 16px 10px 40px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-item:hover,
.chat-item.active {
    background: var(--bg-tertiary);
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: var(--text-primary);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.avatar.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--online);
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
}

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

.chat-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.chat-name {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.verified-badge {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.chat-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-preview {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main chat area */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

.main.empty {
    align-items: center;
    justify-content: center;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 120px;
    height: 120px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chat-header {
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header .avatar {
    width: 42px;
    height: 42px;
    font-size: 16px;
}

.chat-header-info h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-header-info span {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

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

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message {
    max-width: 65%;
    display: flex;
    flex-direction: column;
}

.message.out {
    align-self: flex-end;
}

.message.in {
    align-self: flex-start;
}

.bubble {
    padding: 8px 12px 6px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
}

.message.out .bubble {
    background: var(--bubble-out);
    border-bottom-right-radius: 4px;
}

.message.in .bubble {
    background: var(--bubble-in);
    border-bottom-left-radius: 4px;
}

.bubble-text {
    font-size: 15px;
    line-height: 1.4;
}

.bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

.message.in .bubble-meta {
    color: var(--text-muted);
}

.gift-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
}

.gift-icon {
    width: 40px;
    height: 40px;
}

.gift-info strong {
    display: block;
    font-size: 14px;
}

.gift-info span {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Input area */
.input-area {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-area textarea {
    flex: 1;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    padding: 12px 18px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
}

.send-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: default;
}

/* Profile / Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.profile-card {
    text-align: center;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 600;
}

.profile-name {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-username {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 20px 0;
}

.stat {
    text-align: center;
}

.stat strong {
    display: block;
    font-size: 18px;
}

.stat span {
    font-size: 12px;
    color: var(--text-secondary);
}

.gift-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.gift-item {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 16px 8px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s;
}

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

.gift-item svg {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
}

.gift-item .name {
    font-size: 12px;
    font-weight: 600;
}

.gift-item .price {
    font-size: 11px;
    color: var(--premium);
    margin-top: 4px;
}

.rarity-common { color: #aaa; }
.rarity-rare { color: #2AABEE; }
.rarity-epic { color: #a855f7; }
.rarity-legendary { color: #e2a03f; }

/* Stars badge */
.stars-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(226,160,63,0.15);
    color: var(--premium);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

/* Anonymous tag */
.anon-tag {
    font-size: 11px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        height: 100%;
    }
    .sidebar.hidden {
        display: none;
    }
    .main {
        width: 100%;
    }
}
