:root {
  --ink: #111629;
  --ink-soft: #566078;
  --paper: #fbfaf6;
  --line: #dfe2e8;
  --yellow: #f7c95c;
  --purple: #7e65d1;
  --green: #55a77c;
  --blue: #5b8fc8;
  --shadow: 0 24px 80px rgba(17, 22, 41, .16);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(126,101,209,.32), transparent 30rem),
    radial-gradient(circle at 92% 80%, rgba(247,201,92,.18), transparent 28rem),
    var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 720px);
  min-height: 100svh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.view { min-height: 100svh; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); }
.intro-view { display: flex; flex-direction: column; position: relative; isolation: isolate; }
.brand-row, .quiz-header, .access-meta, .progress-label, .choice-poles, .scale-caption { display: flex; align-items: center; justify-content: space-between; }
.brand-mark { font-weight: 900; letter-spacing: -.04em; background: var(--ink); color: white; padding: 9px 10px; border-radius: 10px; }
.brand-note { color: var(--ink-soft); font-size: .875rem; letter-spacing: .12em; }

.intro-copy { margin-top: clamp(34px, 6vh, 58px); position: relative; z-index: 2; }
.eyebrow { margin: 0 0 18px; color: var(--purple); font-size: .8rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.mbti-title { display: flex; flex-direction: column; margin: 0; line-height: .78; letter-spacing: -.09em; }
.mbti-main { color: var(--ink); font-size: clamp(5.4rem, 24vw, 9.2rem); font-weight: 950; }
.mbti-outline { margin-top: 13px; color: transparent; -webkit-text-stroke: 1.4px var(--ink); font-size: clamp(1.55rem, 7.7vw, 3rem); font-weight: 900; letter-spacing: .02em; }
.lead { max-width: 31rem; margin: 24px 0 0; color: var(--ink-soft); font-size: 1.05rem; line-height: 1.7; }

.emoji-galaxy { position: relative; z-index: 1; width: min(100%, 430px); height: clamp(280px, 39vh, 360px); margin: -2px auto -18px; overflow: hidden; }
.emoji-galaxy::before { content: ""; position: absolute; left: 50%; top: 51%; width: 236px; height: 236px; border-radius: 50%; background: radial-gradient(circle, rgba(126,101,209,.16), rgba(126,101,209,.055) 42%, transparent 70%); transform: translate(-50%,-50%); filter: blur(14px); animation: cluster-glow 9s ease-in-out infinite; }
.emoji-ring { position: absolute; left: 50%; top: 51%; width: 0; height: 0; animation: ring-rotate 36s linear infinite; }
.orbit-node { position: absolute; left: 0; top: 0; width: var(--size); height: var(--size); margin: var(--half) 0 0 var(--half); transform: rotate(var(--angle)) translateY(calc(0px - var(--radius))); transform-origin: 50% 50%; animation: bubble-release 18s cubic-bezier(.45,0,.2,1) infinite; animation-delay: var(--delay); }
.orbit-emoji, .emoji-core { display: block; background-image: url('./assets/personality-emoji-sprite.png'); background-repeat: no-repeat; background-size: 400% 400%; filter: drop-shadow(0 13px 13px rgba(31,35,55,.18)); }
.orbit-emoji { width: 100%; height: 100%; transform: rotate(calc(var(--angle) * -1)); animation: emoji-counter 36s linear infinite; }
.emoji-core { position: absolute; left: 50%; top: 51%; z-index: 3; width: clamp(88px, 27vw, 108px); height: clamp(88px, 27vw, 108px); transform: translate(-50%,-50%); animation: core-float 7s ease-in-out infinite; }
@keyframes ring-rotate { to { transform: rotate(360deg); } }
@keyframes emoji-counter { to { rotate: -360deg; } }
@keyframes bubble-release {
  0%, 17%, 100% { transform: rotate(var(--angle)) translateY(calc(0px - var(--radius))) scale(.94); }
  6%, 10% { transform: rotate(var(--angle)) translateY(calc(-22px - var(--radius))) scale(1.18); }
}
@keyframes core-float { 0%,100% { transform: translate(-50%,-51%) scale(.97); } 50% { transform: translate(-50%,-49%) scale(1.03); } }
@keyframes cluster-glow { 0%,100% { opacity: .64; transform: translate(-50%,-50%) scale(.94); } 50% { opacity: 1; transform: translate(-50%,-50%) scale(1.04); } }

.access-card { position: relative; z-index: 5; margin-top: auto; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.88); backdrop-filter: blur(12px); }
.access-card label { display: block; margin-bottom: 10px; font-weight: 750; }
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
input { min-width: 0; border: 1px solid #cbd0da; border-radius: 12px; padding: 14px; color: var(--ink); background: white; text-transform: uppercase; outline: none; }
input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(126,101,209,.14); }
.primary-btn { border: 0; border-radius: 12px; padding: 14px 18px; color: white; background: var(--ink); font-weight: 800; transition: transform .18s ease, background .18s ease; }
.primary-btn:hover { background: #242b45; transform: translateY(-1px); }
.access-meta { min-height: 20px; margin-top: 9px; color: #7d8496; font-size: .75rem; }
.error-text { color: #bd3d4a; }
.fine-print { margin: 16px 0 0; color: #848b9a; text-align: center; font-size: .75rem; line-height: 1.5; }
.returning-actions { position: relative; z-index: 5; display: grid; gap: 10px; margin-top: auto; }
.returning-actions .primary-btn { min-height: 54px; }
.text-btn { border: 0; padding: 8px; color: var(--ink-soft); background: transparent; font-weight: 700; }

.quiz-view { background: linear-gradient(180deg, #f7f5ee 0%, #fbfaf6 45%); }
.quiz-header { gap: 16px; }
.icon-btn { width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: white; font-size: 1.35rem; }
.progress-wrap { flex: 1; }
.progress-label { margin-bottom: 8px; color: var(--ink-soft); font-size: .75rem; }
.progress-track { height: 5px; overflow: hidden; border-radius: 10px; background: #e1e3e8; }
.progress-track span { display: block; width: 4.16%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), #a18fea); transition: width .3s ease; }
.question-card { margin-top: clamp(64px, 12vh, 110px); }
.dimension-tag { width: fit-content; margin: 0 0 22px; padding: 7px 11px; border-radius: 100px; color: #5945a4; background: #ebe6fb; font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
.question-card h2 { min-height: 4.8em; margin: 0; font-size: clamp(1.75rem, 7vw, 2.7rem); line-height: 1.35; letter-spacing: -.035em; }
.choice-poles { gap: 28px; margin-top: 36px; font-weight: 750; line-height: 1.45; }
.choice-poles span { width: 44%; }
.choice-poles span:last-child { text-align: right; }
.answer-scale { display: flex; align-items: center; justify-content: space-between; margin: 32px 8px 14px; }
.answer-dot { width: 54px; height: 54px; border: 2px solid #c9ced8; border-radius: 50%; background: transparent; transition: .16s ease; }
.answer-dot:nth-child(2), .answer-dot:nth-child(4) { width: 46px; height: 46px; }
.answer-dot:nth-child(3) { width: 38px; height: 38px; }
.answer-dot:hover, .answer-dot:focus-visible { border-color: var(--purple); background: rgba(126,101,209,.1); transform: scale(1.07); outline: none; }
.answer-dot.selected { border-color: var(--purple); background: var(--purple); box-shadow: 0 0 0 7px rgba(126,101,209,.13); }
.scale-caption { color: #8a91a1; font-size: .75rem; }
.quiz-tip { margin: 70px auto 0; color: #8a91a1; text-align: center; font-size: .82rem; }

.loading-view { display: grid; place-content: center; text-align: center; background: var(--ink); color: white; }
.loading-complete { width: fit-content; margin: 0 auto 36px; padding: 9px 13px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; color: #dce1ef; background: rgba(255,255,255,.06); font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
.loading-complete span { color: var(--yellow); }
.loading-view p { margin: 28px 0 6px; font-size: 1.35rem; font-weight: 800; }
.loading-view small { min-height: 1.5em; color: #aeb6cc; }
.loader-orbit { width: 106px; height: 106px; margin: auto; position: relative; animation: orbit 4.8s linear infinite; }
.loader-orbit span { position: absolute; width: 38px; height: 38px; border-radius: 14px; transform: rotate(45deg); }
.loader-orbit span:nth-child(1) { left: 34px; top: 0; background: var(--purple); }
.loader-orbit span:nth-child(2) { right: 0; top: 34px; background: var(--green); }
.loader-orbit span:nth-child(3) { left: 34px; bottom: 0; background: var(--yellow); }
.loader-orbit span:nth-child(4) { left: 0; top: 34px; background: var(--blue); }
.personality-loading-track { width: min(70vw, 310px); height: 8px; margin: 30px auto 0; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.12); }
.personality-loading-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), var(--blue), var(--yellow)); box-shadow: 0 0 22px rgba(126,101,209,.55); }
.loading-percent { display: block; margin-top: 12px; color: white; font-size: .84rem; font-variant-numeric: tabular-nums; letter-spacing: .08em; }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .emoji-ring, .orbit-node, .orbit-emoji, .emoji-core, .emoji-galaxy::before, .loader-orbit { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

.result-view { padding: 0; background: #f2f1ec; }
.result-hero { position: relative; overflow: hidden; padding: max(28px, env(safe-area-inset-top)) 26px 38px; color: white; background: linear-gradient(155deg, color-mix(in srgb, var(--group-color) 84%, #111629), var(--group-color)); isolation: isolate; }
.result-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.24), transparent 37%), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: auto, 42px 42px, 42px 42px; mask-image: linear-gradient(to bottom, #000 0 68%, transparent 96%); }
.result-topbar { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 3; }
.result-brand { display: flex; align-items: center; gap: 9px; font-size: .76rem; font-weight: 800; letter-spacing: .08em; }
.result-brand b { display: grid; place-content: center; width: 34px; height: 34px; border-radius: 10px; color: var(--ink); background: white; letter-spacing: -.04em; }
.ghost-btn { border: 1px solid rgba(255,255,255,.45); border-radius: 100px; padding: 9px 13px; color: white; background: rgba(255,255,255,.1); font-size: .8rem; font-weight: 700; }
.result-code { position: relative; z-index: 3; margin: 12px 0 0; text-align: center; font-size: .78rem; font-weight: 850; letter-spacing: .18em; opacity: .82; }
.result-character-stage { position: relative; width: min(100%, 500px); margin: 8px auto 0; }
.result-character-art { width: 100%; aspect-ratio: 1; background-image: url('./assets/personality-emoji-sprite.png'); background-repeat: no-repeat; background-size: 400% 400%; filter: drop-shadow(0 30px 28px rgba(17,22,41,.28)); }
.hero-keywords { position: absolute; left: 0; right: 0; bottom: 16px; z-index: 2; margin: 0; }
.hero-keywords span { color: var(--ink); border: 0; background: rgba(255,255,255,.88); box-shadow: 0 7px 20px rgba(17,22,41,.12); backdrop-filter: blur(10px); }
.type-label { margin: 7px 0 0; text-align: center; font-size: .8rem; font-weight: 800; letter-spacing: .16em; opacity: .8; }
.result-hero h1 { margin: 11px 0 0; color: white; text-align: center; font-size: clamp(2.5rem, 11vw, 4.4rem); line-height: 1.08; letter-spacing: -.06em; }
.result-hero h1 span { color: white; -webkit-text-stroke: 0; }
.result-quote { max-width: 33rem; margin: 18px auto 0; text-align: center; font-size: 1rem; line-height: 1.7; opacity: .92; }
.keyword-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.keyword-row span { padding: 8px 11px; border: 1px solid rgba(255,255,255,.34); border-radius: 100px; background: rgba(255,255,255,.1); font-size: .78rem; }

.result-body { padding: 22px 18px 44px; }
.report-card { margin-bottom: 14px; padding: 22px; border: 1px solid #e1e2e2; border-radius: 22px; background: white; box-shadow: 0 8px 30px rgba(17,22,41,.05); }
.section-kicker { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; color: var(--group-color, var(--purple)); font-size: .76rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.section-kicker::before { content: ""; width: 22px; height: 2px; background: currentColor; }
.report-card h2 { margin: 0 0 13px; font-size: 1.35rem; letter-spacing: -.03em; }
.report-card p { margin: 0; color: #586177; line-height: 1.82; }
.dimension-list { display: grid; gap: 20px; }
.dimension-head { display: grid; grid-template-columns: 36px 1fr 36px; align-items: end; gap: 11px; margin-bottom: 8px; font-weight: 900; }
.dimension-head span:nth-child(2) { color: #7d8597; text-align: center; font-size: .76rem; font-weight: 650; }
.dimension-head span:last-child { text-align: right; }
.dimension-track { height: 10px; overflow: hidden; border-radius: 100px; background: #eceef2; }
.dimension-fill { height: 100%; border-radius: inherit; background: var(--group-color, var(--purple)); }
.dimension-detail { display: flex; justify-content: space-between; margin-top: 7px; color: #8a91a1; font-size: .72rem; }
.split-grid { display: grid; gap: 14px; }
.insight-block { padding: 16px; border-radius: 16px; background: #f6f5f1; }
.insight-block h3 { margin: 0 0 7px; font-size: .95rem; }
.insight-block p { font-size: .9rem; line-height: 1.7; }
.match-list { display: grid; gap: 10px; }
.match-item { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 16px; }
.mini-avatar, .atlas-avatar, .dialog-avatar { background-image: url('./assets/personality-emoji-sprite.png'); background-size: 400% 400%; background-repeat: no-repeat; }
.mini-avatar { width: 48px; height: 48px; border-radius: 14px; }
.match-item strong { display: block; }
.match-item small { color: #828a9b; }
.match-score { font-size: .9rem; font-weight: 850; color: var(--group-color, var(--purple)); }
.result-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 18px 0 28px; }
.result-actions button { min-height: 52px; border-radius: 14px; font-weight: 800; }
.save-btn { border: 0; color: white; background: var(--ink); }
.share-btn { border: 1px solid #cfd3dc; color: var(--ink); background: white; }
.secondary-actions { display: flex; justify-content: center; gap: 22px; margin-bottom: 34px; }
.secondary-actions button { border: 0; color: #626b7e; background: transparent; font-size: .86rem; font-weight: 750; text-decoration: underline; text-underline-offset: 4px; }
.atlas-title { margin: 0 0 7px; font-size: 1.5rem; }
.atlas-intro { margin: 0 0 17px; color: #747d90; line-height: 1.65; }
.type-atlas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.atlas-card { min-width: 0; border: 1px solid #e0e2e6; border-radius: 15px; padding: 8px 6px 10px; background: white; text-align: center; }
.atlas-card.active { border-color: var(--group-color, var(--purple)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--group-color, var(--purple)) 22%, transparent); }
.atlas-avatar { width: 100%; aspect-ratio: 1; border-radius: 11px; }
.atlas-card strong { display: block; margin-top: 7px; font-size: .78rem; }
.atlas-card small { display: block; overflow: hidden; color: #7c8496; font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.result-disclaimer { margin: 28px 12px 0; color: #8b92a0; text-align: center; font-size: .72rem; line-height: 1.6; }

.radar-layout { display: grid; gap: 18px; align-items: center; }
.radar-chart { width: min(100%, 360px); margin: 0 auto; overflow: visible; }
.radar-grid { fill: none; stroke: #dfe2e8; stroke-width: 1; }
.radar-axis { stroke: #d5d9e1; stroke-width: 1; }
.radar-shape { fill: color-mix(in srgb, var(--group-color) 24%, transparent); stroke: var(--group-color); stroke-width: 3; stroke-linejoin: round; }
.radar-dot { fill: white; stroke: var(--group-color); stroke-width: 3; }
.radar-label { fill: #4c556b; font-size: 12px; font-weight: 800; }
.radar-score-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.radar-score { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 13px; background: #f3f3ef; color: #60697c; font-size: .82rem; }
.radar-score b { color: var(--group-color); }
.career-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 18px; }
.career-chip { display: flex; align-items: center; min-height: 52px; padding: 12px 13px; border: 1px solid color-mix(in srgb, var(--group-color) 25%, #dfe2e8); border-radius: 15px; color: #394258; background: color-mix(in srgb, var(--group-color) 7%, white); font-size: .88rem; font-weight: 750; line-height: 1.35; }
.career-note { margin-top: 16px !important; padding-top: 16px; border-top: 1px solid #e6e7e9; font-size: .9rem; }

.type-dialog { width: min(calc(100% - 28px), 520px); max-height: 84svh; overflow: auto; border: 0; border-radius: 26px; padding: 28px; color: var(--ink); background: white; box-shadow: 0 30px 100px rgba(13,18,35,.35); }
.type-dialog::backdrop { background: rgba(17,22,41,.68); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; top: 0; z-index: 2; float: right; width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--ink); background: #f0f1f3; font-size: 1.35rem; }
.dialog-avatar { width: 164px; height: 164px; margin: 8px auto 20px; border-radius: 0; }
.atlas-avatar, .mini-avatar { border-radius: 0; }
.role-explanation h3 { margin: 12px 0; color: var(--group-color); font-size: 2rem; }
.role-explanation .role-eyebrow { font-size: .82rem; font-weight: 800; color: var(--group-color); }
.role-explanation small { display:block; margin-top:16px; color:#8a91a1; line-height:1.6; }
.ability-list { display:grid; gap:14px; margin-top:24px; }
.ability-row { display:grid; grid-template-columns:38px 1fr 32px; gap:14px; align-items:center; color:#566078; font-size:.88rem; }
.ability-row b { text-align:right; font-size:.82rem; font-weight:650; }
.ability-track { height:7px; background:#e8e5ef; border-radius:999px; overflow:hidden; }
.ability-track i { display:block; height:100%; background:var(--group-color); border-radius:inherit; }
.ability-note { margin-top:20px !important; font-size:.78rem; color:#8a91a1 !important; line-height:1.6 !important; }
.inspiration-card { margin:24px 0; padding:36px 24px; color:var(--group-color); text-align:center; }
.inspiration-card blockquote { margin:0; font-family:Georgia,'Songti SC',serif; font-size:1.5rem; line-height:1.85; }
.inspiration-card cite { display:block; margin-top:18px; font-family:system-ui,sans-serif; font-size:.84rem; font-style:normal; color:#788095; }
.dialog-code { margin: 0; color: var(--dialog-color, var(--purple)); text-align: center; font-size: .8rem; font-weight: 900; letter-spacing: .14em; }
.type-dialog h2 { margin: 8px 0 14px; text-align: center; font-size: 1.8rem; }
.type-dialog p { color: #5d667a; line-height: 1.75; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 50; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 100px; color: white; background: var(--ink); box-shadow: 0 16px 48px rgba(0,0,0,.26); font-size: .84rem; font-weight: 750; transform: translate(-50%, 120px); opacity: 0; transition: .25s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 721px) {
  body { padding: 28px 0; }
  .app-shell, .view { min-height: calc(100svh - 56px); }
  .app-shell { border-radius: 28px; }
  .view { padding-left: 46px; padding-right: 46px; }
  .result-view { padding: 0; }
  .result-body { padding: 28px 34px 52px; }
  .split-grid { grid-template-columns: 1fr 1fr; }
  .radar-layout { grid-template-columns: 1.2fr .8fr; }
}

@media (max-width: 480px) {
  .view { padding-left: 18px; padding-right: 18px; }
  .intro-copy { margin-top: 34px; }
  .emoji-galaxy { margin-top: -6px; }
  .orbit-node { --radius: 112px !important; }
  .code-row { grid-template-columns: 1fr; }
  .primary-btn { width: 100%; }
  .answer-dot { width: 48px; height: 48px; }
  .answer-dot:nth-child(2), .answer-dot:nth-child(4) { width: 42px; height: 42px; }
  .result-hero { min-height: 0; }
  .result-actions { grid-template-columns: 1fr; }
  .type-atlas { gap: 7px; }
  .atlas-card { padding-left: 4px; padding-right: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
.entry-gate { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.entry-gate[hidden] { display: none; }
.entry-content { width: min(100%,480px); }
.entry-content h1 { font-size: clamp(1.8rem,6vw,2.5rem); margin: 32px 0; }
.entry-content input { letter-spacing: .2em; min-width: 0; }
.match-medal { font-size: 2rem; line-height: 1; }
