:root {
    --bg: #f5f7ff;
    --panel: rgba(255, 255, 255, 0.72);
    --panel-border: rgba(255, 255, 255, 0.8);
    --text: #1b1f3b;
    --muted: #6f7690;
    --accent: #6c7cff;
    --accent-dark: #5b6ae6;
    --danger: #ff4d6d;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background:
        radial-gradient(120% 120% at 20% 20%, #ffffff 0%, rgba(255, 255, 255, 0) 60%),
        radial-gradient(120% 120% at 80% 0%, #e0edff 0%, rgba(255, 255, 255, 0) 50%),
        radial-gradient(160% 160% at 50% 120%, #dff9ff 0%, #f5f7ff 60%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    transition: opacity 0.2s ease;
}

body.overlay-active {
    overflow: hidden;
    background:
        radial-gradient(130% 130% at 10% 30%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.35) 40%, rgba(255, 255, 255, 0) 70%),
        radial-gradient(120% 120% at 90% 10%, rgba(215, 236, 255, 0.9) 0%, rgba(255, 255, 255, 0) 60%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.75), rgba(219, 236, 255, 0.9));
}

.app-shell {
    width: min(860px, 100%);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 32px;
    padding: 40px;
    backdrop-filter: blur(25px) saturate(160%);
    box-shadow: 0 30px 80px rgba(139, 160, 209, 0.35);
}

.hero {
    margin-bottom: 32px;
}

.hero .eyebrow {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 16px;
}

.hero h1 {
    margin: 0 0 12px;
    font-size: clamp(28px, 4vw, 40px);
}

.hero .lead {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.control-panel {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 20px 60px rgba(139, 160, 209, 0.25);
}

.panel-description {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.cta {
    border: none;
    border-radius: 16px;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.8), rgba(228, 234, 255, 0.9));
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 15px 35px rgba(143, 169, 230, 0.4);
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(228, 234, 255, 1));
}

.cta:active {
    transform: scale(0.99);
}

.webrtc-demo {
    display: none;
    justify-content: center;
    align-items: center;
    position: fixed;
    inset: 0;
    background:
        radial-gradient(120% 120% at 50% 20%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.2) 70%),
        rgba(230, 240, 255, 0.75);
    backdrop-filter: blur(20px) saturate(150%);
    z-index: 10;
    padding: clamp(12px, 4vw, 32px);
}

.video-wrapper {
    position: relative;
    width: min(96vw, 1280px);
    max-height: 92vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 30px 90px rgba(138, 164, 209, 0.45);
    overflow: hidden;
}

#localVideo {
    width: 100%;
    height: 100%;
    max-height: 92vh;
    border-radius: 24px;
    border: none;
    box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
    transform: scaleX(-1);
    object-fit: cover;
}

#webrtcRecord {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.9);
    background: radial-gradient(circle at 30% 30%, #ff8fa3, var(--danger));
    box-shadow: 0 0 30px rgba(255, 77, 109, 0.6);
    transition: border-radius 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    position: absolute;
}

#webrtcRecord:disabled {
    background: gray;
    box-shadow: none;
    cursor: not-allowed;
}

#webrtcRecord::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    opacity: 0;
}

#webrtcRecord.recording {
    border-radius: 16px;
    transform: translateX(-50%) scale(0.92);
}

#webrtcRecord.recording::after {
    opacity: 1;
    animation: pulseRecord 1.2s ease-in-out infinite;
}

#webrtcDownload {
    position: absolute;
    bottom: 120px;
    right: 40px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.8);
    color: var(--text);
    padding: 14px 24px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 15px 40px rgba(139, 160, 209, 0.4);
}

#webrtcClose {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 26px;
    padding: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.65);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.8);
    cursor: pointer;
}

#webrtcFullscreen {
    position: absolute;
    top: 30px;
    right: 90px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.65);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
}

#webrtcFullscreen.active {
    background: rgba(108, 124, 255, 0.3);
    color: var(--accent-dark);
}

#webrtcRecord,
#webrtcDuration,
#webrtcPause,
#webrtcAudioToggle {
    z-index: 2;
}

#webrtcPause {
    position: absolute;
    bottom: 44px;
    left: calc(50% + 150px);
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 12px 28px rgba(139, 160, 209, 0.35);
    cursor: pointer;
}

#webrtcPause:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#webrtcPause.paused {
    background: rgba(108, 124, 255, 0.25);
}

#webrtcAudioToggle {
    position: absolute;
    bottom: 44px;
    left: calc(50% - 180px);
    transform: translateX(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
    font-size: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px rgba(139, 160, 209, 0.35);
    cursor: pointer;
    overflow: visible;
}

#webrtcAudioToggle.muted {
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
}

#webrtcAudioToggle::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid rgba(108, 124, 255, 0.35);
    opacity: 0;
}

#webrtcAudioToggle.speaking::after {
    animation: audioPulse 0.9s ease-out infinite;
    opacity: 1;
}

#webrtcDuration {
    position: absolute;
    bottom: 44px;
    left: calc(50% + 260px);
    transform: translateX(-50%);
    color: var(--text);
    padding: 10px 14px;
    font-weight: 600;
    line-height: 1;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(139, 160, 209, 0.35);
}

@media (max-width: 640px) {
    body {
        padding: 24px 12px;
    }

    .app-shell {
        padding: 28px 20px;
    }

    .video-wrapper {
        width: 100%;
        max-height: 80vh;
    }

    #webrtcDuration {
        bottom: 120px;
        left: 50%;
        transform: translateX(-50%);
    }

    #webrtcPause {
        bottom: 120px;
        left: calc(50% + 140px);
        transform: translateX(-50%);
    }

    #webrtcAudioToggle {
        bottom: 120px;
        left: calc(50% - 150px);
        transform: translateX(-50%);
    }

    #webrtcFullscreen {
        top: 20px;
        right: 20px;
    }

    #webrtcClose {
        top: 20px;
        right: 76px;
    }
}

@keyframes pulseRecord {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.45);
        opacity: 0;
    }
}

.vc-switch {
    left: 16px !important;
    right: auto !important;
    bottom: 16px !important;
    background: rgba(255, 255, 255, 0.85) !important;
    color: var(--text) !important;
    border-radius: 16px !important;
    box-shadow: 0 12px 35px rgba(139, 160, 209, 0.4) !important;
}

@keyframes audioPulse {
    0% {
        transform: scale(0.9);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}
