/* 可力艺术 · 韦老师 AI 一对一咨询 —— 招生转化线配色（暖米白 / 亮橙 / 香槟金） */
:root {
  --bg: #F5F1EA;
  --bg-deep: #EDE4D5;
  --card: #FCF9F4;
  --card-soft: #F7F0E4;
  --ink: #332A1F;
  --ink-soft: #776C5C;
  --ink-faint: #9B8F7C;
  --orange: #FFA500;
  --orange-bright: #FFB733;
  --orange-deep: #E88D00;
  --orange-ink: #3A2A10;
  --gold: #C9A86A;
  --gold-deep: #A8844A;
  --line: #E9DEC9;
  --danger: #B85C38;
  --shadow: 0 18px 50px rgba(92, 72, 40, .14);
  --shadow-soft: 0 8px 24px rgba(92, 72, 40, .10);
  --radius: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(720px 420px at 50% -8%, #FFF9EC 0%, transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; border: 0; }
input, textarea { font: inherit; color: var(--ink); }

.app-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── 顶栏 ─────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 4px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-faint);
  font-weight: 700;
}

.eyebrow.gold { color: var(--gold-deep); letter-spacing: .18em; }

.topbar h1 {
  margin: 3px 0 0;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: .01em;
}

.link-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
}

.link-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 168, 106, .22);
}

.link-state.is-live i { background: var(--orange); box-shadow: 0 0 0 3px rgba(255, 165, 0, .22); }
.link-state.is-offline { color: var(--danger); border-color: rgba(184, 92, 56, .35); }
.link-state.is-offline i { background: var(--danger); box-shadow: 0 0 0 3px rgba(184, 92, 56, .18); }

/* ── 对话区 ───────────────────────────── */
.conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 16px;
}

.progress-track {
  height: 8px;
  border-radius: 99px;
  background: rgba(201, 168, 106, .24);
  overflow: hidden;
}

.progress-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--orange), var(--orange-bright) 45%, var(--gold));
  box-shadow: 0 0 10px rgba(255, 165, 0, .45);
  transition: width .55s cubic-bezier(.25, .8, .3, 1);
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 2px 2px;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .06em;
}

.progress-meta .progress-text {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}

/* ── 头像舞台 ─────────────────────────── */
.portrait-stage {
  position: relative;
  width: 196px;
  height: 196px;
  margin: 8px auto 0;
  display: grid;
  place-items: center;
}

.orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px dashed rgba(201, 168, 106, .55);
  animation: spin 34s linear infinite;
}

.orbit-b {
  inset: 11px;
  border-style: dotted;
  border-color: rgba(255, 165, 0, .35);
  animation-direction: reverse;
  animation-duration: 26s;
}

@keyframes spin { to { transform: rotate(360deg); } }

.portrait-ring {
  position: relative;
  width: 156px;
  height: 156px;
  border-radius: 50%;
  padding: 5px;
  background: linear-gradient(145deg, var(--gold), var(--orange-bright) 55%, var(--gold));
  box-shadow: var(--shadow-soft);
}

.portrait-ring::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.portrait-stage.is-speaking .portrait-ring::after {
  border-color: var(--orange);
  animation: breathe 1.5s ease-in-out infinite;
}

.portrait-stage.is-thinking .portrait-ring::after {
  border-color: var(--gold);
  animation: breathe 1.7s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: .95; box-shadow: 0 0 0 0 rgba(255, 165, 0, .30); }
  50% { transform: scale(1.035); opacity: .75; box-shadow: 0 0 0 12px rgba(255, 165, 0, 0); }
}

.portrait-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--card-soft);
}

.live-badge {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--orange-ink);
  background: linear-gradient(120deg, var(--orange-bright), var(--orange));
  box-shadow: 0 6px 16px rgba(255, 165, 0, .32);
}

/* ── 语音波形 ─────────────────────────── */
.voice-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 42px;
  margin-top: 4px;
}

.voice-wave i {
  width: 4px;
  height: 15px;
  border-radius: 4px;
  background: rgba(201, 168, 106, .55);
  transform: scaleY(.4);
  transform-origin: center;
  transition: background .3s;
}

.voice-wave.is-active i { background: linear-gradient(180deg, var(--orange-bright), var(--orange-deep)); animation: wave-bar .8s ease-in-out infinite; }
.voice-wave.is-recording i { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); animation: wave-bar .55s ease-in-out infinite; }
.voice-wave.is-thinking i { background: var(--gold); animation: wave-think 1.15s ease-in-out infinite; }

.voice-wave i:nth-child(2n) { animation-delay: .08s; }
.voice-wave i:nth-child(3n) { animation-delay: .16s; }
.voice-wave i:nth-child(5n) { animation-delay: .24s; }

@keyframes wave-bar {
  0%, 100% { transform: scaleY(.28); }
  50% { transform: scaleY(1); }
}

@keyframes wave-think {
  0%, 100% { transform: scaleY(.22); opacity: .55; }
  50% { transform: scaleY(.72); opacity: 1; }
}

/* ── 字幕卡片 ─────────────────────────── */
.subtitle-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 13px;
  box-shadow: var(--shadow-soft);
  min-height: 108px;
  display: flex;
  flex-direction: column;
}

.speaker {
  margin: 0 0 7px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-deep);
  letter-spacing: .08em;
}

.speaker i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(168, 132, 74, .16);
}

.subtitle {
  margin: 0;
  font-size: 16px;
  line-height: 1.65;
  flex: 1;
  overflow-wrap: break-word;
}

.subtitle.is-live-answer { color: var(--ink-soft); }

.replay {
  align-self: flex-start;
  margin-top: 9px;
  padding: 0 0 1px;
  background: none;
  color: var(--gold-deep);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.replay:disabled { opacity: .45; cursor: default; }

/* ── 回答面板 ─────────────────────────── */
.answer-panel {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: rise .35s ease both;
}

.turn-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.turn-status strong { font-size: 15px; }
.turn-status p { margin: 0; font-size: 12px; color: var(--ink-soft); }

.thinking-pulse { display: inline-flex; gap: 4px; padding: 0 2px; }

.thinking-pulse i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  animation: blink 1s ease-in-out infinite;
}

.thinking-pulse i:nth-child(2) { animation-delay: .18s; }
.thinking-pulse i:nth-child(3) { animation-delay: .36s; }

@keyframes blink { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

.mic-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: none;
  color: var(--ink);
}

.mic-icon {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--orange-ink);
  background: linear-gradient(145deg, var(--orange-bright), var(--orange) 55%, var(--orange-deep));
  box-shadow: 0 10px 24px rgba(255, 165, 0, .36), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .18s ease, box-shadow .25s ease;
}

.mic-icon svg { width: 30px; height: 30px; }

.mic-button:active .mic-icon { transform: scale(.95); }
.mic-button:disabled { opacity: .5; cursor: default; }
.mic-button.is-recording .mic-icon {
  background: linear-gradient(145deg, var(--gold), var(--gold-deep));
  box-shadow: 0 0 0 0 rgba(201, 168, 106, .35);
  animation: record-ping 1.4s ease-out infinite;
}

@keyframes record-ping {
  0% { box-shadow: 0 0 0 0 rgba(201, 168, 106, .4); }
  70%, 100% { box-shadow: 0 0 0 22px rgba(201, 168, 106, 0); }
}

#holdLabel {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.text-toggle {
  margin-top: 8px;
  background: none;
  color: var(--ink-faint);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-toggle:disabled { opacity: .4; cursor: default; }

.text-fallback {
  width: 100%;
  display: flex;
  gap: 8px;
  margin-top: 10px;
  text-align: left;
}

.text-fallback textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 11px 13px;
  line-height: 1.5;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.text-fallback textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 165, 0, .16);
}

.privacy-note {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
}

/* ── 按钮 ─────────────────────────────── */
.primary-button {
  flex: none;
  width: 100%;
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--orange-ink);
  background: linear-gradient(120deg, var(--orange-bright), var(--orange) 55%, var(--orange-deep));
  box-shadow: 0 10px 22px rgba(255, 165, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .38);
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s;
}

.primary-button:active { transform: scale(.98); }
.primary-button:disabled { opacity: .55; cursor: default; transform: none; }
.primary-button.glow { animation: glow-pulse 2.4s ease-in-out infinite; }

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 10px 22px rgba(255, 165, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .38); }
  50% { box-shadow: 0 10px 30px rgba(255, 165, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .38); }
}

#sendButton { margin: 0; padding: 0 20px; width: auto; }

/* ── 弹窗 ─────────────────────────────── */
dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(92vw, 460px);
  max-height: 90dvh;
  overflow: auto;
  overscroll-behavior: contain;
}

dialog.modal::backdrop {
  background: rgba(50, 41, 31, .46);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

dialog.modal[open] { animation: pop .3s cubic-bezier(.2, .9, .3, 1.15) both; }

@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 26px 24px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  margin: auto;
}

.modal-card h2 {
  margin: 8px 0 10px;
  font-size: 23px;
  line-height: 1.4;
}

.modal-card h2 em {
  font-style: normal;
  color: var(--orange-deep);
}

.modal-copy {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.field-label {
  display: block;
  margin: 8px 0 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.modal-card input[type="text"],
.modal-card input[type="tel"] {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #FFFDF8;
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.modal-card input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 165, 0, .16);
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  cursor: pointer;
}

.consent input { margin-top: 2px; accent-color: var(--orange-deep); }

.hint {
  display: block;
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-faint);
}

.seal {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  border-radius: 50%;
  font-size: 27px;
  color: var(--card);
  background: linear-gradient(145deg, var(--gold), var(--orange));
  box-shadow: 0 8px 20px rgba(201, 168, 106, .4);
}

.next-steps {
  list-style: none;
  margin: 4px 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.next-steps li {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 13px;
  text-align: left;
}

.next-steps i {
  flex: none;
  font-style: normal;
  font-weight: 700;
  font-size: 11px;
  color: var(--gold-deep);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 3px 7px;
  margin-top: 1px;
}

.next-steps strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.next-steps small {
  display: block;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #FFFDF8;
  border: 1px dashed var(--gold);
  border-radius: 18px;
  padding: 14px;
}

.qr-box canvas {
  width: 152px;
  height: 152px;
  border-radius: 10px;
  background: #FFF;
  box-shadow: var(--shadow-soft);
}

.qr-caption {
  margin: 0;
  font-size: 11px;
  color: var(--ink-faint);
}

.qualified-card .privacy-note { margin-top: 12px; }

/* ── Toast ────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: min(88vw, 420px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(51, 42, 31, .92);
  color: var(--card);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 60;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ── 小屏适配 ─────────────────────────── */
@media (max-width: 380px) {
  .portrait-stage { width: 178px; height: 178px; }
  .portrait-ring { width: 140px; height: 140px; }
  .subtitle-card { min-height: 102px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
