/* ============================================================
   LoomRoom · voice.css（v2 增量）
   语音输入 / 运行指标 / 字数与折叠 / 设置 / 上下文视图
   ============================================================ */

/* ══════════════ 语音状态条 ══════════════ */
/* 语音条必须独占一行：否则预览态的 3 个按钮会和下面的主操作行挤在一起，
   把插话输入框压成一条线（真踩过）。 */
.dock { flex-wrap: wrap; }
.send-btn { white-space: nowrap; }
.interject-form { min-width: min(320px, 100%); }

.voice-bar {
  flex-basis: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 4px 2px 2px;
  font-size: var(--fs-2); color: var(--muted);
  min-width: 0;
}
.path-badge {
  flex: none; padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  font-size: var(--fs-1);
}
.path-badge[data-path="server"] { color: var(--ok); border-color: rgba(69, 121, 90, .30); background: rgba(69, 121, 90, .10); }
.path-badge[data-path="browser"] { color: var(--text-2); border-color: rgba(85, 104, 140, .30); background: rgba(85, 104, 140, .10); }
.path-badge[data-path="none"] { color: var(--faint); }
.voice-wave {
  flex: none; width: 190px; height: 26px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 2px 4px;
}
.voice-state {
  flex: none; font-size: var(--fs-1); padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-2); background: var(--panel);
}
.voice-state[data-state="recording"] { color: var(--danger); border-color: rgba(217, 113, 107, .32); background: var(--danger-soft); }
.voice-state[data-state="recognizing"] { color: var(--lamp); border-color: var(--lamp-line); background: var(--lamp-soft); }
.voice-state[data-state="preview"] { color: var(--cool); border-color: var(--line); background: rgba(79, 122, 112, .10); }
.voice-state[data-state="error"] { color: var(--danger); border-color: rgba(217, 113, 107, .32); background: var(--danger-soft); }
.voice-interim {
  min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-2);
}
.voice-interim.final { color: var(--lamp); }
.voice-note { flex: none; color: var(--faint); font-size: var(--fs-1); max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════ 大号录音按钮 ══════════════ */
.voice-btn {
  position: relative;
  display: flex; align-items: center; gap: 9px; flex: none;
  padding: 12px 18px; border-radius: var(--r);
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
  color: var(--text); font-size: var(--fs-4); font-weight: 650;
  transition: background .15s, box-shadow .15s, transform .06s, border-color .15s;
}
.voice-btn:hover { background: linear-gradient(180deg, var(--panel-3), var(--panel-2)); border-color: var(--line); }
.voice-btn:active { transform: translateY(1px); }
.voice-btn .voice-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line); transition: background .15s;
}
.voice-btn .mic-icon { font-size: var(--fs-6); }
.voice-btn .voice-kbd { opacity: .5; }
.voice-btn[data-state="recording"] {
  color: var(--danger); border-color: #7d2f24;
  background: linear-gradient(180deg, rgba(178, 74, 66, .14), rgba(178, 74, 66, .12));
  animation: voiceBreath 1.5s ease-in-out infinite;
}
.voice-btn[data-state="recording"] .voice-dot { background: var(--danger); box-shadow: 0 0 10px 2px rgba(255,77,109,.6); }
.voice-btn[data-state="recognizing"] { color: var(--lamp); border-color: var(--lamp-line); background: linear-gradient(180deg, rgba(168,48,30, .10), rgba(168,48,30, .10)); }
.voice-btn[data-state="recognizing"] .voice-dot { background: var(--lamp); animation: voiceBlink .8s steps(2) infinite; }
.voice-btn[data-state="preview"] { color: var(--cool); border-color: var(--line); background: linear-gradient(180deg, rgba(79, 122, 112, .10), rgba(79, 122, 112, .10)); }
.voice-btn[data-state="preview"] .voice-dot { background: var(--cool); }
/* 免提待命：听得见，但别用"录音中"的呼吸红光 —— 那代表"正在录"，会让人不敢喘气 */
.voice-btn[data-state="listening"] {
  color: var(--cool); border-color: rgba(86, 200, 192, .45);
  background: linear-gradient(180deg, rgba(86, 200, 192, .10), rgba(86, 200, 192, .06));
}
.voice-btn[data-state="listening"] .voice-dot {
  background: var(--cool);
  box-shadow: 0 0 8px 1px rgba(86, 200, 192, .55);
  animation: voiceBlink 1.6s steps(2) infinite;
}
.voice-state[data-state="listening"] { color: var(--cool); border-color: rgba(86, 200, 192, .35); background: rgba(86, 200, 192, .10); }
.voice-btn[data-state="listening"] .voice-kbd { opacity: .35; }
@keyframes voiceBreath {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,77,109,.28); }
  50%      { box-shadow: 0 0 0 7px rgba(255,77,109,.10); }
}
@keyframes voiceBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .2; } }

/* ══════════════ 运行指标条 ══════════════ */
.metrics-bar {
  flex: none; width: 100%; text-align: center;
  font-size: var(--fs-1); color: var(--faint);
  font-variant-numeric: tabular-nums;
  padding: 2px 4px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.metrics-bar.live { color: var(--muted); }
.stream-stats { font-size: var(--fs-1); color: var(--faint); font-variant-numeric: tabular-nums; margin-left: 4px; }

/* ══════════════ 气泡：字数 / 折叠 / 引用 / 改口 / @点名 / 连发 ══════════════ */
.b-chars {
  font-size: var(--fs-1); padding: 0 6px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.b-chars.near { color: var(--lamp); border-color: rgba(200,68,42,.45); }
.b-chars.over { color: var(--danger); border-color: rgba(217, 113, 107, .32); background: var(--danger-soft); }

.b-fold {
  align-self: flex-start; margin-top: 5px;
  background: transparent; border: 0; padding: 0;
  color: var(--cool); font-size: var(--fs-2); text-decoration: underline dotted;
}
.b-fold:hover { color: #8fe3dc; }
.b-body.folded {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; position: relative;
}
.b-body.folded::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22px;
  background: linear-gradient(180deg, transparent, var(--bg));
  pointer-events: none;
}

.b-ref {
  align-self: flex-start; max-width: 100%;
  background: rgba(156, 184, 174,.06); border: 1px solid rgba(156, 184, 174,.22);
  color: #9fdcd7; border-radius: 999px; padding: 2px 10px;
  font-size: var(--fs-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.b-ref:hover { background: rgba(156, 184, 174,.13); }
.b-turn { font-size: var(--fs-1); color: var(--faint); }
.b-revised {
  font-size: var(--fs-1); padding: 0 7px; border-radius: 999px;
  color: var(--text-2); background: var(--panel-3); border: 1px solid var(--line);
}
.b-voice-tag {
  font-size: var(--fs-1); padding: 0 7px; border-radius: 999px;
  color: var(--cool); background: rgba(79, 122, 112, .10); border: 1px solid var(--line);
}
.b-ctx { font-size: var(--fs-1); color: var(--faint); }
mark.mention {
  background: rgba(200,68,42,.18); color: var(--lamp);
  border-radius: 4px; padding: 0 3px; font-weight: 600;
}
.bubble.cont { margin-top: -6px; }
.bubble.cont .b-avatar { visibility: hidden; }
.bubble.cont .b-body { border-top-left-radius: 10px; }
.bubble.flash { animation: bubbleFlash 1.6s ease-out; }
@keyframes bubbleFlash {
  0%   { box-shadow: 0 0 0 2px rgba(156, 184, 174,.5); border-radius: var(--r); }
  100% { box-shadow: 0 0 0 2px rgba(156, 184, 174,0); border-radius: var(--r); }
}
.seat.mentioned .seat-avatar { animation: mentionNudge .5s ease-in-out 2; }
@keyframes mentionNudge {
  0%, 100% { transform: none; }
  50% { transform: scale(1.12); box-shadow: 0 0 0 5px rgba(200,68,42,.18); }
}

/* ══════════════ 设置抽屉 ══════════════ */
.set-state { font-size: var(--fs-2); color: var(--faint); margin-bottom: 14px; font-family: var(--mono); }
.set-group {
  padding: 14px 0 16px; border-bottom: 1px solid var(--line-soft);
}
.set-title { font-size: var(--fs-3); color: var(--text); margin-bottom: 6px; }
.set-desc { font-size: var(--fs-2); color: var(--faint); line-height: 1.6; margin: 6px 0 10px; }
.set-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.set-k { flex: none; width: 6em; font-size: var(--fs-2); color: var(--text-2); }
.set-row .seg { flex-wrap: wrap; }
.switch-row {
  display: flex; align-items: center; gap: 9px;
  font-size: var(--fs-3); color: var(--text-2); margin-top: 10px; cursor: pointer;
}
.switch-row input { accent-color: var(--lamp); width: 16px; height: 16px; }
.hint-line { font-size: var(--fs-2); color: var(--muted); margin-top: 8px; min-height: 1.5em; }
#set-priority-hint { color: var(--lamp); }
#panel-settings .seg, #nm-verbosity { display: inline-flex; }
#nm-verbosity { padding: 3px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 999px; }
#set-verbosity { display: inline-flex; padding: 3px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 999px; }

/* ══════════════ 上下文视图 ══════════════ */
.ctx-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px; margin-bottom: 14px;
}
.ctx-cell { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 8px 10px; }
.ctx-k { font-size: var(--fs-1); color: var(--faint); }
.ctx-v { font-size: var(--fs-4); color: var(--text); font-variant-numeric: tabular-nums; }
.ctx-timeline { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.ctx-round-title {
  font-size: var(--fs-1); color: var(--lamp); letter-spacing: .02em;
  margin-bottom: 6px; padding-left: 2px;
}
.ctx-item {
  display: flex; gap: 9px; padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--line-soft);
  cursor: pointer; margin-bottom: 6px;
}
.ctx-item:hover { border-color: var(--line); background: var(--panel-2); }
.ctx-item.user { background: var(--user-soft); border-color: rgba(155, 168, 196,.28); }
.ctx-emoji { flex: none; font-size: var(--fs-4); }
.ctx-main { min-width: 0; flex: 1; }
.ctx-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ctx-name { font-size: var(--fs-2); color: var(--text); font-weight: 620; }
.ctx-chars { font-size: var(--fs-1); color: var(--faint); }
.ctx-tag { font-size: var(--fs-1); padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.ctx-tag.voice { color: var(--cool); border-color: var(--line); }
.ctx-tag.revised { color: var(--text-2); }
.ctx-tag.cut { color: var(--danger); border-color: rgba(217, 113, 107, .32); }
.ctx-quote { font-size: var(--fs-2); color: var(--text-2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-digest { font-size: var(--fs-1); color: var(--cool); margin-top: 4px; }
.ctx-mems { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ctx-mem {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 999px; font-size: var(--fs-2);
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--text-2);
}
.ctx-mem:hover { border-color: var(--lamp-line); color: var(--lamp); }
.ctx-mem-n { color: var(--faint); font-size: var(--fs-1); }

/* ══════════════ 纪要统计头 ══════════════ */
.minutes-stats {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  padding: 9px 12px; margin-bottom: 14px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  font-size: var(--fs-2); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.minutes-stats b { color: var(--text); font-weight: 620; }
.minutes-stats .warn { color: var(--danger); }

/* ══════════════ 窄屏 ══════════════ */
@media (max-width: 900px) {
  .voice-bar { flex-wrap: wrap; gap: 6px; }
  .voice-wave { width: 120px; }
  .voice-interim { flex-basis: 100%; order: 5; white-space: normal; }
  .voice-btn { flex: 1; justify-content: center; }
  .metrics-bar { font-size: var(--fs-1); }
  .set-row { flex-wrap: wrap; }
}

/* ══════════════ 语音 HUD（第 10 轮） ══════════════ */
/* 按一下 V 之后，状态不能只藏在底部那条细线里：用户看的是中间的画面，
   会不知道"现在在录吗、下一步按什么"。HUD 固定浮在操作坞上方，四个状态各一套文案。 */
.voice-hud {
  position: fixed;
  left: 50%;
  bottom: clamp(150px, 19vh, 200px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(600px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-3, var(--panel));
  box-shadow: 0 18px 48px rgba(0, 0, 0, .42), 0 0 0 1px rgba(255, 255, 255, .02) inset;
  color: var(--text);
}
.voice-hud[hidden] { display: none; }
.voice-hud .vh-dot {
  flex: none; width: 12px; height: 12px; margin-top: 5px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 4px rgba(255, 255, 255, .04);
}
.voice-hud[data-tone="recording"] { border-color: rgba(217, 113, 107, .55); }
.voice-hud[data-tone="recording"] .vh-dot { background: var(--danger); animation: vhPulse 1.4s ease-in-out infinite; }
.voice-hud[data-tone="arming"] .vh-dot { background: var(--lamp); animation: voiceBlink 1s steps(2) infinite; }
.voice-hud[data-tone="recognizing"] .vh-dot { background: var(--lamp); animation: voiceBlink .7s steps(2) infinite; }
.voice-hud[data-tone="preview"] { border-color: rgba(86, 200, 192, .45); }
.voice-hud[data-tone="preview"] .vh-dot { background: var(--cool); }
/* 发送回执：绿一点点、不抢眼，1.8s 自动收起 */
.voice-hud[data-tone="sent"] { border-color: rgba(86, 200, 192, .5); }
.voice-hud[data-tone="sent"] .vh-dot { background: var(--cool); box-shadow: 0 0 0 4px rgba(86, 200, 192, .12); }
/* 失败：红框 + 明确的两个出口（重录 / 收起） */
.voice-hud[data-tone="error"] { border-color: rgba(217, 113, 107, .6); }
.voice-hud[data-tone="error"] .vh-dot { background: var(--danger); }
/* 警告文案（没声音 / 快到 90s 上限）：换成琥珀色，别和普通提示混在一起 */
.voice-hud.is-warning .vh-hint { color: var(--lamp); }
.voice-hud[data-tone="recording"] .vh-dot { transform: scale(calc(1 + var(--lvl, 0) * 0.9)); transition: transform .08s linear; }
@keyframes vhPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 113, 107, .45); }
  50%      { box-shadow: 0 0 0 9px rgba(217, 113, 107, .10); }
}
.voice-hud .vh-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; }
.voice-hud .vh-title { font-size: var(--fs-4); font-weight: 700; letter-spacing: .2px; display: flex; align-items: baseline; gap: 6px; }
.voice-hud .vh-timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--danger); }
.voice-hud .vh-hint { font-size: var(--fs-2); color: var(--muted); }
.voice-hud .vh-text.live { color: var(--muted); font-style: normal; opacity: .85; }
.voice-hud .vh-text {
  margin-top: 4px; max-height: 76px; overflow: auto;
  font-size: var(--fs-3); color: var(--text-2); line-height: 1.5;
  padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, .03);
}
.voice-hud .vh-bars { display: none; align-items: flex-end; gap: 3px; height: 18px; margin-top: 2px; color: var(--danger); }
.voice-hud.has-meter .vh-bars { display: flex; }
.voice-hud .vh-bars i {
  display: block; width: 4px; height: 100%; border-radius: 2px; background: currentColor; opacity: .55;
  transform-origin: bottom; transform: scaleY(calc(var(--lvl, .2) * var(--k, 1)));
  transition: transform .08s linear;
}
.voice-hud .vh-bars i:nth-child(1) { --k: .45; }
.voice-hud .vh-bars i:nth-child(2) { --k: .7; }
.voice-hud .vh-bars i:nth-child(3) { --k: .95; }
.voice-hud .vh-bars i:nth-child(4) { --k: 1; }
.voice-hud .vh-bars i:nth-child(5) { --k: .9; }
.voice-hud .vh-bars i:nth-child(6) { --k: .65; }
.voice-hud .vh-bars i:nth-child(7) { --k: .4; }
.voice-hud .vh-actions { flex: none; display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .voice-hud { bottom: 176px; padding: 12px; gap: 10px; flex-wrap: wrap; }
  .voice-hud .vh-actions { width: 100%; justify-content: flex-end; }
  .voice-hud .vh-title { font-size: var(--fs-3); }
}
@media (prefers-reduced-motion: reduce) {
  .voice-hud .vh-dot { animation: none !important; }
}
