/* 遇见 / 陪伴 · 按 demo 一比一实现
   - 遇见：demo/encounter（纸感 + 衬线 + 插画 hero + 故事卡 + 探索区）
   - 陪伴：demo/companion-chat（深色 + 立绘 + 三行问候 + 快捷短语 + 输入 dock）
   只作用于 .screen-home.paper / .screen-crystal.companion，不改底栏与共用组件。 */

/* 遇见页左右两侧：纸感页居中时，把整窗底换成 demo 同款浅纸色，避免深色场景底漏边 */
body:has(.screen-home.paper) { background: #dce2d7 !important; }

@font-face {
  font-family: Story;
  src: url('/vendor/fonts/xiaolai-cjk.woff2') format('woff2');
  font-display: swap;
}

/* ============ 遇见 ============ */

/* 遇见页的强调色跟随「当前精灵主题」——原来是 demo 的森林绿，和主线水晶紫不搭 */
.screen-home.paper {
  --paper-accent: var(--theme-accent-deep, #6f83cb);
  --paper-accent-lite: var(--theme-accent-lite, #c8cfeb);
  --paper-ink-soft: #7c7b88;
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: 88px;
  background: #f6f5ee !important;
  color: #344b43;
  font: 15px/1.6 'Microsoft YaHei', sans-serif;
  box-shadow: 0 0 100px #334f4320;
}

/* 顶栏压在大图上：纸色渐隐 + 白描边，保证「遇见 / 场景名」在亮插画上也读得清 */
.screen-home.paper .top {
  background: linear-gradient(#f6f5ee 0%, #f6f5eee0 58%, transparent 100%);
}
.screen-home.paper .top h1,
.screen-home.paper .top small { text-shadow: 0 1px 10px #fffdf8, 0 0 2px #fffdf8; }
.screen-home.paper .hero-title p,
.screen-home.paper .hero-title h2 { text-shadow: 0 1px 12px #fffdf8, 0 0 3px #fffdf8; }
.screen-home.paper .location { text-shadow: 0 1px 10px #fffdf8; }
.screen-home.paper .top {
  height: 85px;
  padding: 20px 23px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.screen-home.paper .top h1 {
  font: 27px Story, serif;
  margin: 0;
  letter-spacing: 3px;
  color: #344b43;
}

.screen-home.paper .top small {
  font-size: 10px;
  letter-spacing: 2px;
  color: #7b897d;
}

.screen-home.paper .top-acts { display: flex; align-items: center; gap: 8px; }

.screen-home.paper .round {
  border: 1px solid #d5ddcf;
  border-radius: 50%;
  background: #ffffff9c;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #344b43;
  overflow: hidden;
}

.screen-home.paper .round img { width: 100%; height: 100%; object-fit: cover; }

/* hero */
.screen-home.paper .hero {
  height: 310px;
  position: relative;
  margin-top: -85px;
  background: #dfe3d6 center 38% / cover no-repeat;
}

.screen-home.paper .hero-title { position: absolute; top: 110px; left: 25px; right: 25px; }
.screen-home.paper .hero-title p { margin: 0 0 8px; font-size: 11px; letter-spacing: 3px; color: var(--paper-ink-soft); }

.screen-home.paper .hero-title h2 {
  margin: 0;
  font: 31px/1.45 Story, serif;
  letter-spacing: 2px;
  text-shadow: 0 2px 12px #fff;
}

.screen-home.paper .location {
  position: absolute;
  right: 23px;
  bottom: 23px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--paper-ink-soft);
}

.screen-home.paper .content { padding: 0 23px; }

/* 每日故事卡 */
.screen-home.paper .daily {
  display: grid;
  grid-template-columns: 79px 1fr;
  gap: 17px;
  align-items: center;
  background: #fffdf8;
  border: 1px solid #e3e6da;
  border-radius: 5px 17px 17px 5px;
  padding: 13px;
  box-shadow: 0 7px 25px #506d4d08;
  margin-top: -5px;
  position: relative;
  text-align: left;
  width: 100%;
  color: inherit;
}

.screen-home.paper .daily img {
  width: 79px;
  height: 107px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 3px 3px 0 #e6dfcf;
}

.screen-home.paper .eyebrow { font-size: 10px; letter-spacing: 2px; color: var(--paper-ink-soft); }
.screen-home.paper .daily h3 { font: 21px Story, serif; margin: 6px 0; color: #344b43; }
.screen-home.paper .daily p { font-size: 12px; color: #7b897d; margin: 0; }
.screen-home.paper .daily .read { display: block; margin-top: 9px; font-size: 12px; color: var(--paper-accent); }

/* 区块 */
.screen-home.paper .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}

.screen-home.paper .section-heading h2 { font: 21px Story, serif; margin: 0; color: #344b43; }

.screen-home.paper .text-button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--paper-accent);
  font-size: 12px;
}

.screen-home.paper .explore { border-top: 1px solid #dce2d6; padding: 18px 0 0; }
.screen-home.paper .explore p { font-size: 14px; margin: 0 0 18px; color: #687a6c; }

.screen-home.paper .primary {
  border: 1px solid var(--paper-accent);
  background: var(--paper-accent);
  color: #fffef4;
  border-radius: 9px;
  padding: 12px 18px;
  min-height: 47px;
  width: 100%;
  box-shadow: 0 6px 18px var(--theme-accent-glow, rgba(150,160,235,.35));
  font-size: 15px;
}

.screen-home.paper .primary span { float: right; opacity: .7; }

.screen-home.paper .foot-note {
  text-align: center;
  font-size: 10px;
  color: var(--paper-ink-soft);
  opacity: .8;
  margin: 18px 0 0;
}

/* ============ 陪伴 ============ */

.screen-crystal.companion { padding-bottom: 96px; }

.screen-crystal.companion .companion-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 8px;
}

.screen-crystal.companion .companion-top h1 { margin: 0; font-size: 26px; letter-spacing: 1px; }

.screen-crystal.companion .companion-top small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, .72);
}

.screen-crystal.companion .companion-acts { display: flex; align-items: center; gap: 8px; }

.screen-crystal.companion .pill-btn {
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .26);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 12.5px;
}

.screen-crystal.companion .avatar-round {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .28);
}

.screen-crystal.companion .avatar-round img { width: 100%; height: 100%; object-fit: cover; }

/* 顶部 LIVE 卡（demo 的三行问候） */
.screen-crystal.companion .live-card {
  margin: 6px 20px 0;
  padding: 12px 14px 14px;
  border-radius: 16px;
  background: rgba(30, 34, 64, .38);
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(10px);
}

.screen-crystal.companion .live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.screen-crystal.companion .live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(226, 74, 74, .92);
  font-size: 10px;
  letter-spacing: .08em;
  color: #fff;
}

.screen-crystal.companion .live-dot i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
}

.screen-crystal.companion .log-btn {
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 11.5px;
}

.screen-crystal.companion .live-quota { margin-left: auto; font-size: 11px; color: rgba(255, 255, 255, .68); }

.screen-crystal.companion .live-title { margin: 0; font-size: 21px; line-height: 1.45; color: #fff; }
.screen-crystal.companion .live-sub { white-space: pre-line; margin: 6px 0 0; font-size: 13px; color: rgba(255, 255, 255, .78); }

/* 立绘 */
.screen-crystal.companion .companion-stage {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 240px;
}

.screen-crystal.companion .companion-art {
  width: min(78%, 300px);
  filter: drop-shadow(0 18px 30px rgba(30, 34, 70, .35));
}

/* dock */
.screen-crystal.companion .companion-dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 84px;
  width: min(398px, calc(100vw - 32px));
  z-index: 9;
  display: grid;
  gap: 8px;
}

.screen-crystal.companion .starters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 2px;
}

.screen-crystal.companion .starters::-webkit-scrollbar { display: none; }

.screen-crystal.companion .starters button {
  flex: none;
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .86);
  color: #2b2b3c;
  font-size: 12.5px;
  white-space: nowrap;
}

.screen-crystal.companion .say-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 12px 30px rgba(24, 28, 60, .28);
}

.screen-crystal.companion .say-form input {
  flex: 1;
  border: 0;
  background: none;
  font-size: 14.5px;
  color: #2b2b3c;
  outline: none;
  min-width: 0;
}

.screen-crystal.companion .say-form button {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(120deg, #8f7bff, #b18cff);
  color: #fff;
  font-size: 16px;
}

.screen-crystal.companion .dock-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  font-size: 11.5px;
  color: #3a3f57;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}

.screen-crystal.companion .dock-meta span { margin-right: auto; font-variant-numeric: tabular-nums; }

.screen-crystal.companion .dock-meta button {
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .86);
  padding: 4px 10px;
  border-radius: 999px;
  color: #2b2b3c;
  font-size: 11.5px;
}

/* 聊天记录弹层 */
.chat-log-wrap { display: grid; gap: 10px; }
.cl-title { margin: 0; font-size: 16px; }
.chat-log { display: grid; gap: 10px; max-height: 56vh; overflow-y: auto; }
.log-row { margin: 0; font-size: 13.5px; line-height: 1.6; color: #2b2b3c; }
.log-row b { display: block; font-size: 11.5px; color: #8b8fa8; font-weight: 600; }
.chat-log-empty { margin: 0; font-size: 13.5px; color: #8b8fa8; }

@media (max-width: 380px) {
  .screen-home.paper .hero { height: 260px; }
  .screen-home.paper .hero-title { top: 95px; }
  .screen-home.paper .daily img { height: 88px; }
  .screen-home.paper .section-heading { margin-top: 17px; }
}

/* demo 版陪伴没有气泡列表面板：消息仍加载，但只在「聊天记录」里看 */
.screen-crystal.companion #chat-panel { display: none !important; }
.screen-crystal.companion .companion-stage { min-height: 320px; }

/* 故事阅读器（分页 + 页码 + 完成） */
.reader { display: grid; gap: 10px; }
.reader-head { display: flex; justify-content: space-between; font-size: 12px; color: #8b947e; }
.reader-title { margin: 0; font: 20px Story, serif; color: #344b43; }
.reader-text { margin: 0; font-size: 15px; line-height: 1.9; color: #3c4f44; min-height: 96px; }
.reader-actions { display: flex; gap: 10px; margin-top: 6px; }
.reader-btn { flex: 1; min-height: 44px; border-radius: 10px; font-size: 14px; border: 1px solid #4f6c59; }
.reader-btn.primary { background: var(--paper-accent); border-color: var(--paper-accent); color: #fffef4; }
.reader-btn.ghost { background: #fbfcf6; color: var(--paper-accent); }

.screen-crystal.companion .show-all {
  margin-top: 6px;
  border: 1px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.86);
  color: #2b2b3c;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11.5px;
  min-height: 32px;
}

/* 发送后：快捷短语收起，「你：xxx」一行（demo 行为） */
.screen-crystal.companion .starters[hidden] { display: none; }
.screen-crystal.companion .last-user {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* textarea 版输入（demo）：单行起，最高 88px，Enter 发送 */
.screen-crystal.companion .say-form textarea {
  flex: 1;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  color: #2b2b3c;
  resize: none;
  outline: none;
  min-width: 0;
  max-height: 88px;
  padding: 6px 0;
}
.screen-crystal.companion .say-form button[disabled] {
  opacity: .45;
  background: #b7b2d6;
}
.screen-crystal.companion .live-actions { display: flex; gap: 8px; margin-top: 6px; }
.cl-sub { margin: -4px 0 8px; font-size: 12px; color: #8b8fa8; }
.cl-back {
  margin-top: 12px;
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--paper-accent);
  background: var(--paper-accent);
  color: #fffef4;
  font-size: 14px;
}

/* 翻书：全屏 iframe 覆盖（不进 sheet，跟着 demo 的"整屏书"形态） */
.book-host {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #171320;
  display: block;
}
.book-host iframe { width: 100%; height: 100%; border: 0; display: block; }

.screen-crystal.companion .skill-entry {
  margin-top: 6px;
  border: 1px solid rgba(185, 138, 46, .5);
  background: rgba(185, 138, 46, .16);
  color: #fff7e8;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  min-height: 32px;
}

/* 答案之书问答弹层 */
#skill-q {
  width: 100%;
  border: 1px solid #d5ddcf;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  background: #fff;
  color: #2b2b3c;
}
.skill-answer {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 10px;
  background: #f6f0e2;
  color: #3b342c;
  font-family: "Source Han Serif SC", Georgia, serif;
  font-size: 16px;
  line-height: 1.9;
  white-space: pre-line;
}

.book-close {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 70;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(30,28,20,.42);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  backdrop-filter: blur(8px);
}

/* Demo integration: cancel the old fixed-height home layout, not the shared navigation. */
.screen-home.paper { display: block; height: auto; min-height: var(--app-h, 100dvh); padding: 0 0 calc(110px + env(safe-area-inset-bottom)); }
.screen-home.paper::before { display: none; }
.screen-home.paper .hero { background-image: linear-gradient(0deg,#f6f5ee,transparent 37%),url('/story/assets/p01.jpg'); }
.screen-home.paper .hero-title h2 { color: #344b43; }
.screen-home.paper .daily>span { min-width: 0; }
.screen-home.paper button { font-family: inherit; cursor: pointer; }
.screen-home.paper .top small { display: block; }
.reading-story { overflow: hidden; }
.book-host { z-index: 100; }
.book-close { position: absolute; right: max(12px, calc((100vw - 460px)/2 + 12px)); z-index: 2; }

/* The companion keeps the demo's open stage and floating text, with live account data. */
.screen-crystal.companion { position: relative; margin: 0; padding: 0; min-height: 460px; }
.screen-crystal.companion::before { content: ''; position: absolute; inset: 0 calc(-1 * var(--pad-x)) auto; height: 52%; background: linear-gradient(#16102c8f,#16102c4d 28%,transparent 64%); pointer-events: none; }
.screen-crystal.companion .companion-top { position: relative; z-index: 3; padding: 18px 0 2px; color: #fff; flex: 0 0 auto; }
.screen-crystal.companion .companion-top h1 { font-size: 26px; color: #fff; }
.screen-crystal.companion .avatar-round { padding: 0; background: #ffffff30; }
.screen-crystal.companion .live-card { position: absolute; top: 92px; left: 0; z-index: 3; width: min(86%,350px); margin: 0; padding: 0; border: 0; border-radius: 0; background: none; backdrop-filter: none; }
.screen-crystal.companion .live-card::before { content: ''; position: absolute; z-index: -1; inset: -18px -22px -20px -24px; background: radial-gradient(110% 100% at 18% 18%,#16102c9e,#16102c61 52%,transparent 78%); filter: blur(10px); pointer-events: none; }
.screen-crystal.companion .live-head { flex-wrap: wrap; margin-bottom: 12px; }
.screen-crystal.companion .live-dot { border-radius: 5px; background: #e0453a; font-size: 11px; padding: 3px 9px; }
.screen-crystal.companion .live-quota { display: flex; align-items: center; gap: 4px; color: #ffffffc7; font-size: 10px; }
.screen-crystal.companion .live-title { font-size: 23px; margin: 0 0 7px; line-height: 1.28; }
.screen-crystal.companion .live-sub { max-height: 112px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.7; color: #fff; margin: 0 0 10px; scrollbar-width: thin; }
.screen-crystal.companion .show-all { padding: 3px 0; border: 0; border-bottom: 1px solid #ffffff4d; border-radius: 0; background: none; color: #fff; font-size: 11px; min-height: 25px; margin: 0; }
.screen-crystal.companion [hidden] { display: none !important; }
.screen-crystal.companion .last-user { font-size: 15px; line-height: 1.65; color: #fffffff2; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 74px; overflow: auto; text-overflow: clip; }
.screen-crystal.companion .companion-stage { position: absolute; inset: 170px 0 65px; min-height: 0; display: grid; place-items: end center; }
.screen-crystal.companion .companion-art { width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center bottom; }
.screen-crystal.companion .speak-bubble { display: none !important; }
.screen-crystal.companion .companion-dock { bottom: calc(var(--nav-inset-b) + var(--sab) + var(--nav-h) + 39px); width: calc(100% - 36px); max-width: calc(var(--app-w) - 36px); z-index: 22; gap: 8px; }
body.nav-hidden .screen-crystal.companion .companion-dock { bottom: calc(var(--nav-inset-b) + var(--sab) + 44px); }
.screen-crystal.companion .starters { justify-content: center; gap: 8px; padding: 0; }
.screen-crystal.companion .starters button { height: auto; min-height: 28px; font-size: 11px; padding: 5px 11px; color: #656386; background: #ffffff82; border: 1px solid #ffffff8c; }
.screen-crystal.companion .say-form { padding: 9px 10px 9px 17px; border: 1px solid #ffffff9c; border-radius: 26px; background: linear-gradient(125deg,#ffffffd9,#e9edffb3); box-shadow: inset 0 1px 1px #fff,0 8px 24px #4b4e8021; backdrop-filter: blur(22px); }
.screen-crystal.companion .say-form textarea { font-size: 16px; line-height: 22px; padding: 5px 0; color: #454476; }
.screen-crystal.companion .say-form textarea::placeholder { color: #8384a4; font-size: 14px; }
.screen-crystal.companion .say-form button { width: 36px; height: 36px; border: 1px solid #ffffff96; background: linear-gradient(140deg,#b6a7e8,#838abf); font-size: 22px; }
.screen-crystal.companion .skill-entry { justify-self: center; margin: 0; padding: 6px 14px; border: 1px solid #ffffffa6; background: #f1edffef; color: #625a87; font-size: 12px; }
.screen-crystal.companion .dock-meta { display: none; }
.screen-crystal.companion.is-editing .dock-meta { display: flex; }
.screen-crystal.companion.is-editing .starters,
.screen-crystal.companion.is-editing .nav,
.screen-crystal.companion.is-editing .nav-toggle { visibility: hidden; pointer-events: none; }
.screen-crystal.companion.is-editing .companion-dock { bottom: calc(var(--kb,0px) + 12px + env(safe-area-inset-bottom)); }
.chat-log-wrap .log-row { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.chat-log-wrap .log-row.mine { align-items: flex-end; }
.chat-log-wrap .log-row p { margin: 0; max-width: 90%; border: 1px solid #fff; border-radius: 4px 17px 17px; padding: 12px 15px; background: #ffffffc9; color: #45446a; font-size: 16px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-log-wrap .log-row.mine p { background: #dcd9f8; border-radius: 17px 4px 17px 17px; }

.companion-stage .home-fox { position: relative; width: 100%; height: 100%; min-height: 0; display: grid; place-items: end center; }
.companion-stage.has-companion-fox > .companion-art { display: none; }
.companion-stage .fox-still,.companion-stage .fox-svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }
.companion-stage .fox-svg svg { width: 100%; height: 100%; overflow: visible; }
.companion-stage .has-svg .fox-still,.companion-stage .is-idle .fox-svg,.companion-stage .is-idle .fox-still { opacity: 0; }
.companion-stage .fox-act { position: absolute; bottom: 0; width: 100%; max-height: 100%; object-fit: contain; object-position: center bottom; opacity: 0; pointer-events: none; }
.companion-stage .is-acting .fox-act,.companion-stage .fox-act.on { opacity: 1; }
.companion-stage .fox-veil { position: absolute; inset: 0; background: #171c32; opacity: 0; pointer-events: none; }
.companion-stage .is-acting:not(.no-alpha) .fox-veil { opacity: .85; }
.companion-stage .fox-gl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; }
.companion-stage .fox-gl.on { opacity: 1; }
.companion-stage .fox-src { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.companion-stage .no-alpha .fox-act:not(.hevc),.companion-stage .no-alpha .fox-veil { display: none; }
.companion-stage .no-alpha .fox-svg { opacity: 1; }
.companion-stage .no-alpha.video-on .fox-svg { display: none; }
.companion-stage .no-alpha .fox-act.hevc { display: block; }
@media(min-width:600px) { .screen-home.paper .hero { height: 340px; } }
@media(max-height:700px) { .screen-home.paper .hero { height: 260px; margin-top: -77px; } .screen-home.paper .top { height: 77px; } .screen-home.paper .hero-title { top: 95px; } .screen-crystal.companion .companion-stage { top: 150px; bottom: 50px; } .screen-crystal.companion .live-card { top: 80px; } .screen-crystal.companion .live-sub { max-height: 72px; } }
@media(prefers-reduced-motion:reduce) { .companion-stage * { animation: none !important; transition: none !important; } }

/* H5 fills the actual viewport. No centered device frame or duplicate outer gutter. */
body.h5-home,body.h5-companion { --app-w: 100vw; margin: 0; overflow-x: hidden; }
body.h5-companion { overflow: hidden; }
body.h5-home #app,body.h5-companion #app { width: 100%; max-width: none; margin: 0; box-shadow: none; }
body.h5-home #app { padding: 0; }
body.h5-companion #app {
  padding: 0 max(var(--pad-x), env(safe-area-inset-right)) var(--app-pad-b) max(var(--pad-x), env(safe-area-inset-left));
}
.screen-home.paper { max-width: none; width: 100%; margin: 0; box-shadow: none; }
.screen-home.paper .nav,.screen-crystal.companion .nav { max-width: none; }
.screen-crystal.companion { height: calc(var(--app-h) - var(--app-pad-b)); }
.screen-crystal.companion .companion-dock { max-width: none; }
.screen-crystal.companion .companion-art,.companion-stage .home-fox { max-width: min(100%, 65dvh); }
.book-close { right: max(12px, env(safe-area-inset-right)); }

/* Mainline companion: same DOM rhythm and spacing as demo/companion-chat. */
.companion-live { position: relative; }
.companion-live .topbar { position: relative; z-index: 4; }
.companion-live .demo-log-button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid #ffffff50;
  border-radius: 18px;
  background: #ffffff1c;
  color: white;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.companion-live .home-live { pointer-events: auto; }
.companion-live .home-live > .demo-log-button { margin-left: 10px; height: 26px; }
.companion-live .hl-live { display: inline-flex; }
.companion-live .hl-sub {
  display: block;
  max-height: 112px;
  overflow: auto;
  white-space: pre-wrap;
  -webkit-line-clamp: unset;
  margin-bottom: 10px;
  color: #fff;
  line-height: 1.7;
  font-size: 14px;
  scrollbar-width: thin;
}
.companion-live .hl-title { font-size: 23px; margin-bottom: 7px; }
.companion-live .demo-last-user {
  max-width: 100%;
  max-height: 74px;
  margin-top: 10px;
  overflow: auto;
  color: #fffffff2;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 4px #20244299;
  scrollbar-width: thin;
}
.companion-live .demo-live-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 25px;
}
.companion-live .demo-live-actions button {
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid #ffffff4d;
  background: none;
  color: #fff;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.companion-live .demo-live-actions button[hidden] { display: none; }
.companion-live .demo-live-actions button:disabled { opacity: .4; cursor: default; }
.companion-live .home-fox { min-height: 0; }
.companion-live > .companion-art {
  width: min(82%, 300px);
  height: 100%;
  min-height: 0;
  margin: auto;
  object-fit: contain;
  object-position: center bottom;
}
.companion-live .chat-dock {
  position: fixed;
  z-index: 22;
  left: 50%;
  bottom: calc(var(--nav-inset-b) + var(--sab) + var(--nav-h) + 39px);
  width: calc(100% - 36px);
  max-width: calc(var(--app-w) - 36px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
  transition: bottom .3s ease;
}
body.nav-hidden .companion-live .chat-dock { bottom: calc(var(--nav-inset-b) + var(--sab) + 44px); }
.companion-live .demo-skill-entry {
  align-self: center;
  padding: 6px 14px;
  border: 1px solid #ffffffa6;
  border-radius: 18px;
  background: #f1edffef;
  color: #625a87;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.companion-live .dock-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.companion-live .dock-tools button {
  padding: 5px 11px;
  border: 1px solid #ffffff8c;
  border-radius: 20px;
  background: #ffffff82;
  color: #656386;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.companion-live .dock-tools[hidden] { display: none; }
.companion-live .chat-dock form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 10px 9px 17px;
  border: 1px solid #ffffff9c;
  border-radius: 26px;
  background: linear-gradient(125deg,#ffffffd9,#e9edffb3);
  box-shadow: inset 0 1px 1px #fff,0 8px 24px #4b4e8021;
  backdrop-filter: blur(22px);
}
.companion-live .chat-dock textarea {
  flex: 1;
  min-width: 0;
  max-height: 88px;
  padding: 5px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #454476;
  font: inherit;
  font-size: 16px;
  line-height: 22px;
  resize: none;
  scrollbar-width: thin;
}
.companion-live .chat-dock textarea::placeholder { color: #8384a4; font-size: 14px; }
.companion-live .chat-dock form:focus-within {
  border-color: #c5b4f5;
  box-shadow: 0 0 0 3px #ddd8ff4d,0 8px 28px #4b4e8021;
}
.companion-live .chat-send {
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid #ffffff96;
  border-radius: 50%;
  background: linear-gradient(140deg,#b6a7e8,#838abf);
  color: white;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 3px 9px #60598e26;
}
.companion-live .chat-send:disabled { opacity: .4; cursor: default; }
.companion-live .dock-meta {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: #66668d;
  font-size: 11px;
}
.companion-live .dock-meta button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: #595c86;
  font: inherit;
  cursor: pointer;
}
.companion-live.is-editing .dock-meta { display: flex; }
.companion-live.is-editing .chat-dock {
  bottom: calc(var(--kb,0px) + 12px + env(safe-area-inset-bottom));
  transition: none;
}
.companion-live.is-editing .dock-tools,
.companion-live.is-editing .nav,
.companion-live.is-editing .nav-toggle { visibility: hidden; pointer-events: none; }
.companion-live.is-editing .home-fox { opacity: .85; }
.companion-live #chat-panel { display: none; }
.companion-live .speak-bubble { display: none; }
.companion-live .demo-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}
@media(max-height:680px) {
  .companion-live .hl-sub { max-height: 72px; font-size: 13px; }
  .companion-live .hl-title { font-size: 20px; }
  .companion-live .chat-dock { gap: 6px; }
  .companion-live .dock-tools button { padding: 4px 9px; }
}
@media(max-height:480px) {
  .companion-live .home-live { top: 75px !important; }
  .companion-live .hl-live { display: none; }
  .companion-live .hl-sub { max-height: 44px; }
  .companion-live .hl-title { font-size: 17px; }
}


/* ---------- 屏幕适配 ---------- */
/* 手机/平板（≤900px）：纸色铺满整屏，页面铺满宽度，绝不出现"两侧空条" */
@media (max-width: 900px) {
  body:has(.screen-home.paper) { background: #f6f5ee !important; }
  .screen-home.paper { box-shadow: none; border-radius: 0; }
}
@media (max-width: 480px) {
  .screen-home.paper,
  body:has(.screen-home.paper) #app {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }
  /* 内容继续保留 23px 内边距（与 demo 一致），只是外框贴边 */
  .screen-home.paper .top { padding-left: 20px; padding-right: 20px; }
}

/* 真桌面（≥901px）：两侧用当天插画柔焦铺底，中间是 460 纸页 */
@media (min-width: 901px) {
  body:has(.screen-home.paper)::before {
    content: "";
    position: fixed;
    inset: -40px;
    z-index: -1;
    background: var(--paper-art, none) center / cover no-repeat;
    filter: blur(34px) saturate(1.05);
    opacity: .5;
  }
  body:has(.screen-home.paper)::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(80% 60% at 50% 40%, rgba(246,245,238,.3), rgba(220,226,215,.75));
  }
  .screen-home.paper { box-shadow: 0 24px 80px rgba(52,75,67,.18); border-radius: 6px; }
}

/* ---------- 手机兜底（全站，2026-11-05 复核） ----------
   实测 320/360/375/390/430 五个宽度下，7 个屏的 scrollWidth 都等于视口宽，
   本来就没有横向溢出；这两条只是防止将来某个新块写死宽度把页面撑开。 */
@media (max-width: 480px) {
  html, body { overflow-x: clip; }
  img, video, canvas { max-width: 100%; }
}

/* 陪伴 IP 待机视频：叠在立绘原位，透明 alpha 与背景自然融合 */
.companion-stage { position: relative; }
/* 视频在播时把静态图淡掉，避免边缘重影 */
.companion-stage[data-idle="video"] .companion-art { opacity: 0; transition: opacity .4s ease; }

/* ---------- 陪伴：LIVE 文案与待机视频的排版约束（2026-11-05） ---------- */
/* hl-title——模型有时一次回两段，不夹住会压到立绘上 */
.companion-live .hl-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 19px;
  line-height: 1.4;
}
.companion-live .hl-sub {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}

/* 待机视频：夹在 LIVE 卡与 dock 之间的一块舞台（绝对定位，按屏高自适应） */
/* 用 fixed 相对**视口**定位：.screen 比视口高时，absolute 的 bottom 会按整页算、算不准 */
.companion-stage {
  position: fixed;
  left: 0;
  right: 0;
  top: clamp(262px, 35vh, 330px);
  bottom: clamp(238px, 29vh, 262px);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.companion-stage .idle-video {
  position: static;
  width: auto;
  height: auto;
  max-width: 88%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 2;
}
.companion-stage[data-idle="video"] .companion-art { display: none; }

/* 快捷短语不要折成两行 */
.chat-dock .dock-tools button {
  white-space: nowrap;
  font-size: 12px;
  padding: 0 12px;
}

/* 快捷短语：横向可滚，但从左起、不被两侧裁掉一半 */
.chat-dock .dock-tools {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  overflow-x: auto;
  padding: 0 16px 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chat-dock .dock-tools::-webkit-scrollbar { display: none; }
.chat-dock .dock-tools button { flex: 0 0 auto; }

.companion-live .chat-dock .chat-plus {
  flex: none;
  width: 30px;
  height: 30px;
  margin-right: -4px;
  padding: 0;
  border: 1px solid #ffffff96;
  border-radius: 50%;
  background: #ffffffb3;
  color: #6f6a94;
  display: grid;
  place-items: center;
  line-height: 1;
  transition: transform .18s ease, background .18s ease;
}
.companion-live .chat-dock .chat-plus svg { display: block; width: 15px; height: 15px; }
.companion-live .chat-dock .chat-plus[aria-expanded="true"] {
  transform: rotate(45deg);
  background: var(--theme-accent-deep, #6f83cb);
  border-color: var(--theme-accent-deep, #6f83cb);
  color: #fff;
}

/* 加号菜单：三个外部玩法，左边说明右边动作 */
.plus-modules { display: flex; flex-direction: column; gap: 10px; }
.plus-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(125, 139, 196, .22);
  border-radius: 16px;
  background: rgba(247, 248, 255, .9);
}
.plus-item .pi-text { flex: 1; min-width: 0; }
.plus-item .pi-text b { display: block; font-size: 14.5px; color: #33324e; font-weight: 600; }
.plus-item .pi-text small { display: block; margin-top: 2px; font-size: 11.5px; color: #7d7c99; }
.plus-item .pi-acts { flex: none; display: flex; gap: 6px; }
.plus-item .pi-acts button {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}
.plus-item .pi-agent {
  border: 1px solid var(--theme-accent-deep, #6f83cb);
  background: var(--theme-accent-deep, #6f83cb);
  color: #fff;
}
.plus-item .pi-open {
  border: 1px solid rgba(125, 139, 196, .45);
  background: #fff;
  color: #5d6ca5;
}

/* 语音输入键：与发送键同尺寸的幽灵按钮，录音时呼吸高亮 */
.chat-dock .chat-mic {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .82);
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  color: #2b2b3c;
}
.chat-dock .chat-mic svg {
  display: block;
  width: 18px;
  height: 18px;
  overflow: visible;
}
.chat-dock .chat-mic.rec {
  background: var(--theme-accent-deep, #6f83cb);
  border-color: var(--theme-accent-deep, #6f83cb);
  color: #fff;
  animation: micPulse 1.1s ease-in-out infinite;
}
.chat-dock .chat-mic.working {
  opacity: .68;
  cursor: wait;
}
.chat-dock .chat-mic.working svg {
  animation: micWorking .8s ease-in-out infinite alternate;
}
.chat-dock .chat-mic.file-mode {
  border-color: rgba(125, 139, 196, .55);
  background: rgba(236, 240, 255, .94);
  color: #5d6ca5;
}
@keyframes micWorking {
  to { transform: scale(.82); opacity: .55; }
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(111, 131, 203, .55); }
  50% { box-shadow: 0 0 0 10px rgba(111, 131, 203, 0); }
}

/* 语音对话开关（dock-meta 行） */
.chat-dock #chat-voice-mode {
  border: 1px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.86);
  color: #2b2b3c;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  min-height: 26px;
}
.chat-dock #chat-voice-mode.on {
  background: var(--theme-accent-deep, #6f83cb);
  border-color: var(--theme-accent-deep, #6f83cb);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(111,131,203,.22);
}
/* 语音模式下麦克风常亮，提示正在免手对话 */
body.voice-mode .chat-dock .chat-mic {
  background: rgba(111,131,203,.16);
  border-color: var(--theme-accent-deep, #6f83cb);
}

/* 输入框两个圆钮：用 grid 居中，避免字形/图标基线造成 1px 偏移 */
.companion-live .chat-dock .chat-mic,
.companion-live .chat-dock .chat-send {
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}
.companion-live .chat-dock .chat-mic svg,
.companion-live .chat-dock .chat-send svg { display: block; }
