:root {
    --bg-app: #0b141a;
    --bg-panel: #111b21;
    --bg-elevated: #202c33;
    --bg-input: #2a3942;
    --text-main: #e9edef;
    --text-muted: #8696a0;
    --border-color: #222e35;
    --accent: #00a884;
    --accent-hover: #029072;
    --msg-out: #005c4b;
    --msg-in: #202c33;
    --tick-grey: #8696a0;
    --tick-read: #25d366;
    --danger: #ef4444;
}

body.theme-light {
    --bg-app: #efeae2;
    --bg-panel: #ffffff;
    --bg-elevated: #f0f2f5;
    --bg-input: #f0f2f5;
    --text-main: #111b21;
    --text-muted: #667781;
    --border-color: #d9dee2;
    --accent: #008069;
    --accent-hover: #016d59;
    --msg-out: #d9fdd3;
    --msg-in: #ffffff;
    --tick-grey: #667781;
    --tick-read: #16a34a;
    --danger: #dc2626;
}

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

html, body {
    height: 100%;
    min-height: 100dvh;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.auth-card {
    min-height: 100dvh;
    max-width: 440px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    background: var(--bg-panel);
}

.top-utility-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.brand-header {
    text-align: center;
}

.brand-badge {
    width: 52px;
    height: 52px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    display: grid;
    place-items: center;
}

.brand-header p {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--bg-elevated);
    padding: 4px;
    border-radius: 10px;
}

.auth-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.auth-tab.active {
    background: var(--accent);
    color: #fff;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input,
.add-contact-box input,
.search-box input,
.message-composer input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 15px;
    outline: none;
}

.auth-form button,
.add-contact-box button,
.message-composer button {
    padding: 12px 14px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.auth-form button:hover,
.add-contact-box button:hover,
.message-composer button:hover {
    background: var(--accent-hover);
}

.auth-hint {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.app-shell {
    height: 100dvh;
    min-height: 100dvh;
    width: 100%;
    display: flex;
    overflow: hidden;
    background: var(--bg-panel);
}

.sidebar {
    width: 360px;
    max-width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--bg-panel);
}

.sidebar-top {
    padding: 12px 14px;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-pill small {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
}

.sidebar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.ghost-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.install-btn {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.avatar-picker {
    position: relative;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-dot,
.avatar-img,
.peer-avatar-img,
.peer-avatar-fallback,
.contact-avatar-img,
.contact-avatar-fallback {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
}

.add-contact-box {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.add-contact-box button {
    width: 100%;
}

.search-box {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.section-label {
    padding: 10px 14px 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.contacts-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.contact-item:hover,
.contact-item.active {
    background: var(--bg-elevated);
}

.contact-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.contact-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-sub {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.contact-tag {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.unread-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-panel {
    flex: 1;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    min-width: 0;
}

.chat-header {
    padding: 12px 14px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-peer-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-header h2 {
    font-size: 16px;
}

.chat-header small {
    color: var(--text-muted);
    font-size: 12px;
}

.call-btn {
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

.call-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.call-banner {
    padding: 10px 14px;
    background: #14362e;
    color: #e9edef;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
}

.call-banner-actions {
    display: flex;
    gap: 8px;
}

.accept-call-btn {
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.hangup-call-btn {
    border: none;
    background: var(--danger);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.messages-feed {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-state {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    max-width: 320px;
}

.msg-bubble {
    max-width: 78%;
    min-width: 110px;
    padding: 10px 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    word-break: break-word;
}

.msg-out {
    align-self: flex-end;
    background: var(--msg-out);
}

.msg-in {
    align-self: flex-start;
    background: var(--msg-in);
}

.msg-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.msg-text {
    font-size: 14px;
    line-height: 1.4;
    flex: 1;
}

.msg-audio {
    width: 220px;
    max-width: 100%;
    height: 36px;
}

.msg-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

.msg-doc-link {
    display: inline-block;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.edit-msg-btn {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    flex-shrink: 0;
}

.edit-msg-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.msg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.receipt-ticks {
    font-weight: 700;
    letter-spacing: -1px;
    font-size: 12px;
}

.receipt-ticks.sent,
.receipt-ticks.delivered {
    color: var(--tick-grey);
}

.receipt-ticks.read {
    color: var(--tick-read);
}

.message-composer {
    padding: 10px 12px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-action-btn {
    padding: 10px 12px;
    font-size: 13px;
    flex-shrink: 0;
}

.icon-action-btn.recording {
    background: var(--danger);
}

.message-composer button:disabled,
.message-composer input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
    }

    .chat-panel {
        width: 100%;
    }

    .msg-bubble {
        max-width: 86%;
    }
}
.app-shell {
    position: relative;
}

.global-call-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.vn-player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 190px;
}

.vn-seek {
    flex: 1;
    width: 110px;
    accent-color: var(--accent);
    cursor: pointer;
}

.vn-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.app-shell {
    position: relative;
}

.global-call-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.vn-player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 190px;
}

.vn-seek {
    flex: 1;
    width: 110px;
    accent-color: var(--accent);
    cursor: pointer;
}

.vn-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
