/* 逐字稿 — 冷纸底、墨字、REC 红点。签名元素：时间码导轨。 */
:root {
  --paper: #f4f5f6;
  --card: #ffffff;
  --ink: #1c2126;
  --slate: #5c6673;
  --faint: #8b95a1;
  --line: #e2e5e9;
  --rec: #d6402f;
  --rec-soft: #d6402f1f;
  --ok: #2e7d4f;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131619;
    --card: #1b1f24;
    --ink: #e8eaed;
    --slate: #9aa4af;
    --faint: #6b7580;
    --line: #2a3037;
    --rec: #e05545;
    --rec-soft: #e0554526;
  }
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; } /* 防止 display:flex 等作者样式覆盖 hidden 属性 */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  padding: max(10px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--rec); outline-offset: 2px; border-radius: 4px; }

/* ---- 顶栏 ---- */
.top {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 2px 18px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.rec-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--rec); align-self: center; flex: none;
  box-shadow: 0 0 0 0 var(--rec-soft);
}
.rec-dot.busy { animation: pulse 1.4s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 45%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}
.brand-name { font-size: 24px; font-weight: 800; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--faint); letter-spacing: .08em; }
.svc { font-size: 12px; color: var(--faint); font-family: var(--mono); }
.svc.ok { color: var(--ok); }
.svc.err { color: var(--rec); }

/* ---- 上传区 ---- */
.drop {
  display: block;            /* 它是 <label>，默认 inline */
  position: relative;        /* 容纳视觉隐藏的 file input */
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 20px 28px;
  text-align: center;
  cursor: pointer;
  user-select: none;         /* 按下拖一点不要变成选中文字 */
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
/* 文件框本身视觉隐藏但仍在渲染树里（键盘 Tab 可达，焦点环画在整个上传区上） */
.vis-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--rec); }
.drop:focus-within { outline: 2px solid var(--rec); outline-offset: 2px; }
.drop:focus-within .wave { color: var(--rec); }
.drop.over { background: var(--rec-soft); }
.wave { display: block; width: min(320px, 80%); height: 40px; margin: 0 auto 14px; color: var(--faint); }
.drop.over .wave, .drop:hover .wave { color: var(--rec); }
.drop-main { font-size: 18px; font-weight: 700; }
.drop-sub { font-size: 12.5px; color: var(--faint); margin-top: 6px; font-family: var(--mono); }

/* ---- 访问口令条：仅当服务端要求口令时出现 ---- */
.pass-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--rec-soft); border: 1px solid var(--rec);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 12px;
  font-size: 13.5px; color: var(--ink);
}
.pass-bar input {
  flex: 1; min-width: 120px; font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.btn-sm { padding: 7px 14px; }

/* ---- 选项 ---- */
.opts { margin-top: 6px; }
.more { margin-top: 4px; border-top: 1px solid var(--line); }
.more summary {
  font-size: 13.5px; color: var(--faint); padding: 10px 4px; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent; /* 手机点按不要高亮背景 */
}
.more summary:focus, .more summary:focus-visible { outline: none; }
.more-body { display: grid; gap: 14px; padding: 4px 4px 14px; }
.field { display: grid; gap: 6px; font-size: 13.5px; color: var(--slate); }
.field textarea, .field input, .field select {
  font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; width: 100%;
}
.field textarea:focus, .field input:focus, .field select:focus { outline: none; border-color: var(--rec); }
.urlmode { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 10px; }
.btn {
  background: var(--ink); color: var(--paper); border: none; border-radius: 9px;
  padding: 10px 16px; font-weight: 600; justify-self: start;
}
.btn:active { transform: translateY(1px); }

/* ---- 任务队列 ---- */
.queue { margin-top: 16px; display: grid; gap: 8px; }
.q-head { font-family: var(--mono); font-size: 12px; color: var(--slate); padding: 0 2px; }
.job {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; display: flex; align-items: center; gap: 12px; font-size: 14px;
}
.job .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .st { font-family: var(--mono); font-size: 12.5px; color: var(--slate); flex: none; }
.job.err { border-color: var(--rec); }
.job.err .st { color: var(--rec); }
.job.ok { cursor: pointer; }
.job.ok .st { color: var(--ok); }
.job.ok:hover { border-color: var(--ok); }
.job .bar {
  position: absolute; left: 0; bottom: 0; height: 2px; background: var(--rec);
  transition: width .2s; border-radius: 2px;
}
.job { position: relative; overflow: hidden; }
.job .retry {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 10px; font-size: 12px; color: var(--slate); flex: none;
  -webkit-tap-highlight-color: transparent;
}
.job .retry:hover { border-color: var(--rec); color: var(--rec); }
.job-hint { font-size: 12.5px; color: var(--slate); width: 100%; margin-top: 4px; }

/* ---- 结果 ---- */
.result { margin-top: 22px; }
.player-wrap {
  position: sticky; top: 8px; z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.06);
}
.player-wrap audio { width: 100%; height: 40px; display: block; }
.player-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 4px; }
.player-actions p { flex: 1 1 240px; font-size: 12px; color: var(--slate); overflow-wrap: anywhere; }
.player-actions .tool { flex: none; }
/* 网格布局：标题占第一行左侧，「收起」固定右上角，meta 独占第二行，
   窄屏下标题不会被挤压（此前 flex:1 基准宽为 0，手机上被 meta 挤成竖排） */
.res-head {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  gap: 2px 12px; margin: 16px 2px 4px;
}
.res-title { font-weight: 700; font-size: 16px; word-break: break-all; }
.res-close {
  grid-column: 2; grid-row: 1; justify-self: end;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 12px; font-size: 12.5px; color: var(--slate);
  -webkit-tap-highlight-color: transparent;
}
.res-close:hover { border-color: var(--rec); color: var(--rec); }
.res-meta { grid-column: 1 / -1; }
.res-meta { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.tool {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; font-size: 13.5px; color: var(--slate);
}
.tool:hover { border-color: var(--rec); color: var(--rec); }
.tool:disabled { opacity: .5; cursor: default; border-color: var(--line); color: var(--slate); }
.filter {
  width: 100%; margin: 8px 0 2px; font: inherit; font-size: 14px; color: var(--ink);
  background: transparent; border: none; border-bottom: 1px solid var(--line); padding: 8px 2px;
}
.filter:focus { outline: none; border-bottom-color: var(--rec); }

/* 时间码导轨：等宽时间戳竖列 + 左侧红色播放线 */
.tl { list-style: none; padding: 6px 0 0; margin: 6px 0 0; position: relative; }
.tl::before {
  content: ""; position: absolute; left: 74px; top: 0; bottom: 0;
  width: 1px; background: var(--line);
}
.u { display: flex; gap: 16px; padding: 7px 0; position: relative; }
.u .ts {
  flex: none; width: 62px; text-align: right;
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  background: none; border: none; padding: 3px 0 0; line-height: 1.6;
}
.u .ts:hover { color: var(--rec); }
.u-body { flex: 1; min-width: 0; font-size: 16.5px; line-height: 1.85; }
.u.active::before {
  content: ""; position: absolute; left: 74px; top: 4px; bottom: 4px;
  width: 2px; background: var(--rec); border-radius: 2px;
}
.u.active .ts { color: var(--rec); font-weight: 600; }
.u.dim { display: none; }
.spk {
  display: inline-block; font-size: 11.5px; font-weight: 600; font-family: var(--mono);
  padding: 1px 7px; border-radius: 999px; margin-right: 8px; vertical-align: 2px;
  background: var(--rec-soft); color: var(--rec);
  border: 1px solid transparent; white-space: normal; overflow-wrap: anywhere;
}
.spk:hover { border-color: currentColor; }
.speaker-hint { font-size: 12px; color: var(--slate); margin: 8px 2px; }
.vp-list { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--slate); }
.vp-panel {
  position: fixed; z-index: 40; left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%); width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; box-shadow: 0 6px 28px rgba(0,0,0,.22);
  display: grid; gap: 12px;
}
.vp-title { font-weight: 700; overflow-wrap: anywhere; }
.vp-panel input { font-size: 16px; }
.vp-help { font-size: 13px; color: var(--slate); }
.vp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
body:has(.vp-panel) .toast { bottom: auto; top: max(16px, env(safe-area-inset-top)); border-radius: 12px; }
.spk[data-s="2"] { background: #2f6fbf22; color: #2f6fbf; }
.spk[data-s="3"] { background: #2e7d4f22; color: #2e7d4f; }
.spk[data-s="4"] { background: #8a5cc622; color: #8a5cc6; }
.spk[data-s="5"] { background: #b8730a22; color: #b8730a; }

/* ---- 历史 ---- */
.history { margin-top: 34px; }
.history h2 { font-size: 13px; color: var(--faint); font-weight: 600; letter-spacing: .1em; margin-bottom: 8px; }
.history ul { list-style: none; padding: 0; display: grid; gap: 6px; }
.h-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.h-open { flex: 1; min-width: 0; text-align: left; background: none; border: none; padding: 0; display: grid; gap: 1px; }
.h-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-meta { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.h-del { background: none; border: none; color: var(--faint); font-size: 16px; padding: 4px 6px; flex: none; }
.h-del:hover { color: var(--rec); }

footer { margin-top: 40px; font-size: 12px; color: var(--faint); text-align: center; line-height: 1.7; }
.android-app { display: block; margin-top: 8px; color: var(--rec); font-weight: 600; text-decoration: none; }

.toast {
  position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-size: 13.5px;
  padding: 9px 16px; border-radius: 999px; box-shadow: 0 6px 24px rgba(0,0,0,.2);
  max-width: 90vw; z-index: 50;
}

@media (max-width: 420px) {
  .brand-sub { display: none; }
  .u { gap: 12px; }
  .tl::before, .u.active::before { left: 66px; }
  .u .ts { width: 54px; font-size: 11px; }
  .u-body { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .rec-dot.busy { animation: none; opacity: .85; }
  * { transition: none !important; }
}
