/* ========================================================
   现代通透毛玻璃设计系统核心样式表 (Glassmorphism Core Theme)
   设计规范参照：DESIGN_AND_ARCHITECTURE_SPEC.md
   ======================================================== */

:root {
  /* 品牌主色系：明亮现代蓝 */
  --primary: #3b82f6;
  --ph: #2563eb;                    /* Hover 交互深蓝 */
  --tb: rgba(59, 130, 246, 0.12);   /* 主色极淡半透明底色（高亮背景） */

  /* 功能语义色彩 */
  --success: #10b981;
  --success-hover: #059669;
  --warn: #f59e0b;
  --warn-hover: #d97706;
  --danger: #ef4444;
  --danger-hover: #dc2626;

  /* 背景与字色 */
  --bgc: #f8fafc;
  --tx: #1e293b;                    /* 主文字：深石板灰 Slate-800，避免使用纯黑 #000 */
  --tx-muted: #64748b;              /* 次要/元数据文字 Slate-500 */
  --tx-subtle: #94a3b8;

  /* 卡片质感与边框系统 */
  --cb: rgba(255, 255, 255, 0.72);  /* 毛玻璃卡片底色 (72% 透白) */
  --cb-hover: rgba(255, 255, 255, 0.85);
  --cd: rgba(0, 0, 0, 0.08);        /* 极细微卡片轮廓外边框 */
  --border-focus: rgba(59, 130, 246, 0.25);

  /* 物理动效缓动曲线 (Spring Easing) */
  --sp: cubic-bezier(0.2, 0.8, 0.2, 1);       /* 弹性操作缓动 */
  --sp-modal: cubic-bezier(0.16, 1, 0.3, 1);  /* 弹窗专用优雅缓动 */

  --app-height: 100vh;
}

/* 视口稳定防抖与盒模型 */
html {
  scrollbar-gutter: stable; /* 关键：保留滚动条宽度占位，避免弹窗抖动 */
  overflow-y: scroll;
}

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bgc);
  color: var(--tx);
  min-height: var(--app-height);
  position: relative;
  overflow-x: hidden;
  padding: 24px 16px 80px 16px;
  line-height: 1.5;
}

/* 双层超低开销模糊环境底色 (Ambient Mesh Gradient) */
.bg-layer {
  position: fixed;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  z-index: -1;
  pointer-events: none;
  background: 
    radial-gradient(circle at 18% 20%, rgba(59, 130, 246, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 82% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(139, 92, 246, 0.09) 0%, transparent 50%),
    radial-gradient(circle at 80% 85%, rgba(59, 130, 246, 0.07) 0%, transparent 40%);
  filter: blur(40px);
}

/* 顶部优雅渐变进度指示条 */
.top-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #10b981);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
  z-index: 99999;
  transition: width 0.25s ease, opacity 0.3s ease;
  pointer-events: none;
  opacity: 0;
  width: 0%;
}

/* 主容器：黄金宽度收敛 900px */
.container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ================= 头部与品牌规范 ================= */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.brand-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--tx);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--tx-muted);
  font-weight: 500;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--cd);
  color: var(--tx);
  backdrop-filter: blur(8px);
}

.badge-tag.cloudflare {
  background: rgba(246, 130, 31, 0.1);
  color: #d97706;
  border-color: rgba(246, 130, 31, 0.2);
}

.badge-tag.pure-local {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.2);
}

/* ================= 磨砂拟物卡片规范 ================= */
.card, .glass-card {
  background: var(--cb);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--cd);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04), inset 0 1px 1px rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.25s var(--sp), box-shadow 0.2s ease, opacity 0.25s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07), inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

/* ================= 药丸滑动切换栏 (Pill Tabs) ================= */
.pill-tabs-nav {
  position: relative;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 14px;
  padding: 4px;
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.03);
  user-select: none;
}

.pill-tab-item {
  flex: 1;
  text-align: center;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--tx-muted);
  cursor: pointer;
  z-index: 2;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  outline: none;
}

.pill-tab-item.active {
  color: var(--primary);
  font-weight: 700;
}

/* 滑动底色药丸指示器 */
.pill-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s var(--sp), width 0.3s var(--sp);
  z-index: 1;
  pointer-events: none;
}

/* ================= 预设场景快捷选择栏 ================= */
.presets-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tx-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.preset-chip {
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.22s var(--sp);
  text-align: left;
}

.preset-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.35);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.08);
}

.preset-chip.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.15);
}

.preset-chip-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--tx);
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-chip.active .preset-chip-title {
  color: var(--primary);
}

.preset-chip-desc {
  font-size: 11.5px;
  color: var(--tx-muted);
  line-height: 1.4;
}

.preset-chip-ratio {
  margin-top: 4px;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

/* ================= 压缩参数配置面板 ================= */
.config-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tx);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label .sub-text {
  font-weight: 400;
  font-size: 11px;
  color: var(--tx-muted);
}

.modern-select {
  appearance: none;
  background: rgba(255, 255, 255, 0.8) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--cd);
  border-radius: 10px;
  padding: 9px 34px 9px 12px;
  font-size: 13.5px;
  color: var(--tx);
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.modern-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--tb);
}

/* 滑块样式 */
.slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-val-badge {
  background: var(--tb);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 6px;
}

.modern-range {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  outline: none;
  cursor: pointer;
}

.modern-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

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

/* ================= 拖拽上传区域 (Dropzone) ================= */
.dropzone-container {
  border: 2px dashed rgba(59, 130, 246, 0.25);
  background: rgba(255, 255, 255, 0.45);
  border-radius: 18px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s var(--sp);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
}

.dropzone-container:hover, .dropzone-container.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.04);
  transform: scale(1.008);
}

.dropzone-icon-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--tb);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.6);
  transition: transform 0.2s var(--sp);
}

.dropzone-container:hover .dropzone-icon-circle {
  transform: translateY(-3px) scale(1.05);
}

.dropzone-text-primary {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--tx);
}

.dropzone-text-secondary {
  font-size: 12.5px;
  color: var(--tx-muted);
}

.dropzone-tags {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.dropzone-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--tx-muted);
  background: rgba(0, 0, 0, 0.04);
  padding: 3px 8px;
  border-radius: 6px;
}

/* ================= 现代物理按钮 (Buttons) ================= */
.btn-modern {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.25s var(--sp);
  white-space: nowrap;
}

.btn-modern:hover {
  background: var(--ph);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.btn-modern:active {
  transform: scale(0.96);
}

.btn-modern:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-modern.secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--tx);
  border: 1px solid var(--cd);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.btn-modern.secondary:hover {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-modern.success {
  background: var(--success);
}
.btn-modern.success:hover {
  background: var(--success-hover);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-modern.danger-ghost {
  background: transparent;
  color: var(--danger);
  padding: 6px 10px;
}
.btn-modern.danger-ghost:hover {
  background: rgba(239, 68, 68, 0.1);
  box-shadow: none;
}

.btn-modern.sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* ================= 批量操作工具栏 ================= */
.batch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  border: 1px solid var(--cd);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.batch-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tx);
}

.stat-item span {
  color: var(--tx-muted);
  font-weight: 400;
  margin-right: 4px;
}

.stat-item strong.highlight {
  color: var(--success);
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================= 音频队列卡片列表 (Queue List) ================= */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audio-item-card {
  background: var(--cb);
  border-radius: 14px;
  border: 1px solid var(--cd);
  padding: 14px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.25s var(--sp);
  position: relative;
  overflow: hidden;
}

.audio-item-card:hover {
  background: var(--cb-hover);
  border-color: rgba(59, 130, 246, 0.2);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}

.audio-item-card.removing {
  opacity: 0;
  transform: scale(0.92) translateY(10px);
  pointer-events: none;
}

.item-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.item-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.item-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.item-text-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-filename {
  font-size: 14px;
  font-weight: 700;
  color: var(--tx);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 12px;
  color: var(--tx-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.item-meta-divider {
  opacity: 0.4;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* 进度与压缩数据行 */
.item-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #10b981);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.status-badge.waiting {
  background: rgba(0, 0, 0, 0.05);
  color: var(--tx-muted);
}
.status-badge.processing {
  background: var(--tb);
  color: var(--primary);
}
.status-badge.done {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.status-badge.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.reduction-pill {
  font-weight: 800;
  font-size: 11.5px;
  color: var(--success);
  background: rgba(16, 185, 129, 0.14);
  padding: 2px 6px;
  border-radius: 6px;
}

/* ================= A/B 试听对比播放器 (A/B Compare Player) ================= */
.player-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.player-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--tx);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* A/B 实时瞬切开关药丸 */
.ab-switch-group {
  display: flex;
  background: rgba(0, 0, 0, 0.06);
  padding: 3px;
  border-radius: 999px;
}

.ab-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--tx-muted);
  cursor: pointer;
  transition: all 0.2s var(--sp);
  display: flex;
  align-items: center;
  gap: 5px;
}

.ab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ab-btn.compressed.active {
  color: var(--success);
}

/* 波形与画布区域 */
.waveform-canvas-container {
  width: 100%;
  height: 90px;
  background: rgba(0, 0, 0, 0.025);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

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

/* 播放器控制栏 */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-playback-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s var(--sp);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.play-toggle-btn:hover {
  background: var(--ph);
  transform: scale(1.05);
}
.play-toggle-btn:active {
  transform: scale(0.95);
}

.time-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-muted);
  font-variant-numeric: tabular-nums;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 120px;
}

/* ================= 提示 Toast 消息系统 ================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(30, 41, 59, 0.9);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.32s var(--sp-modal) forwards;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.success {
  background: rgba(16, 185, 129, 0.95);
}
.toast.warn {
  background: rgba(245, 158, 11, 0.95);
}
.toast.danger {
  background: rgba(239, 68, 68, 0.95);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ================= 空状态与占位 ================= */
.empty-queue-placeholder {
  padding: 40px 20px;
  text-align: center;
  color: var(--tx-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon {
  font-size: 32px;
  opacity: 0.6;
}

/* ================= 响应式调整 (Mobile Optimization) ================= */
@media (max-width: 640px) {
  body {
    padding: 16px 12px 60px 12px;
  }
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .preset-grid {
    grid-template-columns: 1fr;
  }
  .config-grid {
    grid-template-columns: 1fr;
  }
  .batch-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .batch-actions {
    width: 100%;
    justify-content: stretch;
  }
  .batch-actions .btn-modern {
    flex: 1;
  }
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}
