/* =============================================================================
 * live-shell.css — 「实时翻译 / 录音中」页面外壳（live-shell 专属）
 *
 * 只作用于 #page-rec 的录音中状态（#rec-active.rec-live / .rec-live 子树）：
 *   - 顶部固定栏（文件夹 / 语言 / 实时状态 / 耳机 TTS / 结束录制）
 *   - 内容区（小标题 + #line-list + #live-bubble + 提示）
 *   - 「↓ 回到实时」按钮
 *   - 固定底部操作栏 #rec-dock（双向开关 / 画中画 / 暂停 + 录音计时）
 *
 * 约定：
 *   - 设计 token 全部用 --lv-* 变量，作用域限定在 #rec-active.rec-live，不污染全局 :root；
 *   - class 一律 lv- 前缀，避免与 styles.css 里同名/裸名样式冲突；
 *   - 深色模式走 document.documentElement[data-theme="dark"]；
 *   - 兼容 Android 10 WebView（Chrome 80）：不使用 :has、inset 简写、gap 作为唯一间距。
 * 卡片/气泡本体由 live-feed.css 负责，这里只做外壳与布局。
 * ========================================================================== */

/* ---------------------------------------------------------------------------
 * 1. 设计 token（仅录音中页面作用域）
 * ------------------------------------------------------------------------ */
#rec-active.rec-live,
.rec-live {
  --lv-bg: #fafafa;
  --lv-surface: #ffffff;
  --lv-line: #e7e8eb;
  --lv-text: #202126;
  --lv-secondary: #858990;
  --lv-accent: #303640;
  --lv-tint: #f3f5f7;
  --lv-green: #16b88e;
  --lv-green-ink: #148f6e;
  --lv-red: #ef4c4c;
  --lv-blue: #6a9bd5;
  --lv-shadow: 0 12px 30px rgba(22, 27, 38, .09);
  --lv-page: 520px;
  /* 由 JS 实测写入（见 app.js measureLiveDock）；默认值只作首帧兜底 */
  --lv-dock-height: 132px;
  --lv-nav-height: 67px;
}

[data-theme="dark"] #rec-active.rec-live,
[data-theme="dark"] .rec-live {
  --lv-bg: #141416;
  --lv-surface: #18181b;
  --lv-line: #2e2e35;
  --lv-text: #f3f3f4;
  --lv-secondary: #8e8e95;
  --lv-accent: #e9e9ec;
  --lv-tint: #1f1f23;
  --lv-green: #3dd6a8;
  --lv-green-ink: #4fd6b0;
  --lv-red: #ff5a60;
  --lv-blue: #7fb0e8;
  --lv-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}

/* ---------------------------------------------------------------------------
 * 2. 录音中页面骨架
 * ------------------------------------------------------------------------ */
#rec-active.rec-live {
  position: relative;
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--lv-bg);
  color: var(--lv-text);
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
 * 3. 顶部固定栏（72px）
 * ------------------------------------------------------------------------ */
/* 注意层级：全局 .modal 的 z-index 是 20，固定 dock 必须低于它，
 * 否则底部「结束录制」确认弹层会被操作栏盖住点不到。 */
#rec-live-head.lv-pagetop {
  flex-shrink: 0;
  height: 72px;
  padding: 0 23px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--lv-line);
  background: var(--lv-bg);
  position: relative;
  z-index: 10;
}
/* 兼容 Android 10 WebView（Chrome 80）：flex gap 从 Chrome 84 才有，
 * 这里用相邻 margin 实现同样的间距，现代浏览器视觉一致。 */
.lv-pagetop > * + * { margin-left: 10px; }

.lv-folder {
  display: flex;
  align-items: center;
  color: #505259;
  font-size: 14px;
  border: 0;
  background: none;
  padding: 8px 0;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
}
[data-theme="dark"] .lv-folder { color: var(--lv-secondary); }
.lv-folder .icon { color: #6e7279; margin-right: 7px; }
[data-theme="dark"] .lv-folder .icon { color: var(--lv-secondary); }
.lv-folder .lv-folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 96px;
}
.lv-folder .lv-caret { font-size: 11px; color: #9da1a7; transform: translateY(1px); margin-left: 7px; }

.lv-topspacer { flex: 1; min-width: 0; }

.lv-topicon {
  width: 39px;
  height: 39px;
  border: 1px solid #ebebee;
  border-radius: 13px;
  background: #f3f3f4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6e7279;
  flex: 0 0 auto;
  padding: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.lv-topicon .icon { width: 20px; height: 20px; }
.lv-topicon:active { background: #ececef; }
.lv-topicon.lv-active {
  background: #e8f6f2;
  color: #148f6e;
  border-color: #cdece2;
}
[data-theme="dark"] .lv-topicon {
  background: #1f1f23;
  border-color: #2e2e35;
  color: #a2a2a9;
}
[data-theme="dark"] .lv-topicon:active { background: #26262b; }
[data-theme="dark"] .lv-topicon.lv-active {
  background: #17352e;
  border-color: #2b6a59;
  color: #4fd6b0;
}
.lv-topicon:disabled { opacity: .55; }

.lv-live {
  font-size: 13px;
  color: #1baa86;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-weight: 600;
  flex: 0 0 auto;
}
.lv-live .lv-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #17bc90;
  box-shadow: 0 0 0 3px rgba(25, 194, 149, .09);
  flex: 0 0 auto;
  margin-right: 6px;
}
.lv-live.paused { color: #8c919a; }
.lv-live.paused .lv-dot { background: #a4a8b0; box-shadow: none; }
.lv-live.ended { color: #8c919a; }
.lv-live.ended .lv-dot { background: #9ba0a8; box-shadow: none; }
[data-theme="dark"] .lv-live { color: #3dd6a8; }
[data-theme="dark"] .lv-live.paused,
[data-theme="dark"] .lv-live.ended { color: #8e8e95; }

.lv-stop {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0 15px;
  height: 42px;
  border-radius: 10px;
  background: var(--lv-red);
  color: #fff;
  white-space: nowrap;
  font-weight: 600;
  font-size: 14px;
  flex: 0 0 auto;
}
.lv-stop:active { filter: brightness(.95); }
.lv-stop:disabled { opacity: .55; }
.lv-stop .lv-stopsquare {
  width: 11px;
  height: 11px;
  background: #fff;
  border-radius: 2px;
  flex: 0 0 auto;
  margin-right: 7px;
}
.lv-stop .lv-check { font-size: 13px; line-height: 1; }

/* ---------------------------------------------------------------------------
 * 4. 连接 / 错误 banner（沿用 styles.css 的 .conn-banner，仅调整录音中页间距）
 * ------------------------------------------------------------------------ */
#rec-active.rec-live .conn-banner {
  margin: 10px 12px 0;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
 * 5. 内容区（#transcript-stream 内部滚动）
 * ------------------------------------------------------------------------ */
#rec-active.rec-live #transcript-stream.lv-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* 卡片更宽（round3）：内容左右 23→12px；底部按实测 dock 高度留白 */
  padding: 16px 12px calc(var(--lv-dock-height, 132px) + 30px);
  position: relative;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  --level: 0;
}
#rec-active.rec-live #transcript-stream.lv-content::-webkit-scrollbar { display: none; }

.lv-smallhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 3px 0 15px;
  color: var(--lv-secondary);
  font-size: 12px;
  line-height: 1.4;
}
.lv-smallhead .lv-headtext {
  flex-shrink: 0;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 结束后的 AI 整理状态（AI 整理中 / 已整理；不是报错提示），显示在计时行右侧 */
.lv-aistatus {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  line-height: 1.4;
  color: #187f6d;
  white-space: nowrap;
}
.lv-aistatus[hidden] { display: none !important; }
.lv-aistatus.lv-done { color: #9ba0a8; }
[data-theme="dark"] .lv-aistatus { color: #4fd6b0; }
[data-theme="dark"] .lv-aistatus.lv-done { color: #8e8e95; }
.lv-smallhead .lv-rule {
  height: 1px;
  background: var(--lv-line);
  flex: 1;
  margin-left: 12px;
}

#rec-active.rec-live #line-list {
  display: flex;
  flex-direction: column;
}

/* 实时气泡容器：内部结构由 live-feed.css 负责；为空时不占位 */
#rec-active.rec-live #live-bubble { margin-top: 12px; }
#rec-active.rec-live #live-bubble:empty { display: none; margin-top: 0; }

/* ---------------------------------------------------------------------------
 * 6.「↓ 回到实时」（固定在操作栏上方，由 live-feed 切换 .show）
 * ------------------------------------------------------------------------ */
.lv-jumpnow {
  position: absolute;
  right: 22px;
  bottom: calc(var(--lv-dock-height, 132px) + 20px);
  z-index: 13;
  border: 1px solid #d6dee1;
  border-radius: 22px;
  background: #ffffff;
  color: #187f6d;
  font-size: 12px;
  font-weight: 600;
  padding: 9px 15px;
  box-shadow: 0 4px 16px rgba(11, 28, 34, .12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s;
}
.lv-jumpnow.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
[data-theme="dark"] .lv-jumpnow {
  background: #232328;
  border-color: #3a3a42;
  color: #4fd6b0;
}

/* ---------------------------------------------------------------------------
 * 7. 固定底部操作栏（位于 #bottom-nav 上方）
 *   用 absolute 相对 #rec-active 定位：桌面端 .app 居中且高度小于视口时，
 *   仍与页面同宽、紧贴底部导航，不受 viewport 底部影响。
 * ------------------------------------------------------------------------ */
#rec-dock.lv-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  z-index: 12;
  background: var(--lv-surface);
  border-top: 1px solid var(--lv-line);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -5px 14px rgba(40, 44, 58, .03);
  padding: 14px calc(16px + var(--safe-right, 0px)) 14px calc(16px + var(--safe-left, 0px));
  box-sizing: border-box;
}
[data-theme="dark"] #rec-dock.lv-dock { box-shadow: 0 -5px 14px rgba(0, 0, 0, .3); }

.lv-handle {
  width: 38px;
  height: 5px;
  border-radius: 5px;
  background: #d8dbe1;
  margin: 0 auto 13px;
}
[data-theme="dark"] .lv-handle { background: #3a3a42; }

.lv-controlrow {
  display: flex;
  align-items: flex-start;
  position: relative;   /* v4：#ai-note-btn 以本行为定位基准，右缘对齐暂停键 */
}
/* Chrome 80 无 flex gap：用相邻 margin 兜底（含画中画列容器） */
.lv-controlrow > * + * { margin-left: 8px; }

.lv-control {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e7e8eb;
  background: #f4f5f6;
  color: #3f4249;
  border-radius: 14px;
  min-height: 44px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.lv-control .icon { width: 18px; height: 18px; flex: 0 0 auto; }
.lv-control .lv-btn-text { margin-left: 7px; }
.lv-control:active { background: #ececef; }
.lv-control.lv-toggle { flex: 1; min-width: 0; }
.lv-control.lv-toggle .lv-btn-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lv-control.lv-selected {
  border-color: #a6d9cc;
  background: #ebf8f4;
  color: #168769;
}
.lv-control.lv-dark {
  background: #31343b;
  border-color: #31343b;
  color: #fff;
}
.lv-control.lv-dark:active { background: #3a3e46; }
.lv-control.lv-square { width: 45px; padding: 0; flex: 0 0 auto; }
.lv-control:disabled { opacity: .55; }
.lv-control:disabled:active { background: #f4f5f6; }

[data-theme="dark"] .lv-control {
  background: #1f1f23;
  border-color: #2e2e35;
  color: #c8c8cd;
}
[data-theme="dark"] .lv-control:active { background: #26262b; }
[data-theme="dark"] .lv-control.lv-selected {
  background: #17352e;
  border-color: #2b6a59;
  color: #4fd6b0;
}
[data-theme="dark"] .lv-control.lv-dark {
  background: #e9e9ec;
  border-color: #e9e9ec;
  color: #17171a;
}
[data-theme="dark"] .lv-control.lv-dark:active { background: #dcdce0; }
[data-theme="dark"] .lv-control:disabled:active { background: #1f1f23; }

/* ---------------------------------------------------------------------------
 * 7.1 画中画图标 + 其正下方的 AI 标志（round3：徽标在左，右侧上下两行）
 * ------------------------------------------------------------------------ */
.lv-pipcol {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  width: 45px;
}
.lv-pipcol .lv-control.lv-square { width: 45px; }

.lv-aibtn {
  position: absolute;
  right: 0;                 /* v4：右边缘与暂停键右边缘齐平 */
  top: 100%;                /* 仍在画中画图标下方 */
  z-index: 2;               /* 位于计时行之上（视觉不重叠，点击不被拦截） */
  margin-top: 3px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  padding: 3px 2px;
  height: 36px;             /* 30px 内容 + 上下 padding，≥34 */
  box-sizing: border-box;
  border: 0;
  background: none;
  color: #8c919a;
  white-space: nowrap;
}
.lv-aibtn:active { opacity: .65; }
.lv-ai-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;             /* 与右侧两行等高（±1px） */
  padding: 0 2px;
  font-size: 15px;          /* v4：13→15 */
  line-height: 1;
  font-weight: 800;
  color: #7b5fd0;
}
.lv-ai-spark { font-size: 17px; line-height: 1; margin-right: 2px; }
.lv-ai-hint {
  display: block;
  height: 30px;             /* 与徽标等高 */
  margin-left: 6px;
  color: #9ba0a8;
  font-size: 12px;          /* v4：10.5→12 */
  font-weight: 500;
  line-height: 1.25;        /* 两行 12 * 1.25 * 2 = 30px */
  text-align: left;
}
[data-theme="dark"] .lv-aibtn { color: #8e8e95; }
[data-theme="dark"] .lv-ai-badge { color: #b39bf5; }
[data-theme="dark"] .lv-ai-hint { color: #8c8e95; }

.lv-row2 {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  min-height: 18px;
  padding-right: 104px;     /* 让出 AI 块宽度，避免与计时重叠 */
  position: relative;       /* #ai-status 右侧绝对定位 */
}
.lv-clock {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #767b84;
  font-size: 12px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .lv-clock { color: #a2a2a9; }
.lv-clock .lv-reddot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ed4d4d;
  flex: 0 0 auto;
  margin-right: 7px;
}
.lv-clock #record-timer.paused { color: #8c919a; }
.lv-clock #record-timer.ended { color: #8c919a; }
#rec-active.rec-live.is-ended .lv-reddot { background: #a4a8b0; }

/* 结束态：整体降噪（卡片由 live-feed 置暗，这里处理外壳） */
#rec-active.rec-live.is-ended .lv-smallhead { opacity: .7; }
#rec-active.rec-live.is-ended .lv-aibtn { opacity: .55; }

/* ---------------------------------------------------------------------------
 * 8. 小屏（≤370px）：按设计稿缩放，保证 320px 无横向溢出
 * ------------------------------------------------------------------------ */
@media (max-width: 430px) {
  /* 390/375 等常见宽度：略收紧顶栏，保证「未分类」完整显示 */
  #rec-live-head.lv-pagetop {
    padding: 0 16px;
  }
  .lv-pagetop > * + * { margin-left: 8px; }
  .lv-folder .lv-folder-name { max-width: 80px; }
  .lv-stop { padding: 0 13px; }
}

@media (max-width: 370px) {
  #rec-live-head.lv-pagetop {
    padding: 0 12px;
  }
  .lv-pagetop > * + * { margin-left: 6px; }
  .lv-folder { font-size: 13px; }
  .lv-folder .icon { margin-right: 6px; }
  .lv-folder .lv-caret { margin-left: 6px; }
  .lv-folder .lv-folder-name { max-width: 56px; }
  .lv-topicon { width: 34px; height: 34px; border-radius: 11px; }
  .lv-stop { padding: 0 9px; font-size: 13px; }
  .lv-stop .lv-stopsquare { margin-right: 6px; }
  .lv-live { font-size: 12px; }
  .lv-live .lv-dot { margin-right: 5px; }
  #rec-active.rec-live .conn-banner { margin: 8px 12px 0; }
  #rec-active.rec-live #transcript-stream.lv-content {
    padding: 12px 12px calc(var(--lv-dock-height, 132px) + 26px);
  }
  #rec-dock.lv-dock {
    padding: 12px calc(11px + var(--safe-right, 0px)) 16px calc(11px + var(--safe-left, 0px));
  }
  .lv-control { padding: 0 9px; font-size: 12px; }
  .lv-control .lv-btn-text { margin-left: 6px; }
  .lv-control.lv-square { width: 42px; }
  .lv-controlrow > * + * { margin-left: 6px; }
  .lv-pipcol { width: 42px; }
  .lv-pipcol .lv-control.lv-square { width: 42px; }
  .lv-handle { margin-bottom: 11px; }
  .lv-row2 { margin-top: 10px; padding-right: 98px; }
  .lv-jumpnow { right: 14px; }
}

/* 极窄屏（<=340px）：优先保住「结束录制」与实时状态 */
@media (max-width: 340px) {
  .lv-folder .lv-folder-name { display: none; }
  .lv-folder .lv-caret { display: none; }
  .lv-stop { padding: 0 8px; }
}
