:root {
    --primary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #2ecc71;
    --text-color: #ffffff;
    --bg-gradient: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.status-bar {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #95a5a6;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.status-light.listening {
    background-color: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
}

.status-light.speaking {
    background-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

#status-text {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
}

.volume-indicator {
    font-size: 12px;
    opacity: 0.7;
    height: 16px;
    min-width: 40px;
}

.controls {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    outline: none;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-danger {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.hidden {
    display: none !important;
}

.main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    gap: 30px;
}

.avatar-wrapper {
    width: 80vw;
    max-width: 350px;
    height: 80vw;
    max-height: 350px;
    position: relative;
    z-index: 10;
    border-radius: 0;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
    border: none;
    background: rgba(0, 0, 0, 0.2);
    overflow: visible;
}

.display-toggle-button {
    position: absolute;
    top: -42px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.camera-main-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    z-index: 5;
}

.avatar-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

#avatar-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.3);
    transform-origin: center;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.robot-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
    background: linear-gradient(to right, #fff, #a5d8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    z-index: 20;
}

.wave-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.wave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    opacity: 0;
    animation: ripple 2s infinite;
}

.wave:nth-child(2) {
    animation-delay: 0.6s;
}

.wave:nth-child(3) {
    animation-delay: 1.2s;
}

@keyframes ripple {
    0% {
        width: 20%;
        height: 20%;
        opacity: 0.8;
        border-width: 4px;
    }

    100% {
        width: 100%;
        height: 100%;
        opacity: 0;
        border-width: 0px;
    }
}

.subtitle-container {
    height: 100px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    overflow: hidden;
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.subtitle-text {
    white-space: nowrap;
    font-size: 20px;
    font-weight: 500;
    color: #fff;
    padding: 0 20px;
    position: absolute;
    transform: translateX(100vw);
    will-change: transform;
}

.scrolling {
    animation: scroll-text linear forwards;
}

@keyframes scroll-text {
    from {
        transform: translateX(100vw);
    }

    to {
        transform: translateX(-100%);
    }
}

.text-mode-link {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    z-index: 50;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    font-weight: 500;
}

.text-mode-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.camera-preview-panel {
    position: fixed;
    right: 16px;
    bottom: 118px;
    width: 172px;
    height: 208px;
    z-index: 200;
    border-radius: 16px;
    overflow: hidden;
    padding: 36px 8px 8px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.camera-preview-title-row {
    position: absolute;
    top: 8px;
    left: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.camera-preview-title {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.camera-preview-title,
.camera-facing-select {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.camera-facing-select {
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    flex: 0 0 64px;
    width: 64px;
    min-width: 64px;
    cursor: pointer;
    text-align: center;
}

.camera-facing-select option {
    color: #111;
}

.camera-preview-title {
    position: absolute;
    position: static;
}

.camera-preview-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #000;
    border-radius: 12px;
}

.camera-preview-avatar {
    position: absolute;
    inset: 36px 8px 8px;
    width: auto;
    height: auto;
    max-width: calc(100% - 16px);
    max-height: calc(100% - 44px);
    margin: auto;
    object-fit: contain;
    z-index: 1;
}

.camera-hidden {
    position: fixed;
    width: 1px;
    height: 1px;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 420px) {
    .camera-preview-panel {
        width: 156px;
        height: 192px;
        right: 12px;
    }

    .display-toggle-button {
        top: -38px;
        padding: 7px 14px;
        font-size: 12px;
    }
}

/* 媒体弹窗 */
.media-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.media-popup-modal.hidden {
    display: none !important;
}

.media-popup-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 80%;
    background: #111;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.media-popup-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 36px;
    height: 36px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10001;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#media-popup-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    min-height: 200px;
}

#media-popup-container img,
#media-popup-container video,
#media-popup-container iframe {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    border: none;
}

/* 环境检测遮罩 */
.env-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.env-overlay.hidden {
    display: none;
}

.env-overlay-content {
    text-align: center;
    color: #fff;
    max-width: 300px;
}

.env-overlay-content h3 {
    font-size: 24px;
    font-weight: 600;
    margin: 20px 0 10px;
}

.env-overlay-content p {
    font-size: 14px;
    opacity: 0.8;
    margin: 0;
    line-height: 1.5;
}

/* 加载动画 */
.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
