:root {
  --ink: #2D2458;
  --muted: #8880B0;
  --primary: #6B5DB8;
  --accent: #7B68C8;
  --bg: #E8E4F2;
  --line: #DDD8EE;
  --paper: rgba(255, 255, 255, 0.9);
  --soft: #F7F4FD;
  --shadow: 0 4px 20px rgba(107, 93, 184, 0.1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(145deg, #E8E4F2, #EFEAF7 55%, #E4DFEF);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
h1, h2, p { margin-top: 0; }

.shell {
  width: 100%;
  max-width: 680px;
  margin: auto;
  padding: 20px 16px 56px;
}

.hidden { display: none !important; }

.card,
.q-header,
.q-body,
.top-card,
.report-section {
  background: var(--paper);
  box-shadow: var(--shadow);
  border: 1px solid rgba(107, 93, 184, 0.08);
}

.card {
  border-radius: 24px;
  padding: 24px 22px;
  margin-bottom: 18px;
}

.icon-box {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: #fff;
  margin: 14px auto 16px;
  box-shadow: 0 8px 28px rgba(107, 93, 184, 0.35);
}

.hero-title {
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  line-height: 1.35;
  margin-bottom: 7px;
}

.hero-title em {
  font-style: normal;
  color: var(--primary);
}

.hero-sub {
  font-size: 12px;
  color: #9180CC;
  letter-spacing: 3px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 22px;
}

.lead {
  font-size: 14px;
  color: #615985;
  line-height: 1.8;
  text-align: center;
  margin-bottom: 20px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 18px;
}

.stat {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 18px;
  padding: 15px 10px;
  text-align: center;
  box-shadow: 0 2px 14px rgba(107, 93, 184, 0.08);
  color: #756D9E;
  font-size: 12px;
}

.stat b {
  display: block;
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 3px;
}

.info-box {
  background: rgba(255, 255, 255, 0.65);
  border-left: 3px solid var(--primary);
  border-radius: 14px;
  padding: 13px 16px;
  color: #5D5682;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 18px;
}

.eyebrow {
  font-size: 13px;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

.btn {
  border: none;
  border-radius: 16px;
  padding: 15px 20px;
  cursor: pointer;
  font-weight: 800;
  transition: 0.15s transform, 0.15s box-shadow, 0.15s background;
}

.btn:hover { transform: translateY(-2px); }

.btn:focus-visible,
.choice:focus-visible,
.nav-btn:focus-visible {
  outline: 3px solid rgba(123, 104, 200, 0.22);
  outline-offset: 3px;
}

.primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
  box-shadow: 0 8px 24px rgba(107, 93, 184, 0.35);
  font-size: 17px;
  letter-spacing: 1px;
}

.ghost {
  width: 100%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid var(--line);
  color: #5A5190;
}

.intro-actions { display: grid; gap: 10px; }

.preference h2 {
  font-size: 22px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.choice {
  width: 100%;
  border: 2px solid #E2DCF5;
  border-radius: 16px;
  background: var(--soft);
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: 0.16s all;
}

.choice:hover {
  border-color: var(--accent);
  background: rgba(123, 104, 200, 0.06);
  transform: translateX(3px);
}

.choice.selected {
  border-color: var(--accent);
  background: rgba(123, 104, 200, 0.1);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123, 104, 200, 0.08);
}

.choice .letter {
  width: 22px;
  flex: 0 0 22px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

.answer .letter { font-size: 0; }
.answer .letter::before { content: "○"; font-size: 19px; }
.answer.selected .letter::before { content: "●"; }

.gender-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #9180CC, #6B5DB8);
  font-weight: 900;
  flex: 0 0 auto;
}

.choice strong { font-size: 15px; display: block; }

.choice small {
  display: block;
  color: #8D86AE;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.nav .btn { width: auto; }

.nav .btn[disabled],
.nav-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.q-header {
  border-radius: 20px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.q-meta {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.q-cat { font-size: 13px; font-weight: 800; color: var(--primary); }
.q-count { font-size: 13px; color: var(--muted); }
.q-pct { font-size: 13px; font-weight: 800; color: var(--accent); }

.progress-track {
  height: 8px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  border-radius: 99px;
  transition: width 0.38s ease;
}

.q-body {
  border-radius: 24px;
  padding: 28px 24px;
  margin-bottom: 18px;
  min-height: 560px;
}

.q-text {
  font-size: 21px;
  font-weight: 900;
  line-height: 1.45;
  margin: 10px 0 22px;
}

.q-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

.nav-btn {
  padding: 12px 17px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  font-size: 14px;
  color: #746C9A;
}

.auto-hint {
  font-size: 12px;
  color: #9B94C8;
  flex: 1;
  text-align: center;
  line-height: 1.4;
  transition: 0.2s;
}

.auto-hint.active {
  color: var(--primary);
  font-weight: 700;
}

.result { padding: 0; }

.top-card {
  border-radius: 28px;
  padding: 30px 24px 26px;
  text-align: center;
  margin-bottom: 18px;
}

.top-sub {
  font-size: 15px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.top-icon-emoji {
  font-size: 44px;
  margin-bottom: 5px;
}

.match-pct {
  font-size: 42px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
  margin: 8px 0;
}

.result-name {
  font-size: 48px;
  font-weight: 900;
  margin: 10px 0 6px;
}

.person-title {
  font-size: 15px;
  color: #8279AE;
  margin-bottom: 16px;
  line-height: 1.6;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.tag {
  background: rgba(107, 93, 184, 0.1);
  color: var(--primary);
  border: 1px solid rgba(107, 93, 184, 0.18);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 700;
}

.dominant-chip {
  display: inline-block;
  margin: 12px 0 0;
  padding: 7px 14px;
  border-radius: 20px;
  background: #F1EDF9;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.match-reason {
  background: linear-gradient(135deg, rgba(232, 228, 242, 0.8), rgba(237, 234, 245, 0.6));
  border-radius: 16px;
  padding: 15px 18px;
  text-align: left;
  margin-top: 16px;
  border: 1px solid rgba(107, 93, 184, 0.1);
}

.reason-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  display: block;
  margin-bottom: 8px;
}

.quote {
  font-size: 17px;
  color: #514A75;
  line-height: 1.85;
  margin: 0;
}

.report-section {
  border-radius: 24px;
  padding: 23px;
  margin-bottom: 18px;
}

.section-title {
  font-size: 19px;
  font-weight: 900;
  margin-bottom: 16px;
}

#sourceNote { margin: 14px 0 0; }

.bio {
  font-size: 17px;
  line-height: 1.9;
  color: #514A75;
}

.dimension-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dim-row {
  display: grid;
  grid-template-columns: 64px 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #655D8F;
}

.dim-bar {
  height: 8px;
  background: #F0EDF8;
  border-radius: 99px;
  overflow: hidden;
}

.dim-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  border-radius: inherit;
}

.three {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.note {
  background: #FAF8FF;
  border: 1px solid #E2DCF5;
  border-radius: 17px;
  padding: 18px 17px;
  line-height: 1.8;
  color: #625B86;
  font-size: 16px;
}

.note b {
  display: block;
  color: var(--ink);
  margin-bottom: 7px;
  font-size: 17px;
}

.share-actions {
  display: grid;
  gap: 10px;
  margin: 22px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  width: max-content;
  max-width: min(520px, calc(100% - 32px));
  background: #2D2458;
  color: #fff;
  padding: 11px 18px;
  border-radius: 18px;
  text-align: center;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.save-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18px;
  background: rgba(45, 36, 88, 0.52);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.save-panel {
  width: min(680px, 100%);
  margin: auto;
  background: #fff;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 24px 70px rgba(45, 36, 88, 0.3);
}

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

.save-panel-head h2 {
  margin: 0;
  font-size: 20px;
}

.save-close {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ECE6FA;
  font-size: 24px;
  cursor: pointer;
}

.save-tip {
  margin: 0 2px 14px;
  color: #625B86;
  font-size: 14px;
  line-height: 1.7;
}

.save-preview {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

.save-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.save-buttons .btn {
  flex: 1 1 190px;
  min-height: 46px;
  font-size: 15px;
}

.micro {
  font-size: 13px;
  color: #8D86AE;
  text-align: center;
  line-height: 1.65;
}

body.locked { overflow: hidden; }
.app-locked { display: none; }

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(145deg, #E8E4F2, #EFEAF7);
}

.access-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.lock-mark {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
  font-size: 32px;
  box-shadow: 0 8px 28px rgba(107, 93, 184, 0.35);
}

.access-card h1 {
  font-size: 25px;
  margin-bottom: 8px;
}

.access-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.access-input {
  display: block;
  width: 100%;
  margin: 20px auto 14px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 12px;
  color: var(--primary);
  outline: 0;
}

.access-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(123, 104, 200, 0.15);
}

.access-error {
  min-height: 22px;
  margin: 10px 0 0 !important;
  color: #EF4444 !important;
  font-size: 13px;
  opacity: 0;
}

.access-error.show { opacity: 1; }

@media (min-width: 640px) {
  .three { grid-template-columns: repeat(3, 1fr); }
  .share-actions { grid-template-columns: 1fr 1fr; }
  .intro-actions { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .shell { padding: 12px 12px 40px; }
  .card, .q-body { padding: 22px 17px; }
  .q-body { min-height: 610px; }
  .q-header { padding: 15px 16px; }
  .q-meta { gap: 7px; }
  .q-text { font-size: 19px; }
  .choice { padding: 15px 13px; }
  .nav-btn { padding: 11px 12px; }
  .auto-hint { font-size: 11px; }
  .report-section { padding: 23px 18px; }
  .result-name { font-size: 42px; }
  .person-title { font-size: 15px; }
  .quote, .bio { font-size: 17px; }
  .dim-row {
    grid-template-columns: 60px 1fr 56px;
    font-size: 14px;
  }
}

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