/* =========================================================================
   Chat V2 — Dark Ghost Theme | Messenger-Grade UI
   Matches JinnChat site theme (purple/pink neon, glassmorphism, dark bg)
   ========================================================================= */

/* ── Chat App Shell ──────────────────────────────────────────── */
.chat-page-v2 {
    margin: 0;
    padding: 0;
    /* Use JS-measured visible viewport height so the container never
       extends behind the browser's address bar / bottom nav on real
       mobile devices. --app-height is set by visualViewport.height. */
    height: 100dvh;
    height: var(--app-height, 100dvh);
    background: var(--bg, #06060f);
    font-family: var(--font-body, 'Inter', sans-serif);
    color: var(--text, #e2e8f0);
    --premium-glow: #fbbf24;
    --premium-glow-strong: rgba(251, 191, 36, 0.6);
    --premium-glow-soft: rgba(251, 191, 36, 0.25);
    --premium-glow-border: rgba(251, 191, 36, 0.55);
    --premium-chat-bg: linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(236, 72, 153, 0.2));
    --partner-premium-glow: var(--premium-glow);
    --partner-premium-glow-strong: var(--premium-glow-strong);
    --partner-premium-glow-soft: var(--premium-glow-soft);
    --partner-premium-glow-border: var(--premium-glow-border);
    --partner-premium-chat-bg: linear-gradient(155deg, rgba(38, 28, 10, 0.8), rgba(12, 14, 26, 0.92));
    overflow: hidden;
    display: flex;
    justify-content: center;
    position: fixed;
    top: var(--app-top, 0px);
    left: 0;
    right: 0;
    /* No bottom: 0 — height is driven by --app-height (visible viewport only) */
}

body.app-embed.chat-page-v2 {
    top: calc(var(--app-top, 0px) + 12px);
    height: calc(var(--app-height, 100dvh) - 12px);
}

/* Centered app column — max 780px on desktop, 100% mobile */
.chat-app-wrapper {
    position: relative;
    width: 100%;
    max-width: 780px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg2, #0d0d1a);
    border-left: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-right: 1px solid var(--border);
    overflow: hidden;
    /* Ensure all children participate in flex layout properly */
}

/* ── App Header ──────────────────────────────────────────────── */
.v2-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    background: rgba(6, 6, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
}

.v2-header-back {
    background: none;
    border: none;
    color: var(--purple, #a855f7);
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s;
    flex-shrink: 0;
}

.v2-header-back:hover {
    background: rgba(168, 85, 247, 0.15);
}

/* Partner info (center) */
.v2-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.v2-header-avatar,
.v2-header-avatar-fallback {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
    color: var(--text);
}

.v2-header-avatar {
    object-fit: cover;
}

.v2-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.v2-header-name {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.v2-header-name-text {
    font-family: var(--font-head, 'Space Grotesk', sans-serif);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v2-header-info.is-partner-premium .v2-header-name-text {
    color: #fff7d1;
    text-shadow: 0 0 10px var(--partner-premium-glow-strong, rgba(251, 191, 36, 0.6)),
        0 0 24px var(--partner-premium-glow-soft, rgba(251, 191, 36, 0.25));
}

.v2-header-info.is-partner-premium {
    border-color: var(--partner-premium-glow-border, rgba(251, 191, 36, 0.35));
    box-shadow: 0 0 0 1px var(--partner-premium-glow-soft, rgba(251, 191, 36, 0.14)),
        0 0 16px var(--partner-premium-glow-soft, rgba(251, 191, 36, 0.2));
}

.v2-header-country {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim, #94a3b8);
    flex-shrink: 0;
}

.v2-header-status {
    font-size: 12px;
    color: var(--text-dim, #94a3b8);
    line-height: 1.3;
}

.v2-header-status .online {
    color: var(--green, #10b981);
}

.v2-header-status .offline {
    color: var(--red, #ef4444);
}

.v2-header-premium {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--partner-premium-glow-border, rgba(251, 191, 36, 0.55));
    background: var(--partner-premium-glow-soft, rgba(251, 191, 36, 0.12));
    color: #fef3c7;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.v2-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.v2-header-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    background: rgba(255, 255, 255, 0.06);
    color: var(--text, #e2e8f0);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, background .18s ease, color .18s ease;
}

.v2-header-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(168, 85, 247, 0.55);
    background: rgba(168, 85, 247, 0.12);
}

.v2-header-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.v2-header-btn.danger {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.16);
    color: #fecaca;
}

.v2-header-btn.danger:hover {
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.28);
}

/* Community vote modal */
.vote-modal {
    align-items: center;
    justify-content: center;
}

.vote-card {
    width: min(420px, 92vw);
    padding: 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(10, 10, 22, 0.96);
    box-shadow: 0 24px 70px rgba(2, 6, 23, 0.6);
}

.vote-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.vote-close {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.vote-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0 6px;
}

.vote-btn {
    flex: 1 1 110px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 0.85rem;
    padding: 9px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.vote-btn:hover {
    transform: translateY(-1px);
}

.vote-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#partner-status {
    cursor: pointer;
}

#partner-status:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.6);
    outline-offset: 4px;
    border-radius: 999px;
}

#partner-status:hover {
    opacity: 0.92;
}

.partner-card {
    width: min(440px, 92vw);
    padding: 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(10, 10, 22, 0.96);
    box-shadow: 0 24px 70px rgba(2, 6, 23, 0.6);
}

.partner-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.partner-card-avatar {
    width: 88px;
    height: 88px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.partner-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.partner-card-avatar-fallback {
    font-size: 38px;
}

.partner-card-title {
    flex: 1;
    min-width: 0;
}

.partner-card-name {
    margin: 0;
    font-size: 18px;
}

.partner-card-sub {
    font-size: 12px;
    color: var(--text-dim);
}

.partner-card-username {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.partner-card-username.is-hidden {
    font-style: italic;
    color: var(--text-dim);
}

.partner-card-close {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.partner-card-body {
    margin-top: 12px;
}

.partner-card-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.partner-stat {
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
}

.partner-stat strong {
    display: block;
    margin-top: 4px;
    font-size: 16px;
    color: var(--text);
}

.partner-card-since {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

.partner-card-since strong {
    color: var(--text);
    font-weight: 600;
}

.partner-card-bio {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    font-size: 12px;
    color: var(--text);
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.partner-modal-note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

.partner-modal-note.error {
    color: #fca5a5;
}

@media (max-width: 520px) {
    .partner-card-head {
        align-items: flex-start;
    }

    .partner-card-since {
        flex-direction: column;
        align-items: flex-start;
    }
}

body.light-mode .partner-card {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.12);
}

body.light-mode .partner-card-bio {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.08);
}

body.light-mode .partner-stat {
    border-color: rgba(15, 23, 42, 0.08);
    background: rgba(15, 23, 42, 0.04);
}

.vote-btn.vote-like {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.16);
    color: #bbf7d0;
}

.vote-btn.vote-neutral {
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(148, 163, 184, 0.14);
    color: #e2e8f0;
}

.vote-btn.vote-dislike {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.14);
    color: #fecaca;
}

.vote-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.vote-feedback {
    margin-top: 8px;
    font-size: 0.84rem;
    color: #86efac;
}

.vote-feedback.error {
    color: #fca5a5;
}

/* Character limit gate modal */
.charlimit-modal {
    align-items: center;
    justify-content: center;
}

.charlimit-card {
    width: min(420px, 92vw);
    padding: 18px 20px;
    border-radius: 16px;
    border: 1px solid rgba(251, 191, 36, 0.28);
    background: linear-gradient(180deg, rgba(18, 12, 2, 0.96), rgba(10, 10, 22, 0.96));
    box-shadow: 0 26px 70px rgba(2, 6, 23, 0.66);
}

.charlimit-countdown {
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 0 14px rgba(251, 191, 36, 0.4);
}

.charlimit-actions {
    flex-wrap: wrap;
}

body.light-mode .charlimit-card {
    background: #fff7e6;
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
}

body.light-mode .charlimit-countdown {
    color: #d97706;
    text-shadow: none;
}

.v2-auto-next {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: rgba(13, 13, 26, 0.9);
    backdrop-filter: blur(6px);
}

.v2-auto-next-text {
    font-size: 13px;
    color: var(--text-dim);
}

.v2-auto-next-text strong {
    color: #fbbf24;
    font-weight: 700;
}

.v2-auto-next-btn {
    width: auto;
    padding: 10px 16px;
    margin: 0;
    font-size: 14px;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.25);
}

.v2-auto-next-btn:hover {
    transform: translateY(-1px);
}

@media (max-width: 520px) {
    .v2-auto-next {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .v2-auto-next-btn {
        width: 100%;
    }
}

body.light-mode .v2-auto-next {
    background: #f8fafc;
    border-top-color: rgba(15, 23, 42, 0.12);
}

body.light-mode .v2-auto-next-text {
    color: #475569;
}

.v2-char-bar {
    flex-shrink: 0;
    z-index: 99;
    padding: 4px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(13, 13, 26, 0.9);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}

.char-bar-track {
    flex: 1;
    height: 4px;
    background: var(--surface);
    border-radius: 2px;
    overflow: hidden;
}

.char-bar-fill {
    height: 100%;
    background: var(--purple-g, linear-gradient(135deg, #a855f7, #ec4899));
    border-radius: 2px;
    transition: width .3s;
}

.char-bar-fill.warning {
    background: linear-gradient(135deg, var(--amber, #f59e0b), var(--red, #ef4444));
}

.char-bar-label {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
}

.char-bar-mode-timer {
    font-size: 11px;
    font-weight: 600;
    color: #ffd7d7;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}

.char-bar-mode-timer.is-critical {
    color: #fff;
    background: rgba(220, 38, 38, 0.55);
    border-color: rgba(254, 202, 202, 0.9);
}

/* ── Stages Container ────────────────────────────────────────── */
.v2-stage {
    flex: 1;
    min-height: 0;
    /* Critical: allows flex child to shrink below content size */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ── Search Stage ────────────────────────────────────────────── */
#stage-search {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    background: var(--bg2);
}

.v2-search-wrap {
    max-width: 320px;
}

.v2-radar {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.v2-radar-ghost {
    font-size: 48px;
    z-index: 2;
    animation: float 3s ease-in-out infinite;
}

.v2-pulse {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(168, 85, 247, 0.4);
    border-radius: 50%;
    animation: radarPulse 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

.v2-pulse.d2 {
    animation-delay: 0.7s;
}

.v2-pulse.d3 {
    animation-delay: 1.4s;
}

@keyframes radarPulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.v2-search-title {
    font-family: var(--font-head);
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px;
    background: var(--purple-g);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.v2-search-sub {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 24px;
}

.v2-btn-cancel {
    padding: 10px 28px;
    border-radius: 50px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

.v2-btn-cancel:hover {
    border-color: var(--purple);
    color: var(--text);
}

/* ── Chat Stage ──────────────────────────────────────────────── */
#stage-chat {
    background: var(--bg);
}

/* Scrollable messages area */
.v2-chat-scroll {
    flex: 1;
    min-height: 0;
    /* Critical: allows flex shrinking so input dock stays visible */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    /* Subtle repeating pattern for chat bg */
    background-image:
        radial-gradient(circle at 20% 80%, rgba(168, 85, 247, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(236, 72, 153, 0.03) 0%, transparent 50%);
}

.v2-chat-scroll::after {
    content: '';
    display: block;
    min-height: var(--v2-scroll-spacer, 8px);
    flex-shrink: 0;
}

/* Messages container */
.v2-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    /* Push messages to bottom when few messages exist */
    margin-top: auto;
}

/* ── Chat Bubbles ────────────────────────────────────────────── */
.msg-v2 {
    display: flex;
    width: 100%;
    animation: msgSlide 0.25s ease-out;
    /* Prevent text selection on long-press (context menu handles copy) */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent callout (iOS "Copy/Select All" popup) */
    -webkit-touch-callout: none;
}

@keyframes msgSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-v2.theirs {
    justify-content: flex-start;
}

.msg-v2.mine {
    justify-content: flex-end;
}

.msg-v2.system {
    justify-content: center;
    margin: 12px 0;
}

.msg-row-inner {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    min-width: 0;
    /* prevent flex overflow */
}

.msg-bubble-row-v2 {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 100%;
}

.msg-avatar-v2 {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    display: block;
}

.chat-page-v2.is-premium .msg-v2.mine .msg-avatar-v2 {
    border-color: var(--premium-glow-border, rgba(251, 191, 36, 0.7));
    box-shadow: 0 0 0 2px var(--premium-glow-soft, rgba(251, 191, 36, 0.22)),
        0 0 12px var(--premium-glow-strong, rgba(251, 191, 36, 0.45));
}

.msg-avatar-wrap {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
}

.msg-avatar-wrap.is-hidden {
    visibility: hidden;
}

.msg-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-muted);
}

.chat-page-v2.is-premium .msg-v2.mine .msg-avatar-fallback {
    color: #fde68a;
    text-shadow: 0 0 8px var(--premium-glow-strong, rgba(251, 191, 36, 0.6));
}

.msg-v2.mine .msg-bubble-row-v2 {
    justify-content: flex-end;
}

.msg-v2.theirs .msg-bubble-row-v2 {
    justify-content: flex-start;
}

.msg-bubble-row-v2 .msg-bubble-v2 {
    max-width: 100%;
}

.msg-quick-actions-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 0;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity .2s ease, max-height .2s ease, margin-top .2s ease;
}

.msg-inline-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity .2s ease, max-width .2s ease;
}

.msg-inline-tools.is-mine {
    margin-left: 0;
    margin-right: 6px;
}

.msg-inline-tools.is-theirs {
    margin-left: 6px;
    margin-right: 0;
}

.msg-v2:hover .msg-inline-tools,
.msg-v2:focus-within .msg-inline-tools,
.msg-v2.mobile-actions-open .msg-inline-tools,
.msg-v2.send-failed .msg-inline-tools {
    opacity: 1;
    max-width: 180px;
    pointer-events: auto;
}

.msg-quick-actions-row.is-theirs {
    justify-content: flex-start;
    padding-left: 32px;
}

.msg-quick-actions-row.is-mine {
    justify-content: flex-end;
    padding-right: 32px;
}

.msg-quick-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.msg-quick-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(2px) scale(0.95);
    transition: opacity .2s ease, transform .2s ease, border-color .2s ease, color .2s ease, background .2s ease;
}

.msg-quick-action-btn i {
    pointer-events: none;
}

.msg-v2:hover .msg-quick-action-btn,
.msg-v2:focus-within .msg-quick-action-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.msg-v2:hover .msg-quick-actions-row,
.msg-v2:focus-within .msg-quick-actions-row,
.msg-v2.mobile-actions-open .msg-quick-actions-row {
    opacity: 1;
    max-height: 32px;
    margin-top: 4px;
    pointer-events: auto;
}

.msg-quick-action-btn:hover,
.msg-quick-action-btn:focus-visible {
    border-color: var(--purple);
    color: var(--purple);
    background: rgba(168, 85, 247, 0.18);
    outline: none;
}

.msg-bubble-v2 {
    position: relative;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Theirs (incoming) */
.msg-v2.theirs .msg-bubble-v2 {
    background: var(--surface, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

/* Mine (outgoing) — purple gradient */
.msg-v2.mine .msg-bubble-v2 {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(236, 72, 153, 0.2));
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-page-v2.is-premium .msg-v2.mine .msg-bubble-v2 {
    background: var(--premium-chat-bg, linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(236, 72, 153, 0.2)));
    border-color: var(--premium-glow-border, rgba(251, 191, 36, 0.5));
    box-shadow: 0 12px 24px rgba(168, 85, 247, 0.28),
        0 0 18px var(--premium-glow-soft, rgba(251, 191, 36, 0.25));
}

/* Incoming premium partner highlight */
.msg-v2.theirs.is-premium-partner .msg-bubble-v2 {
    background: var(--partner-premium-chat-bg, linear-gradient(155deg, rgba(38, 28, 10, 0.8), rgba(12, 14, 26, 0.92)));
    border-color: var(--partner-premium-glow-border, rgba(251, 191, 36, 0.55));
    color: #fff6d5;
    box-shadow: 0 10px 22px var(--partner-premium-glow-soft, rgba(251, 191, 36, 0.18)),
        0 0 16px var(--partner-premium-glow-soft, rgba(251, 191, 36, 0.22));
}

.msg-v2.theirs.is-premium-partner .msg-avatar-v2 {
    border-color: var(--partner-premium-glow-border, rgba(251, 191, 36, 0.7));
    box-shadow: 0 0 0 2px var(--partner-premium-glow-soft, rgba(251, 191, 36, 0.22)),
        0 0 12px var(--partner-premium-glow-strong, rgba(251, 191, 36, 0.45));
}

.msg-v2.theirs.is-premium-partner .msg-avatar-fallback {
    color: #fde68a;
    text-shadow: 0 0 8px var(--partner-premium-glow-strong, rgba(251, 191, 36, 0.6));
}

/* System messages */
.msg-v2.system .msg-bubble-v2 {
    background: rgba(148, 163, 184, 0.1);
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    border-radius: 20px;
    padding: 4px 14px;
    text-align: center;
}

/* Sticker bubble */
.msg-bubble-v2.sticker {
    background: none !important;
    border: none !important;
    font-size: 56px;
    padding: 4px;
    line-height: 1;
    box-shadow: none;
}

.msg-bubble-v2.emoji-pop {
    background: none !important;
    border: none !important;
    font-size: 56px;
    padding: 4px;
    line-height: 1;
    box-shadow: none;
}

/* Inline time & read status */
.msg-meta-v2 {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 10.5px;
    margin-top: 0;
    opacity: 0;
    max-height: 0;
    pointer-events: none;
    user-select: none;
    transition: opacity .2s ease, max-height .2s ease, margin-top .2s ease;
}

.msg-v2:hover .msg-meta-v2,
.msg-v2:focus-within .msg-meta-v2,
.msg-v2.mobile-actions-open .msg-meta-v2,
.msg-v2.send-failed .msg-meta-v2 {
    opacity: 0.7;
    max-height: 24px;
    margin-top: 2px;
    pointer-events: auto;
}

.msg-v2:hover .msg-inline-tools .msg-meta-v2,
.msg-v2:focus-within .msg-inline-tools .msg-meta-v2,
.msg-v2.mobile-actions-open .msg-inline-tools .msg-meta-v2,
.msg-v2.send-failed .msg-inline-tools .msg-meta-v2 {
    margin-top: 0;
}

.msg-v2.mine .msg-meta-v2 {
    color: rgba(255, 255, 255, 0.7);
}

.msg-v2.theirs .msg-meta-v2 {
    color: var(--text-muted);
}

.msg-failed-label {
    font-size: 10px;
    color: var(--red);
    font-weight: 600;
}

.msg-retry-btn {
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
    border-radius: 999px;
    font-size: 10px;
    padding: 2px 8px;
    cursor: pointer;
}

.msg-retry-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.msg-edited-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    opacity: 0.9;
    margin-right: 4px;
}

.status-icon-v2 {
    font-size: 10px;
}

.msg-v2.mine.sending .msg-bubble-v2 {
    opacity: 0.7;
}

.msg-v2.mine.sending .status-icon-v2 {
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0.3;
    }
}

.msg-v2.mine.send-failed .msg-bubble-v2 {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--red);
}

/* Reply block */
.reply-block-v2 {
    background: rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--purple);
    padding: 5px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background .2s;
}

.reply-block-v2:hover {
    background: rgba(255, 255, 255, 0.1);
}

.msg-v2.mine .reply-block-v2 {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: #fff;
}

.reply-sender-v2 {
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
    color: var(--purple);
}

.msg-v2.mine .reply-sender-v2 {
    color: rgba(255, 255, 255, 0.85);
}

/* Reactions underneath bubble */
.msg-reactions {
    display: inline-flex;
    gap: 4px;
    margin-top: 2px;
    flex-wrap: wrap;
    align-self: flex-start;
}

.msg-v2.theirs .msg-reactions {
    align-self: flex-end;
}

.msg-v2.mine .msg-reactions {
    align-self: flex-start;
}

.reaction-badge {
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all .2s;
}

.reaction-badge:hover {
    border-color: var(--purple);
    box-shadow: 0 0 6px rgba(168, 85, 247, 0.3);
}

.reaction-badge.mine {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
}

/* Message highlight (when scrolling to a reply target) */
.msg-highlight .msg-bubble-v2 {
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
    transition: box-shadow 0.4s;
}

/* ── Typing Indicator ────────────────────────────────────────── */
.v2-typing {
    position: relative;
    align-self: flex-start;
    margin: 0 16px 8px;
    background: var(--surface);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
    z-index: 5;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.v2-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--purple);
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes voicePulse {

    0%,
    100% {
        transform: scale(0.8);
        opacity: 0.6;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ── Input Dock ──────────────────────────────────────────────── */
.v2-input-dock {
    background: rgba(6, 6, 15, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    /* Guarantee visibility */
    min-height: 56px;
}

.v2-dock-inner {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

.v2-dock-btn {
    background: none;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all .2s;
    flex-shrink: 0;
}

.v2-dock-btn:hover {
    color: var(--purple);
    background: rgba(168, 85, 247, 0.1);
}

.v2-dock-btn.is-recording {
    color: #f87171;
    background: rgba(239, 68, 68, 0.18);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
}

/* Input pill */
.v2-input-pill {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    transition: border-color .2s;
}

.v2-input-pill:focus-within {
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.15);
}

.v2-textarea {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14.5px;
    resize: none;
    padding: 10px 0;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.35;
    caret-color: var(--purple);
}

.v2-textarea:focus {
    outline: none;
}

.v2-textarea::placeholder {
    color: var(--text-muted);
}

.voice-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 0;
    font-size: 12px;
    color: var(--text-muted);
}

.voice-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f87171;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
    animation: voicePulse 1.2s ease-in-out infinite;
}

.voice-cancel {
    margin-left: auto;
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
}

.voice-cancel:hover {
    background: rgba(239, 68, 68, 0.2);
}

.voice-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.voice-play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.voice-play-btn:hover {
    transform: scale(1.03);
}

.voice-bubble.is-playing .voice-play-btn {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
}

.voice-wave {
    position: relative;
    flex: 1;
    min-width: 90px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.voice-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: rgba(255, 255, 255, 0.75);
}

.voice-time {
    font-size: 11px;
    min-width: 78px;
    text-align: right;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

.voice-bubble.is-processing {
    opacity: 0.9;
}

.voice-bubble.is-processing .voice-play-btn {
    cursor: not-allowed;
    opacity: 0.6;
}

.voice-processing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    opacity: 0.8;
}

.voice-processing-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    animation: voiceSpin 0.9s linear infinite;
    flex-shrink: 0;
}

.voice-audio {
    display: none;
}

@keyframes voiceSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.msg-v2.theirs .voice-play-btn {
    background: rgba(15, 23, 42, 0.12);
    border-color: rgba(15, 23, 42, 0.16);
    color: var(--text);
}

.msg-v2.theirs .voice-wave {
    background: rgba(15, 23, 42, 0.12);
}

.msg-v2.theirs .voice-progress {
    background: rgba(15, 23, 42, 0.45);
}

.msg-v2.theirs .voice-time {
    color: var(--text-muted);
}

/* Send button — glowing */
.v2-btn-send {
    background: var(--purple-g, linear-gradient(135deg, #a855f7, #ec4899));
    color: #fff;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.35);
    transition: all .2s;
}

.v2-btn-send:hover {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.6);
    transform: scale(1.05);
}

/* ── Picker Overlays (Emoji / Sticker) ───────────────────────── */
.v2-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: rgba(13, 13, 26, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 12px;
    max-height: 260px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 20;
}

.emoji-grid,
.sticker-grid {
    display: grid;
    gap: 4px;
}

.emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
}

.sticker-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
}

.emoji-btn {
    background: none;
    border: none;
    font-size: 22px;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    font-family: var(--font-emoji);
}

.emoji-btn:hover {
    background: var(--surface-h);
}

.sticker-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 6px;
    font-size: 32px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sticker-btn:hover {
    border-color: var(--purple);
    background: var(--surface-h);
    box-shadow: var(--glow-purple);
}

.sticker-label {
    font-size: 10px;
    color: var(--text-dim);
}

/* ── End Stage ───────────────────────────────────────────────── */
#stage-end {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px 20px;
    background: var(--bg2);
}

.v2-end-wrap {
    max-width: 380px;
    width: 100%;
}

.v2-end-icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

.v2-end-title {
    font-family: var(--font-head);
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px;
    background: var(--purple-g);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.v2-end-sub {
    color: var(--text-dim);
    margin-bottom: 28px;
}

/* End buttons */
.v2-btn-primary {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius, 14px);
    background: var(--purple-g);
    color: #fff;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 16px;
    border: none;
    cursor: pointer;
    margin-bottom: 12px;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
    transition: all .25s;
}

.v2-btn-primary:hover {
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.5);
    transform: translateY(-2px);
}

.v2-btn-ghost {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all .2s;
}

.v2-btn-ghost:hover {
    border-color: var(--purple);
    color: var(--text);
}

/* ── Reply Bar (above input) ─────────────────────────────────── */
.reply-bar {
    background: var(--surface);
    border-left: 3px solid var(--purple);
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.reply-bar-content {
    min-width: 0;
}

.reply-bar-label {
    font-size: 12px;
    color: var(--purple);
    font-weight: 600;
}

.reply-bar-text {
    font-size: 12.5px;
    color: var(--text-dim);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-bar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
}

/* ── Context Menu ────────────────────────────────────────────── */
.msg-context-menu {
    position: absolute;
    z-index: 50;
    background: rgba(13, 13, 26, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    min-width: 150px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    transition: background .15s;
}

.ctx-item:hover {
    background: var(--surface-h);
}

.ctx-item i {
    width: 16px;
    color: var(--text-dim);
}

/* Reaction picker */
.reaction-picker {
    position: fixed;
    z-index: 9100;
    background: rgba(13, 13, 26, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 6px 8px;
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
    max-width: min(calc(100vw - 16px), 360px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transform: translateX(-50%);
}

.reaction-emoji-btn {
    flex: 0 0 auto;
    background: none;
    border: none;
    font-size: 20px;
    padding: 4px 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
}

.reaction-emoji-btn:hover {
    background: var(--surface-h);
    transform: scale(1.2);
}

.reaction-picker::-webkit-scrollbar {
    display: none;
}

/* ── Connected Flash ─────────────────────────────────────────── */
.connected-flash {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--purple-g);
    color: #fff;
    padding: 8px 22px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 999;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.5);
}

/* ── Shared Modal ───────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 4, 12, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-card {
    width: min(100%, 460px);
    padding: 20px;
    animation: modalIn 0.22s ease;
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    font-family: var(--font-head);
    font-size: 20px;
    font-weight: 700;
}

.modal-sub {
    margin: 0 0 14px;
    color: var(--text-dim);
    font-size: 13px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Game Modal ─────────────────────────────────────────────── */
.v2-game-card {
    width: min(100%, 520px);
    max-height: min(88vh, 860px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.v2-game-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    position: sticky;
    top: 0;
    z-index: 3;
    padding-bottom: 10px;
    background: linear-gradient(180deg, rgba(9, 10, 24, 0.98), rgba(9, 10, 24, 0.92) 78%, rgba(9, 10, 24, 0));
}

.v2-game-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    flex-shrink: 0;
}

.v2-game-close:hover {
    color: var(--text);
    border-color: var(--purple);
}

.v2-game-launcher {
    display: grid;
    gap: 12px;
}

.v2-game-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.v2-game-option h4 {
    margin: 0 0 4px;
    font-family: var(--font-head);
    font-size: 16px;
}

.v2-game-option p {
    margin: 0;
    color: var(--text-dim);
    font-size: 13px;
}

.v2-game-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: var(--purple);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 10px;
}

.v2-game-status {
    display: grid;
    gap: 12px;
}

.v2-game-panel {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
}

.v2-game-panel h4 {
    margin: 0 0 6px;
    font-family: var(--font-head);
    font-size: 18px;
}

.v2-game-panel p {
    margin: 0;
    color: var(--text-dim);
    font-size: 13px;
}

.v2-game-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.v2-game-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
}

.v2-game-chip strong {
    color: var(--text);
}

.v2-game-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.v2-game-cell {
    aspect-ratio: 1 / 1;
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: var(--font-head);
    font-size: clamp(28px, 7vw, 42px);
    font-weight: 700;
    cursor: pointer;
    transition: transform .18s, border-color .18s, box-shadow .18s, background .18s;
}

.v2-game-cell:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--purple);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.24);
}

.v2-game-cell:disabled {
    cursor: default;
}

.v2-game-cell.is-filled {
    background: rgba(168, 85, 247, 0.08);
}

.v2-game-cell.cell-x {
    color: #f8fafc;
}

.v2-game-cell.cell-o {
    color: #f9a8d4;
}

.v2-game-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.v2-rps-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.v2-rps-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 108px;
    padding: 14px 10px;
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: transform .18s, border-color .18s, box-shadow .18s, background .18s;
}

.v2-rps-choice i {
    font-size: 26px;
    color: var(--purple);
}

.v2-rps-choice span {
    font-family: var(--font-head);
    font-size: 14px;
    font-weight: 600;
}

.v2-rps-choice:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--purple);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.24);
}

.v2-rps-choice.is-selected {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.48);
}

.v2-rps-choice:disabled {
    cursor: default;
}

.v2-animal-grid,
.v2-dice-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.v2-animal-choice,
.v2-dice-choice {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 108px;
    padding: 14px 10px;
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: transform .18s, border-color .18s, box-shadow .18s, background .18s;
    font-family: var(--font-head);
    font-size: 22px;
    font-weight: 700;
}

.v2-animal-choice {
    flex-direction: column;
    gap: 6px;
}

.v2-animal-emoji {
    font-size: 30px;
    line-height: 1;
}

.v2-animal-label {
    font-size: 14px;
    font-weight: 600;
}

.v2-animal-rank {
    font-size: 12px;
    opacity: 0.7;
}

.v2-animal-choice:hover:not(:disabled),
.v2-dice-choice:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--purple);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.24);
}

.v2-animal-choice.is-selected,
.v2-dice-choice.is-selected {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.48);
}

.v2-animal-choice:disabled,
.v2-dice-choice:disabled {
    cursor: default;
}

.v2-ludo-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.v2-ludo-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(168, 85, 247, 0.1);
    overflow: hidden;
}

.v2-ludo-marker {
    height: 100%;
    border-radius: 999px;
    transition: width .3s ease;
}

.v2-ludo-me {
    background: rgba(56, 189, 248, 0.6);
}

.v2-ludo-partner {
    background: rgba(251, 191, 36, 0.6);
}

.v2-ludo-roll {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.v2-ludo-board {
    display: grid;
    gap: 6px;
    margin: 14px 0;
}

.v2-ludo-board.snake {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: 48px;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid rgba(16, 185, 129, 0.24);
    background:
        linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(16, 185, 129, 0.04) 60%, rgba(59, 130, 246, 0.08));
    box-shadow: inset 0 0 18px rgba(16, 185, 129, 0.15);
}

.v2-ludo-cell {
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-muted);
    position: relative;
    min-height: 42px;
}

.v2-ludo-cell.is-path {
    border: 1px solid rgba(16, 185, 129, 0.35);
    background: rgba(15, 23, 42, 0.45);
}

.v2-ludo-cell.is-snake {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: inset 0 0 12px rgba(239, 68, 68, 0.2);
}

.v2-ludo-cell.is-empty {
    border: 1px dashed rgba(148, 163, 184, 0.18);
    background: rgba(2, 6, 23, 0.25);
}

.v2-ludo-step {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 0.66rem;
    color: rgba(226, 232, 240, 0.8);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.v2-ludo-snake {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.78rem;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.35));
}

.v2-ludo-token-stack {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
}

.v2-ludo-token {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(15, 23, 42, 0.4);
}

.v2-ludo-token-me {
    background: rgba(56, 189, 248, 0.96);
}

.v2-ludo-token-partner {
    background: rgba(251, 191, 36, 0.96);
}

.v2-memory-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.v2-memory-card {
    border: 1px solid rgba(168, 85, 247, 0.28);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.6);
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.v2-memory-card:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(168, 85, 247, 0.6);
    background: rgba(168, 85, 247, 0.12);
}

.v2-memory-card.is-revealed {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.5);
}

.v2-memory-card.is-matched {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.5);
}

.v2-memory-card:disabled {
    cursor: default;
    opacity: 0.7;
}

.v2-memory-face {
    line-height: 1;
}

.v2-math-answer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.v2-math-answer.locked {
    color: var(--text-muted);
    font-size: 0.92rem;
}

.v2-math-input {
    width: 120px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    background: rgba(15, 23, 42, 0.7);
    color: var(--text);
    font-size: 0.95rem;
}

.v2-math-input:focus {
    outline: none;
    border-color: rgba(168, 85, 247, 0.6);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.v2-math-note {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.v2-connect-four-shell {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.v2-connect-four-dropbar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.v2-connect-four-drop {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 42px;
    padding: 6px 2px;
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: transform .18s, border-color .18s, box-shadow .18s, background .18s;
}

.v2-connect-four-drop i {
    color: #fbbf24;
    font-size: 16px;
}

.v2-connect-four-drop span {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.1;
}

.v2-connect-four-drop:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--purple);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.24);
}

.v2-connect-four-drop:disabled {
    cursor: default;
    opacity: 0.6;
}

.v2-connect-four-board {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    padding: 10px;
    border: 1px solid rgba(96, 165, 250, 0.18);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.28), rgba(15, 23, 42, 0.72));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.v2-connect-four-slot {
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: rgba(2, 6, 23, 0.48);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.v2-connect-four-disc {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.04);
}

.v2-connect-four-disc.token-red {
    background: radial-gradient(circle at 30% 30%, #fda4af, #ef4444 62%, #991b1b 100%);
    border-color: rgba(254, 202, 202, 0.4);
}

.v2-connect-four-disc.token-yellow {
    background: radial-gradient(circle at 30% 30%, #fde68a, #fbbf24 62%, #a16207 100%);
    border-color: rgba(254, 240, 138, 0.4);
}

.v2-game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.v2-game-btn:hover {
    border-color: var(--purple);
}

.v2-game-btn.primary {
    background: var(--purple-g);
    border: none;
    color: #fff;
}

.v2-game-btn.danger {
    color: #fff;
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.35);
}

.v2-game-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.v2-game-result {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.2);
    color: var(--text);
    font-size: 13px;
}

.v2-game-countdown {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
}

.v2-game-countdown strong {
    min-width: 22px;
    color: var(--text);
    font-family: var(--font-head);
    font-size: 18px;
    text-align: center;
}

/* ── Custom Scrollbar (stays consistent with site) ───────────── */
.v2-chat-scroll::-webkit-scrollbar {
    width: 5px;
}

.v2-chat-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.v2-chat-scroll::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.3);
    border-radius: 3px;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 780px) {
    .chat-app-wrapper {
        max-width: 100%;
        border: none;
    }
}

@media (max-width: 600px) {

    .v2-game-modal {
        align-items: flex-start;
        padding: 10px 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
        overflow-y: auto;
    }

    .v2-game-card {
        width: 100%;
        max-height: calc(100dvh - 20px);
        padding: 14px;
        margin: 0 auto;
        border-radius: 18px;
    }

    .v2-game-head {
        margin: -2px -2px 10px;
        padding: 2px 2px 10px;
    }

    .v2-game-head .modal-title {
        font-size: 18px;
    }

    .v2-game-head .modal-sub {
        margin-bottom: 0;
        font-size: 12px;
    }

    .v2-game-panel {
        padding: 12px;
    }

    .v2-game-meta {
        gap: 6px;
    }

    .v2-game-chip {
        padding: 5px 8px;
        font-size: 11px;
    }

    html,
    body {
        overflow: hidden !important;
        height: 100% !important;
    }

    .chat-page-v2 {
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #stage-chat {
        flex: 1 1 0 !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .v2-header {
        height: 54px;
        padding: 0 10px;
        gap: 8px;
    }

    .v2-header-avatar,
    .v2-header-avatar-fallback {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .v2-header-name {
        font-size: 14px;
    }

    .v2-chat-scroll {
        flex: 1 1 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        padding: 10px 10px 6px;
    }

    .msg-row-inner {
        max-width: 85%;
    }

    .msg-bubble-row-v2 {
        gap: 5px;
    }

    .msg-avatar-v2 {
        width: 22px;
        height: 22px;
    }

    .msg-avatar-wrap {
        width: 22px;
        height: 22px;
    }

    .msg-avatar-fallback {
        font-size: 12px;
    }

    .msg-quick-action-btn {
        width: 28px;
        height: 28px;
        opacity: 0;
        pointer-events: none;
        transform: translateY(2px) scale(0.95);
        font-size: 13px;
    }

    .msg-quick-actions-row.is-theirs {
        padding-left: 27px;
    }

    .msg-quick-actions-row.is-mine {
        padding-right: 27px;
    }

    .msg-v2.mobile-actions-open .msg-quick-action-btn {
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }

    .msg-bubble-v2 {
        font-size: 14px;
    }

    .msg-bubble-v2.sticker,
    .msg-bubble-v2.emoji-pop {
        font-size: 70px;
        padding: 2px;
    }

    .v2-input-dock {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        background: rgba(6, 6, 15, 0.98) !important;
        z-index: 1000 !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.4);
    }

    .v2-dock-inner {
        display: grid;
        align-items: end;
        width: 100%;
        max-width: 780px;
        padding: 8px;
        box-sizing: border-box;
        gap: 4px;
    }

    .chat-page-v2:not(.group-chat-page) .v2-dock-inner {
        grid-template-columns: 34px 34px 34px 34px minmax(0, 1fr) 34px;
    }

    .group-chat-page .v2-dock-inner {
        grid-template-columns: 34px 34px 34px minmax(0, 1fr) 34px;
    }

    .v2-game-card {
        padding: 16px;
    }

    .v2-game-option {
        flex-direction: column;
        align-items: stretch;
    }

    .v2-rps-grid {
        grid-template-columns: 1fr;
    }

    .v2-connect-four-shell {
        gap: 8px;
    }

    .v2-connect-four-dropbar {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 4px;
    }

    .v2-connect-four-drop {
        min-height: 34px;
        padding: 4px 0;
        border-radius: 10px;
    }

    .v2-connect-four-drop i {
        font-size: 14px;
    }

    .v2-connect-four-drop span {
        display: none;
    }

    .v2-connect-four-board {
        gap: 4px;
        padding: 8px;
        border-radius: 16px;
    }

    .v2-connect-four-slot {
        padding: 2px;
    }

    .v2-game-actions,
    .modal-actions {
        flex-direction: column;
    }

    .v2-dock-btn {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }

    .v2-input-pill {
        min-height: 38px;
        padding: 0 12px;
    }

    .v2-textarea {
        font-size: 14px;
        padding: 8px 0;
    }

    .v2-picker {
        max-height: 220px;
        padding: 8px;
    }

    .emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
        gap: 6px;
    }

    .sticker-grid {
        grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
        gap: 6px;
    }

    .emoji-btn {
        font-size: 28px;
        padding: 8px 4px;
    }

    .sticker-btn {
        font-size: 40px;
        padding: 10px 6px;
    }

    .sticker-label {
        font-size: 11px;
    }
}

@media (max-width: 420px) {
    .v2-header {
        height: 50px;
        padding: 0 8px;
        gap: 6px;
    }

    .v2-header-actions {
        gap: 2px;
    }

    .v2-header-avatar,
    .v2-header-avatar-fallback {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .v2-header-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .v2-dock-inner {
        gap: 6px;
        padding: 8px;
    }

    .v2-dock-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .v2-input-pill {
        min-height: 36px;
        padding: 0 10px;
    }

    .v2-textarea {
        font-size: 13px;
    }
}

/* Unsent */
.msg-v2.unsent .msg-bubble-v2 {
    background: rgba(71, 85, 105, 0.15) !important;
    border-color: transparent !important;
    color: var(--text-muted) !important;
}

/* ── Light Mode overrides ────────────────────────────────────── */
body.light-mode .v2-header {
    background: rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .v2-header-btn {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(15, 23, 42, 0.14);
    color: #475569;
}

body.light-mode .v2-header-btn:hover {
    background: rgba(124, 58, 237, 0.1);
    border-color: rgba(124, 58, 237, 0.4);
    color: #6d28d9;
}

body.light-mode .v2-header-btn.danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #b91c1c;
}

body.light-mode .v2-header-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #991b1b;
}

body.light-mode .v2-char-bar {
    background: rgba(243, 244, 248, 0.97);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .v2-input-dock {
    background: rgba(255, 255, 255, 0.97);
    border-top-color: rgba(0, 0, 0, 0.1);
}

@media (max-width: 600px) {
    body.light-mode .v2-input-dock {
        background: rgba(255, 255, 255, 0.98) !important;
    }
}

body.light-mode .v2-picker {
    background: rgba(255, 255, 255, 0.98);
    border-top-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .v2-chat-scroll {
    background-image: none;
    background-color: #f7f8fc;
}

body.light-mode .msg-v2.theirs .msg-bubble-v2 {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.12);
    color: #1f2937;
}

body.light-mode .msg-v2.mine .msg-bubble-v2 {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    border-color: rgba(139, 92, 246, 0.6);
    color: #ffffff;
}

body.light-mode .v2-header-info.is-partner-premium .v2-header-name-text {
    color: var(--partner-premium-glow, #92400e);
    text-shadow: none;
}

body.light-mode .v2-header-info.is-partner-premium {
    border-color: var(--partner-premium-glow-border, rgba(245, 158, 11, 0.4));
    box-shadow: 0 0 0 1px var(--partner-premium-glow-soft, rgba(245, 158, 11, 0.16));
    background: rgba(255, 255, 255, 0.92);
}

body.light-mode .v2-header-premium {
    border-color: var(--partner-premium-glow-border, rgba(245, 158, 11, 0.65));
    background: var(--partner-premium-glow-soft, rgba(245, 158, 11, 0.18));
    color: #92400e;
}

body.light-mode.chat-page-v2.is-premium .msg-v2.mine .msg-bubble-v2 {
    background: var(--premium-chat-bg, linear-gradient(135deg, #8b5cf6, #ec4899));
    border-color: var(--premium-glow-border, rgba(245, 158, 11, 0.4));
    box-shadow: 0 10px 18px var(--premium-glow-soft, rgba(245, 158, 11, 0.18));
}

body.light-mode .msg-v2.theirs.is-premium-partner .msg-bubble-v2 {
    background: var(--partner-premium-chat-bg, #fff7e6);
    border-color: var(--partner-premium-glow-border, rgba(245, 158, 11, 0.5));
    color: #1f2937;
    box-shadow: 0 10px 18px var(--partner-premium-glow-soft, rgba(245, 158, 11, 0.18));
}

body.light-mode .msg-v2.theirs.is-premium-partner .msg-avatar-v2 {
    border-color: var(--partner-premium-glow-border, rgba(245, 158, 11, 0.55));
    box-shadow: 0 0 0 2px var(--partner-premium-glow-soft, rgba(245, 158, 11, 0.16)),
        0 0 10px var(--partner-premium-glow-soft, rgba(245, 158, 11, 0.2));
}

body.light-mode .msg-v2.theirs.is-premium-partner .msg-avatar-fallback {
    color: var(--partner-premium-glow, #b45309);
    text-shadow: none;
}

body.light-mode .msg-v2.system .msg-bubble-v2 {
    background: rgba(15, 23, 42, 0.08);
    color: #334155;
}

body.light-mode .msg-v2.mine .msg-meta-v2,
body.light-mode .msg-v2.theirs .msg-meta-v2 {
    color: #475569;
}

body.light-mode .msg-v2:hover .msg-meta-v2,
body.light-mode .msg-v2:focus-within .msg-meta-v2,
body.light-mode .msg-v2.mobile-actions-open .msg-meta-v2,
body.light-mode .msg-v2.send-failed .msg-meta-v2 {
    opacity: 0.75;
}

body.light-mode .msg-avatar-v2 {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.04);
}

body.light-mode .msg-avatar-fallback {
    color: #64748b;
}

body.light-mode .reply-block-v2 {
    background: rgba(0, 0, 0, 0.04);
}

body.light-mode .reply-block-v2:hover {
    background: rgba(0, 0, 0, 0.07);
}

body.light-mode .msg-context-menu {
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

body.light-mode .ctx-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.light-mode .reaction-picker {
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

body.light-mode .reaction-emoji-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

body.light-mode .msg-quick-action-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.14);
    color: #64748b;
}

body.light-mode .msg-quick-action-btn:hover,
body.light-mode .msg-quick-action-btn:focus-visible {
    color: #7c3aed;
    border-color: rgba(124, 58, 237, 0.45);
    background: rgba(124, 58, 237, 0.1);
}

body.light-mode .reaction-badge {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text-dim);
}

body.light-mode .reaction-badge.mine {
    background: rgba(168, 85, 247, 0.08);
    border-color: rgba(168, 85, 247, 0.3);
}

body.light-mode .v2-game-head {
    background: linear-gradient(180deg, rgba(243, 244, 248, 0.98), rgba(243, 244, 248, 0.92) 78%, rgba(243, 244, 248, 0));
}

/* ── Bottom nav accommodation for chat pages ───────────────── */
.chat-page-v2 .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

.chat-page-v2 .v2-auto-next {
    margin-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}

.chat-page-v2 .v2-input-dock {
    padding-bottom: max(64px, calc(56px + env(safe-area-inset-bottom)));
}

/* ── Gender Poll Modal ──────────────────────────────────────── */
.gender-poll-card {
    max-width: 360px !important;
}

.gender-poll-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 14px 0 10px;
}

.gender-poll-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    transition: all .22s;
    text-align: left;
    width: 100%;
    font-family: var(--font-body);
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.gender-poll-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--purple-g);
    opacity: 0;
    transition: opacity .22s;
    pointer-events: none;
}

.gender-poll-option:hover {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.08);
}

.gender-poll-option:hover::before {
    opacity: 0.04;
}

.gender-poll-option.selected {
    border-color: var(--purple);
    background: rgba(168, 85, 247, 0.15);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.25);
}

.gender-poll-option.selected::before {
    opacity: 0.06;
}

.gpo-emoji {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.gpo-label {
    flex: 1;
    font-weight: 600;
}

.gpo-label small {
    font-weight: 400;
    opacity: 0.65;
    margin-left: 4px;
    font-size: 0.82em;
}

.gpo-count {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dim);
    min-width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.gender-poll-option.selected .gpo-count {
    background: rgba(168, 85, 247, 0.3);
    color: #fff;
}

/* Poll result bars */
.gender-poll-bars {
    margin: 8px 0 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gp-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.gp-bar-label {
    width: 72px;
    flex-shrink: 0;
    color: var(--text-dim);
}

.gp-bar-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.gp-bar-fill {
    height: 100%;
    border-radius: 3px;
    width: 0;
    transition: width .4s cubic-bezier(.4, 0, .2, 1);
}

.gp-bar-fill.jinn {
    background: linear-gradient(90deg, #6366f1, #a855f7);
}

.gp-bar-fill.pori {
    background: linear-gradient(90deg, #ec4899, #f472b6);
}

.gp-bar-fill.not-sure {
    background: linear-gradient(90deg, #64748b, #94a3b8);
}

.gp-bar-pct {
    width: 32px;
    text-align: right;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.gp-total {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}