/* MBTI 测评 — 视觉系统 */
:root {
  --bg: #f6f2ea;
  --bg-elev: #fffdf8;
  --ink: #1b1c2e;
  --ink-2: #4a4c63;
  --muted: #7a7c91;
  --line: rgba(27, 28, 46, 0.1);
  --accent: #5b5ce6;
  --accent-2: #7c6af7;
  --accent-soft: #ebe9ff;
  --good: #2f9e6e;
  --warn: #c97a2b;
  --shadow: 0 18px 50px rgba(35, 32, 80, 0.1);
  --shadow-sm: 0 8px 24px rgba(35, 32, 80, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --max: 880px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans JP", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #efe9ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ffe8d6 0%, transparent 50%),
    var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
}

.orb-a {
  width: 320px;
  height: 320px;
  left: -80px;
  top: 18%;
  background: #c7c0ff;
}

.orb-b {
  width: 280px;
  height: 280px;
  right: -60px;
  top: 12%;
  background: #ffd2b8;
}

.orb-c {
  width: 240px;
  height: 240px;
  left: 35%;
  bottom: -80px;
  background: #d8f3e8;
}

main,
.footer {
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px rgba(91, 92, 230, 0.28);
}

.brand-text {
  font-size: 15px;
}

.ghost-btn {
  background: transparent;
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}

.ghost-btn:hover {
  background: rgba(27, 28, 46, 0.06);
  color: var(--ink);
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 20px 48px;
}

.view {
  display: none;
  animation: fadeIn 0.35s ease;
}

.view.active {
  display: block;
}

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

/* Hero */
.hero {
  text-align: center;
  padding: 28px 8px 18px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 64px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.grad-text {
  background: linear-gradient(120deg, var(--accent) 0%, #8b7cff 45%, #f09b6a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-desc {
  max-width: 560px;
  margin: 18px auto 0;
  color: var(--ink-2);
  font-size: 17px;
}

.meta-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0;
}

.meta-chip {
  min-width: 118px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.meta-chip strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
  color: var(--accent);
}

.meta-chip span {
  color: var(--muted);
  font-size: 13px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 180px;
  padding: 15px 28px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 14px 30px rgba(91, 92, 230, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(91, 92, 230, 0.38);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  padding: 14px 24px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.18s ease, transform 0.18s ease;
}

.secondary-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

.hero-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.dim-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.dim-card {
  padding: 20px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.dim-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.dim-card .pair {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.alt {
  background: #ffe9dc;
  color: #c46b2c;
}

.dim-card p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

/* Quiz */
.quiz-shell {
  max-width: 720px;
  margin: 0 auto;
}

.quiz-top {
  margin-bottom: 18px;
}

.progress-wrap {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(91, 92, 230, 0.12);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8b7cff);
  transition: width 0.35s ease;
}

.question-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
  animation: cardIn 0.28s ease;
}

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

.q-badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.question-text {
  margin: 0 0 28px;
  font-size: clamp(22px, 3.5vw, 30px);
  line-height: 1.45;
  letter-spacing: -0.01em;
}

/* 选项：强烈同意 → 强烈不同意，低饱和红到蓝
   桌面一行 5 个；小屏 2 + 1（中立居中）+ 2 */
.scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.scale-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 88px;
  text-align: center;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1.5px solid rgba(27, 28, 46, 0.08);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.scale-btn[data-value="2"] {
  background: #e8a4a0; /* 低饱和红 */
}
.scale-btn[data-value="1"] {
  background: #e8b8a8;
}
.scale-btn[data-value="0"] {
  background: #d8d2c8;
}
.scale-btn[data-value="-1"] {
  background: #b0c0d0;
}
.scale-btn[data-value="-2"] {
  background: #a0b8d4; /* 低饱和蓝 */
}

.scale-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(35, 32, 80, 0.1);
  border-color: rgba(27, 28, 46, 0.16);
}

.scale-btn.selected {
  border-color: rgba(27, 28, 46, 0.28);
  box-shadow: 0 10px 22px rgba(35, 32, 80, 0.16);
  transform: translateY(-1px);
  filter: saturate(1.15);
}

/* 已有选择时：未选中的 4 项变为浅灰（字/边框同色，略深于底） */
.scale.has-selection .scale-btn:not(.selected) {
  background: #e6e3df;
  color: #b5b0aa;
  border-color: #b5b0aa;
  box-shadow: none;
  filter: none;
}

.scale.has-selection .scale-btn:not(.selected) .val {
  color: #b5b0aa;
  opacity: 0.85;
}

.scale.has-selection .scale-btn:not(.selected):hover {
  background: #ddd9d3;
  border-color: #a39e98;
  color: #8f8a84;
  transform: none;
  box-shadow: none;
}

.scale-btn[data-value="2"].selected {
  background: #e39490;
}
.scale-btn[data-value="1"].selected {
  background: #e0a890;
}
.scale-btn[data-value="0"].selected {
  background: #cfc6b8;
}
.scale-btn[data-value="-1"].selected {
  background: #9db0c8;
}
.scale-btn[data-value="-2"].selected {
  background: #8eacd0;
}

.auto-hint {
  margin: 28px 0 0;
  text-align: center;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.auto-hint strong {
  font-variant-numeric: tabular-nums;
}

.scale-btn .label {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
}

.scale-btn .val {
  color: rgba(27, 28, 46, 0.55);
  font-size: 11px;
  font-weight: 500;
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

/* Result */
.result-shell {
  max-width: 760px;
  margin: 0 auto;
}

.result-hero {
  text-align: center;
  padding: 36px 24px 30px;
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(246, 242, 255, 0.92));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.type-code {
  display: table;
  margin: 14px auto 8px;
  padding: 10px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.12em;
  box-shadow: 0 12px 28px rgba(91, 92, 230, 0.28);
}

.type-name {
  margin: 8px 0 4px;
  font-size: clamp(32px, 5vw, 44px);
  letter-spacing: -0.02em;
}

.type-tag {
  margin: 0;
  color: var(--accent);
  font-weight: 600;
}

.type-summary {
  max-width: 560px;
  margin: 16px auto 0;
  color: var(--ink-2);
  font-size: 16px;
}

.panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 22px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  margin: 0 0 14px;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.dim-bars {
  display: grid;
  gap: 16px;
}

.dim-row {
  display: grid;
  gap: 8px;
}

.dim-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
}

.dim-row-head strong {
  color: var(--ink);
  font-size: 14px;
}

.bar-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(91, 92, 230, 0.14), rgba(240, 155, 106, 0.18));
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8b7cff);
  width: 0;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  left: 0;
  transition: left 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.dim-ends {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip-list li {
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}

.plain-list {
  display: grid;
  gap: 10px;
}

.plain-list li {
  position: relative;
  padding: 12px 14px 12px 36px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 14px;
}

.plain-list li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.cta-panel .cta-text {
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: 14px;
}

.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.toast {
  margin: 14px 0 0;
  color: var(--good);
  font-size: 13px;
  font-weight: 600;
}

/* 题旁小故事：大图在上，文字在下 */
.story-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.35s ease;
}

.story-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.story-label {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: #ffe9dc;
  color: #c46b2c;
  font-size: 12px;
  font-weight: 700;
}

.story-cast {
  display: flex;
  align-items: center;
}

.cast-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
  background: var(--accent-soft);
  box-shadow: 0 4px 10px rgba(35, 32, 80, 0.12);
  margin-left: -6px;
}

.cast-avatar:first-child {
  margin-left: 0;
}

.cast-names {
  margin-left: 10px;
  color: var(--muted);
  font-size: 12px;
}

.story-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.story-image-wrap {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #efe9ff, #ffe8d6);
}

.story-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-text {
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.8;
}

/* 人群分布统计 */
.stats-panel {
  overflow: hidden;
}

.stats-head {
  margin-bottom: 8px;
}

.stats-sub {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.stats-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  align-items: center;
}

.donut-wrap {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 0 auto;
}

.donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 40px;
}

.donut-center-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.donut-center-type {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--ink);
  line-height: 1.2;
}

.donut-center-name {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 600;
}

.stats-side {
  display: grid;
  gap: 14px;
}

.you-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(91, 92, 230, 0.1), rgba(255, 150, 100, 0.12));
  border: 1px solid rgba(91, 92, 230, 0.18);
}

.you-badge {
  grid-row: span 2;
  align-self: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.you-type {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.you-desc {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.55;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid transparent;
  font-size: 12px;
  color: var(--ink-2);
}

.legend-item.you {
  border-color: rgba(91, 92, 230, 0.35);
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 700;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.legend-code {
  font-weight: 700;
  color: var(--ink);
  min-width: 36px;
}

.legend-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(27, 28, 46, 0.08);
  overflow: hidden;
}

.legend-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 8px 20px 36px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 720px) {
  .dim-grid {
    grid-template-columns: 1fr;
  }

  .question-card {
    padding: 28px 18px;
  }

  .quiz-actions {
    flex-direction: column-reverse;
  }

  .quiz-actions .primary-btn,
  .quiz-actions .secondary-btn,
  .cta-actions .primary-btn,
  .cta-actions .secondary-btn {
    width: 100%;
  }

  .hero {
    padding-top: 12px;
  }

  .meta-chip {
    min-width: 0;
    flex: 1;
  }

  /* 小屏：第一行 2 个，第二行中立 1 个居中，第三行 2 个 */
  .scale {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .scale-btn {
    min-height: 76px;
    padding: 12px 10px;
  }

  .scale-btn[data-value="0"] {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc(50% - 5px);
  }

  .story-image-wrap {
    aspect-ratio: 16 / 10;
  }

  .stats-layout {
    grid-template-columns: 1fr;
  }

  .donut-wrap {
    width: 240px;
    height: 240px;
  }

  .legend {
    grid-template-columns: 1fr;
    max-height: none;
  }
}

/* 三语：语言切换 */
.page-tools {
  display: flex;
  justify-content: flex-end;
  padding: 8px 0 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.lang-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.lang-btn:hover {
  background: rgba(91, 92, 230, 0.1);
  color: var(--ink);
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

/* 按语言微调字体栈 */
html[lang="ja"] body,
html[lang="ja"] button {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0.01em;
}

html[lang="en"] body,
html[lang="en"] button {
  font-family: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
}

html[lang="en"] .hero-desc,
html[lang="en"] .type-summary,
html[lang="en"] .cta-text,
html[lang="en"] .story-text {
  line-height: 1.75;
}

html[lang="ja"] .hero-desc,
html[lang="ja"] .type-summary,
html[lang="ja"] .story-text {
  line-height: 1.9;
}

@media (max-width: 640px) {
  .lang-btn {
    padding: 7px 8px;
    font-size: 11px;
  }
}
