/* =========================================================================
 * styles.css — AI 亲密关系教练 · 全局 UI 规范
 * 深空紫 / 雾紫底色 · 柔雾粉点缀 · 16-24px 大圆角 · 圆润字体
 * 柔和治愈 · 淡入+微微上浮过渡
 * ========================================================================= */

:root {
  /* 底色：深空紫 → 雾紫 渐变 */
  --bg-0: #150f24;
  --bg-1: #1d1533;
  --bg-2: #271a40;

  /* 卡片 / 表面 */
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --surface-solid: #2a1f44;

  /* 柔雾粉（低饱和）点缀 */
  --pink: #e3a9cf;
  --pink-soft: rgba(227, 169, 207, 0.16);
  --pink-line: rgba(227, 169, 207, 0.34);

  /* 文字 */
  --text: #f4eef8;
  --text-dim: #b9aed0;
  --text-faint: #8a7ea6;

  /* 圆角 */
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 14px;

  /* 字体：优先圆润中文字体，叠加圆体拉丁字体 */
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Quicksand", "Nunito", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2c1f49 0%, transparent 60%),
    linear-gradient(165deg, var(--bg-1) 0%, var(--bg-0) 55%, #120c20 100%);
  background-attachment: fixed;
}

/* 应用容器：移动端优先，最大宽度约束，居中 */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================ 顶部栏 ============================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  /* 关键修复：适配刘海屏安全区，padding-top 45~50px */
  padding: calc(env(safe-area-inset-top, 0px) + 46px) 18px 12px;
  background: linear-gradient(180deg, rgba(21,15,36,0.96) 60%, rgba(21,15,36,0));
  backdrop-filter: blur(8px);
}
.topbar.home { padding-bottom: 4px; }
.topbar .title { font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease;
}
.back-btn:active { transform: scale(.95); background: var(--pink-soft); }
.back-btn svg { width: 16px; height: 16px; }

/* ============================ 页面主体 ============================ */
.page {
  flex: 1;
  padding: 8px 18px calc(env(safe-area-inset-bottom, 0px) + 96px);
  /* 柔和过渡：淡入 + 微微上浮 */
  animation: pageIn .42s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================ 首页 ============================ */
/* 居中大标题：一眼看懂这个工具是做什么的 */
.hero {
  padding: 18px 6px 16px;
  text-align: center;
}
.hero h1 {
  font-size: 32px;
  line-height: 1.2;
  margin: 0 0 10px;
  font-weight: 800;
  letter-spacing: .5px;
}
.hero-sub {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
  margin: 0 0 10px;
}
.hero-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0 auto 12px;
  max-width: 92%;
}
.hero-tags {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hero-tag {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,.08);
  padding: 4px 10px;
  border-radius: 999px;
}

/* 模式大卡片：压矮、更中性，图标叠在标题上方，不与标题同行 */
.mode-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(150deg, rgba(255,255,255,.09), rgba(255,255,255,.04));
  border-radius: var(--r-lg);
  padding: 14px;
  margin: 0;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  transition: transform .18s ease, box-shadow .25s ease, border-color .2s ease;
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
}
.mode-card:active { transform: translateY(2px) scale(.99); }
.mode-card:hover { border-color: rgba(255,255,255,.22); }
.mode-card .mc-emoji {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: rgba(255,255,255,.08);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.mode-card .mc-emoji svg { width: 18px; height: 18px; stroke: var(--text-dim); }
.mode-card .mc-body { flex: 1 1 auto; display: block; }
.mode-card h2 { font-size: 16px; margin: 0 0 3px; font-weight: 700; }
.mode-card .mc-sub { font-size: 12px; color: var(--text-dim); line-height: 1.45; margin: 0; }
.mode-card .mc-cta {
  display: block;
  margin-top: auto;
  padding-top: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.mode-card .mc-tag { display: none; }

/* 底部「直接和 AI 教练聊聊」按钮：简洁描边，不抢视觉 */
.chat-cta {
  width: 100%;
  border: 1px solid rgba(255,255,255,.14);
  background: transparent;
  color: var(--text);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .2s ease, transform .15s ease;
}
.chat-cta:active { transform: scale(.98); }
.chat-cta:hover { background: rgba(255,255,255,.06); }

/* ===================== 首页整屏布局（一屏装下·不滚动） ===================== */
.page.home-page {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
}
/* hero 贴顶部，内部元素紧凑居中 */
.home-page > .hero { flex: 0 0 auto; }
/* 卡片组：占据剩余空间，两张卡片均匀分布，上下留白呼吸 */
.home-cards {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 6px 0;
}
.home-page .mode-card {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  justify-content: flex-start;
  padding: 16px;
}
.home-page .mode-card .mc-emoji { margin-bottom: 10px; }
.home-page .mode-card .mc-body { flex: 0 0 auto; }
.home-page .mode-card .mc-cta { margin-top: auto; padding-top: 10px; }
/* 底部按钮和说明均匀分布 */
.home-page > .chat-cta { flex: 0 0 auto; margin-top: 12px; }
.home-page > .muted { flex: 0 0 auto; margin: 10px 0 0; font-size: 11px; }

/* ============================ 通用卡片 ============================ */
.card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--r-md);
  padding: 18px;
  margin: 14px 0;
}
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card p { color: var(--text-dim); font-size: 14px; line-height: 1.75; margin: 6px 0; }

/* ============================ 答题页 ============================ */
.quiz-progress {
  display: flex; align-items: center; gap: 12px;
  margin: 4px 2px 14px;
}
.quiz-progress .bar {
  flex: 1; height: 8px; border-radius: 999px;
  background: rgba(255,255,255,.1); overflow: hidden;
}
.quiz-progress .bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--pink), #f3c6e2);
  border-radius: 999px; transition: width .35s ease;
}
.quiz-progress .num { font-size: 13px; color: var(--text-dim); white-space: nowrap; }

.q-title {
  font-size: 19px; line-height: 1.55; font-weight: 700;
  margin: 6px 2px 18px;
}
.q-dimension {
  display: inline-block; font-size: 12px; color: var(--pink);
  background: var(--pink-soft); padding: 3px 10px; border-radius: 999px;
  margin: 0 2px 14px;
}
.option {
  display: block; width: 100%; text-align: left;
  border: 1px solid rgba(255,255,255,.1);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.5;
  padding: 15px 16px;
  border-radius: var(--r-sm);
  margin: 10px 0;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .12s ease;
}
.option:active { transform: scale(.99); }
.option.sel {
  border-color: var(--pink);
  background: var(--pink-soft);
}
.option .o-key {
  display: inline-block; width: 22px; height: 22px; line-height: 22px;
  text-align: center; border-radius: 7px; margin-right: 10px;
  background: rgba(255,255,255,.1); font-size: 13px; font-weight: 700;
}
.option.sel .o-key { background: var(--pink); color: #2a1330; }

/* 答题导航 */
.quiz-nav {
  display: flex; gap: 12px; margin-top: 22px;
}
.btn {
  flex: 1;
  border: none; border-radius: 999px;
  padding: 15px; font-family: var(--font);
  font-size: 15.5px; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, opacity .2s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, #f3c6e2, #e3a9cf); color: #2a1330; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ============================ 报告页 ============================ */
.report-hero {
  text-align: center;
  padding: 8px 4px 6px;
}
.report-hero .badge {
  display: inline-block; font-size: 12px; color: var(--pink);
  background: var(--pink-soft); padding: 4px 12px; border-radius: 999px;
  margin-bottom: 10px;
}
.report-hero h1 { font-size: 22px; margin: 0 0 6px; font-weight: 800; }
.report-hero .lead { font-size: 14px; color: var(--text-dim); line-height: 1.7; }

/* 维度雷达条 */
.radar-row { margin: 12px 0; }
.radar-row .rl {
  display: flex; justify-content: space-between; font-size: 13px;
  color: var(--text-dim); margin-bottom: 6px;
}
.radar-row .rl b { color: var(--text); font-weight: 650; }
.radar-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,.09); overflow: hidden; }
.radar-track > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #c98bb6, #f3c6e2);
  border-radius: 999px;
}

.module {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--r-md);
  padding: 18px;
  margin: 14px 0;
  animation: pageIn .5s cubic-bezier(.22,.61,.36,1) both;
}
.module h3 {
  font-size: 16.5px; margin: 0 0 10px; font-weight: 750;
  display: flex; align-items: center; gap: 8px;
}
.module h3 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); }
.module p { font-size: 14px; line-height: 1.85; color: var(--text-dim); margin: 8px 0; }
.module p strong, .module b { color: var(--text); font-weight: 700; }
.module .letter {
  font-style: italic; color: var(--text); line-height: 1.9;
  border-left: 3px solid var(--pink-line); padding-left: 14px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  font-size: 12.5px; color: var(--pink); background: var(--pink-soft);
  padding: 6px 12px; border-radius: 999px;
}
.action-step {
  display: flex; gap: 12px; margin: 14px 0;
}
.action-step .n {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 9px;
  background: var(--pink-soft); color: var(--pink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.action-step .body { flex: 1; }
.action-step .body b { display: block; color: var(--text); font-size: 14.5px; margin-bottom: 3px; }
.action-step .body span { font-size: 13.5px; color: var(--text-dim); line-height: 1.7; }

/* ============================ 双人模式 ============================ */
.room-box { text-align: center; }
.room-id {
  font-size: 26px; letter-spacing: 6px; font-weight: 800;
  color: var(--pink); margin: 6px 0 4px;
}
.copy-btn {
  border: 1px solid var(--pink-line); background: var(--pink-soft);
  color: var(--pink); border-radius: 999px; padding: 9px 16px;
  font-family: var(--font); font-size: 13.5px; cursor: pointer; font-weight: 600;
}
.role-tabs { display: flex; gap: 10px; margin: 16px 0; }
.role-tab {
  flex: 1; text-align: center; padding: 14px; border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,.1); background: var(--surface);
  font-family: var(--font); font-size: 15px; color: var(--text-dim); cursor: pointer;
}
.role-tab.active { border-color: var(--pink); background: var(--pink-soft); color: var(--text); font-weight: 700; }

/* 李克特 1-5 选择 */
.likert { display: flex; gap: 8px; margin: 16px 0; }
.likert button {
  flex: 1; aspect-ratio: 1 / 1; border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,.1); background: var(--surface);
  color: var(--text); font-family: var(--font); font-size: 18px; font-weight: 750;
  cursor: pointer; transition: all .15s ease;
}
.likert button.sel { background: var(--pink); color: #2a1330; border-color: var(--pink); transform: scale(1.04); }
.likert-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint); margin-top: -6px; }

/* ============================ 聊天 ============================ */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow-y: auto; padding: 6px 2px 12px; }
.bubble { max-width: 84%; padding: 12px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.7; margin: 10px 0; animation: pageIn .3s ease both; }
.bubble.ai { background: var(--surface-2); border-top-left-radius: 6px; align-self: flex-start; }
.bubble.me { background: linear-gradient(135deg, #f3c6e2, #e3a9cf); color: #2a1330; border-top-right-radius: 6px; align-self: flex-end; margin-left: auto; }
.chat-input {
  display: flex; gap: 10px; padding: 12px 2px 4px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.chat-input input {
  flex: 1; border: 1px solid rgba(255,255,255,.12); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 13px 16px;
  font-family: var(--font); font-size: 14.5px; outline: none;
}
.chat-input input:focus { border-color: var(--pink); }
.chat-input button {
  border: none; border-radius: 999px; padding: 0 18px;
  background: linear-gradient(135deg, #f3c6e2, #e3a9cf); color: #2a1330;
  font-family: var(--font); font-weight: 700; font-size: 14.5px; cursor: pointer;
}
.chat-meta { text-align: center; font-size: 12px; color: var(--text-faint); padding: 6px 0 2px; }

/* 加载占位 */
.loading { text-align: center; padding: 40px 0; color: var(--text-dim); }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px;
  border: 3px solid rgba(255,255,255,.12); border-top-color: var(--pink);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-cta { text-align: center; margin: 26px 0; }
.muted { color: var(--text-faint); font-size: 12.5px; text-align: center; margin-top: 8px; }

/* ============================ 折叠卡片（一页一卡片） ============================ */
.fold-deck { margin: 16px 0 6px; }
.fold-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--r-md);
  overflow: hidden;
  animation: pageIn .45s cubic-bezier(.22,.61,.36,1) both;
}
.fold-card .fold-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; cursor: pointer; user-select: none;
}
.fold-num {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 9px;
  background: var(--pink-soft); color: var(--pink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.fold-title { flex: 1; font-size: 16px; font-weight: 700; }
.fold-chev { color: var(--pink); font-size: 16px; transition: transform .22s ease; }
.fold-card.open .fold-chev { transform: rotate(180deg); }
.fold-body {
  padding: 0 18px; max-height: 0; overflow: hidden;
  transition: max-height .32s ease, padding .32s ease;
}
.fold-card.open .fold-body { padding: 0 18px 18px; max-height: 1600px; }
.fold-body p { font-size: 14px; line-height: 1.85; color: var(--text-dim); margin: 8px 0; }
.fold-body p strong, .fold-body b { color: var(--text); font-weight: 700; }
.fold-body .letter { font-style: italic; color: var(--text); border-left: 3px solid var(--pink-line); padding-left: 14px; line-height: 1.9; }
.fold-body .radar-inside { padding: 6px 0; }

.fold-nav { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 14px 0 6px; }
.fold-arrow {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--pink-line); background: var(--surface-2);
  color: var(--text); font-size: 24px; line-height: 1; cursor: pointer;
  transition: transform .12s ease, background .2s ease;
}
.fold-arrow:active { transform: scale(.9); }
.fold-arrow[disabled] { opacity: .3; cursor: not-allowed; }
.fold-count { font-size: 14px; color: var(--text-dim); min-width: 58px; text-align: center; }
.fold-dots { display: flex; justify-content: center; gap: 8px; margin: 4px 0 8px; }
.fold-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); transition: all .2s ease; }
.fold-dots i.on { width: 22px; border-radius: 999px; background: var(--pink); }

/* 免责声明 */
.disclaimer {
  margin: 18px 0 4px; padding: 14px 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-sm);
  font-size: 12px; line-height: 1.7; color: var(--text-faint); text-align: left;
}

/* 海报按钮 */
.poster-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: none; border-radius: 999px;
  padding: 16px 20px; font-family: var(--font); font-size: 16px; font-weight: 800;
  color: #2a1330; background: linear-gradient(135deg, #f3c6e2, #e3a9cf);
  box-shadow: 0 12px 30px rgba(227,169,207,.35); cursor: pointer;
  transition: transform .14s ease;
}
.poster-btn:active { transform: scale(.97); }
.poster-btn svg { width: 18px; height: 18px; }

/* 海报弹窗 */
.poster-modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10,7,18,.8); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 22px;
  animation: pageIn .25s ease both;
}
.poster-sheet { width: 100%; max-width: 330px; text-align: center; }
.poster-img { width: 100%; border-radius: var(--r-md); box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.poster-actions { display: flex; gap: 12px; margin: 16px 0 6px; }
.poster-actions .btn { flex: 1; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
