/* =========================================================
   金陵遗韵 · 南京非遗数字讲解员
   视觉：宣纸、城墙灰、朱砂印、云锦金
   ========================================================= */
:root {
  color-scheme: only light;
  --paper: #f4ecdd;
  --paper-deep: #e9ddc7;
  --card: #fffdf8;
  --ink: #22333b;
  --ink-2: #4d5f63;
  --ink-3: #6f7d7e;
  --seal: #a63a2f;
  --seal-deep: #8b2e25;
  --gold: #94662f;
  --gold-soft: #d9c09a;
  --jade: #4c6759;
  --line: rgba(34, 51, 59, 0.11);
  --line-gold: rgba(169, 124, 69, 0.28);
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --shadow: 0 34px 70px -42px rgba(34, 51, 59, 0.5);
  --ease: cubic-bezier(0.32, 0.72, 0.3, 1);
}

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

html,
body {
  height: 100%;
  color-scheme: only light;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 720px at 78% -8%, #fffaf0 0%, rgba(255, 250, 240, 0) 62%),
    radial-gradient(900px 620px at -8% 104%, #ecdfc7 0%, rgba(236, 223, 199, 0) 58%),
    linear-gradient(160deg, #f7f1e5 0%, #f2e9d9 48%, #eee3d0 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.36'/%3E%3C/svg%3E");
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.fine {
  margin: 0;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

/* ---------------- 布局 ---------------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(300px, 370px) minmax(0, 1fr);
  gap: clamp(22px, 3.2vw, 48px);
  width: 100%;
  max-width: 1180px;
  height: 100vh;
  height: var(--app-h, 100dvh);
  margin: 0 auto;
  padding: clamp(16px, 2.6vw, 34px);
}

/* ---------------- 左侧序厅 ---------------- */
.intro {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: clamp(6px, 3vh, 30px);
}

.brandline {
  display: flex;
  align-items: center;
  gap: 11px;
}

.seal {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: var(--seal);
  color: #fbf3e2;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 232, 0.35), 0 6px 14px -8px rgba(139, 46, 37, 0.8);
  transform: rotate(-2deg);
}

.seal.small {
  width: 36px;
  height: 36px;
  font-size: 21px;
  border-radius: 8px;
}

.brand-en {
  font-size: 9.5px;
  letter-spacing: 0.32em;
  color: var(--ink-3);
  white-space: nowrap;
}

h1 {
  margin: clamp(16px, 3.4vh, 34px) 0 6px;
  font-family: var(--serif);
  font-size: clamp(42px, 4.7vw, 62px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.sub {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.36em;
  color: var(--gold);
}

.scene {
  position: relative;
  margin: clamp(14px, 2.6vh, 26px) 0 clamp(10px, 1.8vh, 16px);
}

.scene::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-gold) 18%, var(--line-gold) 82%, transparent);
}

.scene img {
  display: block;
  width: 100%;
  max-height: min(38vh, 330px);
  object-fit: contain;
  object-position: center bottom;
  filter: saturate(0.94);
}

.lede {
  margin: 0 0 clamp(12px, 2.2vh, 22px);
  padding-left: 13px;
  border-left: 2px solid var(--gold-soft);
  font-size: 13px;
  line-height: 2;
  letter-spacing: 0.03em;
  color: var(--ink-2);
  max-width: 330px;
}

.project-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--line);
}

.project-list li {
  border-top: 1px solid var(--line);
}

.project-list button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 4px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s var(--ease), padding 0.25s var(--ease);
}

.project-list button:hover {
  background: rgba(255, 253, 248, 0.55);
  padding-left: 8px;
}

.project-list b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  color: var(--seal);
  background: rgba(255, 253, 248, 0.7);
}

.project-list span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 13.5px;
  letter-spacing: 0.04em;
}

.project-list small {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.project-list i {
  margin-left: auto;
  font-style: normal;
  font-size: 12px;
  color: var(--gold);
  opacity: 0;
  transform: translateX(-4px);
  transition: 0.25s var(--ease);
}

.project-list button:hover i {
  opacity: 1;
  transform: none;
}

.intro-foot {
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.linkbtn {
  padding: 0;
  border: 0;
  background: none;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--gold);
  cursor: pointer;
  border-bottom: 1px solid rgba(169, 124, 69, 0.35);
}

/* ---------------- 对话区 ---------------- */
.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  border: 1px solid rgba(169, 124, 69, 0.32);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow), inset 0 0 0 5px rgba(255, 255, 255, 0.42);
  overflow: hidden;
}

.chat::before {
  content: "";
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--seal), var(--gold) 34%, var(--jade) 68%, var(--seal));
  opacity: 0.82;
}

.chat-head {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf8, #faf4e7);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.who-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.who strong {
  display: flex;
  align-items: center;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.brand-chip {
  display: none;
  margin-left: 7px;
  padding: 1px 5px;
  border: 1px solid var(--line-gold);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 8.5px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--gold);
  transform: translateY(1px);
}

.who small {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6f8f6a;
  box-shadow: 0 0 0 3px rgba(111, 143, 106, 0.16);
  animation: pulse 2.6s ease-in-out infinite;
}

.head-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.voice,
.icon-btn,
.bgm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  border: 1px solid var(--line-gold);
  background: rgba(255, 253, 248, 0.8);
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.2s var(--ease);
}

.bgm {
  padding: 0 9px;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.bgm:hover {
  border-color: var(--gold);
  color: var(--seal);
  background: #fff;
}

.bgm svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bgm .ico-off {
  display: none;
}

.bgm[aria-pressed="false"] {
  color: var(--ink-3);
  border-color: var(--line);
  background: transparent;
}

.bgm[aria-pressed="false"] .ico-on {
  display: none;
}

.bgm[aria-pressed="false"] .ico-off {
  display: block;
}

.bgm-playing #bgmBtn {
  color: var(--seal);
  border-color: rgba(166, 58, 47, 0.45);
}

.bgm-playing #bgmBtn svg {
  animation: bgmPulse 1.6s ease-in-out infinite;
}

.voice {
  padding: 0 11px;
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.voice:hover,
.icon-btn:hover {
  border-color: var(--gold);
  color: var(--ink);
  background: #fff;
}

.voice svg,
.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice svg path:first-child {
  fill: currentColor;
  stroke: none;
}

.voice .ico-off {
  display: none;
}

.voice[aria-pressed="false"] {
  color: var(--ink-3);
  border-color: var(--line);
  background: transparent;
}

.voice[aria-pressed="false"] .ico-on {
  display: none;
}

.voice[aria-pressed="false"] .ico-off {
  display: block;
}

.icon-btn {
  width: 34px;
  border-radius: 50%;
  padding: 0;
  color: var(--ink-3);
}

/* ---------------- 消息舞台 ---------------- */
.stage {
  --lane: 136px;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(680px 360px at 82% 6%, rgba(233, 221, 199, 0.32), transparent 68%),
    linear-gradient(180deg, #fffdf8 0%, #fdfaf2 100%);
}

.stage::after {
  content: "";
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: var(--lane);
  left: 0;
  height: 26px;
  background: linear-gradient(to bottom, rgba(253, 250, 242, 0), #fdfaf2 88%);
  pointer-events: none;
}

.scroll {
  position: absolute;
  inset: 0 0 var(--lane) 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 18px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(169, 124, 69, 0.35) transparent;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.scroll::-webkit-scrollbar {
  width: 6px;
}

.scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(169, 124, 69, 0.28);
}

.day {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 16px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
}

.day::before,
.day::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, var(--line-gold));
}

.day::after {
  background: linear-gradient(90deg, var(--line-gold), transparent);
}

#messages {
  display: flex;
  flex-direction: column;
}

.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0 0 16px;
  animation: rise 0.42s var(--ease) both;
}

.msg.user {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 5px 4px;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}

.msg.user .msg-meta {
  margin-right: 4px;
}

.bubble {
  position: relative;
  max-width: min(86%, 620px);
  padding: 12px 15px;
  border: 1px solid rgba(169, 124, 69, 0.2);
  border-left: 3px solid var(--gold);
  border-radius: 4px 14px 14px 14px;
  background: #fbf5e7;
  box-shadow: 0 2px 0 rgba(169, 124, 69, 0.04);
  font-size: 15.5px;
  line-height: 1.88;
  letter-spacing: 0.01em;
  color: var(--ink);
  word-break: break-word;
}

.bubble strong {
  color: var(--seal);
  font-weight: 600;
}

.msg.user .bubble {
  max-width: min(82%, 560px);
  padding: 11px 15px;
  border: 0;
  border-radius: 14px 4px 14px 14px;
  background: linear-gradient(150deg, #35525a, #28434b);
  box-shadow: 0 10px 24px -16px rgba(34, 51, 59, 0.8);
  color: #faf4e6;
}

.msg.user .bubble strong {
  color: #ffe9bd;
}

.msg-title {
  display: inline-block;
  margin-bottom: 2px;
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--seal);
}

.msg-cue {
  color: var(--gold);
  font-weight: 600;
}

.source {
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px dashed rgba(169, 124, 69, 0.3);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.project-cards {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
  max-width: calc(100% - 4px);
  margin: -4px 0 18px 2px;
  animation: rise 0.45s 0.12s var(--ease) both;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(169, 124, 69, 0.22);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.82);
  text-align: left;
  cursor: pointer;
  transition: 0.22s var(--ease);
}

.project-card:hover {
  border-color: var(--gold);
  background: #fff;
  transform: translateY(-1px);
}

.project-card b {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.9);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  color: var(--seal);
}

.project-card span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.project-card small {
  overflow: hidden;
  font-size: 9.5px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 0 5px;
  opacity: 0.55;
  transition: opacity 0.2s;
}

.msg:hover .actions,
.actions:focus-within {
  opacity: 1;
}

.actions button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  border: 0;
  background: none;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  cursor: pointer;
}

.actions button:hover {
  color: var(--seal);
}

.actions svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 45px;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  animation: blink 1.25s infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.18s;
}

.typing i:nth-child(3) {
  animation-delay: 0.36s;
}

/* ---------------- 桌宠 ---------------- */
.pet-layer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  top: auto;
  height: var(--lane);
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
}

.pet {
  --dir: 1;
  position: absolute;
  right: 14px;
  bottom: 10px;
  width: clamp(72px, 7.8vw, 92px);
  pointer-events: auto;
  cursor: pointer;
  z-index: 2;
  transition:
    left 1.05s cubic-bezier(0.45, 0.05, 0.35, 1),
    top 1.05s cubic-bezier(0.45, 0.05, 0.35, 1);
  will-change: left, top;
  -webkit-tap-highlight-color: transparent;
}

.pet-body {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 10px 14px rgba(30, 45, 60, 0.16));
}

.pet-flip {
  transform: scaleX(var(--dir));
  transform-origin: 50% 80%;
  transition: transform 0.22s var(--ease);
}

.pet-bob {
  transform-origin: 50% 90%;
}

.pet img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.pet-shadow {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: -2px;
  width: 58%;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(34, 51, 59, 0.32), transparent 70%);
  transform: translateX(-50%);
  filter: blur(1.5px);
}

.pet-bubble {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: calc(100% - 10px);
  max-width: 168px;
  padding: 6px 10px;
  border: 1px solid var(--line-gold);
  border-radius: 11px 11px 3px 11px;
  background: #fffdf8;
  box-shadow: 0 10px 22px -16px rgba(34, 51, 59, 0.55);
  font-size: 11.5px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(5px) scale(0.94);
  transition: opacity 0.22s, transform 0.22s var(--ease);
  pointer-events: none;
}

.pet-bubble.show {
  opacity: 1;
  transform: none;
}

.pet.walk .pet-bob {
  animation: waddle 0.52s ease-in-out infinite;
}

.pet.think .pet-bob {
  animation: think 0.72s ease-in-out infinite;
}

.pet.hop .pet-bob {
  animation: hop 0.5s var(--ease);
}

/* 点击桌宠的随机小动作：只影响画面，不触发语音 */
.pet.act-hop .pet-bob {
  animation: petHop 0.62s var(--ease);
}
.pet.act-spin .pet-flip {
  animation: petSpin 0.72s var(--ease);
}
.pet.act-shake .pet-bob {
  animation: petShake 0.62s var(--ease);
}
.pet.act-squash .pet-bob {
  animation: petSquash 0.64s var(--ease);
}
.pet.act-peek .pet-bob {
  animation: petPeek 0.76s var(--ease);
}
.pet.act-dash .pet-bob {
  animation: petDash 0.7s var(--ease);
}
.pet.act-dizzy .pet-bob {
  animation: petDizzy 0.82s var(--ease);
}

.pet-emote {
  position: absolute;
  z-index: 5;
  top: 6%;
  right: -4%;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(34, 51, 59, 0.25));
}

.pet-emote.show {
  animation: emotePop 1.05s ease-out both;
}

.spark {
  position: absolute;
  z-index: 3;
  font-size: 11px;
  color: var(--gold);
  opacity: 0;
  pointer-events: none;
}

.spark.s1 {
  top: 14%;
  left: -6%;
}

.spark.s2 {
  top: 32%;
  right: -3%;
  font-size: 9px;
}

.pet.arrive .s1 {
  animation: sparkle 0.9s ease-out;
}

.pet.arrive .s2 {
  animation: sparkle 0.9s 0.14s ease-out;
}

/* ---------------- 快捷提问 ---------------- */
.suggest {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  padding: 9px 14px 3px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.suggest::-webkit-scrollbar {
  display: none;
}

.game-chip {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid rgba(166, 58, 47, 0.3);
  border-radius: 999px;
  background: rgba(166, 58, 47, 0.07);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--seal);
  text-decoration: none;
  white-space: nowrap;
  transition: 0.2s var(--ease);
}

.game-chip:hover {
  border-color: var(--seal);
  background: rgba(166, 58, 47, 0.12);
  transform: translateY(-1px);
}

.suggest button {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid rgba(169, 124, 69, 0.3);
  border-radius: 999px;
  background: #fffdf8;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: 0.2s var(--ease);
}

.suggest button:hover {
  border-color: var(--gold);
  color: var(--seal);
  background: #fff;
  transform: translateY(-1px);
}

/* ---------------- 输入区 ---------------- */
.composer {
  display: flex;
  align-items: flex-end;
  flex: 0 0 auto;
  gap: 9px;
  padding: 6px 14px 2px;
  background: var(--card);
}

.composer textarea {
  flex: 1;
  width: 100%;
  min-height: 46px;
  max-height: 118px;
  padding: 12px 14px;
  border: 1px solid rgba(34, 51, 59, 0.16);
  border-radius: 16px;
  background: #fff;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  resize: none;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer textarea::placeholder {
  color: #899593;
  font-size: 13px;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(169, 124, 69, 0.12);
}

.mic {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  background: #fffdf8;
  color: var(--ink-2);
  cursor: pointer;
  transition: 0.2s var(--ease);
}

.mic svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic:hover {
  border-color: var(--gold);
  color: var(--seal);
  background: #fff;
}

.mic.recording {
  border-color: var(--seal);
  background: var(--seal);
  color: #fff8ec;
  animation: micPulse 1.15s ease-in-out infinite;
}

.mic.processing {
  opacity: 0.5;
  pointer-events: none;
}

.mic:disabled {
  opacity: 0.45;
  cursor: default;
}

.send {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(150deg, #b5463a, var(--seal-deep));
  color: #fff8ec;
  cursor: pointer;
  box-shadow: 0 9px 18px -10px rgba(166, 58, 47, 0.85);
  transition: transform 0.16s var(--ease), opacity 0.2s;
}

.send svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateX(1px);
}

.send:hover {
  transform: translateY(-1px) scale(1.03);
}

.send:active {
  transform: scale(0.95);
}

.send:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.chat-fine {
  flex: 0 0 auto;
  padding: 5px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--card);
  text-align: center;
  font-size: 10px;
}

/* ---------------- 方案弹窗 ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 36, 40, 0.46);
  backdrop-filter: blur(4px);
  animation: fade 0.25s ease both;
}

.modal-card {
  position: relative;
  outline: none;
  z-index: 1;
  width: min(720px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid rgba(169, 124, 69, 0.4);
  border-radius: 20px;
  background:
    radial-gradient(600px 300px at 100% 0%, #fffaf0, transparent 70%),
    var(--card);
  box-shadow: 0 50px 100px -40px rgba(20, 30, 34, 0.6);
  animation: modalIn 0.32s var(--ease) both;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(169, 124, 69, 0.1);
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 9.5px;
  letter-spacing: 0.34em;
  color: var(--gold);
}

.modal-card h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: clamp(23px, 3.4vw, 30px);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.modal-lede {
  margin: 0 0 22px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--ink-2);
}

.flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 7px;
  margin: 0 0 22px;
  padding: 16px 14px;
  border: 1px solid var(--line-gold);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.7);
}

.flow > i {
  font-style: normal;
  color: var(--gold);
  font-size: 14px;
}

.flow-step {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: center;
}

.flow-step b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 0 auto 4px;
  border-radius: 50%;
  background: var(--seal);
  color: #fbf3e2;
  font-size: 11px;
  font-weight: 600;
}

.flow-step span {
  font-size: 12px;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.flow-step small {
  font-size: 9.5px;
  color: var(--ink-3);
}

.modal-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.modal-list li {
  position: relative;
  padding: 9px 0 9px 16px;
  border-top: 1px dashed rgba(169, 124, 69, 0.25);
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--ink-2);
}

.modal-list li::before {
  content: "·";
  position: absolute;
  left: 2px;
  top: 8px;
  color: var(--seal);
  font-weight: 700;
}

.modal-list b {
  color: var(--ink);
  font-weight: 600;
}

.modal-note {
  margin: 18px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(169, 124, 69, 0.08);
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-3);
}

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  max-width: min(86vw, 360px);
  padding: 9px 16px;
  border: 1px solid rgba(169, 124, 69, 0.3);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 16px 34px -20px rgba(34, 51, 59, 0.6);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s var(--ease);
}

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

.speaking #voiceBtn {
  border-color: var(--seal);
  color: var(--seal);
  animation: voiceGlow 1.6s ease-in-out infinite;
}

.voice-loading #voiceBtn {
  border-color: var(--gold);
  color: var(--gold);
  animation: voiceGlow 1.05s ease-in-out infinite;
}

/* ---------------- 动画 ---------------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes blink {
  0%,
  70%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(111, 143, 106, 0.16);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(111, 143, 106, 0.06);
  }
}

@keyframes waddle {
  0%,
  100% {
    transform: translateY(0) rotate(-2.6deg);
  }
  50% {
    transform: translateY(-4px) rotate(2.6deg);
  }
}

@keyframes think {
  0%,
  100% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(2.4deg) translateY(-2px);
  }
}

@keyframes hop {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-9px) rotate(-3deg);
  }
  70% {
    transform: translateY(0) rotate(2deg);
  }
}

@keyframes bgmPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

@keyframes micPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(166, 58, 47, 0.28);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(166, 58, 47, 0);
  }
}

@keyframes emotePop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.5) rotate(-8deg);
  }
  22% {
    opacity: 1;
    transform: translateY(-2px) scale(1.18) rotate(5deg);
  }
  68% {
    opacity: 1;
    transform: translateY(-11px) scale(1) rotate(-2deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
  }
}

@keyframes petHop {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  35% {
    transform: translateY(-16px) rotate(-3deg);
  }
  62% {
    transform: translateY(0) rotate(2deg) scale(1.04, 0.96);
  }
  80% {
    transform: translateY(-4px);
  }
}

@keyframes petSpin {
  from {
    transform: scaleX(var(--dir)) rotate(0);
  }
  to {
    transform: scaleX(var(--dir)) rotate(360deg);
  }
}

@keyframes petShake {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  18% {
    transform: translateX(-5px) rotate(-3deg);
  }
  38% {
    transform: translateX(5px) rotate(3deg);
  }
  58% {
    transform: translateX(-4px) rotate(-2deg);
  }
  78% {
    transform: translateX(3px) rotate(2deg);
  }
}

@keyframes petSquash {
  0%,
  100% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.14, 0.84) translateY(4px);
  }
  60% {
    transform: scale(0.94, 1.07) translateY(-3px);
  }
  82% {
    transform: scale(1.03, 0.97);
  }
}

@keyframes petPeek {
  0%,
  100% {
    transform: rotate(0) translateY(0);
  }
  35% {
    transform: rotate(11deg) translateY(-7px);
  }
  68% {
    transform: rotate(6deg) translateY(-4px);
  }
}

@keyframes petDash {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(calc(22px * var(--dir))) rotate(3deg);
  }
  62% {
    transform: translateX(calc(10px * var(--dir))) rotate(-2deg);
  }
}

@keyframes petDizzy {
  0%,
  100% {
    transform: rotate(0);
  }
  20% {
    transform: rotate(-7deg) translateY(-2px);
  }
  45% {
    transform: rotate(7deg) translateY(-3px);
  }
  70% {
    transform: rotate(-5deg) translateY(-1px);
  }
  88% {
    transform: rotate(3deg);
  }
}

@keyframes sparkle {
  0% {
    opacity: 0;
    transform: scale(0.4) translateY(3px);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.15) translateY(-7px);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes voiceGlow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(166, 58, 47, 0.16);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(166, 58, 47, 0.08);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1000px) {
  body {
    background: var(--card);
  }

  .app {
    display: block;
    height: 100vh;
    height: var(--app-h, 100dvh);
    max-width: none;
    padding: 0;
  }

  .intro {
    display: none;
  }

  .chat {
    height: 100vh;
    height: var(--app-h, 100dvh);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .chat::before {
    height: 2px;
  }

  .chat-head {
    padding-top: calc(11px + env(safe-area-inset-top));
  }

  .brand-chip {
    display: inline-block;
  }

  .bgm {
    width: 34px;
    padding: 0;
    border-radius: 50%;
  }

  .bgm span {
    display: none;
  }

  .chat-fine {
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  .stage {
    --lane: 92px;
  }

  .scroll {
    padding: 12px 14px 18px;
    scrollbar-width: none;
  }

  .scroll::-webkit-scrollbar {
    display: none;
  }

  .pet {
    width: 56px;
    right: 10px;
    bottom: 6px;
  }

  .pet-bubble {
    font-size: 11px;
    max-width: 150px;
  }

  .suggest {
    padding: 8px 12px 2px;
  }

  .composer {
    padding: 5px 12px 1px;
  }

  .mic {
    width: 40px;
    height: 40px;
  }

  .mic svg {
    width: 18px;
    height: 18px;
  }

  .bubble {
    max-width: 90%;
    font-size: 14.5px;
    line-height: 1.8;
  }

  .project-cards {
    display: grid;
  }

  .project-card {
    gap: 7px;
    padding: 7px 8px;
  }

  .project-card b {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .project-card span {
    font-size: 12px;
  }

  .project-card small {
    font-size: 9px;
  }

  .msg.user .bubble {
    max-width: 86%;
  }
}

@media (max-width: 360px) {
  .mic {
    width: 38px;
    height: 38px;
  }

  .bgm {
    width: 34px;
    padding: 0;
    border-radius: 50%;
  }

  .bgm span {
    display: none;
  }

  .brand-chip,
  .status-extra {
    display: none;
  }

  .voice {
    width: 34px;
    padding: 0;
    border-radius: 50%;
  }

  .voice span {
    display: none;
  }
}

@media (max-width: 560px) {
  .flow {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 14px 12px;
  }

  .flow > i {
    transform: rotate(90deg);
    justify-self: center;
  }

  .flow-step {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-align: left;
  }

  .flow-step b {
    margin: 0;
    flex: 0 0 auto;
  }

  .flow-step small {
    display: none;
  }

  .modal-card {
    max-height: 90dvh;
  }

  .voice {
    padding: 0 10px;
  }
}

@media (max-height: 520px) {
  .suggest,
  .chat-fine {
    display: none;
  }

  .stage {
    --lane: 72px;
  }

  .pet {
    width: 46px;
    bottom: 4px;
  }

  .pet-bubble {
    padding: 4px 7px;
    font-size: 10px;
  }

  .chat-head {
    padding-top: calc(7px + env(safe-area-inset-top));
    padding-bottom: 7px;
  }
}

@media (max-height: 720px) and (min-width: 1001px) {
  .scene img {
    max-height: 190px;
  }

  .lede {
    display: none;
  }

  h1 {
    margin-top: 14px;
  }
}

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