/* --- NexaLine premium glass reference layer --- */
:root {
    --bg-dark: #05070a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --accent-blue: #00f2ff;
    --accent-green: #00d96f;
    --accent-pink: #ff00b8;
    --text-main: #e0e0e0;
    --radius: 24px;
}

html,
body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background:
        radial-gradient(circle at 18% 0%, rgba(0, 242, 255, 0.1), transparent 28%),
        radial-gradient(circle at 100% 10%, rgba(255, 0, 184, 0.09), transparent 30%),
        #05070a;
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
}

.glass-card,
.card,
.message,
.auth-card,
.qr-login-card,
.modal-panel,
.settings-box,
.chat-item,
.contact-row,
.call-row,
.profile-card,
.vault-card,
.ai-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(130%);
    -webkit-backdrop-filter: blur(20px) saturate(130%);
    border: var(--glass-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: #fff;
}

.nav-bar,
.mobile-nav {
    position: fixed;
    left: 15px;
    right: 15px;
    bottom: max(14px, env(safe-area-inset-bottom));
    min-height: 70px;
    background: rgba(10, 12, 16, 0.82);
    backdrop-filter: blur(30px) saturate(145%);
    -webkit-backdrop-filter: blur(30px) saturate(145%);
    border: var(--glass-border);
    border-radius: 40px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.48);
}

.nav-item,
.nav-tab {
    color: rgba(224, 224, 224, 0.62);
    transition: color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.nav-item.active,
.nav-tab.active {
    color: var(--accent-blue);
    text-shadow: 0 0 14px rgba(0, 242, 255, 0.45);
}

.ai-trigger,
.voice-btn,
.accent-glow {
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.25), 0 0 28px rgba(255, 0, 184, 0.12);
}

.ai-trigger {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    display: flex;
    justify-content: center;
    align-items: center;
    color: #000;
}

/* --- static/theme.css --- */
:root {
    --bg-dark: #05070a;
    --glass-panel: rgba(255, 255, 255, 0.05);
    --glass-panel-strong: rgba(255, 255, 255, 0.085);
    --glass-panel-soft: rgba(255, 255, 255, 0.032);
    --glass-border-color: rgba(255, 255, 255, 0.1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --neon-blue: #00f2ff;
    --neon-pink: #ff00b8;
    --neon-purple: #704cff;
    --success: #00d96f;
    --danger: #ff4d5e;
    --text-main: #ffffff;
    --text-soft: rgba(255, 255, 255, 0.72);
    --text-muted: rgba(255, 255, 255, 0.48);
    --radius-lg: 32px;
    --radius-md: 22px;
    --radius-sm: 16px;
    --shadow-deep: 0 8px 32px rgba(0, 0, 0, 0.6);
    --app-height: 100dvh;
    --viewport-top: 0px;
    --viewport-left: 0px;
    --viewport-width: 100vw;
    --safe-top-fallback: 0px;
    --safe-bottom-fallback: 0px;
    --safe-top: max(env(safe-area-inset-top, 0px), var(--safe-top-fallback));
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-bottom-fallback));
    --safe-left: env(safe-area-inset-left, 0px);
    --keyboard-inset: 0px;
    --composer-height: 64px;
    --sidebar-width: min(430px, 36vw);
    --ease: cubic-bezier(.2, .88, .22, 1);
}

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

button,
[role="button"],
a,
label,
input[type="button"],
input[type="submit"] {
    touch-action: manipulation;
}

html,
body {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    overflow: hidden;
}

body {
    background: radial-gradient(circle at top, #151920, #05070a);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    overscroll-behavior: none;
}

html.nexaline-native-android *,
html.nexaline-native-android *::before,
html.nexaline-native-android *::after {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 860px) {
    html.nexaline-native-android .glass-card,
    html.nexaline-native-android .modal-panel,
    html.nexaline-native-android .modal-box,
    html.nexaline-native-android .settings-panel,
    html.nexaline-native-android .settings-box,
    html.nexaline-native-android .composer,
    html.nexaline-native-android .nav-tabs,
    html.nexaline-native-android .mobile-nav,
    html.nexaline-native-android .chat-top,
    html.nexaline-native-android .attachment-menu,
    html.nexaline-native-android .bottom-sheet,
    html.nexaline-native-android .account-switcher-panel,
    html.nexaline-native-android .toast {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    html.nexaline-native-android .glass-card,
    html.nexaline-native-android .chat-item,
    html.nexaline-native-android .contact-row,
    html.nexaline-native-android .call-row,
    html.nexaline-native-android .message-bubble,
    html.nexaline-native-android .bubble {
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
    }

    html.nexaline-native-android .nav-tabs,
    html.nexaline-native-android .mobile-nav,
    html.nexaline-native-android .composer,
    html.nexaline-native-android .chat-top {
        background-color: rgba(12, 17, 27, 0.98);
    }

    html.nexaline-native-android .chat-list,
    html.nexaline-native-android .contact-list,
    html.nexaline-native-android .messages {
        -webkit-overflow-scrolling: touch;
        contain: layout paint;
    }
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
    color: inherit;
}

input,
textarea,
select {
    width: 100%;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
    border: var(--glass-border);
    border-radius: var(--radius-sm);
    outline: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

img,
video {
    max-width: 100%;
}

.hidden {
    display: none;
}

.glass-card {
    background: var(--glass-panel);
    backdrop-filter: blur(25px) saturate(130%);
    -webkit-backdrop-filter: blur(25px) saturate(130%);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 15px;
    box-shadow: var(--shadow-deep);
}

.accent-glow,
.active,
.selected,
[aria-selected="true"],
[aria-pressed="true"] {
    border-color: rgba(0, 242, 255, 0.42);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.22), var(--shadow-deep);
}

.nav-bar,
.nav-tabs,
.mobile-nav {
    position: fixed;
    bottom: 20px;
    left: 15px;
    right: 15px;
    background: rgba(20, 20, 25, 0.7);
    backdrop-filter: blur(20px) saturate(135%);
    -webkit-backdrop-filter: blur(20px) saturate(135%);
    border: var(--glass-border);
    border-radius: 40px;
    padding: 15px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    box-shadow: var(--shadow-deep);
}

.voice-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 20px var(--neon-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    animation: glow 2s infinite;
}

@keyframes glow {
    0%,
    100% {
        box-shadow: 0 0 15px var(--neon-blue);
    }

    50% {
        box-shadow: 0 0 30px var(--neon-blue);
    }
}

.auth-screen,
.app,
.chat-pane,
.messages,
.section,
.screen,
.page,
.view,
.modal,
.call-panel,
.settings-panel,
.drawer,
.sheet {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.auth-screen {
    min-height: var(--app-height);
    display: grid;
    place-items: center;
    gap: 18px;
    padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.auth-card,
.qr-login-card {
    width: min(440px, calc(100vw - 30px));
}

.brand,
.topbar,
.chat-top,
.qr-login-head,
.identity-row,
.call-info,
.call-actions,
.icon-row,
.section-head,
.modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    justify-content: center;
    text-align: center;
    margin-bottom: 18px;
}

.brand h1 {
    margin: 0;
    font-size: clamp(26px, 6vw, 42px);
}

.brand-subtitle,
.status-line,
.qr-code-meta,
.last-message,
small {
    color: var(--text-muted);
}

.brand-mark,
.avatar,
.transition-mark,
.pane-loader {
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple), var(--neon-pink));
    box-shadow: 0 0 22px rgba(0, 242, 255, 0.22);
}

.brand-mark {
    width: 72px;
    height: 72px;
    border-radius: 24px;
}

.brand-mark img,
.transition-mark img,
.pane-loader img,
.empty-chat-inner img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    color: #fff;
    font-weight: 800;
}

.avatar.avatar-has-custom-gradient {
    background: var(--avatar-user-gradient);
}

.avatar > img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    border-radius: inherit;
}

.avatar.online {
    outline: 2px solid var(--success);
    outline-offset: 2px;
}

.auth-tabs,
.auth-actions,
.filter-row,
.segment-row,
.mini-actions,
.smart-replies {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-tab,
.primary,
.secondary,
.mini-btn,
.icon-btn,
.text-btn,
.nav-tab,
.new-requests-chip,
.new-chat-fab,
.file-pill,
.points-chip,
.account-switcher-button {
    min-height: 42px;
    border-radius: 999px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.07);
    border: var(--glass-border);
    color: var(--text-main);
    transition: transform 160ms var(--ease), border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary,
.new-chat-fab,
.send-btn,
#sendButton {
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple), var(--neon-pink));
    color: #fff;
    box-shadow: 0 0 24px rgba(0, 242, 255, 0.2);
}

.secondary {
    background: rgba(255, 255, 255, 0.045);
}

.danger,
.mini-btn.danger {
    background: linear-gradient(135deg, var(--danger), #a5122a);
}

button:active,
.icon-btn:active,
.nav-tab:active {
    transform: scale(.96);
}

.icon-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-grid;
    place-items: center;
}

.text-btn {
    width: 100%;
    background: transparent;
    border-color: transparent;
    color: var(--neon-blue);
}

.field,
.search-box input,
.composer-input,
#messageInput,
textarea {
    min-height: 46px;
    padding: 12px 14px;
}

.auth-fields {
    display: grid;
    gap: 10px;
}

.account-add-back {
    width: 100%;
    margin-top: 10px;
}

.auth-progress {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin: 12px 0;
}

.auth-progress span {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
}

.app {
    height: var(--app-height);
    max-height: var(--app-height);
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    background: radial-gradient(circle at top, rgba(0, 242, 255, 0.08), transparent 30%), var(--bg-dark);
}

.sidebar {
    position: relative;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    border-right: var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.topbar,
.chat-top {
    min-height: 74px;
    padding: 12px 16px;
    border-bottom: var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.identity {
    min-width: 0;
    flex: 1 1 auto;
}

.identity strong,
#activeTitle,
#meName {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-identity-button {
    min-width: 0;
    min-height: 44px;
    padding: 4px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}

.chat-identity-button:active {
    transform: none;
    opacity: .76;
}

.mobile-brand-title {
    display: none;
    font-weight: 800;
}

.search-box {
    padding: 12px 15px;
}

.nav-tabs {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    margin: 0 15px 12px;
    padding: 8px;
    flex-wrap: wrap;
    border-radius: 28px;
}

.nav-tab {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 92px;
    display: grid;
    justify-items: center;
    gap: 4px;
    font-size: 12px;
}

.nav-icon {
    font-size: 18px;
}

.section-head {
    justify-content: space-between;
    padding: 0 15px 10px;
}

.new-requests-chip {
    min-height: 32px;
    padding: 6px 11px;
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    font-size: 12px;
    font-weight: 720;
}

.section-label {
    font-size: 28px;
    font-weight: 850;
}

.chat-list,
.contact-list,
.story-list,
.scroll-area {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 10px 92px;
}

.chat-item,
.contact-row,
.call-row,
.profile-card,
.vault-card,
.ai-card,
.file-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(100% - 10px);
    margin: 8px 5px;
    color: var(--text-main);
    text-align: left;
}

.chat-item,
.contact-row,
.call-row {
    min-height: 70px;
}

.chat-pane {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    overflow: hidden;
}

.messages {
    min-height: 0;
    overflow-y: auto;
    padding: 18px 18px calc(var(--composer-height) + 30px);
    background:
        radial-gradient(circle at 85% 0%, rgba(255, 0, 184, 0.08), transparent 32%),
        radial-gradient(circle at 15% 100%, rgba(0, 242, 255, 0.06), transparent 30%);
}

.message-row,
.message-wrap {
    display: flex;
    margin: 8px 0;
}

.message-row.mine,
.message-wrap.mine {
    justify-content: flex-end;
}

.bubble,
.message-bubble {
    width: fit-content;
    max-width: min(74%, 640px);
    padding: 10px 14px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.07);
    border: var(--glass-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .24);
    overflow-wrap: anywhere;
}

.mine .bubble,
.mine .message-bubble,
.bubble.mine,
.message-bubble.mine {
    background: linear-gradient(135deg, rgba(0, 242, 255, .28), rgba(112, 76, 255, .34), rgba(255, 0, 184, .30));
}

.composer {
    position: sticky;
    bottom: 0;
    z-index: 40;
    min-height: var(--composer-height);
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
    grid-template-areas: "attach input once action";
    align-items: center;
    gap: 8px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    margin: 0;
    border-radius: 28px 28px 0 0;
    background: rgba(20, 20, 25, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: var(--glass-border);
}

#attachButton {
    grid-area: attach;
}

#emojiButton {
    display: none;
}

#messageInputShell {
    grid-area: input;
    margin: 0;
}

#sendButton {
    grid-area: action;
}

#voiceButton {
    grid-area: action;
}

#viewOnceButton {
    grid-area: once;
}

#locationButton {
    display: none;
}

.composer:not(.has-content) #sendButton {
    display: none;
}

.composer.has-content #voiceButton {
    display: none;
}

#messageInputShell {
    position: relative;
    min-height: 42px;
    padding: 0;
    border-radius: 999px;
}

#messageInput {
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    border-radius: 999px;
    padding: 8px 44px 8px 14px;
    resize: none;
    overflow: hidden;
}

#gifInlineButton {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.attachment-preview-grid,
.media-bundle-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    overflow: hidden;
    border-radius: 14px;
}

.attachment-preview-grid {
    width: 62px;
    height: 48px;
}

.attachment-preview-grid > *,
.media-bundle-cell > img,
.media-bundle-cell > video {
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
}

.attachment-preview-file {
    min-height: 22px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.07);
}

.media-bundle-grid {
    width: min(300px, 70vw);
    aspect-ratio: 1.2;
}

.media-bundle-grid.media-count-1 {
    grid-template-columns: 1fr;
}

.media-bundle-grid.media-count-3 .media-bundle-cell:first-child {
    grid-row: span 2;
}

.media-bundle-cell {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 10px;
}

.view-once-guard {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.compact-share-menu {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.compact-share-menu .attachment-option {
    min-width: 0;
    min-height: 92px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 10px 6px;
    border-radius: 18px;
    text-align: center;
}

.compact-share-menu .attachment-option-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #00f2ff, #704cff 55%, #ff00b8);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
}

.compact-share-menu .attachment-option[data-attachment-tone="media"] .attachment-option-icon {
    color: #5ee7ff;
    background: linear-gradient(145deg, #075985, #2563eb);
    box-shadow: 0 0 22px rgba(56, 189, 248, 0.42);
}

.compact-share-menu .attachment-option[data-attachment-tone="location"] .attachment-option-icon {
    color: #d9ff70;
    background: linear-gradient(145deg, #166534, #22c55e);
    box-shadow: 0 0 22px rgba(74, 222, 128, 0.4);
}

.compact-share-menu .attachment-option[data-attachment-tone="file"] .attachment-option-icon {
    color: #fff1a8;
    background: linear-gradient(145deg, #b45309, #f59e0b);
    box-shadow: 0 0 22px rgba(245, 158, 11, 0.42);
}

.compact-share-menu .attachment-option[data-attachment-tone="once"] .attachment-option-icon {
    color: #ffd2e0;
    background: linear-gradient(145deg, #be123c, #fb3b72);
    box-shadow: 0 0 22px rgba(251, 59, 114, 0.42);
}

.compact-share-menu .attachment-option[data-attachment-tone="ai"] .attachment-option-icon {
    color: #f5ddff;
    background: linear-gradient(145deg, #6d28d9, #d946ef);
    box-shadow: 0 0 22px rgba(217, 70, 239, 0.44);
}

.compact-share-menu .attachment-option[data-attachment-tone="poll"] .attachment-option-icon {
    color: #cbfff7;
    background: linear-gradient(145deg, #0f766e, #14b8a6);
    box-shadow: 0 0 22px rgba(45, 212, 191, 0.4);
}

.compact-share-menu .attachment-option[data-attachment-tone] .attachment-option-icon {
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.compact-share-menu .attachment-option[data-attachment-tone] .nexa-svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
}

.compact-share-menu .attachment-option strong {
    display: block;
    font-size: 12px;
    line-height: 1.2;
}

.share-menu-sheet .modal-box,
.keyboard-sheet .modal-box {
    width: min(560px, 100%);
    max-height: none;
    overflow: visible;
}

.share-menu-sheet .modal-actions,
.keyboard-sheet .modal-actions {
    margin-top: 10px;
}

.smart-replies,
.reply-preview,
.voice-wave,
.attachment-preview,
.emoji-panel {
    grid-column: 1 / -1;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(12px);
}

.modal-panel {
    position: fixed;
    inset: 0;
    z-index: 2800;
    width: 100%;
    max-width: 100vw;
    height: var(--app-height);
    max-height: none;
    display: grid;
    place-items: center;
    margin: 0;
    padding:
        calc(14px + var(--safe-top))
        calc(14px + var(--safe-right))
        calc(14px + var(--safe-bottom))
        calc(14px + var(--safe-left));
    overflow: hidden;
    box-sizing: border-box;
    border: 0;
    border-radius: 0;
    background: rgba(1, 4, 10, 0.42);
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    box-shadow: none;
    animation: modal-backdrop-in 180ms ease both;
}

.modal-panel.hidden {
    display: none;
}

.modal-box {
    width: min(560px, 100%);
    max-height: min(760px, calc(var(--app-height) - var(--safe-top) - var(--safe-bottom) - 28px));
    padding: 18px;
    overflow: auto;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 26px;
    background: rgba(13, 18, 30, 0.88);
    backdrop-filter: blur(26px) saturate(135%);
    -webkit-backdrop-filter: blur(26px) saturate(135%);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.52), 0 0 34px rgba(0, 242, 255, 0.08);
    animation: modal-card-grow 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.modal-head {
    justify-content: space-between;
    margin-bottom: 14px;
}

.modal-body {
    display: grid;
    gap: 12px;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.profile-crop-modal .modal-box {
    width: min(430px, 100%);
    overflow: hidden;
}

.profile-crop-modal .modal-body {
    justify-items: center;
}

.crop-frame {
    position: relative;
    width: min(280px, calc(100vw - 76px));
    aspect-ratio: 1;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
    border: 3px solid rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    background: #05070c;
    box-shadow:
        0 0 0 6px rgba(59, 130, 246, 0.16),
        0 18px 44px rgba(0, 0, 0, 0.42);
    user-select: none;
    -webkit-user-select: none;
}

.crop-frame:active {
    cursor: grabbing;
}

.crop-frame img {
    position: absolute;
    top: 50%;
    left: 50%;
    max-width: none;
    max-height: none;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center;
    will-change: width, height, transform;
}

.crop-controls {
    width: 100%;
    display: grid;
    gap: 10px;
}

.crop-controls label {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 700;
}

.crop-controls input[type="range"] {
    width: 100%;
    min-width: 0;
    accent-color: var(--accent-blue);
}

@media (max-width: 640px) {
    .profile-crop-modal {
        align-items: center;
        padding:
            calc(12px + var(--safe-top))
            14px
            calc(12px + var(--safe-bottom));
    }

    .profile-crop-modal .modal-box {
        max-height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom) - 24px);
        padding: 16px;
        overflow-y: auto;
    }

    .crop-frame {
        width: min(260px, calc(100vw - 76px));
    }
}

@keyframes modal-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-card-grow {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.toast-stack {
    position: fixed;
    left: 50%;
    top: calc(10px + env(safe-area-inset-top));
    bottom: auto;
    z-index: 3000;
    display: grid;
    gap: 8px;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    width: min(420px, calc(100vw - 32px));
    min-height: 54px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    box-sizing: border-box;
    border: 1px solid rgba(239, 68, 68, 0.42);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(34, 18, 26, 0.97), rgba(16, 20, 30, 0.98));
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.46), 0 0 24px rgba(239, 68, 68, 0.12);
    backdrop-filter: blur(20px) saturate(135%);
    -webkit-backdrop-filter: blur(20px) saturate(135%);
    pointer-events: auto;
    touch-action: none;
    transform: translate3d(0, var(--toast-drag-y, 0), 0);
    animation: toast-notification-in 280ms cubic-bezier(0.18, 0.82, 0.22, 1) both;
    will-change: transform, opacity;
}

.toast::before {
    content: "!";
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    margin-right: 10px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.18);
    color: #ff7b7b;
    font-size: 15px;
    font-weight: 900;
}

.toast.toast-dragging {
    animation: none;
    transition: none;
}

.toast:not(.toast-dragging) {
    transition: transform 180ms ease, opacity 180ms ease;
}

.toast.toast-leaving {
    pointer-events: none;
    animation: toast-notification-out 220ms cubic-bezier(0.4, 0, 0.8, 0.2) both;
}

@keyframes toast-notification-in {
    from {
        opacity: 0;
        transform: translate3d(0, calc(-100% - 24px), 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes toast-notification-out {
    from {
        opacity: 1;
        transform: translate3d(0, var(--toast-drag-y, 0), 0);
    }
    to {
        opacity: 0;
        transform: translate3d(0, calc(-100% - 24px), 0);
    }
}

.screen-transition,
.pane-transition,
.empty-chat,
.call-panel {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: grid;
    place-items: center;
    background: rgba(5, 7, 10, .72);
    backdrop-filter: blur(18px);
}

.transition-card,
.empty-chat-inner,
.pane-loader {
    width: min(240px, 70vw);
    min-height: 180px;
    display: grid;
    place-items: center;
    text-align: center;
}

.transition-mark,
.pane-loader,
.empty-chat-inner {
    width: 116px;
    height: 116px;
    border-radius: 36px;
}

.screen-transition:not(.hidden) .transition-card {
    animation: brand-card-arrive 520ms cubic-bezier(.2, .82, .24, 1) both;
}

.screen-transition:not(.hidden) .transition-mark {
    position: relative;
    overflow: visible;
    background: #000;
    border: 1px solid rgba(44, 216, 235, 0.22);
    box-shadow:
        0 0 28px rgba(19, 205, 220, 0.22),
        0 0 56px rgba(44, 105, 255, 0.14);
    animation: brand-logo-breathe 1.45s ease-in-out infinite;
}

.screen-transition:not(.hidden) .transition-mark::before {
    content: "";
    position: absolute;
    inset: -12px;
    z-index: -1;
    border: 1px solid rgba(44, 216, 235, 0.28);
    border-radius: 44px;
    opacity: 0;
    animation: brand-logo-ring 1.45s ease-out infinite;
}

.screen-transition:not(.hidden) .transition-mark img {
    border-radius: 34px;
    animation: brand-logo-shine 1.45s ease-in-out infinite;
}

.screen-transition:not(.hidden) .transition-lines {
    display: none;
}

.screen-transition:not(.hidden) .transition-text {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    letter-spacing: 0.04em;
    animation: brand-text-pulse 1.45s ease-in-out infinite;
}

@keyframes brand-card-arrive {
    from { opacity: 0; transform: translateY(10px) scale(.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes brand-logo-breathe {
    0%, 100% { transform: scale(.96); }
    50% { transform: scale(1.035); }
}

@keyframes brand-logo-ring {
    0% { opacity: .7; transform: scale(.82); }
    75%, 100% { opacity: 0; transform: scale(1.18); }
}

@keyframes brand-logo-shine {
    0%, 100% { filter: brightness(.94) saturate(1.02); }
    50% { filter: brightness(1.14) saturate(1.18); }
}

@keyframes brand-text-pulse {
    0%, 100% { opacity: .58; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .screen-transition:not(.hidden) .transition-card,
    .screen-transition:not(.hidden) .transition-mark,
    .screen-transition:not(.hidden) .transition-mark::before,
    .screen-transition:not(.hidden) .transition-mark img,
    .screen-transition:not(.hidden) .transition-text {
        animation: none;
    }
}

.call-panel {
    z-index: 2200;
}

.call-card {
    width: min(980px, calc(100vw - 24px));
    min-height: min(620px, calc(var(--app-height) - 24px));
}

.video-stage {
    min-height: 360px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #020308;
}

.call-actions {
    justify-content: center;
}

.new-chat-fab {
    position: absolute;
    right: 18px;
    bottom: 106px;
    width: 58px;
    height: 58px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 28px;
}

.account-switcher-menu,
.notification-panel,
.emoji-panel,
.attachment-menu,
.bottom-sheet,
.settings-box {
    background: rgba(20, 20, 25, .82);
    backdrop-filter: blur(22px);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-deep);
}

.scroll-area,
.messages,
.modal-panel,
.chat-list,
.contact-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 242, 255, .45) transparent;
}

@media (max-width: 860px) {
    :root {
        --composer-height: 58px;
    }

    .app {
        position: fixed;
        inset: 0;
        display: block;
        height: var(--app-height);
        max-height: none;
        overflow: hidden;
    }

    .sidebar,
    .chat-pane {
        width: 100vw;
        height: var(--app-height);
        max-width: 100vw;
    }

    .sidebar {
        border-right: 0;
        padding-bottom: 92px;
    }

    .app.chat-open .sidebar {
        display: none;
    }

    .chat-pane {
        display: none;
    }

    .app.chat-open .chat-pane {
        display: grid;
    }

    .app.profile-open .chat-pane {
        animation: profilePaneSlideIn 280ms cubic-bezier(.2, .8, .2, 1);
    }

    .topbar,
    .chat-top {
        min-height: calc(66px + var(--safe-top));
        padding:
            calc(8px + var(--safe-top))
            calc(12px + var(--safe-right))
            10px
            calc(12px + var(--safe-left));
    }

    .ai-head,
    .story-head,
    .settings-head {
        padding-top: calc(10px + var(--safe-top));
        padding-right: calc(12px + var(--safe-right));
        padding-left: calc(12px + var(--safe-left));
    }

    .call-box .video-stage {
        margin-top: calc(8px + var(--safe-top));
    }

    .nav-tabs {
        left: calc(12px + var(--safe-left));
        right: calc(12px + var(--safe-right));
        bottom: max(12px, var(--safe-bottom));
    }

    .mobile-brand-title {
        display: block;
    }

    .icon-row {
        gap: 6px;
    }

    .icon-row .icon-btn {
        width: 38px;
        height: 38px;
    }

    .nav-tabs {
        position: fixed;
        bottom: max(12px, var(--safe-bottom));
        left: calc(12px + var(--safe-left));
        right: calc(12px + var(--safe-right));
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        margin: 0;
        padding: 7px;
        border-radius: 34px;
    }

    .nav-tab {
        width: 100%;
        min-width: 0;
        min-height: 52px;
        padding: 6px 2px;
        font-size: clamp(8px, 2.35vw, 9px);
        border-color: transparent;
        background: transparent;
        box-shadow: none;
    }

    .settings-rail-button,
    .nav-tab[data-section="groups"],
    .nav-tab[data-section="friends"] {
        display: none;
    }

    .nav-tab .nav-label {
        width: 100%;
        overflow: hidden;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-tab .nexa-svg {
        width: 20px;
        height: 20px;
        stroke-width: 1.45;
        transition: fill 180ms ease, stroke-width 180ms ease, transform 180ms ease;
    }

    .nav-tab.active {
        background: rgba(0, 242, 255, 0.1);
        box-shadow: inset 0 0 0 1px rgba(0, 242, 255, 0.14), 0 0 18px rgba(0, 242, 255, 0.1);
    }

    .nav-tab.active .nexa-svg {
        fill: currentColor;
        stroke-width: 1.7;
        transform: translateY(-1px) scale(1.04);
    }

    .section-label {
        font-size: 30px;
    }

    .chat-list,
    .contact-list,
    .story-list,
    .scroll-area {
        padding-bottom: 104px;
    }

    .messages {
        padding: 12px 10px calc(var(--composer-height) + 20px);
    }

    .bubble,
    .message-bubble {
        max-width: min(82vw, 420px);
        border-radius: 20px;
    }

    .composer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: max(var(--keyboard-inset), env(safe-area-inset-bottom));
        grid-template-columns: 35px minmax(0, 1fr) 35px 35px;
        grid-template-areas: "attach input once action";
        gap: 5px;
        min-height: 52px;
        padding: 6px 8px max(6px, env(safe-area-inset-bottom));
        border-radius: 24px 24px 0 0;
    }

    .composer .icon-btn,
    #sendButton,
    #voiceButton,
    #attachButton,
    #viewOnceButton {
        width: 35px;
        height: 35px;
    }

    #messageInputShell,
    #messageInput {
        min-height: 36px;
        height: 36px;
        max-height: 36px;
    }

    #messageInput {
        font-size: 15.5px;
        padding-right: 40px;
    }

    #gifButton {
        width: 25px;
        height: 25px;
        min-height: 25px;
    }
}

@media (min-width: 861px) {
    .mobile-nav {
        display: none;
    }

    .chat-pane {
        display: grid;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms;
        transition-duration: .001ms;
        scroll-behavior: auto;
    }
}

.hidden,
[hidden],
#authScreen.hidden,
#app.hidden,
#screenTransition.hidden,
#paneTransition.hidden,
#emptyChat.hidden,
#callPanel.hidden,
.screen-transition.hidden,
.pane-transition.hidden,
.empty-chat.hidden,
.call-panel.hidden,
.modal.hidden,
.sidebar.hidden,
.chat-pane.hidden,
.chat-list.hidden,
.contact-list.hidden,
.story-list.hidden,
.scroll-area.hidden,
.icon-btn.hidden,
.field.hidden,
.text-btn.hidden,
.primary.hidden,
.secondary.hidden,
.auth-progress.hidden,
.account-switcher-menu.hidden {
    display: none;
}

/* --- PDF iskeleti korunarak premium cam modernizasyon katmani --- */
body :where(div, button) {
    transition: all 0.3s ease;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.nexa-svg {
    width: 1.25em;
    height: 1.25em;
    display: inline-block;
    vertical-align: -0.18em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.35;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-card,
.qr-login-card,
.chat-item,
.contact-item,
.contact-row,
.call-item,
.call-row,
.story-item,
.explore-card,
.profile-card,
.settings-box,
.modal-panel,
.bottom-sheet,
.account-switcher-menu,
.notification-panel,
.message-bubble,
.attachment-option,
.file-pill,
.x-compose-card,
.x-feed-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px) saturate(135%);
    -webkit-backdrop-filter: blur(20px) saturate(135%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.story-list:not(.hidden) {
    display: block;
    overflow: hidden auto;
    padding: 8px 10px 120px;
}

.story-bubbles {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 4px 14px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.story-bubbles::-webkit-scrollbar {
    display: none;
}

.story-bubbles .story-item {
    flex: 0 0 74px;
    min-height: 92px;
    padding: 6px 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    scroll-snap-align: start;
    color: #fff;
}

.story-bubbles .story-item .avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.42), 0 0 20px rgba(255, 0, 184, 0.25);
}

.story-bubbles .story-item > div:not(.avatar) {
    width: 100%;
    text-align: center;
}

.story-bubbles .story-item .chat-title {
    display: block;
    max-width: 74px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.story-bubbles .story-item .last-message,
.story-bubbles .story-item .chat-time {
    display: none;
}

.x-feed {
    display: grid;
    gap: 14px;
    padding: 2px 4px 20px;
}

.x-compose-card,
.x-feed-card {
    border-radius: 24px;
    padding: 14px;
}

.x-compose-head {
    display: grid;
    gap: 3px;
    margin-bottom: 10px;
}

.x-compose-head strong,
.x-feed-card strong {
    color: #fff;
}

.x-compose-head small,
.x-feed-card small,
.x-feed-card p {
    color: rgba(255, 255, 255, 0.72);
}

.x-compose-card textarea {
    width: 100%;
    min-height: 76px;
    resize: vertical;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    background: rgba(5, 7, 10, 0.42);
    color: #fff;
    padding: 12px;
    box-sizing: border-box;
    outline: none;
}

.x-compose-card textarea:focus {
    border-color: rgba(0, 242, 255, 0.56);
    box-shadow: 0 0 0 3px rgba(0, 242, 255, 0.12);
}

.x-photo-preview img,
.x-feed-image {
    width: 100%;
    height: 100%;
    min-height: 132px;
    max-height: 320px;
    object-fit: cover;
    border-radius: 16px;
    margin: 0;
}

.x-photo-grid,
.x-feed-media-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    overflow: hidden;
    border-radius: 18px;
    margin-top: 10px;
}

.x-photo-grid:has(img:only-child),
.x-feed-media-grid.media-count-1 {
    grid-template-columns: 1fr;
}

.x-feed-media-grid.media-count-3 img:first-child {
    grid-row: span 2;
}

.x-feed-meta > div:nth-child(2) {
    min-width: 0;
    flex: 1;
}

.x-feed-more {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.82);
    font-size: 22px;
}

.x-feed-card {
    position: relative;
}

.x-feed-menu {
    position: absolute;
    top: 54px;
    right: 12px;
    z-index: 5;
    min-width: 118px;
    padding: 6px;
    display: grid;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(9, 13, 24, 0.94);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.42);
}

.x-feed-menu.hidden {
    display: none;
}

.x-feed-menu button {
    min-height: 36px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-align: left;
    padding: 0 12px;
}

.x-feed-menu button.danger {
    color: #ff657e;
}

.story-source-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.story-source-grid button {
    min-height: 108px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.055);
    color: #fff;
}

.story-source-grid .nexa-svg {
    width: 28px;
    height: 28px;
    color: #00f2ff;
}

.story-source-preview {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(0, 242, 255, 0.08);
    color: rgba(255, 255, 255, 0.76);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar[data-active-section="stories"] > .search-box {
    display: none;
}

.x-feed-list {
    display: grid;
    gap: 12px;
}

.x-feed-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.x-feed-avatar-slot .avatar {
    width: 42px;
    height: 42px;
}

.x-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.x-actions #updatesFeedVoiceButton {
    min-width: 74px;
}

.x-actions #updatesFeedVoiceButton.recording {
    color: #fff;
    border-color: rgba(255, 0, 184, .34);
    background: linear-gradient(135deg, rgba(0, 216, 255, .28), rgba(112, 76, 255, .52), rgba(255, 0, 184, .46));
    box-shadow: 0 0 20px rgba(255, 0, 184, .18);
}

.x-audio-draft,
.x-feed-audio {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 11px;
    overflow: hidden;
    border: 1px solid rgba(0, 242, 255, .13);
    border-radius: 17px;
    background:
        radial-gradient(circle at 8% 20%, rgba(0, 242, 255, .12), transparent 32%),
        rgba(9, 15, 27, .78);
}

.x-audio-draft.hidden {
    display: none;
}

.x-audio-draft strong,
.x-audio-draft small,
.x-feed-audio strong,
.x-feed-audio small {
    display: block;
}

.x-audio-draft small,
.x-feed-audio small {
    margin-top: 2px;
    color: var(--muted);
}

.x-audio-draft p {
    grid-column: 1 / -1;
    margin: 0;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
}

.x-audio-play,
.x-audio-remove,
.x-feed-audio-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 50%;
    background: rgba(255, 255, 255, .055);
}

.x-audio-play {
    color: #9af8ff;
}

.x-audio-remove {
    color: #ff7890;
}

.x-audio-play .nexa-svg,
.x-audio-remove .nexa-svg,
.x-feed-audio-icon .nexa-svg {
    width: 18px;
    height: 18px;
}

.x-recording-dot {
    width: 13px;
    height: 13px;
    margin: 0 12px;
    border-radius: 50%;
    background: #ff3c68;
    box-shadow: 0 0 0 7px rgba(255, 60, 104, .1), 0 0 18px rgba(255, 60, 104, .42);
    animation: xRecordingPulse 1s ease-in-out infinite;
}

@keyframes xRecordingPulse {
    50% { transform: scale(.72); opacity: .65; }
}

.x-recording-bars,
.x-audio-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 30px;
}

.x-recording-bars i,
.x-audio-wave i {
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, #00e9ff, #704cff 58%, #ff00b8);
}

.x-recording-bars i {
    animation: xRecordingBar .8s ease-in-out infinite alternate;
}

.x-recording-bars i:nth-child(1),
.x-audio-wave i:nth-child(1) { height: 8px; }
.x-recording-bars i:nth-child(2),
.x-audio-wave i:nth-child(2) { height: 19px; animation-delay: .12s; }
.x-recording-bars i:nth-child(3),
.x-audio-wave i:nth-child(3) { height: 27px; animation-delay: .24s; }
.x-recording-bars i:nth-child(4),
.x-audio-wave i:nth-child(4) { height: 15px; animation-delay: .36s; }
.x-recording-bars i:nth-child(5),
.x-audio-wave i:nth-child(5) { height: 22px; animation-delay: .48s; }
.x-audio-wave i:nth-child(6) { height: 12px; }
.x-audio-wave i:nth-child(7) { height: 6px; }

@keyframes xRecordingBar {
    to { transform: scaleY(.38); opacity: .5; }
}

.x-feed-audio {
    grid-template-columns: 40px minmax(0, 1fr) auto;
}

.x-feed-audio-body {
    min-width: 0;
}

.x-feed-audio audio {
    width: 100%;
    height: 32px;
    margin-top: 4px;
}

.x-feed-audio details {
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
}

.x-feed-audio details p {
    margin: 6px 0 0;
    color: rgba(255, 255, 255, .76);
    line-height: 1.45;
}

.x-actions button {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.86);
    border-radius: 999px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.x-actions button.primary {
    background: linear-gradient(135deg, #00f2ff, #ff00b8);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.24);
}

.x-actions button.liked {
    color: #ff3b68;
    border-color: rgba(255, 59, 104, 0.38);
    background: rgba(255, 59, 104, 0.1);
    box-shadow: 0 0 16px rgba(255, 59, 104, 0.16);
}

.x-actions button.liked .nexa-svg {
    fill: currentColor;
}

.sidebar[data-active-section="contacts"] > .search-box,
.sidebar[data-active-section="contacts"] > .section-head,
.sidebar[data-active-section="explore"] > .search-box,
.sidebar[data-active-section="explore"] > .section-head {
    display: none;
}

.section-inline-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 5px 12px;
}

.section-inline-heading > span {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.section-inline-heading strong {
    color: #fff;
    font-size: clamp(25px, 7vw, 31px);
    line-height: 1.1;
    letter-spacing: 0;
}

.section-inline-heading small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    line-height: 1.35;
}

.contacts-inline-header {
    padding-top: 4px;
}

.contact-search-shell {
    margin-bottom: 12px;
}

.contact-results-frame {
    min-width: 0;
    padding-bottom: 8px;
}

.contact-results-frame.mode-forward {
    animation: chatModeForward 320ms cubic-bezier(.18, .82, .22, 1);
}

.contact-results-frame.mode-backward {
    animation: chatModeBackward 320ms cubic-bezier(.18, .82, .22, 1);
}

.contact-list-row {
    width: 100%;
    min-height: 72px;
    margin: 7px 0;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 20px;
    color: var(--text-main);
    text-align: left;
}

.contact-list-row.active {
    border-color: rgba(0, 242, 255, 0.3);
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.1), rgba(124, 77, 255, 0.08));
    box-shadow: 0 0 22px rgba(0, 242, 255, 0.1);
}

.contact-list-row .avatar {
    width: 48px;
    height: 48px;
}

.contact-list-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.contact-list-copy .chat-title,
.contact-list-copy .last-message,
.contact-username {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-username {
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
}

.contact-list-side {
    min-width: 64px;
    display: grid;
    justify-items: end;
    gap: 5px;
}

.contact-relation-badge {
    max-width: 76px;
    padding: 4px 7px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.62);
    font-size: 9px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-relation-badge.friend {
    border-color: rgba(0, 242, 255, 0.23);
    background: rgba(0, 242, 255, 0.1);
    color: #8ff8ff;
}

.contact-relation-badge.incoming {
    border-color: rgba(231, 0, 255, 0.24);
    background: rgba(231, 0, 255, 0.1);
    color: #f5a5ff;
}

.contact-relation-badge.pending {
    border-color: rgba(255, 184, 0, 0.22);
    background: rgba(255, 184, 0, 0.09);
    color: #ffd86e;
}

.contact-score {
    color: rgba(255, 255, 255, 0.44);
    font-size: 9px;
    white-space: nowrap;
}

.contact-empty-state {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 24px 8px;
}

.explore-inline-heading {
    padding-top: 4px;
}

.explore-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 0 0 8px;
}

.explore-card {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 13px;
    padding: 12px 14px;
    color: #fff;
    text-align: left;
    border-radius: 22px;
    overflow: hidden;
}

.explore-card .attachment-option-icon {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    color: #fff;
    border-radius: 17px;
    background: linear-gradient(135deg, #00f2ff, #7c4dff 52%, #ff00b8);
    box-shadow: 0 0 24px rgba(0, 242, 255, 0.24);
}

.explore-card-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.explore-card strong {
    font-size: 15px;
}

.explore-card small {
    display: block;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.62);
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explore-card-arrow {
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.54);
}

.explore-card-arrow .nexa-svg {
    width: 18px;
    height: 18px;
}

.sidebar[data-active-section="contacts"] #contactList {
    padding: 8px 10px 104px;
}

.sidebar[data-active-section="explore"] #exploreList:not(.hidden) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    padding: 8px 10px 104px;
}

.contact-mode-switch {
    margin-right: 0;
    margin-left: 0;
}

.contact-results-frame .section-mini-title {
    padding: 8px 4px 3px;
}

@keyframes profilePaneSlideIn {
    from {
        opacity: 0;
        transform: translateX(28px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.chat-mode-switch {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 4px 5px 10px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.045);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: hidden;
}

.chat-mode-switch::before {
    content: "";
    position: absolute;
    inset: 4px 50% 4px 4px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.9), rgba(124, 77, 255, 0.88), rgba(255, 0, 184, 0.86));
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
    transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.chat-mode-switch.groups-active::before {
    transform: translateX(100%);
}

.chat-mode-switch button {
    position: relative;
    z-index: 1;
    min-width: 0;
    min-height: 38px;
    padding: 8px 10px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: rgba(255, 255, 255, 0.62);
    font-weight: 750;
}

.chat-mode-switch button.active {
    color: #fff;
}

.chat-search-shell {
    min-height: 42px;
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    margin: 0 5px 10px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
    color: rgba(255, 255, 255, 0.54);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.chat-search-shell .nexa-svg {
    width: 18px;
    height: 18px;
}

.chat-search-shell input {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-main);
    font: inherit;
}

.chat-search-shell input::placeholder {
    color: rgba(255, 255, 255, 0.42);
}

.chat-mode-content {
    min-width: 0;
}

.chat-mode-content.mode-forward {
    animation: chatModeForward 320ms cubic-bezier(.18, .82, .22, 1);
}

.chat-mode-content.mode-backward {
    animation: chatModeBackward 320ms cubic-bezier(.18, .82, .22, 1);
}

@keyframes chatModeForward {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes chatModeBackward {
    from { opacity: 0; transform: translateX(-18px); }
    to { opacity: 1; transform: translateX(0); }
}

.sidebar[data-active-section="chats"] > .search-box {
    display: none;
}

.call-filter-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 4px 5px 12px;
}

.call-filter-row .filter-chip {
    min-width: 0;
    min-height: 54px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    padding: 6px 3px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
    color: rgba(255, 255, 255, 0.58);
}

.call-filter-row .filter-chip.active {
    border-color: rgba(0, 242, 255, 0.28);
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.2), rgba(255, 0, 184, 0.16));
    color: #fff;
    box-shadow: 0 0 18px rgba(0, 242, 255, 0.12);
}

.call-filter-row .filter-chip .nexa-svg {
    width: 17px;
    height: 17px;
}

.call-filter-row .filter-chip span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
}

.sidebar[data-active-section="calls"] > .search-box {
    display: none;
}

.section-action-button {
    margin-left: auto;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(0, 242, 255, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.055);
    color: rgba(255, 255, 255, 0.82);
    font-size: 11px;
    font-weight: 650;
}

.call-search-shell {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 4px 5px 10px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.045);
}

.call-search-shell .nexa-svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.58);
}

.call-search-shell input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #fff;
}

.call-results-title {
    padding: 8px 8px 2px;
    color: rgba(255, 255, 255, 0.54);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.call-item {
    position: relative;
    width: calc(100% - 10px);
    min-height: 76px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    margin: 7px 5px;
    padding: 11px 12px;
    color: var(--text-main);
    text-align: left;
    border-radius: 20px;
}

.call-item .avatar {
    width: 48px;
    height: 48px;
}

.call-item .last-message {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    flex-wrap: wrap;
}

.call-direction-pill,
.call-kind-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 750;
}

.call-direction-pill.incoming {
    color: #39d98a;
}

.call-direction-pill.outgoing {
    color: #00d9ff;
}

.call-direction-pill.missed,
.call-item.missed .chat-title {
    color: #ff4d67;
}

.call-kind-pill {
    color: rgba(255, 255, 255, 0.72);
}

.call-kind-pill .nexa-svg,
.call-redial-cue .nexa-svg {
    width: 15px;
    height: 15px;
}

.call-duration {
    color: rgba(255, 255, 255, 0.48);
}

.call-log-side {
    display: grid;
    justify-items: end;
    align-self: stretch;
    align-content: space-between;
    gap: 6px;
    padding: 2px 0;
}

.call-log-side .chat-time {
    align-self: end;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.58);
}

.call-redial-cue {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    color: var(--neon-blue);
    border: 1px solid rgba(0, 242, 255, 0.22);
    border-radius: 50%;
    background: rgba(0, 242, 255, 0.07);
}

.call-item.missed .call-redial-cue {
    color: #ff4d67;
    border-color: rgba(255, 77, 103, 0.26);
    background: rgba(255, 77, 103, 0.08);
}

.call-detail-card {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
}

.new-call-list {
    display: grid;
    gap: 8px;
}

.new-call-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.045);
}

.new-call-actions {
    display: flex;
    gap: 7px;
}

.new-call-actions button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(0, 242, 255, 0.2);
    border-radius: 50%;
    background: rgba(0, 242, 255, 0.07);
    color: #00f2ff;
}

.new-call-actions .nexa-svg {
    width: 18px;
    height: 18px;
}

.x-actions button:hover,
.x-actions button:focus-visible,
.nav-tab.active,
.icon-btn:hover,
.icon-btn:focus-visible {
    box-shadow: 0 0 18px rgba(0, 242, 255, 0.22);
}

/* Premium call surface */
.call-panel {
    --call-wave-level: 0;
    padding: clamp(10px, 2vw, 24px);
    background:
        radial-gradient(circle at 50% 18%, rgba(0, 242, 255, 0.16), transparent 34%),
        radial-gradient(circle at 85% 78%, rgba(255, 0, 184, 0.14), transparent 38%),
        rgba(2, 5, 10, 0.9);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.call-panel.call-entering {
    animation: call-panel-fade 0.36s ease both;
}

.call-panel.call-entering .call-box {
    animation: call-panel-slide-up 0.42s cubic-bezier(0.2, 0.82, 0.24, 1) both;
}

.call-box {
    position: relative;
    width: min(980px, calc(100vw - 24px));
    height: min(760px, calc(var(--app-height) - 28px));
    min-height: 520px;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 40px;
    background: rgba(10, 16, 25, 0.72);
    backdrop-filter: blur(28px) saturate(140%);
    -webkit-backdrop-filter: blur(28px) saturate(140%);
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.58),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.call-box .video-stage {
    position: relative;
    min-height: 0;
    margin: 14px 14px 0;
    overflow: hidden;
    border: 1px solid rgba(0, 242, 255, 0.18);
    border-radius: 40px;
    background:
        radial-gradient(circle at 50% 34%, rgba(0, 242, 255, 0.11), transparent 34%),
        #03060c;
    box-shadow:
        inset 0 0 50px rgba(0, 242, 255, 0.06),
        0 0 34px rgba(0, 242, 255, 0.12);
}

.call-box .video-stage > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.call-box #localVideo {
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: clamp(100px, 22%, 190px);
    height: clamp(142px, 30%, 250px);
    z-index: 4;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 26px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.44), 0 0 24px rgba(0, 242, 255, 0.18);
}

.call-cover {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    overflow: hidden;
    background: rgba(4, 8, 15, 0.38);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.call-cover::before {
    content: "";
    position: absolute;
    inset: -18%;
    z-index: -2;
    background:
        radial-gradient(circle, rgba(0, 242, 255, 0.14), transparent 42%),
        radial-gradient(circle at 72% 65%, rgba(255, 0, 184, 0.16), transparent 38%);
    filter: blur(28px);
}

.call-cover .avatar {
    position: relative;
    z-index: 2;
    width: clamp(118px, 22vw, 176px);
    height: clamp(118px, 22vw, 176px);
    border: 2px solid rgba(255, 255, 255, 0.28);
    font-size: clamp(36px, 8vw, 58px);
    box-shadow:
        0 0 calc(24px + (var(--call-wave-level) * 38px)) rgba(0, 242, 255, 0.3),
        0 18px 48px rgba(0, 0, 0, 0.42);
    transform: scale(calc(1 + (var(--call-wave-level) * 0.035)));
}

.call-cover strong {
    z-index: 2;
    margin-top: 8px;
    font-size: clamp(22px, 4vw, 32px);
}

.call-cover > span {
    z-index: 2;
    color: rgba(255, 255, 255, 0.68);
}

.call-waveform {
    position: absolute;
    left: 50%;
    top: 50%;
    width: clamp(170px, 32vw, 250px);
    aspect-ratio: 1;
    transform: translate(-50%, -58%);
    pointer-events: none;
}

.call-waveform span {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(0, 242, 255, 0.34);
    border-radius: 50%;
    opacity: calc(0.18 + (var(--call-wave-level) * 0.65));
    transform: scale(calc(0.72 + (var(--call-wave-level) * 0.32)));
    transition: transform 80ms linear, opacity 120ms ease;
}

.call-waveform span:nth-child(2) {
    inset: -17%;
    border-color: rgba(124, 77, 255, 0.34);
    transform: scale(calc(0.7 + (var(--call-wave-level) * 0.4)));
}

.call-waveform span:nth-child(3) {
    inset: -34%;
    border-color: rgba(255, 0, 184, 0.28);
    transform: scale(calc(0.66 + (var(--call-wave-level) * 0.5)));
}

.call-cover.speaking .call-waveform {
    filter: drop-shadow(0 0 18px rgba(0, 242, 255, 0.42));
}

.call-box .call-info {
    justify-content: space-between;
    padding: 14px 22px 8px;
}

.call-box .call-info > div {
    display: grid;
    gap: 3px;
}

.call-box .call-info > span {
    color: rgba(255, 255, 255, 0.7);
}

.call-box .call-actions {
    width: min(560px, calc(100% - 28px));
    min-height: 82px;
    justify-self: center;
    justify-content: center;
    margin: 8px 14px max(14px, env(safe-area-inset-bottom));
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(16, 23, 34, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
}

.call-box .call-actions .icon-btn {
    width: 56px;
    height: 56px;
    border: 1px solid rgba(0, 242, 255, 0.34);
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(20, 38, 50, 0.96), rgba(7, 15, 24, 0.98));
    color: var(--neon-blue);
    box-shadow:
        0 9px 0 rgba(1, 8, 14, 0.72),
        0 0 22px rgba(0, 242, 255, 0.18);
    transform: translateY(-3px);
}

.call-box .call-actions .icon-btn:active {
    transform: translateY(3px) scale(0.96);
    box-shadow: 0 2px 0 rgba(1, 8, 14, 0.72), 0 0 15px rgba(0, 242, 255, 0.16);
}

.call-box .call-actions .icon-btn.accept {
    color: #39ff14;
    border-color: rgba(57, 255, 20, 0.42);
    box-shadow: 0 9px 0 rgba(3, 38, 6, 0.8), 0 0 24px rgba(57, 255, 20, 0.26);
}

.call-box .call-actions .icon-btn.danger,
.call-box .call-actions .icon-btn.control-off {
    color: #fff;
    border-color: rgba(255, 58, 93, 0.5);
    background: linear-gradient(145deg, #ff3a5d, #a91335);
    box-shadow: 0 9px 0 rgba(71, 3, 19, 0.86), 0 0 24px rgba(255, 58, 93, 0.26);
}

/* Voice rooms */
.voice-room-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px 16px;
    padding: 16px;
    border-radius: 24px;
    overflow: hidden;
}

.voice-room-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.voice-room-copy strong,
.voice-room-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-room-avatars {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    min-height: 50px;
    padding-left: 7px;
}

.voice-room-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin-left: -7px;
    overflow: visible;
    border: 2px solid #101722;
    border-radius: 50%;
    background: linear-gradient(145deg, #173047, #101827);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.28);
}

.voice-room-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.voice-room-avatar i {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 16px;
    height: 16px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #ff3a5d;
    font-size: 11px;
    font-style: normal;
    opacity: 0;
}

.voice-room-avatar.muted i {
    opacity: 1;
}

.voice-room-avatar.speaking {
    border-color: var(--neon-blue);
    animation: voice-speaking-ring 1.15s ease-in-out infinite;
}

.voice-room-empty {
    color: var(--text-muted);
    font-size: 12px;
}

.voice-room-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.voice-room-section-title {
    margin-top: 18px;
}

.voice-room-joining {
    animation: voice-room-spring 0.68s cubic-bezier(0.16, 1.35, 0.32, 1) both;
}

.voice-room-remote-audio {
    position: fixed;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.voice-rooms-body,
.voice-stage {
    display: grid;
    gap: 10px;
}

.ai-voice-panel .modal-body {
    overflow: hidden;
}

.nexal-voice-stage {
    min-height: min(520px, 62dvh);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px 10px 12px;
    text-align: center;
}

.nexal-voice-stage > strong {
    font-size: 19px;
    letter-spacing: -0.02em;
}

.nexal-voice-stage > small {
    max-width: 290px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.nexal-voice-orb {
    position: relative;
    width: 154px;
    height: 154px;
    display: grid;
    place-items: center;
    margin-bottom: 12px;
    border: 1px solid rgba(90, 200, 255, 0.34);
    border-radius: 50%;
    background:
        radial-gradient(circle at 36% 28%, rgba(117, 230, 255, 0.88), transparent 24%),
        radial-gradient(circle at 65% 70%, rgba(52, 114, 255, 0.75), transparent 42%),
        linear-gradient(145deg, rgba(26, 211, 255, 0.8), rgba(38, 91, 255, 0.8));
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.55),
        inset 0 -18px 34px rgba(15, 46, 145, 0.38),
        0 18px 50px rgba(28, 136, 255, 0.28);
    isolation: isolate;
    transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 320ms ease, filter 320ms ease;
}

.nexal-voice-orb::before,
.nexal-voice-orb::after,
.nexal-voice-orb > i {
    position: absolute;
    content: "";
    border-radius: 50%;
    pointer-events: none;
}

.nexal-voice-orb::before {
    inset: -13px;
    z-index: -2;
    border: 1px solid rgba(84, 201, 255, 0.18);
    background: rgba(42, 149, 255, 0.05);
}

.nexal-voice-orb::after {
    inset: -29px;
    z-index: -3;
    border: 1px solid rgba(84, 201, 255, 0.1);
}

.nexal-voice-orb > i {
    inset: 12%;
    z-index: -1;
    opacity: 0.52;
    background: linear-gradient(120deg, rgba(143, 241, 255, 0.65), rgba(59, 88, 246, 0.18));
    filter: blur(12px);
}

.nexal-voice-orb > i:nth-child(2) {
    inset: 24% 9% 16% 29%;
    animation-delay: -0.7s;
}

.nexal-voice-orb > i:nth-child(3) {
    inset: 11% 28% 27% 8%;
    animation-delay: -1.4s;
}

.nexal-voice-orb .mic {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: #fff;
    filter: drop-shadow(0 4px 12px rgba(3, 25, 80, 0.5));
}

.nexal-voice-orb .mic svg {
    width: 34px;
    height: 34px;
}

.nexal-voice-orb.user-speaking {
    animation: nexa-voice-listening 1.2s ease-in-out infinite;
}

.nexal-voice-orb.user-speaking > i {
    animation: nexa-voice-flow 1.35s ease-in-out infinite alternate;
}

.nexal-voice-orb.ai-thinking {
    animation: nexa-voice-thinking 1.4s linear infinite;
    filter: hue-rotate(22deg);
}

.nexal-voice-orb.ai-speaking {
    animation: nexa-voice-speaking 0.78s ease-in-out infinite alternate;
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.62),
        inset 0 -18px 34px rgba(15, 46, 145, 0.3),
        0 18px 62px rgba(55, 174, 255, 0.55);
}

.nexal-voice-actions {
    width: min(100%, 310px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
}

.nexal-voice-actions .nexal-pill-button:not(.primary) {
    border: 1px solid rgba(103, 196, 255, 0.22);
    background: rgba(13, 25, 42, 0.88);
    color: rgba(235, 247, 255, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@keyframes nexa-voice-listening {
    0%, 100% { transform: scale(0.97); }
    50% { transform: scale(1.045); }
}

@keyframes nexa-voice-flow {
    from { transform: translate3d(-8px, 5px, 0) scale(0.9); opacity: 0.35; }
    to { transform: translate3d(8px, -6px, 0) scale(1.12); opacity: 0.8; }
}

@keyframes nexa-voice-thinking {
    from { transform: rotate(0deg) scale(0.98); }
    to { transform: rotate(360deg) scale(0.98); }
}

@keyframes nexa-voice-speaking {
    from { transform: scale(0.98); }
    to { transform: scale(1.075); }
}

@media (prefers-reduced-motion: reduce) {
    .nexal-voice-orb,
    .nexal-voice-orb > i {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
    }
}

.ai-home-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.ai-home-card {
    min-width: 0;
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid rgba(0, 242, 255, 0.12);
    border-radius: 17px;
    background:
        linear-gradient(145deg, rgba(0, 242, 255, 0.06), rgba(112, 76, 255, 0.05)),
        rgba(9, 15, 24, 0.78);
    color: var(--text-main);
    text-align: left;
}

.ai-home-card:hover,
.ai-home-card:focus-visible {
    border-color: rgba(0, 242, 255, 0.3);
    box-shadow: 0 0 18px rgba(0, 242, 255, 0.09);
}

.ai-home-card strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-home-card small {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
}







.points-panel-body {
    display: grid;
    gap: 14px;
    padding-bottom: 8px;
}

.points-panel-body > h3 {
    margin: 4px 0 0;
    font-size: 15px;
}

.points-panel-body .profile-hero {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    align-items: center;
    gap: 13px;
    padding: 14px;
    border: 1px solid rgba(255, 193, 7, 0.16);
    border-radius: 22px;
    background:
        radial-gradient(circle at 12% 20%, rgba(255, 193, 7, 0.12), transparent 42%),
        rgba(9, 15, 24, 0.74);
}

.points-panel-body .profile-hero .avatar {
    width: 58px;
    height: 58px;
}

.points-panel-body .profile-title {
    min-width: 0;
}

.points-panel-body .profile-title h2,
.points-panel-body .profile-title p {
    margin: 0;
}

.points-panel-body .profile-title h2 {
    font-size: 20px;
}

.points-panel-body .profile-title p {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.points-help {
    width: 20px;
    height: 20px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(255, 193, 7, 0.28);
    border-radius: 50%;
    color: #ffe59a;
    font-size: 11px;
    vertical-align: 2px;
}

.points-progress {
    width: 100%;
    height: 6px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
}

.points-progress > span {
    width: var(--points-progress, 0%);
    height: 100%;
    display: block;
    border-radius: inherit;
    background: linear-gradient(90deg, #00d8ff, #704cff 52%, #ff00b8);
    box-shadow: 0 0 12px rgba(112, 76, 255, 0.32);
}

.points-panel-body .profile-grid,
.points-panel-body .quest-grid,
.points-panel-body .badge-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.points-panel-body .profile-stat,
.points-panel-body .quest-card,
.points-panel-body .badge-card,
.points-panel-body .point-ledger-row {
    min-width: 0;
    display: grid;
    gap: 5px;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.04);
}

.points-panel-body .profile-stat span,
.points-panel-body .profile-stat small,
.points-panel-body .quest-card small,
.points-panel-body .badge-card small,
.points-panel-body .point-ledger-row small {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}

.points-panel-body .profile-stat strong {
    color: #ffe59a;
    font-size: 17px;
}

.points-panel-body .quest-card,
.points-panel-body .badge-card {
    align-content: start;
}

.points-panel-body .badge-card.unlocked {
    border-color: rgba(255, 193, 7, 0.28);
    background: linear-gradient(145deg, rgba(255, 193, 7, 0.1), rgba(112, 76, 255, 0.08));
}

.points-panel-body .quest-card .mini-btn {
    justify-self: start;
    margin-top: 2px;
}

.points-panel-body .point-ledger-list {
    display: grid;
    gap: 8px;
}

.points-panel-body .point-ledger-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.points-panel-body .point-ledger-row small {
    text-align: right;
}

@media (max-width: 430px) {
    .points-panel-body .profile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .points-panel-body .quest-grid,
    .points-panel-body .badge-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes call-panel-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes call-panel-slide-up {
    from {
        opacity: 0;
        transform: translateY(48px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes voice-speaking-ring {
    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(0, 242, 255, 0.18), 0 0 16px rgba(0, 242, 255, 0.28);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(0, 242, 255, 0.08), 0 0 28px rgba(0, 242, 255, 0.58);
    }
}

@keyframes voice-room-spring {
    0% { transform: scale(0.92); }
    58% { transform: scale(1.035); }
    78% { transform: scale(0.99); }
    100% { transform: scale(1); }
}

@media (max-width: 640px) {
    .call-panel {
        padding: 0;
    }

    .call-box {
        width: 100vw;
        height: var(--app-height);
        min-height: 0;
        border-width: 0;
        border-radius: 0;
    }

    .call-box .video-stage {
        margin: max(8px, env(safe-area-inset-top)) 8px 0;
        border-radius: 32px;
    }

    .call-box .call-info {
        padding-inline: 16px;
    }

    .call-box .call-actions {
        min-height: 72px;
        gap: 9px;
        margin-bottom: max(9px, env(safe-area-inset-bottom));
    }

    .call-box .call-actions .icon-btn {
        width: 50px;
        height: 50px;
    }

    .voice-room-card {
        width: calc(100% - 10px);
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Stage 2: mobile top panel */
@media (max-width: 860px) {
    .topbar {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .topbar #meAvatar {
        flex: 0 0 auto;
        width: 44px;
        height: 44px;
    }

    .topbar .identity {
        flex: 0 1 auto;
        max-width: min(52vw, 210px);
    }

    .topbar #meName {
        max-width: 100%;
        font-size: 15px;
        line-height: 1.15;
    }

    .topbar #accountSwitcherButton {
        flex: 0 0 28px;
        width: 28px;
        height: 28px;
        min-height: 28px;
        margin-left: -2px;
        padding: 0;
        border-color: transparent;
        background: transparent;
        box-shadow: none;
        color: rgba(255, 255, 255, 0.78);
        font-size: 16px;
    }

    .topbar .mobile-brand-title,
    .topbar #mobileQrButton,
    .topbar #installButton,
    .topbar #storyButton,
    .topbar #notificationButton,
    .topbar #newGroupButton {
        display: none;
    }

    .topbar #pointsRailButton {
        width: auto;
        min-width: 48px;
        max-width: 72px;
        height: 38px;
        min-height: 38px;
        margin-left: auto;
        padding: 0 9px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        overflow: hidden;
        border: 1px solid rgba(255, 193, 7, 0.25);
        border-radius: 14px;
        background: rgba(255, 193, 7, 0.08);
        color: #ffe59a;
        box-shadow: 0 0 16px rgba(255, 193, 7, 0.08);
        white-space: nowrap;
    }

    .topbar #pointsTopLabel {
        overflow: hidden;
        font-size: 11px;
        text-overflow: ellipsis;
    }

    .topbar .icon-row {
        margin-left: 0;
        flex: 0 0 auto;
        display: flex;
    }

    .topbar #topSettingsButton {
        display: inline-grid;
        width: 42px;
        height: 42px;
        color: var(--neon-blue);
        border-color: rgba(0, 242, 255, 0.18);
        background: rgba(255, 255, 255, 0.06);
        box-shadow: 0 0 18px rgba(0, 242, 255, 0.12);
    }

    .settings-panel:not(.hidden) {
        animation: settings-panel-grow-down 0.34s cubic-bezier(0.2, 0.82, 0.24, 1) both;
        transform-origin: top right;
    }

    .settings-panel .settings-box {
        transform-origin: top right;
    }
}

@media (max-width: 640px) {
    .settings-panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: var(--app-height);
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
        margin: 0;
        border-radius: 0;
    }

    .settings-panel .settings-box {
        width: 100vw;
        height: var(--app-height);
        max-height: var(--app-height);
        margin: 0;
        border-radius: 0;
        border-width: 0;
    }

    .settings-menu {
        display: grid;
        gap: 9px;
        padding: 12px;
    }

    .settings-option,
    .settings-row {
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 58px;
        padding: 10px 12px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 18px;
        background: rgba(9, 15, 24, 0.64);
        color: var(--text-main);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    }

    .settings-option .option-icon {
        width: 34px;
        height: 34px;
        display: grid;
        place-items: center;
        border-radius: 13px;
        color: var(--neon-blue);
        background: rgba(0, 242, 255, 0.09);
    }

    .settings-option > span:nth-child(2) {
        display: grid;
        gap: 3px;
        min-width: 0;
    }

    .settings-option > span:nth-child(2) strong,
    .settings-option > span:nth-child(2) small {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.settings-panel.settings-closing {
    pointer-events: none;
    animation: settings-panel-shrink-up 0.28s cubic-bezier(0.4, 0, 0.8, 0.2) both;
    transform-origin: top right;
}

.settings-section {
    min-width: 0;
    display: grid;
    gap: 12px;
    padding: 12px;
}

.settings-section.hidden {
    display: none;
}

.settings-menu.hidden {
    display: none;
}

.settings-box.settings-view-forward .settings-section:not(.hidden) {
    animation: settings-view-forward 280ms cubic-bezier(.2, .8, .2, 1) both;
}

.settings-box.settings-view-backward .settings-menu:not(.hidden) {
    animation: settings-view-backward 280ms cubic-bezier(.2, .8, .2, 1) both;
}

.settings-back {
    justify-self: start;
    min-height: 38px;
    padding: 7px 12px;
    border-color: rgba(0, 242, 255, 0.14);
    background: rgba(0, 242, 255, 0.06);
    color: #a9f9ff;
}

.profile-hero-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 24px;
    background:
        radial-gradient(circle at 15% 15%, rgba(0, 242, 255, 0.13), transparent 35%),
        radial-gradient(circle at 85% 85%, rgba(231, 0, 255, 0.12), transparent 38%),
        rgba(9, 15, 24, 0.72);
}

.profile-hero-top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.profile-avatar-xl {
    position: relative;
    flex: 0 0 auto;
}

.profile-avatar-xl .avatar {
    width: 70px;
    height: 70px;
    font-size: 22px;
    box-shadow: 0 0 0 4px rgba(0, 242, 255, 0.08), 0 0 22px rgba(231, 0, 255, 0.16);
}

.profile-camera-button {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 11px;
}

.profile-hero-title {
    min-width: 0;
}

.profile-hero-title h3 {
    margin: 0;
    overflow: hidden;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-hero-title p {
    margin: 5px 0 0;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.profile-metrics-grid {
    display: grid;
    grid-template-columns: minmax(92px, .45fr) minmax(0, 1fr);
    gap: 9px;
}

.profile-metric,
.profile-note-card {
    min-width: 0;
    min-height: 62px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text-main);
    text-align: left;
}

.profile-metric small,
.profile-note-card small {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-ai-analysis-button {
    width: 100%;
    padding: 13px 14px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: 1px solid rgba(124, 77, 255, 0.34);
    border-radius: 16px;
    color: var(--text-main);
    background:
        radial-gradient(circle at 12% 20%, rgba(0, 207, 255, 0.16), transparent 38%),
        linear-gradient(135deg, rgba(49, 70, 121, 0.48), rgba(76, 21, 111, 0.42));
}

.profile-ai-analysis-button small {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    line-height: 1.35;
}

.profile-ai-analysis-orb {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, #00d5ff, #7047ff 54%, #ff00b8);
    box-shadow: 0 0 20px rgba(112, 71, 255, 0.42);
}

.profile-ai-analysis-orb.active {
    animation: profile-analysis-pulse 1.35s ease-in-out infinite;
}

@keyframes profile-analysis-pulse {
    50% {
        transform: scale(1.08);
        box-shadow: 0 0 32px rgba(255, 0, 184, 0.55);
    }
}

.profile-analysis-loading {
    min-height: 280px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    text-align: center;
}

.profile-analysis-loading small {
    max-width: 300px;
    color: var(--text-muted);
    line-height: 1.45;
}

.profile-analysis-loading.error .profile-ai-analysis-orb {
    background: linear-gradient(135deg, #ff4d68, #b51b60);
}

.profile-analysis-hero,
.profile-analysis-profession {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.profile-analysis-hero {
    justify-content: flex-start;
    padding: 4px 0 14px;
}

.profile-analysis-hero small,
.profile-analysis-profession small {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
}

.profile-analysis-summary,
.profile-analysis-section {
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(10, 17, 32, 0.72);
}

.profile-analysis-summary {
    margin: 0 0 12px;
    line-height: 1.55;
}

.profile-analysis-metrics {
    display: grid;
    gap: 9px;
}

.profile-analysis-metric {
    --metric-color: #8f5cff;
    padding: 11px 12px;
    border: 1px solid color-mix(in srgb, var(--metric-color) 30%, transparent);
    border-radius: 14px;
    background: rgba(13, 21, 39, 0.82);
}

.profile-analysis-metric > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}

.profile-analysis-track {
    height: 6px;
    margin-top: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.profile-analysis-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--metric-color);
    box-shadow: 0 0 12px var(--metric-color);
}

.profile-analysis-metric.tone-red { --metric-color: #ff4d68; }
.profile-analysis-metric.tone-green { --metric-color: #00d79b; }
.profile-analysis-metric.tone-blue { --metric-color: #388cff; }
.profile-analysis-metric.tone-pink { --metric-color: #ff28bd; }
.profile-analysis-metric.tone-cyan { --metric-color: #00d5ff; }
.profile-analysis-metric.tone-amber { --metric-color: #ffb22e; }

.profile-analysis-section {
    margin-top: 12px;
}

.profile-analysis-evidence-grid {
    margin-top: 11px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.profile-analysis-evidence {
    min-width: 0;
    padding: 10px 6px;
    text-align: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.045);
}

.profile-analysis-evidence strong,
.profile-analysis-evidence small {
    display: block;
}

.profile-analysis-evidence small {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 10px;
}

.profile-analysis-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 11px;
}

.profile-analysis-chips span {
    padding: 7px 10px;
    border-radius: 999px;
    color: #d7dfff;
    background: rgba(112, 71, 255, 0.17);
    border: 1px solid rgba(112, 71, 255, 0.3);
}

.profile-analysis-profession b {
    max-width: 45%;
    text-align: right;
    color: #c9a8ff;
}

.profile-analysis-privacy {
    margin: 14px 2px 2px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.45;
}

@media (max-width: 520px) {
    .profile-analysis-evidence-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Stage 8: username, Gmail and future phone identity theme */
.auth-identity-field {
    transition:
        border-color 180ms ease,
        box-shadow 180ms ease,
        background 180ms ease;
}

.auth-identity-field[data-identity-kind="username"] {
    border-color: rgba(139, 92, 246, 0.28);
    box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.04);
}

.auth-identity-field[data-identity-kind="gmail"] {
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.07);
}

.auth-identity-field[data-identity-kind="phone"] {
    border-color: rgba(245, 158, 11, 0.38);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.06);
}

.auth-identity-meta,
.profile-phone-preview {
    min-width: 0;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.74);
    color: var(--text-main);
}

.auth-identity-meta.hidden {
    display: none;
}

.auth-identity-meta > span:last-child,
.profile-phone-preview > span:last-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.auth-identity-meta strong,
.profile-phone-preview strong {
    overflow: hidden;
    font-size: 13px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-identity-meta small,
.profile-phone-preview small {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}

.auth-identity-badge,
.profile-phone-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    border: 1px solid rgba(139, 92, 246, 0.32);
    border-radius: 13px;
    background: rgba(139, 92, 246, 0.13);
    color: #c4b5fd;
    font-size: 17px;
    font-weight: 800;
}

.auth-identity-badge::before {
    content: "@";
}

.auth-identity-meta[data-kind="gmail"] {
    border-color: rgba(56, 189, 248, 0.18);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(17, 24, 39, 0.78));
}

.auth-identity-meta[data-kind="gmail"] .auth-identity-badge {
    border-color: rgba(56, 189, 248, 0.34);
    background: rgba(56, 189, 248, 0.13);
    color: #7dd3fc;
}

.auth-identity-meta[data-kind="gmail"] .auth-identity-badge::before {
    content: "G";
}

.auth-identity-meta[data-kind="phone"] {
    border-color: rgba(245, 158, 11, 0.2);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(17, 24, 39, 0.78));
}

.auth-identity-meta[data-kind="phone"] .auth-identity-badge,
.profile-phone-icon {
    border-color: rgba(245, 158, 11, 0.34);
    background: rgba(245, 158, 11, 0.13);
    color: #fbbf24;
}

.auth-identity-meta[data-kind="phone"] .auth-identity-badge::before {
    content: "+";
}

.profile-phone-preview {
    opacity: 0.9;
}

@media (max-width: 520px) {
    .auth-card {
        max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .auth-identity-meta,
    .profile-phone-preview {
        padding: 9px 10px;
    }
}

.settings-section .settings-row {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 54px;
}

.settings-section .settings-row > button {
    min-width: 0;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid rgba(0, 242, 255, 0.14);
    border-radius: 13px;
    background: rgba(0, 242, 255, 0.06);
    color: #dffcff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-section .settings-row > button:hover,
.settings-section .settings-row > button:focus-visible {
    border-color: rgba(0, 242, 255, 0.34);
    background: rgba(0, 242, 255, 0.12);
}

.avatar-preset-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.avatar-preset-card {
    min-width: 0;
    min-height: 66px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(9, 15, 24, 0.68);
    color: var(--text-main);
    text-align: left;
}

.avatar-preset-card.active {
    border-color: rgba(0, 242, 255, 0.3);
    box-shadow: 0 0 18px rgba(0, 242, 255, 0.1);
}

.avatar-mini-preview {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--avatar-gradient);
    color: #fff;
    font-weight: 800;
}

.avatar-preset-card > span:last-child {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.avatar-preset-card strong,
.avatar-preset-card small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-preset-card small {
    color: var(--text-muted);
    font-size: 10px;
}

.settings-section > input,
.settings-section > textarea,
.settings-section > select,
.settings-section .privacy-scope-card select {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 15px;
    background: rgba(8, 14, 24, 0.76);
    color: var(--text-main);
}

.settings-section > button:not(.settings-back):not(.primary),
.settings-section > a,
.modal-body > button:not(.primary):not(.danger) {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid rgba(56, 189, 248, 0.16);
    border-radius: 15px;
    background: rgba(9, 18, 30, 0.88);
    color: #dff8ff;
    box-shadow: none;
}

.settings-section > button:not(.settings-back):not(.primary):active,
.settings-section > a:active {
    transform: scale(0.985);
}

.settings-section > .last-message,
.modal-body > .last-message,
.modal-body > p {
    margin: 0;
    padding: 11px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(9, 15, 24, 0.68);
    color: var(--text-muted);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.settings-list {
    min-width: 0;
    display: grid;
    gap: 10px;
}

.device-card,
.blocked-card {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: rgba(9, 15, 24, 0.76);
    color: var(--text-main);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.device-card.clickable {
    cursor: pointer;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.device-card.clickable:active {
    transform: scale(0.985);
    border-color: rgba(56, 189, 248, 0.24);
    background: rgba(12, 24, 39, 0.9);
}

.device-card > div,
.blocked-card > div,
.device-card .profile-preview,
.device-card .profile-preview > div {
    min-width: 0;
}

.device-card .profile-preview {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.device-card strong,
.blocked-card strong {
    display: block;
    color: var(--text-main);
}

.device-card .last-message,
.blocked-card .last-message {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.device-card .mini-btn,
.blocked-card .mini-btn {
    align-self: center;
    min-width: 76px;
}

.notification-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(9, 15, 24, 0.72);
}

.notification-tools .last-message {
    flex: 1 0 100%;
    color: var(--text-muted);
    line-height: 1.4;
}

.empty-state-view {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 3px 11px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    background:
        radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.1), transparent 48%),
        rgba(17, 24, 39, 0.86);
    color: var(--text-main);
}

.empty-state-view .empty-state-icon {
    grid-row: 1 / span 2;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(56, 189, 248, 0.22);
    border-radius: 14px;
    background: rgba(56, 189, 248, 0.1);
    color: #7dd3fc;
}

.empty-state-view .empty-state-icon svg {
    width: 21px;
    height: 21px;
}

.empty-state-view strong,
.empty-state-view span {
    min-width: 0;
    display: block;
}

.empty-state-view strong {
    font-size: 14px;
    line-height: 1.3;
}

.empty-state-view > span {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.x-feed-list .empty-state-view {
    margin-top: 10px;
}

@media (max-width: 520px) {
    .device-card,
    .blocked-card {
        grid-template-columns: minmax(0, 1fr);
    }

    .device-card > .mini-btn,
    .blocked-card > .mini-btn {
        width: 100%;
    }
}

.privacy-grid,
.privacy-scope-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.privacy-scope-card {
    min-width: 0;
    display: grid;
    gap: 7px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: rgba(9, 15, 24, 0.68);
}

.privacy-scope-card small {
    color: var(--text-muted);
    line-height: 1.35;
}

.toggle-row {
    min-width: 0;
    min-height: 52px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(9, 15, 24, 0.66);
}

.toggle-row > span {
    min-width: 0;
    line-height: 1.35;
}

.toggle-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 42px;
    height: 24px;
    min-height: 24px;
    margin: 0;
    padding: 2px;
    border: 1px solid rgba(255, 88, 103, 0.46);
    border-radius: 999px;
    outline: 0;
    background: rgba(255, 68, 92, 0.24);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

.toggle-row input[type="checkbox"]::after {
    content: "";
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.34);
    transition: transform 180ms ease;
}

.toggle-row input[type="checkbox"]:checked {
    border-color: rgba(57, 255, 20, 0.52);
    background: rgba(57, 255, 20, 0.34);
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.13);
}

.toggle-row input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

.password-rule-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.password-rule-list span {
    padding: 5px 8px;
    border: 1px solid rgba(0, 242, 255, 0.14);
    border-radius: 999px;
    background: rgba(0, 242, 255, 0.06);
    color: rgba(255, 255, 255, 0.66);
    font-size: 10px;
}

@media (max-width: 640px) {
    .settings-section {
        padding:
            12px
            calc(12px + var(--safe-right))
            calc(24px + var(--safe-bottom))
            calc(12px + var(--safe-left));
    }

    .privacy-grid,
    .privacy-scope-grid {
        grid-template-columns: 1fr;
    }
}

.messages.profile-mode {
    overflow-y: auto;
    padding: 14px 14px calc(96px + var(--safe-bottom));
    background:
        radial-gradient(circle at 18% 12%, rgba(0, 242, 255, 0.1), transparent 34%),
        radial-gradient(circle at 86% 84%, rgba(231, 0, 255, 0.1), transparent 36%),
        #050911;
}

.chat-top .member-action {
    display: none;
}

.chat-top .member-action.visible {
    display: inline-grid;
}

.messages.profile-mode .profile-page {
    width: min(100%, 720px);
    margin: 0 auto;
    display: grid;
    gap: 12px;
}

.messages.profile-mode .profile-hero,
.messages.profile-mode .profile-stat,
.messages.profile-mode .profile-about {
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(14, 23, 37, 0.76);
    backdrop-filter: blur(20px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
}

.messages.profile-mode .profile-hero {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 22px 16px;
    border-radius: 26px;
    text-align: center;
}

.messages.profile-mode .profile-hero .avatar {
    width: 92px;
    height: 92px;
    font-size: 28px;
    border-width: 2px;
    box-shadow: 0 0 0 5px rgba(0, 242, 255, 0.08), 0 0 28px rgba(231, 0, 255, 0.16);
}

.messages.profile-mode .profile-title {
    min-width: 0;
}

.messages.profile-mode .profile-title h2 {
    margin: 0;
    font-size: clamp(21px, 6vw, 27px);
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.messages.profile-mode .profile-title p {
    margin: 7px 0 0;
    color: var(--text-muted);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.messages.profile-mode .profile-chip-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    margin-top: 13px;
}

.messages.profile-mode .profile-chip {
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid rgba(0, 242, 255, 0.16);
    border-radius: 999px;
    background: rgba(0, 242, 255, 0.07);
    color: rgba(255, 255, 255, 0.86);
    font-size: 12px;
    line-height: 1.2;
}

.messages.profile-mode .point-badge-chip {
    border-color: rgba(255, 193, 7, 0.34);
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.16), rgba(255, 0, 184, 0.1));
    color: #ffe6a1;
    box-shadow: 0 0 16px rgba(255, 193, 7, 0.08);
}

.messages.profile-mode .profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.messages.profile-mode .profile-stat {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 7px;
    padding: 14px;
    border-radius: 18px;
}

.messages.profile-mode .profile-stat span,
.messages.profile-mode .profile-about span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.messages.profile-mode .profile-stat strong {
    min-width: 0;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.messages.profile-mode .profile-about {
    padding: 16px;
    border-radius: 18px;
}

.messages.profile-mode .profile-about p {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.messages.profile-mode .profile-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.messages.profile-mode .profile-action {
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    background: rgba(14, 23, 37, 0.8);
    color: var(--text-main);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.messages.profile-mode .profile-action.primary {
    border-color: rgba(0, 242, 255, 0.24);
    background: linear-gradient(135deg, rgba(44, 91, 255, 0.92), rgba(231, 0, 255, 0.88));
    box-shadow: 0 10px 24px rgba(89, 54, 255, 0.2);
}

.messages.profile-mode .profile-action.danger {
    border-color: rgba(255, 68, 92, 0.24);
    background: rgba(255, 68, 92, 0.09);
    color: #ff8b9a;
}

.settings-option.danger-option {
    border-color: rgba(255, 68, 92, 0.16);
}

.settings-option.danger-option .option-icon,
.settings-option.danger-option strong {
    color: #ff8b9a;
}

/* Asistan full-screen assistant */
.ai-panel {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--app-height);
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background:
        radial-gradient(circle at 16% 6%, rgba(0, 242, 255, 0.11), transparent 30%),
        radial-gradient(circle at 90% 88%, rgba(255, 0, 184, 0.1), transparent 32%),
        rgba(5, 7, 10, 0.97);
    box-shadow: none;
}

.ai-panel.hidden {
    display: none;
}

.ai-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 14, 24, 0.78);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.ai-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-title-row > span:last-child {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.ai-title-row strong,
.ai-title-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-mini-orb {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 34% 30%, #00f2ff, #704cff 48%, #ff00b8 74%, #05070a 76%);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.28), 0 0 24px rgba(255, 0, 184, 0.18);
}

.ai-messages {
    flex: 1 1 auto;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 14px 12px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 242, 255, 0.4) transparent;
}

.ai-bubble {
    align-self: flex-start;
    width: fit-content;
    max-width: min(86%, 680px);
    min-width: 0;
    padding: 10px 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px 17px 17px 6px;
    background: rgba(20, 29, 46, 0.82);
    color: var(--text-main);
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: normal;
}

.ai-bubble.user {
    align-self: flex-end;
    border-color: rgba(0, 242, 255, 0.18);
    border-radius: 17px 17px 6px 17px;
    background: linear-gradient(135deg, rgba(49, 79, 255, 0.94), rgba(218, 0, 255, 0.88));
}

.ai-bubble p,
.ai-bubble ul,
.ai-bubble ol,
.ai-bubble pre,
.ai-bubble a,
.ai-bubble span {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.ai-bubble .ai-link {
    display: inline;
    color: #73e9ff;
    font-weight: 650;
    line-height: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(115, 233, 255, 0.5);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    word-break: break-word;
}

.ai-bubble .ai-link:hover,
.ai-bubble .ai-link:focus-visible {
    color: #b9f7ff;
    text-decoration-color: currentColor;
}

.ai-bubble br + .ai-link {
    display: inline-block;
    margin-top: 3px;
}

.ai-composer {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 38px 38px minmax(0, 1fr) 38px 38px;
    align-items: end;
    gap: 6px;
    width: 100%;
    padding: 8px 10px calc(8px + var(--safe-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 14, 22, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.ai-composer .icon-btn,
.ai-composer .send-btn {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.ai-composer textarea {
    width: 100%;
    height: 38px;
    min-height: 38px;
    max-height: 112px;
    margin: 0;
    padding: 9px 12px;
    resize: none;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 19px;
    background: rgba(16, 25, 41, 0.86);
    color: var(--text-main);
    font: inherit;
    line-height: 1.25;
    outline: none;
}

.ai-composer textarea:focus {
    border-color: rgba(0, 242, 255, 0.42);
    box-shadow: 0 0 0 3px rgba(0, 242, 255, 0.08);
}

.nexal-command-list,
.nexal-form-grid,
.nexal-menu {
    display: grid;
    gap: 9px;
    width: 100%;
}

.nexal-command-card,
.nexal-menu-card,
.nexal-tool-card,
.nexal-task-card {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(18, 27, 43, 0.78);
    color: var(--text-main);
    text-align: left;
}

.nexal-command-card span:nth-child(2),
.nexal-menu-card span:nth-child(2),
.nexal-tool-card span:last-child,
.nexal-task-card span {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.nexal-command-card strong,
.nexal-command-card small,
.nexal-menu-card strong,
.nexal-menu-card small,
.nexal-tool-card strong,
.nexal-tool-card small,
.nexal-task-card strong,
.nexal-task-card small {
    overflow-wrap: anywhere;
}

.nexal-command-card small,
.nexal-menu-card small,
.nexal-tool-card small,
.nexal-task-card small {
    color: var(--text-muted);
    line-height: 1.35;
}

.nexal-card-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #00f2ff, #704cff 56%, #ff00b8);
    box-shadow: 0 0 18px rgba(0, 242, 255, 0.2);
}

.nexal-card-icon.green {
    background: linear-gradient(135deg, #00d96f, #00a884);
}

.nexal-card-icon.orange {
    background: linear-gradient(135deg, #ff9f1a, #ff3d81);
}

.nexal-card-icon.gray {
    background: linear-gradient(135deg, #455066, #222b3c);
}

.nexal-chevron {
    color: var(--text-muted);
}

@media (max-width: 860px) {
    .ai-head {
        min-height: calc(60px + var(--safe-top));
        padding:
            calc(8px + var(--safe-top))
            calc(10px + var(--safe-right))
            8px
            calc(10px + var(--safe-left));
    }

    .ai-messages {
        padding-right: calc(10px + var(--safe-right));
        padding-left: calc(10px + var(--safe-left));
    }

    .ai-composer {
        grid-template-columns: 36px 36px minmax(0, 1fr) 36px 36px;
        gap: 5px;
        padding-right: calc(8px + var(--safe-right));
        padding-left: calc(8px + var(--safe-left));
    }

    .ai-composer .icon-btn,
    .ai-composer .send-btn {
        width: 36px;
        height: 36px;
        min-height: 36px;
    }

    .modal-panel.sheet:not(.hidden) {
        position: fixed;
        inset: auto 8px max(8px, var(--safe-bottom));
        z-index: 2800;
        display: flex;
        flex-direction: column;
        width: auto;
        height: auto;
        max-height: min(78vh, calc(var(--app-height) - var(--safe-top) - 18px));
        padding: 14px;
        overflow: auto;
        border-radius: 24px;
        background: rgba(12, 18, 29, 0.96);
    }

    .modal-panel.sheet.share-menu-sheet:not(.hidden) {
        inset: 0;
        width: var(--viewport-width, 100vw);
        height: var(--app-height);
        max-height: var(--app-height);
        display: flex;
        justify-content: flex-end;
        padding:
            calc(12px + var(--safe-top))
            calc(12px + var(--safe-right))
            calc(12px + var(--safe-bottom))
            calc(12px + var(--safe-left));
        overflow: hidden;
        border-radius: 0;
        background: rgba(2, 5, 12, 0.5);
        backdrop-filter: blur(14px) saturate(120%);
        -webkit-backdrop-filter: blur(14px) saturate(120%);
    }

    .share-menu-sheet .modal-box {
        width: 100%;
        max-height: none;
    }
}

@keyframes settings-panel-grow-down {
    from {
        opacity: 0;
        transform: translate(12px, -18px) scale(0.82);
    }
    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

@keyframes settings-panel-shrink-up {
    from {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(12px, -18px) scale(0.82);
    }
}

@keyframes settings-view-forward {
    from {
        opacity: 0;
        transform: translateX(28px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes settings-view-backward {
    from {
        opacity: 0;
        transform: translateX(-22px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Stage 9: iPhone notch, dynamic viewport and keyboard-safe mobile layout */
@media (max-width: 860px) {
    html,
    body {
        width: 100%;
        height: var(--app-height);
        min-height: var(--app-height);
        overflow: hidden;
    }

    .auth-screen {
        min-height: var(--app-height);
        padding:
            calc(12px + var(--safe-top))
            calc(16px + var(--safe-right))
            calc(16px + var(--safe-bottom))
            calc(16px + var(--safe-left));
        overflow-y: auto;
    }

    .app {
        inset: auto;
        top: var(--viewport-top);
        left: var(--viewport-left);
        width: var(--viewport-width);
        height: var(--app-height);
        max-width: var(--viewport-width);
        max-height: var(--app-height);
    }

    .sidebar,
    .chat-pane {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
    }

    .topbar,
    .chat-top {
        flex: 0 0 auto;
        min-height: calc(64px + var(--safe-top));
        padding:
            calc(8px + var(--safe-top))
            calc(10px + var(--safe-right))
            8px
            calc(10px + var(--safe-left));
    }

    .topbar .identity,
    .chat-top .identity {
        min-width: 0;
        overflow: hidden;
    }

    .nav-tabs {
        position: absolute;
        bottom: max(12px, var(--safe-bottom));
    }

    .composer {
        position: absolute;
        top: auto;
        bottom: 0;
        padding:
            6px
            calc(8px + var(--safe-right))
            max(6px, var(--safe-bottom))
            calc(8px + var(--safe-left));
    }

    .app.keyboard-open .composer {
        padding-bottom: 6px;
    }

    .messages {
        padding-bottom: calc(var(--composer-height) + var(--safe-bottom) + 14px);
    }

    .app.keyboard-open .messages {
        padding-bottom: calc(var(--composer-height) + 14px);
    }

    .screen-transition,
    .call-panel,
    .ai-panel,
    .story-panel,
    .settings-panel,
    .modal-panel:not(.sheet) {
        inset: auto;
        top: var(--viewport-top);
        left: var(--viewport-left);
        width: var(--viewport-width);
        height: var(--app-height);
        max-width: var(--viewport-width);
        max-height: var(--app-height);
    }

    .pane-transition,
    .empty-chat {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }

    .call-box,
    .settings-panel .settings-box {
        max-height: 100%;
    }
}

/* Stage 1: chat surface polish */
.messages {
    display: flex;
    flex-direction: column;
}

.bubble,
.message-bubble {
    position: relative;
    line-height: 1.42;
}

.bubble.theirs,
.message-bubble.theirs {
    align-self: flex-start;
    border-radius: 18px 18px 18px 7px;
    background: rgba(20, 29, 46, 0.84);
}

.bubble.mine,
.message-bubble.mine {
    align-self: flex-end;
    border-radius: 18px 18px 7px 18px;
}

.bubble.theirs::after,
.bubble.mine::after,
.message-bubble.theirs::after,
.message-bubble.mine::after {
    content: "";
    position: absolute;
    bottom: 0;
    width: 10px;
    height: 10px;
    background: inherit;
}

.bubble.theirs::after,
.message-bubble.theirs::after {
    left: -3px;
    border-bottom-right-radius: 10px;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.bubble.mine::after,
.message-bubble.mine::after {
    right: -3px;
    border-bottom-left-radius: 10px;
    clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.composer .icon-btn,
.composer #sendButton,
.composer #voiceButton,
.composer #attachButton,
.composer #viewOnceButton,
.composer #emojiButton,
.composer #locationButton {
    border-color: rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.045);
    box-shadow: none;
}

.composer .icon-btn:hover,
.composer .icon-btn:focus-visible,
.composer #voiceButton:not(.recording):hover,
.composer #voiceButton:not(.recording):focus-visible {
    border-color: rgba(0, 242, 255, 0.18);
    background: rgba(0, 242, 255, 0.07);
    box-shadow: none;
}

.composer #voiceButton {
    font-size: 0;
}

.composer #voiceButton:not(.recording),
.composer #voiceButton.voice-btn:not(.recording) {
    filter: none;
    box-shadow: none !important;
}

.composer #voiceButton svg {
    width: 19px;
    height: 19px;
}

.composer #voiceButton.recording {
    color: #fff;
    border-color: rgba(255, 0, 184, 0.38);
    background: radial-gradient(circle at 35% 28%, rgba(0, 242, 255, 0.6), rgba(112, 76, 255, 0.72) 48%, rgba(255, 0, 184, 0.78));
    box-shadow: 0 0 22px rgba(255, 0, 184, 0.28), 0 0 18px rgba(0, 242, 255, 0.18);
}

#gifInlineButton {
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    box-shadow: none;
    font-size: 9px;
    letter-spacing: 0.02em;
}

#gifInlineButton:hover,
#gifInlineButton:focus-visible {
    color: #8ff8ff;
    background: rgba(0, 242, 255, 0.08);
    box-shadow: none;
}

.smart-replies {
    padding: 0 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.smart-replies::-webkit-scrollbar {
    display: none;
}

.smart-replies button,
.emoji-panel button {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(18, 27, 41, 0.78);
    color: var(--text-main);
    box-shadow: none;
}

.emoji-panel {
    justify-self: start;
    max-width: min(360px, calc(100vw - 20px));
    padding: 8px;
}

.compact-share-menu .attachment-option,
.attachment-preview,
.view-once-compose-shell {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(18, 27, 41, 0.82);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.attachment-preview .view-once-toggle,
.attachment-preview button,
.view-once-inline-send {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    box-shadow: none;
}

.attachment-preview .view-once-toggle.active,
.view-once-inline-send:not(:disabled) {
    border-color: rgba(0, 242, 255, 0.24);
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.3), rgba(112, 76, 255, 0.38), rgba(255, 0, 184, 0.34));
}

.view-once-compose-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
}

.view-once-compose-shell textarea {
    min-height: 44px;
    max-height: 110px;
    resize: vertical;
    border: 0;
    background: transparent;
    color: var(--text-main);
}

.view-once-inline-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.view-once-inline-send svg {
    width: 18px;
    height: 18px;
}

.voice-wave {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 28px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(0, 242, 255, 0.06);
}

.voice-wave.active {
    display: flex;
}

.voice-wave span {
    width: 3px;
    min-height: 6px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--neon-blue), var(--neon-pink));
    transition: height 80ms ease;
}

.voice-card,
.file-pill,
.location-card,
.poll-card,
.gif-card,
.single-open-media-card {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(15, 24, 38, 0.74);
    box-shadow: none;
}

.voice-card audio {
    width: min(260px, 68vw);
    height: 32px;
}

.bubble .voice-card {
    display: grid;
    gap: 7px;
    width: min(238px, 62vw);
    min-width: 0;
}

.voice-card-head,
.voice-card-actions {
    display: flex;
    align-items: center;
}

.voice-card-head {
    gap: 7px;
    min-width: 0;
}

.voice-card-head strong {
    overflow: hidden;
    font-size: 12px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-card-icon {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: #e0f5ff;
    background: rgba(14, 165, 233, 0.34);
}

.voice-card-icon .nexa-svg {
    width: 15px;
    height: 15px;
}

.voice-card-actions {
    justify-content: space-between;
    gap: 6px;
}

.voice-card-action {
    min-height: 27px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(255, 255, 255, 0.07);
    font-size: 10px;
    font-weight: 700;
}

.voice-transcript-button {
    flex: 1;
}

.voice-card-action .nexa-svg {
    width: 13px;
    height: 13px;
}

.voice-card-action:disabled {
    opacity: 0.58;
}

.voice-transcript {
    max-width: 100%;
    padding: 8px 9px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(2, 8, 23, 0.3);
    font-size: 11px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.bubble .location-card {
    width: min(256px, 66vw);
    min-width: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
}

.location-map-preview {
    position: relative;
    width: 76px;
    height: 72px;
    overflow: hidden;
    border-radius: 12px;
    background:
        linear-gradient(32deg, transparent 46%, rgba(255, 255, 255, 0.24) 47% 53%, transparent 54%),
        linear-gradient(145deg, #0f766e, #155e75 54%, #1d4ed8);
}

.location-map-preview::before,
.location-map-preview::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    background: rgba(120, 255, 188, 0.24);
}

.location-map-preview::before {
    width: 44px;
    height: 22px;
    left: -10px;
    top: 8px;
    transform: rotate(-18deg);
}

.location-map-preview::after {
    width: 38px;
    height: 18px;
    right: -8px;
    bottom: 7px;
    transform: rotate(22deg);
}

.location-map-road {
    position: absolute;
    z-index: 1;
    display: block;
    width: 96px;
    height: 5px;
    border-radius: 999px;
    background: rgba(236, 254, 255, 0.72);
}

.location-map-road.road-one {
    left: -11px;
    top: 27px;
    transform: rotate(32deg);
}

.location-map-road.road-two {
    left: -5px;
    top: 46px;
    transform: rotate(-24deg);
}

.location-map-pin {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 50%;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.86);
    border-radius: 50% 50% 50% 12px;
    color: #fff;
    background: #ff3158;
    box-shadow: 0 5px 16px rgba(255, 49, 88, 0.48);
    transform: translate(-50%, -58%) rotate(-45deg);
}

.location-map-pin .nexa-svg {
    width: 15px;
    height: 15px;
    transform: rotate(45deg);
}

.location-card-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.location-card-copy strong,
.location-card-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-card-copy strong {
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
}

.location-card-copy small {
    color: rgba(255, 255, 255, 0.66);
    font-size: 9px;
    line-height: 1.3;
}

.location-card-arrow {
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.68);
}

.location-card-arrow .nexa-svg {
    width: 16px;
    height: 16px;
}

.bubble.has-voice-attachment,
.bubble.has-location-attachment,
.bubble.has-view-once-attachment {
    width: fit-content;
    min-width: 0;
    max-width: min(82vw, 310px);
}

.bubble.has-voice-attachment .voice-card,
.bubble.has-location-attachment .location-card,
.bubble.has-view-once-attachment .single-open-media-card {
    max-width: 100%;
}

.bubble .single-open-media-card {
    min-width: 0;
    overflow: hidden;
}

.bubble .single-open-media-card .profile-action {
    width: 100%;
    max-width: 220px;
    min-height: 36px;
    padding: 7px 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Stage 4: compact chat interaction system */
.composer {
    grid-template-columns: 36px 36px minmax(0, 1fr) 36px;
    grid-template-areas:
        "suggestions suggestions suggestions suggestions"
        "reply reply reply reply"
        "wave wave wave wave"
        "emoji-panel emoji-panel emoji-panel emoji-panel"
        "preview preview preview preview"
        "attach emoji input action";
    gap: 5px;
    min-height: 54px;
    padding: 5px 9px max(6px, env(safe-area-inset-bottom));
}

#attachButton { grid-area: attach; }
#emojiButton {
    grid-area: emoji;
    display: grid;
}
#messageInputShell { grid-area: input; }
#sendButton,
#voiceButton { grid-area: action; }
#viewOnceButton,
#locationButton { display: none; }

.smart-replies { grid-area: suggestions; }
.reply-preview { grid-area: reply; }
.voice-wave { grid-area: wave; }
.emoji-panel { grid-area: emoji-panel; }
.attachment-preview { grid-area: preview; }

.composer .icon-btn,
.composer #sendButton,
.composer #voiceButton,
.composer #attachButton,
.composer #emojiButton {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: rgba(240, 245, 255, 0.88);
    background: transparent;
}

.composer #sendButton {
    color: #fff;
    background: linear-gradient(135deg, #00cfff, #704cff 52%, #ff00b8);
    box-shadow: 0 5px 18px rgba(112, 76, 255, 0.32);
}

#messageInputShell,
#messageInput {
    min-height: 38px;
    height: 38px;
    max-height: 38px;
}

#messageInputShell {
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(13, 22, 35, 0.82);
}

#messageInput {
    padding: 7px 43px 7px 13px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

#gifInlineButton {
    right: 6px;
    width: 30px;
    height: 30px;
    min-height: 30px;
    border-radius: 10px;
    font-size: 10px;
}

.smart-replies {
    width: 100%;
    gap: 7px;
    padding: 2px 1px 4px;
}

.smart-replies button {
    flex: 0 0 auto;
    min-height: 31px;
    padding: 5px 11px;
    border: 1px solid rgba(112, 76, 255, 0.2);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(27, 39, 61, 0.9), rgba(40, 24, 70, 0.82));
    font-size: 12px;
}

.emoji-panel {
    width: max-content;
    grid-template-columns: repeat(8, 34px);
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 18px;
    background: rgba(11, 18, 30, 0.96);
}

.emoji-panel:not(.hidden) {
    display: grid;
}

.emoji-panel button {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 20px;
}

.attachment-preview {
    grid-template-columns: auto minmax(0, 1fr) 34px 34px;
    gap: 8px;
    min-height: 48px;
    padding: 6px 8px;
    border-radius: 16px;
}

.attachment-preview .view-once-toggle,
.attachment-preview .attachment-clear {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
}

.compact-share-menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    width: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.compact-share-menu .attachment-option {
    min-height: 90px;
    padding: 11px 7px;
    border-radius: 17px;
}

.compact-share-menu .attachment-option-icon {
    width: 38px;
    height: 38px;
}

.gif-card {
    overflow: hidden;
    border: 0;
    background: transparent;
}

.gif-card img {
    display: block;
    border: 0;
    border-radius: 14px;
}

.gif-card .last-message {
    padding: 4px 2px 0;
}

.voice-card,
.file-pill,
.location-card,
.poll-card,
.single-open-media-card,
.call-card {
    width: fit-content;
    max-width: min(290px, 70vw);
    padding: 8px 10px;
    border-radius: 14px;
}

.voice-card audio {
    width: 100%;
    max-width: 100%;
}

.bubble .message-meta,
.bubble .chat-time {
    margin-top: 3px;
}

@media (max-width: 520px) {
    .composer {
        grid-template-columns: 34px 34px minmax(0, 1fr) 34px;
        min-height: 50px;
        padding: 4px 7px max(5px, env(safe-area-inset-bottom));
    }

    .composer .icon-btn,
    .composer #sendButton,
    .composer #voiceButton,
    .composer #attachButton,
    .composer #emojiButton {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }

    #messageInputShell,
    #messageInput {
        min-height: 36px;
        height: 36px;
        max-height: 36px;
    }

    #messageInput {
        padding-right: 40px;
    }

    #gifInlineButton {
        width: 28px;
        height: 28px;
        min-height: 28px;
        right: 5px;
    }

    .emoji-panel {
        width: 100%;
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

/* Stage 5: mobile navigation, stories, PIN and nearby controls */
.story-panel {
    position: fixed;
    inset: 0;
    z-index: 3600;
    width: 100%;
    height: var(--app-height);
    display: grid;
    place-items: center;
    padding:
        calc(12px + var(--safe-top))
        calc(12px + var(--safe-right))
        calc(12px + var(--safe-bottom))
        calc(12px + var(--safe-left));
    overflow: hidden;
    background: rgba(1, 4, 11, 0.82);
    backdrop-filter: blur(24px) saturate(130%);
    -webkit-backdrop-filter: blur(24px) saturate(130%);
    box-sizing: border-box;
}

.story-panel.hidden {
    display: none;
}

.story-box {
    width: min(520px, 100%);
    max-height: 100%;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    background:
        radial-gradient(circle at 20% 0%, rgba(0, 242, 255, 0.11), transparent 34%),
        radial-gradient(circle at 90% 90%, rgba(255, 0, 184, 0.12), transparent 38%),
        rgba(8, 13, 23, 0.92);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.58);
}

.story-head {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#storyBody {
    min-height: 0;
    display: grid;
    align-content: center;
    gap: 14px;
    padding: 16px;
    overflow: auto;
}

.story-media {
    width: 100%;
    max-height: min(66vh, 680px);
    object-fit: contain;
    border-radius: 22px;
}

.story-reply {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.story-action-bar {
    min-height: 0;
    padding: 0 16px 16px;
}

.story-action-bar:empty {
    display: none;
}

.story-reply input {
    min-width: 0;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.9);
    color: #fff;
}

.story-reply button,
.story-delete-button {
    min-height: 48px;
    border-radius: 999px;
}

.story-reply button {
    border-color: rgba(125, 211, 252, 0.72);
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: #02111d;
    font-weight: 800;
    box-shadow: 0 0 22px rgba(56, 189, 248, 0.28);
}

.story-reply button:disabled {
    opacity: 0.56;
    box-shadow: none;
}

.story-delete-button {
    width: 100%;
}

.pin-dots {
    min-height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 12px 0 8px;
}

.pin-dots span {
    width: 12px;
    height: 12px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    background: transparent;
    transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.pin-dots span.filled {
    background: #fff;
    box-shadow: 0 0 14px rgba(124, 77, 255, 0.7);
    transform: scale(1.08);
}

.pin-keypad {
    width: min(286px, 100%);
    display: grid;
    grid-template-columns: repeat(3, 68px);
    justify-content: center;
    gap: 13px 20px;
    margin: 8px auto 4px;
}

.pin-keypad button {
    width: 68px;
    height: 68px;
    min-height: 0;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.075);
    color: #fff;
    font-size: 25px;
    font-weight: 520;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
    transition: transform 120ms ease, background 160ms ease, border-color 160ms ease;
}

.pin-keypad button:active {
    transform: scale(0.92);
    border-color: rgba(124, 77, 255, 0.62);
    background: rgba(124, 77, 255, 0.28);
}

.pin-keypad [data-vault-submit],
.pin-keypad [data-archive-submit] {
    background: linear-gradient(145deg, #5e4bff, #d900c7);
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.25);
}

.archive-lock,
.vault-unlock-card {
    display: grid;
    justify-items: center;
    gap: 8px;
    width: min(100%, 390px);
    margin: 18px auto;
    padding: 20px 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 24px;
    background: rgba(9, 15, 25, 0.72);
}

.nearby-status {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
}

.nearby-status-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #7e8798;
}

.nearby-status.active {
    border-color: rgba(0, 204, 83, 0.24);
    color: #bfffd4;
}

.nearby-status.active .nearby-status-dot {
    background: var(--success);
    box-shadow: 0 0 12px rgba(0, 204, 83, 0.65);
}

.points-panel-body .profile-hero {
    position: relative;
    overflow: hidden;
}

.points-panel-body .profile-hero::after {
    content: "";
    position: absolute;
    inset: -60% auto -60% -35%;
    width: 28%;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 235, 153, 0.2), transparent);
    transform: rotate(18deg);
    animation: points-shimmer 4.8s ease-in-out infinite;
}

.points-panel-body .badge-card.unlocked {
    animation: points-badge-pulse 2.8s ease-in-out infinite;
}

@keyframes points-shimmer {
    0%, 55% { transform: translateX(0) rotate(18deg); opacity: 0; }
    65% { opacity: 1; }
    100% { transform: translateX(640px) rotate(18deg); opacity: 0; }
}

@keyframes points-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 193, 7, 0); }
    50% { box-shadow: 0 0 20px rgba(255, 193, 7, 0.12); }
}

@media (max-width: 860px) {
    .section-head {
        min-height: 48px;
        padding: 8px 14px 10px;
        box-sizing: border-box;
    }

    .section-label {
        min-width: 0;
        font-size: clamp(24px, 7.2vw, 30px);
        line-height: 1.05;
    }

    .nav-tabs {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .nav-tab {
        min-width: 0;
        padding-inline: 1px;
    }

    .nav-tab .nav-label {
        width: auto;
        max-width: 100%;
        overflow: visible;
        font-size: clamp(7.5px, 2.05vw, 9px);
        line-height: 1.05;
        text-overflow: clip;
        white-space: nowrap;
    }

    .story-panel {
        top: var(--viewport-top);
        left: var(--viewport-left);
        width: var(--viewport-width);
        height: var(--app-height);
    }

    .story-box {
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    .story-head {
        min-height: calc(58px + var(--safe-top));
        padding:
            calc(7px + var(--safe-top))
            calc(12px + var(--safe-right))
            7px
            calc(12px + var(--safe-left));
    }

    #storyBody {
        padding:
            12px
            calc(12px + var(--safe-right))
            calc(12px + var(--safe-bottom))
            calc(12px + var(--safe-left));
    }
}

@media (prefers-reduced-motion: reduce) {
    .points-panel-body .profile-hero::after,
    .points-panel-body .badge-card.unlocked {
        animation: none;
    }
}

/* Stage 6: premium call states */
.call-panel .hidden {
    display: none;
}

.video-stage.remote-live .call-cover {
    opacity: 0;
    pointer-events: none;
}

.call-panel.connected-call .call-waveform {
    opacity: 1;
}

.call-panel.offline-call .call-cover > span,
.call-panel.offline-call #callStatus {
    color: #ffb3c2;
}

.call-box .call-actions .icon-btn.control-active {
    border-color: rgba(0, 242, 255, 0.72);
    background: linear-gradient(145deg, #00b8e8, #5f48ef);
    color: #fff;
    box-shadow: 0 0 26px rgba(0, 242, 255, 0.34);
}

.call-box .call-actions .icon-btn[data-label] {
    position: relative;
    overflow: visible;
}

.call-box .call-actions .icon-btn[data-label]::after {
    content: attr(data-label);
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    width: max-content;
    max-width: 78px;
    color: rgba(255, 255, 255, 0.88);
    font-size: 9px;
    font-weight: 560;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
    transform: translateX(-50%);
}

.call-panel.incoming-call .call-actions .icon-btn[data-label]::after {
    max-width: 110px;
    font-size: 11px;
}

.call-panel.incoming-call .call-box .call-actions .icon-btn {
    width: 72px;
    height: 72px;
}

.call-panel.incoming-call .call-actions {
    gap: clamp(68px, 20vw, 150px);
}

.call-panel.incoming-call .accept {
    color: #fff;
    border-color: rgba(45, 226, 103, 0.62);
    background: linear-gradient(145deg, #29dc68, #00a94b);
    box-shadow: 0 0 28px rgba(45, 226, 103, 0.3);
}

.call-panel.video-call.incoming-call .accept {
    border-color: rgba(132, 91, 255, 0.7);
    background: linear-gradient(145deg, #845bff, #5732ca);
    box-shadow: 0 0 30px rgba(132, 91, 255, 0.34);
}

@media (max-width: 640px) {
    .call-panel {
        top: var(--viewport-top);
        left: var(--viewport-left);
        width: var(--viewport-width);
        height: var(--app-height);
        padding: 0;
        background:
            radial-gradient(circle at 50% 36%, rgba(91, 57, 215, 0.18), transparent 42%),
            linear-gradient(180deg, #060815, #02030a 72%);
    }

    .call-box {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: block;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .call-box .video-stage {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .call-box .video-stage > video {
        border-radius: 0;
    }

    .call-box .call-info {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 8;
        min-height: calc(78px + var(--safe-top));
        display: grid;
        grid-template-columns: 1fr;
        place-items: center;
        justify-content: stretch;
        padding:
            calc(14px + var(--safe-top))
            calc(18px + var(--safe-right))
            10px
            calc(18px + var(--safe-left));
        text-align: center;
        pointer-events: none;
    }

    .call-box .call-info > div {
        display: grid;
        place-items: center;
        gap: 4px;
    }

    .call-box #callTitle {
        color: #a783ff;
        font-size: 16px;
        font-weight: 760;
        text-transform: uppercase;
    }

    .call-box #callPeerLine,
    .call-box #callStatus,
    .call-box #callTimer {
        display: none;
    }

    .call-cover {
        padding:
            calc(90px + var(--safe-top))
            calc(22px + var(--safe-right))
            calc(168px + var(--safe-bottom))
            calc(22px + var(--safe-left));
        gap: 10px;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        transition: opacity 220ms ease;
    }

    .call-cover::before {
        inset: 0;
        background:
            radial-gradient(circle at 50% 38%, rgba(104, 66, 238, 0.2), transparent 35%),
            radial-gradient(circle at 50% 68%, rgba(0, 0, 0, 0.24), transparent 44%);
        filter: blur(18px);
    }

    .call-cover strong {
        margin-top: 20px;
        font-size: clamp(32px, 9vw, 46px);
        font-weight: 560;
        text-align: center;
    }

    .call-cover > span {
        min-height: 28px;
        color: rgba(255, 255, 255, 0.72);
        font-size: 19px;
        text-align: center;
    }

    .call-panel.audio-only .call-cover .avatar {
        width: min(58vw, 242px);
        height: min(58vw, 242px);
        border: 3px solid #845bff;
        font-size: 58px;
        box-shadow:
            0 0 0 10px rgba(132, 91, 255, 0.06),
            0 0 0 25px rgba(132, 91, 255, 0.035),
            0 0 42px rgba(132, 91, 255, 0.34);
    }

    .call-panel.audio-only .call-waveform {
        width: min(76vw, 320px);
        transform: translate(-50%, -62%);
    }

    .call-panel.video-call:not(.connected-call) .call-cover {
        justify-content: flex-start;
        padding-top: calc(142px + var(--safe-top));
    }

    .call-panel.video-call:not(.connected-call) .call-cover .avatar {
        width: min(88vw, 430px);
        height: min(54vh, 560px);
        border: 1px solid rgba(132, 91, 255, 0.55);
        border-radius: 38px;
        font-size: 70px;
        background-size: cover;
        box-shadow: 0 0 34px rgba(132, 91, 255, 0.22);
    }

    .call-panel.video-call:not(.connected-call) .call-cover strong {
        order: -2;
        margin: 0 0 2px;
        font-size: clamp(32px, 9vw, 46px);
    }

    .call-panel.video-call:not(.connected-call) .call-cover > span {
        order: -1;
        margin-bottom: 20px;
    }

    .call-box #localVideo {
        top: calc(76px + var(--safe-top));
        right: calc(12px + var(--safe-right));
        bottom: auto;
        width: 112px;
        height: 160px;
        border-radius: 24px;
    }

    .call-box .call-actions {
        position: absolute;
        left: 50%;
        bottom: calc(38px + var(--safe-bottom));
        z-index: 10;
        width: auto;
        min-height: 94px;
        display: flex;
        align-items: flex-start;
        gap: 24px;
        margin: 0;
        padding: 0;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        transform: translateX(-50%);
    }

    .call-box .call-actions .icon-btn {
        width: 62px;
        height: 62px;
        flex: 0 0 auto;
        border: 1px solid rgba(255, 255, 255, 0.1);
        background: rgba(18, 19, 30, 0.9);
        color: #fff;
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.36);
        transform: none;
    }

    .call-box .call-actions .icon-btn:active {
        transform: scale(0.94);
        box-shadow: 0 7px 18px rgba(0, 0, 0, 0.3);
    }

    .call-box .call-actions .icon-btn.danger {
        background: linear-gradient(145deg, #ff3c4f, #e71835);
        box-shadow: 0 0 28px rgba(255, 42, 66, 0.26);
    }

    .call-panel.connected-call.audio-only #endCallButton {
        order: 2;
        width: 82px;
        height: 82px;
        margin-top: -7px;
    }

    .call-panel.connected-call.audio-only #muteButton {
        order: 1;
        width: 70px;
        height: 70px;
    }

    .call-panel.connected-call.audio-only #speakerButton {
        order: 3;
        width: 70px;
        height: 70px;
    }

    .call-panel.incoming-call #endCallButton { order: 1; }
    .call-panel.incoming-call #acceptCallButton { order: 2; }

    .call-panel.connected-call.video-call .call-actions {
        gap: 16px;
    }

    .call-panel.connected-call.video-call #muteButton { order: 1; }
    .call-panel.connected-call.video-call #switchCameraButton { order: 2; }
    .call-panel.connected-call.video-call #cameraButton { order: 3; }
    .call-panel.connected-call.video-call #endCallButton { order: 4; }
}

/* NexaLine iPhone 16 mobile design system */
:root {
    --screen-width: 393px;
    --screen-height: 852px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --page-padding: 16px;
    --content-width: calc(100vw - 32px);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;
    --bottom-nav-height: 70px;
    --bottom-nav-width: calc(100vw - 32px);
    --bottom-nav-bottom: calc(12px + var(--safe-bottom));
    --bg-main: #080A0F;
    --bg-page: #0B0D14;
    --bg-card: #111827;
    --bg-card-soft: #151A23;
    --bg-input: #171C26;
    --border-soft: rgba(255, 255, 255, 0.08);
    --border-active: rgba(139, 92, 246, 0.45);
    --text-main: #FFFFFF;
    --text-muted: #9CA3AF;
    --text-soft: #6B7280;
    --accent-purple: #8B5CF6;
    --accent-violet: #A855F7;
    --accent-indigo: #6366F1;
    --accent-blue: #3B82F6;
    --danger: #EF4444;
    --success: #22C55E;
    --warning: #F59E0B;
    --bg-dark: var(--bg-main);
    --glass-panel: rgba(17, 24, 39, 0.78);
    --glass-panel-strong: rgba(21, 26, 35, 0.9);
    --glass-panel-soft: rgba(21, 26, 35, 0.62);
    --glass-border-color: var(--border-soft);
    --glass-border: 1px solid var(--border-soft);
    --neon-blue: var(--accent-indigo);
    --neon-purple: var(--accent-purple);
    --neon-pink: var(--accent-violet);
    --shadow-deep: 0 18px 50px rgba(0, 0, 0, 0.45);
    --app-height: 100dvh;
}

.mobile-page {
    width: 100vw;
    max-width: var(--screen-width);
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--bg-main);
    color: var(--text-main);
    padding:
        calc(12px + var(--safe-top))
        var(--page-padding)
        calc(96px + var(--safe-bottom));
}

.page-enter {
    opacity: 0;
    transform: translateX(18px);
}

.page-enter-active {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 220ms ease, transform 220ms ease;
}

.page-exit {
    opacity: 1;
    transform: translateX(0);
}

.page-exit-active {
    opacity: 0;
    transform: translateX(-18px);
    transition: opacity 180ms ease, transform 180ms ease;
}

@media (max-width: 860px) {
    html,
    body {
        min-height: 100dvh;
        background: var(--bg-main);
    }

    body {
        color: var(--text-main);
        overflow: hidden;
    }

    .auth-screen,
    .app {
        background:
            radial-gradient(circle at 16% 0%, rgba(139, 92, 246, 0.16), transparent 34%),
            radial-gradient(circle at 95% 10%, rgba(59, 130, 246, 0.1), transparent 32%),
            var(--bg-main);
    }

    .app {
        width: min(100vw, var(--screen-width));
        max-width: var(--screen-width);
        min-height: 100dvh;
        height: 100dvh;
        left: 50%;
        transform: translateX(-50%);
        overflow: hidden;
    }

    .sidebar,
    .chat-pane {
        width: 100%;
        max-width: var(--screen-width);
        min-height: 100dvh;
        height: 100dvh;
        overflow-x: hidden;
        background: var(--bg-main);
        color: var(--text-main);
    }

    .sidebar {
        padding-bottom: calc(96px + var(--safe-bottom));
    }

    .topbar,
    .chat-top {
        min-height: calc(64px + var(--safe-top));
        padding:
            calc(10px + var(--safe-top))
            16px
            10px;
        border-bottom: 0;
        background: linear-gradient(180deg, rgba(8, 10, 15, 0.96), rgba(8, 10, 15, 0.72));
    }

    .search-box {
        padding: 10px 16px 12px;
    }

    .search-box input,
    .field,
    .composer-input,
    #messageInput,
    textarea {
        background: var(--bg-input);
        border: 1px solid var(--border-soft);
        color: var(--text-main);
    }

    .nav-tabs {
        position: fixed;
        left: 16px;
        right: 16px;
        bottom: var(--bottom-nav-bottom);
        width: var(--bottom-nav-width);
        max-width: 361px;
        height: var(--bottom-nav-height);
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: center;
        gap: 0;
        margin: 0 auto;
        padding: 0 6px;
        box-sizing: border-box;
        overflow: hidden;
        contain: paint;
        border: 1px solid var(--border-soft);
        border-radius: var(--radius-xl);
        background: rgba(17, 24, 39, 0.92);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        z-index: 1200;
    }

    .nav-tab {
        width: 100%;
        min-width: 0;
        min-height: 58px;
        display: grid;
        place-items: center;
        align-content: center;
        gap: 3px;
        padding: 4px 0;
        border: 0;
        border-radius: 18px;
        background: transparent;
        color: var(--text-muted);
        box-shadow: none;
        font-size: 9px;
        line-height: 1.05;
        transition: transform 160ms ease, color 160ms ease, background 160ms ease;
    }

    .nav-tab[data-section="stories"] { order: 1; }
    .nav-tab[data-section="calls"] { order: 2; }
    .nav-tab[data-section="explore"] { order: 3; }
    .nav-tab[data-section="chats"] { order: 4; }
    .nav-tab[data-section="contacts"] { order: 5; }

    .nav-tab .nav-icon {
        width: 32px;
        height: 32px;
        display: grid;
        place-items: center;
        border-radius: 14px;
        transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
    }

    .nav-tab .nexa-svg {
        width: 20px;
        height: 20px;
        stroke-width: 1.65;
    }

    .nav-tab .nav-label {
        width: 100%;
        max-width: 64px;
        overflow: hidden;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: inherit;
    }

    .nav-tab.active {
        color: #38bdf8;
        transform: translateY(-3px);
        background: transparent;
        box-shadow: none;
        text-shadow: none;
    }

    .nav-tab.active .nav-icon {
        background: rgba(56, 189, 248, 0.16);
        box-shadow: 0 0 22px rgba(56, 189, 248, 0.4);
    }

    .nav-tab:active {
        transform: scale(0.92);
    }

    .nav-tab.active:active {
        transform: translateY(-3px) scale(0.92);
    }

    .chat-list,
    .contact-list,
    .story-list,
    .scroll-area {
        padding: 0 16px calc(96px + var(--safe-bottom));
        scrollbar-color: rgba(139, 92, 246, 0.42) transparent;
    }

    .chat-item,
    .contact-row,
    .call-row,
    .profile-card,
    .vault-card,
    .ai-card,
    .file-pill {
        border: 1px solid var(--border-soft);
        background: var(--bg-card);
        color: var(--text-main);
        transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
    }

    .chat-item:active,
    .contact-row:active,
    .call-row:active,
    .profile-card:active,
    .vault-card:active,
    .ai-card:active {
        transform: scale(0.98);
    }

    .section-frame-enter {
        animation: mobile-slide-fade 220ms ease both;
    }
}

@keyframes mobile-slide-fade {
    from {
        opacity: 0;
        transform: translateX(18px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Active bottom-tab reselect returns the current section home without snapping. */
@media (max-width: 860px) {
    .chat-list.section-resetting,
    .contact-list.section-resetting,
    .story-list.section-resetting {
        scroll-behavior: auto !important;
        overscroll-behavior-y: none;
        pointer-events: none;
    }

    .section-resetting .chat-item,
    .section-resetting .discover-card,
    .section-resetting .call-item,
    .section-resetting .contact-row,
    .section-resetting .person-card,
    .section-resetting .story-item,
    .section-resetting .update-post {
        animation: section-reset-settle 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
        animation-delay: calc(var(--section-reset-order, 0) * 7ms);
    }

    .nav-tab.section-reset-active .nav-icon {
        animation: section-reset-nav-pulse 260ms cubic-bezier(0.22, 1, 0.36, 1);
    }
}

@keyframes section-reset-settle {
    0% {
        filter: brightness(1.08);
    }

    48% {
        transform: translateY(3px) scale(0.992);
        filter: brightness(1.04);
    }

    100% {
        transform: translateY(0) scale(1);
        filter: brightness(1);
    }
}

@keyframes section-reset-nav-pulse {
    50% {
        transform: translateY(-2px) scale(1.08);
    }
}

/* Compact flow composer and quieter chat-list metadata. */
@media (max-width: 860px) {
    .story-list .x-compose-card {
        padding: 11px;
        border-radius: 20px;
    }

    .x-compose-head {
        gap: 2px;
        margin-bottom: 7px;
    }

    .x-compose-head strong {
        font-size: 14px;
        line-height: 1.2;
    }

    .x-compose-head small {
        font-size: 10px;
        line-height: 1.25;
    }

    .x-compose-card textarea {
        min-height: 52px;
        max-height: 108px;
        padding: 9px 10px;
        resize: none;
        border-radius: 15px;
        font-size: 13px;
        line-height: 1.35;
    }

    .x-compose-card .x-actions {
        margin-top: 8px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .x-compose-card .x-actions button {
        min-width: 0;
        min-height: 34px;
        padding: 6px 9px;
        justify-content: center;
        font-size: 11px;
        line-height: 1;
    }

    .x-compose-card .x-actions #updatesFeedVoiceButton {
        min-width: 62px;
    }

    .chat-list .chat-item > .chat-list-meta {
        min-width: 44px;
        height: 100%;
        padding: 1px 0 2px;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        justify-content: flex-end;
        gap: 3px;
    }

    .chat-list .chat-item > .chat-list-meta .chat-time {
        order: 3;
        color: rgba(156, 163, 175, 0.62);
        font-size: 9px;
        font-weight: 480;
        line-height: 1;
        letter-spacing: 0.01em;
    }

    .chat-list .chat-item > .chat-list-meta .chat-flags {
        order: 1;
    }

    .chat-list .chat-item > .chat-list-meta .badge {
        order: 2;
    }

    .chat-list .chat-item > .chat-time {
        align-self: end;
        margin-bottom: 2px;
        color: rgba(156, 163, 175, 0.58);
        font-size: 9px;
        font-weight: 480;
        line-height: 1;
    }
}

.bubble,
.message-bubble,
.message-context-popover {
    -webkit-touch-callout: none;
}

.bubble .message-text,
.message-bubble .message-text,
.message-context-popover button,
.message-context-popover p,
.message-context-popover span {
    -webkit-user-select: none;
    user-select: none;
}

.bubble ::selection,
.message-bubble ::selection,
.message-context-popover ::selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text-main);
}

/* Stage 2: chats and people mobile cards */
@media (max-width: 860px) {
    .chat-mode-switch {
        width: 100%;
        min-height: 46px;
        margin: 0 0 12px;
        padding: 4px;
        border: 1px solid var(--border-soft);
        border-radius: var(--radius-pill);
        background: var(--bg-input);
        box-shadow: none;
    }

    .chat-mode-switch::before {
        inset: 4px 50% 4px 4px;
        border-radius: var(--radius-pill);
        background: linear-gradient(135deg, var(--accent-purple), var(--accent-indigo));
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.24);
        transition: transform 220ms ease;
    }

    .chat-mode-switch.groups-active::before {
        transform: translateX(100%);
    }

    .chat-mode-switch button {
        min-height: 38px;
        padding: 0 10px;
        border-radius: var(--radius-pill);
        color: var(--text-muted);
        font-size: 13px;
        font-weight: 760;
    }

    .chat-mode-switch button.active {
        color: #fff;
    }

    .chat-search-shell,
    .contact-search-shell {
        margin: 0 0 12px;
        border-radius: var(--radius-lg);
        background: var(--bg-input);
        border: 1px solid var(--border-soft);
    }

    .chat-list .chat-item,
    .chat-list-item {
        width: 100%;
        height: 74px;
        min-height: 74px;
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        margin: 0 0 10px;
        padding: 12px;
        border-radius: var(--radius-lg);
        background: var(--bg-card);
        border: 1px solid var(--border-soft);
        box-shadow: none;
        text-align: left;
    }

    .chat-list .chat-item.active {
        border-color: var(--border-active);
        background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(17, 24, 39, 0.96));
        box-shadow: 0 0 22px rgba(139, 92, 246, 0.16);
    }

    .chat-list .chat-item .avatar,
    .chat-list-item .avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
    }

    .chat-list .chat-item > div:not(.avatar),
    .chat-list-item > div:not(.avatar) {
        min-width: 0;
    }

    .chat-title,
    .last-message {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-side,
    .chat-time {
        min-width: max-content;
    }

    .person-card,
    .contact-list-row {
        width: 100%;
        height: 72px;
        min-height: 72px;
        display: grid;
        grid-template-columns: 46px minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        margin: 0 0 10px;
        padding: 12px;
        border-radius: var(--radius-lg);
        background: var(--bg-card);
        border: 1px solid var(--border-soft);
        color: var(--text-main);
        box-shadow: none;
    }

    .person-card .avatar,
    .contact-list-row .avatar {
        width: 46px;
        height: 46px;
        border-radius: 50%;
    }

    .contact-list-side {
        min-width: 0;
        justify-items: end;
    }

    .request-button {
        height: 34px;
        min-height: 34px;
        padding: 0 14px;
        border-radius: var(--radius-pill);
        background: var(--accent-purple);
        color: #fff;
        font-size: 12px;
        font-weight: 780;
        white-space: nowrap;
        box-shadow: 0 0 18px rgba(139, 92, 246, 0.22);
        transition: transform 180ms ease, box-shadow 180ms ease;
    }

    .request-button:active {
        transform: scale(0.94);
        box-shadow: 0 0 10px rgba(139, 92, 246, 0.18);
    }

    .request-button.pending {
        max-width: 112px;
        padding: 0 10px;
        overflow: hidden;
        border: 1px solid rgba(56, 189, 248, 0.34);
        background: rgba(56, 189, 248, 0.12);
        color: #7dd3fc;
        font-size: 10px;
        text-overflow: ellipsis;
        box-shadow: 0 0 18px rgba(56, 189, 248, 0.16);
    }

    .nav-tab .nav-badge {
        position: absolute;
        z-index: 3;
        top: 2px;
        right: 8px;
        min-width: 17px;
        height: 17px;
        display: grid;
        place-items: center;
        padding: 0 4px;
        border: 2px solid #111827;
        border-radius: 999px;
        background: #38bdf8;
        color: #04111d;
        font-size: 9px;
        font-weight: 900;
        line-height: 1;
        opacity: 0;
        transform: scale(0.72);
        transition: opacity 160ms ease, transform 160ms ease;
        pointer-events: none;
    }

    .nav-tab .nav-badge.visible {
        opacity: 1;
        transform: scale(1);
    }

    .contacts-inline-header {
        gap: 12px;
        margin: 0 0 12px;
    }

    .contact-results-frame .section-mini-title {
        padding: 2px 2px 8px;
        color: var(--text-muted);
    }
}

/* Stage 3: discover and updates mobile surfaces */
@media (max-width: 860px) {
    .explore-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        padding-bottom: calc(96px + var(--safe-bottom));
    }

    .discover-card,
    .explore-card {
        width: 100%;
        min-height: 92px;
        display: grid;
        grid-template-columns: 46px minmax(0, 1fr) auto;
        align-items: center;
        gap: 14px;
        margin: 0;
        padding: 18px;
        border-radius: 22px;
        background: linear-gradient(135deg, #111827, #171C26);
        border: 1px solid var(--border-soft);
        box-shadow: none;
    }

    .discover-card[data-explore-module="ai"] {
        border-color: rgba(139, 92, 246, 0.32);
        background:
            radial-gradient(circle at 8% 0%, rgba(139, 92, 246, 0.28), transparent 34%),
            linear-gradient(135deg, #111827, #171C26);
        box-shadow: 0 0 28px rgba(139, 92, 246, 0.16);
    }

    .discover-card .attachment-option-icon,
    .explore-card .attachment-option-icon {
        width: 46px;
        height: 46px;
        border-radius: 16px;
        border: 1px solid transparent;
        box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
    }

    .discover-card[data-explore-module="ai"] .attachment-option-icon {
        color: #67e8f9;
        border-color: rgba(103, 232, 249, 0.3);
        background: linear-gradient(145deg, rgba(8, 145, 178, 0.3), rgba(99, 102, 241, 0.24));
        box-shadow: 0 0 24px rgba(34, 211, 238, 0.18);
    }

    .discover-card[data-explore-module="play"] .attachment-option-icon {
        color: #ff3b5c;
        border-color: rgba(255, 59, 92, 0.34);
        background: linear-gradient(145deg, rgba(127, 29, 29, 0.34), rgba(244, 63, 94, 0.18));
        box-shadow: 0 0 24px rgba(255, 59, 92, 0.18);
    }

    .discover-card[data-explore-module="play"] .attachment-option-icon .nexa-svg {
        fill: currentColor;
        stroke-width: 1.05;
    }

    .discover-card[data-explore-module="nearby"] .attachment-option-icon {
        color: #4ade80;
        border-color: rgba(74, 222, 128, 0.34);
        background: linear-gradient(145deg, rgba(5, 150, 105, 0.3), rgba(14, 165, 233, 0.2));
        box-shadow: 0 0 24px rgba(74, 222, 128, 0.16);
    }

    .discover-card[data-explore-module="vault"] .attachment-option-icon {
        color: #fbbf24;
        border-color: rgba(251, 191, 36, 0.34);
        background: linear-gradient(145deg, rgba(180, 83, 9, 0.3), rgba(245, 158, 11, 0.16));
        box-shadow: 0 0 24px rgba(251, 191, 36, 0.16);
    }

    .story-row {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 0 8px;
        scrollbar-width: none;
    }

    .story-row::-webkit-scrollbar {
        display: none;
    }

    .story-row .story-item {
        flex: 0 0 68px;
        min-height: 88px;
        padding: 0;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .story-avatar,
    .story-row .story-item .story-avatar {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        padding: 3px;
        background: linear-gradient(135deg, #8B5CF6, #3B82F6);
        box-shadow: none;
    }

    .x-feed {
        gap: 12px;
        padding: 0 0 20px;
    }

    .x-compose-card,
    .update-post {
        border-radius: 20px;
        background: var(--bg-card);
        border: 1px solid var(--border-soft);
        padding: 14px;
        box-shadow: none;
    }

    .x-feed-list {
        display: grid;
        gap: 12px;
    }

    .voice-post,
    .x-feed-audio {
        height: 54px;
        min-height: 54px;
        display: flex;
        align-items: center;
        gap: 10px;
        overflow: hidden;
        border-radius: var(--radius-pill);
        background: var(--bg-input);
        border: 1px solid var(--border-soft);
        padding: 0 12px;
    }

    .voice-post audio,
    .voice-post details,
    .voice-post .x-audio-wave {
        display: none;
    }
}

/* Stage 4: profile simplification and Asistan plus menu */
.profile-notes-grid {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

@media (max-width: 860px) {
    .profile-metrics-grid {
        display: none;
    }

    .profile-note-card {
        width: 100%;
        min-height: 72px;
        border-radius: var(--radius-lg);
        background: var(--bg-card);
        border: 1px solid var(--border-soft);
        color: var(--text-main);
        text-align: left;
    }

    .modal-panel.sheet.ai-plus-menu:not(.hidden) {
        position: fixed;
        inset: auto;
        top: auto;
        left: 16px;
        right: 16px;
        bottom: calc(92px + var(--safe-bottom));
        width: calc(100vw - 32px);
        max-width: 361px;
        height: auto;
        max-height: calc(100dvh - 120px - var(--safe-bottom));
        display: block;
        margin: 0 auto;
        border-radius: var(--radius-xl);
        background: rgba(17, 24, 39, 0.96);
        border: 1px solid var(--border-soft);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 12px;
        place-items: initial;
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    }

    .ai-plus-menu .modal-box {
        width: 100%;
        max-height: min(560px, calc(100dvh - 140px - var(--safe-bottom)));
        padding: 12px;
        border: 0;
        border-radius: 20px;
        background: transparent;
        box-shadow: none;
    }

    .ai-plus-menu .nexal-command-list {
        display: grid;
        gap: 8px;
    }

    .ai-plus-menu .nexal-command-card {
        min-height: 54px;
        border-radius: 18px;
        background: var(--bg-card-soft);
        border: 1px solid var(--border-soft);
    }
}

/* Stage 6: stacked chat cards */
@media (max-width: 860px) {
    #chatList {
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }

    #chatList .chat-mode-content.has-chat-stack {
        position: relative;
        min-height: calc(100% + 1px);
        padding-bottom: 0;
    }

    #chatList .chat-stack-spacer {
        width: 100%;
        height: calc(100dvh + var(--safe-bottom));
        pointer-events: none;
    }

    #chatList .chat-mode-content.has-chat-stack > .chat-item {
        position: sticky;
        top: var(--chat-stack-top, 0px);
        z-index: var(--chat-stack-z, 20);
        transform-origin: top center;
        background: linear-gradient(135deg, var(--bg-card), var(--bg-card-soft));
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.24), 0 12px 28px rgba(0, 0, 0, 0.3);
        transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
    }

    #chatList .chat-mode-content.has-chat-stack > .chat-item:active {
        transform: scale(0.98);
    }
}

/* Stage 8: phased chat controls and persistent stack */
@media (max-width: 860px) {
    #chatList .chat-list-controls {
        position: relative;
        z-index: 80;
        min-width: 0;
        padding-top: 1px;
    }

    #chatList .chat-list-controls .chat-mode-switch {
        position: sticky;
        top: 0;
        z-index: 2;
        margin-top: 0;
        background: rgba(23, 28, 38, 0.98);
        box-shadow: 0 10px 22px rgba(8, 10, 15, 0.34);
    }

    #chatList .chat-list-controls .chat-search-shell {
        position: relative;
        z-index: 1;
        transform-origin: top center;
        background: var(--bg-input);
        box-shadow: 0 -10px 20px rgba(8, 10, 15, 0.18);
    }

    #chatList .chat-mode-content.has-chat-stack > .chat-item:last-of-type {
        box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.32), 0 16px 34px rgba(0, 0, 0, 0.38);
    }
}

/* Stage 9: persistent discover stack */
@media (max-width: 860px) {
    .sidebar[data-active-section="explore"] #exploreList:not(.hidden) {
        display: block;
        grid-template-rows: none;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }

    #exploreList .explore-grid.has-discover-stack {
        position: relative;
        display: block;
        padding-bottom: 0;
    }

    #exploreList .explore-grid.has-discover-stack > .discover-card {
        position: sticky;
        top: var(--discover-stack-top, 0px);
        z-index: var(--discover-stack-z, 30);
        margin: 0 0 12px;
        transform-origin: top center;
        box-shadow: 0 -9px 26px rgba(0, 0, 0, 0.28), 0 14px 32px rgba(0, 0, 0, 0.34);
        transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
    }

    #exploreList .discover-stack-spacer {
        width: 100%;
        height: calc(100dvh + var(--safe-bottom));
        pointer-events: none;
    }
}

/* Stage 10: settings header alignment and bottom pull close affordance */
@media (max-width: 860px) {
    .settings-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
    }

    .settings-head > div:first-child {
        min-width: 0;
    }

    #closeSettingsButton {
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        margin-left: auto;
    }
}

/* Stage 11: settings-only vault entry and destructive reset */
.settings-vault-choice-grid {
    display: grid;
    gap: 12px;
}

.settings-vault-choice {
    width: 100%;
    min-height: 84px;
    padding: 14px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08));
    border-radius: 22px;
    background: linear-gradient(135deg, #111827, #171c26);
    color: var(--text-main);
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.settings-vault-choice:active {
    transform: scale(0.98);
}

.settings-vault-choice > span:nth-child(2) {
    display: grid;
    gap: 4px;
}

.settings-vault-choice small {
    line-height: 1.35;
}

.settings-vault-choice-arrow {
    color: var(--text-muted);
    font-size: 24px;
}

.settings-vault-choice.danger-option {
    border-color: rgba(239, 68, 68, 0.26);
    background: linear-gradient(135deg, rgba(64, 19, 28, 0.92), rgba(35, 17, 25, 0.96));
}

.settings-vault-choice.danger-option strong,
.settings-vault-choice.danger-option .settings-vault-choice-arrow {
    color: #ff8b9a;
}

.vault-reset-warning {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 20px 16px;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.28);
    border-radius: 22px;
    background: rgba(64, 19, 28, 0.52);
}

.vault-reset-warning p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Stage 12: chat-to-vault actions and sender groups */
.media-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.media-actions > a,
.media-actions > button {
    min-height: 38px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
}

.vault-grouped-content {
    display: grid;
    gap: 12px;
}

.vault-sender-card {
    width: 100%;
    min-height: 72px;
    padding: 12px;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08));
    border-radius: 18px;
    background: var(--bg-card, #111827);
    color: var(--text-main);
    transition: transform 180ms ease, border-color 180ms ease;
}

.vault-sender-card:active {
    transform: scale(0.98);
}

.vault-sender-card > span:nth-child(2) {
    display: grid;
    gap: 4px;
}

.vault-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.vault-group-header > span {
    display: grid;
    gap: 2px;
}

.vault-saved-item {
    width: 100%;
    display: grid;
    align-items: start;
    gap: 10px;
}

.vault-saved-text {
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--bg-input, #171c26);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.vault-saved-media,
.vault-saved-media > * {
    width: 100%;
    max-width: 100%;
}

.vault-saved-media img,
.vault-saved-media video {
    max-height: 320px;
    object-fit: contain;
    border-radius: 16px;
}

.vault-saved-media audio {
    width: 100%;
}

.vault-unlock-card.hidden,
.vault-list.hidden {
    display: none;
}

/* Stage 13: responsive mobile account switcher */
.account-switcher-list {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 10px;
}

.account-switcher-row {
    width: 100%;
    min-width: 0;
    min-height: 82px;
    padding: 12px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 7px;
    overflow: hidden;
    border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08));
    border-radius: 18px;
    background: var(--bg-card, #111827);
    color: var(--text-main, #fff);
}

.account-switcher-row.account-active {
    border-color: var(--border-active, rgba(139, 92, 246, 0.45));
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.13), rgba(17, 24, 39, 0.98));
}

.account-switcher-avatar {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 44px;
    height: 44px;
    align-self: center;
}

.account-switcher-copy {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    display: grid;
    gap: 3px;
}

.account-switcher-copy .chat-title,
.account-switcher-copy .last-message {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-switcher-actions {
    grid-column: 2;
    grid-row: 2;
    width: min(100%, 132px);
    min-width: 0;
    justify-self: end;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.account-switcher-actions .mini-btn {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    height: 34px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1;
}

.account-switcher-switch:disabled {
    opacity: 1;
    cursor: default;
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.16);
    border-color: rgba(139, 92, 246, 0.32);
}

@media (max-width: 360px) {
    .account-switcher-row {
        grid-template-columns: 40px minmax(0, 1fr);
        padding: 10px;
    }

    .account-switcher-avatar {
        width: 40px;
        height: 40px;
    }
}

/* Stage 14: visual viewport driven chat layout for mobile keyboards */
@media (max-width: 860px) {
    html,
    body {
        height: var(--app-height);
        min-height: var(--app-height);
        max-height: var(--app-height);
        overflow: hidden;
    }

    .app {
        top: var(--viewport-top);
        width: min(var(--viewport-width), var(--screen-width));
        height: var(--app-height);
        min-height: 0;
        max-height: var(--app-height);
        overflow: hidden;
        will-change: top, height;
    }

    .sidebar,
    .chat-pane {
        height: 100%;
        min-height: 0;
        max-height: 100%;
    }

    .chat-pane {
        grid-template-rows: auto minmax(0, 1fr) auto;
        overflow: hidden;
    }

    .messages {
        min-height: 0;
        overscroll-behavior-y: contain;
        scroll-padding-bottom: calc(var(--composer-height) + 16px);
    }

    .composer {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        max-width: 100%;
        transform: translateZ(0);
        will-change: transform;
    }

    .app.keyboard-open .composer {
        padding-bottom: 6px;
    }

    .app.keyboard-open .messages {
        padding-bottom: calc(var(--composer-height) + 14px);
    }
}

/* Stage 15: message long-press glass capsule */
.bubble.message-pressing,
.message-bubble.message-pressing {
    transform: scale(0.985);
    filter: brightness(1.08);
    transition: transform 120ms ease, filter 120ms ease;
}

.bubble.message-menu-anchor,
.message-bubble.message-menu-anchor {
    transform: scale(1.015);
    filter: brightness(1.12);
}

.modal-panel.message-context-popover {
    display: block;
    padding: 0;
    background: rgba(2, 5, 10, 0.34);
    backdrop-filter: blur(8px) saturate(112%);
    -webkit-backdrop-filter: blur(8px) saturate(112%);
    animation: message-context-backdrop-in 180ms ease both;
}

.message-context-popover .modal-box {
    position: fixed;
    top: var(--message-menu-top, 50%);
    left: var(--message-menu-left, 50%);
    width: min(318px, calc(100vw - 20px));
    max-height: min(620px, calc(var(--app-height) - 20px));
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 24px;
    background: transparent;
    box-shadow: none;
    transform-origin: var(--message-menu-origin-x, 50%) top;
    animation: message-context-capsule-in 180ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
}

.message-context-popover.opens-above .modal-box {
    transform-origin: var(--message-menu-origin-x, 50%) bottom;
}

.message-context-popover .modal-head,
.message-context-popover .modal-actions {
    display: none;
}

.message-context-popover .modal-body,
.message-context-actions {
    display: grid;
    gap: 8px;
}

.message-reaction-row {
    width: max-content;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 7px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(20, 25, 32, 0.94);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(22px) saturate(135%);
    -webkit-backdrop-filter: blur(22px) saturate(135%);
}

.message-reaction-row button {
    width: 45px;
    height: 45px;
    min-height: 45px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: transparent;
    font-size: 25px;
    transition: transform 140ms ease, background 140ms ease;
}

.message-reaction-row button:active {
    transform: scale(1.18);
    background: rgba(139, 92, 246, 0.18);
}

.message-action-capsule {
    max-height: min(500px, calc(var(--app-height) - 94px));
    padding: 8px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    background: rgba(18, 26, 31, 0.96);
    box-shadow: 0 22px 54px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(24px) saturate(130%);
    -webkit-backdrop-filter: blur(24px) saturate(130%);
}

.message-context-summary {
    max-height: 46px;
    margin: 0 4px 5px;
    padding: 7px 9px;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.045);
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    line-height: 1.35;
}

.message-context-row {
    display: grid;
    gap: 2px;
}

.message-context-row + .message-context-row {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.message-context-row button {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: 25px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-radius: 13px;
    background: transparent;
    color: rgba(255, 255, 255, 0.94);
    text-align: left;
    transition: transform 140ms ease, background 140ms ease;
}

.message-context-row button .nexa-svg {
    width: 21px;
    height: 21px;
}

.message-context-row button:active {
    transform: scale(0.975);
    background: rgba(255, 255, 255, 0.08);
}

.message-context-row button.danger-action {
    color: #fb7185;
}

.message-context-extra.hidden {
    display: none;
}

.message-context-extra:not(.hidden) {
    animation: message-context-extra-in 160ms ease both;
}

.message-context-popover.message-context-closing {
    pointer-events: none;
    animation: message-context-backdrop-out 160ms ease both;
}

.message-context-popover.message-context-closing .modal-box {
    animation: message-context-capsule-out 160ms cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes message-context-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes message-context-backdrop-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes message-context-capsule-in {
    from { opacity: 0; transform: translateY(8px) scale(0.84); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes message-context-capsule-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(6px) scale(0.88); }
}

@keyframes message-context-extra-in {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 380px) {
    .message-context-popover .modal-box {
        width: min(304px, calc(100vw - 16px));
    }

    .message-reaction-row button {
        width: 42px;
        height: 42px;
        min-height: 42px;
        font-size: 23px;
    }
}

/* Stage 9: account-wide chat theme picker */
.settings-theme-card {
    width: 100%;
    min-width: 0;
    min-height: 76px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 72px;
    align-items: center;
    gap: 11px;
    padding: 11px;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.16);
    border-radius: 19px;
    background:
        radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.12), transparent 46%),
        rgba(13, 20, 31, 0.92);
    color: var(--text-main);
    text-align: left;
    box-shadow: none;
}

.settings-theme-card:active {
    transform: scale(0.985);
}

.settings-theme-icon {
    position: relative;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 14px;
    background:
        conic-gradient(from 35deg, #38bdf8, #6366f1, #a855f7, #38bdf8);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.16);
}

.settings-theme-icon::after {
    content: "";
    width: 17px;
    height: 17px;
    border: 3px solid rgba(8, 10, 15, 0.82);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.82);
}

.settings-theme-copy,
.settings-theme-current,
.chat-theme-picker-intro > span:last-child {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.settings-theme-copy strong,
.chat-theme-picker-intro strong {
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.25;
}

.settings-theme-copy small,
.chat-theme-picker-intro small {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}

.settings-theme-current {
    justify-items: center;
    gap: 4px;
}

.settings-theme-current img {
    width: 52px;
    height: 40px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 11px;
    background: #080a0f;
}

.settings-theme-current span {
    width: 68px;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.74);
    font-size: 9px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-picker-panel .modal-box {
    width: min(680px, calc(100vw - 32px));
    max-height: min(780px, calc(100dvh - 32px));
    border: 1px solid rgba(56, 189, 248, 0.16);
    background:
        radial-gradient(circle at 90% 0, rgba(99, 102, 241, 0.12), transparent 34%),
        rgba(8, 13, 22, 0.98);
}

.theme-picker-panel .modal-body {
    gap: 13px;
    overscroll-behavior: contain;
}

.chat-theme-picker-intro {
    min-width: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: rgba(17, 24, 39, 0.82);
}

.chat-theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 11px;
}

.chat-theme-picker-card {
    position: relative;
    min-width: 0;
    min-height: 190px;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 19px;
    background: #080a0f;
    box-shadow: none;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.chat-theme-picker-card:active {
    transform: scale(0.965);
}

.chat-theme-picker-card img {
    width: 100%;
    height: 190px;
    display: block;
    object-fit: cover;
}

.chat-theme-picker-card::after {
    content: attr(title);
    position: absolute;
    right: 7px;
    bottom: 7px;
    left: 7px;
    padding: 7px 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    background: rgba(3, 6, 12, 0.72);
    color: #fff;
    font-size: 11px;
    font-weight: 720;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    backdrop-filter: blur(12px);
}

.chat-theme-picker-card.active {
    border-color: var(--picker-accent, #38bdf8);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--picker-accent, #38bdf8) 30%, transparent),
        0 13px 32px rgba(0, 0, 0, 0.32);
}

.chat-theme-picker-check {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 8px;
    width: 29px;
    height: 29px;
    display: grid;
    place-items: center;
    opacity: 0;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    background: var(--picker-accent, #38bdf8);
    color: #fff;
    transform: scale(0.72);
    transition: opacity 160ms ease, transform 160ms ease;
}

.chat-theme-picker-check svg {
    width: 16px;
    height: 16px;
}

.chat-theme-picker-card.active .chat-theme-picker-check {
    opacity: 1;
    transform: scale(1);
}

.chat-pane[data-theme] .chat-top {
    border-color: var(--chat-theme-border, rgba(255, 255, 255, 0.08));
    background: var(--chat-theme-top-panel, rgba(5, 10, 18, 0.84));
}

.chat-pane[data-theme] .composer {
    border-color: var(--chat-theme-border, rgba(255, 255, 255, 0.08));
    background: var(--chat-theme-bottom-panel, rgba(7, 14, 24, 0.9));
}

.chat-pane[data-theme] .message-input-shell,
.chat-pane[data-theme] #messageInput {
    border-color: var(--chat-theme-border, rgba(255, 255, 255, 0.08));
    background: var(--chat-theme-input, rgba(13, 24, 38, 0.86));
    color: var(--chat-theme-text, #fff);
}

.chat-pane[data-theme] .chat-top .icon-btn,
.chat-pane[data-theme] .composer .icon-btn,
.chat-pane[data-theme] .gif-inline-button {
    color: var(--chat-theme-icon, #7dd3fc);
}

@media (max-width: 520px) {
    .theme-picker-panel {
        align-items: stretch;
        padding: 0;
    }

    .theme-picker-panel .modal-box {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
        border-width: 0;
        border-radius: 0;
    }

    .theme-picker-panel .modal-body {
        padding-right: 1px;
    }

    .chat-theme-picker-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .chat-theme-picker-card,
    .chat-theme-picker-card img {
        min-height: 178px;
        height: 178px;
    }
}

/* Stage 16: native-feeling chat transition and message theme */
.messages {
    background-color: var(--chat-theme-bg, #030406);
    background-image: var(--chat-theme-image, none);
    background-size: var(--chat-theme-size, cover);
    background-repeat: var(--chat-theme-repeat, no-repeat);
}

.bubble,
.message-bubble {
    max-width: min(78%, 560px);
    padding: 10px 13px 7px;
    border: 1px solid var(--chat-theme-border, rgba(255, 255, 255, 0.09));
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 15px;
    line-height: 1.34;
    isolation: isolate;
}

.bubble.theirs,
.message-bubble.theirs {
    border-radius: 23px 23px 23px 8px;
    background: var(--chat-theme-incoming, linear-gradient(145deg, #777a76, #8d908b));
    color: var(--chat-theme-incoming-text, #fff);
}

.bubble.mine,
.message-bubble.mine,
.mine .bubble,
.mine .message-bubble {
    border-radius: 23px 23px 8px 23px;
    background: var(--chat-theme-outgoing, linear-gradient(145deg, #0a84ff, #0072e6));
    color: var(--chat-theme-outgoing-text, #fff);
}

.bubble .message-text {
    min-width: 34px;
    white-space: pre-wrap;
}

.bubble .sender {
    margin: 0 0 3px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 11px;
    font-weight: 760;
    line-height: 1.2;
}

.messages[data-chat-type="direct"] .bubble .sender,
.messages[data-chat-type="ai"] .bubble .sender {
    display: none;
}

.bubble .message-meta {
    min-height: 13px;
    margin: 3px 0 0 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    color: rgba(255, 255, 255, 0.68);
    font-size: 10px;
    font-weight: 520;
    line-height: 1;
    text-align: right;
    white-space: nowrap;
}

.bubble .bubble-time {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
}

.bubble .ticks {
    min-width: 12px;
    margin-left: 3px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    letter-spacing: -3px;
}

.bubble .ticks.read {
    color: #b8e4ff;
}

.bubble::selection,
.bubble *::selection {
    background: rgba(139, 92, 246, 0.48);
    color: #fff;
}

@media (max-width: 860px) {
    .app.chat-opening .sidebar,
    .app.chat-closing .sidebar {
        display: block;
    }

    .app.chat-opening .chat-pane,
    .app.chat-closing .chat-pane {
        position: absolute;
        inset: 0;
        z-index: 60;
        display: grid;
        overflow: hidden;
        background: var(--bg-main);
        contain: paint;
        backface-visibility: hidden;
        will-change: transform;
    }

    .app.chat-opening .chat-pane {
        animation: mobile-chat-pane-in 220ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
    }

    .app.chat-closing .chat-pane {
        pointer-events: none;
        animation: mobile-chat-pane-out 180ms cubic-bezier(0.4, 0, 0.8, 0.2) both;
    }

    .app.chat-opening .bubble {
        animation: mobile-chat-message-in 190ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
        animation-delay: var(--message-enter-delay, 0ms);
    }

    .messages {
        padding-right: 12px;
        padding-left: 12px;
    }

    .bubble,
    .message-bubble {
        max-width: min(84%, 330px);
        font-size: 15px;
    }
}

@keyframes mobile-chat-pane-in {
    from {
        opacity: 0.7;
        transform: translateX(28px) scale(0.992);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes mobile-chat-pane-out {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(30px, 0, 0);
    }
}

@keyframes mobile-chat-message-in {
    from {
        opacity: 0;
        transform: translateY(7px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Stage 17: timed story viewer and gesture transitions */
.story-panel {
    --story-drag-x: 0px;
    --story-drag-y: 0px;
    --story-drag-opacity: 1;
    touch-action: none;
}

.story-panel.story-opening {
    animation: story-backdrop-in 220ms ease both;
}

.story-panel.story-closing {
    pointer-events: none;
    animation: story-backdrop-out 180ms ease both;
}

.story-panel.story-opening .story-box {
    animation: story-viewer-in 220ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
}

.story-panel.story-closing .story-box {
    animation: story-viewer-out 180ms cubic-bezier(0.4, 0, 0.8, 0.2) both;
}

.story-panel.story-dragging {
    background: rgba(1, 4, 11, 0.68);
}

.story-panel.story-dragging .story-box {
    opacity: var(--story-drag-opacity);
    transform: translate3d(var(--story-drag-x), var(--story-drag-y), 0) scale(0.992);
    transition: none;
}

.story-box {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    transform-origin: center;
    transition: transform 180ms ease, opacity 180ms ease;
}

.story-progress {
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 4px;
    padding: 9px 12px 0;
}

.story-progress-segment {
    height: 3px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
}

.story-progress-fill {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: #fff;
    transform: scaleX(0);
    transform-origin: left center;
}

.story-progress-segment.complete .story-progress-fill {
    transform: scaleX(1);
}

.story-progress-segment.active:not(.video-progress) .story-progress-fill {
    animation: story-progress-fill var(--story-duration, 5000ms) linear both;
}

.story-panel.story-paused .story-progress-segment.active .story-progress-fill {
    animation-play-state: paused;
}

#storyBody.story-content-enter.story-forward {
    animation: story-content-forward 190ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
}

#storyBody.story-content-enter.story-backward {
    animation: story-content-backward 190ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
}

#storyBody .story-text {
    margin: 0;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    background: rgba(17, 24, 39, 0.72);
    color: #fff;
    font-size: clamp(18px, 5.2vw, 25px);
    line-height: 1.36;
    text-align: center;
}

#storyBody .story-media {
    width: 100%;
    max-height: min(72dvh, 680px);
    border-radius: 20px;
    background: #000;
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
    user-select: none;
    -webkit-user-drag: none;
}

@media (max-width: 860px) {
    .story-panel {
        padding: 0;
        background: #02040a;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .story-box {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border: 0;
        border-radius: 0;
        background:
            radial-gradient(circle at 50% 18%, rgba(56, 189, 248, 0.1), transparent 34%),
            #02040a;
        box-shadow: none;
    }

    .story-progress {
        padding:
            calc(7px + var(--safe-top))
            calc(12px + var(--safe-right))
            0
            calc(12px + var(--safe-left));
    }

    .story-head {
        min-height: 58px;
        padding:
            7px
            calc(12px + var(--safe-right))
            7px
            calc(12px + var(--safe-left));
        border-bottom-color: rgba(255, 255, 255, 0.06);
    }

    #storyBody {
        place-items: center;
        padding: 0;
        overflow: hidden;
    }

    #storyBody:not(.story-has-media) {
        align-content: center;
    }

    #storyBody.story-has-media:not(.story-has-copy) {
        grid-template-rows: minmax(0, 1fr);
    }

    #storyBody.story-has-media.story-has-copy {
        grid-template-rows: auto minmax(0, 1fr);
        align-content: stretch;
        gap: 10px;
        padding-top: 8px;
    }

    #storyBody .story-media {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        box-shadow: none;
    }

    #storyBody .story-text {
        width: min(88%, 520px);
        max-height: 100%;
        overflow: auto;
        box-sizing: border-box;
    }

    #storyBody.story-has-media .story-text {
        padding: 10px 14px;
        font-size: 15px;
    }

    .story-action-bar {
        padding:
            10px
            calc(12px + var(--safe-right))
            calc(12px + var(--safe-bottom))
            calc(12px + var(--safe-left));
        background: linear-gradient(to top, rgba(2, 4, 10, 0.98), rgba(2, 4, 10, 0.72));
    }
}

@keyframes story-progress-fill {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes story-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes story-backdrop-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes story-viewer-in {
    from { opacity: 0; transform: translateY(16px) scale(0.94); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes story-viewer-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(12px) scale(0.95); }
}

@keyframes story-content-forward {
    from { opacity: 0; transform: translateX(20px) scale(0.99); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes story-content-backward {
    from { opacity: 0; transform: translateX(-20px) scale(0.99); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* Stage 18: finger-following glass capsule navigation */
@media (max-width: 860px) {
    .nav-tabs {
        --indicator-left: 6px;
        --indicator-top: 8px;
        --indicator-width: 58px;
        --indicator-height: 54px;
        --indicator-intensity: 1;
        isolation: isolate;
        overflow: hidden;
        box-sizing: border-box;
        contain: paint;
        touch-action: none;
    }

    .nav-tabs::before {
        content: "";
        position: absolute;
        z-index: 0;
        left: var(--indicator-left);
        top: var(--indicator-top);
        width: var(--indicator-width);
        height: var(--indicator-height);
        max-width: calc(100% - 14px);
        max-height: calc(100% - 12px);
        box-sizing: border-box;
        pointer-events: none;
        border: 1px solid rgba(125, 211, 252, 0.38);
        border-radius: 20px;
        background:
            radial-gradient(circle at 35% 18%, rgba(255, 255, 255, 0.24), transparent 38%),
            linear-gradient(145deg, rgba(56, 189, 248, 0.4), rgba(14, 165, 233, 0.22));
        box-shadow:
            inset 0 1px rgba(255, 255, 255, 0.16),
            0 0 24px rgba(56, 189, 248, 0.34),
            0 10px 24px rgba(0, 0, 0, 0.28);
        backdrop-filter: blur(16px) saturate(145%);
        -webkit-backdrop-filter: blur(16px) saturate(145%);
        transform: translateZ(0);
        transition:
            left 220ms cubic-bezier(0.2, 0.82, 0.24, 1),
            top 220ms cubic-bezier(0.2, 0.82, 0.24, 1),
            width 180ms ease,
            height 180ms ease,
            background 160ms ease,
            border-color 160ms ease,
            box-shadow 160ms ease;
        will-change: left, top, width, height;
    }

    .nav-tabs.indicator-no-transition::before,
    .nav-tabs.indicator-following::before {
        transition: none;
    }

    .nav-tabs.indicator-following::before {
        border-color: rgba(125, 211, 252, 0.28);
        background:
            radial-gradient(circle at 35% 18%, rgba(255, 255, 255, 0.18), transparent 38%),
            linear-gradient(145deg, rgba(56, 189, 248, 0.25), rgba(14, 165, 233, 0.13));
        box-shadow:
            inset 0 1px rgba(255, 255, 255, 0.14),
            0 0 18px rgba(56, 189, 248, 0.24),
            0 8px 18px rgba(0, 0, 0, 0.24);
    }

    .nav-tabs.indicator-hot::before {
        border-color: rgba(186, 230, 253, 0.7);
        background:
            radial-gradient(circle at 35% 16%, rgba(255, 255, 255, 0.38), transparent 40%),
            linear-gradient(145deg, rgba(56, 189, 248, 0.68), rgba(14, 165, 233, 0.44));
        box-shadow:
            inset 0 1px rgba(255, 255, 255, 0.24),
            0 0 32px rgba(56, 189, 248, 0.56),
            0 12px 26px rgba(0, 0, 0, 0.3);
    }

    .nav-tabs .nav-tab {
        --nav-focus: 0;
        --nav-lift: 0px;
        --nav-icon-lift: 0px;
        --nav-icon-scale: 1;
        --nav-icon-glow: 0px;
        --nav-icon-bg: transparent;
        position: relative;
        z-index: 1;
        background: transparent;
        transform: translateY(var(--nav-lift));
        transition:
            color 160ms ease,
            transform 160ms ease,
            opacity 160ms ease;
        will-change: transform;
    }

    .nav-tabs .nav-tab.active {
        --nav-focus: 1;
        --nav-lift: -3px;
        --nav-icon-lift: -2px;
        --nav-icon-scale: 1.14;
        --nav-icon-glow: 9px;
        --nav-icon-bg: rgba(56, 189, 248, 0.08);
    }

    .nav-tabs .nav-tab .nav-icon {
        transform:
            translateY(var(--nav-icon-lift))
            scale(var(--nav-icon-scale));
        filter: drop-shadow(0 0 var(--nav-icon-glow) rgba(56, 189, 248, 0.82));
        transition:
            transform 160ms ease,
            filter 160ms ease;
        will-change: transform;
    }

    .nav-tabs.nav-interpolating .nav-tab,
    .nav-tabs.nav-interpolating .nav-tab .nav-icon {
        transition: none;
    }

    .nav-tabs .nav-tab.active .nav-icon {
        background: transparent;
        box-shadow: none;
        filter: drop-shadow(0 0 9px rgba(56, 189, 248, 0.8));
    }

    .nav-tabs .nav-tab.active {
        color: #38bdf8;
    }

    .nav-tabs .nav-tab.nav-preview {
        color: #7dd3fc;
    }

    .nav-tabs .nav-tab.nav-preview .nav-icon {
        background: var(--nav-icon-bg);
    }
}

/* Stage 19: full-screen account switcher */
@media (max-width: 860px) {
    .modal-panel.account-switcher-panel {
        inset: auto;
        top: var(--viewport-top);
        left: var(--viewport-left);
        width: var(--viewport-width);
        height: var(--app-height);
        max-width: var(--viewport-width);
        max-height: var(--app-height);
        padding: 0;
        display: block;
        overflow: hidden;
        background: rgba(2, 4, 9, 0.7);
        backdrop-filter: blur(16px) saturate(120%);
        -webkit-backdrop-filter: blur(16px) saturate(120%);
        animation: account-switcher-backdrop-in 300ms ease both;
    }

    .account-switcher-panel .modal-box {
        width: 100%;
        height: 100%;
        max-height: 100%;
        padding: 0;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background:
            radial-gradient(circle at 10% 0%, rgba(139, 92, 246, 0.16), transparent 32%),
            linear-gradient(180deg, #080a0f, #0b0d14);
        box-shadow: none;
        transform-origin: calc(16px + 22px) calc(var(--safe-top) + 30px);
        animation: account-switcher-grow-down 320ms cubic-bezier(0.2, 0.82, 0.24, 1) both;
    }

    .account-switcher-panel .modal-head {
        min-height: calc(64px + var(--safe-top));
        margin: 0;
        padding:
            calc(10px + var(--safe-top))
            calc(16px + var(--safe-right))
            10px
            calc(16px + var(--safe-left));
        border-bottom: 1px solid var(--border-soft);
        background: rgba(8, 10, 15, 0.76);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .account-switcher-panel .modal-head strong {
        font-size: 19px;
        font-weight: 820;
    }

    .account-switcher-panel #modalCloseButton {
        width: 42px;
        height: 42px;
        min-height: 42px;
        margin-left: auto;
        border: 1px solid var(--border-soft);
        border-radius: 50%;
        background: var(--bg-card-soft);
        color: #fff;
    }

    .account-switcher-panel .modal-body {
        min-height: 0;
        padding:
            16px
            calc(16px + var(--safe-right))
            18px
            calc(16px + var(--safe-left));
        align-content: start;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
    }

    .account-switcher-panel .account-switcher-list {
        gap: 12px;
    }

    .account-switcher-panel .account-switcher-row {
        min-height: 94px;
        padding: 14px;
        grid-template-columns: 48px minmax(0, 1fr);
        grid-template-rows: minmax(42px, auto) auto;
        column-gap: 12px;
        row-gap: 10px;
        border-radius: 20px;
        background: var(--bg-card);
        box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
    }

    .account-switcher-panel .account-switcher-avatar {
        width: 48px;
        height: 48px;
    }

    .account-switcher-panel .account-switcher-copy {
        align-self: center;
    }

    .account-switcher-panel .account-switcher-copy .chat-title {
        font-size: 15px;
    }

    .account-switcher-panel .account-switcher-copy .last-message {
        color: var(--text-muted);
        font-size: 12px;
    }

    .account-switcher-panel .account-switcher-actions {
        grid-column: 1 / -1;
        grid-row: 2;
        width: min(100%, 176px);
        justify-self: end;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .account-switcher-panel .account-switcher-actions .mini-btn {
        min-height: 36px;
        height: 36px;
        padding: 0 10px;
        border-radius: 999px;
        font-size: 12px;
    }

    .account-switcher-panel .modal-actions {
        min-height: calc(70px + var(--safe-bottom));
        margin: 0;
        padding:
            10px
            calc(16px + var(--safe-right))
            calc(10px + var(--safe-bottom))
            calc(16px + var(--safe-left));
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        border-top: 1px solid var(--border-soft);
        background: rgba(8, 10, 15, 0.88);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .account-switcher-panel .modal-actions .mini-btn {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 0 12px;
        overflow: hidden;
        border-radius: 16px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .modal-panel.account-switcher-panel.account-switcher-closing {
        pointer-events: none;
        animation: account-switcher-backdrop-out 280ms ease both;
    }

    .account-switcher-panel.account-switcher-closing .modal-box {
        animation: account-switcher-shrink-up 280ms cubic-bezier(0.4, 0, 0.8, 0.2) both;
    }
}

/* Stage 21: settings-style Nexa Points panel */
@media (max-width: 860px) {
    .modal-panel.points-panel {
        inset: auto;
        top: var(--viewport-top);
        left: var(--viewport-left);
        width: var(--viewport-width);
        height: var(--app-height);
        max-width: var(--viewport-width);
        max-height: var(--app-height);
        display: block;
        padding: 0;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background: rgba(3, 7, 14, 0.88);
        transform-origin: top right;
        animation: settings-panel-grow-down 0.34s cubic-bezier(0.2, 0.82, 0.24, 1) both;
    }

    .modal-panel.points-panel .modal-box {
        width: 100%;
        height: 100%;
        max-height: 100%;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background:
            radial-gradient(circle at 82% 5%, rgba(245, 190, 48, 0.1), transparent 30%),
            var(--bg-main);
        box-shadow: none;
        transform-origin: top right;
        animation: none;
    }

    .modal-panel.points-panel .modal-head {
        min-height: calc(64px + var(--safe-top));
        margin: 0;
        padding:
            calc(10px + var(--safe-top))
            calc(12px + var(--safe-right))
            10px
            calc(16px + var(--safe-left));
        border-bottom: 1px solid var(--border-soft);
        background: rgba(8, 10, 15, 0.86);
        backdrop-filter: blur(22px);
        -webkit-backdrop-filter: blur(22px);
    }

    .modal-panel.points-panel .modal-head > strong {
        font-size: 18px;
    }

    .modal-panel.points-panel .modal-head .icon-btn {
        width: 42px;
        height: 42px;
        margin-left: auto;
        border: 1px solid var(--border-soft);
        border-radius: 50%;
        background: var(--bg-card-soft);
    }

    .modal-panel.points-panel .modal-body {
        min-height: 0;
        grid-auto-rows: max-content;
        align-content: start;
        padding:
            14px
            calc(14px + var(--safe-right))
            calc(22px + var(--safe-bottom))
            calc(14px + var(--safe-left));
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .modal-panel.points-panel .modal-actions {
        display: none;
    }

    .modal-panel.points-panel.points-panel-closing {
        pointer-events: none;
        animation: settings-panel-shrink-up 0.28s cubic-bezier(0.4, 0, 0.8, 0.2) both;
    }

    .points-panel-loading {
        min-height: calc(var(--app-height) - 180px);
        display: grid;
        place-items: center;
        align-content: center;
        gap: 10px;
        text-align: center;
        color: var(--text-muted);
    }

    .points-panel-loading .points-star {
        width: 58px;
        height: 58px;
        display: grid;
        place-items: center;
        border: 1px solid rgba(245, 190, 48, 0.32);
        border-radius: 20px;
        background: rgba(245, 190, 48, 0.12);
        color: #ffe59a;
        font-size: 25px;
        box-shadow: 0 0 28px rgba(245, 190, 48, 0.18);
        animation: points-badge-pulse 1.4s ease-in-out infinite;
    }

    .points-panel-loading strong {
        color: var(--text-main);
    }
}

/* Stage 22: continuous glass mode switchers */
@media (max-width: 860px) {
    .chat-mode-switch {
        --mode-progress: 0;
        --mode-color: rgb(0, 190, 68);
        --mode-left-color: rgb(0, 190, 68);
        --mode-right-color: rgb(214, 30, 48);
        --mode-left-text: #fff;
        --mode-right-text: #fff;
        --mode-color-soft: rgba(0, 190, 68, 0.96);
        --mode-lens: 0;
        --mode-left-scale: 1.075;
        --mode-right-scale: 1;
        --mode-left-opacity: 1;
        --mode-right-opacity: 0.6;
        isolation: isolate;
        overflow: hidden;
        touch-action: pan-y;
        background: rgba(9, 14, 24, 0.94);
        border-color: rgba(255, 255, 255, 0.1);
        box-shadow:
            inset 0 1px rgba(255, 255, 255, 0.045),
            0 10px 26px rgba(0, 0, 0, 0.22);
        backdrop-filter: blur(20px) saturate(125%);
        -webkit-backdrop-filter: blur(20px) saturate(125%);
    }

    #chatList .chat-list-controls .chat-mode-switch {
        background: rgba(17, 24, 39, 0.82);
    }

    .chat-mode-switch::before,
    .chat-mode-switch.groups-active::before {
        left: 4px;
        right: auto;
        width: calc(50% - 4px);
        height: calc(100% - 8px);
        inset-block: 4px;
        border: 1px solid color-mix(in srgb, var(--mode-color) 82%, white);
        border-radius: var(--radius-pill);
        background:
            radial-gradient(circle at 34% 16%, rgba(255, 255, 255, 0.34), transparent 46%),
            linear-gradient(145deg, color-mix(in srgb, var(--mode-color) 78%, white), var(--mode-color-soft));
        box-shadow:
            inset 0 1px rgba(255, 255, 255, 0.13),
            0 8px 18px rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(18px) saturate(140%);
        -webkit-backdrop-filter: blur(18px) saturate(140%);
        transform:
            translateX(calc(var(--mode-progress) * 100%))
            scale(calc(1 + var(--mode-lens) * 0.045));
        transform-origin: center;
        transition:
            transform 340ms cubic-bezier(0.18, 0.82, 0.22, 1),
            background 180ms ease,
            border-color 180ms ease,
            box-shadow 180ms ease;
        will-change: transform, background, box-shadow;
    }

    .chat-mode-switch.mode-switch-dragging::before {
        transition: background 50ms linear, border-color 50ms linear, box-shadow 50ms linear;
    }

    .chat-mode-switch button {
        color: #f8faff;
        text-shadow:
            0 1px 2px rgba(0, 0, 0, 0.58),
            0 0 7px rgba(255, 255, 255, 0.16);
        transition:
            color 180ms ease,
            opacity 180ms ease,
            transform 180ms ease;
        will-change: transform, opacity;
    }

    .chat-mode-switch button:first-child {
        color: var(--mode-left-text);
        opacity: var(--mode-left-opacity);
        transform: scale(var(--mode-left-scale));
    }

    .chat-mode-switch button:nth-child(2) {
        color: var(--mode-right-text);
        opacity: var(--mode-right-opacity);
        transform: scale(var(--mode-right-scale));
    }

    .chat-mode-switch button:not(.active) {
        filter: saturate(0.92) brightness(0.94);
    }

    .chat-mode-switch button.active {
        font-weight: 850;
        letter-spacing: 0.005em;
    }

    .chat-mode-switch.mode-switch-dragging button,
    .chat-mode-switch.mode-switch-settling button {
        filter: saturate(1.08) brightness(1.04);
    }
}

@keyframes account-switcher-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes account-switcher-backdrop-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes account-switcher-grow-down {
    from {
        opacity: 0.24;
        transform: translate(-8px, -14px) scale(0.14);
        border-radius: 50%;
    }
    58% {
        opacity: 1;
        transform: translate(0, 0) scale(1.015);
        border-radius: 18px;
    }
    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
        border-radius: 0;
    }
}

@keyframes account-switcher-shrink-up {
    from {
        opacity: 1;
        transform: translate(0, 0) scale(1);
        border-radius: 0;
    }
    to {
        opacity: 0;
        transform: translate(-8px, -14px) scale(0.14);
        border-radius: 50%;
    }
}

/* Stage 7: readable chat preferences and online identity */
.online-strip {
    display: flex;
    gap: 10px;
    padding: 2px 2px 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.online-strip::-webkit-scrollbar {
    display: none;
}

.online-chip {
    flex: 0 0 64px;
    min-width: 0;
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 5px 2px;
    border: 0;
    background: transparent;
    color: var(--text-main);
    scroll-snap-align: start;
}

.online-chip .avatar {
    width: 52px;
    height: 52px;
}

.online-chip > span {
    width: 100%;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.online-chip .avatar.online,
.chat-top #activeAvatar.online,
.chat-preferences-panel .chat-pref-profile .avatar.online {
    position: relative;
    overflow: visible;
    outline: 0;
}

.online-chip .avatar.online::after,
.chat-top #activeAvatar.online::after,
.chat-preferences-panel .chat-pref-profile .avatar.online::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 11px;
    height: 11px;
    box-sizing: border-box;
    border: 2px solid #080a0f;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.72);
}

.chat-preferences-panel .modal-box {
    width: min(580px, 100%);
    overscroll-behavior: contain;
}

.chat-preferences-panel .modal-body {
    gap: 14px;
}

.chat-pref-profile {
    min-width: 0;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 13px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 20px;
    background:
        radial-gradient(circle at 10% 10%, rgba(56, 189, 248, 0.12), transparent 42%),
        rgba(14, 21, 33, 0.88);
}

.chat-pref-profile .avatar {
    width: 58px;
    height: 58px;
}

.chat-pref-profile > div:last-child {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.chat-pref-profile strong,
.sound-row-copy strong {
    color: var(--text-main);
}

.chat-pref-profile .last-message,
.sound-row-copy small {
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.chat-pref-toggles {
    gap: 9px;
}

.chat-pref-toggles .toggle-row {
    min-height: 56px;
    background: rgba(13, 20, 31, 0.9);
}

.chat-pref-section {
    min-width: 0;
    display: grid;
    gap: 9px;
}

.chat-pref-title {
    padding: 0 2px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 750;
}

.chat-pref-theme-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}

.chat-pref-theme-grid .theme-card {
    min-width: 0;
    min-height: 116px;
    display: grid;
    grid-template-rows: 78px auto;
    gap: 7px;
    padding: 7px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(13, 20, 31, 0.92);
    color: var(--text-main);
    box-shadow: none;
}

.chat-pref-theme-grid .theme-card.active {
    border-color: var(--theme-accent, #38bdf8);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-accent, #38bdf8) 24%, transparent);
}

.chat-pref-theme-grid .theme-preview {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 12px;
    background-color: var(--preview-bg);
    background-image: var(--preview-image);
    background-position: center;
    background-repeat: var(--preview-repeat);
    background-size: var(--preview-size);
}

.chat-pref-theme-grid .theme-preview::before,
.chat-pref-theme-grid .theme-preview::after {
    content: "";
    position: absolute;
    width: 54%;
    height: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9px;
}

.chat-pref-theme-grid .theme-preview::before {
    left: 7px;
    top: 17px;
    background: var(--preview-incoming);
}

.chat-pref-theme-grid .theme-preview::after {
    right: 7px;
    bottom: 15px;
    background: var(--preview-outgoing);
}

.chat-pref-theme-grid .theme-card strong {
    min-width: 0;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.25;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sound-panel {
    min-width: 0;
    display: grid;
    gap: 9px;
}

.sound-row {
    min-width: 0;
    min-height: 64px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(13, 20, 31, 0.9);
}

.sound-row-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.sound-row-copy small {
    display: block;
    line-height: 1.35;
}

.sound-test-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0 0 0 2px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(56, 189, 248, 0.22);
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.1);
    color: #7dd3fc;
    box-shadow: none;
}

.chat-pref-select {
    width: 100%;
    min-height: 44px;
    padding: 0 38px 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 15px;
    background-color: rgba(13, 20, 31, 0.92);
    color: var(--text-main);
    font-size: 14px;
}

.chat-pref-select option {
    background: #111827;
    color: #fff;
}

@media (max-width: 520px) {
    .chat-preferences-panel .modal-box {
        padding: 15px;
    }

    .chat-preferences-panel .modal-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .chat-preferences-panel .modal-actions .mini-btn {
        width: 100%;
        min-width: 0;
        min-height: 42px;
        padding: 8px 7px;
        overflow: hidden;
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
