/* ===== 基础 ===== */
:root {
  --cream: #f5efe6;
  --cream-dark: #e8dcc8;
  --ink: #2c1810;
  --ink-soft: #5c4033;
  --ink-mute: #8b7355;
  --wood: #8b6914;
  --wood-light: #d4a94a;
  --wood-dark: #6b4f0a;
  --card: #faf6ef;
  --card-border: #d4c9b0;
  --danger: #b7472a;
  --success: #6b8f3a;
  --radius: 12px;
  --shadow: 0 2px 0 rgba(108, 79, 10, 0.2);
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--cream-dark);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  line-height: 1.6;
}

#app {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  background: linear-gradient(180deg, #faf6ef 0%, var(--cream) 40%, var(--cream-dark) 100%);
  position: relative;
  box-shadow: 0 0 30px rgba(60, 30, 10, 0.15);
}

/* ===== 场景切换 ===== */
.scene {
  display: none;
  min-height: 100dvh;
  padding: 32px 24px 40px;
}
.scene.active { display: flex; }
.scene.hidden { display: none; }

.scene-inner {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  letter-spacing: 0.5px;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #d4a94a, #b8860b);
  color: #fff;
  border: 2px solid var(--wood-dark);
  box-shadow: inset 0 1px 0 #e8c87a, 0 3px 0 var(--wood-dark), 0 5px 12px rgba(60,30,10,0.2);
  text-shadow: 0 1px 0 rgba(60,30,10,0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 #e8c87a, 0 4px 0 var(--wood-dark), 0 7px 14px rgba(60,30,10,0.22);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 #e8c87a, 0 1px 0 var(--wood-dark);
}

.btn-outline {
  background: linear-gradient(180deg, #fff8ef, var(--card));
  color: var(--ink-soft);
  border: 1.5px solid var(--card-border);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 rgba(108,79,10,0.15);
}
.btn-outline:hover {
  background: linear-gradient(180deg, #fffef5, #fff8ef);
}

.btn-sm { padding: 10px 20px; font-size: 14px; }

.btn-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--wood);
  background: var(--wood);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-icon:hover:not(:disabled) { background: var(--wood-dark); }

/* ===== 加载遮罩 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(44, 24, 16, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #fff;
  font-size: 15px;
}
.loading-overlay.hidden { display: none; }

.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--wood-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 欢迎页 ===== */
#sceneWelcome {
  justify-content: center;
  text-align: center;
}
.badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(139, 105, 20, 0.12);
  color: var(--wood-dark);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
#sceneWelcome h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--ink);
}
.subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.8;
  margin-bottom: 8px;
}
.form-group {
  text-align: left;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.opt-btn {
  flex: 1;
  min-width: calc(50% - 4px);
  padding: 10px 8px;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.opt-btn:hover { border-color: var(--wood); background: #fffcf5; }
.opt-btn.selected {
  border-color: var(--wood);
  background: rgba(212, 169, 74, 0.12);
  color: var(--wood-dark);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--wood);
}

.footnote {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 8px;
}

/* ===== 选择关卡 ===== */
.stage-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 8px 0;
}
.progress-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--card-border);
  transition: all 0.3s;
}
.progress-dot.done { background: var(--wood); }
.progress-dot.current { background: var(--wood); box-shadow: 0 0 0 3px rgba(212,169,74,0.25); }

.stage-card {
  background: linear-gradient(180deg, #fff8ef, var(--card));
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 rgba(108,79,10,0.15);
}
.stage-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-mute);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.stage-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}
.stage-situation {
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(139, 105, 20, 0.05);
  border-radius: var(--radius);
  border-left: 3px solid var(--wood-light);
}
.stage-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.choice-btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1.5;
}
.choice-btn:hover { border-color: var(--wood); background: #fffcf5; }
.choice-btn.selected {
  border-color: var(--wood-dark);
  background: rgba(212, 169, 74, 0.1);
  font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--wood);
}

/* ===== 对话 ===== */
.dialogue-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 0;
}
.dialogue-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}
.dialogue-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wood-light), var(--wood-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}
.dialogue-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.dialogue-tagline {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.dialogue-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-system {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--ink);
}
.msg-user {
  align-self: flex-end;
  background: var(--wood);
  color: #fff;
  border: none;
}
.msg-typing {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--ink-mute);
}
.msg-typing::after {
  content: '...';
  animation: dots 1.2s infinite;
}
@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

.dialogue-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 16px;
  background: var(--card);
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
}
#dialogueInput {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid var(--card-border);
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
#dialogueInput:focus { border-color: var(--wood); }
#dialogueInput::placeholder { color: var(--ink-mute); }
.dialogue-hint {
  text-align: center;
  font-size: 11px;
  color: var(--ink-mute);
  padding: 0 16px 12px;
  flex-shrink: 0;
}

/* ===== 报告 ===== */
.report-badge {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--wood-dark);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.report-content {
  background: linear-gradient(180deg, #fff8ef, var(--card));
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 rgba(108,79,10,0.12);
  font-size: 14px;
  line-height: 1.8;
  min-height: 300px;
}
.report-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--ink-mute);
}
.report-content h2, .report-content h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--wood-dark);
  margin: 20px 0 8px;
  letter-spacing: 1px;
}
.report-content h2:first-child, .report-content h3:first-child { margin-top: 0; }
.report-content p {
  margin-bottom: 12px;
  color: var(--ink);
}
.report-content strong {
  color: var(--wood-dark);
}

.report-actions {
  display: flex;
  gap: 10px;
}
.report-actions .btn { flex: 1; font-size: 14px; padding: 12px; }

.report-subscribe {
  text-align: center;
  padding: 20px;
  background: rgba(139, 105, 20, 0.06);
  border-radius: var(--radius);
  border: 1px solid rgba(212, 169, 74, 0.2);
}
.report-subscribe p {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.subscribe-link {
  display: inline-block;
  color: var(--wood-dark);
  font-weight: 700;
  text-decoration: none;
  font-size: 14px;
  border-bottom: 2px solid var(--wood-light);
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .scene { padding: 24px 16px 32px; }
  #sceneWelcome h1 { font-size: 30px; }
  .stage-card { padding: 20px 16px; }
  .stage-title { font-size: 20px; }
  .opt-btn { font-size: 12px; padding: 8px 6px; }
  .report-content { padding: 20px 16px; }
}
