/* =============================================================================
 * 实时翻译 APP · WebView 样式
 * 视觉与布局 1:1 复用原设计 HTML
 * 原内联样式全部拆出，并在保持浅色视觉不变的前提下：
 *   - 抽出颜色/圆角/字号变量，支持深色模式整体切换
 *   - 增加安全区（--safe-* 可由原生注入）、100dvh、字幕字号变量
 *   - 增加接入真实能力所需的状态样式（partial、连接 banner、进度条、错误）
 * ========================================================================== */

/* ---------------------------------------------------------------------------
 * 1. 变量：浅色方案完全等价于原设计
 * ------------------------------------------------------------------------ */
:root {
  /* 原设计变量 */
  --black: #161616;
  --muted: #969696;
  --line: #e9e9e9;
  --soft: #f7f7f7;
  --purple: #a480df;
  --violet: #9e8cf6;
  --blue: #418de6;
  --green: #16ad85;
  --red: #ed494e;
  --radius: 17px;
  --shadow: 0 2px 11px rgba(25, 25, 25, .045);

  /* 语义色（浅色 = 原设计取值） */
  --bg-app: #f0f0f0;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --surface-3: #f6f6f6;
  --surface-4: #fafafa;
  --chip-bg: #f6f6f6;
  --border: #e7e7e7;
  --border-soft: #eeeeee;
  --border-strong: #dedede;
  --text: #161616;
  --text-2: #555555;
  --text-3: #888888;
  --text-4: #999999;
  --text-5: #aaaaaa;
  --text-6: #b0b0b0;
  --nav-bg: #ffffff;
  --nav-border: #ececec;
  --switch-off: #d6d6db;
  --switch-on: #181818;
  --switch-knob: #ffffff;
  --danger: #ef4d52;
  --warn: #edaa08;
  --accent: #9b7eec;
  --focus: #ae97ed;

  /* 排版与适配 */
  --subtitle-font-size: 17px;
  --status-h: 30px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --nav-h: 67px;
  color-scheme: light;
}

/* 深色方案：仅替换变量，结构与浅色完全一致 */
[data-theme="dark"] {
  --black: #f3f3f4;
  --muted: #8e8e95;
  --line: #2c2c32;
  --soft: #1e1e22;
  --bg-app: #0a0a0c;
  --bg: #141416;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --surface-3: #1c1c20;
  --surface-4: #1b1b1f;
  --chip-bg: #1f1f23;
  --border: #2e2e35;
  --border-soft: #27272c;
  --border-strong: #3a3a42;
  --text: #f3f3f4;
  --text-2: #c8c8cd;
  --text-3: #a2a2a9;
  --text-4: #8e8e95;
  --text-5: #7c7c83;
  --text-6: #6f6f76;
  --nav-bg: #141416;
  --nav-border: #27272c;
  --switch-off: #3a3a42;
  --switch-on: #e9e9ec;
  --switch-knob: #17171a;
  --danger: #ff5a60;
  --warn: #f2b023;
  --accent: #b39bf5;
  --focus: #9b86e8;
  --shadow: 0 2px 11px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ---------------------------------------------------------------------------
 * 2. 基础重置
 * ------------------------------------------------------------------------ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;                 /* 键盘弹出不整页顶起：页面滚动只发生在 .page / .transcript-stream 内 */
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg-app);
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
a { color: var(--blue); }

/* ---------------------------------------------------------------------------
 * 3. 通用：图标 / 工具类 / 外壳
 * ------------------------------------------------------------------------ */
.icon { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }
.icon.lg { width: 27px; height: 27px; }
.icon.xl { width: 43px; height: 43px; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.small { font-size: 12px; }
.semibold { font-weight: 650; }
.hidden { display: none !important; }

.app {
  position: relative;
  max-width: 520px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 570px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* ---------------------------------------------------------------------------
 * 真实 APP（WebView）：系统已有状态栏/手势条，隐藏自绘状态栏并用原生注入的
 * insets（--inset-top / --inset-bottom，单位 px）给内容让位：
 *  - 顶部从系统状态栏下方开始，不再出现“两个时间/状态被电池图标压住”
 *  - 底部导航整体抬到系统手势条上方，不被手势条压住
 * dev 浏览器预览（无原生注入、无 native-app 类）仍保留原设计状态栏，视觉不变。
 * ------------------------------------------------------------------------ */
html.native-app #status { display: none; }
html.native-app .app {
  padding-top: var(--inset-top, 0px);
  padding-bottom: var(--inset-bottom, 0px);
}

/* 状态栏：真实时间 + 真实运行状态；高度含原生状态栏安全区 */
#status {
  height: calc(var(--status-h) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  padding-bottom: 3px;
}
#status .status-icons { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-weight: 500; }
#status .status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }
#status .status-dot.idle { background: var(--muted); }
#status .status-dot.recording { background: var(--danger); }
#status .status-dot.error { background: var(--warn); }

/* ---------------------------------------------------------------------------
 * 4. 页面骨架 / 顶栏 / 底部 tab
 * ------------------------------------------------------------------------ */
.page {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.page::-webkit-scrollbar { display: none; }
.page.active { display: flex; flex-direction: column; }
.content { padding: 12px 17px 30px; }

.topbar { min-height: 65px; display: flex; align-items: center; padding: 6px 17px; gap: 10px; flex-shrink: 0; }
.topbar .title { font-weight: 700; font-size: 19px; flex: 1; text-align: center; }
.topbar .left-title { font-weight: 700; font-size: 17px; }

/* v5 §12.2：设置页右上角主题切换按钮（深色显示月亮 / 浅色显示太阳） */
.theme-toggle {
  height: 36px;
  width: 36px;
  border-radius: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-2);
}
.theme-toggle:active { background: var(--surface-3); }
.theme-toggle .icon { width: 18px; height: 18px; }
[data-theme="dark"] .theme-toggle { color: #d8d8de; }

.ghost-btn {
  height: 36px;
  min-width: 36px;
  border-radius: 12px;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 9px;
  color: var(--text-2);
}

.group-pill {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 4px;
  gap: 2px;
}
.group-pill button {
  border-radius: 12px;
  padding: 8px 11px;
  color: var(--text-5);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.group-pill button.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .04); }

.mode-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ffb400; }

.bottom-nav {
  height: calc(var(--nav-h) + var(--safe-bottom));
  flex-shrink: 0;
  border-top: 1px solid var(--nav-border);
  display: flex;
  align-items: flex-start;
  background: var(--nav-bg);
  z-index: 5;
  padding-bottom: var(--safe-bottom);
}
.tab {
  display: flex;
  align-items: center;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  color: var(--text-5);
  font-size: 11px;
  white-space: nowrap;
}
.tab .icon { width: 24px; height: 24px; }
.tab.active { color: var(--text); }
.tab:active { transform: scale(.98); }

/* ---------------------------------------------------------------------------
 * 5. 录音首页（#page-rec 空闲态）
 * ------------------------------------------------------------------------ */
#page-rec { overflow: hidden; }
.rec-idle { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.rec-active { display: none; flex-direction: column; flex: 1; min-height: 0; }
.rec-header { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 10px 15px; gap: 8px; }
.folder-top { display: flex; align-items: center; gap: 7px; color: #898989; font-size: 13px; white-space: nowrap; padding: 0; }
[data-theme="dark"] .folder-top { color: var(--text-4); }
.rec-header .group-pill { margin-left: auto; }
.rec-header .settings-btn { margin-left: 2px; }
.main-mode { padding: 4px 16px 0; display: flex; justify-content: center; }
.main-mode .mode-switch { width: 100%; max-width: 365px; }

.rec-home { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 19px 10px; }
.rec-center { flex: 1; min-height: 210px; display: flex; align-items: center; justify-content: center; flex-direction: column; margin-top: 4px; }
.mic-button {
  width: 113px;
  height: 113px;
  border-radius: 50%;
  background: linear-gradient(140deg, #f3bed8 1%, #c9aeef 50%, #958ff9 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  box-shadow: 0 12px 25px #e4d6f05c;
  transition: transform .2s;
}
.mic-button:active { transform: scale(.96); }
.mic-button svg { width: 43px; height: 43px; stroke-width: 2.5; }
.mic-button[disabled] { opacity: .55; }
.hero-text { font-size: 18px; font-weight: 700; margin-top: 22px; }
.hero-sub { font-size: 12px; color: #999; margin-top: 6px; text-align: center; }
[data-theme="dark"] .hero-sub { color: var(--text-4); }

.lang-dock { display: flex; align-items: center; gap: 10px; margin: 15px 0 6px; }
.lang-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 15px;
  flex: 1;
  min-width: 0;
  height: 64px;
  text-align: left;
  display: flex;
  align-items: center;
  padding: 0 11px;
  gap: 8px;
}
.lang-card .icon { color: #868686; width: 19px; height: 19px; }
[data-theme="dark"] .lang-card .icon { color: var(--text-4); }
.lang-caption { font-size: 11px; color: #aaa; margin-bottom: 3px; }
[data-theme="dark"] .lang-caption { color: var(--text-5); }
.lang-value { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swap { height: 35px; width: 26px; flex-shrink: 0; color: var(--text-3); }

/* 首页可见的真实状态提示（桥不可用 / 系统声音授权） */
.rec-alerts { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 0; }
.alert-card {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.6;
  text-align: left;
  width: 100%;
}
.alert-card .icon { color: var(--warn); margin-top: 1px; }
.alert-card.error .icon { color: var(--danger); }
.alert-card.info .icon { color: var(--blue); }
.alert-card .alert-body { flex: 1; min-width: 0; }
.alert-card .alert-title { display: block; font-weight: 650; color: var(--text); margin-bottom: 3px; }
.alert-card .alert-action { color: var(--accent); font-weight: 650; white-space: nowrap; align-self: center; }

/* ---------------------------------------------------------------------------
 * 6. 实时字幕（#rec-active）
 * ------------------------------------------------------------------------ */
.rec-live-top { padding: 9px 17px 6px; display: flex; gap: 8px; align-items: center; flex-shrink: 0; overflow: hidden; }
.rec-live-top .folder-top { margin-right: auto; overflow: hidden; }
.rec-live-top .folder-top > span:not(.icon) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-live-top .orange-state,
.rec-live-top .end-btn,
.rec-live-top .ghost-btn { flex-shrink: 0; }
.orange-state { font-size: 11px; color: var(--warn); display: flex; gap: 5px; align-items: center; white-space: nowrap; }
.orange-state.paused { color: var(--text-3); }

/* 录音模式 chip（录音页顶部，位于「正在聆听」旁） */
.capture-chip {
  flex-shrink: 1;
  min-width: 0;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 5px 8px;
  transition: background .15s;
}
.capture-chip:active { background: var(--surface-3); }
.capture-chip.catching-up { color: var(--warn); border-color: var(--warn); }
.end-btn {
  background: #ef4d52;
  border-radius: 9px;
  padding: 10px 11px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.conn-banner {
  margin: 2px 16px 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-2);
  padding: 11px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  line-height: 1.5;
}
.conn-banner.warn { border-color: #f0d193; background: #fdf6e6; color: #8a6412; }
.conn-banner.error { border-color: #f3b8ba; background: #fdf1f1; color: #9c2b2f; }
[data-theme="dark"] .conn-banner.warn { border-color: #5c4a1d; background: #2a2413; color: #e9c46a; }
[data-theme="dark"] .conn-banner.error { border-color: #5c2b2d; background: #2a1718; color: #f08a8d; }
.conn-banner .icon { flex-shrink: 0; }
.conn-banner .banner-text { flex: 1; min-width: 0; }
.conn-banner button { color: inherit; font-weight: 650; text-decoration: underline; white-space: nowrap; }

.transcript-stream {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 3px 16px;
  position: relative;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  --level: 0;
}

/* final 正式卡片（v5 §12.1 紧凑版：padding 14 / 卡片间距 10 / 高度自适应） */
.transcript-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin: 0 0 10px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .03);
}

/* v4 说话人分离：人物标签（契约 §11.4）
 * 小号、圆角、低饱和；只做辅助标识，不抢双语字幕主体。
 * speaker-1..6 按编号循环，speaker-unknown 为「未识别人物」。 */
.speaker-chip {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 4px;
  margin: 0 0 8px;
  padding: 1px 7px 2px;
  font-size: 10px;
  line-height: 1.5;
  font-weight: 650;
  letter-spacing: .02em;
  border: 1px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 100%;
}
.speaker-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .72;
  flex-shrink: 0;
}
.speaker-chip[hidden] { display: none !important; }
[data-theme="dark"] .speaker-chip { box-shadow: none; }

/* 低饱和人物色板（浅色） */
.speaker-1 { color: #6f5aa8; background: #f3effa; border-color: #e4dcf3; }
.speaker-2 { color: #4f6f9e; background: #eef3fa; border-color: #dbe6f3; }
.speaker-3 { color: #4f7a63; background: #edf5f0; border-color: #d9e9df; }
.speaker-4 { color: #9a6b3f; background: #faf2e8; border-color: #f0e2cf; }
.speaker-5 { color: #3f7786; background: #eaf4f6; border-color: #d5e8ec; }
.speaker-6 { color: #9a5f77; background: #f8eef2; border-color: #eedae2; }
.speaker-unknown { color: #6f6f78; background: #f1f1f4; border-color: #e3e3e8; }

/* 低饱和人物色板（深色模式） */
[data-theme="dark"] .speaker-1 { color: #b9a6ee; background: #251f36; border-color: #3d3358; }
[data-theme="dark"] .speaker-2 { color: #9db8e0; background: #1f2836; border-color: #33445c; }
[data-theme="dark"] .speaker-3 { color: #9ac7af; background: #1e2c25; border-color: #31483b; }
[data-theme="dark"] .speaker-4 { color: #d6ac7c; background: #2e2619; border-color: #4a3a24; }
[data-theme="dark"] .speaker-5 { color: #8fc3cf; background: #1d2a2e; border-color: #2f464d; }
[data-theme="dark"] .speaker-6 { color: #d3a1b5; background: #2d2127; border-color: #4a333d; }
[data-theme="dark"] .speaker-unknown { color: #b9b9c2; background: #262629; border-color: #3b3b41; }

/* 同一人物连续说话：视觉上连成一段（间距更紧），与其它人物自然分段。
 * #line-list 用 flex 纵向排列，避免 margin 折叠导致「同人物更紧」失效。 */
#line-list { display: flex; flex-direction: column; }
#line-list .transcript-card { margin-bottom: 0; }
#line-list .transcript-card + .transcript-card { margin-top: 10px; }
#line-list .transcript-card.speaker-continued { margin-top: 3px; }
.transcript-card.speaker-continued .speaker-chip { opacity: .78; }
/* v5 §12.1 字号：默认 subtitleFontSize=17 时原文 22px、译文 17px（仍随字号设置等比生效） */
.transcript-original { font-size: calc(var(--subtitle-font-size) * 1.294); line-height: 1.5; margin: 0 0 10px; word-break: break-word; }
.transcript-rule { height: 1px; background: var(--line); margin: 0 0 10px; }
.transcript-translated {
  font-size: var(--subtitle-font-size);
  line-height: 1.5;
  color: var(--text-2);
  margin: 0;
  word-break: break-word;
}
.transcript-translated.pending { color: var(--text-4); font-style: italic; }
.transcript-note { font-size: 12px; color: var(--text-4); line-height: 1.5; margin: 0 0 10px; word-break: break-word; }
.transcript-note[hidden] { display: none !important; }
.transcript-translated.error { color: var(--danger); font-size: 12px; }
/* 翻译超时重试入口（任务 4）：只在 30s 未收到终态时出现 */
.transcript-retry { margin: 0; }
.transcript-retry[hidden] { display: none !important; }
.transcript-retry button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--danger);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 7px 11px;
}
/* v5 §12.1：图标 18px（sm）、按钮行留白 ≤8px */
.transcript-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 6px; color: #9e9e9e; }
[data-theme="dark"] .transcript-actions { color: var(--text-5); }
.transcript-actions button { color: inherit; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.transcript-actions button .icon { width: 18px; height: 18px; }
.transcript-actions button.on { color: var(--warn); }
.transcript-actions button.on svg { fill: currentColor; }

/* AI 摘要卡片（任务 8）：与字幕卡片同一视觉语言，深色模式走变量 */
.summary-card {
  margin: 8px 16px 10px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .03);
  flex-shrink: 0;
}
.summary-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 650; }
.summary-actions { display: flex; align-items: center; gap: 8px; }
.summary-actions button {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
}
.summary-actions button:disabled { opacity: .5; }
.summary-actions .summary-regen { color: var(--accent); }
.summary-actions .summary-regen[hidden] { display: none !important; }
.summary-body { margin-top: 10px; font-size: 12px; line-height: 1.7; color: var(--text-2); word-break: break-word; }
.summary-body .summary-list { margin: 0; padding-left: 18px; }
.summary-body .summary-list li + li { margin-top: 6px; }
.summary-body .summary-truncated { margin-top: 8px; font-size: 11px; color: var(--text-4); }
.summary-body .summary-error { color: var(--danger); }
.summary-body .loading-line { padding: 8px 0; justify-content: flex-start; }
.summary-body .summary-hint { margin-top: 4px; font-size: 11px; color: var(--text-4); line-height: 1.6; }

/* partial 临时条：浅色、光标、呼吸点（v5 §12.1 同步缩小，自动高度） */
.partial-line {
  min-height: 44px;                 /* 仅最小高度，实际高度随文本自适应 */
  align-items: flex-start;
  contain: layout style;            /* 隔离 partial 条内部布局，避免影响字幕列表 */
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-4);
  color: var(--text-3);
  padding: 10px 12px;
  margin: 6px 0 10px;
  font-size: calc(var(--subtitle-font-size) * 1.176);   /* 默认 20px：比原文略小 */
  line-height: 1.5;
  display: none;
  align-items: flex-start;
  gap: 8px;
}
.partial-line.visible { display: flex; }
.partial-line .breath {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
  flex-shrink: 0;
  animation: breath 1.15s ease-in-out infinite;
}
.partial-line .partial-text { flex: 1; min-width: 0; word-break: break-word; }
/* v6：partial 临时条内同时显示实时译文（原文在上、译文在下，同一卡片自适应高度） */
.partial-line .partial-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.partial-line .partial-translated {
  font-size: calc(var(--subtitle-font-size) * 0.95);
  line-height: 1.45;
  color: var(--text-4);
  word-break: break-word;
}
.partial-line .partial-translated:empty { display: none; }
.partial-line .partial-text:after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  vertical-align: -2px;
  animation: caret 1s step-end infinite;
}
@keyframes breath { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* 监听指示器（原设计 .listening，作为列表底部状态） */
.listening {
  border: 1px solid var(--border-strong);
  box-shadow: 0 2px 9px rgba(0, 0, 0, .08);
  border-radius: 14px;
  min-height: 93px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  margin: 10px 0;
}
.listening .listening-main { padding: 20px 14px 14px; display: flex; align-items: center; gap: 9px; color: var(--text-3); font-size: 15px; }
.wave { display: flex; align-items: center; gap: 3px; height: 18px; }
.wave i { display: block; width: 3px; background: currentColor; border-radius: 5px; height: 5px; transform-origin: center; }
.wave i:nth-child(2) { height: 12px; }
.wave i:nth-child(3) { height: 18px; }
.wave i:nth-child(4) { height: 10px; }
.wave i:nth-child(5) { height: 6px; }
.listening.active .wave i { animation: pulse .7s alternate infinite; }
.listening.active .wave i:nth-child(2) { animation-delay: .17s; }
.listening.active .wave i:nth-child(3) { animation-delay: .35s; }
@keyframes pulse { to { height: 4px; } }
/* 真实音频电平（audio_level 事件）驱动整体振幅，避免每帧改 DOM */
.listening.active .wave { transform: scaleY(calc(.55 + var(--level) * .9)); transition: transform .12s linear; }
.listen-foot {
  padding: 9px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--text-3);
  gap: 8px;
}
.listen-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text); display: inline-block; margin-right: 6px; }
.listen-foot .listen-state { display: flex; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* 回到底部 */
.jump-bottom {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translate(-50%, 8px);
  background: rgba(25, 25, 25, .86);
  color: #fff;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 4;
}
.jump-bottom.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
[data-theme="dark"] .jump-bottom { background: #ececf0; color: #17171a; }

.rec-tools { padding: 7px 14px 13px; border-top: 1px solid var(--border-soft); background: var(--bg); flex-shrink: 0; }
.tool-chips { display: flex; gap: 7px; margin-bottom: 11px; }
.chip { border-radius: 22px; background: var(--chip-bg); border: 1px solid var(--border-soft); padding: 9px 12px; font-size: 12px; flex: 1; color: var(--text-2); }
.chip:disabled { opacity: .5; }
.tool-footer { display: flex; align-items: center; justify-content: space-between; color: var(--text-3); }
.tool-footer .icon { width: 21px; }
.tool-footer button { padding: 3px 7px; }
.tool-footer .record-timer { font-size: 11px; min-width: 87px; white-space: nowrap; }
.tool-footer .record-timer:before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  margin-right: 6px;
}
.tool-footer .record-timer.paused:before { background: var(--warn); }

/* ---------------------------------------------------------------------------
 * 7. 文字翻译
 * ------------------------------------------------------------------------ */
.textarea-wrap { position: relative; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); padding: 16px; margin-top: 18px; }
.textarea-wrap textarea {
  resize: none;
  border: 0;
  background: transparent;
  width: 100%;
  height: 125px;
  outline: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}
.textarea-wrap textarea::placeholder { color: var(--text-5); }
.text-bar { display: flex; align-items: center; justify-content: space-between; color: var(--text-5); padding-top: 9px; border-top: 1px solid var(--border-soft); font-size: 11px; }
.translated-output { border: 1px solid var(--border); border-radius: 15px; background: var(--surface-4); padding: 16px; min-height: 130px; margin-top: 14px; }
.translated-output .output-text { font-size: 16px; line-height: 1.65; margin-top: 15px; word-break: break-word; }
.translated-output .output-head { display: flex; justify-content: space-between; color: var(--text-4); font-size: 12px; gap: 8px; }
.flat-button {
  border-radius: 12px;
  background: #141414;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 14px;
  font-weight: 600;
  font-size: 14px;
  width: 100%;
  margin-top: 14px;
}
.flat-button:disabled { opacity: .5; }
.flat-button.danger { background: #e74a50; }
[data-theme="dark"] .flat-button { background: #ededf0; color: #141416; }
[data-theme="dark"] .flat-button.danger { background: #e0484d; color: #fff; }
.flat-button.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ---------------------------------------------------------------------------
 * 8. 设置 / 通用卡片
 * ------------------------------------------------------------------------ */
.section-title { font-weight: 700; font-size: 19px; margin: 7px 0 14px; }
.section-headline { font-size: 12px; color: #919191; margin: 24px 0 9px; }
[data-theme="dark"] .section-headline { color: var(--text-4); }
.setting-card { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); margin-bottom: 12px; overflow: hidden; }
.setting-row { min-height: 70px; padding: 16px; display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; }
.setting-row + .setting-row { border-top: 1px solid var(--border-soft); }
.setting-row .row-main { flex: 1; min-width: 0; }
.row-name { font-size: 14px; font-weight: 560; }
.row-description { font-size: 11px; color: var(--text-4); margin-top: 5px; line-height: 1.55; }
.arrow-right { color: #a7a7a7; }
[data-theme="dark"] .arrow-right { color: var(--text-5); }

.switch { width: 38px; height: 23px; border-radius: 16px; background: var(--switch-off); padding: 2px; flex-shrink: 0; transition: background .2s; }
.switch:after { content: ""; display: block; width: 19px; height: 19px; border-radius: 50%; background: var(--switch-knob); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch.on { background: var(--switch-on); }
.switch.on:after { transform: translateX(15px); }

.setting-mode { display: flex; gap: 9px; padding: 12px; }
.mode-card { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 13px; padding: 15px 10px 13px; text-align: left; }
.mode-card.chosen { border-color: #b2a0ed; background: #fbfaff; }
[data-theme="dark"] .mode-card.chosen { border-color: #5c4b93; background: #1c1a26; }
.mode-card .mc-icon { color: #5a5a5a; }
.mode-card.chosen .mc-icon { color: #9b7eec; }
[data-theme="dark"] .mode-card .mc-icon { color: var(--text-4); }
.mc-title { font-size: 13px; font-weight: 650; margin-top: 8px; }
.mc-desc { font-size: 10px; color: #9c9c9c; line-height: 1.6; margin-top: 5px; }
[data-theme="dark"] .mc-desc { color: var(--text-4); }
.safe-area-bottom { height: 20px; flex-shrink: 0; }
.back { display: flex; align-items: center; justify-content: center; height: 36px; width: 35px; margin-left: -7px; }
.headline-bar { display: flex; align-items: center; padding: 11px 19px; gap: 10px; flex-shrink: 0; min-height: 56px; }
.headline-bar h1 { font-size: 19px; margin: 0; flex: 1; text-align: center; padding-right: 33px; }

/* ---------------------------------------------------------------------------
 * 9. 历史 / 文件夹
 * ------------------------------------------------------------------------ */
.search-input {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 13px;
  margin: 12px 0 20px;
  color: var(--text-5);
}
.search-input input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 13px; color: var(--text); }
.history-item { width: 100%; display: flex; align-items: center; gap: 13px; padding: 15px 2px; text-align: left; border-bottom: 1px solid var(--border-soft); }
.history-icon { height: 39px; width: 39px; border-radius: 13px; background: var(--surface-2); color: var(--text-3); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.history-details { flex: 1; min-width: 0; }
.history-details .history-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-details .history-sub { font-size: 11px; color: var(--text-4); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { margin: auto; text-align: center; color: var(--text-5); display: flex; align-items: center; flex-direction: column; gap: 12px; padding: 38px 20px; }
.empty-list .icon { height: 43px; width: 43px; color: #ccc; }
[data-theme="dark"] .empty-list .icon { color: var(--text-6); }
.history-detail {
  position: absolute;
  inset: calc(var(--status-h) + var(--safe-top)) 0 calc(var(--nav-h) + var(--safe-bottom));
  z-index: 9;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.history-detail.active { display: flex; }
.detail-scroll { padding: 16px; overflow: auto; flex: 1; overscroll-behavior: contain; }
.detail-actions { padding: 10px 12px; display: flex; gap: 7px; border-top: 1px solid var(--border-soft); background: var(--bg); }
.detail-actions button {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 11px;
  padding: 10px 4px;
  font-size: 11px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.detail-actions button:disabled { opacity: .45; }
.detail-actions button.icon-only { flex: 0 0 40px; padding: 10px 0; }
.detail-meta { padding: 0 19px 12px; font-size: 12px; color: var(--text-4); display: flex; gap: 10px; flex-wrap: wrap; }

/* 历史详情：AI 摘要区块（record.summary，随停止落库） */
.history-summary {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 14px 16px;
  margin: 0 0 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .03);
}
.history-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 9px;
}
.history-summary-head button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 650;
  color: var(--accent);
  padding: 4px 6px;
  border-radius: 8px;
}
.history-summary-head button:active { background: var(--surface-2); }
.history-summary-body {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 24px);
  max-width: calc(100% - 35px);
  transform: translate(-50%, 20px);
  padding: 11px 14px;
  background: rgba(25, 25, 25, .89);
  color: #fff;
  border-radius: 11px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  font-size: 12px;
  text-align: center;
  transition: opacity .2s, transform .2s;
  white-space: normal;
  min-width: 180px;
  line-height: 1.5;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
[data-theme="dark"] .toast { background: rgba(238, 238, 242, .95); color: #141416; }

/* 弹层 */
.modal { position: absolute; inset: 0; display: none; align-items: flex-end; background: rgba(0, 0, 0, .27); z-index: 20; }
.modal.open { display: flex; }
.sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  padding: 15px 17px max(26px, var(--safe-bottom));
  box-shadow: 0 -3px 15px rgba(0, 0, 0, .13);
  max-height: 78vh;
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 3px 1px 14px; border-bottom: 1px solid var(--border-soft); font-size: 16px; font-weight: 700; }
.sheet-head button { color: var(--text-3); }
.choice { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 15px 6px; border-bottom: 1px solid var(--border-soft); font-size: 14px; color: var(--text); }
.choice.selected { color: #8369c3; }
.choice small { color: var(--text-5); font-size: 11px; }
.choice .tick { font-weight: bold; }
.text-field {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  margin: 9px 0;
  font-size: 13px;
}
.notice { color: #9d9d9d; font-size: 11px; line-height: 1.7; padding: 11px 3px; }
[data-theme="dark"] .notice { color: var(--text-4); }

/* 设置：输入项 / 调试输出 */
.model-action { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: 9px; padding: 7px 10px; font-size: 11px; white-space: nowrap; }
.model-action.primary { border-color: #c9b8f2; background: #f7f4fe; color: #7b5fd0; }
[data-theme="dark"] .model-action.primary { border-color: #4c3f78; background: #211d2f; color: #b39bf5; }
.model-action.danger { color: var(--danger); }
/* debug-only 入口：导入 WAV 的返回 JSON / 事件输出（仅 appInfo().debug===true 时显示） */
.debug-output {
  margin: 8px 0 0;
  padding: 8px 10px;
  max-height: 190px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-2);
}
.slider-row { padding: 14px 16px 18px; }
.slider-row .slider-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 560; margin-bottom: 12px; gap: 10px; }
.slider-row .slider-val { font-size: 12px; color: var(--text-4); font-weight: 400; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: var(--surface-3);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.slider-preview { margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; background: var(--surface-4); }
.slider-preview .sp-origin { font-size: var(--subtitle-font-size); line-height: 1.6; }
.slider-preview .sp-trans { font-size: calc(var(--subtitle-font-size) * .76); color: var(--text-2); line-height: 1.6; margin-top: 8px; }

.version-line { color: var(--text-4); font-size: 12px; text-align: center; padding: 18px 0 6px; line-height: 1.7; }

/* 加载 / 骨架 */
.loading-line { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 26px 0; color: var(--text-4); font-size: 12px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================
 * v3：全屏登录门禁 / 管理员后台 / 购买与改密
 * ========================================================================== */

/* v8 硬锁：未登录时 #app 完全不渲染（HTML 初始即 locked，不依赖 JS）。
 * 登录页只在 JS 明确展示（.visible）时出现；启动阶段由 #boot-splash 先遮挡，
 * 避免已登录用户冷启动时先看到登录页闪一下。 */
html.locked #app { display: none !important; }
html.locked #auth-gate.visible { display: flex !important; }
html.locked body { overflow: hidden; }

/* 门禁打开时主界面不可交互（inert 由 JS 设置，这里做 CSS 兜底） */
html.auth-locked .page,
html.auth-locked .bottom-nav,
html.auth-locked #status { pointer-events: none; }

/* ---------------- 全屏认证页 ---------------- */
/* 默认不渲染，由 showAuthGate() 加 .visible / 内联 display 后出现（见上方 locked 规则） */
.auth-gate {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: none;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(120% 85% at 88% -8%, rgba(155, 126, 236, .42), transparent 58%),
    radial-gradient(95% 75% at -6% 104%, rgba(65, 141, 230, .28), transparent 60%),
    linear-gradient(158deg, #f8f5ff 0%, #eef2ff 46%, #f6f0fb 100%);
  padding: calc(var(--inset-top, 0px) + 18px) 20px calc(var(--inset-bottom, 0px) + 18px);
}
html.native-app .auth-gate { padding-top: calc(var(--inset-top, 0px) + 20px); }
[data-theme="dark"] .auth-gate {
  background:
    radial-gradient(120% 85% at 88% -8%, rgba(150, 118, 245, .30), transparent 60%),
    radial-gradient(95% 75% at -6% 104%, rgba(56, 108, 200, .22), transparent 62%),
    linear-gradient(158deg, #0b0a12 0%, #0a0d17 50%, #0d0a15 100%);
}
.auth-ambient { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.auth-glow { position: absolute; border-radius: 50%; filter: blur(62px); opacity: .62; }
.auth-glow.g1 { width: 330px; height: 330px; background: #b9a3ff; top: -120px; right: -100px; }
.auth-glow.g2 { width: 300px; height: 300px; background: #8fc4ff; bottom: -110px; left: -110px; }
.auth-glow.g3 { width: 210px; height: 210px; background: #ffc9e4; bottom: 26%; right: -90px; opacity: .35; }
[data-theme="dark"] .auth-glow { opacity: .34; }
[data-theme="dark"] .auth-glow.g3 { opacity: .16; }

.auth-scroll {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 6px 2px 14px;
  scrollbar-width: none;
}
.auth-scroll::-webkit-scrollbar { display: none; }
.auth-scroll > * { flex-shrink: 0; }

.auth-brand { text-align: center; padding: 4px 0 2px; }
.auth-logo {
  width: 66px;
  height: 66px;
  margin: 0 auto 14px;
  border-radius: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(140deg, #f3bed8 0%, #c9aeef 52%, #8f8bfa 100%);
  box-shadow: 0 18px 38px -16px rgba(120, 92, 235, .75), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.auth-logo .icon { width: 32px; height: 32px; }
.auth-brand-name { font-size: 27px; font-weight: 800; letter-spacing: .16em; text-indent: .16em; }
.auth-brand-sub { margin-top: 7px; font-size: 12px; color: var(--text-3); letter-spacing: .04em; }

/* ---------------- 启动闪屏（登录态确认前） ---------------- */
/* 已登录用户冷启动时只看到品牌加载页，不会先闪出登录页；确认未登录后由登录页取代。 */
.boot-splash {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(120% 85% at 88% -8%, rgba(155, 126, 236, .42), transparent 58%),
    radial-gradient(95% 75% at -6% 104%, rgba(65, 141, 230, .28), transparent 60%),
    linear-gradient(158deg, #f8f5ff 0%, #eef2ff 46%, #f6f0fb 100%);
  padding: calc(var(--inset-top, 0px) + 24px) 24px calc(var(--inset-bottom, 0px) + 24px);
}
html.native-app .boot-splash { padding-top: calc(var(--inset-top, 0px) + 26px); }
[data-theme="dark"] .boot-splash {
  background:
    radial-gradient(120% 85% at 88% -8%, rgba(150, 118, 245, .30), transparent 60%),
    radial-gradient(95% 75% at -6% 104%, rgba(56, 108, 200, .22), transparent 62%),
    linear-gradient(158deg, #0b0a12 0%, #0a0d17 50%, #0d0a15 100%);
}
.boot-splash.hide { display: none !important; }
.boot-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.boot-splash .auth-logo { margin-bottom: 8px; }
.boot-splash-name { font-size: 26px; font-weight: 800; letter-spacing: .18em; text-indent: .18em; }
.boot-splash-sub { font-size: 12px; color: var(--text-3); letter-spacing: .06em; }
.boot-splash-loading {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .04em;
}

.auth-card {
  position: relative;
  border-radius: 26px;
  padding: 18px 16px 16px;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(255, 255, 255, .78);
  box-shadow: 0 26px 60px -26px rgba(52, 30, 120, .45), inset 0 1px 0 rgba(255, 255, 255, .7);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}
[data-theme="dark"] .auth-card {
  background: rgba(24, 23, 34, .64);
  border-color: rgba(255, 255, 255, .09);
  box-shadow: 0 26px 65px -26px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.auth-seg {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 15px;
  background: rgba(122, 110, 168, .12);
}
.auth-seg-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  height: 38px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text-3);
  transition: color .2s;
}
.auth-seg-btn.active { color: var(--text); }
.auth-seg-thumb {
  position: absolute;
  z-index: 0;
  top: 4px;
  left: 4px;
  width: calc(50% - 6px);
  height: 38px;
  border-radius: 11px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(40, 26, 90, .14);
  transition: transform .26s cubic-bezier(.22, .8, .2, 1);
}
.auth-gate.mode-register .auth-seg-thumb { transform: translateX(calc(100% + 4px)); }

.auth-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 12px 0 14px;
  margin-bottom: 10px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .55);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
[data-theme="dark"] .auth-field { background: rgba(255, 255, 255, .055); border-color: rgba(255, 255, 255, .09); }
.auth-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3.5px rgba(155, 126, 236, .16); background: rgba(255, 255, 255, .78); }
[data-theme="dark"] .auth-field:focus-within { background: rgba(255, 255, 255, .08); }
.auth-field > .icon { color: var(--text-4); }
.auth-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.auth-field input::placeholder { color: var(--text-5); }
.auth-eye {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-4);
}
.auth-eye:active { background: rgba(120, 110, 160, .12); }

/* v9：注册邮箱验证码（保持登录页原视觉，仅追加验证码输入与获取按钮） */
.auth-code-field input { letter-spacing: .32em; font-size: 17px; }
.auth-code-actions { display: flex; justify-content: flex-end; margin: -2px 2px 10px; }
.auth-send {
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
  padding: 6px 9px;
  border-radius: 9px;
  white-space: nowrap;
}
.auth-send:active:not(:disabled) { background: var(--surface-2); }
.auth-send:disabled { color: var(--text-5); }
.auth-code-hint { margin: -4px 2px 10px; font-size: 11px; line-height: 1.5; color: var(--text-4); }
.auth-field.hidden { display: none !important; }

.auth-error {
  margin: 2px 2px 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.6;
  color: #b3262b;
  background: rgba(239, 77, 82, .1);
  border: 1px solid rgba(239, 77, 82, .26);
}
[data-theme="dark"] .auth-error { color: #ff9296; background: rgba(239, 77, 82, .16); border-color: rgba(239, 77, 82, .34); }

.auth-submit {
  position: relative;
  width: 100%;
  height: 52px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #8b6ef0 0%, #5e8bf5 100%);
  box-shadow: 0 16px 30px -16px rgba(105, 90, 240, .95);
  transition: transform .15s, opacity .2s, box-shadow .2s;
}
.auth-submit:active { transform: scale(.985); }
.auth-submit[disabled] { opacity: .62; box-shadow: none; }
.auth-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
  display: none;
}
.auth-spinner.show { display: inline-block; }
/* v8：校验失败时的「重试」（保持登录页原视觉，仅追加一个次级按钮） */
.auth-retry {
  width: 100%;
  height: 44px;
  margin-top: 10px;
  border-radius: 13px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
}
.auth-retry:active { background: var(--surface-2); }
.auth-retry[hidden] { display: none !important; }
.auth-foot { margin-top: 13px; text-align: center; font-size: 12px; color: var(--text-3); }
.auth-legal { text-align: center; font-size: 11px; color: var(--text-4); letter-spacing: .03em; }
.auth-gate.checking .auth-seg,
.auth-gate.checking .auth-fields,
.auth-gate.checking .auth-foot { opacity: .5; pointer-events: none; }

/* 矮屏 / 键盘弹出：品牌区收紧 */
@media (max-height: 640px) {
  .auth-gate { padding-top: calc(var(--inset-top, 0px) + 10px); padding-bottom: calc(var(--inset-bottom, 0px) + 10px); }
  .auth-logo { width: 54px; height: 54px; border-radius: 17px; margin-bottom: 10px; }
  .auth-brand-name { font-size: 23px; }
  .auth-brand-sub { margin-top: 4px; }
  .auth-scroll { gap: 14px; justify-content: flex-start; padding-top: 10px; }
}

/* ---------------- 修改密码弹层内的密码框 ---------------- */
.pwd-wrap { position: relative; margin: 9px 0; }
.pwd-wrap .text-field { margin: 0; padding-right: 48px; }
.pwd-wrap .auth-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* ---------------- 管理员后台（全屏子页面，不占 tab） ---------------- */
.admin-page {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: none;
  flex-direction: column;
  background: var(--bg-app);
  color: var(--text);
}
.admin-page.visible { display: flex; }
.admin-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  flex-shrink: 0;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  padding-top: calc(10px + var(--inset-top, 0px));
}
.admin-title { flex: 1; font-size: 17px; font-weight: 700; }
.admin-badge {
  font-size: 10px;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 3px 7px;
  white-space: nowrap;
}
.admin-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px 16px calc(30px + var(--inset-bottom, 0px));
}
.admin-page .section-headline { margin-top: 18px; }
.admin-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 14px;
  margin-bottom: 12px;
}
.admin-label { font-size: 12px; color: var(--text-3); margin: 2px 0 9px; }
.admin-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.admin-seg button {
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 560;
}
.admin-seg button.active {
  border-color: #b2a0ed;
  background: #f7f4fe;
  color: #7b5fd0;
  font-weight: 700;
}
[data-theme="dark"] .admin-seg button.active { border-color: #4c3f78; background: #211d2f; color: #b39bf5; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 6px; }
.admin-input { width: 104px !important; margin: 0 !important; text-align: center; }
.admin-error {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--danger);
  background: rgba(239, 77, 82, .09);
  border: 1px solid rgba(239, 77, 82, .22);
}
.admin-result { margin-top: 14px; border-top: 1px solid var(--border-soft); padding-top: 12px; }
.admin-result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 650; margin-bottom: 9px; }
.admin-code-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(46vh, 360px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.admin-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
.admin-code-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: .04em;
  word-break: break-all;
  color: var(--text);
}
.admin-code-row button { flex-shrink: 0; font-size: 11px; font-weight: 650; color: var(--accent); padding: 4px 6px; }
.admin-url-actions { display: flex; gap: 8px; }
.admin-url-actions .flat-button { margin-top: 8px; }
.admin-url-actions .flat-button.ghost { flex: 0 0 42%; }

/* =============================================================================
 * v5 §12.4：管理员「用户管理」抽屉（overlay，不挤压页面）
 * ========================================================================== */
.admin-drawer { position: fixed; inset: 0; z-index: 70; display: none; }
.admin-drawer.visible { display: block; }
.admin-drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .38);
  opacity: 0;
  transition: opacity .2s ease;
}
.admin-drawer.visible .admin-drawer-backdrop { opacity: 1; }
.admin-drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(92vw, 520px);
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  color: var(--text);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0, 0, 0, .2);
  transform: translateX(100%);
  transition: transform .24s ease;
}
.admin-drawer.visible .admin-drawer-panel { transform: translateX(0); }
[data-theme="dark"] .admin-drawer-backdrop { background: rgba(0, 0, 0, .58); }
[data-theme="dark"] .admin-drawer-panel { border-left-color: var(--border); box-shadow: -10px 0 30px rgba(0, 0, 0, .5); }
.admin-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.admin-drawer-title { font-size: 16px; font-weight: 720; }
.admin-users-total { flex: 1; font-size: 12px; color: var(--text-4); }
.admin-drawer-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.admin-drawer-toolbar .text-field { flex: 1; margin: 0 !important; }
.admin-drawer-toolbar .flat-button { width: auto; margin: 0; flex-shrink: 0; padding: 8px 14px; }
.admin-drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 8px 10px calc(24px + var(--inset-bottom, 0px));
}
.admin-users-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.admin-users-table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 12px; }
.admin-users-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  font-weight: 650;
  color: var(--text-4);
  background: var(--bg-app);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-users-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.admin-users-table tr:last-child td { border-bottom: none; }
.admin-users-email { word-break: break-all; color: var(--text); }
.admin-users-badge {
  display: inline-block;
  font-size: 10px;
  line-height: 1.5;
  padding: 0 6px 1px;
  border-radius: 999px;
  border: 1px solid #d9c9f2;
  background: #f5f0fd;
  color: #7b5fd0;
  white-space: nowrap;
}
[data-theme="dark"] .admin-users-badge { border-color: #4c3f78; background: #211d2f; color: #b39bf5; }
.admin-users-status { padding: 12px 4px; font-size: 12px; color: var(--text-4); text-align: center; }
.admin-users-status .spinner { margin-right: 6px; }
.admin-users-empty { padding: 26px 8px; text-align: center; color: var(--text-4); font-size: 12px; }

/* =============================================================================
 * v3.1：画中画字幕视图（PiP）
 * ========================================================================== */
html.pip-on .page,
html.pip-on .bottom-nav,
html.pip-on #status { pointer-events: none; }

.pip-view {
  position: absolute;
  inset: 0;
  z-index: 55;
  display: none;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  padding: calc(var(--inset-top, 0px) + 10px) 14px calc(var(--inset-bottom, 0px) + 12px);
}
.pip-view.visible { display: flex; }
.pip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-4);
  padding-bottom: 4px;
}
.pip-brand { font-weight: 750; letter-spacing: .18em; text-indent: .18em; color: var(--text-3); }
.pip-state { white-space: nowrap; }
.pip-lines {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(3px, 1vh, 9px);
  overflow: hidden;
}
.pip-line { padding: clamp(2px, .6vh, 7px) 0; }
.pip-line + .pip-line { border-top: 1px solid var(--border-soft); }
.pip-origin {
  font-size: clamp(11px, 2.9vh, 20px);
  line-height: 1.35;
  color: var(--text-3);
  word-break: break-word;
}
.pip-trans {
  font-size: clamp(15px, 4.4vh, 30px);
  line-height: 1.32;
  font-weight: 720;
  color: var(--text);
  margin-top: 2px;
  word-break: break-word;
}
.pip-line:last-child .pip-trans { font-size: clamp(17px, 5.2vh, 36px); }
.pip-line.pending .pip-trans { color: var(--text-4); font-weight: 500; font-style: italic; }
.pip-line.no-trans .pip-origin { color: var(--text); font-weight: 620; }
/* v4：PIP 小窗同样显示人物标签（小号，不抢主字幕） */
.pip-speaker {
  display: inline-block;
  margin-bottom: 2px;
  padding: 0 6px 1px;
  font-size: clamp(9px, 2.2vh, 13px);
  line-height: 1.5;
  font-weight: 650;
  border: 1px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
}
.pip-empty {
  margin: auto;
  color: var(--text-4);
  font-size: clamp(12px, 3.2vh, 18px);
  text-align: center;
}
@media (max-height: 340px) {
  .pip-view { padding: 5px 10px; }
  .pip-head { display: none; }
  .pip-line { padding: 2px 0; }
}

/* 译文区「译」小标签（不再显示引擎名等技术信息） */
.output-tag {
  font-size: 10px;
  color: var(--text-4);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px 5px;
  white-space: nowrap;
}

/* 检查更新弹层 */
.update-version { font-size: 17px; font-weight: 750; margin: 2px 0 9px; }
.update-changelog {
  font-size: 12px;
  line-height: 1.75;
  color: var(--text-2);
  max-height: 180px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  margin-bottom: 10px;
  word-break: break-word;
}
.update-size { font-size: 11px; color: var(--text-4); margin-bottom: 10px; }
.update-progress {
  height: 6px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
  display: none;
  margin: 8px 0;
}
.update-progress.show { display: block; }
.update-progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, #a480df, #958ff9); transition: width .2s linear; }
.update-progress-text { font-size: 11px; color: var(--text-4); margin-bottom: 10px; display: none; line-height: 1.6; }
.update-progress-text.show { display: block; }
.update-error {
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--danger);
  background: rgba(239, 77, 82, .09);
  border: 1px solid rgba(239, 77, 82, .22);
}
.update-error[hidden] { display: none !important; }

/* =============================================================================
 * v4：历史页长按多选（批量导出 / 删除）
 * ========================================================================== */
#page-history.selecting .topbar { display: none; }
#page-history.selecting .search-input,
#page-history.selecting #history-count { display: none; }

.history-selbar {
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: 8px 14px;
  flex-shrink: 0;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border-soft);
}
#page-history.selecting .history-selbar { display: flex; }
.history-selbar .sel-close {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-2);
}
.history-selbar .sel-count { font-size: 13px; font-weight: 650; white-space: nowrap; }
.history-selbar .sel-toggle {
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
  padding: 8px 10px;
  border-radius: 9px;
  white-space: nowrap;
}
.history-selbar .sel-toggle:active { background: var(--surface-2); }
#page-history.selecting #history-list { padding-bottom: 76px; }

/* 列表项复选框与长按/选中反馈 */
.history-item { transition: transform .12s, background .12s; }
.history-item .sel-box {
  display: none;
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  border-radius: 7px;
  border: 1.6px solid var(--border-strong);
  color: #fff;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}
#page-history.selecting .history-item .sel-box { display: inline-flex; }
.history-item .sel-box .icon { width: 14px; height: 14px; display: none; }
.history-item.selected .sel-box { background: var(--accent); border-color: var(--accent); }
.history-item.selected .sel-box .icon { display: inline-flex; }
.history-item.selected { background: rgba(155, 126, 236, .07); border-radius: 12px; }
[data-theme="dark"] .history-item.selected { background: rgba(179, 155, 245, .12); }
.history-item.long-pressing { transform: scale(.985); background: var(--surface-2); border-radius: 12px; }

/* 多选底部操作栏（相对 .app 绝对定位，位于底部 tab 上方） */
.multi-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  z-index: 8;
  display: none;
  gap: 8px;
  padding: 10px 14px;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, .08);
}
.multi-bar.show { display: flex; }
.multi-bar button {
  flex: 1;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.multi-bar button.danger { color: var(--danger); border-color: rgba(239, 77, 82, .3); }
.multi-bar button:disabled { opacity: .45; }
.multi-bar button:active { transform: scale(.985); }

/* 批量导出结果 */
.batch-summary { font-size: 13px; font-weight: 650; margin: 2px 0 9px; }
.batch-hint { font-size: 11px; color: var(--text-4); line-height: 1.6; margin-bottom: 8px; }
.batch-path-list {
  max-height: 230px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 4px 10px;
  margin-bottom: 10px;
}
.batch-path-row { padding: 8px 0; }
.batch-path-row + .batch-path-row { border-top: 1px solid var(--border-soft); }
.batch-path-title { font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-path-line { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.batch-path-value {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text-4);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.batch-path-line button { flex-shrink: 0; font-size: 11px; font-weight: 650; color: var(--accent); padding: 4px 6px; }
.batch-fail-list { margin-bottom: 10px; }
.batch-fail-row {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(239, 77, 82, .07);
  border: 1px solid rgba(239, 77, 82, .18);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
}
.batch-fail-row + .batch-fail-row { margin-top: 6px; }
.batch-fail-row b { color: var(--danger); font-weight: 650; }

/* ---------------------------------------------------------------------------
 * 10. 响应式 / 矮屏（与原设计一致）
 * ------------------------------------------------------------------------ */
@media (min-width: 620px) {
  body { display: grid; place-items: center; }
  .app { height: min(93vh, 900px); min-height: 600px; border-radius: 26px; border: 1px solid var(--border-strong); box-shadow: 0 15px 65px rgba(0, 0, 0, .13); }
  .bottom-nav { border-radius: 0 0 26px 26px; }
}
@media (max-height: 680px) {
  .mic-button { width: 92px; height: 92px; }
  .hero-text { margin-top: 12px; }
  .rec-center { min-height: 160px; }
  .rec-header { min-height: 56px; }
}

/* ---------------------------------------------------------------------------
 * 11. 无障碍 / 动效偏好 / 性能
 * ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
/* 字幕列表内容变化时的轻提示，避免大面积重排 */
.transcript-card { contain: content; }

/* 禁用长按选择外的高亮，保持 APP 手感 */
* { -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
