:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #3b6ef6;
  --accent-soft: #eaf0fe;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .2px; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: #f59e0b; }
.dot.bad { background: var(--danger); }

/* ---------- 布局 ---------- */
main { max-width: 900px; margin: 0 auto; padding: 24px 20px 80px; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.card h2 { font-size: 15px; margin: 0 0 16px; font-weight: 600; display: flex; align-items: center; gap: 9px; }

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex: none;
}

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

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 9px; width: fit-content; margin-bottom: 16px; }

.tab {
  border: 0; background: transparent; padding: 7px 20px; border-radius: 6px;
  font: inherit; font-size: 13.5px; color: var(--muted); cursor: pointer; transition: .15s;
}
.tab.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(16,24,40,.08); }

.pane { display: none; }
.pane.active { display: block; }

/* ---------- 拖拽区 ---------- */
.dropzone {
  border: 1.5px dashed #c7cdd6;
  border-radius: 10px;
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
  background: #fbfcfd;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone p { margin: 8px 0 0; }
.dropzone strong { color: var(--accent); }

/* ---------- 录音 ---------- */
.recorder { display: flex; align-items: center; gap: 20px; padding: 8px 4px; }

.rec-btn {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--card); cursor: pointer; display: grid; place-items: center;
  transition: .15s; flex: none;
}
.rec-btn:hover { border-color: var(--accent); }
.rec-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--danger); transition: .2s; }
.rec-btn.recording { border-color: var(--danger); }
.rec-btn.recording .rec-icon { border-radius: 4px; transform: scale(.72); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.rec-body { flex: 1; min-width: 0; }
.rec-time { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .5px; }

.level-meter { display: flex; align-items: flex-end; gap: 3px; height: 26px; margin: 6px 0; }
.level-meter span { flex: 1; height: 3px; background: #e5e8ee; border-radius: 2px; transition: height .07s linear, background .07s linear; }
.rec-hint { font-size: 12.5px; color: var(--muted); }

/* ---------- 预览 ---------- */
.preview { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 12px 14px; background: var(--bg); border-radius: 10px; }
.preview audio { height: 36px; flex: 1; min-width: 0; }
.preview-meta { min-width: 0; }
.preview-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-sub { font-size: 12px; color: var(--muted); }

.link-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 6px; }
.link-btn:hover { background: #e8eaee; color: var(--text); }

/* ---------- 参数 ---------- */
details summary {
  cursor: pointer; list-style: none;
  /* 三栏网格：标题居左、箭头居中、摘要居右，箭头始终在栏目正中间 */
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 12px;
  /* 负外边距 + 等量内边距，让 hover 底色延伸到卡片内边缘 */
  margin: -8px -10px; padding: 8px 10px;
  border-radius: 8px; user-select: none;
  transition: background .15s;
}
details summary:hover { background: var(--bg); }
details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
details summary::-webkit-details-marker { display: none; }
details summary h2 { margin: 0; justify-self: start; }

.summary-hint {
  justify-self: end; min-width: 0;
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.caret {
  justify-self: center;
  width: 15px; height: 15px;
  color: var(--muted);
  transition: transform .2s, color .15s;
}
details[open] .caret { transform: rotate(180deg); }
details summary:hover .caret { color: var(--accent); }
details[open] .summary-hint { display: none; }

.params { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.field > span { font-weight: 600; }
.field em { font-style: normal; font-size: 12px; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }

input[type="text"], input[type="number"], textarea {
  font: inherit; font-size: 13.5px; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 8px; background: #fbfcfd;
  color: var(--text); width: 100%; transition: .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.field-inline input { width: 90px; }

.switches { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; padding-top: 4px; border-top: 1px solid var(--border); }

.switch { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- 按钮 ---------- */
.actions { display: flex; flex-direction: column; gap: 14px; }

.primary {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 12px 32px; border-radius: 9px; border: 0;
  background: var(--accent); color: #fff; cursor: pointer; transition: .15s;
}
.primary:hover:not(:disabled) { background: #2f5ee0; }
.primary:disabled { background: #c3cbdc; cursor: not-allowed; }

.ghost {
  font: inherit; font-size: 13.5px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; transition: .15s;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 进度 ---------- */
.progress-bar { height: 6px; background: #e5e8ee; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .25s; }
.progress-fill.indeterminate { width: 35% !important; animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.progress-text { font-size: 13px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }

/* ---------- 结果 ---------- */
.result-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.result-head h2 { margin: 0; }
.result-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.seg-toggle { display: flex; gap: 3px; background: var(--bg); padding: 3px; border-radius: 8px; margin-right: 4px; }
.seg-toggle button { border: 0; background: transparent; font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg-toggle button.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(16,24,40,.08); }

.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.stat { background: var(--bg); border-radius: 8px; padding: 7px 13px; font-size: 12.5px; color: var(--muted); }
.stat b { color: var(--text); font-size: 14px; margin-left: 5px; font-variant-numeric: tabular-nums; }

.view { display: none; }
.view.active { display: block; }

.segment {
  display: flex; gap: 14px; padding: 12px 14px; border-radius: 9px;
  cursor: pointer; transition: background .12s; border-left: 3px solid transparent;
}
.segment:hover { background: var(--bg); }

.seg-left { flex: none; width: 118px; }
.seg-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg-speaker { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; margin-top: 5px; }
.seg-text { flex: 1; min-width: 0; }
.seg-conf { font-size: 11.5px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* 说话人配色 */
.spk-0 { background: #e0eaff; color: #2454c9; }
.spk-1 { background: #dcf5e6; color: #14713c; }
.spk-2 { background: #fde8d5; color: #a1520c; }
.spk-3 { background: #f0e2fb; color: #6b2fa0; }
.spk-4 { background: #fde0e7; color: #a81d45; }
.spk-5 { background: #d9f1f5; color: #0d6673; }
.spk-6 { background: #fbf3d0; color: #85650a; }
.spk-7 { background: #e4e7ec; color: #414b5a; }

.plain-text { white-space: pre-wrap; margin: 0; line-height: 1.9; }

.empty {
  margin: 0; padding: 32px 20px; text-align: center;
  color: var(--muted); font-size: 13.5px;
  background: var(--bg); border-radius: 9px;
}

mark.hl { background: #fff3c4; border-radius: 3px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 11px 20px; border-radius: 9px;
  font-size: 13.5px; max-width: min(560px, 90vw); box-shadow: 0 8px 28px rgba(0,0,0,.22); z-index: 60;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

@media (max-width: 620px) {
  .params { grid-template-columns: 1fr; }
  .segment { flex-direction: column; gap: 6px; }
  .seg-left { width: auto; display: flex; align-items: center; gap: 10px; }
  .seg-speaker { margin-top: 0; }
  .preview { flex-wrap: wrap; }
}
