/* ========== 情侣 MBTI 测试 — 样式（简约有质感版） ========== */
:root {
  --bg: #FAF8F6;
  --card: #FFFFFF;
  --line: #EBE6E2;
  --ink: #2B2626;
  --muted: #8C8580;
  --rose: #A96C78;
  --rose-deep: #96606B;
  --rose-soft: #F8EFF1;
  --violet: #8B7FA8;
  --violet-soft: #F0EEF6;
  --radius: 20px;
  --shadow: 0 12px 30px rgba(60, 40, 45, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 18px 56px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ========== 步骤切换 ========== */
.step { display: none; animation: fadeUp .35s ease both; }
.step.active { display: block; }

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

/* ========== 通用 ========== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 24px;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

h1 { font-size: 28px; line-height: 1.35; letter-spacing: .03em; }
h2 { font-size: 22px; line-height: 1.4; letter-spacing: .02em; }
h3 { font-size: 17px; }

.muted { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 16px; text-align: center; letter-spacing: .02em; }

/* 品牌 */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--rose);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3em;
}
.brand svg { flex: none; }

/* ========== 按钮 ========== */
.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 999px;
  padding: 14px 26px;
  letter-spacing: .06em;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--rose);
  color: #fff;
  box-shadow: 0 10px 22px rgba(169, 108, 120, .26);
}
.btn-primary:hover {
  background: var(--rose-deep);
  box-shadow: 0 12px 26px rgba(169, 108, 120, .34);
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--rose); color: var(--rose); }

.btn-lg { width: 100%; padding: 16px; font-size: 15px; }
.btn-block { width: 100%; margin-top: 14px; }

/* ========== 欢迎页 ========== */
.hero { text-align: center; }
.logo { width: 56px; height: 56px; margin: 6px auto 22px; display: block; }
.hero .brand { margin-bottom: 16px; }
.subtitle {
  color: var(--muted);
  margin: 14px auto 30px;
  font-size: 15px;
  line-height: 1.8;
  max-width: 300px;
}

.feature-list {
  list-style: none;
  text-align: left;
  margin-top: 36px;
  border-top: 1px solid var(--line);
}
.feature-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: #4A4240;
}
.feature-list svg { flex: none; width: 16px; height: 16px; color: var(--violet); }

/* ========== 填写称呼 ========== */
.step-head { text-align: center; margin-bottom: 24px; }
.step-head h2 { margin: 12px 0 8px; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--rose);
  background: var(--rose-soft);
  padding: 5px 14px;
  border-radius: 999px;
  letter-spacing: .04em;
}

.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--card);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.text-input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(169, 108, 120, .12); }
.text-input::placeholder { color: #B9B1AC; }

/* ========== 答题页 ========== */
.quiz-card { min-height: 320px; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.quiz-top .muted { font-size: 12px; font-variant-numeric: tabular-nums; }

.progress-track {
  height: 2px;
  background: #EEE9E5;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 36px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--violet), var(--rose));
  border-radius: 999px;
  transition: width .3s ease;
}

.quiz-question {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: .01em;
  margin-bottom: 28px;
  min-height: 92px;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  font-family: inherit;
  font-size: 14.5px;
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: #4A4240;
  cursor: pointer;
  text-align: center;
  letter-spacing: .02em;
  transition: all .14s ease;
  -webkit-tap-highlight-color: transparent;
}
.option:hover { border-color: var(--rose); }
.option.selected {
  border-color: var(--rose);
  background: var(--rose-soft);
  color: var(--rose);
  font-weight: 600;
}

#quiz-back { color: var(--muted); font-size: 13px; }

/* ========== 加载页 ========== */
.loading-card { text-align: center; padding: 56px 22px; }

.dots { display: flex; gap: 10px; justify-content: center; margin-bottom: 26px; }
.dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rose);
  opacity: .25;
  animation: dotPulse 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: .18s; background: var(--violet); }
.dots span:nth-child(3) { animation-delay: .36s; }
@keyframes dotPulse {
  0%, 100% { opacity: .25; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.25); }
}

.loading-card h2 { margin-bottom: 8px; }

.error-box {
  margin-top: 26px;
  background: #FBF1F0;
  border: 1px solid #EFD9D4;
  border-radius: 16px;
  padding: 16px 18px;
}
.error-box p { color: #A95A5A; font-size: 14px; margin-bottom: 14px; }
.error-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.error-actions .btn { padding: 10px 20px; font-size: 13.5px; }

/* ========== 结果页 ========== */
.result-wrap { display: flex; flex-direction: column; gap: 14px; }

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 2px 6px;
}
.who { font-size: 13px; color: var(--rose); font-weight: 600; letter-spacing: .04em; }

.score-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeUp .4s ease both;
}

.ring-wrap { position: relative; width: 128px; margin: 0 auto 14px; }
.ring-wrap svg { display: block; width: 128px; height: 128px; }
#ring-fg { transition: stroke-dashoffset .8s ease; }

.ring-num {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-num b { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.ring-num span { font-size: 10px; color: var(--muted); letter-spacing: .22em; margin-top: 4px; }

#result-score-label { font-size: 17px; font-weight: 700; letter-spacing: .08em; }
.summary { color: var(--muted); font-size: 13.5px; line-height: 1.7; margin-top: 10px; }

.mbti-cards { display: flex; gap: 12px; animation: fadeUp .4s .08s ease both; }
.mbti-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 14px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.mbti-name { font-size: 12.5px; color: var(--muted); }
.mbti-type { font-size: 30px; font-weight: 800; letter-spacing: .14em; margin: 6px 0; }
.mbti-tie {
  align-self: center;
  font-size: 10.5px;
  color: var(--violet);
  background: var(--violet-soft);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 4px;
}
.rule { height: 1px; background: var(--line); margin: 2px 0 10px; }
.mbti-desc { font-size: 12px; color: #5A5250; line-height: 1.6; }

.ai-report {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 20px;
  box-shadow: var(--shadow);
  animation: fadeUp .4s .16s ease both;
}
.ai-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.ai-section:last-child { border-bottom: none; }
.ai-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #4A4240;
  margin-bottom: 10px;
}
.ai-section h3 svg { flex: none; width: 15px; height: 15px; color: var(--rose); }
.ai-section p { font-size: 13.5px; color: #5A5250; line-height: 1.75; margin-bottom: 10px; }
.ai-section ul { list-style: none; }
.ai-section li {
  position: relative;
  padding: 7px 0 7px 16px;
  font-size: 13.5px;
  color: #5A5250;
  line-height: 1.6;
}
.ai-section li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 14px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--violet);
}

.notice {
  background: #FBF6E9;
  border: 1px solid #EFE3C0;
  color: #8A6D1A;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  background: #F7F4F1;
  border-radius: 12px;
  padding: 12px;
  color: #5A5250;
  max-height: 320px;
  overflow: auto;
}

.result-actions { display: flex; flex-direction: column; gap: 10px; animation: fadeUp .4s .24s ease both; }

/* ========== 响应式 ========== */
@media (max-width: 420px) {
  .app { padding: 18px 14px 40px; }
  .mbti-cards { flex-direction: column; }
  h1 { font-size: 25px; }
  .quiz-question { font-size: 17.5px; }
}

/* ========== 减少动态效果偏好 ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ========== 氛围背景（浅色：A 晨曦光晕 + C 星尘流动） ========== */
html { background: #FAF8F6; }

.app { position: relative; z-index: 1; }

#bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#bg-scene .scene-base,
#bg-scene .scene-glow,
#bg-scene .scene-blobs,
#bg-scene .scene-grain,
#bg-scene .scene-vignette {
  position: absolute;
  inset: 0;
}

.scene-base {
  background:
    radial-gradient(120% 90% at 12% -6%, rgba(248,232,236,.85), transparent 58%),
    radial-gradient(120% 90% at 88% 106%, rgba(235,231,244,.9), transparent 60%),
    linear-gradient(180deg, #FBF7F3 0%, #F7F0ED 100%);
}

.scene-glow {
  opacity: .6;
  background:
    radial-gradient(46% 34% at 16% 12%, rgba(214,152,165,.55), transparent 70%),
    radial-gradient(46% 34% at 86% 88%, rgba(157,143,191,.5), transparent 70%);
}

/* 缓慢流动的模糊光晕 */
.scene-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .5;
  will-change: transform;
}
.scene-blob.b1 {
  width: 420px; height: 420px; left: -130px; top: -120px;
  background: radial-gradient(circle, rgba(233,178,189,.5), rgba(233,178,189,0) 70%);
  animation: sceneDrift1 26s ease-in-out infinite alternate;
}
.scene-blob.b2 {
  width: 460px; height: 460px; right: -150px; top: 22%;
  background: radial-gradient(circle, rgba(186,174,218,.45), rgba(186,174,218,0) 70%);
  animation: sceneDrift2 32s ease-in-out infinite alternate;
}
.scene-blob.b3 {
  width: 380px; height: 380px; left: 30%; bottom: -160px;
  background: radial-gradient(circle, rgba(240,204,186,.4), rgba(240,204,186,0) 70%);
  animation: sceneDrift3 38s ease-in-out infinite alternate;
}
@keyframes sceneDrift1 { from { transform: translate(0,0) scale(1); } to { transform: translate(60px, 46px) scale(1.12); } }
@keyframes sceneDrift2 { from { transform: translate(0,0) scale(1); } to { transform: translate(-70px, 54px) scale(1.08); } }
@keyframes sceneDrift3 { from { transform: translate(0,0) scale(1); } to { transform: translate(-44px, -60px) scale(1.15); } }

/* 漂浮柔光粒子（浅色） */
.particle {
  position: absolute;
  bottom: -30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, rgba(255,255,255,.95), rgba(214,142,158,.6) 48%, rgba(214,142,158,0) 74%);
  box-shadow: 0 0 14px rgba(214,142,158,.45);
  filter: blur(.5px);
  animation: sceneFloat linear infinite;
  will-change: transform;
}
.particle.pv {
  background: radial-gradient(circle at 35% 32%, rgba(255,255,255,.95), rgba(150,136,188,.6) 48%, rgba(150,136,188,0) 74%);
  box-shadow: 0 0 14px rgba(150,136,188,.45);
}
@keyframes sceneFloat {
  0%   { transform: translate3d(0,0,0) scale(1); opacity: 0; }
  8%   { opacity: var(--p-o, .7); }
  90%  { opacity: var(--p-o, .7); }
  100% { transform: translate3d(var(--p-x, 30px), -78vh, 0) scale(.9); opacity: 0; }
}

/* 星点（深色） */
.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: sceneTwinkle 4s ease-in-out infinite;
}
.star.tint-rose { background: #E8A7B6; }
.star.tint-violet { background: #B9AEE0; }
@keyframes sceneTwinkle { 0%,100% { opacity: .15; } 50% { opacity: .9; } }

/* 浅色主题默认：隐藏星点 */
.star { display: none; }

/* 颗粒质感 + 暗角 */
.scene-grain {
  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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: .05;
}
.scene-vignette { display: none; }

/* ========== 深色主题（方案 B 暗夜星辉） ========== */
html[data-theme="dark"] {
  color-scheme: dark;
  background: #141018;
  --bg: #141018;
  --card: rgba(255,255,255,.055);
  --line: rgba(255,255,255,.12);
  --ink: #F5EFF2;
  --muted: rgba(245,239,242,.6);
  --rose: #E8A7B6;
  --rose-deep: #D98DA0;
  --rose-soft: rgba(169,108,120,.22);
  --violet: #C9BEE6;
  --violet-soft: rgba(139,127,168,.25);
  --shadow: 0 18px 44px rgba(0,0,0,.35);
}
html[data-theme="dark"] body { background: #141018; }

html[data-theme="dark"] .scene-base {
  background:
    radial-gradient(120% 100% at 18% 0%, #2A2233 0%, #1C1720 46%, #141018 100%);
}
html[data-theme="dark"] .scene-glow {
  opacity: .6;
  background:
    radial-gradient(48% 36% at 16% 10%, rgba(190,120,140,.38), transparent 70%),
    radial-gradient(48% 36% at 86% 90%, rgba(124,108,168,.36), transparent 70%);
}
html[data-theme="dark"] .scene-blob { opacity: .55; }
html[data-theme="dark"] .scene-blob.b1 { background: radial-gradient(circle, rgba(160,88,116,.4), rgba(160,88,116,0) 70%); }
html[data-theme="dark"] .scene-blob.b2 { background: radial-gradient(circle, rgba(104,88,152,.38), rgba(104,88,152,0) 70%); }
html[data-theme="dark"] .scene-blob.b3 { background: radial-gradient(circle, rgba(146,102,88,.24), rgba(146,102,88,0) 70%); }
html[data-theme="dark"] .scene-grain { opacity: .07; }
html[data-theme="dark"] .scene-vignette {
  display: block;
  background: radial-gradient(120% 100% at 50% 42%, transparent 52%, rgba(8,6,12,.55) 100%);
}
html[data-theme="dark"] .particle { display: none; }
html[data-theme="dark"] .star { display: block; }

/* 深色：卡片玻璃质感与文字适配 */
html[data-theme="dark"] .card,
html[data-theme="dark"] .score-card,
html[data-theme="dark"] .mbti-card,
html[data-theme="dark"] .ai-report {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
html[data-theme="dark"] .feature-list li { color: rgba(245,239,242,.82); }
html[data-theme="dark"] .mbti-desc,
html[data-theme="dark"] .ai-section p,
html[data-theme="dark"] .ai-section li { color: rgba(245,239,242,.72); }
html[data-theme="dark"] .ai-section h3 { color: #EFE8EC; }
html[data-theme="dark"] .text-input::placeholder { color: rgba(245,239,242,.35); }
html[data-theme="dark"] .progress-track { background: rgba(255,255,255,.14); }
html[data-theme="dark"] .option { color: #EFE8EC; }
html[data-theme="dark"] .option.selected { color: #F2C1CC; background: rgba(169,108,120,.2); }
html[data-theme="dark"] #ring-bg { stroke: rgba(255,255,255,.16); }
html[data-theme="dark"] #ringGrad stop:first-child { stop-color: #B9AEE0; }
html[data-theme="dark"] #ringGrad stop:last-child { stop-color: #E8A7B6; }
html[data-theme="dark"] .notice { background: rgba(222,180,90,.12); border-color: rgba(222,180,90,.3); color: #E4C782; }
html[data-theme="dark"] .error-box { background: rgba(200,80,90,.12); border-color: rgba(200,80,90,.3); }
html[data-theme="dark"] .error-box p { color: #E8A0A0; }
html[data-theme="dark"] pre { background: rgba(255,255,255,.07); color: rgba(245,239,242,.78); }

/* ========== 主题切换按钮 ========== */
#theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.65);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(60,40,45,.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform .12s ease, background .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
}
#theme-toggle:hover { transform: translateY(-1px); border-color: var(--rose); }
#theme-toggle:active { transform: scale(.96); }
#theme-toggle:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
#theme-toggle svg { width: 19px; height: 19px; }
#theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] #theme-toggle {
  background: rgba(255,255,255,.08);
  box-shadow: 0 8px 22px rgba(0,0,0,.35);
}
html[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* 小屏：让固定按钮不遮住顶部内容 */
@media (max-width: 680px) {
  .app { padding-top: 62px; }
}

/* 减弱动态效果：粒子改为静态散布，保持可见 */
@media (prefers-reduced-motion: reduce) {
  #bg-scene .particle {
    top: var(--p-top, 40%);
    bottom: auto;
    opacity: var(--p-o, .7);
    animation: none !important;
  }
}
