/* ── MiMo TTS Studio — ElevenLabs Design System ── */
/* Reference: component-library.html */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── CSS Variables ── */
:root {
  --bg: #FDFCFC; --surface1: #F5F3F1; --surface2: #EDEBE8; --surface3: #E9E6E2;
  --border: #EDEBE8; --border-visible: #E9E6E2;
  --text1: #090F15; --text2: #57534E; --text3: #A59F97; --text4: #E9E6E2;
  --accent: #0A59D2; --accent-subtle: #EFF6FF;
  --success: #22C55E; --success-bg: #F0FDF4;
  --warning: #FBBE45; --warning-bg: #FFFBEB;
  --error: #F41A2F; --error-bg: #FEF2F2;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow-1: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-3: 0 8px 32px rgba(0,0,0,0.08);
}

/* ── Night Mode ── */
.theme-night, .dark {
  --bg: #090F15; --surface1: #1C1917; --surface2: #292524; --surface3: #44403C;
  --border: #292524; --border-visible: #44403C;
  --text1: #FDFCFC; --text2: #A59F97; --text3: #777169; --text4: #57534E;
  --accent: #60A5FA; --accent-subtle: #010D20;
  --success: #22C55E; --success-bg: #14532D;
  --warning: #FBBE45; --warning-bg: #78350F;
  --error: #F41A2F; --error-bg: #7F1D1D;
  --shadow-1: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-3: 0 8px 32px rgba(0,0,0,0.5);
}

/* ── Sidebar ── */
.el-sidebar {
  width: 220px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex; flex-direction: column;
  transition: background 500ms ease, border-color 500ms ease;
}
.sidebar-logo { padding: 16px 20px 0; margin-bottom: 24px; font-size: 16px; font-weight: 700; color: var(--text1); }
.sidebar-section { padding: 0 12px; margin-bottom: 24px; }
.sidebar-label { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text3); padding: 0 8px; margin-bottom: 8px; }
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--text2);
  cursor: pointer; transition: background 150ms ease, color 150ms ease;
  border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.sidebar-item:hover { background: var(--surface1); color: var(--text1); }
.sidebar-item.active { background: var(--accent-subtle); color: var(--accent); }
.sidebar-item i { font-size: 16px; }
.sidebar-spacer { flex: 1; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); }
.sidebar-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 600; }
.sidebar-username { font-size: 13px; font-weight: 500; color: var(--text1); }
.sidebar-plan { font-size: 11px; color: var(--text3); }

/* ── Main ── */
.el-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); transition: background 500ms ease; }
.main-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border); transition: border-color 500ms ease; }
.main-title { font-size: 20px; font-weight: 600; color: var(--text1); }

/* ── Tabs ── */
.el-tabs { display: flex; gap: 0; padding: 0 24px; border-bottom: 1px solid var(--border); transition: border-color 500ms ease; }
.el-tab { padding: 12px 16px; font-size: 13px; font-weight: 500; color: var(--text3); cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; transition: color 150ms ease, border-color 150ms ease; font-family: inherit; }
.el-tab:hover { color: var(--text2); }
.el-tab.active { color: var(--text1); border-bottom-color: var(--accent); }

/* ── Content ── */
.content { flex: 1; padding: 24px; overflow-y: auto; }
.content-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; height: 100%; }

/* ── Editor ── */
.editor { display: flex; flex-direction: column; gap: 16px; }
.editor-textarea {
  width: 100%; min-height: 160px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface1); font-family: var(--font-body); font-size: 15px;
  color: var(--text1); resize: vertical; outline: none;
  transition: border-color 150ms ease, background 500ms ease; line-height: 1.6;
}
.editor-textarea:focus { border-color: var(--border-visible); }
.editor-textarea::placeholder { color: var(--text3); }
.editor-toolbar { display: flex; align-items: center; gap: 8px; }
.editor-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: background 150ms ease; }
.editor-btn:hover { background: var(--surface1); }

/* ── Controls Panel ── */
.controls { display: flex; flex-direction: column; gap: 16px; }
.control-group { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; transition: background 500ms ease, border-color 500ms ease; }
.control-label { font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text3); margin-bottom: 12px; }
.control-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.control-row:last-child { margin-bottom: 0; }
.control-name { font-size: 13px; color: var(--text1); }
.control-value { font-size: 13px; color: var(--text3); font-weight: 500; min-width: 32px; text-align: right; }
.slider-track { flex: 1; height: 4px; background: var(--border); border-radius: 9999px; margin: 0 12px; position: relative; }
.slider-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: 9999px; background: var(--accent); }

/* ── Voice Selector ── */
.voice-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.voice-option:hover { border-color: var(--border-visible); }
.voice-option.selected { border-color: var(--accent); background: var(--accent-subtle); }
.voice-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.voice-name { font-size: 13px; font-weight: 500; color: var(--text1); }
.voice-meta { font-size: 11px; color: var(--text3); }

/* ── Buttons ── */
/* Large: 40px, 15px, 10px 24px, icon 18px */
/* Small: 32px, 13px,  6px 16px, icon 16px */
.el-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 10px 24px; border-radius: 9999px;
  font-family: var(--font-body); font-size: 15px; font-weight: 500;
  cursor: pointer; transition: opacity 150ms ease, background 150ms ease;
  border: none; outline: none; white-space: nowrap;
}
.el-btn-sm { height: 32px; padding: 6px 16px; font-size: 13px; }
.el-btn-primary { background: var(--accent); color: #fff; }
.el-btn-primary:hover { opacity: 0.9; }
.el-btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.el-btn-secondary { background: var(--text1); color: #fff; }
.el-btn-secondary:hover { opacity: 0.9; }
.el-btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.el-btn-ghost:hover { background: var(--surface1); }
.el-btn-danger { background: var(--error); color: #fff; }
.el-btn-danger:hover { opacity: 0.9; }
.el-btn-danger-outline { background: transparent; color: var(--error); border: 1px solid var(--error-bg); }
.el-btn-danger-outline:hover { background: var(--error-bg); }
.el-btn i { font-size: 18px; }
.el-btn-sm i { font-size: 16px; }

/* ── SVG 图标内联对齐 ── */
svg { vertical-align: middle; }
.icon-btn svg, .el-btn svg { display: block; }

/* ── Icon Button (圆形小图标按钮) ── */
.icon-btn {
  width: 28px; height: 28px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  color: var(--text2); transition: background 150ms ease, color 150ms ease;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface2); color: var(--text1); }
.icon-btn i { font-size: 15px; line-height: 1; }
.icon-btn-danger:hover { background: var(--error-bg); color: var(--error); }

/* ── Toggle Switch (36×20, 16px thumb) ── */
.toggle-track {
  width: 36px; height: 20px; border-radius: 9999px;
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background 150ms ease;
}
.toggle-track.off { background: var(--border); }
.toggle-track.on { background: var(--accent); }
.toggle-track::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; top: 2px;
  transition: transform 150ms ease;
}
.toggle-track.off::after { transform: translateX(0); left: 2px; }
.toggle-track.on::after { transform: translateX(16px); }

/* ── Filter Bar (pill tab selector) ── */
.filter-bar {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface1); border: 1px solid var(--border); border-radius: 9999px;
}
.filter-btn {
  padding: 6px 16px; border-radius: 9999px; border: none;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  font-family: inherit; background: transparent; color: var(--text3);
}
.filter-btn:hover { color: var(--text2); }
.filter-btn.active { background: var(--surface3); color: var(--text1); }

/* ── Tags (12px, pill, no border) ── */
.el-tag { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 9999px; font-size: 12px; font-weight: 500; border: none; font-family: var(--font-body); }
.el-tag-neutral { background: var(--surface1); color: var(--text2); }
.el-tag-selected { background: var(--accent-subtle); color: var(--accent); }
.el-tag-accent { background: var(--accent-subtle); color: var(--accent); }
.el-tag-success { background: var(--success-bg); color: var(--success); }
.el-tag-warning { background: var(--warning-bg); color: var(--warning); }
.el-tag-error { background: var(--error-bg); color: var(--error); }

/* ── Waveform ── */
.waveform { display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 4px; }
.wave-bar { flex: 1; border-radius: 2px; background: var(--accent); opacity: 0.6; transition: height 0.3s ease; }

/* ── Bottom Bar ── */
.bottom-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; border-top: 1px solid var(--border); background: var(--surface1); transition: background 500ms ease, border-color 500ms ease; flex-shrink: 0; }
.bottom-stat { font-size: 12px; color: var(--text3); }
.bottom-stat strong { color: var(--text1); font-weight: 500; }

/* ── Cards (standard / featured / compact) ── */
.el-card { background: var(--surface1); border: 1px solid var(--border); border-radius: 12px; transition: background 500ms ease, border-color 500ms ease; }
.el-card-featured { border-radius: 16px; padding: 32px; border-color: var(--border-visible); box-shadow: var(--shadow-2); }
.el-card-compact { border-radius: 8px; padding: 16px; }

/* ── Input (40px, pill, surface1 bg, 15px) ── */
.el-input {
  height: 40px; padding: 10px 16px; border-radius: 9999px;
  border: 1px solid var(--border); background: var(--surface1);
  font-family: var(--font-body); font-size: 15px; color: var(--text1);
  outline: none; width: 100%;
  transition: border-color 150ms ease, background 500ms ease;
}
.el-input:focus { border-color: var(--border-visible); }
.el-input::placeholder { color: var(--text3); }
.el-input-error { border-color: var(--error); }

/* ── Textarea (12px radius, surface1 bg, 15px) ── */
.el-textarea {
  min-height: 100px; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface1);
  font-family: var(--font-body); font-size: 15px; color: var(--text1);
  outline: none; width: 100%; resize: vertical;
  transition: border-color 150ms ease, background 500ms ease;
}
.el-textarea:focus { border-color: var(--border-visible); }

/* ── Select (pill, surface1 bg) ── */
.el-select {
  height: 40px; padding: 10px 16px; border-radius: 9999px;
  border: 1px solid var(--border); background: var(--surface1);
  font-family: var(--font-body); font-size: 15px; color: var(--text1);
  outline: none; cursor: pointer;
  transition: border-color 150ms ease, background 500ms ease;
}
.el-select:focus { border-color: var(--border-visible); }
.el-select-accent { border-color: var(--accent) !important; }
.el-select-accent:focus { border-color: var(--accent) !important; }
.theme-night .el-select-accent, .dark .el-select-accent { border-color: var(--border) !important; }
.theme-night .el-select-accent:focus, .dark .el-select-accent:focus { border-color: var(--border-visible) !important; }

/* ── Status Dot ── */
.status-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-dot.pending { background: var(--warning); animation: pulse 1.5s infinite; }
.status-dot.processing { background: var(--accent); animation: pulse 1s infinite; }
.status-dot.completed { background: var(--success); }
.status-dot.failed { background: var(--error); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── Recording ── */
.recording-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--error);
  animation: recording-pulse 1s ease-in-out infinite;
}
@keyframes recording-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.recording-wave {
  animation: wave-bounce 0.6s ease-in-out infinite alternate;
}
@keyframes wave-bounce {
  from { height: 15% !important; }
  to { height: 85% !important; }
}

/* ── Progress (4px, pill, semantic colors) ── */
.progress-track { height: 4px; border-radius: 9999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 9999px; transition: width 0.3s; }
.progress-fill-accent { background: var(--accent); }
.progress-fill-success { background: var(--success); }
.progress-fill-warning { background: var(--warning); }
.progress-fill-error { background: var(--error); }
/* backward compat */
.progress-bar { height: 4px; border-radius: 9999px; background: var(--border); overflow: hidden; }

/* ── Table ── */
.el-table { width: 100%; font-size: 13px; }
.el-table th { text-align: left; padding: 12px 16px; font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text3); border-bottom: 1px solid var(--border); }
.el-table td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text2); }
.el-table tr:last-child td { border-bottom: none; }
.el-table tr:hover td { background: rgba(0,0,0,0.015); }
.dark .el-table tr:hover td { background: rgba(255,255,255,0.03); }

/* ── Modal (16px radius, shadow-3) ── */
.modal-mask { background: rgba(0,0,0,0.35); backdrop-filter: blur(4px); }
.modal-body { background: var(--bg); border: 1px solid var(--border-visible); border-radius: 16px; box-shadow: var(--shadow-3); transition: background 500ms ease, border-color 500ms ease; }

/* ── Upload Zone ── */
.upload-zone { border: 1px dashed var(--border-visible); border-radius: 12px; transition: border-color 150ms ease, background 150ms ease; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--accent-subtle); }

/* ── Toast (12px radius, shadow-2, 360px max) ── */
@keyframes slide-in { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.animate-slide-in { animation: slide-in 0.25s ease-out; }
.toast-box {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; max-width: 360px;
  background: var(--surface1); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-2);
  font-size: 14px; color: var(--text1);
  transition: background 500ms ease, border-color 500ms ease;
}

/* ── Dropdown (12px radius, shadow-2) ── */
.dropdown { background: var(--surface1); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-2); overflow: hidden; transition: background 500ms ease, border-color 500ms ease; }
.dropdown-item { display: flex; align-items: center; height: 36px; padding: 0 16px; font-size: 13px; color: var(--text1); cursor: pointer; }
.dropdown-item:hover { background: var(--surface2); }
.dropdown-item.selected { background: var(--accent-subtle); color: var(--accent); }

/* ── Range ── */
input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; background: var(--border); border-radius: 9999px; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-visible); border-radius: 2px; }
.theme-night ::-webkit-scrollbar-thumb { background: var(--surface3); }

/* ── Night audio ── */
.theme-night audio { filter: invert(1) hue-rotate(180deg); }

/* ════════════════════════════════════════════════════════════
 *  Mobile Layout (< 768px)
 * ════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* 隐藏侧边栏 */
  .el-sidebar { display: none !important; }

  /* 主区域全宽 */
  .el-main { min-width: 0; }

  /* Header 紧凑 */
  .main-header { padding: 12px 16px; }
  .main-title { font-size: 16px; }

  /* 内容区缩小 padding，留出底部导航空间 */
  .content { padding: 16px; padding-bottom: 72px; }

  /* 合成页双栏 → 单栏堆叠 */
  .content-grid { grid-template-columns: 1fr; }

  /* 仪表盘 4 列 → 2 列 */
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

  /* 批量页 5 列 → 单列 */
  .grid-cols-5 { grid-template-columns: 1fr !important; }
  .col-span-3, .col-span-2 { grid-column: span 1 !important; }

  /* 音色库卡片 3 列 → 单列 */
  .lg\:grid-cols-3 { grid-template-columns: 1fr !important; }
  .md\:grid-cols-2 { grid-template-columns: 1fr !important; }

  /* 设置页内置音色 4 列 → 2 列 */
  .settings-voices-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* 表格横滑 */
  .el-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .el-table { min-width: 480px; }

  /* 模态框接近全屏 */
  .modal-body { max-width: calc(100vw - 16px) !important; margin: 8px !important; max-height: 92vh; }

  /* 底部状态栏隐藏（被底部导航替代） */
  .bottom-bar { display: none !important; }

  /* Toast 移到底部导航上方 */
  .mobile-toast-container { top: auto !important; bottom: 72px !important; left: 16px !important; right: 16px !important; }

  /* 音色选择器在合成页改为横滑 */
  .voice-select { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 8px; padding-bottom: 4px; }
  .voice-option { flex-shrink: 0; width: 160px; }

  /* 批量页文本域减小高度 */
  .batch-textarea-mobile { min-height: 180px !important; }

  /* 隐藏设置页快速选择按钮（太长放不下） */
  .settings-quick-btns { flex-direction: column; }
  .settings-quick-btns button { width: 100%; font-size: 11px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* 触控友好：按钮最小高度 */
  .el-btn { min-height: 44px; }
  .el-btn-sm { min-height: 36px; }
  .icon-btn { min-width: 36px; min-height: 36px; width: 36px; height: 36px; }
}

/* ── Mobile Bottom Navigation ── */
.mobile-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: 60px;
  display: flex; align-items: center; justify-content: space-around;
  background: var(--bg); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  transition: background 500ms ease, border-color 500ms ease;
}
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px 0; min-width: 56px;
  font-size: 10px; font-weight: 500; color: var(--text3);
  border: none; background: none; cursor: pointer; font-family: inherit;
  transition: color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item:active { opacity: 0.7; }
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item svg { flex-shrink: 0; }

/* ── Mobile More Overlay ── */
.mobile-more-mask {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(4px);
}
.mobile-more-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 46;
  background: var(--bg); border-top: 1px solid var(--border-visible);
  border-radius: 16px 16px 0 0; padding: 8px 0;
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
  box-shadow: var(--shadow-3);
  transition: background 500ms ease, border-color 500ms ease;
}
.mobile-more-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border-visible); margin: 0 auto 8px;
}
.mobile-more-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; font-size: 15px; font-weight: 500; color: var(--text1);
  border: none; background: none; width: 100%; text-align: left; cursor: pointer;
  font-family: inherit; transition: background 150ms ease;
  -webkit-tap-highlight-color: transparent;
}
.mobile-more-item:active { background: var(--surface1); }
.mobile-more-item svg { color: var(--text2); flex-shrink: 0; }
