/* ==========================================================================
   TTS Online — 站点样式
   单一文件、无外部依赖、无图标字体；首屏不加载任何第三方资源。
   ========================================================================== */

:root {
  --brand: #1d4ed8;
  --brand-dark: #1e40af;
  --brand-soft: #eff4ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --bg: #f8fafc;
  --card: #ffffff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px -18px rgba(15, 23, 42, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 750; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
code { font-family: var(--mono); font-size: .86em; background: #f1f5f9; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; word-break: break-all; }
strong { font-weight: 650; }
time { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  text-decoration: none; transition: top .2s;
}
.skip-link:focus { top: 12px; color: #fff; }

:focus-visible { outline: 3px solid rgba(29, 78, 216, .45); outline-offset: 2px; border-radius: 6px; }

/* ---------- 页头 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; min-height: 64px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 11px; background: linear-gradient(140deg, var(--brand), #0ea5e9);
  color: #fff; font-weight: 700; font-size: .8rem; letter-spacing: .04em;
}
.brand-text { display: flex; flex-direction: column; font-weight: 700; line-height: 1.15; white-space: nowrap; }
.brand-text small { font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: .14em; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; text-decoration: none; color: var(--ink-2);
  font-size: .93rem; padding: 8px 12px; border-radius: 8px;
}
.nav a:hover { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- 首屏 ---------- */
.hero {
  padding: 64px 0 44px;
  background:
    radial-gradient(900px 380px at 12% -10%, #e0ecff 0%, transparent 60%),
    radial-gradient(700px 320px at 88% 0%, #e6fbff 0%, transparent 55%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  margin: 0 0 14px; font-size: .78rem; font-weight: 700;
  letter-spacing: .22em; color: var(--brand);
}
.hero h1 { max-width: 20em; }
.lead { max-width: 46em; color: var(--ink-2); font-size: 1.05rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 34px; }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  margin: 0; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.stat { background: var(--card); padding: 18px 20px; }
.stat dt { font-size: .78rem; color: var(--muted); letter-spacing: .06em; }
.stat dd { margin: 6px 0 0; display: flex; flex-direction: column; gap: 2px; }
.stat dd strong { font-size: 1.55rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat dd span { font-size: .8rem; color: var(--muted); }
.hero-note { margin: 18px 0 0; font-size: .86rem; color: var(--muted); }
.hero-note strong { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- 区块 ---------- */
.section { padding: 64px 0; scroll-margin-top: 78px; }
.section.alt { background: #fff; border-block: 1px solid var(--line); }
.section-head { max-width: 52em; margin-bottom: 26px; }
.section-head p { color: var(--muted); margin: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; min-height: 44px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  text-decoration: none; transition: background-color .15s, border-color .15s, color .15s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.btn-small { padding: 7px 14px; min-height: 36px; font-size: .86rem; }
.btn-step { padding: 0; min-height: 34px; width: 34px; background: #fff; border-color: var(--line-strong); color: var(--ink-2); font-size: 1.05rem; line-height: 1; }
.btn-step:hover { border-color: var(--brand); color: var(--brand); }

.link-btn {
  background: none; border: 0; padding: 2px 4px; font: inherit; font-size: .85rem;
  color: var(--brand); cursor: pointer; border-radius: 5px;
}
.link-btn:hover { background: var(--brand-soft); }

/* ---------- 工具面板 ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 26px;
}
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 30px; }
.composer-main { min-width: 0; }

.field-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field { min-width: 0; }
.field label,
.output-label {
  display: block; margin-bottom: 6px;
  font-size: .82rem; font-weight: 600; color: var(--ink-2); letter-spacing: .02em;
}
select, input[type="text"], textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: .92rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2364748b' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
select:focus, input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .14); }
.voice-row { display: flex; gap: 8px; }
.voice-row select { flex: 1; min-width: 0; }
.voice-row .btn { flex: none; white-space: nowrap; }

.text-block { margin-top: 18px; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: #fff; }
.text-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: #f8fafc;
  font-size: .85rem;
}
.counter { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.replace-tools { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.replace-tools input { width: 78px; padding: 4px 8px; font-size: .82rem; }
#text {
  border: 0; border-radius: 0; resize: vertical; min-height: 260px;
  padding: 14px 16px; line-height: 1.75; font-size: .95rem;
}
#text:focus { box-shadow: inset 0 0 0 2px rgba(29, 78, 216, .14); }

.sliders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.slider label { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.slider output { color: var(--brand); font-variant-numeric: tabular-nums; }
.slider-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
input[type="range"] { width: 100%; accent-color: var(--brand); height: 24px; }

.advanced { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.advanced > summary {
  cursor: pointer; padding: 12px 16px; font-size: .88rem; font-weight: 600; color: var(--ink-2);
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after { content: "＋"; color: var(--muted); font-weight: 400; }
.advanced[open] > summary::after { content: "－"; }
.advanced > summary:hover { color: var(--brand-dark); }
.advanced .field-grid { padding: 4px 16px 0; }
.advanced .hint { padding: 0 16px; }
.advanced .ssml-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 0; }
.advanced > *:last-child { margin-bottom: 14px; }

.ssml-actions { margin-bottom: 0; }
.hint { font-size: .82rem; color: var(--muted); line-height: 1.75; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.toolbar .quota { margin: 0 0 0 auto; font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.inline-check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.inline-check input { accent-color: var(--brand); }

.result { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line-strong); }
.result audio { width: 100%; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.result-note { font-size: .8rem; color: var(--muted); }

.composer-side { border-left: 1px solid var(--line); padding-left: 26px; }
.composer-side h3 { font-size: .9rem; color: var(--ink-2); margin: 0 0 8px; }
.composer-side h3 + .tips { margin-bottom: 22px; }
.tips { margin: 0; padding: 0; list-style: none; }
.tips li { position: relative; padding-left: 16px; margin-bottom: 6px; font-size: .86rem; color: var(--muted); }
.tips li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); opacity: .55; }

/* ---------- 上传区 ---------- */
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.media-input, .media-output { min-width: 0; }
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  background: #f8fafc; transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--brand); background: var(--brand-soft); }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 30px 20px; cursor: pointer; text-align: center; }
.drop-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 6px; border-radius: 50%; background: #fff; border: 1px solid var(--line-strong); color: var(--brand); font-size: 1.1rem; }
.drop-title { font-weight: 600; font-size: .95rem; }
.drop-hint { font-size: .8rem; color: var(--muted); }
.file-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: .84rem; color: var(--ink-2); }
.file-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.media-output textarea { min-height: 300px; resize: vertical; line-height: 1.8; }
.media-output .tips { margin-top: 16px; }
.status { margin: 12px 0 0; font-size: .86rem; min-height: 1.4em; }
.status.is-info { color: var(--muted); }
.status.is-ok { color: var(--ok); }
.status.is-err { color: var(--err); }
.status.is-busy { color: var(--brand); }

/* ---------- 步骤 ---------- */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; }
.step-no { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 12px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: .9rem; }
.step h3 { font-size: 1rem; }
.step p { margin: 0; font-size: .88rem; color: var(--muted); }

/* ---------- 特性卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 34px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; }
.card h3 { font-size: 1rem; color: var(--ink); }
.card p { margin: 0; font-size: .88rem; color: var(--muted); }

.prose { max-width: 60em; }
.prose h2 { margin-bottom: .4em; }
.prose h3 { margin-top: 1.6em; font-size: 1.05rem; }
.prose p { color: var(--ink-2); }
.defs { margin: 1.2em 0 0; border-top: 1px solid var(--line); }
.defs > div { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.defs dt { font-weight: 650; color: var(--ink); font-size: .92rem; }
.defs dd { margin: 0; color: var(--muted); font-size: .9rem; }

/* ---------- 语言清单 ---------- */
.voice-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.voice-list > summary {
  cursor: pointer; padding: 16px 20px; font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between; list-style: none;
}
.voice-list > summary::-webkit-details-marker { display: none; }
.voice-list > summary::after { content: "＋"; color: var(--muted); font-weight: 400; }
.voice-list[open] > summary::after { content: "－"; }
.voice-list > summary:hover { background: var(--brand-soft); }
.voice-list ul { margin: 0; padding: 4px 20px 20px; list-style: none; columns: 2; column-gap: 36px; }
.voice-list li { break-inside: avoid; padding: 9px 0; border-top: 1px solid var(--line); font-size: .86rem; }
.lang-name { font-weight: 650; color: var(--ink); }
.lang-count { display: inline-block; margin: 0 6px; padding: 0 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: .74rem; font-variant-numeric: tabular-nums; }
.lang-voices { display: block; color: var(--muted); font-size: .82rem; line-height: 1.65; }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 10px; }
.faq-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.faq-item > summary {
  cursor: pointer; padding: 14px 18px; font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none;
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::after { content: "＋"; flex: none; color: var(--muted); font-weight: 400; }
.faq-item[open] > summary::after { content: "－"; }
.faq-item[open] > summary { color: var(--brand-dark); }
.faq-body { padding: 0 18px 16px; }
.faq-body p { margin: 0; color: var(--ink-2); font-size: .92rem; }

/* ---------- 页脚 ---------- */
.site-footer { background: #0f172a; color: #cbd5e1; padding: 46px 0 26px; margin-top: 20px; }
.footer-inner { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.footer-brand { margin: 0; font-weight: 700; color: #fff; font-size: 1.05rem; }
.footer-desc { margin: 4px 0 0; font-size: .84rem; color: #94a3b8; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.footer-nav a { color: #cbd5e1; text-decoration: none; font-size: .88rem; }
.footer-nav a:hover { color: #fff; text-decoration: underline; }
.footer-legal { margin-top: 28px; padding-top: 18px; border-top: 1px solid #1e293b; }
.footer-legal p { margin: 0; font-size: .8rem; color: #94a3b8; }
.footer-legal a { color: #cbd5e1; }

/* ---------- 模态框 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  padding: 20px; background: rgba(15, 23, 42, .55); opacity: 0; transition: opacity .15s;
}
.modal-overlay.is-open { opacity: 1; }
.modal {
  width: min(560px, 100%); max-height: min(82vh, 680px); overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 30px 80px -30px rgba(15, 23, 42, .7);
  transform: translateY(10px); transition: transform .15s;
}
.modal-overlay.is-open .modal { transform: none; }
.modal-head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 1.02rem; }
.modal-close {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 1.5rem; line-height: 1; padding: 2px 8px; border-radius: 6px;
}
.modal-close:hover { background: #f1f5f9; color: var(--ink); }
.modal-body { padding: 18px 20px 22px; }
.model-list { display: grid; gap: 8px; margin-bottom: 18px; }
.model-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.model-name { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-save { display: flex; gap: 8px; padding-top: 16px; border-top: 1px dashed var(--line-strong); }
.model-save input { flex: 1; min-width: 0; }

/* ---------- 多音色分段 ---------- */
.multi-panel { margin-top: 18px; padding: 14px; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.multi-panel .hint { margin: 0 0 10px; }
.multi-controls { display: flex; gap: 8px; margin-bottom: 12px; }
.multi-controls input { flex: 1; max-width: 260px; }
.multi-controls .multi-delim { max-width: 240px; }
.multi-rows { display: grid; gap: 8px; max-height: 420px; overflow: auto; padding-right: 4px; }
.multi-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 190px; gap: 8px; align-items: center; }
.multi-index {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark); font-size: .74rem; font-weight: 700;
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(560px, calc(100% - 32px));
  padding: 12px 18px; border-radius: 10px;
  background: #0f172a; color: #fff; font-size: .9rem; line-height: 1.5;
  box-shadow: 0 18px 40px -20px rgba(15, 23, 42, .8);
  transition: opacity .18s, transform .18s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #7f1d1d; }
.toast.is-ok { background: #065f46; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .composer { grid-template-columns: minmax(0, 1fr); }
  .composer-side { border-left: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .voice-list ul { columns: 1; }
}

@media (max-width: 720px) {
  .wrap { width: min(1120px, 100% - 28px); }
  .hero { padding: 44px 0 34px; }
  .section { padding: 46px 0; }
  .panel { padding: 18px; }
  .field-row, .field-grid { grid-template-columns: minmax(0, 1fr); }
  .sliders { grid-template-columns: minmax(0, 1fr); }
  .media-grid { grid-template-columns: minmax(0, 1fr); }
  .cards, .steps { grid-template-columns: minmax(0, 1fr); }
  .header-inner { min-height: 58px; gap: 10px; }
  .site-header { position: static; }
  .header-inner { flex-wrap: wrap; padding: 8px 0 10px; row-gap: 4px; }
  .nav { width: 100%; }
  .brand-text small { display: none; }
  .nav a { padding: 7px 10px; font-size: .88rem; }
  .toolbar .quota { margin-left: 0; width: 100%; }
  .replace-tools { margin-left: 0; }
  .defs > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .footer-inner { flex-direction: column; }
  .multi-row { grid-template-columns: 22px minmax(0, 1fr); }
  .multi-row select { grid-column: 2; }
  .model-save { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
