/* 通话页 H5 —— 苹果风设计令牌（1rpx = 0.5px） */
:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --text: #1C1C1E;
  --text-2: #6E6E73;
  --text-3: #AEAEB2;
  --separator: rgba(60, 60, 67, 0.09);
  --blue: #0A84FF;
  --green: #30D158;
  --red: #FF3B30;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "SF Pro Text", "Helvetica Neue", Helvetica, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.call-page {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

/* ---------- 顶部：身份 / 计时 / 状态 ---------- */
.call-top {
  flex: none;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 20px 8px;
  background: #F2F5FA;
  position: relative;
  z-index: 3;
}

.call-top__line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.call-top__name,
.call-top__timer {
  font-size: 13.5px;
  color: var(--text-2);
}

.call-top__timer {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.call-state {
  display: flex;
  align-items: center;
  margin-top: 5px;
}

.call-state__dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--text-3);
  margin-right: 6px;
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.call-state__text {
  font-size: 13px;
  color: var(--text-2);
}

body.state-listening .call-state__dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.16);
}

body.state-speaking .call-state__dot {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.14);
}

/* ---------- 人像舞台：占剩余高度 ---------- */
.stage {
  flex: none;
  height: 60vh;
  height: 60dvh;
  min-height: 0;
  transition: height 0.45s cubic-bezier(.2,.8,.2,1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #F2F5FA 0%, #E4EAF3 52%, #D9E1EC 100%);
}

#avatar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 118%;
  object-fit: cover;
  object-position: center top;
  transform-origin: 50% 38%;
  z-index: 1;
  animation: photo-life 7.5s ease-in-out infinite;
  will-change: transform;
}

/* 缓慢呼吸 + 间歇点头 */
@keyframes photo-life {
  0%   { transform: scale(1)     translateY(0)    rotate(0deg); }
  25%  { transform: scale(1.014) translateY(-2px) rotate(0deg); }
  50%  { transform: scale(1.026) translateY(-4px) rotate(0deg); }
  62%  { transform: scale(1.02)  translateY(-2.5px) rotate(0deg); }
  70%  { transform: scale(1.016) translateY(1px) rotate(0.7deg); }
  78%  { transform: scale(1.01)  translateY(0)   rotate(-0.5deg); }
  88%  { transform: scale(1.004) translateY(0)   rotate(0.2deg); }
  100% { transform: scale(1)     translateY(0)    rotate(0deg); }
}

body.state-listening #avatar { animation-duration: 6s; }
body.state-speaking #avatar { animation-duration: 4.2s; }

/* 底部渐隐，让人像自然过渡到字幕区 */
.stage::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 85px;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(245, 246, 248, 0) 0%, rgba(245, 246, 248, 0.55) 58%, #F5F6F8 100%);
}

/* 四周柔光：聆听绿、说话蓝，平滑过渡 */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  box-shadow: inset 0 0 35px 3px rgba(52, 199, 89, 0);
  transition: box-shadow 0.6s ease;
}

body.state-listening .stage::after {
  box-shadow: inset 0 0 35px 3px rgba(52, 199, 89, 0.40);
}

body.state-speaking .stage::after {
  box-shadow: inset 0 0 35px 3px rgba(10, 132, 255, 0.32);
}

.stage__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.stage__name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.stage__hint {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 4px;
}

/* ---------- 字幕区：固定高度 + 独立滚动 ---------- */
#captions {
  flex: 1;
  min-height: 0;
  padding: 0 20px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
  z-index: 2;
  scrollbar-width: none;
}

#captions::-webkit-scrollbar { display: none; }

.caption-list { padding: 6px 0 12px; }

.caption-empty {
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

.caption {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 6px rgba(60, 80, 120, 0.04);
}

.caption--user {
  background: rgba(10, 132, 255, 0.08);
}

.caption__role {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.caption__en {
  font-size: 18.5px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}

.caption--user .caption__en { color: #1B4F86; }

/* 中文翻译：更小更灰 */
.caption__zh {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-2);
  margin-top: 5px;
}

.caret {
  color: var(--blue);
  animation: caption-caret 1s steps(2) infinite;
}

@keyframes caption-caret { 50% { opacity: 0; } }

.interrupted {
  font-size: 11px;
  color: var(--text-3);
}

/* ---------- 底部拇指区 ---------- */
.dock {
  flex: none;
  padding: 12px 20px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(245, 246, 248, 0.96);
  border-top: 0.5px solid var(--separator);
  position: relative;
  z-index: 4;
}

.dock__grid {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
}

.dock__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
}

.dock__btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: 18px;
  cursor: pointer;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.04);
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.dock__btn:active { transform: scale(0.94); }

.dock__btn.is-on {
  background: rgba(10, 132, 255, 0.14);
  color: var(--blue);
}


.dock__label {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 7px;
}

.dock__item--main .dock__label { margin-top: 1px; }

@media (prefers-reduced-motion: reduce) {
  #avatar, .caret { animation: none; }
}

/* ---------- 字幕：AI 左侧白卡，用户右侧蓝卡 ---------- */
.caption { max-width: 88%; }
.caption--ai { margin-right: auto; border-top-left-radius: 4px; }
.caption--user { margin-left: auto; border-top-right-radius: 4px; background: rgba(10, 132, 255, 0.10); }
.caption--user .caption__role { text-align: right; }
.caption-list, #captions { padding-top: 8px; }

/* ---------- 头像缩略态：字幕多了以后 ---------- */
body.is-compact .stage { height: 132px; }
body.is-compact .stage__hint { display: none; }
body.is-compact #avatar { height: 260%; object-position: center 8%; animation: none; }
body.is-compact .stage__caption { bottom: 6px; }
body.is-compact .stage__name { font-size: 15px; }

/* ---------- 主按钮：按通话状态变色 ---------- */
.dock__btn--call {
  width: 72px;
  height: 72px;
  margin-top: -8px;
  font-size: 30px;
  color: #FFFFFF;
  background: var(--green);
  box-shadow: 0 5px 13px rgba(48, 209, 88, 0.28);
}
body[data-call="connecting"] .dock__btn--call {
  background: #FF9F0A;
  box-shadow: 0 5px 13px rgba(255, 159, 10, 0.3);
  font-size: 26px;
  animation: ring 1.2s ease-in-out infinite;
}
body[data-call="incall"] .dock__btn--call {
  background: var(--red);
  transform: rotate(135deg);
  box-shadow: 0 5px 13px rgba(255, 59, 48, 0.25);
}
body[data-call="incall"] .dock__btn--call:active { transform: rotate(135deg) scale(0.94); }
@keyframes ring { 50% { box-shadow: 0 0 0 10px rgba(255, 159, 10, 0.12); } }

.dock__btn:disabled { opacity: 0.35; cursor: default; }
.dock__btn:disabled:active { transform: none; }

/* ---------- 结束态：头像变灰、提示原因 ---------- */
.call-reason { font-size: 12px; color: var(--text-3); margin-top: 3px; min-height: 0; }
.call-reason:empty { display: none; }
body[data-call="ended"] #avatar,
body[data-call="idle"] #avatar { animation: none; }
body[data-call="ended"] #avatar { filter: grayscale(1) brightness(0.92); opacity: 0.55; transition: filter 0.4s, opacity 0.4s; }
body[data-call="ended"] .call-state__dot { background: var(--red); }
body[data-call="ended"] .call-state__text { color: var(--text); font-weight: 600; }
body[data-call="connecting"] .call-state__dot { background: #FF9F0A; }

/* ---------- 访问口令 ---------- */
.gate { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(245, 246, 248, 0.9); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.gate__box { width: 280px; display: flex; flex-direction: column; gap: 12px; padding: 24px;
  background: #fff; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); }
.gate__title { font-size: 17px; font-weight: 600; text-align: center; }
.gate input { height: 46px; border: 1px solid var(--separator); border-radius: 12px; padding: 0 14px; font-size: 17px; background: var(--bg); }
.gate button { height: 46px; border: 0; border-radius: 12px; background: var(--blue); color: #fff; font-size: 17px; font-weight: 600; }
.gate button:disabled { opacity: 0.5; }
.gate__err { min-height: 18px; font-size: 13px; color: var(--red); text-align: center; }

/* ---------- 语速 ---------- */
.speed { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 12px; font-size: 13px; }
.speed__label { color: #8e8e93; margin-right: 2px; }
.speed button { border: 0; padding: 6px 11px; border-radius: 999px; background: rgba(120,120,128,0.12); color: #3c3c43; font-size: 13px; }
.speed button.is-on { background: var(--blue); color: #fff; font-weight: 600; }
.speed__note { font-size: 11px; color: #ff9500; }
.speed__note:empty { display: none; }
.speed { position: relative; }

/* ---------- hint 文案不溢出（追加块） ---------- */
.caption-empty { box-sizing: border-box; max-width: 100%; padding: 0 24px; text-align: center; white-space: normal; overflow-wrap: anywhere; }
