/* ============ Bamboo Weaver — immersive scene design ============ */
:root {
  /* paper & ink */
  --bg: #f1e9d8;
  --paper: #fbf6ea;
  --ink: #241e10;
  --muted: #7a6d55;
  --line: rgba(58, 46, 24, 0.16);
  --line-soft: rgba(255, 255, 255, 0.55);

  /* bamboo greens */
  --accent: #2f6b45;
  --accent-deep: #1d4a2e;
  --accent-soft: rgba(47, 107, 69, 0.12);

  /* warm metal */
  --gold: #b8902a;
  --gold-soft: rgba(184, 144, 42, 0.16);

  --danger: #b64c3f;
  --rec: #2f6b45;
  --halo: rgba(255, 252, 244, 0.55);   /* 录音态跟随主色，不再用刺眼的红 */

  /* scene glass */
  --glass: rgba(255, 252, 244, 0.74);
  --glass-strong: rgba(255, 252, 244, 0.9);
  --glass-line: rgba(255, 255, 255, 0.6);
  --hairline: rgba(58, 46, 24, 0.12);
  --shadow-soft: 0 26px 60px -30px rgba(45, 36, 18, 0.5);
  --shadow-lift: 0 40px 90px -40px rgba(35, 28, 12, 0.55);

  --bubble-visitor: rgba(255, 252, 244, 0.93);
  --bubble-student: linear-gradient(135deg, #3a7b52, #1f4d31);
  --bubble-student-ink: #f6f2e4;

  --radius: 20px;
  --radius-sm: 12px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", "STSong", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Helvetica Neue", sans-serif;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="dark"] {
  --bg: #0f150f;
  --paper: #1a231a;
  --ink: #efe7d2;
  --muted: #9dab8e;
  --line: rgba(233, 223, 195, 0.16);
  --line-soft: rgba(255, 255, 255, 0.08);
  --accent: #79c78c;
  --accent-deep: #4a9561;
  --accent-soft: rgba(121, 199, 140, 0.14);
  --gold: #ddbf58;
  --gold-soft: rgba(221, 191, 88, 0.16);
  --danger: #e07562;
  --rec: #8fc9a4;
  --halo: rgba(6, 12, 8, 0.55);
  --glass: rgba(22, 30, 22, 0.6);
  --glass-strong: rgba(20, 28, 20, 0.86);
  --glass-line: rgba(255, 255, 255, 0.1);
  --hairline: rgba(233, 223, 195, 0.12);
  --shadow-soft: 0 26px 60px -30px rgba(0, 0, 0, 0.8);
  --shadow-lift: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
  --bubble-visitor: rgba(28, 38, 28, 0.86);
  --bubble-student: linear-gradient(135deg, #35704a, #1d4429);
  --bubble-student-ink: #f2efdf;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  overflow: hidden;
  transition: color 0.5s var(--ease-out);
}

/* ============ the scene ============ */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url('../main_bg.jpg') center 30% / cover no-repeat;
  filter: saturate(0.94) contrast(1.02) brightness(1.02);
  transform: scale(1.03);
  animation: sceneBreath 26s ease-in-out infinite alternate;
}
/* 对话页换用 chat_bg 场景，遮罩也放松一些，别把场景压死 */
body[data-screen="screen-chat"]::before {
  background-image: url('../chat_bg.png');
  background-position: center 50%;
}
body[data-screen="screen-chat"]::after {
  background:
    radial-gradient(900px 520px at 50% 2%, rgba(255, 250, 236, 0.24), transparent 62%),
    radial-gradient(130% 100% at 50% 30%, transparent 44%, rgba(48, 36, 14, 0.24) 100%),
    linear-gradient(180deg, rgba(247, 241, 228, 0.14) 0%, rgba(247, 241, 228, 0.26) 54%, rgba(240, 232, 216, 0.7) 100%);
}
html[data-theme="dark"] body[data-screen="screen-chat"]::after {
  background:
    radial-gradient(900px 520px at 50% 2%, rgba(126, 150, 110, 0.12), transparent 62%),
    radial-gradient(130% 100% at 50% 30%, transparent 34%, rgba(4, 7, 4, 0.76) 100%),
    linear-gradient(180deg, rgba(10, 15, 10, 0.46) 0%, rgba(10, 15, 10, 0.66) 54%, rgba(10, 15, 10, 0.9) 100%);
}

@keyframes sceneBreath { from { transform: scale(1.03) translateY(0); } to { transform: scale(1.07) translateY(-10px); } }

body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 520px at 50% 4%, rgba(255, 250, 236, 0.45), transparent 65%),
    radial-gradient(130% 100% at 50% 30%, transparent 38%, rgba(48, 36, 14, 0.22) 100%),
    linear-gradient(180deg, rgba(247, 241, 228, 0.32) 0%, rgba(247, 241, 228, 0.5) 52%, rgba(240, 232, 216, 0.94) 100%);
}

html[data-theme="dark"] body::before { filter: saturate(0.75) brightness(0.52) contrast(1.08); }
html[data-theme="dark"] body::after {
  background:
    radial-gradient(900px 520px at 50% 4%, rgba(126, 150, 110, 0.16), transparent 65%),
    radial-gradient(130% 100% at 50% 30%, transparent 30%, rgba(4, 7, 4, 0.82) 100%),
    linear-gradient(180deg, rgba(10, 15, 10, 0.55) 0%, rgba(10, 15, 10, 0.72) 52%, rgba(10, 15, 10, 0.96) 100%);
}

.bg-decor { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.bg-weave {
  position: absolute; inset: -60px;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 13px, var(--hairline) 13px 14px),
    repeating-linear-gradient(90deg, transparent 0 13px, var(--hairline) 13px 14px);
  opacity: 0.18;
  transform: perspective(1000px) rotateX(20deg) scale(1.4);
  transform-origin: center bottom;
  animation: weaveDrift 32s linear infinite;
}
@keyframes weaveDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 28px, 28px 0; }
}
.bg-glow {
  position: absolute; width: 62vw; height: 62vw; border-radius: 50%;
  filter: blur(110px); opacity: 0.34;
  background: radial-gradient(circle, var(--accent-soft), transparent 66%);
  top: -28vw; right: -20vw;
  animation: glowFloat 18s ease-in-out infinite alternate;
}
.bg-glow.g2 { background: radial-gradient(circle, var(--gold-soft), transparent 66%); top: auto; bottom: -34vw; left: -18vw; animation-delay: -8s; }
@keyframes glowFloat { from { transform: translate(0, 0) scale(1); } to { transform: translate(-4vw, 3vw) scale(1.14); } }
.leaf { position: absolute; font-size: 0; opacity: 0.45; animation: leafSway 9s ease-in-out infinite alternate; transform-origin: bottom center; }
.leaf svg { width: 100%; height: auto; }
.leaf.l1 { width: 150px; top: 9%; left: -34px; }
.leaf.l2 { width: 104px; bottom: 14%; right: -22px; animation-delay: -4.5s; transform: scaleX(-1); }
@keyframes leafSway { from { transform: rotate(-6deg); } to { transform: rotate(8deg); } }
.leaf.l2 { animation-name: leafSway2; }
@keyframes leafSway2 { from { transform: scaleX(-1) rotate(-5deg); } to { transform: scaleX(-1) rotate(7deg); } }

/* ============ shell ============ */
#app { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
textarea, select { font-family: inherit; }
.hidden { display: none !important; }
::selection { background: var(--accent-soft); }

.topbar {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 20px 34px 10px;
  flex: none;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 24px -18px rgba(50, 40, 20, 0.6);
  transition: transform 0.2s var(--ease-spring), background 0.25s, color 0.25s;
}
.icon-btn:hover { transform: translateY(-2px); color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }
#btnTheme .moon { display: none; }
html[data-theme="dark"] #btnTheme .sun { display: none; }
html[data-theme="dark"] #btnTheme .moon { display: block; }

.stage { flex: 1; min-height: 0; display: grid; place-items: stretch; }
.screen { height: 100%; min-height: 0; animation: screenIn 0.6s var(--ease-out) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ============ intro ============ */
#screen-intro {
  display: grid; place-items: center;
  padding: 10px 64px 48px; overflow-y: auto;
}
.intro-hero {
  width: min(1160px, 100%);
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 56px; align-items: center;
}
.intro-copy { text-align: left; position: relative; isolation: isolate; }
.intro-copy::before {
  content: ""; position: absolute; inset: -70px -80px; z-index: -1;
  background: radial-gradient(56% 60% at 36% 48%, rgba(250, 245, 232, 0.94), rgba(250, 245, 232, 0.64) 54%, transparent 78%);
  filter: blur(26px);
}
html[data-theme="dark"] .intro-copy::before {
  background: radial-gradient(56% 60% at 36% 48%, rgba(10, 16, 10, 0.9), rgba(10, 16, 10, 0.58) 54%, transparent 78%);
}
.intro-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--accent-deep); font-weight: 700;
  padding: 7px 16px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: fadeUp 0.8s 0.05s var(--ease-out) both;
}
.intro-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(38px, 4.4vw, 62px);
  line-height: 1.12; letter-spacing: -0.5px; font-weight: 500;
  margin: 22px 0 18px;
  animation: fadeUp 0.8s 0.14s var(--ease-out) both;
}
.intro-copy h2 em {
  font-style: italic; color: var(--accent); position: relative;
}
.intro-copy h2 em::after {
  content: ""; position: absolute; left: 2px; right: 2px; bottom: 4px; height: 8px;
  background: var(--gold-soft); border-radius: 99px; z-index: -1;
}
.intro-sub {
  color: color-mix(in srgb, var(--ink) 94%, transparent);
  font-size: 17.5px; line-height: 1.8; max-width: 31em; font-weight: 450;
  text-shadow: 0 1px 6px var(--halo);
  animation: fadeUp 0.8s 0.22s var(--ease-out) both;
}
.intro-cta { margin-top: 34px; animation: fadeUp 0.8s 0.32s var(--ease-out) both; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; letter-spacing: 0.4px;
  color: #f8f4e6;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  padding: 16px 40px; border-radius: 999px;
  box-shadow: 0 20px 40px -18px rgba(29, 74, 46, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s;
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.3) 50%, transparent 80%);
  transform: translateX(-120%);
  animation: sheen 4s 1.4s ease-in-out infinite;
}
@keyframes sheen { 0% { transform: translateX(-120%); } 42%, 100% { transform: translateX(120%); } }
.btn-primary:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 26px 50px -18px rgba(29, 74, 46, 0.8); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.985); }
.btn-primary svg { width: 18px; height: 18px; }

.intro-meta { margin-top: 16px; font-size: 13px; color: color-mix(in srgb, var(--ink) 80%, transparent); letter-spacing: 0.6px; text-shadow: 0 1px 5px var(--halo); }
.intro-key-miss {
  margin-top: 18px; padding: 11px 16px; border-radius: 14px; font-size: 13px;
  background: rgba(182, 76, 63, 0.1); color: var(--danger);
  border: 1px solid rgba(182, 76, 63, 0.22);
}

/* portrait medallion */
.intro-portrait {
  position: relative; display: flex; flex-direction: column; align-items: center;
  animation: fadeUp 1s 0.3s var(--ease-out) both;
}
.portrait-halo {
  position: absolute; top: -6%; width: 118%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 250, 232, 0.75), rgba(255, 248, 228, 0.15) 55%, transparent 70%);
  filter: blur(6px); z-index: -1;
  animation: haloBreathe 7s ease-in-out infinite alternate;
}
@keyframes haloBreathe { from { transform: scale(0.96); opacity: 0.75; } to { transform: scale(1.06); opacity: 1; } }
.portrait-frame {
  position: relative; width: min(340px, 100%); aspect-ratio: 1; border-radius: 50%;
  padding: 10px;
  background: conic-gradient(from 140deg, rgba(255, 255, 255, 0.9), rgba(184, 144, 42, 0.35), rgba(47, 107, 69, 0.4), rgba(255, 255, 255, 0.9));
  box-shadow: var(--shadow-lift);
}
.portrait-frame img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  display: block; background: var(--paper);
}
.portrait-frame .portrait-ring { position: absolute; inset: -14px; border-radius: 50%; border: 1px solid var(--line); }
.portrait-plate { margin-top: 26px; text-align: center; }
.portrait-plate b { font-family: var(--font-display); font-size: 17px; letter-spacing: 0.4px; display: block; text-shadow: 0 1px 6px rgba(255, 255, 255, 0.7); }
.portrait-plate span { font-size: 11px; letter-spacing: 2.2px; text-transform: uppercase; color: var(--muted); text-shadow: 0 1px 5px rgba(255, 255, 255, 0.6); }
.portrait-quote {
  margin-top: 16px; font-family: var(--font-display); font-style: italic;
  font-size: 13.5px; color: var(--muted); max-width: 300px; text-align: center;
  text-shadow: 0 1px 6px rgba(255, 255, 255, 0.7);
}

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

/* ============ chat stage ============ */
#screen-chat { display: block; padding: 0 36px 26px; position: relative; }
.chat-stage {
  height: 100%;
  width: min(860px, 100%);
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 6px;
  align-items: stretch;
}

/* visitor speech item: avatar sits above the bubble */
.msg-avatar {
  position: relative; align-self: center;
  width: 108px; height: 108px; border-radius: 50%; flex: none;
  padding: 4px;
  background: conic-gradient(from 200deg, rgba(255, 255, 255, 0.95), rgba(184, 144, 42, 0.35), rgba(47, 107, 69, 0.4), rgba(255, 255, 255, 0.95));
  box-shadow: 0 16px 34px -20px rgba(35, 28, 12, 0.85);
  transition: transform 0.5s var(--ease-spring);
}
.msg-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block;
  background: var(--paper);
}
html[data-theme="dark"] .msg-avatar img,
html[data-theme="dark"] .portrait-frame img { filter: brightness(0.88) saturate(0.94); }
.msg.visitor.speaking .msg-avatar { transform: translateY(-3px) scale(1.05); }
.msg.visitor.speaking .msg-avatar::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 1px solid var(--accent);
  animation: speakHalo 1.8s ease-out infinite;
}
@keyframes speakHalo {
  0% { opacity: 0.85; transform: scale(0.96); }
  70% { opacity: 0; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(1.12); }
}

/* right: dialogue */
.dialogue {
  position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  flex: 1 1 auto;
  padding-top: 4px; isolation: isolate;
}
.dialogue::before {
  content: ""; position: absolute; inset: -14px -18px -10px -18px; z-index: -1;
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(250, 245, 232, 0.34), rgba(250, 245, 232, 0.66) 34%, rgba(250, 245, 232, 0.8));
  filter: blur(30px);
}
html[data-theme="dark"] .dialogue::before {
  background: linear-gradient(180deg, rgba(9, 14, 9, 0.36), rgba(9, 14, 9, 0.7) 32%, rgba(9, 14, 9, 0.84));
}
.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 26px 10px 24px 6px;
  scroll-behavior: smooth;
  mask-image: linear-gradient(180deg, transparent 0, #000 40px, #000 calc(100% - 12px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 40px, #000 calc(100% - 12px), transparent 100%);
}
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.msg { display: flex; width: 100%; justify-content: center; margin-bottom: 26px; animation: msgIn 0.55s var(--ease-out) both; flex: none; }
.chat-scroll > .msg:first-of-type { margin-top: auto; }
@keyframes msgIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.bubble-wrap { max-width: min(76%, 640px); display: flex; flex-direction: column; gap: 7px; }
.msg.student .bubble-wrap { align-items: center; }
.bubble {
  padding: 16px 22px; font-size: 17.5px; line-height: 1.7;
  border-radius: 20px;
  background: var(--bubble-visitor);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 44px -28px rgba(45, 36, 18, 0.65);
  word-break: break-word;
  position: relative;
}
.msg.visitor .bubble { color: var(--ink); }
.msg.student .bubble {
  border-radius: 20px;
  background: var(--bubble-student);
  color: var(--bubble-student-ink);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 46px -26px rgba(20, 55, 34, 0.75);
}
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin: 0; }
.bubble strong { font-weight: 700; }
.bubble code { background: rgba(127, 127, 127, 0.16); padding: 1px 5px; border-radius: 5px; font-size: 15px; }
.bubble a { color: var(--accent); }
.bubble em { opacity: 0.88; }

.meta-row { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 6px; font-size: 11px; color: color-mix(in srgb, var(--ink) 55%, transparent); text-shadow: 0 1px 4px rgba(255, 255, 255, 0.6); }
.msg.student .meta-row { justify-content: center; }
.replay-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500; letter-spacing: 0.3px; text-shadow: none;
  color: color-mix(in srgb, var(--ink) 64%, transparent);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 22px -19px rgba(45, 36, 18, 0.9);
  transition: color 0.22s, background 0.22s, border-color 0.22s, transform 0.22s var(--ease-spring);
}
/* speaking feedback: bubble float + halo + wave bars */
.msg.visitor.speaking .bubble {
  animation: bubbleSpeak 2.6s ease-in-out infinite;
}
.msg.visitor.speaking .bubble::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; overflow: hidden;
  background: linear-gradient(100deg,
    transparent 24%,
    color-mix(in srgb, var(--gold) 20%, transparent) 50%,
    transparent 76%);
  background-size: 240% 100%;
  animation: bubbleShimmer 3.4s linear infinite;
}
@keyframes bubbleShimmer {
  0% { background-position: 170% 0; }
  100% { background-position: -80% 0; }
}
@keyframes bubbleSpeak {
  0%, 100% {
    transform: translateY(0);
    box-shadow: 0 18px 40px -34px rgba(45, 36, 18, 0.85);
  }
  50% {
    transform: translateY(-2px);
    box-shadow: 0 26px 48px -32px rgba(45, 36, 18, 0.9),
                0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent);
  }
}
.speak-wave {
  display: inline-flex; align-items: flex-end; gap: 3.5px; height: 14px;
  opacity: 0; transform: translateY(1px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.msg.visitor.speaking .speak-wave { opacity: 1; transform: none; }
.speak-wave i {
  width: 3px; height: 5px; border-radius: 2px;
  background: var(--accent);
  transform-origin: 50% 100%;
}
.msg.visitor.speaking .speak-wave i { animation: waveBar 0.92s ease-in-out infinite; }
.speak-wave i:nth-child(2) { animation-delay: 0.14s; }
.speak-wave i:nth-child(3) { animation-delay: 0.28s; }
.speak-wave i:nth-child(4) { animation-delay: 0.42s; }
@keyframes waveBar {
  0%, 100% { height: 5px; opacity: 0.5; }
  50% { height: 14px; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .msg.visitor.speaking .bubble { animation: none; }
  .msg.visitor.speaking .bubble::before { animation: none; opacity: 0; }
  .msg.visitor.speaking .speak-wave i { animation: none; height: 8px; opacity: 0.8; }
}
.replay-btn svg { width: 12.5px; height: 12.5px; flex: none; transition: transform 0.3s var(--ease-spring); }
.replay-btn:hover:not(:disabled) {
  color: var(--accent);
  background: var(--glass-strong);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
  transform: translateY(-1px);
}
.replay-btn:hover:not(:disabled) svg { transform: scale(1.08); }
.replay-btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.replay-btn:disabled { opacity: 0.62; }
.replay-btn.playing { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.replay-btn.playing svg { animation: replayPulse 1.1s ease-in-out infinite; }
html[data-theme="dark"] .replay-btn {
  color: color-mix(in srgb, var(--ink) 84%, transparent);
  box-shadow: 0 10px 22px -18px rgba(0, 0, 0, 0.95);
}
@keyframes replayPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.typing { display: inline-flex; align-items: center; gap: 5px; padding: 3px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: 0.5;
  animation: typingJump 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingJump { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-5px); opacity: 1; } }

/* composer: voice-first */
.composer-zone { flex: none; padding: 4px 6px 0; position: relative; }
.composer {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px;
}

/* 开始录音 */
.rec-start {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 42px; padding: 0 18px 0 15px; border-radius: 999px;
  color: #fff; font-size: 13.5px; font-weight: 600; letter-spacing: 0.3px;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: 0 16px 28px -18px color-mix(in srgb, var(--accent) 90%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, 0.26);
  transition: transform 0.25s var(--ease-spring), box-shadow 0.3s, opacity 0.3s, background 0.3s;
}
.rec-start svg { width: 17px; height: 17px; flex: none; }
.rec-start:hover:not(:disabled) { transform: translateY(-1px); }
.rec-start:active:not(:disabled) { transform: scale(0.97); }
.rec-start:disabled { opacity: 0.42; }

/* 录音中：波形即停止按钮 */
.rec-live {
  display: none; flex: 1; min-width: 0; align-items: center; gap: 14px;
  height: 44px; padding: 0 4px; cursor: pointer;
}
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--rec);
  animation: recBlink 1.8s ease-in-out infinite;
}
@keyframes recBlink {
  0%, 100% { opacity: 0.95; box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 34%, transparent); }
  50% { opacity: 0.4; box-shadow: 0 0 0 6px color-mix(in srgb, var(--rec) 0%, transparent); }
}
.rec-wave {
  flex: 1; min-width: 0; height: 30px;
  display: flex; align-items: center; justify-content: space-between; gap: 2px;
}
.eq-bar {
  flex: 0 0 auto; width: 5px; height: 100%;
  border-radius: 999px; background: var(--rec); opacity: 0.88;
  transform: scaleY(0.16); transform-origin: center;
  will-change: transform;
}
.rec-live:hover .eq-bar { opacity: 1; }
.rec-live:active .eq-bar { opacity: 0.62; }
.rec-time {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; letter-spacing: 0.5px;
  color: var(--muted); flex: none; text-shadow: 0 1px 3px var(--halo);
}
.rec-cancel {
  display: none; flex: none; font-size: 12.5px; color: var(--muted);
  padding: 8px 6px; transition: color 0.2s;
  text-shadow: 0 1px 3px var(--halo);
}
.rec-cancel:hover { color: var(--rec); }

/* 文本输入 */
.composer textarea {
  display: none; flex: 1; border: none; outline: none; background: transparent; resize: none;
  font-size: 15.5px; color: var(--ink); max-height: 120px; min-height: 26px; line-height: 1.5;
  padding: 5px 2px;
}
.composer textarea::placeholder { color: var(--muted); opacity: 0.7; }

.composer-note { text-align: center; font-size: 10.5px; color: var(--muted); margin-top: 6px; letter-spacing: 0.3px; text-shadow: 0 1px 3px var(--halo); }

/* 模式 / 状态切换 */
/* 语音待录：收成一条窄胶囊，只放一个录音按钮 */
.composer[data-mode="voice"][data-state="idle"],
.composer[data-mode="voice"][data-state="transcribing"] {
  width: fit-content; margin: 0 auto; gap: 8px; min-height: 0;
}
.composer[data-mode="voice"][data-state="idle"] .rec-start { padding: 0 16px 0 13px; height: 40px; }

.composer[data-state="recording"] .rec-live { display: flex; }
.composer[data-state="recording"] .rec-cancel { display: inline-flex; }
.composer[data-state="recording"] .rec-start { display: none; }
.composer[data-state="transcribing"] .rec-start { opacity: 0.75; }

.asr-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 8px 6px 0; animation: msgIn 0.3s var(--ease-out) both; }

/* ============ score ============ */
#screen-score { overflow-y: auto; padding: 6px 36px 48px; display: block; }
.score-wrap { width: min(940px, 100%); margin: 0 auto; }
.hero-overall {
  position: relative; margin-top: 18px; padding: 15px 18px 16px 22px;
  border-radius: 18px; text-align: left;
  background: color-mix(in srgb, var(--paper) 46%, transparent);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: box-shadow 0.4s, background 0.4s;
}
.hero-overall::before {
  content: ""; position: absolute; left: 9px; top: 18px; bottom: 18px; width: 3px;
  border-radius: 99px; background: linear-gradient(180deg, var(--accent), var(--gold));
  opacity: 0.85; transition: opacity 0.4s;
}
.hero-overall.speaking::before { animation: hoPulse 2s ease-in-out infinite; opacity: 1; }
@keyframes hoPulse {
  0%, 100% { transform: scaleY(0.92); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 38%, transparent); }
  50% { transform: scaleY(1.04); box-shadow: 0 0 14px 3px color-mix(in srgb, var(--accent) 22%, transparent); }
}
.ho-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.ho-label { font-size: 11px; letter-spacing: 2.6px; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.hero-overall p {
  font-family: var(--font-display); font-style: italic;
  font-size: 18.5px; line-height: 1.7; color: var(--ink); max-width: 62em;
}
.score-hero {
  position: relative; overflow: hidden;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(20px) saturate(1.05); -webkit-backdrop-filter: blur(20px) saturate(1.05);
  border-radius: 26px; box-shadow: var(--shadow-lift);
  padding: 22px 30px 24px; text-align: center; margin-bottom: 16px;
}
.score-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 17px, var(--hairline) 17px 18px),
    repeating-linear-gradient(90deg, transparent 0 17px, var(--hairline) 17px 18px);
  opacity: 0.09;
  mask-image: radial-gradient(circle at 50% 40%, #000, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000, transparent 75%);
}
.score-kicker { font-size: 12px; letter-spacing: 3.4px; text-transform: uppercase; color: var(--accent); font-weight: 700; animation: fadeUp 0.6s 0.05s var(--ease-out) both; }
.score-ring-zone {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center;
  gap: 24px; margin: 10px 0 0; text-align: left;
}
.score-ring { position: relative; width: 124px; height: 124px; flex: none; animation: fadeUp 0.8s 0.15s var(--ease-out) both; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--line); }
.score-ring .ring-fg { stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset 1.8s var(--ease-out); filter: drop-shadow(0 6px 14px rgba(47, 107, 69, 0.35)); }
.score-ring .ring-text { position: absolute; inset: 0; display: grid; place-items: center; }
.ring-num { font-family: var(--font-display); font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -0.5px; }
.ring-num small { font-size: 14px; color: color-mix(in srgb, var(--ink) 55%, transparent); font-weight: 400; letter-spacing: 0; }
.ring-label { font-size: 9.5px; color: color-mix(in srgb, var(--ink) 58%, transparent); letter-spacing: 2px; margin-top: 5px; text-transform: uppercase; }
.score-level { text-align: left; max-width: 640px; animation: fadeUp 0.8s 0.3s var(--ease-out) both; }
.score-level .lv-badge {
  display: inline-block; font-size: 13.5px; font-weight: 800; letter-spacing: 1.2px;
  padding: 8px 19px; border-radius: 999px; color: #fbf7ea;
  background: linear-gradient(135deg, var(--lv, var(--accent)), var(--accent-deep));
  box-shadow: 0 18px 34px -18px rgba(29, 74, 46, 0.8);
  animation: badgeIn 0.8s 0.55s var(--ease-spring) both;
}
@keyframes badgeIn { from { transform: scale(0.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
.score-level p { font-size: 15px; line-height: 1.75; color: color-mix(in srgb, var(--ink) 80%, transparent); margin-top: 12px; }

.dim-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 18px; }
.dim-card {
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 22px; padding: 22px;
  box-shadow: 0 22px 46px -34px rgba(45, 36, 18, 0.7);
  animation: fadeUp 0.7s var(--ease-out) both; position: relative; overflow: hidden;
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s;
}
.dim-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-soft); }
.dim-card:nth-child(1) { animation-delay: 0.35s; }
.dim-card:nth-child(2) { animation-delay: 0.43s; }
.dim-card:nth-child(3) { animation-delay: 0.51s; }
.dim-card:nth-child(4) { animation-delay: 0.59s; }
.dim-card::after {
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px;
  border-radius: 0 4px 4px 0; background: var(--dim-color, var(--accent));
}
.dim-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dim-head h4 { font-size: 16.5px; letter-spacing: 0.2px; font-weight: 650; color: var(--ink); }
.dim-score { font-family: var(--font-display); font-size: 30px; font-weight: 600; color: var(--dim-color, var(--accent)); font-variant-numeric: tabular-nums; line-height: 1; }
.dim-score small { font-size: 13px; color: var(--muted); font-weight: 400; }
.dim-bar { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 8%, transparent); overflow: hidden; margin-bottom: 14px; }
.dim-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--dim-color, var(--accent)), color-mix(in srgb, var(--dim-color, var(--accent)) 55%, var(--gold))); width: 0; transition: width 1.4s var(--ease-out); }
.dim-card p { font-size: 15px; line-height: 1.7; color: color-mix(in srgb, var(--ink) 82%, transparent); }


.master-check {
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px;
  padding: 22px 26px; margin-bottom: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: fadeUp 0.7s 0.74s var(--ease-out) both;
}
.master-check h4 { font-size: 12px; letter-spacing: 2.4px; text-transform: uppercase; color: color-mix(in srgb, var(--ink) 62%, transparent); margin-bottom: 15px; }
.master-check .mc-row { display: flex; flex-wrap: wrap; gap: 9px; }
.mc-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px;
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 45%, transparent); color: color-mix(in srgb, var(--ink) 68%, transparent);
  transition: transform 0.2s var(--ease-spring);
}
.mc-chip:hover { transform: scale(1.05); }
.mc-chip.hit { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mc-chip svg { width: 13px; height: 13px; }

.transcript-card {
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px;
  padding: 22px 26px; margin-bottom: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: fadeUp 0.7s 0.82s var(--ease-out) both;
}
.transcript-card summary { cursor: pointer; font-size: 14.5px; color: var(--accent); font-weight: 600; padding: 4px 0; list-style: none; }
.transcript-card summary::-webkit-details-marker { display: none; }
.transcript-card summary::after { content: " ↓"; font-size: 12px; }
.t-line { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; line-height: 1.7; color: color-mix(in srgb, var(--ink) 88%, transparent); }
.t-line:last-child { border-bottom: none; }
.t-line .t-role { flex: none; width: 74px; font-size: 10px; font-weight: 700; letter-spacing: 1.6px; color: var(--muted); padding-top: 4px; text-transform: uppercase; }
.t-line.student .t-role { color: var(--gold); }
.t-line .t-text { flex: 1; }
.t-line .t-chip { font-size: 10px; color: var(--muted); border: 1px solid var(--line); padding: 1px 7px; border-radius: 99px; margin-left: 8px; white-space: nowrap; }

.score-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; animation: fadeUp 0.7s 0.9s var(--ease-out) both; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 600; padding: 14px 30px; border-radius: 999px;
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--ink);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform 0.2s var(--ease-spring), background 0.2s;
}
.btn-outline:hover { transform: translateY(-2px); }
.btn-outline svg { width: 16px; height: 16px; }

/* judging */
.judging-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: fadeIn 0.4s var(--ease-out) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.judging-box { text-align: center; animation: fadeUp 0.5s 0.1s var(--ease-out) both; }
.judging-ring { width: 88px; height: 88px; margin: 0 auto 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.judging-box h3 { font-family: var(--font-display); font-size: 24px; font-weight: 500; margin-bottom: 8px; }
.judging-box p { color: var(--muted); font-size: 14px; }

/* ============ modal & toast ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(20, 16, 8, 0.42);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.3s var(--ease-out) both;
}
.modal {
  width: min(440px, calc(100vw - 48px));
  background: var(--glass-strong); border: 1px solid var(--glass-line);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 26px; padding: 30px; box-shadow: var(--shadow-lift);
  animation: modalIn 0.4s var(--ease-spring) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.94); } to { opacity: 1; transform: none; } }
.modal h3 { font-family: var(--font-display); font-size: 22px; font-weight: 500; margin-bottom: 12px; }
.modal p { font-size: 14px; color: var(--muted); margin-bottom: 22px; line-height: 1.75; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-flat { padding: 11px 20px; border-radius: 12px; font-size: 14px; font-weight: 600; transition: background 0.2s, transform 0.2s var(--ease-spring); }
.btn-flat:hover { transform: translateY(-1px); }
.btn-flat.plain { color: var(--muted); }
.btn-flat.plain:hover { background: var(--accent-soft); color: var(--ink); }
.btn-flat.danger { background: var(--danger); color: #fff; }
.btn-flat.good { background: var(--accent); color: #fff; }
.help-list { margin: 0 0 20px; padding-left: 18px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; line-height: 1.7; }
.toast-zone { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 11px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--glass-strong); color: var(--ink); border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  animation: toastIn 0.4s var(--ease-spring) both;
  max-width: min(560px, calc(100vw - 40px));
}
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.out { animation: toastOut 0.35s var(--ease-out) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-18px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-14px) scale(0.94); } }

/* ============ narrow desktop ============ */
@media (max-width: 1180px) {
  .intro-hero { gap: 36px; }
  .chat-stage { gap: 4px; }
}
@media (max-width: 980px) {
  .bubble-wrap { max-width: 88%; }
  .dim-grid { grid-template-columns: 1fr; }
  #screen-intro { padding: 14px 34px 44px; }
  .intro-hero { grid-template-columns: 1fr; gap: 18px; justify-items: center; align-content: center; }
  .intro-copy { text-align: center; }
  .intro-copy h2 { font-size: clamp(30px, 5.4vw, 44px); margin: 16px 0 14px; }
  .intro-sub { margin: 0 auto; font-size: 16px; line-height: 1.8; }
  .intro-cta { margin-top: 24px; }
  .intro-portrait { order: -1; }
  .portrait-frame { width: 168px; }
  .portrait-plate { margin-top: 12px; }
  .portrait-plate b { font-size: 15px; }
  .portrait-plate span { font-size: 10px; letter-spacing: 1.8px; }
  .portrait-quote { display: none; }
  .portrait-halo { width: 104%; top: -2%; }
}
