/* ==============================================
   LIVE ROOM - CHAT & LYRICS SYSTEM
   ============================================== */

/* Messages Container - Apple Music Lyrics Style */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 30vh 32px 25vh;
    /* Large vertical padding to center first/last items */
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Fade mask at top and bottom */
    mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
}

.messages-container::-webkit-scrollbar {
    display: none;
}

/* Live Lyrics Line - Apple Music Style */
.live-lyrics-line {
    text-align: left;
    padding: 16px 24px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    filter: blur(2px);
    opacity: 0.4;
    transform: scale(0.92);
}

.live-lyrics-line:hover {
    filter: blur(0);
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.03);
}

.live-lyrics-line.active {
    filter: blur(0);
    opacity: 1;
    transform: scale(1);
    background: linear-gradient(135deg, rgba(243, 194, 106, 0.12) 0%, rgba(243, 194, 106, 0.03) 100%);
    border-left: 4px solid var(--gold);
    padding-left: 20px;
}

.live-lyrics-line.user-line {
    filter: blur(0);
    opacity: 1;
    text-align: right;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(236, 72, 153, 0.08) 100%);
    border-left: none;
    border-right: 4px solid var(--purple);
    padding-right: 20px;
    padding-left: 24px;
}

.live-lyrics-meta {
    display: block;
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-lyrics-meta .avatar-img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    overflow: hidden;
}

.live-lyrics-line.user-line .live-lyrics-meta {
    color: var(--purple);
}

.live-lyrics-text {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.live-lyrics-line.active .live-lyrics-text {
    color: #fff;
    text-shadow: 0 0 30px rgba(243, 194, 106, 0.4);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message .avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.message .bubble {
    padding: 16px 20px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    position: relative;
    transition: all 0.3s ease;
}

.message.user .bubble {
    background: linear-gradient(135deg, var(--purple) 0%, var(--pink) 100%);
    border: none;
    box-shadow: 0 10px 20px rgba(168, 85, 247, 0.2);
}

.message .sender {
    font-size: 0.8rem;
    color: var(--gold);
    margin-bottom: 6px;
    font-weight: 700;
}

.message .content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Live Mode Sentence Highlighting (Apple Podcast Style) */
.message .content .sentence {
    display: inline;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    padding: 2px 4px;
    border-radius: 6px;
    margin: 0 1px;
}

.message .content .sentence.active {
    color: var(--gold);
    text-shadow: 0 0 20px rgba(243, 194, 106, 0.5);
    background: rgba(243, 194, 106, 0.1);
    font-weight: 600;
}

/* Text Toggle Logic */
.messages-container.hidden-text .bubble,
.messages-container.hidden-text .live-lyrics-line {
    opacity: 0 !important;
    filter: blur(8px);
    pointer-events: none;
    transform: scale(0.95);
}

.messages-container.hidden-text .message.user .bubble,
.messages-container.hidden-text .live-lyrics-line.user-line {
    opacity: 1 !important;
    filter: none;
}

/* ==============================================
   PREMIUM FLOATING CONTROLS
   ============================================== */

.live-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 50%, transparent 100%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    z-index: 9999;
}

.mic-hint {
    background: rgba(243, 194, 106, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(243, 194, 106, 0.2);
    color: var(--gold);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    animation: fadeInDown 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Current Subtitle in Control Bar */
.live-current-subtitle {
    width: 100%;
    max-width: 600px;
    min-height: 44px;
    padding: 10px 20px;
    margin-bottom: 12px;
    background: rgba(243, 194, 106, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(243, 194, 106, 0.2);
    border-radius: 16px;
    color: var(--gold);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    display: none;
    /* Injected via JS when active */
    animation: slideUpFade 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.live-current-subtitle:empty {
    display: none !important;
}

/* AI Avatar Overlay — Premium Podcast Studio Mode */
.live-avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(243, 194, 106, 0.03) 0%, transparent 60%);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.live-avatar-overlay.hidden {
    opacity: 0;
    transform: scale(0.92);
    display: none !important;
}

/* Inner Box Container — Matches Replay Mode .album-art */
.live-album-art {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1/1;
    background: linear-gradient(135deg, #333, #111);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: center;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px;
    gap: 16px;
    pointer-events: auto;
}

/* Individual Avatar Card */
.live-avatar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    gap: 12px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.live-avatar-item .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background-color: rgba(20, 20, 30, 0.95);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.06);
    border: 3px solid rgba(255, 255, 255, 0.08);
    animation: avatarBreathing 4s ease-in-out infinite;
    transition: border-color 0.4s ease, box-shadow 0.6s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Character Name Label */
.live-avatar-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.3s ease;
    pointer-events: none;
}

/* Speaking State — Golden Glow + Ring Pulse + Bounce-In Scale */
.live-avatar-item.speaking .avatar-img {
    border-color: rgba(243, 194, 106, 0.7);
    box-shadow:
        0 0 0 4px rgba(243, 194, 106, 0.25),
        0 0 30px rgba(243, 194, 106, 0.2),
        0 0 60px rgba(243, 194, 106, 0.08),
        0 20px 50px rgba(0, 0, 0, 0.5);
    animation: speakingPulse 2s ease-in-out infinite, speakingBounceIn 0.6s ease-out forwards;
}

.live-avatar-item.speaking .live-avatar-name {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 12px rgba(243, 194, 106, 0.3), 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Non-speaking Avatars — Dim when at least one is speaking */
.live-album-art:has(.live-avatar-item.speaking) .live-avatar-item:not(.speaking) {
    opacity: 0.5;
    transform: scale(0.95);
}

.live-album-art:has(.live-avatar-item.speaking) .live-avatar-item:not(.speaking) .avatar-img {
    border-color: rgba(255, 255, 255, 0.04);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: none;
}

.live-album-art:has(.live-avatar-item.speaking) .live-avatar-item:not(.speaking) .live-avatar-name {
    color: rgba(255, 255, 255, 0.3);
}

/* Subtle Breathing Animation (idle) */
@keyframes avatarBreathing {

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

    50% {
        transform: scale(1.015);
    }
}

/* Speaking Pulse Animation */
@keyframes speakingPulse {

    0%,
    100% {
        box-shadow:
            0 0 0 4px rgba(243, 194, 106, 0.25),
            0 0 30px rgba(243, 194, 106, 0.2),
            0 0 60px rgba(243, 194, 106, 0.08),
            0 20px 50px rgba(0, 0, 0, 0.5);
    }

    50% {
        box-shadow:
            0 0 0 6px rgba(243, 194, 106, 0.35),
            0 0 40px rgba(243, 194, 106, 0.25),
            0 0 80px rgba(243, 194, 106, 0.12),
            0 20px 50px rgba(0, 0, 0, 0.5);
    }
}

/* Bounce-In Scale for Speaker Activation */
@keyframes speakingBounceIn {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1.04);
    }
}

/* Hover state on avatars */
.live-avatar-item:hover .avatar-img {
    border-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.04);
}

.live-avatar-item:hover .live-avatar-name {
    color: #fff;
}
/* ── 一对一对话 ────────────────────────────────────────────────
   同一个 chatContainer，但对面是一个人不是一场直播：没有听众数、没有直播
   脉冲、没有分享。头像条末尾多一个「+」，因为中途把别人拉进来是这个形态
   的一半意义。 */
.direct-add-char {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    margin-left: 4px;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}
.direct-add-char:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.8);
    color: #fff;
}

/* 「XXX 加入了对话」这类不属于任何人的行 */
.message.system-note {
    align-self: center;
    background: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.82rem;
    text-align: center;
    padding: 6px 0;
}
.message.system-note .sender { display: none; }

/* 送礼那一行比普通系统行亮一点：它记的是用户真花了钱的一次动作，翻回去看的时候
   该能一眼扫到，而「XXX 加入了对话」不需要。 */
.message.system-note.gift-note { color: rgba(255, 255, 255, 0.72); }
.message.system-note.tier-up-note {
    color: #ffd7e0;
    font-weight: 600;
}

/* ── Price and balance ──────────────────────────────────────────────────
   The line under the composer. A size below the system note and dimmer: it is
   permanent, and anything brighter competes with the conversation for
   attention. But it has to stay put, because every message spends credits. */
.direct-price-line {
    text-align: center;
    font-size: 0.72rem;
    line-height: 1;
    padding: 6px 0 2px;
    color: rgba(255, 255, 255, 0.42);
    white-space: nowrap;
}
/* In the call it sits under the affinity pill. The whole .call-topbar is
   pointer-events:none (so it never blocks the video); this line is not
   clickable, so it does not need that turned back on — only to stay legible
   over the video. */
.call-price {
    margin-top: 4px;
    font-size: 0.72rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.62);
}
.call-overlay.has-video .call-price {
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .38);
}

/* The trial-end / out-of-credits card. Wider than a plain system-note and
   bordered: it is not an aside, it is where a decision gets made, and
   .system-note's 45% grey was tuned precisely for not interrupting. */
.message.system-note.trial-note {
    align-self: center;
    max-width: 22rem;
    width: 100%;
}
.trial-card {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
}
.trial-card-why {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.86rem;
    line-height: 1.45;
}
/* The pricing sentence is brighter than the reason: it is why this card
   exists at all. */
.trial-card-price {
    margin: 8px 0 0;
    color: #ffd7e0;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.45;
}
.trial-card-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}
.trial-card-btn {
    flex: 0 1 auto;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.82);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.trial-card-btn.is-primary {
    color: #fff;
    background: rgba(168, 85, 247, 0.85);
    border-color: rgba(168, 85, 247, 0.9);
}

/* ── 好感药丸：聊天页头部和通话浮层各一颗，同一套样式 ─────────────────────
   flex:none + nowrap：头部那一行里它和角色名并排，而 .live-title 是会省略号
   截断的；不锁住的话，名字长一点就会把药丸挤成竖着断行的两行。375px 上实测
   需要：名字最少 1 个字符 + 药丸约 96px，剩下的都给名字。 */
.affinity-pill {
    flex: none;
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    padding: 4px 9px;
    border-radius: 999px;
    color: #ffd7e0;
    background: rgba(244, 114, 182, 0.16);
    border: 1px solid rgba(244, 114, 182, 0.32);
    transition: transform .25s ease, background .25s ease;
}
.affinity-pill.is-bumped {
    animation: affinity-bump .85s cubic-bezier(.25,.8,.4,1);
}
@keyframes affinity-bump {
    0%   { transform: scale(1);    background: rgba(244, 114, 182, 0.16); }
    22%  { transform: scale(1.18); background: rgba(244, 114, 182, 0.42); }
    100% { transform: scale(1);    background: rgba(244, 114, 182, 0.16); }
}
@media (prefers-reduced-motion: reduce) {
    .affinity-pill.is-bumped { animation: none; }
}
/* 通话里它排在计时器下面。.call-topbar 整条是 pointer-events:none，药丸不需要
   点，所以不用翻回来；只要在视频上看得清。 */
.call-affinity { margin-top: 4px; }
.call-overlay.has-video .call-affinity {
    background: rgba(0, 0, 0, .38);
    border-color: rgba(255, 255, 255, .28);
    text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}

/* ── 加人选择器 ──────────────────────────────────────────────── */
.direct-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.direct-picker {
    width: min(420px, 92vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border-radius: 16px;
    background: #16161c;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.direct-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    font-weight: 700;
}
.direct-picker-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 1rem;
}

.direct-picker-search {
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.9rem;
}

.direct-picker-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.direct-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    text-align: left;
}
.direct-picker-item:hover { background: rgba(168, 85, 247, 0.16); }
.direct-picker-item:disabled { opacity: 0.5; cursor: default; }
.direct-picker-item .avatar-img { width: 32px; height: 32px; border-radius: 50%; }
.direct-picker-name { font-size: 0.92rem; }

.direct-picker-empty {
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 24px 0;
    font-size: 0.88rem;
}

/* ── 一对一：把直播的那一套全摘掉 ──────────────────────────────────────
 *
 * 私聊没有观众，所以「结束直播」「暂停」「点赞」「点踩」「观众」「分享」
 * 「举报」「字幕语言」「氛围」一个都不该在这儿 —— 它们整齐地待在 .action-bar
 * 里，所以按容器摘，而不是按 id 一个个点：模板以后再往那个 bar 里加按钮，
 * 这条规则不用跟着改。
 *
 * 用 CSS 而不是 JS 逐个 style.display='none'：applyDirectChrome 本来就已经
 * 打了 body.direct-chat，藏什么是外观问题，写在样式里只有一处。
 *
 * 元素仍然在 DOM 里，只是不可见 —— 别处的 getElementById 照常拿得到。
 */
body.direct-chat .action-bar,
body.direct-chat #toggleActionBarBtn,
body.direct-chat #terminateBtn,
body.direct-chat #replayActions,
body.direct-chat #liveCurrentSubtitle,
body.direct-chat #bulletChatContainer,
body.direct-chat #sceneLayer,
body.direct-chat #liveVisualizer,
body.direct-chat #liveAvatarOverlay,
body.direct-chat #participantDrawer,
body.direct-chat #liveBadge,
body.direct-chat #liveTimer,
body.direct-chat #chatTopic,
body.direct-chat .online-indicator {
    display: none !important;
}

/* The call's "switch to messages" key (callMode.toMessagesHTML): top-right, the AI badge's row and inset, a
 * 40px glass key like the bar's. Above the HUD's top bar (z 2) and the captions; gone in the call's own keyboard
 * mode, whose header takes that row (and whose "back to voice" is the way out of it). */
.call-to-messages {
    position: absolute; z-index: 4;
    top: calc(8px + env(safe-area-inset-top, 0px)); right: 12px;
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid rgba(255,255,255,.28); color: #fff; font-size: 17px; cursor: pointer;
    background: rgba(0,0,0,.38);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.call-to-messages:active { background: rgba(255,255,255,.26); }
.call-overlay.typing .call-to-messages { display: none; }

/* 输入行上没有了那个折叠条，就不该再为它留位置 */
body.direct-chat .input-row {
    margin-bottom: 0;
}

/* ── 一对一的时候，页面本身不滚 ──────────────────────────────────────────
 *
 * owner：「手机上不应该可以 scroll up/down」。一通电话不是一张网页——两根手指
 * 一划，整个界面连同头像和输入框一起被推走，露出底下的白边，而人只是想往回看
 * 一句话。
 *
 * 会滚的一共两层，两层都要按住：
 *   1. **文档自己**。`overflow: hidden` 一个人挡不住 iOS 的橡皮筋——Safari 照样
 *      让 body 在触摸下位移。`position: fixed; inset: 0` 才是那个真正把文档钉死
 *      的组合，overscroll-behavior: none 再挡住下拉刷新和链式滚动。
 *   2. **滚动链**。文字区滚到头之后，惯性会顺着链子传给祖先，于是「滚到最上面
 *      再往下拉」就把整页拽下来了。overscroll-behavior: contain 把链子剪断，
 *      滚动只留在文字区里面。
 *
 * 高度用 100dvh 不用 100vh：iOS 上 100vh 算的是地址栏收起来之后的高度，钉死的
 * 文档因此比屏幕高一截，正好又能滚一点点——而那一点点恰恰是最气人的。dvh 跟着
 * 可见区域走。旧浏览器落在前面那条 100vh 上，仍然比不锁强。
 *
 * .in-call 一起：通话面板是 position:fixed 的覆盖层，但底下的文档还在，还会滚。
 */
body.direct-chat,
body.in-call {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    touch-action: pan-x pan-y;
}

/* 只有文字区滚，而且滚不出去 */
body.direct-chat .messages-container,
body.in-call .messages-container {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* 键盘弹起来的时候，输入框要在键盘上面。
 *
 * iOS 不会为软键盘改变布局视口，所以输入框会被键盘盖住，人打字看不见自己打的
 * 字。visualViewport 知道键盘占了多少（directChat.js 的 trackKeyboardInset 把
 * 它写进 --kb-inset），这里让出那么多。没有 visualViewport 的浏览器读到 0px，
 * 和以前一模一样。 */
body.direct-chat .chat-input-area,
body.direct-chat .input-row {
    padding-bottom: calc(var(--kb-inset, 0px) + env(safe-area-inset-bottom, 0px));
    transition: padding-bottom .18s ease-out;
}

/* ── 通话形态 ────────────────────────────────────────────────────────────
 *
 * 点开麦克风之后盖住整个房间。聊天框还在下面，挂断就回到它——通话是同一场
 * 对话的另一种看法，不是另一个地方。
 */
.call-overlay {
    /* 侧栏是 1000。通话要盖住整个窗口 —— 半盖着的通话界面比没有更糟：
       它看起来像个弹窗，而这是一通电话。 */
    position: fixed; inset: 0; z-index: 1200;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 18px;
    background: radial-gradient(circle at 50% 38%, #1b2432 0%, #0b0e14 62%);
    animation: call-in .28s ease-out;
    /* no-video layout: keep the buttons above the iOS home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
@keyframes call-in { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }

.call-faces { display: flex; gap: 22px; align-items: center; }
.call-face { position: relative; width: 132px; height: 132px; }
.call-face .call-avatar,
.call-face img {
    width: 132px; height: 132px; border-radius: 50%;
    object-fit: cover; position: relative; z-index: 1;
    border: 2px solid rgba(255,255,255,.14);
}

/* 光晕就是状态：它在说的时候脉动，你在说的时候收紧，在想的时候慢慢转。 */
.call-halo {
    position: absolute; inset: -14px; border-radius: 50%;
    border: 2px solid transparent; transition: border-color .25s ease;
}
.call-overlay.is-speaking  .call-halo { border-color: rgba(94,234,212,.85); animation: call-pulse 1.1s ease-in-out infinite; }
.call-overlay.is-hearing   .call-halo { border-color: rgba(129,140,248,.85); animation: call-pulse .7s ease-in-out infinite; }
.call-overlay.is-thinking  .call-halo { border-color: rgba(148,163,184,.55); animation: call-spin 1.6s linear infinite; border-top-color: rgba(226,232,240,.9); }
.call-overlay.is-listening .call-halo { border-color: rgba(255,255,255,.18); }
@keyframes call-pulse { 0%,100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.07); opacity: .55; } }
@keyframes call-spin  { to { transform: rotate(360deg); } }

.call-name   { font-size: 20px; font-weight: 600; color: #f1f5f9; }
.call-status { font-size: 14px; color: #94a3b8; min-height: 20px; }
.call-timer  { font-size: 13px; color: #64748b; font-variant-numeric: tabular-nums; }

.call-actions { display: flex; align-items: center; gap: 18px; margin-top: 14px; }
.call-btn {
    width: 54px; height: 54px; border-radius: 50%;
    border: none; cursor: pointer; color: #e2e8f0; font-size: 19px;
    background: rgba(255,255,255,.10);
    transition: transform .15s ease, background .15s ease, color .15s ease;
}
.call-btn:hover { background: rgba(255,255,255,.18); transform: scale(1.05); }
.call-mute.is-muted { background: rgba(248,113,113,.22); color: #fca5a5; }

/* 挂断大一点、红一点：三个按钮里只有它会结束这通电话。 */
.call-hangup {
    width: 62px; height: 62px; font-size: 22px; color: #fff;
    background: #ef4444; box-shadow: 0 8px 24px rgba(239,68,68,.35);
}
.call-hangup:hover { background: #dc2626; }

/* 送礼是第五个键。五个键按 18px 间距要 4×54 + 62 + 4×18 = 350px，而 iPhone SE
 * (375px) 去掉 has-video 控件条左右各 16px 的内边距只剩 343px —— 差 7px，最右边
 * 那个就被挤出屏幕。窄屏收到 10px：五个键 318px，留得下余量。按钮本身不缩，
 * 54px 已经是拇指还能稳稳点中的下限。 */
@media (max-width: 400px) {
    .call-actions { gap: 10px; }
}

/* Talkbell's bar is six keys (callMode.js callActionsHTML: mic, hang up,
 * keyboard, gift, Looks, report). At the sizes above six need 5×54 + 62 + 5×10 =
 * 382px, and a phone leaves 343 (375pt) / 358 (390pt) / 398 (430pt) inside the
 * bar's 16px padding. The report key had already made it six before Looks joined
 * it, and the keys are flex items, so the row did not leave the screen — every
 * round key was squeezed into an oval: 48×54 at 375pt, 50×54 at 390 and 430
 * (tests/unit/test_call_bar_width.py). So on phones the six shrink one step:
 * 5×48 + 56 + 5×8 = 336px, which fits 375pt with 7px to spare. 48 is still above
 * Apple's 44pt minimum; the 54 above is a comfort size, not a floor.
 * Before the typing-mode rules on purpose: those size the keys to 44 and must
 * keep winning at equal specificity. */
.call-actions.six { gap: 12px; }
@media (max-width: 440px) {
    .call-actions.six { gap: 8px; }
    .call-actions.six .call-btn { width: 48px; height: 48px; font-size: 17px; }
    .call-actions.six .call-hangup { width: 56px; height: 56px; font-size: 20px; }
}

@media (max-width: 640px) {
    .call-face, .call-face .call-avatar, .call-face img { width: 104px; height: 104px; }
    .call-faces { gap: 14px; }
}

/* ── 视频通话 / 直播样式 ────────────────────────────────────────────────
 *
 * 角色有说话视频时，画面就是一通视频电话：视频铺满整屏，名字和状态在顶部、
 * 控件浮在底部，都压在半透明渐变上。没视频（语音、多人）时退回上面的圆形头像。
 */
/* 语音（无视频）：stage/topbar/actions 都走正常流，overlay 的 flex-column-center
   把它们从上到下堆叠——圆形头像、名字、状态、计时、按钮，和原来一样。 */
.call-stage { display: flex; align-items: center; justify-content: center; }

/* 视频是一张有最大长宽的居中卡片，不铺满整屏裁切——竖屏视频硬撑满横屏电脑会
   被裁得很怪。保持原始比例（object-fit: contain），四周留深色底，像视频通话窗口。 */
.call-overlay.has-video { background: radial-gradient(circle at 50% 42%, #1b2432 0%, #060810 70%); }
.call-overlay.has-video .call-stage {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 12px 12px 12px;   /* 尽量大：只留一点点边，控件浮在视频上而不是挤开它 */
}
/* 视频会议那样的大画面：在窗口内尽量占满，保持原始比例（不裁）。竖屏视频高度
   撑满、宽度随比例；横屏视频宽度撑满。四周是深色底，不是把视频裁掉去填满。 */
.call-overlay.has-video .call-stage .call-avatar,
.call-overlay.has-video .call-stage video.call-video {
    position: static;
    width: auto; height: auto;
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    border: none; border-radius: 16px; z-index: 0;
    background: #000;
    box-shadow: 0 18px 60px rgba(0,0,0,.55);
}

/* 顶部信息条：压在从上往下的暗渐变上，白字才看得清。 */
.call-topbar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    /* The overlay is fixed + full-bleed (viewport-fit=cover), so in the iOS
       shell the name/phase/timer sat under the status bar / Dynamic Island.
       env() is 0 in a normal browser tab. */
    padding: calc(26px + env(safe-area-inset-top, 0px)) 16px 40px;
    pointer-events: none;
}
.call-overlay.has-video .call-topbar {
    background: linear-gradient(to bottom, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 100%);
}
.call-overlay.has-video .call-name   { color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.5); }
.call-overlay.has-video .call-status { color: rgba(255,255,255,.85); text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.call-overlay.has-video .call-timer  { color: rgba(255,255,255,.65); text-shadow: 0 1px 4px rgba(0,0,0,.5); }

/* ── 这一条默认藏着，点一下画面才出来 ────────────────────────────────────
 *
 * owner 的截图：名字 / 说话状态 / 计时 / 熟悉程度 / 价格五行压在画面正中上方，
 * 还有一个「形象」按钮浮在人脸上。这些是**偶尔要看**的信息（她是谁、这通花了
 * 多少），不是每一秒都要看的——常驻在画面上，挡住的正好是唯一值得看的东西。
 *
 * 点一下画面调出来，四秒不动自己收回去；接通那一刻先亮四秒，因为「对面是谁、
 * 这通多少钱」正是那时候要知道的事。视频通话的常规操作（FaceTime / 微信 /
 * WhatsApp 都这样），不用新学。
 *
 * 底部那一条（麦克风 / 挂断 / 键盘 / 字幕 / 礼物）**不藏**：挂断是必须一眼能
 * 按到的动作，藏起来等于把人关在通话里。
 *
 * 只对 has-video 生效。打字形态是另一套布局（.call-overlay.typing 把 topbar 排
 * 成一列），它要的正是这些信息常驻，那边一条都没改。 */
.call-overlay.has-video .call-topbar {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .22s ease, transform .22s ease;
}
.call-overlay.has-video.hud .call-topbar {
    opacity: 1;
    transform: none;
}
@media (prefers-reduced-motion: reduce) {
    .call-overlay.has-video .call-topbar { transition: none; }
}

/* 视频还没出第一帧时盖在上面，撤掉后就一直是视频（loadeddata 时移除）。
   不再用头像 poster——从头到尾就是视频。 */
.call-connecting {
    position: absolute; z-index: 3;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    display: flex; align-items: center; gap: 10px;
    color: rgba(255,255,255,.85); font-size: 15px;
    padding: 12px 18px; border-radius: 14px;
    background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
}
.call-connecting span {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.25); border-top-color: rgba(255,255,255,.9);
    animation: call-spin .8s linear infinite;
}

/* 说话时给视频卡片描一圈青色光边，作为「正在说」的提示。 */
.call-overlay.has-video.is-speaking .call-stage video.call-video {
    box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 3px rgba(94,234,212,.75);
    animation: call-glow 1.4s ease-in-out infinite;
}
@keyframes call-glow {
    0%,100% { box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 3px rgba(94,234,212,.35); }
    50%     { box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 4px rgba(94,234,212,.9); }
}

/* ── Talkbell: a 1:1 with no talking video (callMode.js renderCallStill) ──
 *
 * The overlay wears `has-video has-still`, so the stage, HUD, bar and captions
 * above are the video call's own. What a still adds:
 *   - the backdrop: her picture again, blurred and dimmed, filling the stage, so
 *     the bands either side of a 9:16 portrait on a desktop are her colours and
 *     not a black frame around a photo;
 *   - a breath: the picture scales 1 → 1.025 over 7s, so she is not a frozen
 *     frame. `scale`, not `transform`, so it composes with anything else that
 *     moves the box. Nothing is downloaded or decoded for it;
 *   - the phase cues on the frame, the same teal ring the video gets while she
 *     speaks, plus a quiet ring while she thinks and while you talk. With no
 *     mouth moving, the ring is the one thing on screen that says who is talking.
 * The picture keeps the video's sizing (auto × auto inside max 100%), so the
 * English roster's 768×1376 portraits frame exactly like their 9:16 clips, and
 * a character who later gets a clip (swapClips) does not jump. */
.call-overlay.has-still .call-stage { overflow: hidden; }
.call-still-bg {
    position: absolute; inset: 0; z-index: 0;
    background-size: cover; background-position: center 30%;
    filter: blur(28px) brightness(.42) saturate(1.1);
    transform: scale(1.15);          /* hides the blur's soft edge */
    pointer-events: none;
}
.call-overlay.has-still .call-stage .call-still-img {
    position: relative; z-index: 1;
    background: transparent;
    transform-origin: 50% 40%;
    animation: call-still-breathe 7s ease-in-out infinite alternate;
    transition: box-shadow .25s ease;
}
@keyframes call-still-breathe { from { scale: 1; } to { scale: 1.025; } }
.call-overlay.has-still.is-speaking .call-stage .call-still-img {
    animation: call-still-breathe 7s ease-in-out infinite alternate, call-glow 1.4s ease-in-out infinite;
}
.call-overlay.has-still.is-thinking .call-stage .call-still-img {
    box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 2px rgba(226,232,240,.35);
}
.call-overlay.has-still.is-hearing .call-stage .call-still-img {
    box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 2px rgba(129,140,248,.6);
}
/* Typing mode: the stage is one grid cell, and the picture sizes to it like the clip does. */
.call-overlay.typing.has-still .call-stage .call-still-img { max-width: 100%; max-height: 100%; }
@media (prefers-reduced-motion: reduce) {
    .call-overlay.has-still .call-stage .call-still-img,
    .call-overlay.has-still.is-speaking .call-stage .call-still-img { animation: none; }
    .call-overlay.has-still.is-speaking .call-stage .call-still-img {
        box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 3px rgba(94,234,212,.75);
    }
}

/* 控件条浮在底部渐变上。 */
.call-overlay.has-video .call-actions {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
    margin: 0; padding: 40px 16px calc(34px + env(safe-area-inset-bottom, 0px)); justify-content: center;
    background: linear-gradient(to top, rgba(0,0,0,.6) 0%, rgba(0,0,0,0) 100%);
}
.call-overlay.has-video .call-btn {
    background: rgba(255,255,255,.16);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.call-overlay.has-video .call-btn:hover { background: rgba(255,255,255,.26); }

/* ── In-call captions: the last few lines, rolling (callMode.js showCaption).
 *
 * Owner, iPhone, 2026-10-03: one long reply's caption covered the whole video.
 * So the box is capped at three lines AND at 40% of the call, whichever is
 * smaller; sentences roll through it newest-at-the-bottom and the top line
 * fades out instead of being cut hard.
 *
 * It sits above the control bar, not on it. The bar is 34px + the home
 * indicator inset below its keys and the hang-up key is 56px tall, so its keys
 * end 90px + inset up; the old `bottom: 108px` with no inset put the caption's
 * last line over the keys on every phone with a home indicator (34px inset:
 * keys up to 124px, caption from 108px). */
.call-caption {
    position: absolute; left: 0; right: 0; z-index: 2;
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    padding: 0 22px; margin: 0 auto; max-width: 680px;
    text-align: center; pointer-events: none;
    color: #fff; font-size: 16px; line-height: 1.5;
    text-shadow: 0 1px 6px rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.7);
    max-height: min(4.5em, 40%);          /* 3 lines at line-height 1.5 */
    overflow: hidden;
    display: none;
}
/* Fade the top edge only when something is actually cut there; on one or two
 * lines a mask would fade the sentence she is saying. */
.call-caption.is-overflowing {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.1em);
            mask-image: linear-gradient(to bottom, transparent 0, #000 1.1em);
}
.call-caption.has-text { display: block; }
/* Only the box's own height scrolls; the track moves inside it. */
.call-caption-track { will-change: transform; }
.call-caption-line.is-old { opacity: .55; transition: opacity .4s ease; }
/* 只有视频会议样式才显示字幕。 */
.call-overlay:not(.has-video) .call-caption { display: none; }
/* 字幕开关关掉时，整条不显示。 */
.call-overlay.captions-off .call-caption { display: none; }

/* Talkbell: the captions are their own switch (no CC key on its bar). They
 * take taps, and with captions off the same place stays a transparent band of
 * one line, so "tap here to show" has a here. */
/* z-index 3: the bar's transparent top padding (40px, z-index 2, later in the
 * DOM) overlaps the caption's last line and swallowed the tap there — measured
 * with elementFromPoint at 390x780: the lower 30px of the band hit .call-actions. */
.call-overlay.has-video .call-caption.is-tappable { pointer-events: auto; cursor: pointer; z-index: 3; }
.call-overlay.has-video.captions-off .call-caption.is-tappable {
    display: block; min-height: 44px; -webkit-mask-image: none; mask-image: none;
}
.call-overlay.has-video.captions-off .call-caption.is-tappable .call-caption-track { display: none; }

/* The transient "Captions off — tap here to show" line, where the captions sit. */
.call-caption-hint {
    position: absolute; left: 50%; z-index: 3; transform: translateX(-50%);
    bottom: calc(112px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100% - 32px); padding: 6px 12px; border-radius: 14px;
    background: rgba(20,24,33,.72); color: #fff; font-size: 13px; line-height: 1.35;
    text-align: center; pointer-events: none;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.call-caption-hint[hidden] { display: none; }
.call-overlay:not(.has-video) .call-caption-hint,
.call-overlay.typing .call-caption-hint { display: none; }
/* 字幕开着时「字幕」键点亮。 */
.call-cc.is-active { background: rgba(94,234,212,.9) !important; color: #04211d; }

/* ── 会议内输入条：点「打字」后浮出，压在控件条上方，全程不离开会议画面。 */
.call-inputbar {
    position: absolute; left: 0; right: 0; z-index: 3;
    bottom: 100px; margin: 0 auto; max-width: 680px;
    padding: 0 16px;
    display: flex; align-items: center; gap: 10px;
}
.call-inputbar[hidden] { display: none; }
.call-input-field {
    flex: 1; min-width: 0;
    height: 44px; padding: 0 16px;
    border: 1px solid rgba(255,255,255,.25); border-radius: 22px;
    background: rgba(20,24,33,.72); color: #fff; font-size: 15px;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    outline: none;
}
.call-input-field::placeholder { color: rgba(255,255,255,.5); }
.call-input-field:focus { border-color: rgba(94,234,212,.7); }
.call-input-send {
    flex: 0 0 auto;
    width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(94,234,212,.9); color: #04211d; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(6px);
}
.call-input-send:hover { background: rgba(94,234,212,1); }

/* 打字状态里「打字」键点亮，提示当前在文字模式。 */
.call-overlay.typing .call-to-text.is-active {
    background: rgba(94,234,212,.9); color: #04211d;
}
/* 打字时把字幕往上抬一点，别被输入条压住。 */
.call-overlay.typing .call-caption { bottom: calc(156px + env(safe-area-inset-bottom, 0px)); }

/* 输入条在语音/圆头像样式里也能用（深色底照样看得清）。 */

/* ── 数字人三态视频(说话/听/思考)叠着放,只显示当前 phase 那一段 ────────
 * 三段同一首帧、背景一致,切换看着像同一段里她的状态在变。只有一段(旧数据)
 * 时不受影响(那一段一直带 is-active)。 */
.call-video:not(.is-active) { display: none !important; }

/* ── 打字形态：一个真正的聊天界面 ────────────────────────────────────────
 *
 * owner 的截图（2026-09-10 17:16）：一层暗纸盖在模糊的视频上，一个气泡飘在靠顶
 * 的地方、旁边挂着一张陌生男人的小照片，标题和状态行叠在一起，五个圆键浮在她
 * 脸中央的一块半透明方块上，输入框独自待在屏幕最底下——离消息一整屏远。
 * 他的原话是「文字聊天框还是不专业」。三层各飘各的，因为它们从来没有一个共同
 * 的容器：`.call-topbar`、`.call-transcript`、`.call-inputbar` 三个都是
 * position:absolute 挂在 overlay 上，各自量各自的 top/bottom。
 *
 * 现在它们在 `.call-chat` 里。**语音形态下这个容器是 display:contents**——它的
 * 三个孩子在布局上仍然是 overlay 的直接子元素，绝对定位一行没改，语音形态因此
 * 一个像素都没动。打字形态下它变成一个真正的列，overlay 变成 grid：
 *
 *     ≥900px            <900px
 *     ┌──────┬──────┐   ┌─────────────┐
 *     │ 舞台 │ 头部 │   │    舞台     │ 42vh
 *     │      ├──────┤   ├─────────────┤
 *     │      │ 消息 │   │  控件一行   │
 *     ├──────┤      │   ├─────────────┤
 *     │ 控件 │ 输入 │   │    消息     │
 *     └──────┴──────┘   ├─────────────┤
 *                       │    输入     │
 *                       └─────────────┘
 *
 * 视频**不模糊**，也不暂停：listening/speaking 那几段照常跟着 phase 走。她在那儿
 * 看着你打字，这正是这个产品要卖的东西——把她糊掉等于把它扔了。
 */
.call-overlay.typing {
    display: grid;
    /* 右栏 40%，但不小于 360px：再窄一行就装不下十来个汉字，气泡开始一个字
       一行。左栏拿剩下的，最少 320px，不然舞台被挤成一条。 */
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 40%);
    grid-template-rows: 1fr auto;
    grid-template-areas:
        "stage chat"
        "controls chat";
    gap: 0;
    padding-bottom: 0;   /* 覆盖语音形态给圆键留的那块安全区 */
    /* 语音形态的 .call-overlay 是居中的 flex（align-items/justify-content:center）。
       那两条在 grid 上会把每一格里的内容**居中而不是撑开**——实测右栏因此只有
       452px 高，浮在屏幕中间，和它要取代的那张飘着的纸一模一样。 */
    align-items: stretch;
    justify-items: stretch;
    align-content: stretch;
    justify-content: stretch;
    height: 100%;
}
/* 每一格自己也要能被压缩：min-height/min-width 的默认值是 auto，内容（尤其是
   视频）会把格子顶大，于是舞台溢出到窗口外面去。 */
.call-overlay.typing > * { min-width: 0; min-height: 0; }
.call-overlay.typing .call-stage    { grid-area: stage; position: relative; min-height: 0; }
.call-overlay.typing .call-chat     { grid-area: chat; }
.call-overlay.typing .call-actions  { grid-area: controls; }

/* 语音形态：这个容器不存在于布局里，三个孩子照旧各自绝对定位。 */
.call-chat { display: contents; }

.call-overlay.typing .call-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;                 /* 不写这一条，中间那段列表撑破网格行 */
    background: rgba(12, 15, 22, .94);
    border-left: 1px solid rgba(255, 255, 255, .07);
}

/* ── 头部：头像 · 名字 · 状态 ─────────────────────────────────────────── */
.call-thumb { display: none; }
.call-overlay.typing .call-topbar {
    position: static;              /* 语音形态是 absolute，这里回到文档流 */
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "thumb name  look"
        "thumb status pill";
    align-items: center;
    gap: 2px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    text-align: left;
    width: auto; max-width: none; transform: none;
}
.call-overlay.typing .call-thumb {
    grid-area: thumb; display: block;
    width: 38px; height: 38px; border-radius: 50%;
    object-fit: cover; background: #223;
}
.call-overlay.typing .call-name {
    grid-area: name; font-size: 15px; font-weight: 600; line-height: 1.25;
    text-align: left; margin: 0;
}
/* 状态不再压在气泡底下 —— 它是头部里自己的一行，占自己的位置。 */
.call-overlay.typing .call-status {
    grid-area: status; font-size: 12px; line-height: 1.3;
    color: rgba(255, 255, 255, .55); text-align: left; margin: 0;
}
.call-overlay.typing .call-affinity { grid-area: pill; justify-self: end; margin: 0; }
.call-overlay.typing .call-look     { grid-area: look; position: static; margin: 0; }
/* 语音形态里整条标题是 pointer-events:none —— 它浮在视频上，不能挡住点击。
   打字形态里它是面板的头部，「形象」那个键就在里面：不还回来，那个键看得见、
   点不动（实测 elementFromPoint 命中的是 .call-chat，不是按钮）。 */
.call-overlay.typing .call-topbar { pointer-events: auto; }
/* 计时和价格在打字形态下不占头部的位置：它们是通话的账，不是这段对话的内容。 */
.call-overlay.typing .call-timer,
.call-overlay.typing .call-price { display: none; }

/* ── 消息列表 ─────────────────────────────────────────────────────────── */
.call-transcript {
    position: absolute; left: 0; right: 0; bottom: 156px; top: 64px; z-index: 4;
    overflow-y: auto; padding: 12px 14px;
    background: rgba(10, 10, 14, .82);
    backdrop-filter: blur(6px); -webkit-overflow-scrolling: touch;
}
.call-overlay:not(.typing) .call-transcript { display: none; }
.call-overlay.typing .call-transcript {
    position: static; flex: 1 1 auto; min-height: 0;
    background: none; backdrop-filter: none; padding: 16px;
    overscroll-behavior: contain;
}
.call-transcript #messagesContainer {
    display: block; height: auto; max-height: none; padding: 0; gap: 10px;
    mask-image: none; -webkit-mask-image: none; overflow: visible;
}
/* 那个 720px 的可读列是给**通栏**的记录面板用的：#220 之前它铺满整个 3440px
   的窗口，一句话就是一条横贯屏幕的细带。面板化之后宽度已经由右栏定住了
   （40%，不超过 40–45 个汉字），再套一层 720 就成了「在一条已经够窄的栏里
   再让出一截」。
   线上实测（3440px）：面板 x=2064 w=1376，列表却是 x=2393 w=720 —— 气泡从面板
   左边缘往里缩了 329px，整个看着往右歪。
   所以这一条只留给非打字形态那条通栏的老路。 */
.call-overlay:not(.typing) .call-transcript #messagesContainer {
    max-width: 720px; margin: 0 auto;
}
/* 打字形态：列表占满面板，左右各让出 16px 的呼吸。气泡本身有 78% 的上限，
   一行的长度由那一条管，不由外面再套一层容器管。 */
.call-overlay.typing .call-transcript #messagesContainer {
    max-width: none; margin: 0; width: 100%;
}

/* 一对一的对话气泡（只在这张面板里生效，直播房一个字不动） */
.call-transcript .message {
    display: flex; align-items: flex-end; gap: 8px;
    margin: 0 0 10px; padding: 0;
    filter: none; opacity: 1; transform: none; background: none;
    cursor: default; max-width: 100%;
}
.call-transcript .message.user { flex-direction: row-reverse; }
.call-transcript .message .avatar {
    flex: 0 0 auto; width: 30px; height: 30px;
    border-radius: 50%; overflow: hidden; font-size: .95rem;
}
.call-transcript .message.user .avatar { display: none; }
.call-transcript .message .bubble {
    max-width: 78%; padding: 9px 13px; border-radius: 14px;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .08);
}
.call-transcript .message.user .bubble {
    background: rgba(94, 234, 212, .16);
    border-color: rgba(94, 234, 212, .28);
}
.call-transcript .message .sender {
    font-size: 11px; line-height: 1.2; margin-bottom: 3px;
    color: rgba(255, 255, 255, .55); font-weight: 400;
}
.call-transcript .message.user .sender { display: none; }
.call-transcript .message .content,
.call-transcript .message .live-lyrics-text {
    font-size: 15px !important; line-height: 1.55; color: #fff !important;
    font-weight: 400; white-space: pre-wrap; word-break: break-word; text-align: left;
}
.call-transcript .live-lyrics-line {
    filter: none; opacity: 1; transform: none; background: none;
    padding: 0; text-align: left;
}
/* 时间戳只在指上去的时候出现，平时不占地方也不抢注意力。 */
.call-transcript .message .bubble { position: relative; }
.call-transcript .message .bubble::after {
    content: attr(data-time);
    position: absolute; bottom: 100%; right: 4px;
    font-size: 10px; color: rgba(255, 255, 255, .38);
    opacity: 0; transition: opacity .15s ease-out; pointer-events: none;
    white-space: nowrap;
}
.call-transcript .message:hover .bubble::after { opacity: 1; }

/* 「在想…」的三个点。聊天界面就是这么说这件事的。 */
.call-typing { display: flex; gap: 4px; padding: 6px 4px 2px 42px; }
.call-typing[hidden] { display: none; }
.call-typing-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: rgba(255, 255, 255, .5);
    animation: call-typing-bounce 1.2s infinite ease-in-out;
}
.call-typing-dot:nth-child(2) { animation-delay: .15s; }
.call-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes call-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ── 输入条：钉在面板底下，不再独自待在屏幕最下面 ─────────────────────── */
.call-overlay.typing .call-inputbar {
    position: static; max-width: none; z-index: auto;
    padding: 10px 12px calc(10px + var(--kb-inset, 0px) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, .07);
    background: rgba(12, 15, 22, .96);
    transition: padding-bottom .18s ease-out;
}
.call-input-mic {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .18); cursor: pointer;
    background: rgba(255, 255, 255, .08); color: #fff;
    display: none; align-items: center; justify-content: center;
}
.call-overlay.typing .call-input-mic { display: flex; }
.call-input-mic:hover { background: rgba(255, 255, 255, .16); }

/* ── 控件条：钉在舞台下面，不再浮在她脸上 ─────────────────────────────── */
.call-overlay.typing .call-actions {
    position: static; z-index: auto;
    margin: 0; padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    justify-content: center; background: none;
}

/* ── 手机：上下堆叠 ───────────────────────────────────────────────────── */
@media (max-width: 899px) {
    .call-overlay.typing {
        grid-template-columns: 1fr;
        /* 舞台 42vh（够看清脸，又留下多半屏给对话），控件一行，消息吃掉剩下的，
           输入条自己那一行。页面本身不滚——body.in-call 已经钉死了（#215）。 */
        grid-template-rows: 42vh auto 1fr;
        grid-template-areas:
            "stage"
            "controls"
            "chat";
    }
    .call-overlay.typing .call-chat { border-left: none; border-top: 1px solid rgba(255,255,255,.07); }
    .call-overlay.typing .call-actions { padding: 8px 12px; }
    .call-overlay.typing .call-btn { width: 44px; height: 44px; }
    .call-overlay.typing .call-actions { gap: 12px; }
}

/* 两种形态之间的切换。变的是网格和面板，不是视频——她不该在切换时闪一下。 */
.call-overlay { transition: background .2s ease-out; }
.call-chat, .call-actions, .call-transcript, .call-inputbar {
    transition: background .2s ease-out, padding .2s ease-out, border-color .2s ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .call-overlay, .call-chat, .call-actions, .call-transcript,
    .call-inputbar, .call-typing-dot { transition: none; animation: none; }
}

/* has-video 的舞台本来是 position:absolute; inset:0（铺满整个 overlay）——那在
   语音形态下是对的，在两栏里就会整个逃出左栏、盖住右边的聊天面板。同权重靠
   顺序取胜太脆，这里写死。 */
.call-overlay.typing.has-video .call-stage {
    position: relative; inset: auto;
    padding: 12px; min-height: 0; min-width: 0;
    overflow: hidden;          /* 视频再大也不许顶破这一格 */
}
/* 视频按这一格的大小收，不按视口。语音形态下它是 min(56vh,100%)，那时舞台就是
   整个窗口；两栏里那个数会算出一个比左栏还高的画面。 */
.call-overlay.typing .call-stage .call-avatar,
.call-overlay.typing .call-stage video.call-video,
.call-overlay.typing .call-stage .call-video {
    width: auto; height: auto; max-width: 100%; max-height: 100%;
}
/* 字幕是给「看不见文字」的语音形态用的。打字形态下每一句都在右边的列表里，
   再在视频上压一行就是同一句话说两遍（而且正好压在她脸上）。 */
.call-overlay.typing .call-caption { display: none; }

/* 两栏打字形态的输入条要占满右栏。它在语音形态里是居中的浮条（margin:0 auto），
   而到了右栏这个 flex 列里，auto 的左右外边距会让它缩成内容宽度再居中——13" iPad
   横屏实测：右栏 550px，输入条只有 330px，输入框 200px，两边各空出 110px。 */
@media (min-width: 900px) {
    .call-overlay.typing .call-inputbar { margin: 0; align-self: stretch; }
    /* 两栏时面板头部就在屏幕最上沿。语音形态的 topbar 自己吃了安全区，这一份
       padding:12px 没有——在 iPad 上名字和状态正好落在 24pt 的状态栏里。 */
    .call-overlay.typing .call-topbar { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
}

/* ── Touch tablets (iPad): the call's sheets open as centred dialogs ──────
 *
 * Same query as www_companion's (core/sidebar.js TABLET_MQ): no hover, coarse
 * pointer, ≥ 700 wide and ≥ 500 tall — a phone on its side (≤ 430 tall) keeps
 * its bottom sheets. Looks and gift are 560px bottom sheets; on a 13" iPad in
 * portrait they sat at y=924–1376 and y=1089–1376, under the video's lower third
 * and as far from the eye line as the screen allows. The modules inject their
 * <style> after this file, hence `html` on each selector. */
@media (hover: none) and (pointer: coarse) and (min-width: 700px) and (min-height: 500px) {
    html .looks-sheet, html .gift-sheet {
        top: 50%; bottom: auto; border-radius: 24px; transform: translateY(100vh);
    }
    html .looks-sheet-overlay.open .looks-sheet,
    html .gift-sheet-overlay.open .gift-sheet { transform: translateY(-50%); }
    html #talkbellReportOverlay, html #genderAsk { align-items: center; padding: 24px; }
    html #talkbellReportOverlay .tr-panel, html #genderAsk .ga-card { border-radius: 20px; }
}

/* ── Talkbell text mode: the transcript you can actually read ──────────────
 *
 * UX audit 2026-10-04 (#5, shots 14/15). Scoped to `.tb` (callMode.js puts it
 * on Talkbell's overlay only), so Vovvy Live's call is unchanged.
 *
 * 1. css/mobile/game_mobile.css gives every `.messages-container` 220px of
 *    bottom padding, !important, to clear the werewolf action panel. Borrowed
 *    into this panel the list kept it, and scrolling to the end showed a 220px
 *    empty band under the last message. Here the input bar is a sibling below
 *    the scroller, so nothing needs clearing: the last bubble sits on the
 *    transcript's own 16px padding, just above the input.
 * 2. The header (name, status, price) was invisible in text mode: the video
 *    call's auto-hiding HUD (`.has-video .call-topbar` opacity 0, until a tap)
 *    applied here too, so the 64px the header occupies read as a gap, and the
 *    per-message price — the only place it is shown in a call — never appeared.
 *    Text mode always shows it, which is what the typing layout above intended
 *    ("它要的正是这些信息常驻"). The price takes its own row: with a streak it
 *    reads "1-day streak · 9/10 free today · Balance 300", too long to share
 *    the name's line on a 375pt phone. */
.call-overlay.tb.typing .call-transcript #messagesContainer { padding-bottom: 0 !important; }
.call-overlay.tb.typing .call-topbar {
    opacity: 1; transform: none;
    grid-template-areas:
        "thumb name   look"
        "thumb status pill"
        "thumb price  price";
}
.call-overlay.tb.typing .call-price {
    display: block; grid-area: price; margin: 2px 0 0; padding: 0; background: none; text-align: left;
    font-size: 12px; line-height: 1.3; color: rgba(255, 255, 255, .72);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-overlay.tb.typing .call-price[hidden] { display: none; }
.call-overlay.tb.typing .call-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
