/* ==================== Dubbing Editor Styles ==================== */

.dubbing-editor-container {
    display: none;
    flex-direction: column;
    height: calc(100vh - 80px); /* Adjust based on header height */
    background: var(--bg-color);
}

.dubbing-editor-container.active {
    display: flex;
}

/* Header */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.project-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-title input {
    border: none;
    background: none;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    width: 200px;
}

.project-title input:focus {
    outline: none;
}

.save-status {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--panel-bg);
    padding: 1px 5px;
    border-radius: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 通用 btn-secondary 样式（适用于所有位置） */
.btn-secondary {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--text-primary); /* 确保文字颜色不变 */
}

/* 确保 span 和 svg 在 hover 时可见 */
.btn-secondary:hover span,
.btn-secondary:hover svg {
    opacity: 1;
    visibility: visible;
}

/* Header Buttons (Polished) */
.header-right .btn-secondary,
.header-right .btn-primary {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-right .btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.header-right .btn-secondary:hover {
    background: var(--hover-bg);
}

.header-right .btn-primary {
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    color: white;
}

.header-right .btn-primary:hover {
    background: var(--primary-hover);
}

/* ==================== Export Dropdown ==================== */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.export-dropdown-btn:hover {
    background: var(--primary-hover);
}

.export-dropdown-btn .icon {
    width: 16px;
    height: 16px;
}

.export-dropdown-btn .dropdown-arrow {
    width: 12px;
    height: 12px;
    margin-left: 2px;
    transition: transform 0.2s;
}

.export-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.export-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 160px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s;
    z-index: 100;
}

.export-dropdown.open .export-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.export-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.export-dropdown-item:first-child {
    border-radius: 7px 7px 0 0;
}

.export-dropdown-item:last-child {
    border-radius: 0 0 7px 7px;
}

.export-dropdown-item:hover {
    background: var(--hover-bg);
}

.export-dropdown-item .icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.export-dropdown-item:hover .icon {
    color: var(--primary-color);
}

/* ==================== Unified Compact Header Layout ==================== */
.editor-header.unified-layout {
    padding: 6px 20px;
    min-height: 48px;
}

.editor-header.unified-layout .header-left {
    gap: 10px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.toolbar-divider-compact {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 2px;
}

.toolbar-btn-compact {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.toolbar-btn-compact:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.toolbar-btn-compact svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
}

.word-count-inline {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    margin-left: 6px;
}

/* Hide old toolbar section (deprecated) */
.editor-toolbar-top {
    display: none;
}

/* Responsive adjustments for compact layout */
@media (max-width: 1200px) {
    .toolbar-btn-compact .btn-label {
        display: none; /* Hide text, show icons only */
    }
    .toolbar-btn-compact {
        padding: 8px;
        min-width: 32px;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .editor-header.unified-layout {
        padding: 5px 16px;
        min-height: 44px;
    }
    .editor-header.unified-layout .header-left {
        gap: 6px;
    }
    .toolbar-btn-compact {
        padding: 4px 6px;
    }
    .word-count-inline {
        display: none; /* Hide on mobile */
    }
}

/* ==================== Synthesis Progress Bar ==================== */
.synthesis-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 24px 8px 24px;
    background: var(--bg-color);
    z-index: 10;
}

.progress-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--panel-bg);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    border-radius: 3px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Shimmer animation */
.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.progress-text {
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.editor-header.unified-layout.has-progress {
    padding-bottom: 48px;
}

@media (max-width: 768px) {
    .progress-text span {
        font-size: 10px;
    }
    .synthesis-progress-container {
        padding: 0 16px 6px 16px;
    }
}

/* Toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    gap: 24px;
}

.tool-group {
    display: flex;
    gap: 8px;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    gap: 6px;
    min-width: 64px;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.tool-btn.active {
    color: var(--primary-color);
    background: #e0e7ff; /* Light indigo */
}

.tool-btn svg {
    width: 24px;
    height: 24px;
}

.tool-btn span {
    font-size: 12px;
    font-weight: 500;
}

.tool-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

/* Workspace */
.editor-workspace {
    flex: 1;
    display: flex;
    gap: 0;
    background: white; /* Unified white background for whiteboard effect */
    overflow: hidden;
}

/* Left Editor Area */
.editor-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white; /* Match workspace background */
    overflow: hidden;
}

.editor-textarea {
    width: 100%;
    height: 100%;
    min-height: 600px;
    background: transparent; /* Transparent to blend with parent */
    border: none;
    border-radius: 0; /* Whiteboard effect: no rounded corners */
    padding: 24px 60px; /* Reduced top padding from 60px to 24px */
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
    resize: none;
    outline: none;
    box-shadow: none; /* Whiteboard effect: no shadow */
    transition: background-color 0.2s ease;
}

.editor-textarea:focus {
    background: #fafbfc; /* Subtle focus indicator */
}

/* Right Sidebar */
.editor-sidebar {
    position: relative;
    width: 280px;
    background: white;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.editor-sidebar.collapsed {
    width: 48px;
    min-width: 48px;
    overflow: hidden;
}

.editor-sidebar.collapsed .sidebar-section {
    display: none;
}

.editor-sidebar.collapsed .sidebar-collapse-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Sidebar Collapse Toggle */
.sidebar-collapse-btn {
    position: absolute;
    top: 12px;
    left: -14px;
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.sidebar-collapse-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.sidebar-collapse-btn svg {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.editor-sidebar.collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
    border-bottom: none;
    flex: 1;
    overflow-y: auto;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Current Voice Card */
.current-voice-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.current-voice-card .voice-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

.current-voice-card .voice-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.current-voice-card .voice-info {
    flex: 1;
    min-width: 0;
}

.current-voice-card .voice-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.current-voice-card .voice-lang {
    font-size: 12px;
    color: var(--text-secondary);
    background: #e0e7ff;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.current-voice-card .play-preview-btn {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.current-voice-card .play-preview-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Voice Parameters */
.param-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.param-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.param-row label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.param-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.param-controls input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.param-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
}

.param-controls input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.param-controls input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.param-controls input[type="range"]::-moz-range-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.param-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 48px;
    text-align: right;
}

/* Voice Search */
.voice-search {
    margin-bottom: 12px;
}

.voice-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.voice-search input:focus {
    border-color: var(--primary-color);
}

/* Voice List */
.voice-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.voice-list .voice-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.voice-list .voice-option:hover {
    background: var(--hover-bg);
}

.voice-list .voice-option.selected {
    background: #e0e7ff;
    border: 1px solid var(--primary-color);
}

.voice-list .voice-option .voice-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f3f4f6;
    overflow: hidden;
    flex-shrink: 0;
}

.voice-list .voice-option .voice-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.voice-list .voice-option .voice-details {
    flex: 1;
    min-width: 0;
}

.voice-list .voice-option .voice-details .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.voice-list .voice-option .voice-details .desc {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Floating Voice Card */
.floating-voice-card {
    background: white;
    color: var(--text-primary);
    padding: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    width: 280px;
    cursor: grab;
    transition: box-shadow 0.2s;
    user-select: none;
}

.floating-voice-card:active {
    cursor: grabbing;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.floating-voice-card:hover {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.voice-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

.voice-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.voice-info {
    flex: 1;
    min-width: 0;
}

.voice-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.voice-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.play-preview-btn {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.play-preview-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Voice Wrapper (for dropdown positioning) */
.floating-voice-wrapper {
    position: absolute;
    right: 60px;
    top: 60px;
    z-index: 10;
}

.floating-voice-wrapper .floating-voice-card {
    position: relative;
    right: auto;
    top: auto;
}

/* Voice Dropdown List */
.dubbing-voice-list {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    width: 280px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
}

.dubbing-voice-list .voice-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.dubbing-voice-list .voice-option:hover {
    background: var(--hover-bg);
}

.dubbing-voice-list .voice-option.selected {
    background: #e0e7ff;
}

.dubbing-voice-list .voice-option .voice-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3f4f6;
    overflow: hidden;
}

.dubbing-voice-list .voice-option .voice-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dubbing-voice-list .voice-option .voice-details {
    flex: 1;
}

.dubbing-voice-list .voice-option .voice-details .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.dubbing-voice-list .voice-option .voice-details .desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ==================== Top Toolbar ==================== */
.editor-toolbar-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.toolbar-btn svg {
    flex-shrink: 0;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

.word-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==================== Voice Quick Select ==================== */
.voice-quick-select {
    padding: 20px 24px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.quick-select-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.quick-voice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.quick-voice-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--panel-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-voice-card:hover {
    background: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.quick-voice-card.selected {
    background: #e0e7ff;
    border-color: var(--primary-color);
}

.quick-voice-card .voice-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #f3f4f6;
    border: 2px solid var(--border-color);
}

.quick-voice-card .voice-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.quick-voice-card .voice-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.quick-voice-card .voice-lang {
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ==================== Editor Text Area ==================== */
.editor-text-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.editor-text-area .editor-textarea {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: white;
    border: none;
    border-radius: 0; /* Whiteboard effect: no rounded corners */
    padding: 24px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
    resize: none;
    outline: none;
    box-shadow: none; /* Whiteboard effect: no shadow */
}

/* ==================== Modals (声音宇宙风格) ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.2),
        0 16px 32px rgba(99, 102, 241, 0.1);
    border: 1px solid var(--border-color);
    position: relative;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 渐变装饰边框 */
.modal-content::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 24px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.4) 0%, rgba(236, 72, 153, 0.4) 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 32px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.03) 0%, transparent 100%);
    position: relative;
}

/* 顶部渐变装饰条 - 已禁用，影响视觉效果 */
/*
.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, #6366f1, #ec4899);
    border-radius: 0 0 4px 4px;
}
*/

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    background: linear-gradient(135deg, var(--text-primary) 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--hover-bg);
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
}

.modal-close-btn:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-color: transparent;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.modal-body {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 32px;
    border-top: 1px solid var(--border-color);
    background: linear-gradient(0deg, rgba(99, 102, 241, 0.02) 0%, transparent 100%);
}

/* ==================== Form Elements ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.ai-prompt-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.ai-prompt-input:focus {
    border-color: var(--primary-color);
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.form-select:focus {
    border-color: var(--primary-color);
}

/* ==================== AI Output ==================== */
.ai-output {
    margin-top: 20px;
    padding: 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.ai-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ai-output-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-text:hover {
    background: rgba(99, 102, 241, 0.1);
}

.ai-output-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* ==================== Template Modal Redesign ==================== */
.templates-modal {
    max-width: 900px;
    max-height: 85vh;
}

.templates-modal .modal-header {
    border-bottom: none;
    padding-bottom: 8px;
}

.templates-modal .modal-body {
    padding-top: 0;
    max-height: calc(85vh - 140px);
    overflow-y: auto;
}

/* Category tabs */
.template-categories {
    display: flex;
    gap: 8px;
    padding: 0 24px 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.template-category-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--panel-bg);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-category-tab svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.5;
}

.template-category-tab:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.template-category-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.template-category-tab.active svg {
    stroke: white;
}

/* ==================== Template Grid ==================== */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.template-card {
    padding: 16px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12);
    transform: translateY(-2px);
}

.template-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.template-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    color: var(--primary-color);
}

.template-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--primary-color);
}

.template-info {
    flex: 1;
    min-width: 0;
}

.template-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.template-category-badge {
    display: inline-block;
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--panel-bg);
    padding: 2px 8px;
    border-radius: 10px;
}

.template-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
}

.template-preview {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 10px;
    background: var(--panel-bg);
    border-radius: 8px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ==================== Multi-Voice UI Styles ==================== */
.speaker-voice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.speaker-voice-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.speaker-voice-item:hover {
    background: white;
    border-color: var(--primary-color);
}

.speaker-name {
    flex: 0 0 80px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-selector {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.voice-selector:hover,
.voice-selector:focus {
    border-color: var(--primary-color);
}

.preview-btn-mini {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.preview-btn-mini:hover {
    background: var(--primary-hover);
    transform: scale(1.08);
}

.preview-btn-mini svg {
    width: 12px;
    height: 12px;
}

/* ==================== Inline Dialogue Editor Styles ==================== */
.dialogue-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.dialogue-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--panel-bg);
}

.dialogue-editor-header .mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.dialogue-editor-header .mode-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color) 0%, #818cf8 100%);
    color: white;
}

.dialogue-editor-header .preview-all-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #818cf8 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dialogue-editor-header .preview-all-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.dialogue-editor-header .preview-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Dialogue Lines Container */
.dialogue-lines-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.dialogue-line {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: all 0.2s;
}

.dialogue-line:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.dialogue-line.playing {
    border-color: var(--primary-color);
    background: #f0f4ff;
}

/* Speaker Badge with Voice Selection */
.speaker-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 100px;
    flex-shrink: 0;
}

.speaker-name-tag {
    font-size: 12px;
    font-weight: 600;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    text-align: center;
    min-width: 60px;
    cursor: pointer;
    transition: transform 0.15s;
}

.speaker-name-tag:hover {
    transform: scale(1.05);
}

/* Speaker color palette */
.speaker-color-0 { background: #6366f1; } /* Indigo */
.speaker-color-1 { background: #ec4899; } /* Pink */
.speaker-color-2 { background: #10b981; } /* Emerald */
.speaker-color-3 { background: #f59e0b; } /* Amber */
.speaker-color-4 { background: #8b5cf6; } /* Violet */
.speaker-color-5 { background: #06b6d4; } /* Cyan */
.speaker-color-6 { background: #ef4444; } /* Red */
.speaker-color-7 { background: #84cc16; } /* Lime */

.voice-mini-select {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-mini-select:hover {
    border-color: var(--primary-color);
}

/* Dialogue Content */
.dialogue-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialogue-text {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: white;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.dialogue-text:focus {
    border-color: var(--primary-color);
}

.dialogue-text::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Line Actions */
.line-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.line-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.line-action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.line-action-btn.play-btn:hover {
    background: var(--primary-color);
    color: white;
}

.line-action-btn.delete-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Add Line Button */
.add-dialogue-line-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    margin-top: 8px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-dialogue-line-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f4ff;
}

/* Empty State */
.dialogue-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    text-align: center;
}

.dialogue-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.dialogue-empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.dialogue-empty-state p {
    font-size: 13px;
    line-height: 1.5;
    max-width: 300px;
}

/* Voice Quick Picker Dropdown */
.voice-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    min-width: 200px;
}

.voice-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.voice-picker-item:hover {
    background: var(--hover-bg);
}

.voice-picker-item.selected {
    background: #e0e7ff;
}

.voice-picker-item .voice-avatar-xs {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f3f4f6;
    overflow: hidden;
}

.voice-picker-item .voice-avatar-xs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.voice-picker-item .voice-name-small {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Hidden state for single voice sidebar section */
.sidebar-section.hidden-in-multi-voice {
    display: none;
}

/* Compact Role Manager in Sidebar */
.role-manager-section {
    padding: 16px;
    background: var(--panel-bg);
    border-radius: 10px;
    margin-bottom: 12px;
}

.role-manager-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.role-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.role-item:last-child {
    border-bottom: none;
}

.role-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.role-name-display {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.role-voice-name {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* AI Smart Voice Matching Button */
.ai-smart-match-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-smart-match-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.ai-smart-match-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-smart-match-btn:active {
    transform: translateY(0);
}

/* Preview All Button */
.btn-preview-all {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-preview-all:hover {
    border-color: var(--primary-color);
    background: #f0f4ff;
}

.btn-preview-all .preview-play-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #818cf8 100%);
    border-radius: 50%;
    color: white;
}

.btn-preview-all .preview-play-icon svg {
    width: 10px;
    height: 10px;
    margin-left: 1px;
}

.btn-preview-all:hover .preview-play-icon {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
}

/* Preview spinner for loading state */
.btn-preview-all .preview-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.btn-preview-all .preview-spinner svg.spinning {
    animation: spin 1s linear infinite;
    color: var(--primary-color);
}

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

.btn-preview-all:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==================== Editor Mode Tabs ==================== */
.editor-mode-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    margin-bottom: 0;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px 8px 0 0;
    padding: 4px 4px 0 4px;
}

.editor-mode-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s ease;
    position: relative;
}

.editor-mode-tab:hover {
    color: var(--text-primary, #1f2937);
    background: var(--bg-tertiary, #f3f4f6);
}

.editor-mode-tab.active {
    color: var(--primary-color, #6366f1);
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-bottom: 1px solid var(--bg-primary, #ffffff);
    margin-bottom: -1px;
}

/* Adjust editor text area when tabs are present */
.editor-left {
    display: flex;
    flex-direction: column;
}

.editor-text-area {
    flex: 1;
    border-radius: 0 0 8px 8px;
}

.dialogue-editor-container {
    flex: 1;
    border-radius: 0 0 8px 8px;
}
