:root {
    --bg-deep: #f3f4f8;
    --bg-panel: #ffffff;
    --bg-elevated: #eceef3;
    --bg-hover: #f0f1f5;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --accent-soft: #e0f2fe;
    --green: #16a34a;
    --green-soft: #f0fdf4;
    --text: #14151a;
    --text-muted: #6b7280;
    --bubble-out: #0ea5e9;
    --bubble-in: #eceef3;
    --danger: #e11d48;
    --border: #e2e5ec;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
    --shadow-md: 0 12px 40px rgba(15,23,42,.12);
    --side-w: min(420px, 100%);
    --mob-nav-h: 80px;
    --dock-h: 58px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font-family: inherit; }
.hidden { display: none !important; }
kbd { background: var(--bg-elevated); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; border: 1px solid var(--border); }

.app-root { height: 100vh; height: 100dvh; overflow: hidden; }

/* Android WebView — native shell pads WebView between status + nav bars */
html.android-app {
    --inset-top: 0px;
    --inset-bottom: 0px;
    height: 100%;
    min-height: 100%;
}
html.android-app,
html.android-app body {
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    overflow: hidden;
}
html.android-app .app-root,
html.android-app .view-boot,
html.android-app .auth-screen {
    height: 100%;
    max-height: 100%;
    min-height: 0;
}
html.android-app .app-root {
    height: 100%;
    max-height: 100%;
    min-height: 0;
}
html.android-app .auth-header {
    padding-top: 12px;
}
html.android-app .auth-back-btn {
    top: 12px;
}
html.android-app .auth-sheet {
    padding-bottom: 12px;
}
html.android-app .panel-head {
    padding-top: 14px;
}
html.android-app .mobile-nav {
    bottom: 0;
    padding-bottom: 10px;
}
html.android-app .view-main {
    padding-bottom: var(--mob-nav-h);
}
html.android-app .auth-screen {
    padding-bottom: 0;
    box-sizing: border-box;
}
html.android-app .panel-conversation.mobile-open {
    bottom: 0;
}
html.android-app .msg-compose {
    padding-bottom: 8px;
}
html.android-app .conv-head {
    padding-top: 0;
}
html.android-app .compose-overlay .compose-head {
    padding-top: 10px;
}
html.android-app .compose-results {
    padding-bottom: 16px;
}
html.android-app .toast {
    top: 12px;
}

/* Boot — shown while session restores (never flash login) */
.view-boot {
    position: fixed; inset: 0; z-index: 300;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #eff6ff, #f8fafc);
    color: var(--text);
}
.view-boot p { margin-top: 12px; font-weight: 600; font-size: 1.1rem; }
.boot-logo {
    width: 72px; height: 72px; border-radius: 20px;
    background: linear-gradient(135deg, #38bdf8, var(--accent));
    display: grid; place-items: center; font-size: 1.75rem; color: #fff;
    box-shadow: 0 12px 32px rgba(14, 165, 233, .25);
    animation: boot-pulse 1.2s ease-in-out infinite;
}
@keyframes boot-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
html.has-token #view-login { display: none !important; }
html.has-token:not(.app-ready) #view-main { display: none; }
html.app-booting #view-boot { display: flex; }
html.app-ready #view-boot { display: none !important; }
html.app-ready #view-login { display: none !important; }
html.app-ready:not(.app-login) #view-main { display: flex !important; }
html.app-ready:not(.app-login) #view-main.hidden { display: flex !important; }
html.app-ready.app-login #view-main { display: none !important; }
html.app-ready.app-login #view-login,
html.app-ready.app-login .auth-screen { display: flex !important; }
html:not(.has-token):not(.app-ready) #view-boot { display: none !important; }

/* Toast */
.toast {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    max-width: min(90vw, 360px);
    padding: 12px 18px;
    border-radius: 12px;
    background: var(--bg-panel);
    color: var(--text);
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    text-align: center;
}
.toast.error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.person-caller-id { font-size: 0.8rem; color: var(--accent); font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.btn { border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; padding: 13px; width: 100%; margin-top: 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(14, 165, 233, .25); }
.btn-primary:active { background: var(--accent-hover); }
.btn-danger-outline {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin: 20px 16px; width: calc(100% - 32px);
    background: #fff; border: 1px solid #fecaca; color: var(--danger);
    border-radius: 12px; padding: 13px; font-weight: 600;
}
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; }
.switch-form { text-align: center; margin-top: 14px; color: var(--text-muted); font-size: 0.9rem; }
.demo-hint { margin-top: 16px; color: var(--text-muted); font-size: 0.82rem; text-align: center; }
.alert { background: #fef2f2; color: #b91c1c; padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 8px; border: 1px solid #fecaca; }

/* Main layout */
.view-main { display: flex; height: 100%; position: relative; }
.tab-panel { display: flex; flex-shrink: 0; height: 100%; width: 100%; }
.tab-panel.hidden { display: none; }

.panel-side {
    width: var(--side-w);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.panel-head {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 18px; min-height: 58px;
    padding-top: calc(14px + env(safe-area-inset-top));
    flex-shrink: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 1.35rem; font-weight: 800; flex: 1; letter-spacing: -.03em; }
.head-btn {
    width: 42px; height: 42px; border: none; border-radius: 14px;
    background: var(--accent-soft); color: var(--accent); font-size: 1.1rem;
    display: grid; place-items: center;
    box-shadow: var(--shadow-sm);
}
.head-btn:active { background: #bae6fd; transform: scale(.96); }

.scroll-list {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0;
    padding-bottom: 8px;
}
.list-loading { padding: 28px; text-align: center; color: var(--text-muted); }

.avatar {
    width: 50px; height: 50px; border-radius: 50%; color: #fff;
    display: grid; place-items: center; font-weight: 600; font-size: 1.1rem; flex-shrink: 0;
}
.avatar-photo {
    position: relative; overflow: hidden; padding: 0;
}
.avatar-photo img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1;
}
.avatar-photo span {
    display: grid; place-items: center; width: 100%; height: 100%;
}
.avatar-xl { width: 88px; height: 88px; font-size: 2rem; margin: 0 auto; }

.contacts-empty {
    padding: 40px 24px; text-align: center; color: var(--text-muted);
    font-size: 0.95rem; line-height: 1.5;
}
.contacts-empty i { display: block; font-size: 1.5rem; margin-bottom: 10px; opacity: .45; }

/* Rows — Instagram inbox */
.chat-row, .call-row, .person-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; cursor: pointer;
    border-bottom: none;
    transition: background .1s;
}
.chat-row:active, .call-row:active, .person-row:active { background: var(--bg-hover); }
.chat-row.active { background: var(--bg-hover); }
.chat-row.active .chat-row-top strong { color: var(--text); }
.chat-row .avatar, .chat-row .avatar-photo { width: 56px; height: 56px; font-size: 1.15rem; }

.chat-row-body, .call-row-body, .person-row .meta { min-width: 0; flex: 1; }
.chat-row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.chat-row-name, .call-row-body strong, .person-row .meta strong {
    font-size: 1rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0; flex: 1;
}
.chat-row-time, .call-row-time {
    font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0;
    line-height: 1; white-space: nowrap;
}
.peer-signal {
    display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; flex-shrink: 0;
}
.peer-signal__bar {
    width: 3px; border-radius: 1px; background: #e2e8f0;
}
.peer-signal__bar:nth-child(1) { height: 4px; }
.peer-signal__bar:nth-child(2) { height: 6px; }
.peer-signal__bar:nth-child(3) { height: 8px; }
.peer-signal__bar:nth-child(4) { height: 10px; }
.peer-signal[data-level="1"] .peer-signal__bar:nth-child(1) { background: #94a3b8; }
.peer-signal[data-level="2"] .peer-signal__bar:nth-child(-n+2) { background: #f59e0b; }
.peer-signal[data-level="3"] .peer-signal__bar:nth-child(-n+3) { background: #84cc16; }
.peer-signal[data-level="4"] .peer-signal__bar { background: #22c55e; }
.chat-row-preview {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted); font-size: 0.875rem; margin-top: 3px;
    min-width: 0;
}
.chat-row-preview-main {
    flex: 1; min-width: 0; overflow: hidden;
}
.chat-row-preview-main > span,
.chat-row-preview-main .chat-preview-call__txt {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-row-preview .peer-signal {
    height: 10px; flex-shrink: 0; margin-left: 4px;
}
.chat-row-preview .peer-signal__bar { width: 2.5px; }
.chat-row-preview .peer-signal__bar:nth-child(1) { height: 3px; }
.chat-row-preview .peer-signal__bar:nth-child(2) { height: 5px; }
.chat-row-preview .peer-signal__bar:nth-child(3) { height: 7px; }
.chat-row-preview .peer-signal__bar:nth-child(4) { height: 9px; }
.chat-preview-call {
    display: inline-flex; align-items: center; gap: 7px;
    min-width: 0; color: var(--text-muted);
}
.chat-preview-call__ic {
    font-size: 0.78rem; width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center; flex-shrink: 0;
    background: var(--accent-soft); color: var(--accent);
}
.chat-preview-call--missed { color: #dc2626; }
.chat-preview-call--missed .chat-preview-call__ic {
    background: #fee2e2; color: #dc2626;
}
.chat-preview-call__txt {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.unread {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700;
    display: grid; place-items: center; flex-shrink: 0;
}

.call-row .avatar, .call-row .avatar-photo { width: 52px; height: 52px; font-size: 1.05rem; }
.call-row-subline {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 3px; min-width: 0;
}
.call-row-sub {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.82rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.call-row-subline.missed .call-row-sub { color: #dc2626; }
.call-row-subline .peer-signal { height: 10px; flex-shrink: 0; }

.inline-search {
    margin: 10px 12px; padding: 11px 14px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--bg-elevated);
    color: var(--text); font-size: 1rem; outline: none; width: calc(100% - 24px); flex-shrink: 0;
}
.inline-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* Account */
.panel-account { background: var(--bg-deep); }
.panel-account .panel-head { display: none; }
.account-page {
    flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--mob-nav-h) + 12px);
}
.account-page__head {
    padding: calc(16px + env(safe-area-inset-top)) 20px 8px;
}
.account-page__head h1 {
    font-size: 1.75rem; font-weight: 800; letter-spacing: -.04em; color: var(--text);
}

.account-profile {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 20px 28px; text-align: center;
}
.account-avatar {
    position: relative; padding: 0; border: none; background: none; cursor: pointer;
}
.account-avatar__ring {
    display: grid; place-items: center; width: 108px; height: 108px; border-radius: 50%;
    padding: 3px; background: linear-gradient(135deg, #38bdf8, #0ea5e9, #0284c7);
    box-shadow: 0 12px 32px rgba(14, 165, 233, .22); overflow: hidden;
}
.account-avatar__img,
.account-avatar__fb {
    display: grid; place-items: center; width: 102px; height: 102px;
    border-radius: 50%; object-fit: cover;
    background: #075985; color: #fff; font-size: 2.4rem; font-weight: 700;
}
.account-avatar__badge {
    position: absolute; right: 2px; bottom: 2px; width: 32px; height: 32px;
    border-radius: 50%; background: var(--bg-panel); color: var(--accent);
    border: 2px solid var(--bg-deep); display: grid; place-items: center;
    font-size: .78rem; box-shadow: var(--shadow-sm);
}
.account-profile__name {
    margin-top: 16px; font-size: 1.45rem; font-weight: 800; letter-spacing: -.03em;
}
.account-profile__handle {
    margin-top: 4px; font-size: .92rem; color: var(--text-muted); font-weight: 500;
}

.account-block { padding: 0 20px 20px; }
.account-block__label {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--text-muted); margin-bottom: 8px;
}
.account-block__hint {
    margin-top: 8px; font-size: .82rem; color: var(--text-muted); line-height: 1.4;
}
.account-id {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 14px 14px 16px;
    background: var(--bg-panel); border-radius: 16px;
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.account-id__code {
    flex: 1; font-size: 1.25rem; font-weight: 800; letter-spacing: 0;
    color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.account-id__copy {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px; border: none; border-radius: 10px;
    background: var(--accent-soft); color: var(--accent);
    font-size: .82rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.account-id__copy:active { background: #bae6fd; }

.account-card {
    background: var(--bg-panel); border-radius: 16px;
    border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm);
}
.account-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.account-row:last-child { border-bottom: none; }
.account-row__lead {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--bg-deep); color: var(--accent);
    display: grid; place-items: center; font-size: .95rem; flex-shrink: 0;
}
.account-row__label { flex: 1; font-size: 1rem; font-weight: 600; color: var(--text); }
.account-toggle {
    appearance: none; width: 48px; height: 28px; border-radius: 999px;
    background: #d1d5db; border: none; position: relative; cursor: pointer;
    flex-shrink: 0; transition: background .2s;
}
.account-toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: transform .2s;
}
.account-toggle:checked { background: var(--accent); }
.account-toggle:checked::after { transform: translateX(20px); }

.account-foot { padding: 8px 20px 24px; }
.account-logout {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px; border-radius: 14px;
    border: 1px solid #fecdd3; background: #fff5f5;
    color: var(--danger); font-size: .95rem; font-weight: 700; cursor: pointer;
}
.account-logout:active { background: #ffe4e6; }

/* Conversation — Instagram DM */
.panel-conversation {
    flex: 1; display: flex; flex-direction: column; min-width: 0;
    background: #fff; position: relative;
}
.conv-empty { flex: 1; display: grid; place-items: center; z-index: 1; }
.conv-empty-inner { text-align: center; padding: 32px 24px; color: var(--text-muted); max-width: 360px; }
.empty-icon {
    width: 80px; height: 80px; border-radius: 20px; margin: 0 auto 16px;
    background: var(--bg-panel); display: grid; place-items: center;
    font-size: 2rem; color: var(--accent);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.conv-empty-inner h3 { color: var(--text); font-weight: 700; margin-bottom: 10px; font-size: 1.25rem; }
.conv-empty-inner p { line-height: 1.55; font-size: 0.95rem; }

.conv-active { flex: 1; display: flex; flex-direction: column; min-height: 0; z-index: 1; }
.conv-head {
    display: flex; align-items: center; gap: 0;
    padding: 0 6px 0 0;
    padding-top: env(safe-area-inset-top);
    background: #fff;
    min-height: 56px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.conv-back {
    width: 40px; height: 52px; border: none; border-radius: 0;
    background: transparent; color: var(--accent); font-size: 1.15rem;
    display: none; place-items: center; flex-shrink: 0;
    margin: 0; padding: 0;
}
.conv-back:active { opacity: .65; }
.conv-peer {
    display: flex; align-items: center; gap: 10px;
    flex: 1; min-width: 0; padding: 8px 4px;
}
.conv-avatar-wrap {
    position: relative; width: 36px; height: 36px; flex-shrink: 0;
    border-radius: 50%; overflow: hidden;
}
.conv-avatar-wrap img,
.conv-avatar-img,
.conv-avatar-fallback {
    position: absolute; inset: 0;
    width: 100%; height: 100%; border-radius: 50%;
}
.conv-avatar-wrap img,
.conv-avatar-img { object-fit: cover; display: block; }
.conv-avatar-fallback {
    display: grid; place-items: center;
    font-weight: 700; font-size: .92rem; color: #fff;
    background: linear-gradient(145deg, #38bdf8, #0ea5e9);
}
.conv-avatar-fallback.hidden { display: none !important; }
.conv-peer-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-peer-name {
    font-size: 1.02rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    letter-spacing: -.02em; line-height: 1.2;
}
.conv-peer-status {
    display: inline-flex; align-items: center;
    line-height: 1; min-width: 0; min-height: 12px;
}
.conv-peer-status.hidden { display: none !important; }
.conv-peer-status .peer-signal { height: 11px; }
.conv-peer-status .peer-signal__bar:nth-child(1) { height: 3px; }
.conv-peer-status .peer-signal__bar:nth-child(2) { height: 5px; }
.conv-peer-status .peer-signal__bar:nth-child(3) { height: 7px; }
.conv-peer-status .peer-signal__bar:nth-child(4) { height: 9px; }
.conv-actions {
    display: flex; align-items: center; gap: 0;
    flex-shrink: 0; padding-right: 4px;
}
.conv-action-btn {
    width: 44px; height: 44px; border: none; border-radius: 50%;
    background: transparent; color: var(--accent); font-size: 1.08rem;
    display: grid; place-items: center;
}
.conv-action-btn:active { background: var(--bg-elevated); }

.msg-stream {
    flex: 1; overflow-y: auto; padding: 8px 12px 12px;
    display: flex; flex-direction: column; gap: 2px;
    -webkit-overflow-scrolling: touch; min-height: 0;
    background: #fff;
}
.msg-date {
    align-self: center; font-size: 0.72rem; color: var(--text-muted);
    padding: 4px 0; margin: 12px 0 8px; font-weight: 500;
}
.bubble-wrap {
    display: flex; flex-direction: column; max-width: 78%; margin-bottom: 1px;
    transition: transform .15s ease-out;
    touch-action: pan-y;
    position: relative;
}
.bubble-wrap.out { align-self: flex-end; align-items: flex-end; }
.bubble-wrap.in { align-self: flex-start; align-items: flex-start; }
.bubble-wrap.is-swiping { transition: none; }
.bubble-reply-hint {
    position: absolute; left: -6px; top: 50%;
    width: 28px; height: 28px; margin-top: -14px;
    display: grid; place-items: center;
    border-radius: 50%; background: #e0f2fe; color: var(--accent);
    font-size: .72rem; pointer-events: none;
    opacity: calc(var(--swipe-op, 0) * .95);
    transform: translateX(calc((1 - var(--swipe-op, 0)) * -10px)) scale(calc(.7 + var(--swipe-op, 0) * .3));
    transition: opacity .12s ease, transform .12s ease;
}
.bubble-wrap.is-swiping .bubble-reply-hint { transition: none; }
.bubble-wrap.msg-highlight { animation: msg-flash .9s ease; }
@keyframes msg-flash {
    0%, 100% { background: transparent; }
    35% { background: rgba(14, 165, 233, .14); border-radius: 12px; }
}
.bubble-stack { display: flex; flex-direction: column; gap: 0; max-width: 100%; }
.bubble-quote {
    display: flex; flex-direction: column; gap: 2px; width: 100%;
    margin: 0 0 4px; padding: 6px 10px 6px 12px; border: none; border-radius: 10px;
    text-align: left; cursor: pointer; position: relative; overflow: hidden;
}
.bubble-quote::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--accent); border-radius: 3px 0 0 3px;
}
.bubble-quote.in { background: rgba(15, 23, 42, .06); color: var(--text); }
.bubble-quote.out { background: rgba(255, 255, 255, .22); color: #fff; }
.bubble-quote__name { font-size: .72rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.bubble-quote.out .bubble-quote__name { color: #e0f2fe; }
.bubble-quote__text {
    font-size: .8rem; opacity: .88; line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-bar {
    display: flex; align-items: stretch; gap: 10px;
    padding: 8px 12px; background: #f8fafc; border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.reply-bar.hidden { display: none !important; }
.reply-bar__accent { width: 3px; border-radius: 3px; background: var(--accent); flex-shrink: 0; }
.reply-bar__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reply-bar__name { font-size: .78rem; font-weight: 700; color: var(--accent); }
.reply-bar__text {
    font-size: .82rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-bar__close {
    width: 32px; height: 32px; border: none; border-radius: 50%;
    background: transparent; color: var(--text-muted); font-size: 1rem; flex-shrink: 0;
    align-self: center;
}
.bubble {
    padding: 8px 12px; border-radius: 22px; font-size: 0.95rem; line-height: 1.4;
    word-wrap: break-word; border: none;
    font-family: Inter, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.bubble.in { background: var(--bubble-in); color: var(--text); }
.bubble.out { background: var(--bubble-out); color: #fff; }
.bubble-meta { display: flex; gap: 4px; align-items: center; margin-top: 2px; padding: 0 6px; }
.bubble-time { font-size: 0.65rem; color: var(--text-muted); }
.bubble-wrap.out .bubble-time { color: var(--text-muted); }
.bubble-check { font-size: 0.6rem; color: var(--accent); }
.bubble.sys {
    align-self: center; background: transparent; color: var(--text-muted);
    font-size: 0.78rem; padding: 6px 0; margin: 6px 0;
    text-align: center; border: none;
}
.bubble-wrap.call-card { max-width: min(78%, 240px); margin-bottom: 3px; }
.call-card__bubble {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15,23,42,.05);
    border: 1px solid rgba(15,23,42,.06);
}
.call-card__bubble.in {
    background: #fff;
    color: var(--text);
}
.call-card__bubble.out {
    background: linear-gradient(145deg, #38bdf8, #0ea5e9);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(14, 165, 233, .28);
}
.call-card__badge {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-size: 0.78rem;
}
.call-card__badge--in { background: #ecfdf5; color: #059669; }
.call-card__badge--out { background: rgba(255,255,255,.2); color: #fff; }
.call-card__badge--missed { background: #fee2e2; color: #dc2626; }
.call-card__text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.call-card__title {
    font-size: 0.8rem; font-weight: 700; line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-card__sub {
    font-size: 0.68rem; font-weight: 500; line-height: 1.2; opacity: .8;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-card__bubble.out .call-card__sub { opacity: .85; }
.call-card--missed .call-card__bubble.in { border-color: #fecaca; }
.call-card--missed .call-card__bubble.in .call-card__title { color: #dc2626; }
.call-card--missed .call-card__bubble.in .call-card__sub { color: #ef4444; opacity: 1; }
.call-card--missed .call-card__bubble.out {
    background: linear-gradient(145deg, #f87171, #dc2626);
    box-shadow: 0 4px 14px rgba(220,38,38,.22);
}

.compose-btn {
    width: 40px; height: 40px; border: none; border-radius: 50%;
    background: transparent; color: var(--text-muted); font-size: 1.15rem; flex-shrink: 0;
}
.compose-btn:active { background: var(--bg-elevated); color: var(--accent); }
.compose-btn.recording, .voice-note-btn.recording {
    background: #fef2f2; color: #dc2626;
    animation: voice-pulse 1s ease-in-out infinite;
}
@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.35); }
    50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
.voice-recording-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 56px;
}
.voice-recording-bar.hidden { display: none !important; }
.msg-compose.is-recording { display: none; }
.conv-active.is-voice-recording .msg-stream { padding-bottom: 4px; }
.voice-rec-cancel {
    width: 42px; height: 42px; border: none; border-radius: 50%;
    background: #fee2e2; color: #dc2626; font-size: 1rem; flex-shrink: 0;
    display: grid; place-items: center;
}
.voice-rec-cancel:active { background: #fecaca; }
.voice-rec-center {
    display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
    background: #f8fafc; border-radius: 22px; padding: 8px 14px;
}
.voice-rec-dot {
    width: 10px; height: 10px; border-radius: 50%; background: #dc2626;
    animation: voice-blink 1s ease-in-out infinite; flex-shrink: 0;
}
@keyframes voice-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.voice-rec-time {
    font-weight: 700; font-variant-numeric: tabular-nums; color: #dc2626;
    font-size: 1rem; min-width: 2.8em;
}
.voice-rec-hint {
    font-size: .8rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; min-width: 0;
}
.voice-rec-send {
    width: 44px; height: 44px; border: none; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 1.05rem; flex-shrink: 0;
    display: grid; place-items: center;
    box-shadow: 0 4px 14px rgba(91,76,219,.35);
}
.voice-rec-send:active { transform: scale(.96); }

.msg-compose {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: #fff; flex-shrink: 0; border-top: 1px solid var(--border);
    position: sticky; bottom: 0; z-index: 4;
}
.compose-field {
    flex: 1; display: flex; align-items: center; gap: 4px;
    background: var(--bg-elevated); border-radius: 22px; padding: 0 4px 0 14px; min-width: 0;
}
.compose-field input {
    flex: 1; border: none; background: transparent;
    color: var(--text); padding: 10px 0; font-size: 1rem; outline: none; min-width: 0;
}
.compose-inline-btn {
    width: 34px; height: 34px; border: none; border-radius: 50%;
    background: transparent; color: var(--text-muted); font-size: 1.15rem; flex-shrink: 0;
}
.compose-camera { color: var(--text); font-size: 1.25rem; }
.compose-actions-slot {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}
.compose-actions-slot .compose-btn,
.compose-actions-slot .send-btn {
    position: absolute;
    inset: 0;
    margin: 0;
}
.compose-actions-slot .send-btn {
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
}
.send-btn {
    width: 36px; height: 36px; border: none; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 0.9rem; flex-shrink: 0;
}

/* Emoji & stickers */
.emoji-panel {
    background: var(--bg-panel); border-top: 1px solid var(--border);
    max-height: 220px; display: flex; flex-direction: column;
    flex-shrink: 0; z-index: 20; position: relative;
}
.emoji-panel:not(.hidden) { display: flex !important; }
.emoji-tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.emoji-tab {
    border: none; background: var(--bg-elevated); border-radius: 10px;
    padding: 6px 14px; font-size: 1.1rem; cursor: pointer;
}
.emoji-tab.active { background: var(--accent-soft); }
.emoji-grid, .sticker-grid {
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
    padding: 8px; overflow-y: auto; flex: 1;
}
.emoji-grid button, .sticker-grid button {
    border: none; background: transparent; font-size: 1.45rem;
    padding: 6px; border-radius: 8px; cursor: pointer; line-height: 1;
}
.emoji-grid button:active, .sticker-grid button:active { background: var(--bg-hover); }
.sticker-grid button { font-size: 2rem; }

/* Media messages */
.bubble.media-open,
.bubble.media-video {
    padding: 0; overflow: hidden; max-width: min(72vw, 280px);
    background: transparent !important; border: none !important;
}
.bubble.media-open {
    display: block; cursor: pointer; text-align: left;
}
.bubble.media-open img,
.bubble.media-video video {
    display: block; width: 100%; border-radius: 18px;
    max-height: 360px; object-fit: cover;
}
.bubble-wrap.out .bubble.media-open img,
.bubble-wrap.out .bubble.media-video video { border-bottom-right-radius: 4px; }
.bubble-wrap.in .bubble.media-open img,
.bubble-wrap.in .bubble.media-video video { border-bottom-left-radius: 4px; }
.bubble.media-open:active img { opacity: .92; }
.bubble.sticker { background: transparent !important; font-size: 3.5rem; padding: 4px; line-height: 1; }
/* Voice notes — WhatsApp-style waveform bubble */
.voice-note {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: min(72vw, 260px);
    max-width: min(78vw, 300px);
    padding: 10px 14px 10px 10px;
    border-radius: 22px;
    border: none;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(30, 111, 217, .22);
}
.voice-note.out {
    background: linear-gradient(90deg, #5eb3ff 0%, #2f8ef0 45%, #1e6fd9 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.voice-note.in {
    background: linear-gradient(90deg, #6ec0ff 0%, #3d96f2 50%, #2478db 100%);
    color: #fff;
    border-bottom-left-radius: 6px;
}
.voice-note.out::after,
.voice-note.in::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 0;
    height: 0;
    border: 7px solid transparent;
}
.voice-note.out::after {
    right: -4px;
    border-left-color: #1e6fd9;
    border-bottom: none;
}
.voice-note.in::after {
    left: -4px;
    border-right-color: #2478db;
    border-bottom: none;
}
.voice-note__audio {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}
.voice-note__play {
    width: 38px;
    height: 38px;
    border: 2px solid rgba(255, 255, 255, .92);
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: .82rem;
    padding: 0;
    padding-left: 2px;
    z-index: 1;
}
.voice-note.is-playing .voice-note__play {
    padding-left: 0;
}
.voice-note__play:active { transform: scale(.94); }
.voice-note__play:disabled { opacity: .65; }
.voice-note__wave {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    height: 32px;
    min-width: 0;
    z-index: 1;
}
.voice-note__bar {
    flex: 1;
    max-width: 3px;
    min-width: 2px;
    height: var(--bar-h, 50%);
    border-radius: 2px;
    background: rgba(255, 255, 255, .32);
    align-self: center;
    transition: background .08s linear;
}
.voice-note__bar.is-played {
    background: rgba(255, 255, 255, .98);
}
.voice-note.media-pending .voice-note__wave { opacity: .55; }
.voice-note.media-pending .media-pending__overlay {
    border-radius: 22px;
}
.bubble.file-link {
    display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
}
.bubble.file-link i { font-size: 1.5rem; color: var(--accent); }
.media-stack { display: flex; flex-direction: column; gap: 2px; max-width: min(72vw, 280px); }
.media-stack .media-caption-bubble { margin-top: 0; border-top-left-radius: 6px; border-top-right-radius: 6px; }
.media-stack .media-open + .media-caption-bubble { border-top-left-radius: 6px; border-top-right-radius: 6px; }
.bubble-wrap.out .media-stack .media-open img { border-bottom-right-radius: 6px; }
.bubble-wrap.out .media-stack:has(.media-caption-bubble) .media-open img { border-bottom-right-radius: 6px; }
.bubble-wrap.out .media-stack:not(:has(.media-caption-bubble)) .media-open img { border-bottom-right-radius: 4px; }
.media-pending__frame { position: relative; overflow: hidden; padding: 0 !important; }
.media-pending__overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px;
    background: rgba(15, 23, 42, .42); color: #fff;
    font-size: .78rem; font-weight: 600; pointer-events: none;
}
.media-pending__overlay i { font-size: 1.35rem; }
.media-pending__overlay--failed { background: rgba(185, 28, 28, .55); }
.media-pending--failed .bubble.media-open img,
.media-pending--failed .bubble.media-video video { opacity: .72; }
.bubble.media-file-pending {
    display: flex; align-items: center; gap: 10px; min-width: 160px;
}
.bubble.media-file-pending i { font-size: 1.1rem; flex-shrink: 0; }
.bubble.media-file-pending.media-pending--failed { background: #fef2f2 !important; color: #b91c1c !important; }
.bubble-wrap.out .bubble.media-file-pending.media-pending--failed { background: #fee2e2 !important; color: #991b1b !important; }

/* Full-screen image viewer */
.lightbox {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,.95);
    display: flex; align-items: center; justify-content: center;
    padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}
.lightbox.hidden { display: none !important; }
body.lightbox-open { overflow: hidden; }
.lightbox img {
    max-width: 100%; max-height: 100%; object-fit: contain;
    border-radius: 4px; user-select: none;
}
.lightbox-close {
    position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px;
    width: 40px; height: 40px; border: none; border-radius: 50%;
    background: rgba(255,255,255,.15); color: #fff; font-size: 1.2rem; z-index: 2;
}

/* Floating dock nav */
.mobile-nav {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 0 20px calc(10px + env(safe-area-inset-bottom));
    pointer-events: none;
}
.dock-shell {
    pointer-events: auto;
    display: flex; align-items: center; justify-content: space-around;
    height: var(--dock-h);
    padding: 0 8px;
    border-radius: 22px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,.65);
    box-shadow: 0 8px 32px rgba(15,23,42,.14), 0 2px 8px rgba(15,23,42,.06);
}
.dock-btn {
    position: relative; flex: 1; max-width: 72px; height: 46px;
    border: none; background: transparent; color: #9ca3af;
    display: grid; place-items: center; border-radius: 16px;
    transition: color .2s, background .2s, transform .12s;
}
.dock-btn__icon { font-size: 1.28rem; line-height: 1; }
.dock-btn__dot {
    position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%;
    background: var(--accent); opacity: 0; transform: scale(.5);
    transition: opacity .2s, transform .2s;
}
.dock-btn.active {
    color: var(--accent); background: var(--accent-soft);
}
.dock-btn.active .dock-btn__dot {
    opacity: 1; transform: scale(1);
}
.dock-btn:active { transform: scale(.94); }

/* New chat screen */
.compose-overlay {
    position: fixed; inset: 0; z-index: 120;
    background: var(--bg-deep);
    display: flex; flex-direction: column;
}
.compose-overlay.hidden { display: none !important; }
.compose-screen {
    flex: 1; display: flex; flex-direction: column; min-height: 0;
    background: var(--bg-panel);
}
.compose-head {
    padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
}
.compose-head__row {
    display: flex; align-items: center; gap: 8px; min-height: 44px;
}
.compose-back {
    width: 40px; height: 40px; border: none; border-radius: 50%;
    background: transparent; color: var(--text);
    display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0;
}
.compose-back:active { background: var(--bg-hover); }
.compose-head h2 {
    flex: 1; min-width: 0; margin: 0;
    font-size: 1.12rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2;
}
.compose-segment {
    display: flex; gap: 4px; margin-top: 12px;
    padding: 3px; border-radius: 12px; background: var(--bg-elevated);
}
.compose-segment__btn {
    flex: 1; border: none; border-radius: 11px; padding: 9px 12px;
    background: transparent; color: var(--text-muted);
    font-size: .88rem; font-weight: 700; cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s;
}
.compose-segment__btn.active {
    background: var(--bg-panel); color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.compose-group-panel { padding: 12px 16px 0; }
.compose-input {
    width: 100%; padding: 12px 14px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--bg-deep);
    font-size: 1rem; outline: none;
}
.compose-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,76,219,.12); }
.compose-search {
    display: flex; align-items: center; gap: 10px;
    margin: 12px 16px 4px; padding: 0 14px; height: 44px;
    border-radius: 12px; background: var(--bg-elevated); border: none;
}
.compose-search:focus-within {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,76,219,.1);
}
.compose-search i { color: var(--text-muted); font-size: .95rem; flex-shrink: 0; }
.compose-search__input {
    flex: 1; border: none; background: transparent; font-size: 1rem;
    color: var(--text); outline: none; min-width: 0;
}
.compose-results {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 4px 0 calc(16px + env(safe-area-inset-bottom));
}
.compose-results .person-row {
    padding: 10px 16px; border-radius: 0;
}
.compose-results .person-row:active { background: var(--bg-hover); }
.list-hint--error { color: #e53935; }
.compose-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border); background: var(--bg-panel);
}
.compose-create-btn {
    width: 100%; border: none; border-radius: 14px; padding: 14px;
    background: var(--accent); color: #fff; font-size: 1rem; font-weight: 700;
    box-shadow: 0 8px 24px rgba(91,76,219,.28);
}
.compose-create-btn:active { background: var(--accent-hover); }
.search-input {
    margin: 10px 12px; padding: 11px 14px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--bg-elevated);
    color: var(--text); font-size: 1rem; outline: none;
}
.person-row .meta span { font-size: 0.82rem; color: var(--text-muted); }
.group-selected {
    display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 4px; min-height: 36px;
}
.group-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent-soft); color: var(--accent);
    border-radius: 999px; padding: 6px 10px; font-size: 0.82rem; font-weight: 600;
}
.group-chip button {
    border: none; background: transparent; color: inherit; font-size: 1rem;
    line-height: 1; cursor: pointer; padding: 0;
}
.person-row.person-add { padding-right: 48px; position: relative; }
.person-add-btn {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; border-radius: 50%; border: none;
    background: var(--accent); color: #fff; cursor: pointer;
}
.person-add-btn.person-remove-btn {
    background: #fef2f2; color: #dc2626;
}
.person-add-btn.person-remove-btn:active { background: #fee2e2; }
.person-caller-id .peer-signal { display: inline-flex; margin-left: 8px; vertical-align: middle; }
.list-hint { padding: 24px; text-align: center; color: var(--text-muted); font-size: .9rem; }

/* Incoming call */
.overlay-incoming {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: stretch; justify-content: center;
}
.overlay-incoming.hidden { display: none !important; }
.incoming-bg {
    position: absolute; inset: 0;
    background: linear-gradient(165deg, #1e1b4b 0%, #312e81 40%, #4c1d95 100%);
}
.incoming-screen {
    position: relative; z-index: 1; width: 100%; max-width: 420px;
    display: flex; flex-direction: column; align-items: center;
    padding: calc(28px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom));
    color: #fff;
}
.incoming-top { text-align: center; margin-bottom: 8px; }
.incoming-type {
    font-size: .88rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .12em; opacity: .75;
}
.incoming-caller-id {
    margin-top: 4px; font-size: .85rem; letter-spacing: .1em; opacity: .55;
    font-family: ui-monospace, monospace;
}
.incoming-avatar-stage {
    position: relative; width: 200px; height: 200px;
    display: grid; place-items: center; margin: 24px 0 20px;
}
.incoming-ring {
    position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.25);
    animation: inc-ring 2.4s ease-out infinite;
}
.incoming-ring.r1 { width: 140px; height: 140px; }
.incoming-ring.r2 { width: 170px; height: 170px; animation-delay: .4s; }
.incoming-ring.r3 { width: 200px; height: 200px; animation-delay: .8s; }
@keyframes inc-ring {
    0% { transform: scale(.85); opacity: .7; }
    100% { transform: scale(1.15); opacity: 0; }
}
.incoming-avatar-wrap {
    position: relative; width: 120px; height: 120px; z-index: 2;
}
.incoming-avatar-wrap img {
    width: 120px; height: 120px; border-radius: 50%; object-fit: cover;
    border: 3px solid rgba(255,255,255,.4); box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.incoming-avatar-fb {
    width: 120px; height: 120px; border-radius: 50%;
    display: grid; place-items: center; font-size: 2.5rem; font-weight: 700; color: #fff;
    border: 3px solid rgba(255,255,255,.4); box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.incoming-name {
    font-size: 1.85rem; font-weight: 700; letter-spacing: -.03em;
    text-align: center; margin-bottom: auto;
}
.incoming-actions {
    display: flex; justify-content: center; gap: 56px; width: 100%; margin-top: 32px;
}
.incoming-act {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    border: none; background: none; color: #fff; cursor: pointer;
}
.incoming-act i {
    width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
    font-size: 1.4rem; color: #fff; transition: transform .12s;
}
.incoming-act:active i { transform: scale(.9); }
.incoming-act.decline i { background: #ef4444; box-shadow: 0 8px 24px rgba(239,68,68,.45); }
.incoming-act.answer i { background: #22c55e; box-shadow: 0 8px 24px rgba(34,197,94,.45); }
.incoming-act span { font-size: .8rem; font-weight: 600; opacity: .85; }
.overlay-incoming.is-video .incoming-act.answer i { background: #3b82f6; box-shadow: 0 8px 24px rgba(59,130,246,.45); }

.overlay-incoming.is-video .incoming-bg {
    background: linear-gradient(to bottom, rgba(15,23,42,.55), rgba(15,23,42,.82));
}
.overlay-incoming.is-video .incoming-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    transform: scaleX(-1);
}
.overlay-incoming.is-video .incoming-preview.hidden { display: none !important; }
.overlay-incoming.is-video .incoming-screen {
    z-index: 2;
    max-width: none;
    justify-content: flex-end;
    background: linear-gradient(to top, rgba(0,0,0,.82) 0%, rgba(0,0,0,.35) 42%, transparent 68%);
}
.overlay-incoming.is-video .incoming-avatar-stage.hidden { display: none !important; }
.overlay-incoming.is-video .incoming-name {
    margin-bottom: 8px;
    text-shadow: 0 2px 12px rgba(0,0,0,.65);
}
.overlay-incoming.is-video .incoming-actions {
    margin-top: 16px;
    margin-bottom: 8px;
}
.overlay-incoming.is-video .incoming-act i {
    animation: incoming-btn-ring 1.35s ease-in-out infinite;
}
.overlay-incoming.is-video .incoming-act.decline i { animation-delay: 0s; }
.overlay-incoming.is-video .incoming-act.answer i { animation-delay: .35s; }
@keyframes incoming-btn-ring {
    0%, 100% { transform: scale(1); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
    50% { transform: scale(1.08); box-shadow: 0 12px 32px rgba(255,255,255,.22); }
}

.incoming-call-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 210;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    color: #fff;
    box-shadow: 0 4px 16px rgba(14, 165, 233, .35);
}
html.android-app .incoming-call-bar {
    padding-top: calc(10px + var(--inset-top));
}
.incoming-call-bar.hidden { display: none !important; }
.incoming-call-bar__info {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.incoming-call-bar__info strong {
    font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.incoming-call-bar__info span { font-size: .75rem; opacity: .92; }
.incoming-call-bar__actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.incoming-bar-act {
    width: 38px; height: 38px; border: none; border-radius: 50%;
    display: grid; place-items: center; color: #fff; font-size: 1rem; cursor: pointer;
}
.incoming-bar-act.decline { background: #ef4444; }
.incoming-bar-act.answer { background: #22c55e; }
html.has-incoming-call-bar .app-root { padding-top: 56px; }
html.has-incoming-call-bar.has-active-call-bar .app-root { padding-top: 108px; }

.active-call-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
    border: none; background: linear-gradient(135deg, #15803d, #16a34a);
    color: #fff; text-align: left; cursor: pointer;
    box-shadow: 0 4px 16px rgba(22,163,74,.35);
}
.active-call-bar.hidden { display: none !important; }
.active-call-bar__pulse {
    width: 10px; height: 10px; border-radius: 50%; background: #fff;
    animation: active-call-pulse 1.2s ease-in-out infinite; flex-shrink: 0;
}
@keyframes active-call-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .5; transform: scale(.85); }
}
.active-call-bar__text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.active-call-bar__text strong { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-call-bar__text span { font-size: .75rem; opacity: .9; }
.active-call-bar__icon { font-size: 1.1rem; flex-shrink: 0; }
html.has-active-call-bar .app-root { padding-top: 52px; }
html.has-incoming-call-bar.has-active-call-bar .active-call-bar {
    top: 56px;
    padding-top: 10px;
}
html.android-app.has-incoming-call-bar.has-active-call-bar .active-call-bar {
    top: calc(46px + var(--inset-top));
}
html.has-active-call-bar .panel-conversation .conv-head { margin-top: 0; }
html.has-incoming-call-bar .panel-conversation .conv-head { margin-top: 0; }

/* Desktop */
@media (min-width: 769px) {
    .view-main { padding-bottom: 0; }
    .tab-panel { display: none; width: auto; }
    .tab-panel.active { display: flex !important; }
    .mobile-nav { display: none !important; }
    .conv-back { display: none !important; }
    .conv-peer { padding-left: 16px; }
    .panel-conversation { display: flex !important; }
    .conv-empty { display: grid !important; }
    .panel-side { width: 400px; flex-shrink: 0; }
    .scroll-list { padding-bottom: 0; }
}

/* Mobile */
@media (max-width: 768px) {
    .view-main {
        flex-direction: column;
        padding-bottom: calc(var(--mob-nav-h) + env(safe-area-inset-bottom));
    }
    html.android-app .view-main {
        padding-bottom: var(--mob-nav-h);
    }
    .mobile-nav { display: block; }
    .tab-panel { flex: 1; min-height: 0; }
    .tab-panel.hidden { display: none !important; }
    .panel-side { width: 100%; border-right: none; height: 100%; }

    .panel-conversation {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0;
        bottom: calc(var(--mob-nav-h) + env(safe-area-inset-bottom));
        z-index: 45;
    }
    html.android-app .panel-conversation {
        bottom: var(--mob-nav-h);
    }
    .panel-conversation.mobile-open {
        display: flex;
        bottom: 0;
        z-index: 55;
    }
    html.android-app .panel-conversation.mobile-open {
        bottom: 0;
    }
    html.keyboard-open .panel-conversation.mobile-open {
        top: var(--vv-top, 0px);
        left: var(--vv-left, 0px);
        width: var(--vv-width, 100%);
        height: var(--vv-height, 100%);
        max-height: var(--vv-height, 100%);
        bottom: auto;
        right: auto;
    }
    html.android-app.keyboard-open .panel-conversation.mobile-open {
        top: var(--vv-top, 0px);
        left: 0;
        right: 0;
        width: 100%;
        height: var(--vv-height, calc(100% - var(--keyboard-inset, 0px)));
        max-height: var(--vv-height, calc(100% - var(--keyboard-inset, 0px)));
        bottom: auto;
    }
    html.keyboard-open .reply-bar,
    html.keyboard-open .msg-compose,
    html.keyboard-open .voice-recording-bar {
        flex-shrink: 0;
    }
    html.keyboard-open .msg-compose,
    html.keyboard-open .voice-recording-bar {
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
    html.android-app.keyboard-open .msg-compose,
    html.android-app.keyboard-open .voice-recording-bar {
        padding-bottom: 8px;
    }
    html.android-app.keyboard-open .msg-stream {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
    html.keyboard-open .conv-active {
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }
    .view-main.in-chat .mobile-nav { display: none; }
    .conv-back { display: grid; }
    .conv-empty { display: none; }

    .scroll-list {
        padding-bottom: calc(var(--mob-nav-h) + 8px);
    }
    .panel-account .account-page {
        padding-bottom: calc(var(--mob-nav-h) + 20px);
    }
}

.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: linear-gradient(165deg, #4c1d95 0%, #312e81 35%, #1e1b4b 70%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.call-overlay.hidden { display: none !important; }
.call-overlay-splash {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: calc(16px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
    color: #fff;
    gap: 10px;
}
.call-overlay-splash.hidden { display: none !important; }
.call-overlay-splash__type {
    margin: 0;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: rgba(255,255,255,.55);
}
.call-overlay-splash__avatar {
    margin: 10px 0 6px;
    width: min(52vw, 220px);
    height: min(52vw, 220px);
}
.call-overlay-splash__avatar.incoming-avatar-wrap img,
.call-overlay-splash__avatar.incoming-avatar-wrap .incoming-avatar-fb {
    width: min(52vw, 220px);
    height: min(52vw, 220px);
    font-size: 3rem;
}
.call-overlay-splash__name {
    margin: 0;
    font-size: clamp(1.6rem, 6vw, 2.2rem);
    font-weight: 800;
    text-align: center;
    line-height: 1.15;
}
.call-overlay-splash__status {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255,255,255,.72);
    animation: splash-status-pulse 1.6s ease-in-out infinite;
}
@keyframes splash-status-pulse {
    0%, 100% { opacity: .55; }
    50% { opacity: 1; }
}
.call-overlay-splash__cancel {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    padding: 0;
}
.call-overlay-splash__cancel i {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #ef4444;
    font-size: 1.35rem;
    box-shadow: 0 8px 28px rgba(239,68,68,.45);
}
.call-overlay-splash__cancel span { font-size: .85rem; font-weight: 600; opacity: .9; }
.call-frame {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: #0f172a;
}
.call-frame.call-frame--hidden { visibility: hidden; pointer-events: none; }
html.in-call-overlay .active-call-bar { display: none !important; }
html.in-call-overlay.has-active-call-bar .app-root { padding-top: 0 !important; }
html.in-call-overlay #view-boot { display: none !important; }
