/* ========== CSS Variables ========== */
:root {
  /* CBTI 配色 - 校园杂志风 */
  --bg: #faf9f7;
  --card-bg: #ffffff;
  --text: #1e1b2e;
  --text-secondary: #6b7280;
  --accent: #4f46e5;
  --accent-light: #eef0ff;
  --accent-hover: #4338ca;
  --accent-warm: #f59e0b;
  --border: #e8e6e3;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(79, 70, 229, 0.08);
  --font: 'Noto Sans SC', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --max-width: 680px;
}

/* ========== Reset ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}

/* ========== Layout ========== */
#app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page {
  display: none;
  width: 100%;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ========== Intro ========== */
.intro-card {
  text-align: center;
  padding: 48px 28px;
}

.intro-title {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 24px;
  color: var(--text);
}

/* ========== Identity Select ========== */
.identity-select {
  margin: 24px 0 16px;
  text-align: center;
}

.identity-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.identity-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-identity {
  flex: 1;
  max-width: 200px;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease;
  font-family: var(--font);
}

.btn-identity:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
}

.btn-identity.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  transform: scale(1.02);
}

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 14px 48px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--accent-light);
  color: var(--accent);
  padding: 12px 36px;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  margin-bottom: 10px;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.5;
}

.btn-option:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

.btn-option:active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(0);
}

/* ========== Quiz ========== */
.quiz-card {
  padding: 28px 24px;
}

.progress-bar {
  height: 4px;
  background: var(--accent-light);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
  margin-bottom: 24px;
}

.question-area {
  margin-bottom: 24px;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.7;
  color: var(--text);
}

/* ========== Result ========== */
.result-card {
  text-align: center;
  padding: 36px 24px;
}

.result-kicker {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.result-avatar {
  width: 220px;
  aspect-ratio: 1;
  margin: 0 auto 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}

.result-avatar img {
  width: 100%;
  height: auto;
  display: block;
}

.result-code {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.result-name {
  font-size: 1.2rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 12px;
}

.result-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 20px;
}

.result-intro {
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 16px;
  font-style: italic;
}

.result-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: left;
  line-height: 1.8;
  margin-bottom: 28px;
}

.result-secondary {
  background: var(--accent-light);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 24px;
}

.secondary-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.secondary-info {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
}

/* ========== Section Title ========== */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 16px;
  text-align: center;
}

/* ========== Radar Chart ========== */
#radar-chart {
  display: block;
  margin: 0 auto 24px;
  max-width: 100%;
}

/* ========== Dimensions Detail ========== */
.dimensions-detail {
  text-align: left;
  margin-bottom: 24px;
}

.dim-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.dim-row:last-child {
  border-bottom: none;
}

.dim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.dim-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.dim-level {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
}

.level-low {
  background: #fef3e2;
  color: #b8860b;
}

.level-mid {
  background: #eef0ff;
  color: #4f46e5;
}

.level-high {
  background: #ecfdf5;
  color: #059669;
}

.dim-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========== Top List ========== */
.top-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.top-item:last-child {
  border-bottom: none;
}

.top-rank {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 28px;
}

.top-code {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 72px;
}

.top-name {
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
}

.top-sim {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ========== Disclaimer ========== */
.disclaimer {
  margin-top: 24px;
  padding: 16px;
  background: var(--accent-light);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  text-align: left;
}

/* ========== Result Actions ========== */
.result-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ========== Agent Section ========== */
.agent-section {
  margin-top: 28px;
  padding: 20px;
  background: var(--bg);
  border-radius: 10px;
  text-align: center;
  border: 1px solid var(--border);
}

.agent-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.agent-cmd {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.agent-cmd code {
  color: var(--accent);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.btn-agent {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 10px 24px;
  font-size: 0.85rem;
}

.btn-agent:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.agent-hint {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* ========== Intro Credits ========== */
.intro-credit {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.intro-note {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* ========== Mobile ========== */
@media (max-width: 480px) {
  .intro-title {
    font-size: 1.6rem;
  }

  .result-code {
    font-size: 2.2rem;
  }

  .card {
    padding: 24px 16px;
  }

  .identity-buttons {
    flex-direction: column;
  }

  .btn-identity {
    max-width: 100%;
  }
}
