/* ===== 全局重置 & 基础 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 品牌色：淘宝橙（ChatUI 品牌主色） */
    --primary: #FF6200;
    --primary-dark: #D45A00;
    --secondary: #FFA040;
    --accent: #F59E0B;
    --success: #22C55E;
    --danger: #EF4444;
    /* 背景与文字：夜青黑 + 雾灰蓝（ChatUI 语义色） */
    --bg: #F3F6F8;
    --white: #FFFFFF;
    --text-dark: #11192D;
    --text-mid: #4A5675;
    --text-light: #8C9AB5;
    --border: #E2E8F0;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-btn: 9999px;
    /* 中性阴影：夜青黑基色 */
    --shadow: 0 4px 24px rgba(17, 25, 45, 0.08);
    --shadow-lg: 0 12px 48px rgba(17, 25, 45, 0.12);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: min(100%, 1920px);
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== 导航栏 ===== */
.navbar {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 98, 0, 0.06);
}

.navbar .container {
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.nav-logo .logo-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0px;
}

.nav-logo .logo-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-logo .brand-name {
    font-weight: 800;
    font-size: 22px;
    color: var(--text-dark);
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.nav-logo .brand-name .highlight {
    color: var(--primary);
}

.nav-logo .brand-sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
    letter-spacing: 0.3px;
    margin-left: 46px;
    padding-top: 1px;
    white-space: nowrap;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-mid);
    text-decoration: none;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--primary);
    background: rgba(255, 98, 0, 0.06);
}

/* 已登录态：功能入口按钮（与 index.html 保持一致） */
.nav-actions .btn-nav-coming {
    position: relative;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    padding: 7px 14px;
    border: 1px dashed rgba(255, 98, 0, 0.35);
    border-radius: var(--radius-btn);
    background: rgba(255, 98, 0, 0.04);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-actions .btn-nav-coming:hover {
    background: rgba(255, 98, 0, 0.10);
    border-color: var(--primary);
}

/* 默认高亮（听力合成） */
.nav-actions .btn-nav-coming.btn-highlight {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: 1px solid transparent;
    box-shadow: 0 4px 16px rgba(255, 98, 0, 0.30);
}

.nav-actions .btn-nav-coming.btn-highlight:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 98, 0, 0.40);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.btn-logout {
    font-size: 14px;
    font-weight: 500;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    padding: 8px 18px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ===== 主体 ===== */
.tts-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 0 40px;
    /* 初始隐藏，避免 JS 初始化过程中布局重排导致的视觉跳变 */
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* JS 初始化完成后添加 .ready 类，平滑显示 */
.tts-main.ready {
    opacity: 1;
}

/* ===== 页面标题 ===== */
.page-header {
    display: flex;
    align-items: baseline; /* 下对齐 */
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
}

.page-header .page-subtitle {
    font-size: 13px;
    color: var(--text-mid);
}

/* ===== 模式切换 Tabs ===== */
.mode-tabs {
    display: flex;
    gap: 4px;
    background: var(--white);
    padding: 4px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    width: fit-content;
}

.mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-mid);
    transition: var(--transition);
}

.mode-tab:hover {
    color: var(--primary);
    background: rgba(255, 98, 0, 0.04);
}

.mode-tab.active {
    color: var(--white);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 4px 12px rgba(255, 98, 0, 0.25);
}

.mode-tab.active:hover {
    color: var(--white);
}

.mode-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-btn);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mode-tab .mode-badge.free {
    background: rgba(34, 197, 94, 0.15);
    color: #16A34A;
}

.mode-tab .mode-badge.paid {
    background: rgba(245, 158, 11, 0.15);
    color: #D97706;
}

.mode-tab.active .mode-badge.free {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.mode-tab.active .mode-badge.paid {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.mode-tab-text {
    font-size: 14px;
}

/* ===== 网格布局 ===== */
.tts-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: stretch;
}

/* ===== 通用卡片 ===== */
.tts-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    border: 1px solid rgba(255, 98, 0, 0.06);
}

.tts-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.tts-card-header h2 {
    font-size: 15px;
    font-weight: 700;
}

/* ===== 文本输入区 ===== */
.text-card {
    display: flex;
    flex-direction: column;
    position: relative;
}

.text-toolbar {
    display: flex;
    gap: 8px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-mid);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    text-decoration: none;
}

.tool-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(255, 98, 0, 0.04);
}

.tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: var(--text-light);
}

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

/* 上传方式选择器（分段控件风格） */
.upload-mode-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    margin-right: 4px;
}

.upload-mode-btn {
    position: relative;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-mid);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

.upload-mode-btn:hover {
    color: var(--primary);
    background: rgba(255, 98, 0, 0.06);
}

.upload-mode-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 2px 6px rgba(255, 98, 0, 0.2);
}

/* 文档上传状态 */
.doc-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, rgba(255, 98, 0, 0.06), rgba(255, 160, 64, 0.06));
    border: 1px solid rgba(255, 98, 0, 0.15);
    border-radius: var(--radius);
}

/* [hidden] 属性优先级需高于 display: flex，否则元素会一直显示 */
.doc-status[hidden] {
    display: none;
}

.doc-status-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.doc-status-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.doc-status-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-status-id {
    font-size: 11px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-status-remove {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.doc-status-remove:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* SSML 工具栏 */
.ssml-toolbar {
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(255, 98, 0, 0.04), rgba(255, 160, 64, 0.04));
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid rgba(255, 98, 0, 0.08);
}

.ssml-toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-mid);
    margin-right: 4px;
}

.btn-ssml {
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    background: var(--white);
    border: 1px solid rgba(255, 98, 0, 0.15);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

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

/* SSML 停顿下拉选择：与 .btn-ssml 风格保持一致 */
.select-ssml-break {
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    background: var(--white);
    border: 1px solid rgba(255, 98, 0, 0.15);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.select-ssml-break:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.select-ssml-break:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 98, 0, 0.1);
}

/* 下拉选项恢复默认配色（不受按钮主色影响） */
.select-ssml-break option {
    color: var(--text-dark);
    background: var(--white);
}

/* SSML 工具栏禁用状态 */
.ssml-toolbar.ssml-disabled {
    opacity: 0.5;
    background: rgba(148, 163, 184, 0.06);
    border-color: rgba(148, 163, 184, 0.15);
}

.ssml-toolbar.ssml-disabled .btn-ssml {
    cursor: not-allowed;
    color: var(--text-light);
    background: var(--bg);
    border-color: var(--border);
}

.ssml-toolbar.ssml-disabled .btn-ssml:hover {
    background: var(--bg);
    color: var(--text-light);
    border-color: var(--border);
}

.ssml-toolbar.ssml-disabled .select-ssml-break {
    cursor: not-allowed;
    color: var(--text-light);
    background: var(--bg);
    border-color: var(--border);
}

.ssml-toolbar.ssml-disabled .select-ssml-break:hover {
    background: var(--bg);
    color: var(--text-light);
    border-color: var(--border);
}

.ssml-disabled-tip {
    width: 100%;
    font-size: 12px;
    color: #92400E;
    background: rgba(245, 158, 11, 0.06);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-top: 6px;
    line-height: 1.5;
}

.textarea-wrapper {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

#textInput {
    width: 100%;
    flex: 1 1 auto;
    min-height: 280px;
    /* 固定高度避免首次加载时因 placeholder 行数/flex 分配导致的跳变 */
    height: 320px;
    padding: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    color: var(--text-dark);
    background: var(--bg);
    transition: var(--transition);
    outline: none;
    resize: none;
    line-height: 1.8;
}

#textInput:focus {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(255, 98, 0, 0.08);
}

#textInput::placeholder {
    color: var(--text-light);
    line-height: 1.8;
}

/* 文本状态栏 */
.text-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-light);
}

.status-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.char-count strong {
    color: var(--text-dark);
    font-weight: 700;
}

.char-count-detail {
    color: var(--text-light);
}

.char-count-detail strong {
    color: var(--text-mid);
}

.cn-ratio strong {
    font-weight: 700;
}

.cn-ratio.warn strong {
    color: var(--danger);
}

.cn-ratio.ok strong {
    color: var(--success);
}

/* 校验提示 */
.validation-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--danger);
    animation: shake 0.3s ease;
}

.validation-alert[hidden] {
    display: none !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.alert-icon {
    font-size: 16px;
}

/* ===== 上传进度遮罩 ===== */
.upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius);
}

.upload-overlay[hidden] {
    display: none;
}

.upload-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-overlay-spinner {
    width: 40px;
    height: 40px;
    border: 3.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: uploadOverlaySpin 0.8s linear infinite;
}

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

.upload-overlay-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

.upload-overlay-hint {
    font-size: 12px;
    color: var(--text-light);
}

/* ===== 右侧设置面板 ===== */
.settings-panel {
    display: flex;
    flex-direction: column;
}

.settings-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.settings-section {
    padding: 18px 20px;
}

.settings-section-header {
    margin-bottom: 12px;
}

.settings-section-header h2 {
    font-size: 14px;
    font-weight: 700;
}

.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 0 20px;
}

/* 发音人列表 */
.voice-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 发音人分组标题 */
.voice-group-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-mid);
    padding: 6px 4px 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.voice-group-title:first-child {
    padding-top: 0;
}

.voice-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.voice-item:hover {
    border-color: rgba(255, 98, 0, 0.3);
    background: rgba(255, 98, 0, 0.02);
}

.voice-item.selected {
    border-color: var(--primary);
    background: rgba(255, 98, 0, 0.04);
}

.voice-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.voice-avatar.male {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.voice-avatar.female {
    background: linear-gradient(135deg, #FF6200, #D45A00);
    color: white;
}

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

.voice-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

/* 发音人 SSML 徽章 */
.voice-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.voice-badge.ssml-ok {
    background: rgba(34, 197, 94, 0.10);
    color: #16A34A;
}

.voice-badge.ssml-no {
    background: rgba(148, 163, 184, 0.15);
    color: #64748B;
}

.voice-check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.voice-item.selected .voice-check {
    border-color: var(--primary);
    background: var(--primary);
}

.voice-item.selected .voice-check::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.free-voice-tip {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: var(--radius);
    font-size: 12px;
    color: #92400E;
    line-height: 1.6;
}

/* 音频参数 */
.param-group {
    margin-bottom: 14px;
}

.param-group:last-child {
    margin-bottom: 0;
}

.param-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.param-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(255, 98, 0, 0.08);
    padding: 2px 10px;
    border-radius: var(--radius-sm);
}

.param-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-sm);
    outline: none;
}

.param-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 98, 0, 0.3);
    transition: var(--transition);
}

.param-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.param-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 98, 0, 0.3);
}

.param-marks {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-light);
}

/* ===== 底部操作栏 ===== */
.action-bar {
    margin-top: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

/* 成本预估（内联，左侧） */
.cost-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: var(--transition);
}

.cost-preview:hover {
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
    transform: translateY(-1px);
}

.cost-preview-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.cost-preview-label {
    font-size: 13px;
    font-weight: 600;
    color: #92400E;
    white-space: nowrap;
}

.cost-preview-price {
    font-size: 16px;
    font-weight: 800;
    color: #D97706;
    white-space: nowrap;
}

.cost-preview-price strong {
    font-size: 18px;
}

.cost-preview-detail {
    font-size: 11px;
    color: #B45309;
    opacity: 0.85;
    white-space: nowrap;
}

.cost-preview-note {
    font-size: 11px;
    color: #A16207;
    opacity: 0.7;
    white-space: nowrap;
}

.cost-preview-sep {
    color: #D97706;
    opacity: 0.4;
    margin: 0 2px;
}

/* 合成按钮 */
.btn-synthesize {
    padding: 14px 48px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 24px rgba(255, 98, 0, 0.30);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 160px;
    margin-left: auto;
}

.btn-synthesize:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(255, 98, 0, 0.40);
}

.btn-synthesize:active:not(:disabled) {
    transform: translateY(0);
}

.btn-synthesize:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-synthesize.loading .btn-text {
    display: none;
}

.btn-synthesize.loading .btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-synthesize.loading .btn-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== 合成结果 ===== */
.result-card {
    margin-top: 20px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.audio-player {
    width: 100%;
    height: 48px;
    border-radius: var(--radius);
}

.result-actions {
    display: flex;
    gap: 12px;
}

/* ===== 弹窗通用样式 ===== */
.modal-overlay .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-overlay .modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-overlay .modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 20px;
    color: var(--text-mid);
    cursor: pointer;
    transition: var(--transition);
}

.modal-overlay .modal-close:hover {
    background: #E2E8F0;
    color: var(--text-dark);
}

.modal-overlay .modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 16px 28px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-overlay .modal-footer .btn-save {
    width: 120px;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 16px rgba(255, 98, 0, 0.25);
}

.modal-overlay .modal-footer .btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(255, 98, 0, 0.35);
}

/* ===== 费用明细弹窗 ===== */
.modal-overlay .cost-detail-box {
    max-width: 440px;
}

.modal-overlay .cost-detail-body {
    padding: 24px 28px;
    overflow-y: auto;
    text-align: left;
    justify-content: flex-start;
}

.cost-detail-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cost-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cost-detail-label {
    font-size: 14px;
    color: var(--text-mid);
}

.cost-detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.cost-detail-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.cost-detail-row.total .cost-detail-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
}

.cost-detail-price {
    font-size: 20px;
    font-weight: 800;
    color: #D97706;
}

.cost-detail-price strong {
    font-size: 24px;
}

.cost-detail-hint {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.5;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.04);
    border-radius: var(--radius-sm);
}

/* ===== SSML 帮助弹窗 ===== */
.modal-overlay .ssml-help-box {
    max-width: 640px;
    max-height: 85vh;
}

.modal-overlay .ssml-help-box .modal-body.ssml-help-body {
    padding: 24px 28px;
    overflow-y: auto;
    text-align: left;
    justify-content: flex-start;
    flex: 1 1 auto;
    min-height: 0;
}

.ssml-intro {
    font-size: 13px;
    color: var(--text-mid);
    line-height: 1.7;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(255, 98, 0, 0.04);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
}

.ssml-section {
    margin-bottom: 18px;
}

.ssml-section h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.ssml-section p {
    font-size: 13px;
    color: var(--text-mid);
    margin-bottom: 6px;
}

.ssml-section pre {
    background: #1E293B;
    color: #E2E8F0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

.ssml-note {
    font-size: 12px !important;
    color: var(--text-light) !important;
    font-style: italic;
}

.ssml-tip {
    font-size: 13px;
    color: var(--primary);
    background: rgba(255, 98, 0, 0.06);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

/* ===== 工具类 ===== */
.ssml-only[hidden] {
    display: none !important;
}

/* ===== 响应式 ===== */
@media (max-width: 960px) {
    .tts-grid {
        grid-template-columns: 1fr;
    }

    .action-bar {
        flex-direction: column-reverse;
        gap: 12px;
    }

    .cost-preview {
        width: 100%;
        justify-content: center;
    }

    .nav-logo .brand-sub {
        font-size: 10px;
        margin-left: 46px;
        white-space: normal;
    }
}

@media (max-width: 540px) {
    .container {
        padding: 0 16px;
    }

    .tts-card {
        padding: 16px 18px;
    }

    .settings-section {
        padding: 14px 16px;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .text-toolbar {
        flex-wrap: wrap;
    }

    .ssml-toolbar-row {
        gap: 6px;
    }

    .btn-ssml {
        padding: 4px 10px;
        font-size: 11px;
    }

    #textInput {
        min-height: 200px;
    }

    .mode-tab {
        padding: 8px 16px;
        font-size: 13px;
    }

    .nav-logo .brand-sub {
        font-size: 9px;
        margin-left: 0;
    }

    .nav-logo .logo-main .brand-name {
        font-size: 18px;
    }

    .nav-logo .logo-icon {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}
