/* ═════════════ Design Tokens ═════════════ */
:root {
  --bg: #0b0820;
  --surface: hsl(250 40% 14% / .55);
  --surface-2: hsl(250 40% 20% / .6);
  --line: hsl(250 60% 80% / .14);
  --text: #f3f0ff;
  --muted: #a9a3c9;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --cyan: #22d3ee;
  --amber: #fbbf24;
  --grad: linear-gradient(120deg, #22d3ee 0%, #8b5cf6 45%, #ec4899 100%);
  --radius: 22px;
  --shadow: 0 20px 60px -20px rgb(0 0 0 / .6);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --accent: var(--cyan);
  --accent-2: var(--violet);
  font-synthesis: none;
}
[data-theme="zero"]   { --accent: #22d3ee; --accent-2: #8b5cf6; }
[data-theme="spring"] { --accent: #6ee7b7; --accent-2: #f9a8d4; }
[data-theme="boss"]   { --accent: #fbbf24; --accent-2: #f97316; }
[data-theme="indie"]  { --accent: #f97316; --accent-2: #eab308; }
[data-theme="eddie"]  { --accent: #38bdf8; --accent-2: #facc15; }
[data-theme="nova"]   { --accent: #f472b6; --accent-2: #c084fc; }
[data-theme="socra"]  { --accent: #818cf8; --accent-2: #38bdf8; }

html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
#career-universe-section { scroll-margin-top: 80px; }
body {
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ═════════════ Background ═════════════ */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55; animation: float 18s var(--ease) infinite alternate; }
.b1 { width: 520px; height: 520px; background: #6d28d9; top: -160px; left: -140px; }
.b2 { width: 460px; height: 460px; background: #db2777; bottom: -180px; right: -120px; animation-delay: -6s; }
.b3 { width: 360px; height: 360px; background: #0891b2; top: 40%; left: 55%; opacity: .35; animation-delay: -12s; }
.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 20%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 80%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 65%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 10% 90%, #fff6 50%, transparent 51%);
  background-size: 300px 300px;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes float { to { transform: translate(60px, 40px) scale(1.12); } }
@keyframes twinkle { from { opacity: .4; } to { opacity: 1; } }

/* ═════════════ Topbar ═════════════ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px clamp(16px, 4vw, 36px);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: hsl(250 50% 6% / .4);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: 'Outfit', sans-serif; font-weight: 500; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand b { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark { color: var(--cyan); }
.engine-badge {
  font-size: .72rem; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.engine-badge::before { content: '●'; margin-right: 6px; color: #34d399; }
.engine-badge.err::before { color: #f87171; }

/* 🔒 관리자 전용 요소 숨김 (추후 관리자 대시보드 개발 시 display: inline-flex 로 복원) */
#engine-badge {
  display: none !important;
}

/* ═════════════ Screens ═════════════ */
#app { max-width: 760px; margin: 0 auto; padding: 12px 18px 40px; position: relative; }
.screen { display: none; }
.screen.active { display: block; animation: screenIn .6s var(--ease) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(18px) scale(.98); filter: blur(6px); } }

.eyebrow { font-family: 'Outfit', sans-serif; font-size: .78rem; letter-spacing: .22em; text-transform: uppercase; color: var(--cyan); margin: 0 0 10px; font-weight: 700; }
h1, h2, h3 { letter-spacing: -.02em; margin: 0; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ═════════════ Buttons ═════════════ */
.btn {
  border: 0; cursor: pointer; border-radius: 16px; padding: 15px 22px; font-weight: 700;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 10px 30px -8px #8b5cf6aa; background-size: 200% 100%; }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -8px #ec4899aa; background-position: 100% 0; }
.btn.ghost { background: var(--surface); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); transform: translateY(-2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ═════════════ Intro ═════════════ */
.intro { text-align: center; padding-top: clamp(20px, 7vh, 80px); }
.intro h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); font-weight: 900; line-height: 1.15; }
.lead { color: var(--muted); line-height: 1.7; margin: 18px 0 28px; font-size: 1.02rem; }
.lead b { color: var(--text); }
.steps { list-style: none; padding: 0; margin: 0 auto 34px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.steps li {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: .9rem; font-weight: 500;
  backdrop-filter: blur(10px);
}
.name-form { display: flex; gap: 10px; max-width: 440px; margin: 0 auto; }
.name-form input {
  flex: 1; min-width: 0; padding: 15px 18px; border-radius: 16px; border: 1px solid var(--line);
  background: hsl(250 40% 10% / .7); outline: none; transition: border-color .2s, box-shadow .2s;
}
.name-form input:focus { border-color: var(--violet); box-shadow: 0 0 0 4px #8b5cf633; }

/* ═════════════ Game ═════════════ */
.progress { height: 8px; border-radius: 99px; background: var(--surface); overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .6s var(--ease); box-shadow: 0 0 16px #8b5cf6; }
.step-count { text-align: right; font-family: 'Outfit'; color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.scene { text-align: center; margin-top: 18px; }
.scene.swap { animation: sceneSwap .55s var(--ease); }
@keyframes sceneSwap { 0% { opacity: 0; transform: translateX(40px) rotate(1deg); } }
.scene-emoji { font-size: 4.6rem; filter: drop-shadow(0 10px 30px #8b5cf688); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }
.scene h2 { font-size: clamp(1.6rem, 5vw, 2.2rem); font-weight: 900; margin-top: 10px; }
.scene-story { color: var(--muted); margin: 10px 0 26px; font-size: 1.05rem; }
.choices { display: grid; gap: 12px; }
.choice {
  position: relative; text-align: left; padding: 18px 20px 18px 58px; border-radius: 18px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(12px);
  font-weight: 500; line-height: 1.5; overflow: hidden;
  transition: transform .3s var(--ease), border-color .3s, background .3s;
  animation: choiceIn .5s var(--ease) both;
}
.choice::before {
  content: attr(data-key); position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px;
  font-family: 'Outfit'; font-weight: 800; font-size: .85rem; background: var(--surface-2); color: var(--cyan);
}
.choice:hover { transform: translateY(-3px); border-color: #8b5cf6aa; background: var(--surface-2); }
.choice.picked { border-color: transparent; background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box, var(--grad) border-box; border: 1.5px solid transparent; transform: scale(1.02); }
.choice.picked::before { background: var(--grad); color: #fff; }
.choice.dim { opacity: .35; transform: scale(.98); }
@keyframes choiceIn { from { opacity: 0; transform: translateY(14px); } }

/* ═════════════ Persona ═════════════ */
#screen-persona h2 { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 900; }
.trait-bars { display: grid; gap: 10px; margin: 22px 0 34px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(12px); }
.trait-row { display: grid; grid-template-columns: 140px 1fr 24px; align-items: center; gap: 12px; font-size: .9rem; }
.trait-track { height: 10px; border-radius: 99px; background: hsl(250 30% 30% / .4); overflow: hidden; }
.trait-fill { height: 100%; width: 0; border-radius: 99px; transition: width 1s var(--ease); }
.trait-row b { font-family: 'Outfit'; text-align: right; }
.sub { font-size: 1.15rem; margin-bottom: 16px; }
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.persona-card {
  --c: var(--accent);
  padding: 0; border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s;
  animation: choiceIn .6s var(--ease) both;
}
.persona-card:nth-child(2) { animation-delay: .08s; }
.persona-card:nth-child(3) { animation-delay: .16s; }
.persona-card:hover, .persona-card:focus-visible { transform: translateY(-6px) rotate(-.5deg); border-color: var(--c); box-shadow: 0 20px 50px -12px var(--c); outline: none; }
.persona-card img { aspect-ratio: 1; object-fit: cover; width: 100%; transition: transform .6s var(--ease); }
.persona-card:hover img { transform: scale(1.06); }
.persona-info { padding: 14px 14px 18px; display: grid; gap: 4px; }
.persona-info strong { font-size: 1rem; }
.persona-info span { font-size: .75rem; color: var(--c); font-weight: 700; }
.persona-info em { font-size: .8rem; color: var(--muted); font-style: normal; line-height: 1.5; margin-top: 4px; }

/* ═════════════ Chat ═════════════ */
.chat-wrap {
  display: flex; flex-direction: column; height: calc(100dvh - 130px); min-height: 480px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  backdrop-filter: blur(16px); overflow: hidden; box-shadow: var(--shadow);
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: hsl(250 40% 8% / .5); }
.chat-head img { width: 48px; height: 48px; border-radius: 14px; object-fit: cover; box-shadow: 0 0 0 2px var(--accent); }
.chat-head h2 { font-size: 1.05rem; }
.online { font-size: .75rem; color: var(--accent); }
.turns { margin-left: auto; display: flex; gap: 6px; }
.turns i { width: 28px; height: 6px; border-radius: 99px; background: hsl(250 30% 40% / .5); transition: background .4s; }
.turns i.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 10px var(--accent); }
.chat-log { flex: 1; overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { max-width: 82%; padding: 13px 16px; border-radius: 20px; line-height: 1.6; font-size: .96rem; white-space: pre-wrap; word-break: keep-all; animation: msgIn .45s var(--ease) both; }
.msg.ai { align-self: flex-start; background: hsl(250 40% 22% / .85); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0820; font-weight: 500; border-bottom-right-radius: 6px; }
.msg.sys { align-self: center; font-size: .8rem; color: var(--muted); background: transparent; padding: 4px; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.typing { display: inline-flex; gap: 5px; padding: 16px 18px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: dot 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-5px); } }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: hsl(250 40% 8% / .5); }
.chat-input input { flex: 1; min-width: 0; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: hsl(250 40% 12% / .8); outline: none; }
.chat-input input:focus { border-color: var(--accent); }
.btn.send { width: 52px; padding: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0820; font-size: 1.1rem; }

/* ═════════════ Loading ═════════════ */
#screen-loading { text-align: center; padding-top: 10vh; }
.compass-loader { position: relative; width: 200px; height: 200px; margin: 0 auto 30px; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.r1 { border-top-color: var(--cyan); border-right-color: var(--cyan); animation: spin 1.6s linear infinite; }
.r2 { inset: 22px; border-bottom-color: var(--violet); border-left-color: var(--violet); animation: spin 2.2s linear infinite reverse; }
.r3 { inset: 44px; border-top-color: var(--pink); animation: spin 1s linear infinite; }
.needle { position: absolute; inset: 0; display: grid; place-items: center; font-size: 3rem; animation: wobble 2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wobble { 50% { transform: rotate(25deg) scale(1.08); } }
#loading-title { font-size: 1.6rem; font-weight: 900; }
.loading-msg { color: var(--muted); margin-top: 10px; min-height: 1.5em; transition: opacity .3s; }

/* ═════════════ Photo Card (html2canvas 호환: backdrop-filter 미사용) ═════════════ */
.card-stage { display: flex; justify-content: center; perspective: 1200px; }
.photo-card {
  position: relative; width: min(100%, 420px); padding: 26px 24px 20px; border-radius: 28px; overflow: hidden;
  background: linear-gradient(160deg, #1a1240 0%, #120c2c 55%, #1d0f33 100%);
  border: 1.5px solid hsl(0 0% 100% / .12);
  box-shadow: 0 40px 80px -30px var(--accent), 0 0 0 1px hsl(0 0% 100% / .04) inset;
  animation: cardIn 1s var(--ease) both;
}
@keyframes cardIn { from { opacity: 0; transform: rotateY(-25deg) rotateX(10deg) translateY(30px) scale(.9); } }
.pc-glow { position: absolute; inset: -40% -20% auto; height: 70%; background: radial-gradient(closest-side, var(--accent), transparent); opacity: .28; pointer-events: none; }
.pc-head { position: relative; display: flex; justify-content: space-between; font-family: 'Outfit'; font-size: .7rem; letter-spacing: .2em; color: var(--muted); font-weight: 700; }
.pc-brand { color: var(--accent); }
.pc-hero { position: relative; display: flex; align-items: center; gap: 14px; margin: 20px 0 14px; }
.pc-hero img { width: 72px; height: 72px; border-radius: 20px; object-fit: cover; border: 2px solid var(--accent); }
.pc-name { margin: 0; font-size: 1.35rem; font-weight: 900; }
.pc-mentor { margin: 2px 0 0; font-size: .78rem; color: var(--muted); }
.pc-title {
  position: relative; margin: 0 0 18px; font-size: 1.45rem; font-weight: 900; line-height: 1.35; letter-spacing: -.02em;
  background: linear-gradient(120deg, #fff 0%, var(--accent) 60%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pc-block { position: relative; padding: 14px 16px; border-radius: 16px; background: hsl(0 0% 100% / .05); border: 1px solid hsl(0 0% 100% / .07); margin-bottom: 10px; }
.pc-block h4, .pc-quest h4 { margin: 0 0 8px; font-size: .78rem; letter-spacing: .04em; color: var(--muted); }
.pc-block p { margin: 0; font-size: .9rem; line-height: 1.55; }
.pc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-chips span { display: inline-block; line-height: 1.2; padding: 6px 12px; border-radius: 99px; font-size: .85rem; font-weight: 700; color: #0b0820; background: linear-gradient(120deg, var(--accent), var(--accent-2)); }
.plan-item { display: flex; gap: 10px; align-items: flex-start; }
.plan-item + .plan-item { margin-top: 8px; }
.tag { flex: none; display: inline-block; line-height: 1.2; font-size: .7rem; font-weight: 900; padding: 4px 8px; border-radius: 8px; background: hsl(0 0% 100% / .1); color: var(--accent); margin-top: 1px; }
.pc-quest { position: relative; padding: 14px 16px; border-radius: 16px; margin-top: 4px; background: linear-gradient(120deg, hsl(45 95% 55% / .16), hsl(330 85% 60% / .14)); border: 1px dashed hsl(45 95% 60% / .5); }
.pc-quest h4 { color: var(--amber); }
.pc-quest p { margin: 0; font-size: .9rem; line-height: 1.55; font-weight: 500; }
.pc-disclaimer { position: relative; margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: hsl(250 40% 8% / .6); border: 1px dashed hsl(250 40% 60% / .3); }
.pc-disclaimer p { margin: 0; font-size: .75rem; line-height: 1.5; color: #cbd5e1; word-break: keep-all; }
.pc-foot { position: relative; margin-top: 16px; text-align: center; font-size: .72rem; color: var(--muted); letter-spacing: .05em; }
.report-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }

/* ═════════════ Toast ═════════════ */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  padding: 12px 20px; border-radius: 14px; background: #1e1745; border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: all .35s var(--ease); font-size: .9rem; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ═════════════ Responsive / A11y ═════════════ */
@media (max-width: 620px) {
  .persona-grid { grid-template-columns: 1fr; }
  .persona-card { display: grid; grid-template-columns: 110px 1fr; align-items: center; }
  .persona-card img { height: 100%; }
  .trait-row { grid-template-columns: 110px 1fr 20px; font-size: .82rem; }
  .name-form { flex-direction: column; }
  .chat-wrap { height: calc(100dvh - 110px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
