:root {
  --bg: #f4efe6;
  --panel: #fffaf2;
  --ink: #2b2620;
  --ink-soft: #7a7064;
  --ink-faint: #b3a99b;
  --line: #e6dccb;
  --me: #ffcf8a;
  --me-ink: #3a2a12;
  --them: #ffffff;
  --accent: #e8893a;
  --accent-ink: #ffffff;
  --narr: #8c8275;
  --os-bg: #2f2b33;
  --os-ink: #f1ecf7;
  --studio: #22313a;
  --studio-ink: #eef3f5;
  --card: #fff3dc;
  --radius: 16px;
  --font: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: #e9e2d6;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}
button { font-family: inherit; }

#app {
  position: relative;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(60, 40, 10, .08);
}

.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* 通用按钮 */
.btn {
  border: 0; border-radius: 999px; padding: 13px 28px;
  font-size: 16px; cursor: pointer; transition: transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }

/* 标题页 */
.title-wrap {
  margin: auto; padding: 0 28px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.title-cats { display: flex; gap: 6px; margin-bottom: 6px; }
.title-cats svg { width: 84px; height: 84px; }
h1 { font-size: 34px; line-height: 1.25; margin: 0; letter-spacing: 1px; }
.subtitle { margin: 0 0 14px; color: var(--ink-soft); }
.tiny { font-size: 12px; color: var(--ink-faint); margin: 4px 0 0; }

/* 性别选择 */
.setup-wrap { margin: auto; width: 100%; padding: 0 24px; display: flex; flex-direction: column; gap: 22px; }
.setup-wrap h2 { text-align: center; margin: 0 0 6px; font-size: 22px; }
.setup-row {
  display: flex; gap: 14px; align-items: center;
  background: var(--panel); border-radius: var(--radius); padding: 14px;
}
.setup-avatar svg { width: 64px; height: 64px; display: block; }
.setup-name { font-weight: 600; }
.setup-desc { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.seg { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 6px 16px; border-radius: 999px;
  font-size: 14px; color: var(--ink-soft); cursor: pointer;
}
.seg button.on { background: var(--accent); color: #fff; }
#btn-setup-go { align-self: center; margin-top: 6px; }

/* 聊天 */
.chat-head {
  flex: none; height: 54px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.chat-title { display: flex; flex-direction: column; line-height: 1.2; }
#chat-name { font-weight: 600; font-size: 17px; }
.typing-tip { font-size: 11px; color: var(--ink-soft); min-height: 13px; }
.chapter-tag { font-size: 12px; color: var(--ink-faint); }

.banner {
  position: absolute; left: 10px; right: 10px; top: -80px; z-index: 5;
  background: rgba(40, 34, 28, .92); color: #fff; border-radius: 14px;
  padding: 10px 14px; font-size: 14px; transition: top .35s ease;
  display: flex; gap: 10px; align-items: center;
}
.banner.show { top: 8px; }
.banner svg { width: 30px; height: 30px; flex: none; }
.banner b { display: block; font-size: 13px; }

.chat-body {
  flex: 1; overflow-y: auto; padding: 14px 12px 20px;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
}
.row { display: flex; gap: 8px; align-items: flex-start; max-width: 100%; }
.row.me { flex-direction: row-reverse; }
.row .ava svg { width: 36px; height: 36px; display: block; }
.bubble {
  max-width: 72%; padding: 8px 12px; border-radius: 14px;
  background: var(--them); word-break: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
  animation: pop .18s ease-out;
}
.row.me .bubble { background: var(--me); color: var(--me-ink); }
.bubble.pic {
  background: #e7ded0; color: var(--ink-soft); font-size: 13px;
  width: 150px; height: 112px; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 10px; border-radius: 10px;
}
.bubble.sticker { background: transparent; box-shadow: none; font-size: 13px; color: var(--ink-soft); padding: 0; }
.bubble.sticker span { display: block; font-size: 44px; line-height: 1.1; }
.read-mark { font-size: 11px; color: var(--ink-faint); align-self: flex-end; margin: -4px 50px 0 0; }
.time { align-self: center; font-size: 12px; color: var(--ink-faint); margin: 8px 0 2px; }
.gap {
  align-self: center; font-size: 12px; color: var(--ink-soft);
  background: rgba(0, 0, 0, .05); border-radius: 999px; padding: 2px 12px; margin: 6px 0;
}
.narr {
  align-self: center; text-align: center; color: var(--narr); font-size: 14px;
  max-width: 88%; margin: 8px 0; animation: fade .4s ease-out;
}
.chapter-card {
  align-self: center; text-align: center; margin: 18px 0 8px;
  font-size: 13px; color: var(--ink-soft); letter-spacing: 2px;
}
.chapter-card b { display: block; font-size: 22px; color: var(--ink); letter-spacing: 4px; margin-top: 4px; }

.chat-foot {
  flex: none; min-height: 56px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.hint { text-align: center; font-size: 12px; color: var(--ink-faint); padding: 8px 0; }
.choice-prompt { font-size: 13px; color: var(--ink-soft); margin: 0 4px 8px; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  text-align: left; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 10px 12px; font-size: 15px; cursor: pointer; line-height: 1.45;
  animation: rise .2s ease-out;
}
.choice:active { background: var(--card); }
.choice small { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.foot-btn { width: 100%; }

/* 观察室 */
#screen-obs { background: var(--studio); color: var(--studio-ink); }
.obs-head {
  flex: none; height: 54px; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.obs-title { font-weight: 600; letter-spacing: 2px; }
.obs-body { flex: 1; overflow-y: auto; padding: 16px 14px 24px; display: flex; flex-direction: column; gap: 12px; }
.obs-foot { flex: none; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); }
.obs-foot .btn { width: 100%; }
.obs-narr { text-align: center; color: #9fb1ba; font-size: 13px; animation: fade .4s; }
.say { display: flex; gap: 10px; align-items: flex-start; animation: rise .25s ease-out; }
.say .ava svg { width: 40px; height: 40px; display: block; }
.say .who { font-size: 12px; color: #9fb1ba; margin-bottom: 2px; }
.say .line {
  background: rgba(255, 255, 255, .08); border-radius: 14px; padding: 8px 12px;
  max-width: 80%; white-space: pre-wrap;
}
.say.owl .line { background: rgba(255, 214, 150, .14); }

.os-block { background: var(--os-bg); color: var(--os-ink); border-radius: var(--radius); padding: 12px 14px; animation: rise .3s; }
.os-block h3 { margin: 0 0 8px; font-size: 14px; color: #c9b8e8; font-weight: 600; }
.os-item { padding: 8px 0; border-top: 1px dashed rgba(255, 255, 255, .12); font-size: 14px; }
.os-item:first-of-type { border-top: 0; }
.os-item .tag { display: block; font-size: 11px; color: #a99cc0; margin-bottom: 2px; }

.cards { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.card { background: var(--card); color: var(--ink); border-radius: 12px; overflow: hidden; animation: rise .25s; }
.card summary { padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; }
.card summary::-webkit-details-marker { display: none; }
.card summary::before { content: "📎 "; }
.card p { margin: 0; padding: 0 14px 12px; font-size: 14px; color: #4a4036; }

/* 阶段小结 */
.end-wrap {
  margin: auto; padding: 24px; width: 100%;
  display: flex; flex-direction: column; gap: 16px; align-items: center; text-align: center;
}
.share-card {
  width: 100%; background: var(--panel); border-radius: 20px; padding: 24px 20px;
  box-shadow: 0 6px 24px rgba(80, 50, 10, .08);
}
.share-card .cats { display: flex; justify-content: center; gap: 4px; }
.share-card .cats svg { width: 58px; height: 58px; }
.share-card .label { font-size: 12px; color: var(--ink-faint); letter-spacing: 2px; margin-top: 10px; }
.share-card h2 { margin: 6px 0 10px; font-size: 24px; }
.share-card p { margin: 0; color: var(--ink-soft); }
.share-card .sign { margin-top: 16px; font-size: 12px; color: var(--ink-faint); }
.end-note { font-size: 13px; color: var(--ink-soft); margin: 0; }
.end-btns { display: flex; gap: 10px; }
.disclaimer { font-size: 11px; color: var(--ink-faint); margin: 8px 0 0; line-height: 1.6; }

@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* 选角色 */
.role-card {
  display: flex; gap: 14px; align-items: center; text-align: left; width: 100%;
  background: var(--panel); border: 2px solid transparent; border-radius: var(--radius);
  padding: 14px; cursor: pointer; font-size: 16px; color: var(--ink);
}
.role-card:active { border-color: var(--accent); }

/* 打字回复 */
.type-row { display: flex; gap: 8px; }
.type-row input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 14px; font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
}
.type-row input:focus { outline: none; border-color: var(--accent); }
.type-row button { flex: none; border: 0; border-radius: 999px; padding: 0 16px; background: var(--accent); color: #fff; font-size: 15px; cursor: pointer; }
.type-row button:disabled { opacity: .4; }
.type-alt { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.type-alt .act {
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.type-alt .link { border: 0; background: none; color: var(--ink-faint); font-size: 12px; cursor: pointer; margin-left: auto; padding: 4px 0; }

/* 小问卷 */
.quiz-wrap { margin: auto; width: 100%; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.quiz-progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.quiz-bar { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.quiz-count { font-size: 12px; color: var(--ink-faint); }
.quiz-intro { margin: 0; font-size: 13px; color: var(--ink-soft); }
.quiz-q { font-size: 20px; line-height: 1.5; margin: 8px 0 10px; min-height: 60px; }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.quiz-opts button {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 12px;
  padding: 12px; font-size: 15px; cursor: pointer; text-align: left;
}
.quiz-opts button.on { border-color: var(--accent); background: var(--card); }
.quiz-back { align-self: flex-start; border: 0; background: none; color: var(--ink-faint); font-size: 13px; cursor: pointer; padding: 6px 0; }

/* 结果 */
.result-cat svg { width: 96px; height: 96px; }
.bars { width: 100%; display: flex; flex-direction: column; gap: 10px; margin: 14px 0 4px; text-align: left; }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.tip { width: 100%; background: var(--card); border-radius: 12px; padding: 10px 14px; font-size: 14px; text-align: left; color: #4a4036; }
.tip b { display: block; font-size: 12px; color: var(--accent); margin-bottom: 2px; }
.recap { font-size: 13px; color: var(--ink-soft); margin: 0; }

/* 类型解释 */
.kind-box { margin-top: 14px; text-align: left; font-size: 14px; color: #4a4036; background: var(--bg); border-radius: 12px; padding: 10px 14px; }
.kind-box b { display: block; font-size: 12px; color: var(--ink-faint); font-weight: 400; margin-bottom: 2px; }
.kind-box .kind { display: inline-block; font-weight: 600; color: var(--ink); margin-right: 6px; }

/* 四只猫对照 */
.grid-box { width: 100%; background: var(--panel); border-radius: 16px; padding: 4px 14px; text-align: left; }
.grid-box summary { padding: 10px 0; font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.grid-box summary::-webkit-details-marker { display: none; }
.grid-box summary::after { content: " ›"; color: var(--ink-faint); }
.grid-box[open] summary::after { content: " ⌄"; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-faint); }
.axis-top span { flex: 1; text-align: center; }
.axis-side { margin-top: 6px; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.cell { background: var(--bg); border-radius: 12px; padding: 10px 8px; text-align: center; border: 2px solid transparent; }
.cell.me { border-color: var(--accent); }
.cell-ava svg { width: 44px; height: 44px; }
.cell-name { font-weight: 600; font-size: 14px; }
.cell-name em { font-style: normal; font-size: 10px; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 6px; margin-left: 4px; vertical-align: 2px; }
.cell-kind { font-size: 12px; color: var(--accent); }
.cell-short { font-size: 12px; color: var(--ink-soft); margin-top: 2px; line-height: 1.4; }
.grid-note { font-size: 11px; color: var(--ink-faint); margin: 8px 0 10px; line-height: 1.6; }
