:root {
    --voice-page-background:
        url("../../models/images/settings-ui/bg-night.png") center center / cover no-repeat,
        radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.1), transparent 32%),
        linear-gradient(180deg, #17151c 0%, #090911 100%);
    --voice-avatar-size: clamp(220px, 32vw, 336px);
}

html[data-scene-mode="voice"] {
    --viewport-background: var(--voice-page-background);
}

.voice-page {
    background: var(--voice-page-background);
    overflow: hidden;
}

.voice-call-shell {
    --voice-avatar-level: 0;
    --voice-avatar-accent: #92a2ff;
    --voice-avatar-accent-soft: rgba(146, 162, 255, 0.22);
    --voice-avatar-secondary: rgba(255, 255, 255, 0.84);
    --voice-avatar-shadow: rgba(146, 162, 255, 0.2);
    --voice-layout-drop: clamp(12px, 2vh, 22px);
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding:
        max(14px, env(safe-area-inset-top))
        18px
        calc(18px + env(safe-area-inset-bottom));
}

.voice-call-shell[data-voice-state="idle"] {
    --voice-avatar-accent: #9b9ba3;
    --voice-avatar-accent-soft: rgba(155, 155, 163, 0.2);
    --voice-avatar-secondary: #d3d3d8;
    --voice-avatar-shadow: rgba(155, 155, 163, 0.18);
}

.voice-call-shell[data-voice-state="connecting"] {
    --voice-avatar-accent: #7be495;
    --voice-avatar-accent-soft: rgba(123, 228, 149, 0.24);
    --voice-avatar-secondary: #dcffe7;
    --voice-avatar-shadow: rgba(123, 228, 149, 0.24);
}

.voice-call-shell[data-voice-state="connected"] {
    --voice-avatar-accent: #8c8dff;
    --voice-avatar-accent-soft: rgba(140, 141, 255, 0.24);
    --voice-avatar-secondary: #d8cbff;
    --voice-avatar-shadow: rgba(140, 141, 255, 0.28);
}

.voice-call-shell[data-voice-state="listening"] {
    --voice-avatar-accent: #ff7fb3;
    --voice-avatar-accent-soft: rgba(255, 127, 179, 0.28);
    --voice-avatar-secondary: #ffd2e6;
    --voice-avatar-shadow: rgba(255, 127, 179, 0.28);
}

.voice-call-shell[data-voice-state="responding"] {
    --voice-avatar-accent: #d48dff;
    --voice-avatar-accent-soft: rgba(212, 141, 255, 0.28);
    --voice-avatar-secondary: #ffc7f1;
    --voice-avatar-shadow: rgba(212, 141, 255, 0.3);
}

.voice-call-shell[data-voice-state="error"] {
    --voice-avatar-accent: #ff6262;
    --voice-avatar-accent-soft: rgba(255, 98, 98, 0.28);
    --voice-avatar-secondary: #ffb8b8;
    --voice-avatar-shadow: rgba(255, 98, 98, 0.28);
}

.voice-back-btn {
    display: none;
}

.voice-call-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    transform: translateY(var(--voice-layout-drop));
}

.voice-role-name {
    font-size: clamp(34px, 5vw, 54px);
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
    text-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.voice-status-pill {
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(24, 23, 31, 0.76);
    color: rgba(255, 255, 255, 0.86);
    font-size: 14px;
    font-weight: 600;
}

.rtc-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.04);
}

.rtc-status-dot.idle {
    background: #9b9ba3;
    box-shadow: 0 0 0 6px rgba(155, 155, 163, 0.16);
}

.rtc-status-dot.connecting {
    background: #7be495;
    box-shadow: 0 0 0 6px rgba(123, 228, 149, 0.18);
}

.rtc-status-dot.connected {
    background: #8c8dff;
    box-shadow: 0 0 0 6px rgba(140, 141, 255, 0.18);
}

.rtc-status-dot.listening {
    background: #ff7fb3;
    box-shadow: 0 0 0 6px rgba(255, 127, 179, 0.18);
}

.rtc-status-dot.responding {
    background: #d48dff;
    box-shadow: 0 0 0 6px rgba(212, 141, 255, 0.18);
}

.rtc-status-dot.error {
    background: #ff6262;
    box-shadow: 0 0 0 6px rgba(255, 98, 98, 0.18);
}

.voice-avatar-stage {
    width: min(72vw, 420px);
    margin-top: 12px;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: clamp(14px, 3vh, 28px);
    position: relative;
    transform: translateY(var(--voice-layout-drop));
}

.voice-avatar-shell {
    position: relative;
    width: var(--voice-avatar-size);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    isolation: isolate;
}

.voice-avatar-halo {
    position: absolute;
    inset: 7%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 50%, var(--voice-avatar-accent-soft) 0%, rgba(255, 255, 255, 0.12) 28%, transparent 72%);
    filter: blur(calc(18px + var(--voice-avatar-level) * 24px));
    opacity: calc(0.58 + var(--voice-avatar-level) * 0.28);
    transform: scale(calc(0.9 + var(--voice-avatar-level) * 0.16));
    transition:
        background 0.24s ease,
        filter 0.16s linear,
        opacity 0.16s linear,
        transform 0.16s linear;
    z-index: 0;
}

.voice-avatar-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        conic-gradient(
            from 0deg,
            var(--voice-avatar-accent) 0deg,
            rgba(255, 255, 255, 0.28) 68deg,
            var(--voice-avatar-secondary) 192deg,
            rgba(255, 255, 255, 0.12) 300deg,
            var(--voice-avatar-accent) 360deg
        );
    opacity: calc(0.82 + var(--voice-avatar-level) * 0.16);
    box-shadow:
        0 0 calc(18px + var(--voice-avatar-level) * 30px) var(--voice-avatar-shadow),
        0 18px 34px rgba(0, 0, 0, 0.26);
    transform: scale(calc(0.985 + var(--voice-avatar-level) * 0.045));
    transition:
        background 0.24s ease,
        box-shadow 0.16s linear,
        opacity 0.16s linear,
        transform 0.16s linear;
    animation: voice-avatar-spin 10s linear infinite;
    z-index: 1;
}

.voice-avatar-shell.is-speaking .voice-avatar-halo {
    animation: voice-avatar-pulse 0.96s ease-in-out infinite;
}

.voice-avatar-shell.is-speaking .voice-avatar-ring {
    animation: voice-avatar-spin 8s linear infinite;
}

.voice-avatar-frame {
    position: relative;
    width: calc(100% - 18px);
    aspect-ratio: 1;
    padding: 10px;
    border-radius: 50%;
    background:
        linear-gradient(180deg, rgba(15, 18, 28, 0.9) 0%, rgba(7, 9, 16, 0.96) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        0 16px 30px rgba(0, 0, 0, 0.34);
    transform: scale(calc(0.995 + var(--voice-avatar-level) * 0.03));
    transition:
        border-color 0.24s ease,
        box-shadow 0.16s linear,
        transform 0.16s linear;
    z-index: 2;
}

.voice-role-image {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 18%;
    background:
        radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.16), rgba(16, 20, 34, 0.96));
    filter: saturate(calc(0.92 + var(--voice-avatar-level) * 0.38));
    user-select: none;
    -webkit-user-drag: none;
}

.voice-live-bubble {
    position: absolute;
    left: 50%;
    top: 70%;
    transform: translate(-50%, -50%);
    z-index: 4;
    width: min(78vw, 560px);
    padding: 22px 28px 18px;
    border-radius: 24px;
    background: transparent;
    color: rgba(255, 245, 247, 0.96);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}

.voice-live-bubble.user {
    background: transparent;
}

.voice-live-speaker {
    display: none;
}

.voice-live-text {
    width: 100%;
    min-height: 54px;
    font-size: clamp(18px, 2.2vw, 21px);
    line-height: 1.7;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.28);
    white-space: pre-wrap;
    word-break: break-word;
}

.voice-call-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    margin-top: 24px;
    transform: translateY(calc(var(--voice-layout-drop) * -0.35));
}

.voice-control-btn {
    width: 78px;
    height: 78px;
    appearance: none;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 18px 28px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.voice-control-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.04);
}

.voice-control-btn:disabled {
    opacity: 0.46;
    cursor: not-allowed;
}

.voice-control-start {
    display: none;
}

.voice-control-stop {
    background: linear-gradient(180deg, #b45656 0%, #7f2f2f 100%);
}

.voice-call-hint {
    display: none;
}

@keyframes voice-avatar-spin {
    from {
        transform: rotate(0deg) scale(calc(0.985 + var(--voice-avatar-level) * 0.045));
    }
    to {
        transform: rotate(360deg) scale(calc(0.985 + var(--voice-avatar-level) * 0.045));
    }
}

@keyframes voice-avatar-pulse {
    0% {
        transform: scale(calc(0.985 + var(--voice-avatar-level) * 0.03));
    }
    50% {
        transform: scale(calc(1.015 + var(--voice-avatar-level) * 0.06));
    }
    100% {
        transform: scale(calc(0.99 + var(--voice-avatar-level) * 0.035));
    }
}

.rtc-transcript {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.rtc-transcript-empty,
.rtc-transcript-item,
.rtc-transcript-role,
.rtc-transcript-text {
    display: none;
}

@media (max-width: 700px) {
    .voice-call-shell {
        padding:
            max(12px, env(safe-area-inset-top))
            14px
            calc(14px + env(safe-area-inset-bottom));
    }

    .voice-avatar-stage {
        width: min(74vw, 280px);
        margin-top: 4px;
        padding-top: clamp(8px, 1.8vh, 16px);
    }

    .voice-call-shell {
        --voice-avatar-size: min(56vw, 248px);
    }

    .voice-live-bubble {
        width: min(80vw, 360px);
        padding: 18px 18px 14px;
        border-radius: 22px;
    }

    .voice-live-text {
        min-height: 46px;
        font-size: 17px;
    }

    .voice-call-actions {
        margin-top: 22px;
    }

    .voice-control-btn {
        width: 70px;
        height: 70px;
        font-size: 30px;
    }
}
