/* ============ 语配音坊 · Edge TTS ============ */
:root {
  --bg: #f4f6fb;
  --bg-soft: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f7f9ff;
  --text: #1c2333;
  --text-2: #5a6478;
  --text-3: #8a93a6;
  --border: #e3e7f0;
  --accent: #4f6ef7;
  --accent-2: #7b5cf0;
  --accent-weak: rgba(79, 110, 247, 0.1);
  --danger: #e5484d;
  --success: #30a46c;
  --warning: #f5a623;
  --shadow: 0 8px 30px rgba(28, 35, 51, 0.08);
  --shadow-sm: 0 2px 10px rgba(28, 35, 51, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
}
html[data-theme="dark"] {
  --bg: #12151f;
  --bg-soft: #171b28;
  --surface: #1c2130;
  --surface-2: #232939;
  --text: #e8ecf5;
  --text-2: #a8b1c4;
  --text-3: #767f93;
  --border: #2c3345;
  --accent: #6b87ff;
  --accent-2: #9b7dff;
  --accent-weak: rgba(107, 135, 255, 0.14);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
button { font-family: inherit; }
::selection { background: var(--accent); color: #fff; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-logo { display: grid; place-items: center; }
.brand-name { font-size: 17px; letter-spacing: 0.5px; }
.brand-name small { font-weight: 500; font-size: 11px; color: var(--text-3); margin-left: 6px; }
.header-nav { display: flex; align-items: center; gap: 18px; }
.header-nav a { color: var(--text-2); font-size: 14px; }
.header-nav a:hover { color: var(--accent); text-decoration: none; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: transform 0.15s, border-color 0.15s;
}
.icon-btn:hover { transform: rotate(15deg) scale(1.06); border-color: var(--accent); }
.theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: inline; }

/* ---------- Hero ---------- */
.hero {
  padding: 72px 0 40px;
  text-align: center;
  background:
    radial-gradient(600px 300px at 15% 0%, var(--accent-weak), transparent 70%),
    radial-gradient(600px 300px at 85% 10%, rgba(123, 92, 240, 0.12), transparent 70%);
}
.hero h1 { font-size: clamp(26px, 4.6vw, 44px); font-weight: 800; letter-spacing: 1px; }
.hero-accent {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--text-2); max-width: 760px; margin: 16px auto 0; font-size: 15.5px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }
.badge {
  font-size: 12.5px; padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  box-shadow: var(--shadow-sm);
}
.hero-actions { display: flex; gap: 14px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 12px; cursor: pointer;
  font-size: 14.5px; font-weight: 600; padding: 10px 20px;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s, opacity 0.15s;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(79, 110, 247, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 24px rgba(79, 110, 247, 0.5); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.btn-lg { padding: 13px 30px; font-size: 16px; border-radius: 14px; }
.btn-mini { padding: 4px 12px; font-size: 12.5px; border-radius: 8px; background: var(--surface-2); border-color: var(--border); color: var(--text-2); font-weight: 500; }
.btn-mini:hover { color: var(--accent); border-color: var(--accent); }
.btn.loading { pointer-events: none; position: relative; }
.btn.loading::after {
  content: ""; width: 14px; height: 14px; margin-left: 2px;
  border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Studio ---------- */
.studio { padding: 26px 20px 10px; }
.studio-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { font-size: 17px; }
.panel-head-actions { display: flex; gap: 8px; }

.sample-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sample-label { font-size: 13px; color: var(--text-3); }
.sample-btn {
  font-size: 12.5px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); color: var(--text-2); border: 1px dashed var(--border);
  transition: all 0.15s;
}
.sample-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }

#textInput {
  width: 100%; min-height: 240px; resize: vertical;
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.9;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
#textInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.text-meta { margin-top: 8px; font-size: 12.5px; color: var(--text-3); display: flex; gap: 4px; flex-wrap: wrap; }
.split-hint { color: var(--accent); }

/* ---------- 音色面板 ---------- */
.field-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.field-label small { color: var(--text-3); font-weight: 400; }
#voiceSearch {
  width: 100%; padding: 9px 14px; border-radius: 10px; outline: none;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 13.5px; transition: border-color 0.15s, box-shadow 0.15s;
}
#voiceSearch:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.voice-grid {
  margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  max-height: 320px; overflow-y: auto; padding: 2px;
}
.voice-group-title {
  grid-column: 1 / -1; font-size: 12px; color: var(--text-3);
  margin: 8px 2px 2px; font-weight: 600; letter-spacing: 1px;
}
.voice-item {
  position: relative; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 12px; cursor: pointer; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.voice-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.voice-item.selected { border-color: var(--accent); background: var(--accent-weak); box-shadow: 0 0 0 1px var(--accent) inset; }
.voice-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 15px; color: #fff;
}
.voice-item-info { min-width: 0; flex: 1; }
.voice-item-name { font-size: 13.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-item-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-preview {
  flex: none; width: 28px; height: 28px; border-radius: 50%; font-size: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; transition: all 0.15s;
}
.voice-preview:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
.voice-preview.playing { color: #fff; background: var(--accent); border-color: var(--accent); animation: pulse 0.9s ease infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.voice-item .check {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11px; display: none; place-items: center;
}
.voice-item.selected .check { display: grid; }

/* ---------- 参数滑块 ---------- */
.param-list { margin-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.param-info { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.param-info label { font-size: 13.5px; font-weight: 600; }
.param-info output { font-size: 12.5px; color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--border) var(--fill, 50%));
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform 0.12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--surface);
  border: 2px solid var(--accent); cursor: pointer;
}
.rate-presets { display: flex; gap: 6px; margin-top: 8px; }
.rate-presets button {
  font-size: 12px; padding: 3px 10px; border-radius: 8px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.rate-presets button.active, .rate-presets button:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }

/* ---------- 操作栏与进度 ---------- */
.action-bar { margin-top: 20px; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.progress-wrap { margin-top: 16px; }
.progress-track { height: 10px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; }
.progress-bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease; position: relative;
}
.progress-bar.indeterminate {
  width: 40% !important; animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.progress-meta b { color: var(--accent); font-variant-numeric: tabular-nums; }
#segInfo { font-variant-numeric: tabular-nums; }
.privacy-note { text-align: center; color: var(--text-3); font-size: 12.5px; margin: 18px 0 40px; }

/* ---------- 音色表格 ---------- */
.section { padding: 46px 20px; }
.section-alt { background: var(--bg-soft); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: 1px; }
.section-sub { text-align: center; color: var(--text-2); margin: 10px auto 28px; max-width: 640px; }
.voice-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.voice-table { width: 100%; border-collapse: collapse; min-width: 640px; font-size: 13.5px; }
.voice-table th, .voice-table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.voice-table th { background: var(--surface-2); color: var(--text-2); font-size: 12.5px; letter-spacing: 1px; }
.voice-table tr:last-child td { border-bottom: none; }
.voice-table code { font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; color: var(--accent); }

/* ---------- 使用说明 / FAQ ---------- */
.guide-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.guide-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 18px; box-shadow: var(--shadow-sm); }
.guide-num {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-weight: 700; margin-bottom: 12px;
}
.guide-card h3 { font-size: 15.5px; margin-bottom: 6px; }
.guide-card p { margin: 0; font-size: 13px; color: var(--text-2); }
.faq { max-width: 780px; margin: 34px auto 0; display: flex; flex-direction: column; gap: 10px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 14.5px; }
.faq p { margin: 10px 0 0; font-size: 13.5px; color: var(--text-2); }

/* ---------- Footer / Toast ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 26px 20px 34px; text-align: center; color: var(--text-3); font-size: 13px; }
.footer-tips { font-size: 12px; margin-top: 6px; }
.toast-container { position: fixed; top: calc(var(--header-h) + 14px); right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 340px; padding: 12px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 13.5px; color: var(--text); animation: toast-in 0.25s ease;
  border-left: 4px solid var(--accent);
}
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warn { border-left-color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.toast.hide { opacity: 0; transform: translateX(24px); transition: all 0.3s; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .studio-grid { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  body { font-size: 14px; }
  .hero { padding: 46px 0 30px; }
  .header-nav a { display: none; }
  .voice-grid { grid-template-columns: 1fr; max-height: 260px; }
  .action-buttons .btn { flex: 1 1 40%; }
  .btn-lg { width: 100%; }
  .guide-grid { grid-template-columns: 1fr; }
  .section { padding: 36px 20px; }
  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: none; }
}
