/* ==================== RESET & CSS VARS ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #4A3278;
  --primary-light: #7B6FE0;
  --primary-dark:  #2D1F72;
  --accent:        #B8A8F0;
  --bg:            #F5F3EF;
  --surface:       #FEFCF8;
  --border:        #E8E0F4;
  --text:          #221A12;
  --text-muted:    #6A5A8A;
  --nav-h:         62px;
  --r-card:        18px;
  --r-btn:         12px;
  --shadow:        0 2px 16px rgba(74,56,112,0.08);
  --shadow-hover:  0 8px 32px rgba(74,56,112,0.16);
  --col-w:         800px;
  --pad-x:         48px;
}

body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Segoe UI', 'Helvetica Neue', sans-serif;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { width: 100%; min-height: 100vh; }

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes float  { 0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)} }
@keyframes bob    { 0%,100%{transform:translateY(0) scaleY(1)}40%{transform:translateY(-6px) scaleY(1.05)}70%{transform:translateY(2px) scaleY(0.97)} }
@keyframes shake  { 0%,100%{transform:rotate(0deg)}20%,60%{transform:rotate(-5deg)}40%,80%{transform:rotate(5deg)} }
@keyframes bounce { 0%,100%{transform:translateY(0)}30%{transform:translateY(-10px)}50%{transform:translateY(-3px)}70%{transform:translateY(-7px)} }
@keyframes pulse  { 0%,100%{transform:scale(1)}50%{transform:scale(1.05)} }
@keyframes revealMbti { 0%{opacity:0;transform:scale(.8) translateY(14px);filter:blur(6px)}100%{opacity:1;transform:scale(1) translateY(0);filter:blur(0)} }
@keyframes analyzingDot { 0%,80%,100%{transform:scale(0)}40%{transform:scale(1)} }
@keyframes msgSlide { from{opacity:0;transform:translateX(-12px)}to{opacity:1;transform:translateX(0)} }
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.anim-float  { animation: float  3s   ease-in-out infinite; }
.anim-bob    { animation: bob    2.5s ease-in-out infinite; }
.anim-shake  { animation: shake  2s   ease-in-out infinite; }
.anim-bounce { animation: bounce 2s   ease-in-out infinite; }
.anim-pulse  { animation: pulse  2.5s ease-in-out infinite; }
.anim-still  {}

/* ==================== NAVBAR ==================== */
.navbar {
  height: var(--nav-h);
  background: rgba(250,248,244,0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 200;
}
.navbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 var(--pad-x);
  height: 100%; display: flex; align-items: center; gap: 16px;
}
.navbar-logo { display: flex; align-items: center; gap: 10px; cursor: pointer; flex-shrink: 0; }
.navbar-logo-icon { font-size: 24px; }
.navbar-logo-name { font-size: 16px; font-weight: 900; color: var(--primary-dark); }
.navbar-logo-sub  { font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.navbar-spacer    { flex: 1; }
.navbar-btn {
  display: flex; align-items: center; gap: 6px; border: none; border-radius: var(--r-btn);
  padding: 8px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
}
.navbar-btn.ghost { background: rgba(74,50,120,0.07); color: var(--primary); }
.navbar-btn.ghost:hover { background: rgba(74,50,120,0.14); }
.navbar-btn.solid {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #FAF4EC; box-shadow: 0 4px 14px rgba(74,50,120,0.28);
}
.navbar-btn.solid:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(74,50,120,0.36); }
.navbar-btn.secondary { background: #EDE8F8; color: var(--primary); border: 1.5px solid var(--border); }
.navbar-btn.secondary:hover { background: #E4DFF4; }

/* ==================== HOME PAGE ==================== */
.home-wrap { animation: fadeIn 0.4s ease; }

/* ── Hero Banner ── */
.hero-banner {
  background: linear-gradient(145deg, #1A0F4E 0%, #3D2EA8 35%, #6B5ED4 65%, #A898E8 100%);
  padding: 72px 0 0; position: relative; overflow: hidden;
}
.hero-banner::before {
  content: ''; position: absolute; left: -100px; bottom: -100px;
  width: 500px; height: 500px; background: rgba(255,255,255,0.04); border-radius: 50%;
}
.hero-banner::after {
  content: ''; position: absolute; right: 8%; top: -60px;
  width: 320px; height: 320px; background: rgba(255,255,255,0.04); border-radius: 50%;
}
.hero-inner {
  max-width: var(--col-w); margin: 0 auto; padding: 0 var(--pad-x);
  position: relative; z-index: 1;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px; padding: 5px 14px; font-size: 12px;
  color: rgba(250,244,236,0.85); font-weight: 600; letter-spacing: 1.5px; margin-bottom: 20px;
}
.hero-h1 {
  font-size: 52px; font-weight: 900; color: #FAF4EC;
  line-height: 1.2; letter-spacing: -1px;
  text-shadow: 0 2px 16px rgba(0,0,0,0.2); margin-bottom: 14px;
}
.hero-h1 em { font-style: normal; color: #D4C4FF; }
.hero-subtitle {
  font-size: 16px; color: rgba(250,244,236,0.72); line-height: 1.7;
  margin-bottom: 24px; white-space: nowrap;
}
.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 32px; }
.hero-tag {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px; padding: 5px 13px; font-size: 13px;
  color: rgba(250,244,236,0.82); font-weight: 500;
}
.hero-btns { display: flex; gap: 12px; align-items: center; }
.hero-btn-primary {
  background: linear-gradient(135deg, #FAF4EC, #E8E0FF); border: none;
  border-radius: var(--r-btn); padding: 13px 28px; font-size: 15px; font-weight: 800;
  color: var(--primary-dark); cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,0.22);
  transition: transform 0.2s, box-shadow 0.2s; display: flex; align-items: center; gap: 8px;
  font-family: inherit;
}
.hero-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(0,0,0,0.28); }
.hero-btn-outline {
  background: transparent; border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: var(--r-btn); padding: 13px 22px; font-size: 14px; font-weight: 600;
  color: rgba(250,244,236,0.9); cursor: pointer; transition: background 0.2s; font-family: inherit;
}
.hero-btn-outline:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.6); }

/* ── Avatar carousel at bottom of hero ── */
@keyframes heroScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.hero-avatar-strip {
  overflow: hidden; margin: 36px 0 0; padding-bottom: 44px;
  position: relative; z-index: 1;
  /* fade edges to give breathing room */
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 80px, black calc(100% - 80px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, black 80px, black calc(100% - 80px), transparent 100%);
}
.hero-avatar-track {
  display: flex; gap: 14px; width: max-content;
  animation: heroScroll 36s linear infinite;
  padding: 0 80px;
}
.hero-avatar-track:hover { animation-play-state: paused; }
.hero-pill {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px; padding: 12px 12px 9px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer;
  min-width: 86px; transition: background 0.2s, transform 0.15s;
}
.hero-pill:hover { background: rgba(255,255,255,0.22); transform: translateY(-3px); }
.hero-pill img  { width: 72px; height: 72px; object-fit: contain; }
.hero-pill span { font-size: 11px; font-weight: 800; color: rgba(250,244,236,0.9); }

/* ── Single-column content area ── */
.home-body {
  max-width: var(--col-w); margin: 0 auto; padding: 32px var(--pad-x) 72px;
  display: flex; flex-direction: column; gap: 18px;
}

/* ── Generic card ── */
.card {
  background: var(--surface); border-radius: var(--r-card);
  border: 1.5px solid var(--border); padding: 22px 24px; box-shadow: var(--shadow);
}
.card-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--primary); margin-bottom: 16px;
}

/* ── Picker card collapsible ── */
.picker-card-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.picker-card-header .card-title { margin-bottom: 0; }
.picker-toggle-icon {
  font-size: 11px; color: var(--primary); flex-shrink: 0;
  width: 22px; height: 22px; background: #EDE8F8; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  transition: transform 0.25s;
}
.picker-toggle-icon.open { transform: rotate(180deg); }
.picker-card-body { margin-top: 16px; animation: fadeIn 0.2s ease; }
.picker-hint {
  padding: 13px 18px; background: #F4F0FA; border-radius: 10px;
  border: 1.5px dashed #DDD0EE; text-align: center; color: var(--text-muted);
  font-size: 13px; margin-top: 12px; cursor: pointer;
}
.picker-hint:hover { background: #EDE8F8; border-color: #B0A0E0; }
.picker-hint-inner {
  margin-top: 12px; padding: 12px 16px; background: #F4F0FA; border-radius: 10px;
  text-align: center; color: var(--text-muted); font-size: 13px;
}

/* ── MBTI picker (always visible) ── */
.mbti-char-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.mbti-char-item {
  display: flex; flex-direction: column; align-items: center; padding: 10px 4px 8px;
  border-radius: 11px; cursor: pointer; border: 2px solid transparent;
  transition: all 0.15s; background: #F4F0FA;
}
.mbti-char-item:hover { background: #EDE8F8; border-color: #B0A0E0; transform: translateY(-2px); }
.mbti-char-item.char-selected { background: #E8E0F8; border-color: var(--primary-light); box-shadow: 0 2px 10px rgba(74,50,120,0.18); }
.char-img-wrap     { width: 46px; height: 46px; }
.char-img-wrap img { width: 100%; height: 100%; object-fit: contain; }
.char-mbti-label   { font-size: 11px; font-weight: 800; color: var(--primary-dark); margin-top: 4px; }
.char-role-name    { font-size: 9px; color: var(--primary); margin-top: 2px; text-align: center; }

/* ── Selected MBTI info strip (below picker grid) ── */
.mbti-selected-strip {
  display: flex; align-items: center; gap: 18px; margin-top: 18px;
  padding: 18px 22px; background: linear-gradient(135deg, #F0EBF8, #EAE4F6);
  border-radius: 14px; border: 1.5px solid #D4C8F0;
  box-shadow: 0 2px 12px rgba(74,50,120,0.08);
}
.mbti-sel-img     { width: 68px; height: 68px; flex-shrink: 0; }
.mbti-sel-img img { width: 100%; height: 100%; object-fit: contain; }
.mbti-sel-info    { flex: 1; }
.mbti-sel-type    { font-size: 30px; font-weight: 900; color: var(--primary-dark); line-height: 1; margin-bottom: 5px; }
.mbti-sel-name    { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.mbti-sel-tag     { font-size: 12px; color: var(--text-muted); }
.mbti-sel-badge   {
  background: rgba(74,50,120,0.08); border-radius: 20px;
  padding: 6px 14px; font-size: 12px; color: var(--primary); font-weight: 700; flex-shrink: 0;
}

/* ── Entry buttons ── */
.entry-row { display: flex; gap: 12px; }
.entry-btn {
  flex: 1; background: linear-gradient(135deg, #F2EEF8, #ECE6F6);
  border: 1.5px solid #DDD0EE; border-radius: 16px; padding: 18px 20px;
  cursor: pointer; transition: all 0.15s; text-align: left;
}
.entry-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(74,50,120,0.12); border-color: #B0A0E0; }
.entry-icon  { font-size: 24px; margin-bottom: 10px; display: block; }
.entry-title { font-size: 15px; font-weight: 700; color: var(--primary-dark); display: block; margin-bottom: 4px; }
.entry-sub   { font-size: 12px; color: var(--text-muted); display: block; }
.entry-btn.detail .entry-title { color: #1E4A90; }

/* ── CTA card ── */
.cta-card {
  background: linear-gradient(140deg, var(--primary-dark) 0%, #5B4AC8 60%, var(--primary-light) 100%);
  border-radius: var(--r-card); padding: 32px 28px;
  box-shadow: 0 8px 28px rgba(45,31,114,0.3); display: flex; flex-direction: column; gap: 16px;
}
.cta-title { font-size: 20px; font-weight: 800; color: #FAF4EC; line-height: 1.35; }
.cta-sub   { font-size: 14px; color: rgba(250,244,236,0.7); line-height: 1.65; }
.cta-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.cta-step  { display: flex; align-items: center; gap: 7px; font-size: 12px; color: rgba(250,244,236,0.85); font-weight: 600; }
.cta-step-num {
  width: 22px; height: 22px; background: rgba(255,255,255,0.2); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.cta-arrow { color: rgba(250,244,236,0.4); margin: 0 6px; font-size: 14px; }
.btn-start {
  width: 100%; background: linear-gradient(135deg, #FAF4EC, #E8E0FF); border: none;
  border-radius: var(--r-btn); padding: 17px; font-size: 16px; font-weight: 800;
  color: var(--primary-dark); cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: transform 0.15s, box-shadow 0.15s; font-family: inherit;
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.28); }

/* ── History ── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px;
  border-radius: 12px; background: #F8F4FC; border: 1px solid #EDE8F8;
  cursor: pointer; transition: all 0.15s;
}
.history-item:hover { background: #EDE8F4; transform: translateX(4px); box-shadow: 0 2px 10px rgba(74,50,120,0.1); }
.hist-mbti { font-size: 18px; font-weight: 900; color: var(--primary-dark); min-width: 48px; }
.hist-info  { flex: 1; }
.hist-nick  { font-size: 14px; font-weight: 600; color: var(--text); }
.hist-rel   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.hist-conf  { font-size: 13px; font-weight: 700; color: var(--primary-light); }
.hist-arr   { font-size: 16px; color: #C8B8E8; }

/* ==================== GUESS PAGE ==================== */
.guess-page { animation: fadeIn 0.3s ease; }
.guess-wrap { max-width: var(--col-w); margin: 0 auto; padding: 44px var(--pad-x) 64px; }

/* Step indicator */
.step-indicator { display: flex; align-items: center; margin-bottom: 36px; }
.si-dot {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; background: #EDE8F8; color: var(--text-muted);
  border: 2px solid transparent; transition: all 0.3s;
}
.si-dot.active { background: var(--primary-light); color: #FAF4EC; border-color: var(--primary); }
.si-dot.done   { background: var(--primary); color: #FAF4EC; }
.si-line       { flex: 1; height: 2px; background: #EDE8F8; transition: background 0.3s; }
.si-line.done  { background: var(--primary); }

/* Step header */
.step-header { margin-bottom: 28px; }
.rel-badge {
  display: inline-flex; align-items: center; gap: 6px; background: #EDE8F8;
  color: var(--primary); font-size: 13px; font-weight: 700; padding: 6px 14px;
  border-radius: 20px; margin-bottom: 12px;
}
.step-title { font-size: 28px; font-weight: 900; color: var(--text); margin-bottom: 8px; display: block; }
.step-sub   { font-size: 15px; color: var(--text-muted); line-height: 1.6; display: block; }

/* Relation grid */
.relation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.relation-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px;
  padding: 24px 16px; display: flex; flex-direction: column; align-items: center;
  gap: 8px; cursor: pointer; text-align: center; transition: all 0.18s;
}
.relation-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--primary-light); }
.rel-emoji { font-size: 32px; }
.rel-label { font-size: 15px; font-weight: 700; color: var(--text); }
.rel-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* Nickname */
.nickname-input {
  width: 100%; background: var(--surface); border: 2px solid var(--border);
  border-radius: 14px; padding: 16px 20px; font-size: 17px; color: var(--text);
  outline: none; margin-bottom: 16px; transition: border-color 0.2s, box-shadow 0.2s; font-family: inherit;
}
.nickname-input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 4px rgba(123,111,224,0.12); }
.nickname-input::placeholder { color: #C0B0D0; }
.nickname-actions { display: flex; gap: 12px; }
.btn-skip {
  flex: 1; background: #F0EDF8; border: 1.5px solid var(--border); border-radius: var(--r-btn);
  padding: 14px; font-size: 15px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: background 0.2s; font-family: inherit;
}
.btn-skip:hover { background: #E8E0F4; }
.btn-confirm {
  flex: 2; background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none; border-radius: var(--r-btn); padding: 14px; font-size: 15px;
  font-weight: 700; color: #FAF4EC; cursor: pointer;
  box-shadow: 0 4px 16px rgba(74,50,120,0.28); transition: transform 0.15s, box-shadow 0.15s; font-family: inherit;
}
.btn-confirm:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(74,50,120,0.36); }

/* Question progress */
.q-progress { margin-bottom: 20px; }
.q-progress-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.q-progress-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.q-progress-count { font-size: 13px; font-weight: 700; color: var(--primary); }
.progress-bar-bg   { background: #EDE8F8; border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 999px; transition: width 0.4s ease;
}

/* Question card */
.question-card {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #5B4AC8 100%);
  border-radius: 18px; padding: 26px 24px; margin-bottom: 16px;
  box-shadow: 0 6px 24px rgba(45,31,114,0.3);
}
.q-scene { font-size: 18px; font-weight: 700; color: #FAF4EC; line-height: 1.55; }

/* Options */
.options-list { display: flex; flex-direction: column; gap: 10px; }
.option-item {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px;
  padding: 15px 18px; display: flex; align-items: flex-start; gap: 12px;
  cursor: pointer; transition: all 0.15s;
}
.option-item:hover { border-color: var(--accent); background: #F6F2FC; transform: translateX(3px); }
.option-item.selected {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-color: var(--primary-light); box-shadow: 0 4px 16px rgba(74,50,120,0.28); transform: translateX(3px);
}
.option-item.selected .option-letter { background: rgba(255,255,255,0.22); color: #FAF4EC; }
.option-item.selected .option-text   { color: #FAF4EC; }
.option-item.dimmed { opacity: 0.4; pointer-events: none; }
.option-letter {
  width: 26px; height: 26px; flex-shrink: 0; background: #EDE8F8; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--primary);
}
.option-text { font-size: 15px; color: var(--text); line-height: 1.5; flex: 1; }
.scene-tag   { display: block; text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 14px; }

/* ==================== ANALYZING PAGE ==================== */
.analyzing-page {
  min-height: calc(100vh - var(--nav-h)); display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1A1228 0%, #2A1A50 55%, #1E0E38 100%);
}
.analyzing-box {
  display: flex; gap: 56px; align-items: center; max-width: 660px; width: 100%;
  margin: 0 var(--pad-x); background: rgba(255,255,255,0.04); border-radius: 28px;
  border: 1px solid rgba(255,255,255,0.08); padding: 48px; animation: fadeIn 0.4s ease;
}
.analyzing-left            { flex-shrink: 0; text-align: center; }
.analyzing-brain           { font-size: 80px; animation: pulse 2s ease-in-out infinite; display: block; margin-bottom: 20px; }
.analyzing-progress-bg     { width: 120px; background: rgba(255,255,255,0.1); border-radius: 999px; height: 4px; margin: 0 auto 16px; overflow: hidden; }
.analyzing-progress-fill   { height: 100%; background: linear-gradient(90deg, #7B6FE0, #E0A0FF); border-radius: 999px; transition: width 0.5s ease; }
.analyzing-dots            { display: flex; gap: 6px; justify-content: center; }
.analyzing-dots span       { width: 8px; height: 8px; background: #9880E8; border-radius: 50%; animation: analyzingDot 1.4s ease-in-out infinite; }
.analyzing-dots span:nth-child(2) { animation-delay: 0.16s; }
.analyzing-dots span:nth-child(3) { animation-delay: 0.32s; }
.analyzing-right  { flex: 1; }
.analyzing-title  { font-size: 22px; font-weight: 800; color: #E8D8F8; margin-bottom: 6px; }
.analyzing-sub    { font-size: 14px; color: rgba(232,216,248,0.6); margin-bottom: 24px; }
.analyzing-messages { display: flex; flex-direction: column; gap: 10px; }
.analyzing-msg {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 10px 16px; font-size: 14px;
  color: rgba(232,216,248,0.85); animation: msgSlide 0.35s ease;
}

/* ==================== RESULT PAGE ==================== */
.result-page { animation: fadeIn 0.3s ease; }

/* Full-width hero */
.result-hero {
  padding: 60px 0 52px; position: relative; overflow: hidden;
  opacity: 0; transition: opacity 0.7s ease, transform 0.7s ease; transform: translateY(8px);
}
.result-hero.revealed { opacity: 1; transform: translateY(0); }
.result-hero::before {
  content: ''; position: absolute; right: -80px; top: -80px;
  width: 400px; height: 400px; background: rgba(255,255,255,0.05); border-radius: 50%;
}
.result-hero-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 var(--pad-x);
  display: flex; align-items: flex-end; gap: 36px; position: relative; z-index: 1;
}
.result-hero-text { flex: 1; }
.result-eyebrow   { display: block; font-size: 14px; font-weight: 600; opacity: 0.7; margin-bottom: 8px; }
.result-mbti      { font-size: 84px; font-weight: 900; line-height: 1; margin-bottom: 10px; animation: revealMbti 0.7s 0.15s ease both; }
.result-name-row  { display: flex; align-items: baseline; gap: 14px; margin-bottom: 5px; }
.result-name      { font-size: 22px; font-weight: 700; }
.confidence-badge { display: flex; align-items: baseline; gap: 3px; }
.conf-num         { font-size: 28px; font-weight: 900; }
.conf-label       { font-size: 13px; opacity: 0.7; }
.result-tagline   { font-size: 15px; opacity: 0.8; margin-top: 5px; display: block; }
.result-hidden    { display: inline-block; margin-top: 16px; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 5px 12px; }
.result-hidden span { font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.result-hero-avatar { flex-shrink: 0; width: 168px; height: 168px; }
.result-hero-avatar img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 24px rgba(0,0,0,0.3)); }

/* Two-column body */
.result-body {
  max-width: 1120px; margin: 0 auto; padding: 32px var(--pad-x) 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start;
}
.result-left  { display: flex; flex-direction: column; gap: 20px; }
.result-right { display: flex; flex-direction: column; gap: 20px; }

/* Result cards */
.r-card {
  background: var(--surface); border-radius: var(--r-card); border: 1.5px solid var(--border);
  padding: 24px; box-shadow: var(--shadow); animation: fadeIn 0.4s ease;
}
.r-title { font-size: 15px; font-weight: 800; color: var(--text); margin-bottom: 14px; }

.profile-desc  { font-size: 15px; color: #3A2E24; line-height: 1.7; margin-bottom: 16px; }
.behavior-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.behavior-item { display: flex; align-items: flex-start; gap: 10px; }
.behavior-dot  { color: var(--primary-light); font-size: 10px; margin-top: 5px; flex-shrink: 0; }
.behavior-text { font-size: 14px; color: #3A2E24; line-height: 1.55; }
.quote-box     { background: linear-gradient(135deg, #F2EEF8, #EDE8F8); border-radius: 14px; padding: 16px 20px; }
.quote-mark    { font-size: 36px; color: #B8A8E8; line-height: 0.5; display: block; margin-bottom: 8px; }
.quote-text    { font-size: 15px; font-style: italic; color: #4A3870; font-weight: 600; line-height: 1.55; }

.evidence-intro { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.evidence-item  { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.ev-dot         { color: var(--primary-light); font-size: 18px; flex-shrink: 0; margin-top: -2px; }
.ev-text        { font-size: 14px; color: #3A2E24; line-height: 1.55; }

/* Compat card */
.compat-pair    { display: flex; align-items: center; margin-bottom: 20px; }
.compat-person  { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.compat-avatar  { width: 68px; height: 68px; object-fit: contain; }
.compat-mbti    { font-size: 16px; font-weight: 900; color: var(--primary-dark); }
.compat-mbti.them { color: var(--primary-light); }
.compat-nick    { font-size: 12px; color: var(--text-muted); }
.compat-vs      { width: 96px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.compat-ring {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 6px 20px rgba(74,50,120,0.4);
}
.compat-ring-num   { font-size: 24px; font-weight: 900; color: #FAF4EC; }
.compat-ring-unit  { font-size: 13px; color: rgba(250,244,236,0.7); }
.compat-ring-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.compat-summary    { font-size: 14px; color: var(--text); font-weight: 600; text-align: center; margin-bottom: 18px; line-height: 1.5; padding: 12px; background: #F4F0FA; border-radius: 10px; }
.compat-section    { margin-bottom: 14px; }
.compat-section-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; display: block; }
.compat-item        { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 7px; }
.compat-item .ci-dot { font-size: 14px; flex-shrink: 0; font-weight: 800; }
.compat-item.green  .ci-dot { color: #20A060; }
.compat-item.red    .ci-dot { color: #D03838; }
.compat-item.purple .ci-dot { color: #8060B0; }
.ci-text { font-size: 13px; color: #3A2E24; line-height: 1.5; }

/* Result actions */
.result-actions {
  max-width: 1120px; margin: 32px auto 0; padding: 0 var(--pad-x) 72px;
  display: flex; flex-direction: column; gap: 10px;
}
.ra-row { display: flex; gap: 10px; }
.ra-row-chat { justify-content: stretch; }
.ra-row-chat .ra-btn { flex: 1; justify-content: center; text-align: center; }
.ra-row:not(.ra-row-chat) .ra-btn { flex: 1; }
.ra-btn {
  border: none; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  gap: 8px; border-radius: 14px; padding: 13px 28px;
  font-size: 14px; font-weight: 700; transition: all 0.17s;
  white-space: nowrap;
}
.ra-chat {
  background: linear-gradient(130deg, #1E0B4E 0%, #3B2090 55%, #6B52D4 100%);
  color: #FAF4EC; box-shadow: 0 4px 16px rgba(30,11,78,0.38);
  justify-content: center; text-align: center;
}
.ra-chat:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(30,11,78,0.48); }
.ra-share {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
  color: #FAF4EC; box-shadow: 0 3px 12px rgba(45,31,114,0.28);
}
.ra-share:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(45,31,114,0.38); }
.ra-again {
  background: #EDE8F8; color: var(--primary);
  border: 1.5px solid #D4C8F0;
}
.ra-again:hover { background: #E2DBF4; border-color: #B0A0E0; transform: translateY(-1px); }
.ra-home {
  background: #F4F0FA; color: var(--text-muted);
  border: 1.5px solid var(--border); flex: 0 0 auto !important;
}
.ra-home:hover { background: #EDE8F8; color: var(--primary); border-color: #C8B8E8; }

/* legacy btn-action kept for other uses */
.btn-action {
  border: none; border-radius: var(--r-btn); padding: 14px 28px;
  font-size: 15px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: all 0.15s; font-family: inherit;
}
.btn-action.primary { background: linear-gradient(135deg, var(--primary-dark), var(--primary-light)); color: #FAF4EC; box-shadow: 0 4px 16px rgba(45,31,114,0.28); }
.btn-action.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(45,31,114,0.36); }
.btn-action.secondary { background: #EDE8F8; color: var(--primary); border: 1.5px solid var(--border); }
.btn-action.secondary:hover { background: #E4DFF4; }
.btn-action.ghost { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-action.ghost:hover { background: #F0EDF8; }
.btn-action.chat { background: linear-gradient(135deg,#1A1A2E,#3D2EA8); color: #E8D8F8; border: none; box-shadow: 0 4px 14px rgba(45,31,114,0.3); }
.btn-action.chat:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(45,31,114,0.4); }

/* ==================== CHAT OVERLAY ==================== */
#chatOverlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0);
  display: flex; align-items: flex-end; justify-content: center;
  transition: background 0.28s ease;
  pointer-events: none;
}
#chatOverlay.visible { background: rgba(0,0,0,0.5); pointer-events: all; }
.chat-overlay-inner {
  width: 100%; max-width: 520px; height: 82vh; background: var(--surface);
  border-radius: 24px 24px 0 0; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.22);
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
#chatOverlay.visible .chat-overlay-inner { transform: translateY(0); }

/* header */
.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  flex-shrink: 0;
}
.chat-back {
  background: rgba(255,255,255,0.18); border: none; border-radius: 8px;
  color: #FAF4EC; font-size: 14px; font-weight: 600; padding: 6px 12px;
  cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.chat-back:hover { background: rgba(255,255,255,0.28); }
.chat-header-info { display: flex; align-items: center; gap: 10px; flex: 1; }
.chat-avatar { width: 38px; height: 38px; object-fit: contain; flex-shrink: 0; filter: drop-shadow(0 1px 4px rgba(0,0,0,0.25)); }
.chat-their-name { font-size: 15px; font-weight: 800; color: #FAF4EC; line-height: 1.2; }
.chat-their-sub  { font-size: 11px; color: rgba(250,244,236,0.65); margin-top: 1px; }
.chat-mbti-badge {
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 800;
  color: #FAF4EC; flex-shrink: 0;
}

/* messages */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px 16px; display: flex;
  flex-direction: column; gap: 10px; background: #F6F2FA;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #DDD0EE; border-radius: 2px; }
.chat-msg { display: flex; flex-direction: column; max-width: 78%; animation: msgSlide 0.25s ease; }
.chat-msg-user { align-self: flex-end; align-items: flex-end; }
.chat-msg-them  { align-self: flex-start; align-items: flex-start; }
.chat-bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.6;
  word-break: break-word; white-space: pre-wrap;
}
.chat-msg-user .chat-bubble { background: linear-gradient(135deg,var(--primary),var(--primary-light)); color: #FAF4EC; border-bottom-right-radius: 4px; }
.chat-msg-them .chat-bubble { background: #fff; color: var(--text); border: 1px solid #EDE8F8; border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(74,50,120,0.06); }
.chat-time { font-size: 10px; color: #B0A0C8; margin-top: 3px; }

/* input bar */
.chat-input-bar {
  display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; align-items: flex-end;
}
.chat-textarea {
  flex: 1; background: #F4F0FA; border: 1.5px solid var(--border); border-radius: 14px;
  padding: 10px 14px; font-size: 14px; color: var(--text); resize: none; outline: none;
  font-family: inherit; line-height: 1.5; max-height: 120px; overflow-y: auto;
  transition: border-color 0.2s;
}
.chat-textarea:focus { border-color: var(--primary-light); }
.chat-textarea::placeholder { color: #C0B0D0; }
.chat-send-btn {
  background: linear-gradient(135deg,var(--primary),var(--primary-light)); border: none;
  border-radius: 12px; padding: 10px 18px; font-size: 14px; font-weight: 700;
  color: #FAF4EC; cursor: pointer; font-family: inherit; flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s; box-shadow: 0 3px 10px rgba(74,50,120,0.28);
}
.chat-send-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(74,50,120,0.36); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.page-bottom { height: 32px; }

/* ==================== MODAL ==================== */
#modalOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn 0.2s ease;
}
#modalBox {
  background: var(--surface); border-radius: 24px; width: 100%;
  max-width: 640px; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3); animation: fadeIn 0.25s ease;
}
#modalBox::-webkit-scrollbar { width: 8px; }
#modalBox::-webkit-scrollbar-track { background: transparent; }
#modalBox::-webkit-scrollbar-thumb { background: #DDD0EE; border-radius: 4px; }
#modalBox::-webkit-scrollbar-thumb:hover { background: #B0A0E0; }
.modal-mbti-item {
  display: flex; align-items: center; gap: 12px; background: #F4F0FA;
  border-radius: 12px; padding: 12px; border: 1.5px solid var(--border); cursor: pointer; transition: all 0.15s;
}
.modal-mbti-item:hover { background: #EDE8F8; border-color: #B0A0E0; transform: translateY(-1px); }

/* ==================== TOAST ==================== */
#toastEl {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: rgba(34,26,18,0.88); color: #FAF4EC; font-size: 14px; font-weight: 600;
  padding: 12px 24px; border-radius: 24px; z-index: 9999; pointer-events: none;
  animation: fadeIn 0.2s ease; white-space: nowrap; max-width: 360px; text-align: center;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  :root { --pad-x: 28px; --col-w: 100%; }
  .result-body { grid-template-columns: 1fr; }
  .result-mbti { font-size: 64px; }
  .result-hero-avatar { width: 120px; height: 120px; }
}
@media (max-width: 640px) {
  :root { --pad-x: 16px; }
  .mbti-char-grid  { grid-template-columns: repeat(4, 1fr); }
  .relation-grid   { gap: 8px; }
  .hero-h1         { font-size: 34px; }
  .hero-subtitle   { font-size: 13px; white-space: normal; }
  .analyzing-box   { flex-direction: column; gap: 28px; padding: 32px 20px; margin: 0 16px; }
  .result-mbti     { font-size: 52px; }
  .result-hero-avatar { display: none; }
  .result-actions  { flex-wrap: wrap; }
  .ra-btn { flex: 1 0 40%; }
  .ra-home { flex: 0 0 auto; }
  .guess-wrap      { padding: 28px var(--pad-x) 48px; }
  .entry-row       { flex-direction: column; }
}
