:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #22211f;
  --muted: #6b6862;
  --border: #e3e0d8;
  --primary: #3f6ad8;
  --primary-ink: #ffffff;
  --agree: #2f9e8f;
  --disagree: #b0629a;
  --neutral: #a6a39b;
  --nt: #7a5bc4;
  --nf: #2f9a68;
  --sj: #3574c4;
  --sp: #d08a1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 24px rgba(0, 0, 0, .06);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151514;
    --surface: #1f1f1d;
    --surface-2: #2a2a27;
    --text: #ecebe6;
    --muted: #a19e96;
    --border: #34332f;
    --primary: #6d8ff0;
    --agree: #4cc0af;
    --disagree: #d182bb;
    --neutral: #75726b;
    --nt: #a288e6;
    --nf: #55c08d;
    --sj: #6aa0e6;
    --sp: #eaa944;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  flex: 1;
}

h1, h2, h3 { line-height: 1.3; margin: 0; }

.hidden { display: none !important; }

/* 顶栏 */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
}
.topbar a { color: var(--text); text-decoration: none; }
.brand { font-weight: 700; font-size: 18px; }
.topbar nav a { color: var(--muted); font-size: 15px; }
.topbar nav a:hover { color: var(--text); }

/* 按钮 */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 28px;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform .12s ease, background .2s, opacity .2s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn:focus-visible, .dot:focus-visible, .type-card:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* 首页 */
.hero { text-align: center; padding: 40px 0 32px; }
.eyebrow { color: var(--primary); font-weight: 600; letter-spacing: .08em; margin: 0 0 8px; font-size: 14px; }
.hero h1 { font-size: clamp(34px, 7vw, 52px); letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 17px; margin: 12px 0 0; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

.dims { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.dim-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dim-card b { font-size: 20px; }
.dim-card small { color: var(--muted); }

.tips {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.tips h2 { font-size: 17px; margin-bottom: 8px; }
.tips ul { margin: 0; padding-left: 20px; color: var(--muted); }
.tips b { color: var(--text); }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0 6px;
}

/* 答题 */
.progress-wrap { margin: 8px 0 24px; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .3s ease; }

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 32px 28px;
  text-align: center;
}
.q-index { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.q-text { font-size: clamp(20px, 4vw, 26px); font-weight: 600; min-height: 2.6em; }
.question-card.enter .q-text { animation: fadeUp .28s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.scale {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  max-width: 520px;
  margin: 36px auto 10px;
}
.dot {
  --c: var(--neutral);
  flex: none;
  border-radius: 50%;
  border: 2.5px solid var(--c);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background .15s, transform .15s;
}
.dot:hover { background: color-mix(in srgb, var(--c) 18%, transparent); transform: scale(1.06); }
.dot[aria-checked="true"] { background: var(--c); }
.dot.s3 { width: 52px; height: 52px; }
.dot.s2 { width: 44px; height: 44px; }
.dot.s1 { width: 36px; height: 36px; }
.dot.s0 { width: 28px; height: 28px; }
.dot.neg { --c: var(--disagree); }
.dot.pos { --c: var(--agree); }

.scale-labels {
  display: flex;
  justify-content: space-between;
  max-width: 520px;
  margin: 0 auto;
  font-size: 14px;
  font-weight: 600;
}
.scale-labels span:first-child { color: var(--disagree); }
.scale-labels span:last-child { color: var(--agree); }

.quiz-nav { display: flex; justify-content: space-between; margin-top: 20px; }

/* 结果 */
.result-hero {
  --g: var(--primary);
  text-align: center;
  padding: 36px 16px 28px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--g) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--g) 25%, var(--border));
}
.result-hero .label { color: var(--muted); margin: 0; }
.result-hero .code {
  font-size: clamp(56px, 14vw, 88px);
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--g);
  line-height: 1.1;
  margin: 6px 0;
}
.result-hero .name { font-size: 24px; font-weight: 700; }
.result-hero .tagline { color: var(--muted); margin: 6px 0 14px; }
.result-hero .summary { text-align: left; max-width: 620px; margin: 16px auto 0; }
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  color: var(--g);
  background: color-mix(in srgb, var(--g) 14%, transparent);
}
.g-nt { --g: var(--nt); }
.g-nf { --g: var(--nf); }
.g-sj { --g: var(--sj); }
.g-sp { --g: var(--sp); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 16px;
}
.card h3 { font-size: 17px; margin-bottom: 12px; }
.card ul { margin: 0; padding-left: 20px; }
.card li + li { margin-top: 4px; }
.card p { margin: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-2 .wide { grid-column: 1 / -1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface-2); border-radius: 99px; padding: 4px 14px; font-size: 14px; }

.dim-row + .dim-row { margin-top: 18px; }
.dim-head { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.dim-head .on { color: var(--text); font-weight: 700; }
.dim-track { position: relative; height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.dim-fill { position: absolute; top: 0; bottom: 0; background: var(--g, var(--primary)); border-radius: 99px; transition: width .6s ease; }
.dim-fill.from-left { left: 0; }
.dim-fill.from-right { right: 0; }
.dim-hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

/* 类型列表 */
.page-title { font-size: 32px; margin-top: 16px; }
.group-block { margin-top: 28px; }
.group-block h2 { font-size: 18px; display: flex; align-items: baseline; gap: 10px; }
.group-block h2 small { color: var(--muted); font-weight: 400; font-size: 14px; }
.types-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.type-card {
  --g: var(--primary);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--g);
  border-radius: 12px;
  padding: 14px;
  transition: transform .15s, box-shadow .15s;
}
.type-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.type-card b { display: block; font-size: 20px; color: var(--g); letter-spacing: .04em; }
.type-card span { font-weight: 600; }
.type-card small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.5; }

/* 页脚与提示 */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px 16px 32px;
  max-width: 820px;
  margin: 0 auto;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 响应式 */
@media (max-width: 640px) {
  .dims { grid-template-columns: repeat(2, 1fr); }
  .types-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .question-card { padding: 28px 16px 20px; }
  .scale { gap: 4px; }
  .dot.s3 { width: 42px; height: 42px; }
  .dot.s2 { width: 36px; height: 36px; }
  .dot.s1 { width: 30px; height: 30px; }
  .dot.s0 { width: 24px; height: 24px; }
  .hero { padding-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
