/* 语音合成台 · 视觉方向
 *
 * 题目：一块常驻桌面的树莓派在替人朗读。取材质感来自电路板与音频硬件，不来自 SaaS 卡片。
 *
 * 色板
 *   --ink      #101614  绿黑，电路板在弱光下的底色（刻意避开中性 #0B0B0B / #111）
 *   --surface  #18201D  面板
 *   --line     #2A3431  分隔
 *   --text     #E8EDEA  正文
 *   --muted    #8B9A94  次级
 *   --accent   #E23D6D  树莓红，唯一动作色
 *   --ok       #7FD8A8  完成
 *   --warn     #E8B45A  进行中
 *   --bad      #F2705F  失败
 *
 * 字体：单一 CJK 系统栈，靠字重与字号拉开层级；数字用 tabular-nums，避免等宽字体当标签的套路。
 * 布局：顶部仪器条（标签在上、读数在下）；主体两栏 1.6fr / 1fr，<900px 堆叠；行宽 < 80 字符。
 * 记忆点：生成后的「分段胶带」——每段宽度按真实时长成比例，点击即播该段。
 */

:root {
  --ink: #101614;
  --surface: #18201d;
  --line: #2a3431;
  --text: #e8edea;
  --muted: #8b9a94;
  --accent: #e23d6d;
  --ok: #7fd8a8;
  --warn: #e8b45a;
  --bad: #f2705f;
  --radius: 3px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    "Source Han Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

/* 让原生控件（audio / 滚动条 / 滑块）跟随暗色，避免白色播放器撕裂版面 */
:root { color-scheme: dark; }

body { padding-bottom: 64px; }

a { color: var(--accent); }

code {
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 .3em;
  font-size: .92em;
}

/* ---------- 顶部仪器条 ---------- */

.rail {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 28px;
  padding: 12px 32px;
  background: rgba(16, 22, 20, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.rail-brand {
  margin-right: auto;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
}

.rail-item { display: flex; flex-direction: column; gap: 1px; }

.rail-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}

.rail-value {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.rail-value.is-ok { color: var(--ok); }
.rail-value.is-bad { color: var(--bad); }

/* ---------- 横幅 ---------- */

.banner {
  padding: 12px 32px;
  background: color-mix(in srgb, var(--bad) 16%, var(--ink));
  border-bottom: 1px solid var(--bad);
  color: var(--text);
  font-size: 14px;
}

/* ---------- 主体 ---------- */

main {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 40px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 32px 24px;
}

@media (max-width: 900px) {
  main { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 24px 20px; }
  .rail { gap: 18px; padding: 10px 20px; align-items: flex-start; }
  .rail-brand { flex-basis: 100%; margin-right: 0; font-size: 15px; }
  .banner { padding: 10px 20px; }
  .ribbon-wrap { min-height: 0; }
}

/* 窄屏历史行：去掉时长列，给操作留出空间 */
@media (max-width: 600px) {
  #history-list li { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; }
  #history-list .dur { display: none; }
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .04em;
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  padding: 16px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.9;
}

textarea:focus-visible,
input:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible,
audio:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 旋钮 ---------- */

.knob {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 78px;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.knob label { font-size: 13px; color: var(--muted); }

.knob output {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* ---------- 音色 ---------- */

.voices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: 8px;
  margin-top: 22px;
}

/* ---------- 上传参考音 ---------- */

.voice-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.voice-tools input[type="text"],
.voice-tools input:not([type]) {
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.file-btn,
.voice-tools button {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.file-btn:hover,
.voice-tools button:hover:not(:disabled) { border-color: var(--muted); }

.voice-tools button:disabled { opacity: .45; cursor: default; }

.voice-tools .has-file { border-color: var(--accent); color: var(--accent); }

.badge {
  font-size: 10px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 2px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge.clone { border-color: var(--accent); color: var(--accent); }

.voice {
  display: flex;
  align-items: stretch;
  gap: 2px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s;
}

.voice:hover { border-color: var(--muted); }

.voice[aria-pressed="true"] { border-color: var(--accent); }

.voice[aria-pressed="true"] .v-pick { color: var(--accent); }

.voice .v-pick {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 9px 4px 9px 11px;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.voice .v-gender {
  font-size: 11px;
  color: var(--muted);
}

.voice .v-play {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0 10px 0 4px;
  font-size: 11px;
  opacity: .55;
}

.voice .v-play:hover { opacity: 1; color: var(--accent); }
.voice .v-play:disabled { opacity: .25; cursor: default; }

.voice .v-del {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 8px 0 0;
  font-size: 13px;
  opacity: .5;
}

.voice .v-del:hover { opacity: 1; color: var(--bad); }

/* ---------- 词典 ---------- */

.dict {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.dict summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}

.dict-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.dict-add input {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.dict-add button {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

#dict-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  font-size: 14px;
}

#dict-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

#dict-list button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

#dict-list button:hover { color: var(--bad); }

/* ---------- 主按钮 ---------- */

.primary {
  width: 100%;
  margin-top: 24px;
  padding: 13px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: filter .15s;
}

.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:disabled { opacity: .55; cursor: default; }

/* ---------- 分段胶带（记忆点） ---------- */

.ribbon-wrap { min-height: 96px; }

.ribbon {
  display: flex;
  gap: 2px;
  height: 56px;
  align-items: stretch;
}

.ribbon button {
  min-width: 18px;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: var(--ok);
  opacity: .45;
  cursor: pointer;
  transition: opacity .15s;
}

.ribbon button:hover,
.ribbon button:focus-visible { opacity: .8; }

.ribbon button[data-status="failed"] { background: var(--bad); opacity: .55; }
.ribbon button[data-status="running"] { background: var(--warn); opacity: .6; }
.ribbon button[data-status="pending"] { background: var(--line); opacity: 1; }

.ribbon.is-revealing button {
  animation: rise .28s ease-out both;
}

@keyframes rise {
  from { transform: scaleY(.35); opacity: 0; }
  to   { transform: scaleY(1); }
}

.empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

/* ---------- 分段列表 ---------- */

.segments {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.segments li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.segments .idx {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

.segments .txt { line-height: 1.6; word-break: break-word; }

.segments .state { font-size: 12px; color: var(--muted); }
.segments li[data-status="done"] .state { color: var(--ok); }
.segments li[data-status="failed"] .state { color: var(--bad); }
.segments li[data-status="running"] .state { color: var(--warn); }

.segments .seg-actions button {
  margin-left: 8px;
  padding: 2px 8px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.segments .seg-actions button:hover { color: var(--text); border-color: var(--muted); }

/* ---------- 播放器 ---------- */

.player { margin-top: 22px; }

audio { width: 100%; height: 34px; }

.downloads {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 14px;
}

.downloads a[hidden] { display: none; }

/* ---------- 历史 ---------- */

.history {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 32px 40px;
}

@media (max-width: 900px) {
  .history { padding: 8px 20px 40px; }
}

.history h2 {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .04em;
  margin: 0 0 10px;
}

#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#history-list li {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 70px auto;
  gap: 12px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

/* 空状态不参与四列网格，否则会被 62px 的第一列挤成竖排 */
#history-list li.is-empty {
  display: block;
  color: var(--muted);
  font-size: 13px;
  border-bottom: none;
}

#history-list .when {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
}

#history-list .what {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

#history-list .dur {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

#history-list .acts { display: flex; gap: 10px; }

#history-list .acts button {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

#history-list .acts button:hover { color: var(--text); }

/* ---------- 登录 ---------- */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: min(360px, 100%);
  padding: 36px 32px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .02em;
}

.auth-card .muted {
  margin: 0 0 26px;
  font-size: 13px;
  color: var(--muted);
}

.auth-card label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.auth-card input {
  width: 100%;
  padding: 10px 12px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.auth-card button {
  width: 100%;
  margin-top: 18px;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* 登录页唯一装饰：一段静态波形，暗示这台机器的工作是声音 */
.auth-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 26px;
  margin-bottom: 22px;
}

.auth-wave i {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
  opacity: .7;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
