:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-danger: #dc2626;
  --color-safe: #16a34a;
  --color-warning: #d97706;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --color-hover: #f1f5f9;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

.container { max-width: 720px; margin: 0 auto; padding: 0 20px; }

header {
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  color: white;
  padding: 28px 0 20px;
  text-align: center;
}

header h1 { font-size: 1.5rem; font-weight: 700; }
header .subtitle { opacity: 0.9; font-size: 0.9rem; margin-top: 4px; }

main { padding: 20px 0 48px; }

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1.15rem; margin-bottom: 12px; }
.card h3 { font-size: 1rem; margin-bottom: 8px; }

/* Form elements */
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.9rem; }

textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}
textarea:focus { outline: none; border-color: var(--color-primary); }

.hint { color: var(--color-text-secondary); font-size: 0.8rem; margin-top: 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--color-hover); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-border); }

.action-bar { margin-top: 16px; display: flex; gap: 12px; }
.action-bar.center { justify-content: center; }

/* Profile questions */
.profile-questions { display: flex; flex-direction: column; gap: 12px; }
.pq-item label { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.pq-item textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}
.pq-item textarea:focus { outline: none; border-color: var(--color-primary); }

/* Quick try buttons */
.quick-try { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-btn {
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.quick-btn:hover { border-color: var(--color-primary); background: #eff6ff; }

/* ── Wizard ──────────────────────────────────────────────────────────── */
.wizard-header { padding: 20px 0 16px; }

.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: white;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-label { font-size: 0.8rem; opacity: 0.85; margin-top: 4px; }

.wizard-step { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.task-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.task-desc { color: var(--color-text-secondary); font-size: 0.9rem; margin-bottom: 20px; }

/* Questions */
.question-card {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--color-hover);
  border-radius: var(--radius);
}
.question-text { font-weight: 600; font-size: 0.95rem; margin-bottom: 10px; }

.option-group { display: flex; flex-direction: column; gap: 6px; }

.option-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.option-item:hover { border-color: var(--color-primary); background: #eff6ff; }
.option-item.selected { border-color: var(--color-primary); background: #dbeafe; }
.option-item input[type="radio"] { display: none; }
.option-label { font-size: 0.9rem; }

/* Time slider */
.time-section {
  margin-top: 20px;
  padding: 16px;
  background: var(--color-hover);
  border-radius: var(--radius);
}
.time-slider-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

.time-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  outline: none;
}
.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
}
.time-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
}
.time-value { font-size: 1.1rem; font-weight: 700; color: var(--color-primary); min-width: 50px; }

/* Wizard nav */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

/* ── Results ─────────────────────────────────────────────────────────── */
.results-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.result-card { text-align: center; }
.result-card.current { border-left: 4px solid var(--color-primary); }
.result-card.trend { border-left: 4px solid var(--color-warning); }
.result-label { font-size: 0.85rem; color: var(--color-text-secondary); margin-bottom: 4px; }
.result-value { font-size: 2rem; font-weight: 700; }
.result-card.current .result-value { color: var(--color-primary); }
.result-card.trend .result-value { color: var(--color-warning); }
.result-range { font-size: 0.8rem; color: var(--color-text-secondary); }

/* Exposure bar */
.exposure-bar-container { margin-bottom: 8px; }
.exposure-bar {
  height: 12px;
  background: var(--color-border);
  border-radius: 6px;
  overflow: visible;
  position: relative;
}
.exposure-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--color-safe), var(--color-warning), var(--color-danger));
  transition: width 0.6s ease;
}
.exposure-bar-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 20px;
  background: var(--color-warning);
  border-radius: 2px;
  transition: left 0.6s ease;
}
.exposure-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
}
.bar-legend { display: flex; gap: 16px; justify-content: center; margin-top: 8px; font-size: 0.8rem; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.current-dot { background: linear-gradient(90deg, var(--color-safe), var(--color-warning), var(--color-danger)); }
.trend-dot { background: var(--color-warning); }

/* Task ranking */
.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.rank-item:last-child { border-bottom: none; }
.rank-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.rank-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--color-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.rank-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.rank-bar-mini {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
  width: 120px;
}
.rank-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--color-safe), var(--color-warning), var(--color-danger));
  transition: width 0.4s ease;
}
.rank-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.rank-pct { font-weight: 700; font-size: 0.95rem; }

.risk-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.risk-low { background: #dcfce7; color: var(--color-safe); }
.risk-medium { background: #fef3c7; color: var(--color-warning); }
.risk-high { background: #fee2e2; color: var(--color-danger); }
.risk-critical { background: #fecaca; color: #991b1b; }

/* Recommendations */
.rec-item {
  display: flex;
  gap: 10px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
}
.rec-action { background: #fef2f2; }
.rec-watch { background: #fffbeb; }
.rec-safe { background: #f0fdf4; }
.rec-icon { font-size: 1.1rem; flex-shrink: 0; }
.rec-text { flex: 1; }

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-content { text-align: center; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content p { color: var(--color-text-secondary); }

/* Hidden */
.hidden { display: none !important; }

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border);
}

/* Responsive */
@media (max-width: 640px) {
  .results-overview { grid-template-columns: 1fr; }
  header h1 { font-size: 1.3rem; }
  .option-item { padding: 8px 10px; }
  .rank-bar-mini { width: 80px; }
}
