/* Mr.Smith — Xiaohongshu / WPS-embed style digital human */
:root {
  --bg: #0a1020;
  --glass: rgba(18, 28, 48, 0.55);
  --glass-strong: rgba(16, 24, 42, 0.78);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent2: #818cf8;
  --purple: #7c3aed;
  --purple2: #a78bfa;
  --teacher: #67e8f9;
  --student: #c4b5fd;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 20px;
  --bubble-font: 0.95rem;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  /* Chat stack: dock + optional composer + chip strip (keep bubbles clear) */
  --dock-h: 68px;
  --dock-bottom: 18px;
  --composer-h: 56px;
  --chips-h: 48px;
  --chips-gap: 10px;
  --chat-bottom-reserve: calc(var(--dock-bottom) + var(--dock-h) + var(--chips-gap) + var(--chips-h) + 12px);
  --chips-bottom: calc(var(--dock-bottom) + var(--dock-h) + var(--chips-gap));
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

.app[data-font="sm"] { --bubble-font: 0.82rem; }
.app[data-font="md"] { --bubble-font: 0.95rem; }
.app[data-font="lg"] { --bubble-font: 1.12rem; }
.app[data-font="xl"] { --bubble-font: 1.32rem; }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  position: relative;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

/* ---- Classroom / PPT backdrop ---- */
.classroom-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 90%, rgba(124, 58, 237, 0.16), transparent 55%),
    linear-gradient(180deg, #101a30 0%, #0a1020 55%, #070c16 100%);
}
.classroom-bg .board {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 6%;
  height: 42%;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(30, 58, 48, 0.55), rgba(15, 35, 28, 0.4));
  border: 1px solid rgba(148, 163, 184, 0.12);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.25);
  opacity: 0.55;
}
.classroom-bg .board::after {
  content: "English Class · Mr.Smith";
  position: absolute;
  left: 24px;
  top: 18px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: rgba(167, 243, 208, 0.35);
  font-weight: 600;
}
.classroom-bg .board-glow {
  position: absolute;
  left: 20%;
  right: 20%;
  top: 38%;
  height: 80px;
  background: radial-gradient(ellipse, rgba(99, 102, 241, 0.25), transparent 70%);
  filter: blur(20px);
}
.classroom-bg .desk-line {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 28%;
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.65));
}

/* ---- Full-bleed avatar ---- */
video.avatar-full {
  background: #0b1020;
}

/* Dual-video lip-sync: toggle visibility instead of swapping src */
.avatar-full.is-hidden {
  /* 只用透明度藏，不要 visibility:hidden，否则很多手机浏览器会暂停视频解码，说话时就“没动画” */
  opacity: 0 !important;
  pointer-events: none;
  z-index: 0;
}
.avatar-full.avatar-idle,
.avatar-full.avatar-talk {
  z-index: 1;
}
.avatar-full.avatar-talk:not(.is-hidden) {
  z-index: 2;
}

/* Motion comes from the idle video; skip CSS bob on desktop & mobile */
.avatar-stage .avatar-full {
  animation: none !important;
}
.app[data-screen="chat"] .avatar-full,
.app[data-screen="chat"] .avatar-stage.talking .avatar-full,
.avatar-stage.talking .avatar-full {
  animation: none !important;
}
@media (max-width: 720px) {
  .app[data-screen="chat"] .avatar-full,
  .avatar-stage.talking .avatar-full {
    animation: none !important;
  }
}

.avatar-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.avatar-full {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center center;
  user-select: none;
  -webkit-user-drag: none;
  filter: none;
  animation: none;
  transition: filter 0.3s ease, transform 0.3s ease;
}
.avatar-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(8, 12, 24, 0.15) 0%,
    transparent 35%,
    transparent 55%,
    rgba(8, 12, 24, 0.55) 100%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
}
.app[data-screen="chat"] .avatar-veil { opacity: 1; }
.app[data-screen="chat"] .avatar-full {
  transform: none;
  height: 100%;
}
@media (max-width: 720px) {
  .app[data-screen="chat"] .avatar-full {
    transform: none;
    height: 100%;
    opacity: 1;
  }
}

.speak-glow {
  pointer-events: none;
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 55%;
  height: 40%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(99, 102, 241, 0.35), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s;
  filter: blur(18px);
}
.avatar-stage.talking .speak-glow { opacity: 1; animation: glow-pulse 0.7s ease-in-out infinite; }
.avatar-stage.talking .avatar-full,
.app[data-screen="chat"] .avatar-stage.talking .avatar-full {
  animation: none !important;
  filter: brightness(1.05);
}

@keyframes idle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.app[data-screen="chat"] .avatar-full {
  animation: none;
}
@keyframes idle-bob-chat {
  0%, 100% { transform: translateX(-8%) translateY(0); }
  50% { transform: translateX(-8%) translateY(-5px); }
}
@media (max-width: 720px) {
  .app[data-screen="chat"] .avatar-full {
    animation: idle-bob 4s ease-in-out infinite;
  }
  .avatar-stage.talking .avatar-full {
    animation: talk-bob 0.4s ease-in-out infinite;
  }
}
@keyframes talk-bob {
  0%, 100% { transform: translateX(-8%) translateY(0) scale(1); }
  50% { transform: translateX(-8%) translateY(-3px) scale(1.012); }
}
@media (max-width: 720px) {
  @keyframes talk-bob {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-3px) scale(1.012); }
  }
}
@keyframes glow-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ---- Glass utility ---- */
.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: var(--shadow);
}

.glass-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.glass-icon:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(129, 140, 248, 0.5);
}
.glass-icon:active { transform: scale(0.95); }

/* ---- Top chrome ---- */
.chrome-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  pointer-events: none;
}
.chrome-top > * { pointer-events: auto; }

.brand-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  flex-shrink: 0;
  transition: background 0.25s, box-shadow 0.25s;
}
.status-dot.listening { background: var(--danger); box-shadow: 0 0 12px var(--danger); animation: pulse 1s infinite; }
.status-dot.speaking { background: var(--accent2); box-shadow: 0 0 12px var(--accent2); animation: pulse 0.8s infinite; }
.status-dot.thinking { background: var(--warn); box-shadow: 0 0 12px var(--warn); animation: pulse 1.2s infinite; }
.status-dot.error { background: var(--danger); box-shadow: none; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.65; }
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 0.92rem; }
.brand-copy span { font-size: 0.68rem; color: var(--muted); }
.chrome-actions { display: flex; gap: 8px; }

/* ---- Screens ---- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.screen > * { pointer-events: auto; }
.screen[hidden] { display: none !important; }

/* HOME */
.screen-home {
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px 36px;
  gap: 18px;
}
.home-nameplate {
  text-align: center;
  margin-bottom: 4px;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}
.home-nameplate h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.home-nameplate p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.home-actions {
  justify-content: center;

  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  width: 100%;
  max-width: 480px;
}
.cta {
  flex: 1 1 180px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.cta:hover { transform: translateY(-2px); filter: brightness(1.08); }
.cta:active { transform: scale(0.98); }
.cta-ico { display: grid; place-items: center; }
.cta-call {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 55%, #5b21b6 100%);
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.45);
}
.cta-chat {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.cta-answer {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #059669);
  margin-top: 8px;
}
.home-hint {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.8);
  text-align: center;
}

/* RING */
.screen-ring {
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.45);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}
.ring-card {
  width: min(340px, 90vw);
  border-radius: 28px;
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.ring-avatar {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(167, 139, 250, 0.55);
}
.ring-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}
.ring-pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(167, 139, 250, 0.6);
  animation: ring 1.4s infinite;
}
@keyframes ring {
  0% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}
.ring-meta strong { display: block; font-size: 1.2rem; }
.ring-meta span { color: var(--muted); font-size: 0.88rem; }
.ring-waves {
  display: flex;
  gap: 6px;
  height: 28px;
  align-items: flex-end;
}
.ring-waves i {
  display: block;
  width: 5px;
  border-radius: 3px;
  background: var(--purple2);
  animation: wave 0.9s ease-in-out infinite;
}
.ring-waves i:nth-child(1) { height: 10px; animation-delay: 0s; }
.ring-waves i:nth-child(2) { height: 20px; animation-delay: 0.15s; }
.ring-waves i:nth-child(3) { height: 14px; animation-delay: 0.3s; }
@keyframes wave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.6; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* CHAT */
.screen-chat {
  pointer-events: none;
}
.screen-chat > * { pointer-events: auto; }

.chat-float {
  position: absolute;
  top: 68px;
  right: 16px;
  bottom: var(--chat-bottom-reserve);
  width: min(420px, 48vw);
  max-width: calc(100% - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Extra bottom padding so last bubble clears chips when scrolled to end */
  padding: 4px 4px 20px;
  scroll-behavior: smooth;
  /* Fade only the top; keep bottom crisp so bubbles aren't clipped under chips */
  mask-image: linear-gradient(180deg, transparent 0%, #000 10%, #000 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 10%, #000 100%);
}
.screen-chat[data-input-mode="text"] {
  --chat-bottom-reserve: calc(var(--dock-bottom) + var(--dock-h) + var(--chips-gap) + var(--composer-h) + var(--chips-gap) + var(--chips-h) + 12px);
  --chips-bottom: calc(var(--dock-bottom) + var(--dock-h) + var(--chips-gap) + var(--composer-h) + var(--chips-gap));
}
@media (max-width: 720px) {
  .chat-float {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: var(--chat-bottom-reserve);
    top: 62px;
  }
}

.bubble {
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: var(--bubble-font);
  line-height: 1.5;
  animation: fadeIn 0.28s ease;
  word-break: break-word;
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.bubble.teacher {
  align-self: flex-start;
  background: rgba(15, 40, 70, 0.62);
  border-color: rgba(103, 232, 249, 0.22);
  border-bottom-left-radius: 6px;
}
.bubble.student {
  align-self: flex-end;
  background: rgba(55, 30, 90, 0.62);
  border-color: rgba(196, 181, 253, 0.28);
  border-bottom-right-radius: 6px;
}
.bubble .who {
  display: block;
  font-size: 0.68em;
  font-weight: 650;
  margin-bottom: 4px;
  opacity: 0.8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.bubble.teacher .who { color: var(--teacher); }
.bubble.student .who { color: var(--student); }
.bubble.system {
  align-self: center;
  background: rgba(15, 23, 42, 0.5);
  color: var(--muted);
  font-size: 0.78rem;
  padding: 8px 14px;
  border-style: dashed;
}

/* Evaluation card */
.eval-card {
  align-self: stretch;
  background: linear-gradient(145deg, rgba(30, 27, 60, 0.78), rgba(15, 35, 55, 0.72));
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 20px;
  padding: 16px 18px 14px;
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  animation: fadeIn 0.3s ease;
}
.eval-card h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fde68a;
}
.eval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}
.eval-row:last-of-type { border-bottom: none; }
.eval-row .label { color: var(--muted); min-width: 4.5em; }
.eval-row .stars { letter-spacing: 1px; color: #fbbf24; font-size: 1rem; }
.eval-row .score { font-weight: 700; color: #fef3c7; min-width: 2.5em; text-align: right; }
.eval-feedback {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.88rem;
  line-height: 1.45;
  color: #e2e8f0;
}

/* Chips — dedicated fixed-height strip above dock/composer; horizontal scroll when crowded */
.chips-float {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: var(--chips-bottom);
  height: var(--chips-h);
  max-height: var(--chips-h);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 4px 2px;
  z-index: 15;
  pointer-events: auto;
  box-sizing: border-box;
}
.chips-float::-webkit-scrollbar { height: 3px; }
.chips-float::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
}
@media (max-width: 720px) {
  .chips-float {
    left: 12px;
    right: 12px;
    bottom: var(--chips-bottom);
  }
}
.chip {
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
  flex: 0 0 auto;
}
.chip:hover { border-color: var(--accent2); background: rgba(99, 102, 241, 0.25); }
.chip:active { transform: scale(0.97); }
.chip-eval {
  border-color: rgba(251, 191, 36, 0.45);
  color: #fcd34d;
}

/* Bottom dock */
.dock {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  width: min(720px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
}
.dock-mic {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(129, 140, 248, 0.45);
  background: linear-gradient(145deg, #4f46e5, #6366f1);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.45);
  transition: transform 0.15s, background 0.15s;
}
.dock-mic:hover { transform: scale(1.06); }
.dock-mic.active {
  background: linear-gradient(145deg, #b91c1c, #ef4444);
  border-color: rgba(248, 113, 113, 0.55);
  animation: mic-pulse 1.2s infinite;
}
.dock-mic .mic-ring {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}
.dock-mic.active .mic-ring {
  border-color: rgba(248, 113, 113, 0.55);
  animation: ring 1.2s infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.dock-modes {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.dock-modes::-webkit-scrollbar { display: none; }
.mode-btn {
  flex: 1 0 auto;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.62rem;
  line-height: 1.1;
  transition: color 0.15s, background 0.15s;
}
.mode-btn .mode-ico { font-size: 0.95rem; }
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  color: #fff;
  background: rgba(99, 102, 241, 0.35);
}
@media (max-width: 520px) {
  .mode-btn span:not(.mode-ico) { display: none; }
  .mode-btn { padding: 8px; }
}

.dock-center {
  flex-shrink: 0;
  min-width: 130px;
  height: 42px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
  white-space: nowrap;
  transition: filter 0.15s, transform 0.1s;
}
.dock-center:hover { filter: brightness(1.08); }
.dock-center:active { transform: scale(0.97); }
.dock-center.listening {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}
@media (max-width: 520px) {
  .dock-center { min-width: 0; padding: 0 12px; font-size: 0.72rem; }
}

.dock-home {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.4);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1rem;
}
.dock-home:hover { color: var(--text); border-color: var(--accent2); }

/* Text composer */
.text-composer {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-bottom) + var(--dock-h) + 8px);
  transform: translateX(-50%);
  z-index: 19;
  width: min(560px, calc(100% - 24px));
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 18px;
  align-items: center;
  box-sizing: border-box;
  min-height: var(--composer-h);
}
.text-composer[hidden] { display: none !important; }
.text-composer input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  font-size: 0.95rem;
  outline: none;
}
.text-composer input::placeholder { color: #64748b; }
.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn:hover { background: #4f46e5; }

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 40;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  font-size: 0.85rem;
  color: var(--text);
  max-width: min(420px, 90vw);
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeIn 0.25s ease;
}
.toast[hidden] { display: none !important; }

/* Settings modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
  backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none !important; }

.modal {
  width: min(560px, 100%);
  max-height: min(88dvh, 780px);
  border-radius: 22px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--glass-strong);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 2px;
  min-height: 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--muted);
}
.field span, .field legend {
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.82rem;
}
.field em {
  font-style: normal;
  color: var(--accent2);
  font-weight: 700;
  margin-left: 6px;
}
.field-hint { color: #64748b; font-size: 0.72rem; }
.field input[type="url"],
.field input[type="password"],
.field input[type="text"],
.field select,
.field textarea {
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(8, 12, 24, 0.65);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}
.field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.45;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent2);
}
.font-size-field {
  border: none;
  margin: 0;
  padding: 0;
}
.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.seg-btn {
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(8, 12, 24, 0.5);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}
.seg-btn.active {
  background: rgba(99, 102, 241, 0.4);
  color: #fff;
  border-color: rgba(129, 140, 248, 0.55);
}
.api-block {
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
}
.api-block summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 8px;
}
.api-block .hint {
  margin: 0 0 10px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}
.api-block .field { margin-bottom: 8px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn.primary {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  border-color: transparent;
}
.btn.ghost { background: transparent; color: var(--muted); }
.cfg-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ok);
  min-height: 1.2em;
}

@media (prefers-reduced-motion: reduce) {
  .avatar-full, .speak-glow, .status-dot, .dock-mic, .bubble, .ring-pulse, .ring-waves i {
    animation: none !important;
  }
}

.home-actions .cta-chat { min-width: 220px; }


/* 手机开启声音 */
.audio-gate {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(12, 24, 48, 0.92);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}
.audio-gate[hidden] { display: none !important; }
.audio-gate-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 600;
  color: #0b1b33;
  background: #7dd3fc;
  cursor: pointer;
}
.audio-gate-tip {
  margin: 0;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}

/* Ring action buttons */
.ring-actions {
  display: flex;
  gap: 36px;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
}
.ring-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.55rem;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, filter 0.15s;
}
.ring-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.ring-btn:active { transform: scale(0.96); }
.ring-btn.answer {
  background: linear-gradient(135deg, #34d399, #059669);
}
.ring-btn.decline {
  background: linear-gradient(135deg, #f87171, #dc2626);
}
.ring-tip {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.screen-ring {
  display: flex;
  z-index: 6;
}
.screen-ring[hidden] { display: none !important; }

/* Keep chat over the board (right side) on landscape */
@media (min-width: 900px) {
  .chat-float {
    left: auto;
    right: 4.5%;
    width: min(420px, 42vw);
    top: 72px;
    bottom: var(--chat-bottom-reserve);
  }
  .chips-float {
    left: auto;
    right: 4.5%;
    width: min(460px, 46vw);
    bottom: var(--chips-bottom);
  }
}

.cta-call .cta-txt,
.cta-chat .cta-txt { white-space: nowrap; }

.home-actions {
  max-width: 560px;
}

/* Character / template library in settings */
.char-library {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.char-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.char-tab {
  border: 1px solid var(--glass-border);
  background: rgba(8, 12, 24, 0.55);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  line-height: 1.2;
}
.char-tab.active {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.28);
}
.char-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 420px) {
  .char-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.char-card {
  position: relative;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(8, 12, 24, 0.65);
  cursor: pointer;
  padding: 0;
  text-align: left;
  color: inherit;
  aspect-ratio: 16 / 10;
}
.char-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.05);
}
.char-card .char-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 8px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(transparent, rgba(2, 6, 23, 0.88));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-card .char-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.35);
}
.char-card.selected {
  border-color: rgba(167, 139, 250, 0.85);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.45);
}
.char-card.selected::after {
  content: "✓";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #7c3aed;
  color: #fff;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.modal-actions {
  flex-wrap: wrap;
}
#cfgGreeting { min-height: 72px; }
#cfgChips { min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
