/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 根元素变量定义 */
:root {
    --primary-color: #3B82F6;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --neutral-color: #6B7280;
    --background-color: #F8FAFC;
    --surface-color: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-large: 0 8px 25px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 页面标题 */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
    background: linear-gradient(135deg, var(--primary-color), #1D4ED8);
    color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 400;
}

/* 通用区块样式 */
section {
    margin-bottom: 40px;
}

section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    padding-left: 12px;
    border-left: 4px solid var(--primary-color);
}

/* 视频区域 */
.video-section {
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    position: relative;
    z-index: 100;
    transition: var(--transition);
}

/* 浮动视频样式 */
.video-section.floating {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    width: 600px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 24px;
    z-index: 1000;
    cursor: default;
    user-select: none;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 16px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* 防止意外的位置重置 */
    will-change: transform, left, top;
}

/* 浮动视频拖拽状态 - 拖拽时禁用transform */
.video-section.floating.dragging {
    cursor: grabbing;
    /* 拖拽时使用绝对定位，不使用transform */
    transform: none;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.99);
    /* 拖拽时禁用过渡动画 */
    transition: none;
}

/* 浮动视频可拖动区域 */
.video-section.floating .video-container,
.video-section.floating h2 {
    cursor: move;
    /* 触摸设备优化 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 浮动视频控制栏 */
.video-section.floating .video-controls {
    max-width: 552px;
}

.video-section.floating h2 {
    font-size: 1.4rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* 浮动视频提示 */
.video-section.floating::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.video-section.floating:hover::after {
    opacity: 1;
}

/* 触摸设备优化 */
@media (max-width: 768px) {
    .video-section.floating {
        top: 10px;
        left: 50%;
        width: calc(100vw - 20px);
        max-width: none;
        padding: 16px;
        transform: translateX(-50%) scale(0.85);
        border-radius: 12px;
        /* 移动端触摸优化 */
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        /* 防止滚动干扰 */
        touch-action: none;
    }
    
    .video-section.floating.dragging {
        /* 移动端拖拽时也禁用transform */
        transform: none;
    }
    
    .video-section.floating .video-container,
    .video-section.floating h2 {
        /* 移动端触摸优化 */
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    .video-section.floating .video-controls {
        max-width: calc(100vw - 52px);
    }
    
    .video-section.floating h2 {
        font-size: 1.2rem;
    }
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 20px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

/* 非浮动状态下的拖拽支持 */
.video-section:not(.floating) .video-container,
.video-section:not(.floating) h2 {
    cursor: move;
}

.video-section:not(.floating).dragging {
    cursor: grabbing;
}

.video-container::before {
    content: '';
    display: block;
    padding-top: 56.25%; /* 16:9 比例 */
}

#referenceVideo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 视频控制栏 */
.video-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.control-group-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.control-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: #2563EB;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.control-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.control-btn .pause-icon {
    display: none;
}

/* 复选框样式 */
.mute-checkbox, .drag-checkbox, .float-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #666;
    position: relative;
}

.mute-checkbox:hover, .drag-checkbox:hover, .float-checkbox:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #333;
}

.mute-checkbox input[type="checkbox"],
.drag-checkbox input[type="checkbox"],
.float-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.mute-checkbox .checkmark,
.drag-checkbox .checkmark,
.float-checkbox .checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 3px;
    margin-right: 8px;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mute-checkbox .checkmark::after,
.drag-checkbox .checkmark::after,
.float-checkbox .checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* 静音复选框样式 */
.mute-checkbox input[type="checkbox"]:checked + .checkmark {
    background-color: #dc3545;
    border-color: #dc3545;
}

.mute-checkbox input[type="checkbox"]:checked + .checkmark::after {
    display: block;
}

.mute-checkbox input[type="checkbox"]:checked ~ .checkbox-text {
    color: #dc3545;
    font-weight: 500;
}

/* 拖动复选框样式 */
.drag-checkbox input[type="checkbox"]:checked + .checkmark {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.drag-checkbox input[type="checkbox"]:checked + .checkmark::after {
    display: block;
}

.drag-checkbox input[type="checkbox"]:checked ~ .checkbox-text {
    color: var(--success-color);
    font-weight: 500;
}

/* 浮动复选框样式 */
.float-checkbox input[type="checkbox"]:checked + .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.float-checkbox input[type="checkbox"]:checked + .checkmark::after {
    display: block;
}

.float-checkbox input[type="checkbox"]:checked ~ .checkbox-text {
    color: var(--primary-color);
    font-weight: 500;
}

.checkbox-text {
    transition: all 0.2s ease;
    white-space: nowrap;
}

.control-btn.playing .play-icon {
    display: none;
}

.control-btn.playing .pause-icon {
    display: block;
}

.time-display {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 复选框样式 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    position: relative;
    z-index: 10;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    z-index: 11;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: var(--transition);
    pointer-events: none;
    background: var(--surface-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* 文本段落区域 */
.text-section {
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.text-segments {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.text-segment {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 24px;
    background: var(--background-color);
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    transition: var(--transition);
    position: relative;
    contain: layout style paint;
}

.text-segment:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.text-segment.completed {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

.text-segment.recording {
    border-color: var(--warning-color);
    background: rgba(245, 158, 11, 0.05);
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

/* 录制动画优化 */
.text-segment.recording {
    border-color: var(--warning-color);
    background: rgba(245, 158, 11, 0.05);
    animation: recordingPulse 1.5s infinite;
    transform: translateZ(0);
    will-change: box-shadow, transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

.record-btn.recording {
    animation: recordingPulse 1s infinite;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

@keyframes recordingPulse {
    0% {
        transform: translateZ(0) scale(1);
    }
    50% {
        transform: translateZ(0) scale(1.02);
    }
    100% {
        transform: translateZ(0) scale(1);
    }
}

.segment-content {
    flex: 1;
}

.segment-text {
    font-size: 1.6rem;
    line-height: 1.6;
    color: #080808;
    margin-bottom: 16px;
    font-weight: 500;
    cursor: pointer;
}

.segment-time {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-color);
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
}

.segment-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 升级版录音按钮 */
.record-btn {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
    box-shadow: var(--shadow-medium);
    cursor: pointer;
}

.record-btn.idle {
    background: #6B7280;
    color: white;
    border: 3px solid transparent;
}

.record-btn.idle:hover {
    background: #4B5563;
    border-color: #9CA3AF;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(107, 114, 128, 0.4);
}

.record-btn.recording {
    background: #F59E0B;
    color: white;
    border: 3px solid #FCD34D;
    animation: recordingPulse 1s infinite;
    transform: translateZ(0);
    will-change: transform;
}

.record-btn.recording:hover {
    background: #D97706;
    border-color: #F59E0B;
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.6);
}

.record-btn.completed {
    background: #10B981;
    color: white;
    border: 3px solid #34D399;
}

.record-btn.completed:hover {
    background: #059669;
    border-color: #10B981;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.record-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
}

.record-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: var(--transition);
}

.record-btn .stop-icon {
    display: none;
}

.record-btn .check-icon {
    display: none;
}

.record-btn.recording .mic-icon {
    display: none;
}

.record-btn.recording .stop-icon {
    display: block;
}

.record-btn.completed .mic-icon {
    display: none;
}

.record-btn.completed .stop-icon {
    display: none;
}

.record-btn.completed .check-icon {
    display: block;
}

/* 录音状态指示器 */
.record-btn::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    transition: var(--transition);
    z-index: 10;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.record-btn.idle::after {
    background: #9CA3AF;
}

.record-btn.recording::after {
    background: #EF4444;
    animation: recordingIndicator 1s infinite;
}

.record-btn.completed::after {
    background: #10B981;
}

@keyframes recordingIndicator {
    0%, 100% {
        transform: scale(1) translateZ(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) translateZ(0);
        opacity: 0.7;
    }
}

/* 播放按钮 */
.play-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-light);
}

.play-btn:hover:not(:disabled) {
    background: #2563EB;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.play-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.play-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.play-btn .pause-icon {
    display: none;
}

.play-btn.playing .play-icon {
    display: none;
}

.play-btn.playing .pause-icon {
    display: block;
}

/* 音色修改按钮 */
.voice-change-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    box-shadow: var(--shadow-medium);
    position: relative;
    overflow: hidden;
}

.voice-change-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.voice-change-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.voice-change-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* 音色指示器 */
.voice-change-btn.voice-changed {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.voice-change-btn.voice-changed:hover:not(:disabled) {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4);
}

.voice-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #10b981;
    border: 2px solid white;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    }
}

/* 变声按钮加载动画 */
.voice-change-btn .loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 状态指示器 */
.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--neutral-color);
    transition: var(--transition);
}

.status-indicator.completed {
    background: var(--success-color);
}

.status-indicator.recording {
    background: var(--warning-color);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0.3;
    }
}

/* 录音时长显示 */
.recording-time {
    font-size: 12px;
    color: var(--warning-color);
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

/* 波形显示区域 */
.waveform-container {
    position: relative;
    width: 100%;
    height: 60px;
    background: #F9FAFB;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 合并区域 */
.merge-section {
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    text-align: center;
}

.merge-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-bottom: 30px;
}

.merge-progress {
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--background-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.progress-percentage {
    font-weight: 600;
    color: var(--primary-color);
}

/* 预览区域 */
.preview-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.preview-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.audio-player {
    background: var(--background-color);
    border-radius: var(--border-radius);
    padding: 20px;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-end;
}

.player-time {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 90px;
    text-align: right;
}

/* 下载区域 */
.download-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.file-info h4 {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.download-controls {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
}

#customFileName {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--surface-color);
    transition: var(--transition);
    min-width: 200px;
}

#customFileName:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-width: 44px;
    height: 44px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563EB;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--background-color);
    border-color: var(--primary-color);
}

.btn-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* 状态提示弹窗 */
.status-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.status-overlay.show {
    opacity: 1;
    visibility: visible;
}

.status-content {
    background: var(--surface-color);
    padding: 32px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-large);
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: var(--transition);
}

.status-overlay.show .status-content {
    transform: scale(1);
}

.status-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-icon.success {
    background: var(--success-color);
}

.status-icon.error {
    background: var(--danger-color);
}

.status-icon.warning {
    background: var(--warning-color);
}

.status-icon.info {
    background: var(--primary-color);
}

.status-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.status-message {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.status-close {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.status-close:hover {
    background: #2563EB;
}

/* 权限请求弹窗 */
.permission-request {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.permission-content {
    background: var(--surface-color);
    padding: 32px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-large);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.permission-content h3 {
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.permission-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* 视频回退样式 */
.video-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--background-color);
    color: var(--text-secondary);
    text-align: center;
    padding: 20px;
}

.video-fallback p {
    margin: 8px 0;
    font-size: 14px;
}

/* 隐藏类 */
.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 录音时长显示优化 */
.recording-time {
    font-size: 12px;
    color: var(--warning-color);
    font-weight: 600;
    min-width: 50px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    visibility: hidden;
}

.recording-time:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

/* 倒计时显示样式 */
.recording-time.countdown {
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 700;
    min-width: 60px;
    animation: countdown-pulse 1s infinite;
}

.recording-time.countdown.urgent {
    color: var(--danger-color);
    animation: countdown-urgent 0.5s infinite;
}

@keyframes countdown-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes countdown-urgent {
    0%, 100% {
        transform: scale(1);
        color: var(--danger-color);
    }
    50% {
        transform: scale(1.1);
        color: #dc2626;
    }
}

/* 波形显示区域优化 */
.waveform-container {
    position: relative;
    width: 100%;
    height: 60px;
    background: #F9FAFB;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.waveform-container:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

/* 预览模态框样式 */
/* 简化版变声预览模态框 */
.voice-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.voice-preview-modal-content {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    transform: scale(1);
    transition: transform 0.3s ease;
}

.voice-preview-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.voice-preview-header h3 {
    margin: 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.voice-preview-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.voice-preview-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.voice-preview-close svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.voice-preview-body {
    padding: 24px;
}

.audio-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.audio-item {
    background: var(--background-color);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.audio-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.audio-item h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.audio-item audio {
    width: 100%;
    margin-bottom: 12px;
}

.download-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
}

.download-btn:hover {
    background: #2563EB;
    transform: translateY(-1px);
}

.download-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .voice-preview-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .voice-preview-header {
        padding: 16px 20px;
    }
    
    .voice-preview-body {
        padding: 20px;
    }
}
}

.preview-option {
    background: var(--background-color);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.preview-option h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.preview-option audio {
    width: 100%;
    height: 40px;
}

.audio-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 500;
}

/* 预览按钮样式 */
.preview-btn {
    background: #8B5CF6;
    border: none;
    border-radius: 6px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    opacity: 1;
}

.preview-btn:hover:not(:disabled) {
    background: #7C3AED;
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.preview-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    background: #8B5CF6;
}

.preview-btn svg {
    width: 44px;
    height: 44px;
    fill: currentColor;
    display: block;
}

.preview-btn:disabled svg {
    opacity: 0.5;
}

/* 音频预览区域 */
.audio-preview-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.audio-preview-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.audio-preview-section .audio-player {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--background-color);
    border-radius: var(--border-radius);
    padding: 20px;
}

.audio-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 10;
}

/* 简化的音频播放器样式 */
.audio-player-simple {
    width: 100%;
    padding: 20px;
    background: var(--background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.audio-player-simple audio {
    width: 100%;
    outline: none;
}

.audio-player-simple audio::-webkit-media-controls-panel {
    background-color: var(--background-color);
}

.audio-player-simple audio::-webkit-media-controls-play-button,
.audio-player-simple audio::-webkit-media-controls-pause-button {
    background-color: var(--primary-color);
    border-radius: 50%;
}

.audio-player-simple audio::-webkit-media-controls-current-time-display,
.audio-player-simple audio::-webkit-media-controls-time-remaining-display {
    color: var(--text-primary);
    font-weight: 500;
}

/* 音频进度条和波形整合样式 */
.audio-progress-container .progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: transparent;
    z-index: 10;
    cursor: pointer;
    margin-bottom: 0;
}

.audio-progress-container .progress-fill {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-color) 50%, transparent 50%);
    opacity: 0.7;
}

.audio-progress-container .waveform-container {
    position: relative;
    z-index: 1;
}

.audio-progress-container .player-time {
    position: relative;
    z-index: 5;
    text-align: right;
}

#audioProgressBar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

#audioProgressFill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #8B5CF6);
    border-radius: 3px;
    transition: width 0.1s ease;
    width: 0%;
}

#audioProgressBar:hover #audioProgressFill {
    background: linear-gradient(90deg, #2563EB, #7C3AED);
}

.player-time {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
}

.audio-preview-section .play-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-light);
}

.audio-preview-section .play-btn:hover:not(:disabled) {
    background: #2563EB;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.audio-preview-section .play-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.audio-preview-section .play-btn .pause-icon {
    display: none;
}

.audio-preview-section .play-btn.playing .play-icon {
    display: none;
}

.audio-preview-section .play-btn.playing .pause-icon {
    display: block;
}

.audio-preview-section audio {
    flex: 1;
}

.audio-preview-section .waveform-container {
    flex: 2;
}

.audio-preview-section .player-time {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 80px;
    text-align: right;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header {
        padding: 24px 16px;
        margin-bottom: 24px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .video-section {
        padding: 20px;
        margin-bottom: 24px;
        position: relative;
    }
    
    .video-controls {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .text-section,
    .merge-section {
        padding: 20px;
        margin-bottom: 24px;
    }
    
    .text-segment {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .segment-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .segment-text {
        text-align: center;
        font-size: 1rem;
    }
    
    section h2 {
        font-size: 1.3rem;
        margin-bottom: 16px;
    }
    
    .download-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    #customFileName {
        min-width: auto;
        width: 100%;
    }
    
    .player-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .audio-preview-section .audio-player {
        flex-direction: column;
        gap: 12px;
    }
    
    .audio-preview-section .waveform-container {
        flex: none;
        width: 100%;
    }
    
    .audio-preview-section .player-time {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .text-segment {
        padding: 16px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .record-btn {
        width: 48px;
        height: 48px;
    }
    
    .play-btn,
    .voice-change-btn {
        width: 40px;
        height: 40px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* 辅助功能 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 录制状态下的布局稳定性 */
.segment-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    contain: layout;
}

.record-btn {
    contain: layout style paint;
    transform: translateZ(0);
}

.record-btn {
    position: relative;
    isolation: isolate;
}

.record-btn {
    flex-shrink: 0;
    flex-grow: 0;
}

.record-btn {
    min-width: 56px;
    min-height: 56px;
}

.record-btn.recording {
    animation: recordingPulse 1s infinite;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    contain: layout style paint;
}

.text-segment.recording {
    contain: layout style paint;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.record-btn::after {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    transition: var(--transition);
    z-index: 10;
    transform: translateZ(0);
    backface-visibility: hidden;
    pointer-events: none;
}

/* 视频合并区域 */
.video-merge-section {
    background: var(--surface-color);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    text-align: center;
    margin-top: 40px;
}

.video-merge-controls {
    margin-bottom: 30px;
}

/* 视频合并进度 */
.video-merge-progress {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 30px;
}

/* 最终视频预览 */
.final-video-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.final-video-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.2rem;
}

/* 加载动画 */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

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

.final-video-section .video-container::before {
    display: none;
}

#finalVideo {
    width: 100%;
    height: auto;
    max-height: 450px;
    border-radius: 12px;
}

/* 录音时长显示 - 确保倒计时可见 */
.recording-time {
    font-size: 12px;
    color: var(--warning-color);
    font-weight: 600;
    min-width: 60px;
    text-align: center;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
}

/* 倒计时显示样式 */
.recording-time.countdown {
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 700;
    animation: countdown-pulse 1s infinite;
}

.recording-time.countdown.urgent {
    color: var(--danger-color);
    animation: countdown-urgent 0.5s infinite;
}

@keyframes countdown-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes countdown-urgent {
    0%, 100% {
        transform: scale(1);
        color: var(--danger-color);
    }
    50% {
        transform: scale(1.1);
        color: #dc2626;
    }
}

/* 预览按钮播放状态 */
.preview-btn.playing {
    background: #8B5CF6;
}

.preview-btn.playing:hover {
    background: #7C3AED;
}

.preview-btn.playing:hover:not(:disabled) {
    background: #7C3AED;
}

/* 预览按钮图标动画 */
.preview-btn.playing svg {
    animation: pulse 1.5s infinite;
}