/* =============================================
   CSS 設計變數（Design Tokens）
   ============================================= */
:root {
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --border: #E8E4DE;
  --text-primary: #1A1714;
  --text-secondary: #6B6460;
  --text-tertiary: #A89F98;
  --accent: #C4956A;
  --accent-light: #F5EDE3;
  --accent-dark: #9B6E47;
  --danger: #C4716A;
  --success: #6A9E7F;
  --radius: 14px;
  --radius-sm: 8px;
}

/* 基礎重置 */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 300;
  min-height: 100vh;
  padding: 0 0 80px;
}

/* =============================================
   頂部標題區
   ============================================= */
.header {
  padding: 32px 24px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-brand {
  font-family: 'Noto Serif TC', serif;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 8px;
}
.header-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}
.header-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.7;
}

/* =============================================
   進度條
   ============================================= */
.progress-wrap {
  padding: 16px 24px 0;
  max-width: 560px;
  margin: 0 auto;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* 主容器 */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
}

/* =============================================
   問題步驟與動畫
   ============================================= */
.step { display: none; }
.step.active { display: block; animation: fadeUp 0.4s ease; }

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

/* 回聲文字（Kiddo 的同理回應） */
.echo {
  margin: 20px 0 0;
  padding: 14px 18px;
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--accent-dark);
  line-height: 1.8;
  font-style: italic;
}

/* =============================================
   問題卡片
   ============================================= */
.q-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px 0;
}
.q-context {
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.q-main {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 8px;
}
/* 複選提示標籤 */
.q-hint {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 16px;
  background: var(--accent-light);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* =============================================
   選項按鈕（單選 + 複選）
   ============================================= */
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.opt {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  line-height: 1.5;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 400;
  position: relative; /* 讓複選的 ✓ 可以絕對定位 */
}
.opt:hover { border-color: var(--accent); background: var(--accent-light); }
.opt.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 500;
}
/* 複選題選中時，右側顯示 ✓ */
.opt.multi.selected::after {
  content: '✓';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--accent);
  font-weight: 700;
}
.opt-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 300;
}
.opt.selected .opt-sub { color: var(--accent); }

/* =============================================
   開放式文字輸入（Q5 分手原因）
   ============================================= */
.open-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 300;
  color: var(--text-primary);
  background: var(--bg);
  resize: none;
  min-height: 100px;
  outline: none;
  transition: border-color 0.18s;
  line-height: 1.7;
}
.open-input:focus { border-color: var(--accent); background: var(--surface); }
.open-input::placeholder { color: var(--text-tertiary); }

/* =============================================
   下一步按鈕
   ============================================= */
.next-btn {
  width: 100%;
  padding: 16px;
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  opacity: 0.25;          /* 預設半透明，代表還不能點 */
  pointer-events: none;   /* 預設不可點擊 */
  letter-spacing: 0.03em;
}
.next-btn.ready { opacity: 1; pointer-events: auto; }
.next-btn.ready:hover { background: var(--accent-dark); transform: translateY(-1px); }

/* =============================================
   結果報告區
   ============================================= */
.result-wrap { display: none; animation: fadeUp 0.5s ease; }
.result-wrap.show { display: block; }

/* 填答摘要 */
.result-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0 12px;
}
.result-summary-title {
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}
.summary-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.summary-item:last-child { border-bottom: none; }
.summary-label {
  color: var(--text-tertiary);
  min-width: 80px;
  flex-shrink: 0;
}
.summary-val {
  color: var(--text-primary);
  font-weight: 400;
  line-height: 1.6;
}

/* 主要分析結果 */
.result-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 12px;
}
.difficulty-label {
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.difficulty-bar-bg {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.difficulty-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1.2s ease;
}
.difficulty-nums {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
}
.difficulty-score {
  font-family: 'Noto Serif TC', serif;
  font-size: 42px;
  font-weight: 600;
  margin: 8px 0 4px;
  line-height: 1;
}
.difficulty-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.result-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.result-section-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.result-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 2;
  white-space: pre-wrap;
}

/* 建議行動列表 */
.action-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.action-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.7;
}
.action-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* =============================================
   Loading 動畫
   ============================================= */
.loading-wrap {
  text-align: center;
  padding: 48px 24px;
  display: none;
}
.loading-wrap.show { display: block; }
.loading-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 3px;
  animation: bounce 1.2s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.loading-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 16px;
  line-height: 1.8;
}

/* =============================================
   CTA 行動呼籲
   ============================================= */
.cta-section { margin-top: 12px; }
.cta-primary {
  display: block;
  width: 100%;
  padding: 18px;
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.18s ease;
  margin-bottom: 10px;
}
.cta-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.cta-note {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.7;
}

/* 錯誤訊息（在結果區 和 Q6 按鈕下方都可顯示） */
.error-msg {
  background: #FDF2F2;
  border: 1px solid #F5C4C4;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--danger);
  margin-top: 12px;
  line-height: 1.7;
  display: none;
}
