/* ============================================================================
   CipherChat — clean iMessage / Telegram style theme
   Light-first, cool-neutral palette with a proper dark theme.
   One accent = iMessage blue (#0a84ff). Green only for presence dots,
   red only for danger. Flat surfaces, hairline dividers, system fonts.
   ========================================================================== */

/* ------------------------------- Tokens ---------------------------------- */
:root {
    /* Approved mockup tokens (light) */
    --bg: #ffffff;
    --panel: #ffffff;
    --sidebar: #ffffff;
    --field: #ecedf0;
    --incoming: #e9e9eb;
    --incoming-ink: #111114;
    --outgoing: #0a84ff;
    --outgoing-ink: #ffffff;
    --ink: #111114;
    --ink-2: #8b8b90;
    --ink-3: #b6b6bb;
    --hairline: #e6e6ea;
    --hairline-strong: #d7d7dc;
    --accent: #0a84ff;
    --online: #34c759;
    --active: #f1f1f4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Legacy aliases the HTML/JS still reference — remapped to new palette.
       They point at the themed tokens above, so they follow light/dark. */
    --primary-color: var(--accent);
    --primary-hover: #0a74e6;
    --primary-glow: transparent;
    --secondary-color: var(--accent);
    --danger-color: #ff453a;
    --danger-hover: #e5342b;
    --warning-color: var(--ink-2);
    --success-color: var(--online);
    --text-main: var(--ink);
    --text-muted: var(--ink-2);
    --text-dark: #ffffff;
    --glass-border: var(--hairline);
    --glass-bg: var(--panel);
    --glass-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    --glass-highlight: transparent;
    --font-heading: var(--font);
    --font-body: var(--font);
    --sidebar-width: 340px;
    --header-height: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --panel: #0a0a0c;
        --sidebar: #0a0a0c;
        --field: #1c1c1f;
        --incoming: #262629;
        --incoming-ink: #f2f2f4;
        --outgoing: #0a84ff;
        --outgoing-ink: #ffffff;
        --ink: #f2f2f4;
        --ink-2: #98989f;
        --ink-3: #636369;
        --hairline: #1f1f22;
        --hairline-strong: #2a2a2e;
        --accent: #0a84ff;
        --online: #34c759;
        --active: #17171a;
        --shadow: none;
        --glass-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    }
}

:root[data-theme="light"] {
    --bg: #ffffff; --panel: #ffffff; --sidebar: #ffffff; --field: #ecedf0;
    --incoming: #e9e9eb; --incoming-ink: #111114; --outgoing: #0a84ff; --outgoing-ink: #fff;
    --ink: #111114; --ink-2: #8b8b90; --ink-3: #b6b6bb; --hairline: #e6e6ea;
    --hairline-strong: #d7d7dc; --accent: #0a84ff; --online: #34c759; --active: #f1f1f4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04); --glass-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}

:root[data-theme="dark"] {
    --bg: #000; --panel: #0a0a0c; --sidebar: #0a0a0c; --field: #1c1c1f;
    --incoming: #262629; --incoming-ink: #f2f2f4; --outgoing: #0a84ff; --outgoing-ink: #fff;
    --ink: #f2f2f4; --ink-2: #98989f; --ink-3: #636369; --hairline: #1f1f22;
    --hairline-strong: #2a2a2e; --accent: #0a84ff; --online: #34c759; --active: #17171a;
    --shadow: none; --glass-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    display: flex;
    justify-content: center;
    align-items: center;
}

button,
input {
    font-family: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

.hidden {
    display: none !important;
}

::selection {
    background: rgba(10, 132, 255, .18);
}

/* Scrollbars — quiet */
.contacts-scroll-container::-webkit-scrollbar,
.social-scroll-container::-webkit-scrollbar,
.messages-log::-webkit-scrollbar,
.checkbox-scroll-list::-webkit-scrollbar,
.group-members-settings-list::-webkit-scrollbar,
.dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.contacts-scroll-container::-webkit-scrollbar-thumb,
.social-scroll-container::-webkit-scrollbar-thumb,
.messages-log::-webkit-scrollbar-thumb,
.checkbox-scroll-list::-webkit-scrollbar-thumb,
.group-members-settings-list::-webkit-scrollbar-thumb,
.dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--hairline-strong);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

#app-root {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Flat surface — replaces the old glassmorphism panel */
.glass-panel {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    overflow: hidden;
}

/* ------------------------------- Buttons --------------------------------- */
.btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
    color: var(--ink);
    background: var(--field);
}

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

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

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

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

.btn-secondary {
    background: var(--field);
    color: var(--ink);
    border-color: var(--hairline-strong);
}

.btn-secondary:hover {
    background: var(--active);
}

.btn-danger {
    background: var(--danger-color);
    color: #fff;
}

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

.btn-round {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    flex: none;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1.05rem;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease, color .18s ease;
}

.btn-icon:hover {
    background: var(--active);
}

/* --------------------------- Authentication ------------------------------ */
#auth-container {
    width: 400px;
    max-width: 92%;
    padding: 32px 30px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: relative;
}

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

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 6px;
}

.logo-icon {
    font-size: 1.7rem;
    color: var(--accent);
}

.logo h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.subtitle {
    font-size: 0.85rem;
    color: var(--ink-2);
}

.auth-form h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
    text-align: center;
    color: var(--ink);
}

.form-warning-info {
    background: var(--field);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 0.78rem;
    color: var(--ink-2);
    margin-bottom: 18px;
    line-height: 1.45;
}

.form-warning-info i {
    color: var(--accent);
    margin-right: 4px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink-2);
}

.input-group label i {
    margin-right: 4px;
    color: var(--ink-3);
}

.input-group input {
    background: var(--field);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--ink);
    font-size: 0.95rem;
    transition: border-color .18s ease, background .18s ease;
}

.input-group input::placeholder {
    color: var(--ink-3);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg);
}

.switch-form-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--ink-2);
    margin-top: 14px;
}

.switch-form-text a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.switch-form-text a:hover {
    text-decoration: underline;
}

.auth-footer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--ink-3);
    margin-top: 4px;
}

.keep-logged-in-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    margin-top: -4px;
    user-select: none;
}

.keep-logged-in-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
}

.keep-logged-in-row label {
    margin: 0;
    font-weight: 400;
    font-size: 0.88rem;
    color: var(--ink-2);
    cursor: pointer;
}

/* ---------------------------- Dashboard shell ---------------------------- */
#messenger-dashboard {
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    display: flex;
    background: var(--bg);
}

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

.sidebar-header {
    min-height: var(--header-height);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--hairline);
    gap: 8px;
}

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

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: none;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
    flex: none;
}

.my-avatar {
    background: #7d8fa6;
}

.profile-details {
    min-width: 0;
}

.profile-details h3 {
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    font-size: 0.76rem;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}

.dot.online {
    background-color: var(--online);
}

.dot.offline {
    background-color: var(--ink-3);
}

/* Sidebar tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--hairline);
}

.sidebar-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--ink-2);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 12px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    position: relative;
    transition: color .18s ease;
}

.sidebar-tab:hover {
    color: var(--ink);
}

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

.sidebar-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 15%;
    width: 70%;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent);
    display: inline-block;
}

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

/* Search box */
.search-box-container {
    padding: 10px 12px;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-2);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    background: var(--field);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 14px 9px 34px;
    color: var(--ink);
    font-size: 0.9rem;
    transition: border-color .18s ease, background .18s ease;
}

.search-input-wrapper input::placeholder {
    color: var(--ink-3);
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg);
}

/* New-group icon button in the search row */
.search-box-container .btn-icon {
    color: var(--accent);
    flex: none;
}

/* ------------------------------- Contacts -------------------------------- */
.contacts-scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 12px;
    min-height: 0;
}

#contacts-list {
    list-style: none;
}

.contact-item {
    padding: 9px 8px;
    display: flex;
    align-items: center;
    gap: 11px;
    cursor: pointer;
    border-radius: 12px;
    transition: background .15s ease;
}

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

.contact-item.active {
    background: var(--active);
}

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

.contact-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.contact-name {
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-time {
    font-size: 0.76rem;
    color: var(--ink-2);
    flex: none;
    font-variant-numeric: tabular-nums;
}

.contact-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.contact-last-msg {
    font-size: 0.86rem;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.unread-badge {
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0 6px;
    height: 20px;
    min-width: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
    flex: none;
}

.contact-item .group-badge {
    background: var(--field);
    color: var(--ink-2);
    font-size: 0.66rem;
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex: none;
}

.group-avatar {
    background: #5ac8fa !important;
}

/* ------------------------------ Social panel ----------------------------- */
.social-scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
}

.social-section h4 {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-2);
    margin-bottom: 9px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    gap: 6px;
}

.social-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.social-empty-state {
    font-size: 0.83rem;
    color: var(--ink-3);
    text-align: center;
    padding: 14px 6px;
    line-height: 1.5;
}

.social-item {
    background: var(--field);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.social-item .username {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.social-actions {
    display: flex;
    gap: 6px;
    flex: none;
}

.request-status-label {
    font-size: 0.74rem;
    color: var(--ink-2);
    background: var(--bg);
    border: 1px solid var(--hairline);
    padding: 4px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Small action buttons */
.btn-mini {
    padding: 6px 11px;
    font-size: 0.76rem;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}

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

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

.btn-mini-success {
    background: var(--accent);
    color: #fff;
}

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

.btn-mini-danger {
    background: var(--danger-color);
    color: #fff;
}

.btn-mini-danger:hover {
    background: var(--danger-hover);
}

.btn-mini-secondary {
    background: var(--bg);
    color: var(--ink);
    border-color: var(--hairline-strong);
}

.btn-mini-secondary:hover {
    background: var(--active);
}

/* ---------------------------- Chat container ----------------------------- */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

.chat-placeholder-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 40px;
    text-align: center;
}

.placeholder-icon {
    font-size: 3.4rem;
    color: var(--ink-3);
    opacity: 0.5;
    margin-bottom: 4px;
}

.chat-placeholder-view h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.chat-placeholder-view p {
    font-size: 0.92rem;
    color: var(--ink-2);
    max-width: 360px;
    line-height: 1.5;
}

.security-badge-item {
    font-size: 0.8rem;
    color: var(--ink-2);
    background: var(--field);
    padding: 7px 14px;
    border-radius: 999px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.security-badge-item i {
    color: var(--ink-2);
}

.security-limit-notice {
    border: 1px solid var(--hairline);
    border-radius: 12px;
    max-width: 420px;
    line-height: 1.45;
}

.security-limit-notice i,
.security-limit-banner i {
    color: var(--warning-color);
}

.active-chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.chat-header {
    min-height: var(--header-height);
    padding: 9px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--hairline);
    background: var(--panel);
}

.active-user-info {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    flex: 1;
}

.peer-avatar {
    background: #8e8e93;
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
}

.peer-details {
    min-width: 0;
}

.peer-details h3 {
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.peer-details span {
    font-size: 0.78rem;
    color: var(--ink-2);
}

.peer-details span.online {
    color: var(--online);
}

.chat-actions {
    display: flex;
    gap: 1px;
    flex: none;
}

.chat-actions .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 0.98rem;
}

.call-action-btn {
    background: none;
}

.call-action-btn:hover {
    background: var(--active);
}

/* Back button — only shown on mobile single-pane */
.back-btn {
    display: none;
    flex: none;
}

/* E2EE info banner — quiet hairline strip */
.e2e-info-banner {
    background: var(--field);
    border-bottom: 1px solid var(--hairline);
    color: var(--ink-2);
    font-size: 0.75rem;
    text-align: center;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
}

.e2e-info-banner.secured {
    color: var(--ink-2);
}

.e2e-info-banner.secured i {
    color: var(--online);
}

.security-limit-banner {
    border-bottom-color: var(--hairline);
}

/* ------------------------------ Messages --------------------------------- */
.messages-log-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.messages-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
}

/* No-messages empty state */
.chat-empty-state {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--ink-3);
    text-align: center;
    padding: 30px;
}

.chat-empty-state .chat-empty-emoji {
    font-size: 1.8rem;
}

.chat-empty-state .chat-empty-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--ink-2);
}

.chat-empty-state .chat-empty-sub {
    font-size: 0.84rem;
    color: var(--ink-3);
}

.message-bubble-wrapper {
    display: flex;
    width: 100%;
    position: relative;
    animation: msgRise .28s cubic-bezier(.2, .7, .3, 1) both;
}

.message-bubble-wrapper.sent {
    justify-content: flex-end;
}

.message-bubble-wrapper.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 74%;
    padding: 7px 12px;
    border-radius: 18px;
    font-size: 0.97rem;
    line-height: 1.34;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.message-bubble-wrapper.sent .message-bubble {
    background: var(--outgoing);
    color: var(--outgoing-ink);
    border-bottom-right-radius: 5px;
}

.message-bubble-wrapper.received .message-bubble {
    background: var(--incoming);
    color: var(--incoming-ink);
    border-bottom-left-radius: 5px;
}

.message-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.sender-tag {
    font-size: 0.74rem;
    font-weight: 600;
    margin-bottom: 2px;
    display: block;
}

.message-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
}

.message-bubble-wrapper.received .message-meta {
    color: var(--ink-2);
}

.message-bubble-wrapper.sent .message-meta {
    color: rgba(255, 255, 255, .72);
}

.message-meta i {
    font-size: 0.72rem;
}

.message-meta .e2e-lock {
    color: inherit;
    opacity: 0.75;
}

/* Read / delivered / sent ticks (always on own = blue bubbles) */
.status-ticks {
    font-size: 0.72rem;
    margin-left: 2px;
    display: inline-flex;
    align-items: center;
    color: rgba(255, 255, 255, .72);
}

.tick-sent,
.tick-delivered {
    color: rgba(255, 255, 255, .72);
}

.tick-read {
    color: #fff;
}

.edited-tag {
    font-size: 0.7rem;
    color: inherit;
    opacity: 0.75;
    font-style: italic;
    margin-right: 2px;
}

/* Quoted reply card inside a bubble */
.quoted-reply-card {
    border-left: 2px solid var(--accent);
    background: rgba(0, 0, 0, .05);
    border-radius: 5px;
    padding: 4px 8px;
    margin-bottom: 5px;
    font-size: 0.82rem;
    cursor: pointer;
}

.message-bubble-wrapper.sent .quoted-reply-card {
    border-left-color: rgba(255, 255, 255, .8);
    background: rgba(255, 255, 255, .14);
}

.quoted-reply-user {
    font-weight: 600;
    color: var(--accent);
    font-size: 0.76rem;
    display: block;
}

.message-bubble-wrapper.sent .quoted-reply-user {
    color: #fff;
}

.quoted-reply-text {
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.message-bubble-wrapper.sent .quoted-reply-text {
    color: rgba(255, 255, 255, .85);
}

/* Reaction pills */
.reactions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
    padding: 0 2px;
}

.message-bubble-wrapper.sent .reactions-container {
    justify-content: flex-end;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--incoming);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 2px 9px 2px 7px;
    font-size: 0.78rem;
    cursor: pointer;
    user-select: none;
    font-family: inherit;
    color: var(--ink);
    transition: background .15s ease, border-color .15s ease;
}

.reaction-pill:hover {
    background: var(--active);
}

.reaction-pill.my-reaction {
    background: rgba(10, 132, 255, .14);
    border-color: rgba(10, 132, 255, .4);
}

.reaction-emoji {
    font-size: 0.95rem;
    line-height: 1;
}

.reaction-count {
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--ink-2);
}

.reaction-pill.my-reaction .reaction-count {
    color: var(--accent);
}

/* Hover action toolbar */
.message-bubble-actions {
    position: absolute;
    top: -14px;
    display: none;
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 2px 6px;
    box-shadow: var(--glass-shadow);
    z-index: 10;
    gap: 2px;
}

.message-bubble-wrapper.sent .message-bubble-actions {
    right: 10px;
}

.message-bubble-wrapper.received .message-bubble-actions {
    left: 10px;
}

.message-bubble-wrapper:hover .message-bubble-actions {
    display: flex;
}

.action-btn-mini {
    background: transparent;
    border: none;
    color: var(--ink-2);
    font-size: 0.82rem;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 50%;
    transition: color .15s ease, background .15s ease;
}

.action-btn-mini:hover {
    color: var(--ink);
    background: var(--active);
}

.action-btn-mini.danger:hover {
    color: var(--danger-color);
}

/* Media / file message bubbles */
.media-message-bubble {
    padding: 4px !important;
    max-width: 280px;
    border-radius: 16px;
    overflow: hidden;
}

.media-message-bubble img {
    width: 100%;
    max-width: 272px;
    height: auto;
    max-height: 260px;
    border-radius: 13px;
    display: block;
    object-fit: cover;
    cursor: pointer;
}

.media-message-bubble audio {
    width: 240px;
    height: 40px;
    outline: none;
    border-radius: 8px;
    display: block;
    margin-top: 4px;
}

.file-message-box {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 11px;
    background: rgba(0, 0, 0, .05);
    border-radius: 10px;
    color: inherit;
    min-width: 200px;
}

.message-bubble-wrapper.sent .file-message-box {
    background: rgba(255, 255, 255, .16);
}

.file-message-icon {
    font-size: 1.5rem;
    color: inherit;
    opacity: 0.85;
}

.file-message-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.file-message-name {
    font-size: 0.86rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-message-size {
    font-size: 0.74rem;
    color: inherit;
    opacity: 0.7;
}

.btn-download-file {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .06);
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    flex: none;
    transition: background .15s ease;
}

.message-bubble-wrapper.sent .btn-download-file {
    background: rgba(255, 255, 255, .22);
}

.btn-download-file:hover {
    background: var(--accent);
    color: #fff;
}

.media-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 240px;
    height: 120px;
    background: rgba(0, 0, 0, .05);
    border-radius: 12px;
    color: var(--ink-2);
    font-size: 0.8rem;
    gap: 8px;
}

.message-bubble-wrapper.sent .media-loading-placeholder {
    background: rgba(255, 255, 255, .16);
    color: rgba(255, 255, 255, .85);
}

.media-loading-placeholder i {
    font-size: 1.3rem;
}

/* Disappearing-message flame badge (inside meta) */
.disappearing-flame-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: inherit;
    opacity: 0.85;
    font-size: 0.7rem;
    font-weight: 500;
    margin-right: 5px;
}

.disappearing-flame-badge i {
    font-size: 0.72rem;
}

/* Dissolve animation for expiring messages */
.message-bubble-wrapper.dissolving {
    animation: dissolveOut .75s forwards ease-in-out;
}

@keyframes dissolveOut {
    0% { opacity: 1; transform: scale(1); }
    100% {
        opacity: 0;
        transform: scale(.9) translateY(-8px);
        max-height: 0;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
}

/* --------------------------- Typing indicator ---------------------------- */
.typing-status-indicator {
    padding: 4px 20px 8px;
    font-size: 0.78rem;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--ink-3);
    border-radius: 50%;
    animation: typingBlink 1.3s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBlink {
    0%, 80%, 100% { opacity: .3; }
    40% { opacity: .9; }
}

/* ------------------------------- Composer -------------------------------- */
.chat-input-bar {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    display: flex;
    gap: 7px;
    align-items: flex-end;
    border-top: 1px solid var(--hairline);
    background: var(--panel);
    position: relative;
}

.chat-input-bar #message-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--hairline-strong);
    border-radius: 20px;
    padding: 9px 16px;
    color: var(--ink);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.35;
    height: 40px;
    max-height: 160px;
    resize: none;
    overflow-y: hidden;
    transition: border-color .18s ease;
    min-width: 0;
}

.chat-input-bar #message-input::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink-3);
}

.chat-input-bar #message-input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-attach,
.btn-voice {
    color: var(--ink-2);
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    transition: color .15s ease, background .15s ease;
    flex: none;
}

.btn-attach:hover,
.btn-voice:hover {
    color: var(--accent);
    background: var(--active);
}

#send-btn.btn.btn-primary.btn-round {
    background: var(--accent);
    color: #fff;
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 1rem;
}

#send-btn.btn.btn-primary.btn-round:hover {
    background: var(--primary-hover);
}

#send-btn:disabled,
#message-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Blocked chat mask */
.chat-mask {
    position: absolute;
    inset: 0;
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger-color);
    font-size: 0.92rem;
    font-weight: 600;
    gap: 8px;
}

/* Floating input preview bars (reply / edit / voice / attachment) */
.input-preview-bar,
.attachment-preview-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--field);
    border-top: 1px solid var(--hairline);
    padding: 8px 16px;
    position: relative;
    z-index: 5;
    animation: barSlideUp .2s ease-out;
}

@keyframes barSlideUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.preview-info,
.attachment-info {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-size: 0.86rem;
    overflow: hidden;
    min-width: 0;
}

.preview-icon,
.attachment-info .file-icon {
    color: var(--accent);
    font-size: 1.05rem;
    flex: none;
}

.preview-text-col {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-title {
    font-size: 0.76rem;
    color: var(--accent);
    font-weight: 600;
}

.preview-snippet {
    font-size: 0.82rem;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size {
    color: var(--ink-2);
    font-size: 0.76rem;
}

.btn-cancel-attach {
    background: transparent;
    border: none;
    color: var(--ink-2);
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    flex: none;
    transition: color .15s ease;
}

.btn-cancel-attach:hover {
    color: var(--danger-color);
}

.attachment-thumbnail-container {
    width: 36px;
    height: 36px;
    border-radius: 7px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--hairline);
    flex: none;
}

.attachment-thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-thumbnail-container i {
    font-size: 1.1rem;
    color: var(--ink-2);
}

/* Voice recording bar */
.recording-pulse-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background-color: var(--danger-color);
    flex: none;
    animation: recBlink 1.3s infinite ease-in-out;
}

@keyframes recBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}

.recording-label {
    font-weight: 600;
    color: var(--ink);
}

.recording-timer {
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
}

.voice-actions {
    display: flex;
    gap: 8px;
    flex: none;
}

/* ----------------------------- Chat search ------------------------------- */
.chat-search-overlay {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--hairline);
    padding: 8px 14px;
    gap: 10px;
    position: relative;
    z-index: 8;
    animation: barSlideDown .2s ease-out;
}

@keyframes barSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* In-chat search input wrapper is a pill (scoped to the overlay so it does
   not collide with the sidebar's .search-input-wrapper) */
.chat-search-overlay .search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1;
    background: var(--field);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 6px 12px;
}

.chat-search-overlay .search-input-wrapper:focus-within {
    border-color: var(--accent);
}

.search-bar-icon {
    color: var(--ink-2);
    font-size: 0.85rem;
    flex: none;
}

.chat-search-overlay .search-input-wrapper input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--ink);
    font-size: 0.9rem;
    width: 100%;
    padding: 0;
}

.search-match-count {
    font-size: 0.74rem;
    color: var(--ink-2);
    font-weight: 600;
    white-space: nowrap;
    flex: none;
}

.search-nav-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: none;
}

.btn-icon-sm {
    background: transparent;
    border: none;
    color: var(--ink-2);
    font-size: 0.85rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
}

.btn-icon-sm:hover {
    background: var(--active);
    color: var(--ink);
}

mark.search-highlight {
    background-color: rgba(10, 132, 255, .22);
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
}

.message-bubble-wrapper.sent mark.search-highlight {
    background-color: rgba(255, 255, 255, .32);
}

mark.search-highlight.active-match {
    background-color: var(--accent);
    color: #fff;
}

/* ------------------------------- Dropdowns ------------------------------- */
.dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
    min-width: 190px;
    z-index: 100;
    overflow: hidden;
    padding: 5px;
    animation: ddFade .14s ease-out;
}

@keyframes ddFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    background: none;
    border: none;
    color: var(--ink);
    padding: 10px 12px;
    text-align: left;
    width: 100%;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    transition: background .15s ease;
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--ink-2);
}

.dropdown-item:hover {
    background: var(--active);
}

.dropdown-item.danger {
    color: var(--danger-color);
}

.dropdown-item.danger i {
    color: var(--danger-color);
}

.dropdown-item.danger:hover {
    background: rgba(255, 69, 58, .1);
}

.dropdown-header-label {
    padding: 8px 12px 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 4px;
}

.dropdown-header-label i {
    color: var(--ink-2);
}

/* Active disappearing-timer button */
.btn-icon.active-timer {
    color: var(--accent) !important;
    background: rgba(10, 132, 255, .12);
}

/* ---------------------------- Emoji popover ------------------------------ */
.emoji-picker-popover {
    position: absolute;
    top: -54px;
    left: 0;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 5px 10px;
    display: flex;
    gap: 3px;
    align-items: center;
    box-shadow: var(--glass-shadow);
    z-index: 50;
    animation: ddFade .16s ease-out;
}

.emoji-picker-popover.below {
    top: calc(100% + 4px);
}

.emoji-option-btn {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 10px;
    transition: transform .12s ease, background .12s ease;
    line-height: 1;
    position: relative;
}

.emoji-option-btn:hover {
    transform: scale(1.25);
    background: var(--active);
}

.emoji-option-btn.already-reacted::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

/* -------------------------- WebRTC call overlay -------------------------- */
.call-screen-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, .6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.call-card {
    width: 640px;
    max-width: 92%;
    padding: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    position: relative;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: 18px;
    box-shadow: var(--glass-shadow);
}

.call-user-meta {
    text-align: center;
}

.call-avatar {
    width: 80px;
    height: 80px;
    font-size: 2rem;
    margin: 0 auto 14px;
    background: #8e8e93;
}

.call-user-meta h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 5px;
    color: var(--ink);
}

.call-user-meta p {
    color: var(--ink-2);
    font-size: 0.9rem;
}

.video-grid {
    width: 100%;
    height: 360px;
    background: #000;
    border-radius: 14px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--hairline);
}

.remote-video-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.local-video-feed {
    position: absolute;
    bottom: 14px;
    right: 14px;
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
    background: #222;
}

.call-controls {
    display: flex;
    gap: 18px;
}

.btn-call-action {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    color: var(--ink);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease, transform .12s ease;
    background: var(--field);
}

.btn-call-action:hover {
    transform: scale(1.04);
}

.btn-call-action.active {
    background: var(--field);
}

.btn-call-action.muted {
    background: var(--danger-color);
    color: #fff;
}

.btn-call-action.btn-danger {
    background: var(--danger-color);
    color: #fff;
}

.btn-call-action.btn-danger:hover {
    background: var(--danger-hover);
}

/* ------------------------------- Dialogs --------------------------------- */
.glass-dialog {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: 16px;
    padding: 26px;
    color: var(--ink);
    max-width: 420px;
    width: 90%;
    margin: auto;
    outline: none;
    box-shadow: var(--glass-shadow);
}

.glass-dialog::backdrop {
    background: rgba(0, 0, 0, .4);
}

.dialog-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
}

.dialog-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialog-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dialog-header h3 i {
    color: var(--accent);
}

.btn-close-dialog {
    background: none;
    border: none;
    color: var(--ink-2);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: color .15s ease;
}

.btn-close-dialog:hover {
    color: var(--ink);
}

.dialog-desc {
    font-size: 0.88rem;
    color: var(--ink-2);
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.dialog-actions .btn {
    flex: 1;
}

/* Safety number */
.safety-num-box {
    background: var(--field);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    padding: 18px;
    font-family: ui-monospace, "SF Mono", "Menlo", monospace;
    font-size: 1.05rem;
    letter-spacing: 2px;
    word-spacing: 5px;
    line-height: 1.9;
    color: var(--ink);
    text-align: center;
    width: 100%;
}

.safety-badge {
    font-size: 0.8rem;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 6px;
}

.safety-badge i {
    color: var(--online);
}

/* Incoming call avatar (was pulsing) */
.call-avatar.pulsing {
    /* animation removed for restraint; kept class for JS compatibility */
}

/* ------------------- Group create / settings dialog --------------------- */
.checkbox-scroll-list {
    max-height: 150px;
    overflow-y: auto;
    background: var(--field);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--ink);
    padding: 3px 0;
    user-select: none;
}

.checkbox-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.group-settings-section label {
    color: var(--ink-2);
}

/* Reusable text input inside dialogs (replaces old inline dark styles) */
.dialog-text-input {
    background: var(--field);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    color: var(--ink);
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
}

.dialog-text-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg);
}

.group-members-settings-list {
    list-style: none;
}

.group-member-settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--field);
    padding: 8px 12px;
    border-radius: 8px;
}

.group-member-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-member-username {
    font-size: 0.9rem;
    color: var(--ink);
    font-weight: 500;
}

.group-member-role-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.role-badge-creator {
    background: rgba(52, 199, 89, .15);
    color: #2ea24a;
}

.role-badge-admin {
    background: rgba(10, 132, 255, .15);
    color: var(--accent);
}

.group-member-actions {
    display: flex;
    gap: 6px;
}

/* ------------------------------- Toasts ---------------------------------- */
.toast-container {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: 90vw;
}

.toast {
    background: var(--ink);
    color: var(--bg);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .25s ease, transform .25s ease;
    pointer-events: auto;
    max-width: 100%;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast .toast-icon {
    font-size: 0.9rem;
    flex: none;
}

.toast.toast-success .toast-icon {
    color: var(--online);
}

.toast.toast-error .toast-icon {
    color: #ff6b60;
}

.toast.toast-info .toast-icon {
    color: #5ac8fa;
}

.toast .toast-msg {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ------------------------- Confirm dialog -------------------------------- */
.app-confirm-dialog .dialog-content {
    align-items: stretch;
    text-align: left;
    gap: 14px;
}

.confirm-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.confirm-message {
    font-size: 0.9rem;
    color: var(--ink-2);
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.confirm-actions .btn {
    flex: 1;
}

/* --------------------- Connection (reconnect) banner --------------------- */
.connection-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--field);
    border-bottom: 1px solid var(--hairline);
    color: var(--ink-2);
    font-size: 0.82rem;
    font-weight: 500;
}

.connection-banner i {
    color: var(--ink-2);
}

/* -------------------------------- Anim ----------------------------------- */
@keyframes msgRise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* --------------------------- Responsive: mobile -------------------------- */
@media (max-width: 720px) {
    #app-root {
        padding: 0;
    }

    #auth-container {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        justify-content: center;
    }

    #messenger-dashboard {
        position: relative;
    }

    .sidebar {
        width: 100%;
        border-right: none;
    }

    /* Single-pane switching driven by data-view on #messenger-dashboard */
    #messenger-dashboard[data-view="list"] .chat-container {
        display: none;
    }

    #messenger-dashboard[data-view="chat"] .sidebar {
        display: none;
    }

    #messenger-dashboard[data-view="chat"] .chat-container {
        display: flex;
        width: 100%;
    }

    .back-btn {
        display: flex;
    }

    .message-bubble {
        max-width: 82%;
    }

    .messages-log {
        padding: 14px 12px 8px;
    }

    .chat-actions .btn-icon {
        width: 34px;
        height: 34px;
    }

    /* Free up header room for the name: these move into the ⋮ menu. */
    #btn-search-chat,
    #btn-safety-num {
        display: none;
    }

}

/* --------------------- Accessibility: reduced motion --------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .message-bubble-wrapper,
    .typing-dots span,
    .recording-pulse-dot {
        animation: none !important;
    }
}

/* -------------------- User Profile & Account Settings -------------------- */
.profile-dialog-content {
    max-width: 480px;
    width: 100%;
}

.profile-settings-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--hairline);
    padding-bottom: 8px;
}

.profile-tab {
    background: transparent;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: all 0.15s ease;
}

.profile-tab:hover {
    background: var(--bg-hover);
    color: var(--ink);
}

.profile-tab.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.avatar-editor-section {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px;
    background: var(--bg-subtle, rgba(255, 255, 255, 0.03));
    border-radius: 12px;
    border: 1px solid var(--hairline);
}

.avatar-preview-wrapper {
    position: relative;
    flex: none;
}

.avatar-large {
    width: 68px;
    height: 68px;
    font-size: 1.6rem;
}

.avatar-upload-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 26px;
    height: 26px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.72rem;
    border: 2px solid var(--bg-panel);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.avatar-upload-badge:hover {
    transform: scale(1.1);
}

.avatar-presets-box {
    flex: 1;
    min-width: 0;
}

.avatar-presets-label {
    display: block;
    font-size: 0.78rem;
    color: var(--ink-2);
    margin-bottom: 8px;
}

.avatar-presets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.avatar-preset-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.avatar-preset-btn:hover {
    transform: scale(1.12);
}

.avatar-preset-btn.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--accent);
}

.status-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.status-chip {
    background: var(--bg-subtle, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--hairline);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.74rem;
    color: var(--ink-2);
    cursor: pointer;
    transition: all 0.15s ease;
}

.status-chip:hover {
    background: var(--bg-hover);
    color: var(--ink);
    border-color: var(--hairline-strong);
}

.danger-zone-card {
    padding: 16px;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.danger-zone-card h4 {
    color: var(--danger, #ef4444);
    font-size: 0.95rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.danger-zone-card p {
    font-size: 0.82rem;
    color: var(--ink-2);
    line-height: 1.4;
}

.avatar-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ---------------------------- Chat list extras ---------------------------- */
.contact-item.has-unread .contact-name { font-weight: 700; }
.contact-item.has-unread .contact-last-msg { color: var(--ink); }
.contact-item.has-unread .contact-time { color: var(--accent); font-weight: 600; }
.contact-status-row .unread-badge { flex: none; }
.draft-label { color: var(--danger-color); font-weight: 600; }

/* --------------------------- Message log extras --------------------------- */
.date-separator {
    display: flex;
    justify-content: center;
    margin: 14px 0 8px;
    position: sticky;
    top: 0;
    z-index: 2;
    pointer-events: none;
}
.date-separator span {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--field);
    padding: 3px 10px;
    border-radius: 999px;
}

.message-text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
.message-bubble-wrapper.received .message-text a { color: var(--accent); }

.jump-latest {
    position: absolute;
    right: 18px;
    bottom: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--hairline-strong);
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--glass-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.jump-latest:hover { color: var(--accent); }
.jump-latest-count {
    position: absolute;
    top: -7px;
    right: -4px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ------------------------------ Drag & drop ------------------------------- */
.active-chat-view { position: relative; }
.drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    pointer-events: none;
}
.drop-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 36px;
    border: 2px dashed var(--accent);
    border-radius: 18px;
    color: var(--ink);
    font-weight: 600;
}
.drop-overlay-inner i { font-size: 2rem; color: var(--accent); }

/* ------------------------------ Settings row ------------------------------ */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--hairline);
}
.settings-row-text { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.settings-row-text strong { font-size: 0.92rem; color: var(--ink); }
.settings-row-text .dialog-desc { margin: 0; }
.settings-row .btn { width: auto; flex: none; padding: 8px 16px; }

/* ------------------------- History paging & outbox ------------------------ */
.history-loader {
    align-self: center;
    margin: 6px 0 10px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--hairline-strong);
    background: var(--panel);
    color: var(--ink-2);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}
.history-loader:hover:not(:disabled) { color: var(--accent); }
.history-loader:disabled { cursor: default; opacity: 0.7; }

.tick-pending { opacity: 0.8; }
.status-failed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: #fff;
    color: var(--danger-color);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    cursor: pointer;
}

/* ----------------------------- Chat options menu --------------------------- */
.dropdown-item.mobile-only { display: none; }
#chat-options-dropdown[data-chat-type="group"] .dm-only { display: none; }

/* --------------------------------- Mute ----------------------------------- */
.unread-badge.muted { background: var(--ink-3); }
.contact-item.is-muted.has-unread .contact-time { color: var(--ink-2); font-weight: 400; }
.muted-icon { font-size: 0.72rem; color: var(--ink-3); margin-left: 5px; }
.unread-badge.mention-badge { background: var(--accent); margin-right: 4px; }
.contact-status-row .badges { display: inline-flex; align-items: center; flex: none; }

/* -------------------------------- Mentions -------------------------------- */
.mention {
    font-weight: 600;
    color: var(--accent);
}
.message-bubble-wrapper.sent .mention { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.mention.mention-me {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-radius: 4px;
    padding: 0 3px;
}
.mention-suggestions {
    position: absolute;
    left: 60px;
    right: 60px;
    bottom: calc(100% + 6px);
    background: var(--panel);
    border: 1px solid var(--hairline-strong);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
    padding: 4px;
    z-index: 40;
    max-width: 320px;
}
.mention-option {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    border: none;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
}
.mention-option .mention-option-sub { color: var(--ink-2); font-size: 0.8rem; }
.mention-option.active,
.mention-option:hover { background: var(--active); }

/* ------------------------- Keyboard focus: chat list ----------------------- */
.contact-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
@media (max-width: 720px) {
    #chat-options-dropdown .dropdown-item.mobile-only { display: flex; }
    #chat-options-dropdown[data-chat-type="group"] .dm-only { display: none; }
}

/* ------------------------------- Key pinning ------------------------------- */
.peer-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.peer-name-row h3 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-verified { color: var(--online); font-size: 0.85rem; flex: none; }
.verified-icon { font-size: 0.72rem; color: var(--online); margin-left: 5px; }
.key-warning-icon { font-size: 0.72rem; color: var(--danger-color); margin-left: 5px; }

.key-change-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--danger-color) 12%, var(--panel));
    border-bottom: 1px solid color-mix(in srgb, var(--danger-color) 35%, transparent);
    color: var(--ink);
    font-size: 0.86rem;
}
.key-change-banner > i { color: var(--danger-color); margin-top: 2px; }
.key-change-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.key-change-text span { color: var(--ink-2); line-height: 1.4; }
.key-change-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
.key-change-actions .btn { width: auto; padding: 6px 12px; font-size: 0.8rem; }
@media (max-width: 720px) {
    .key-change-banner { flex-wrap: wrap; }
    .key-change-actions { flex-direction: row; width: 100%; }
}

.safety-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-2);
}
.safety-status.verified { color: var(--online); }
.safety-status.warning { color: var(--danger-color); }
.safety-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* A quote whose original isn't loaded can't be checked against it. */
.quoted-reply-card.quoted-reply-unchecked { border-left-style: dashed; opacity: 0.8; }

/* Forward secrecy on: calmer banner; retention picker */
.e2e-info-banner.fs-on { color: var(--online); }
.settings-select {
    flex: none;
    background: var(--field);
    color: var(--ink);
    border: 1px solid var(--hairline-strong);
    border-radius: 8px;
    padding: 7px 10px;
    font: inherit;
    font-size: 0.88rem;
}

/* iOS-style switch for boolean settings */
.settings-switch {
    appearance: none;
    flex: none;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--hairline-strong);
    position: relative;
    cursor: pointer;
    transition: background .15s ease;
}
.settings-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s ease;
}
.settings-switch:checked { background: var(--accent); }
.settings-switch:checked::after { transform: translateX(18px); }
.settings-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Each message row is its own layer (entry animation), so lift the row that
   holds an open emoji picker above the rows after it. */
.message-bubble-wrapper:has(.emoji-picker-popover) { z-index: 30; }

/* ------------------------------ Call extras -------------------------------- */
/* Self-view shows like a mirror (front cameras). The other side always gets
   the true, un-mirrored image: this only affects our own preview. */
.local-video-feed.mirrored { transform: scaleX(-1); }
.local-video-feed { cursor: pointer; z-index: 2; transition: box-shadow .15s ease; }
.local-video-feed:hover { box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(0, 0, 0, .4); }

/* Swapped: our camera big, theirs in the corner. */
.video-grid.swapped .local-video-feed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
    z-index: 1;
}
.video-grid.swapped .remote-video-feed {
    position: absolute;
    bottom: 14px;
    right: 14px;
    width: 120px;
    height: 90px;
    border-radius: 10px;
    border: 2px solid #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
    z-index: 2;
    cursor: pointer;
}
/* Screen sharing is shown whole, not cropped. */
.local-video-feed.screen { object-fit: contain; background: #000; }

.call-controls { flex-wrap: wrap; justify-content: center; }
.btn-call-action.on { background: var(--accent); color: #fff; }

.call-meta-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 6px;
    min-height: 1.2em;
}
.call-timer { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 0.88rem; }
.call-quality { font-size: 0.85rem; }
.call-quality.good { color: var(--online); }
.call-quality.fair { color: #ffcc00; }
.call-quality.poor { color: var(--danger-color); }

/* Full screen: the call takes the whole display, video first. */
.call-screen-overlay:fullscreen { background: #000; }
.call-screen-overlay:fullscreen .call-card {
    width: 100vw;
    max-width: none;
    height: 100vh;
    border-radius: 0;
    border: none;
    padding: 16px;
    gap: 14px;
    background: #000;
}
.call-screen-overlay:fullscreen .call-user-meta h2 { color: #fff; font-size: 1.1rem; }
.call-screen-overlay:fullscreen .call-avatar { display: none; }
.call-screen-overlay:fullscreen .video-grid { flex: 1; height: auto; border: none; }
.call-screen-overlay:fullscreen .local-video-feed:not(.video-grid.swapped *) { width: 200px; height: 150px; }
.call-screen-overlay:fullscreen .remote-video-feed { object-fit: contain; }

@media (max-width: 720px) {
    .call-card { padding: 22px 14px; gap: 18px; }
    .btn-call-action { width: 48px; height: 48px; font-size: 1.1rem; }
    .call-controls { gap: 12px; }
    .video-grid { height: 52vh; }
}

/* ------------------------- Anonymous group messages ------------------------ */
.sender-tag.anon-tag { color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
.message-bubble-wrapper.sent .sender-tag.anon-tag { color: rgba(255, 255, 255, .85); }
.btn-icon.anon-on { color: #fff; background: #5e5ce6; }
.anon-banner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 16px;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--ink-2);
    background: color-mix(in srgb, #5e5ce6 14%, var(--panel));
    border-bottom: 1px solid var(--hairline);
}
.anon-banner i { color: #5e5ce6; margin-top: 2px; }

/* -------------------------------- Pinned bar ------------------------------- */
.pinned-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--hairline);
    cursor: pointer;
}
.pinned-bar > i { color: var(--accent); transform: rotate(30deg); }
.pinned-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pinned-text strong { font-size: 0.78rem; color: var(--accent); }
.pinned-text span { font-size: 0.86rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.message-bubble-wrapper.flash .message-bubble { animation: pinFlash 1.6s ease; }
@keyframes pinFlash {
    0%, 60% { box-shadow: 0 0 0 3px var(--accent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------------------------------- Polls ---------------------------------- */
.poll-bubble { min-width: min(320px, 70vw); }
.poll-question { font-weight: 600; margin-bottom: 10px; display: flex; gap: 8px; align-items: baseline; }
.poll-options { display: flex; flex-direction: column; gap: 6px; }
.poll-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}
.poll-option:disabled { cursor: default; opacity: .7; }
.poll-bar {
    position: absolute;
    inset: 0 auto 0 0;
    background: color-mix(in srgb, currentColor 14%, transparent);
    transition: width .3s ease;
    pointer-events: none;
}
.poll-option.voted { border-color: currentColor; }
.poll-check, .poll-label, .poll-count { position: relative; }
.poll-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-count { font-variant-numeric: tabular-nums; opacity: .8; }
.poll-footer { margin-top: 8px; font-size: 0.78rem; opacity: .75; }

.poll-options-editor { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 8px; }
.poll-option-input { display: flex; gap: 6px; align-items: center; }
.poll-option-input .dialog-text-input { flex: 1; }
.poll-add-option { margin-bottom: 10px; }
#poll-form { display: flex; flex-direction: column; gap: 6px; }

/* ---------------------------------- Videos --------------------------------- */
.video-tile {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 12px;
    overflow: hidden;
    padding: 0;
    background: #111;
    cursor: pointer;
    color: #fff;
}
.video-tile .video-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-tile .video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform .15s ease, background .15s ease;
}
.video-tile:hover .video-play { transform: translate(-50%, -50%) scale(1.08); background: rgba(0, 0, 0, .7); }
.video-tile .video-info {
    position: absolute;
    left: 8px;
    bottom: 8px;
    font-size: 0.75rem;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .55);
}
.video-wrap { position: relative; width: 100%; }
/* Video bubbles are a little wider than photo bubbles; the video fills them. */
.media-message-bubble:has(.video-tile, .video-wrap) { max-width: min(340px, 78vw); width: min(340px, 78vw); }
.media-message-bubble .video-tile .video-thumb { max-width: none; max-height: none; height: 100%; border-radius: 0; }
.media-message-bubble .sender-tag { display: block; padding: 2px 6px 4px; }
.chat-video { width: 100%; max-height: 420px; border-radius: 12px; background: #000; display: block; }
.video-expand {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    cursor: pointer;
}
.media-message-bubble img { cursor: zoom-in; }

/* ------------------------------- Media viewer ------------------------------ */
.media-viewer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, .92);
    display: flex;
    flex-direction: column;
}
.media-viewer-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-top, 0px));
    color: #fff;
}
.media-viewer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; opacity: .85; }
.media-viewer-btn { color: #fff; background: rgba(255, 255, 255, .12); width: 40px; height: 40px; border-radius: 50%; }
.media-viewer-btn:hover { background: rgba(255, 255, 255, .22); }
.media-viewer-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px 16px;
}
.media-viewer-content { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
