:root {
  --bg: #faf7ff;
  --card: #ffffff;
  --ink: #2b2440;
  --ink-soft: #6b6285;
  --line: #e9e2f7;
  --primary: #7c5cff;
  --primary-soft: #efeaff;
  --accent: #ff6b9d;
  --accent-soft: #ffe9f1;
  --good: #22b07d;
  --warn: #e8862e;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(90, 60, 160, 0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
  background: linear-gradient(180deg, #f3edff 0%, var(--bg) 220px);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  word-break: keep-all;
}

/* ---------- 헤더 ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 20px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}

.nav { display: flex; gap: 4px; }

.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover { background: var(--primary-soft); color: var(--primary); }
.nav a.active { background: var(--primary); color: #fff; }

/* ---------- 레이아웃 ---------- */
.container {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px 48px;
  flex: 1;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  background: #fff;
}

.site-footer p + p { margin-top: 4px; }

/* ---------- 공통 요소 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card + .card { margin-top: 16px; }

h1.page-title {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 16px 0 6px;
  letter-spacing: -0.02em;
}

p.page-sub { color: var(--ink-soft); margin-bottom: 20px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(124, 92, 255, 0.35); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(124, 92, 255, 0.45); }
.btn-ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

ul.tips { list-style: none; }
ul.tips li {
  position: relative;
  padding-left: 26px;
  margin-bottom: 10px;
}
ul.tips li::before {
  content: "✦";
  position: absolute;
  left: 4px;
  color: var(--primary);
}
ul.tips.good li::before { content: "💚"; left: 0; font-size: 0.85em; }
ul.tips.clash li::before { content: "⚡"; left: 0; font-size: 0.9em; }
ul.tips.avoid li::before { content: "🚫"; left: 0; font-size: 0.85em; }

/* ---------- 홈 ---------- */
.hero {
  text-align: center;
  padding: 36px 12px 28px;
}

.hero h1 {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.3;
}

.hero h1 .grad {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p { color: var(--ink-soft); margin-top: 12px; font-size: 1.02rem; }

.entry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 8px;
}

.entry-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.entry-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(90, 60, 160, 0.16); }
.entry-card .emoji { font-size: 2rem; display: block; margin-bottom: 10px; }
.entry-card h3 { font-size: 1.05rem; margin-bottom: 4px; }
.entry-card p { font-size: 0.86rem; color: var(--ink-soft); }

/* ---------- 유형 선택 그리드 ---------- */
.picker-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.picker h3 {
  text-align: center;
  margin-bottom: 12px;
  font-size: 1rem;
}

.picker h3 .picked { color: var(--primary); }

.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.type-grid.wide { grid-template-columns: repeat(8, 1fr); }

.type-btn {
  padding: 10px 4px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.12s;
}

.type-btn:hover { border-color: var(--primary); color: var(--primary); }
.type-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.type-btn.selected.mine { background: var(--accent); border-color: var(--accent); }

.picker-cta { text-align: center; margin-top: 20px; }

/* ---------- 궁합 결과 ---------- */
.result-head {
  text-align: center;
  padding: 8px 0 4px;
}

.result-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 1.4rem;
  font-weight: 900;
}

.result-vs .type-chip {
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 12px;
  padding: 6px 14px;
}

.result-vs .heart { color: var(--accent); font-size: 1.2rem; }

.result-nicks { color: var(--ink-soft); font-size: 0.88rem; margin-top: 6px; }

.oneliner {
  margin: 14px auto 4px;
  font-size: 1.05rem;
  font-weight: 600;
  max-width: 560px;
}

.gauge-wrap { display: flex; justify-content: center; margin: 8px 0 0; }

.axes-wrap { margin-top: 8px; }

.axis-row { display: grid; grid-template-columns: 88px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 10px; }
.axis-label { font-size: 0.88rem; font-weight: 700; color: var(--ink-soft); }
.axis-value { font-size: 0.88rem; font-weight: 800; color: var(--primary); text-align: right; }
.axis-track { height: 10px; background: var(--primary-soft); border-radius: 999px; overflow: hidden; }
.axis-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.tip-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tip-col h4 { margin-bottom: 10px; font-size: 0.98rem; }
.tip-col h4 .who { color: var(--accent); }

.share-bar { display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- 소통법 ---------- */
.comm-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.comm-card {
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
  transition: transform 0.13s, box-shadow 0.13s;
}

.comm-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.comm-card .emoji { font-size: 1.6rem; display: block; margin-bottom: 6px; }
.comm-card .code { font-weight: 800; }
.comm-card .nick { font-size: 0.78rem; color: var(--ink-soft); display: block; margin-top: 2px; }

.group-label {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-soft);
  margin-top: 8px;
}

.comm-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.comm-head .emoji { font-size: 2.6rem; }
.comm-head h2 { font-size: 1.5rem; }
.comm-head .nick { color: var(--ink-soft); font-size: 0.92rem; }

.trait-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.trait-chip {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 5px 12px;
}

/* ---------- 퀴즈 ---------- */
.quiz-progress { height: 8px; background: var(--primary-soft); border-radius: 999px; overflow: hidden; margin-bottom: 24px; }
.quiz-progress .fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width 0.3s; }

.quiz-q { font-size: 1.15rem; font-weight: 800; margin-bottom: 20px; text-align: center; }
.quiz-count { text-align: center; color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 8px; }

.quiz-options { display: grid; gap: 12px; max-width: 520px; margin: 0 auto; }

.quiz-opt {
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 0.98rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s;
}

.quiz-opt:hover { border-color: var(--primary); background: var(--primary-soft); }

.quiz-result { text-align: center; padding: 12px 0; }
.quiz-result .big-type {
  font-size: 2.6rem;
  font-weight: 900;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.quiz-result .emoji { font-size: 3rem; display: block; margin-bottom: 6px; }

.quiz-links { display: flex; justify-content: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

/* ---------- AI 질문 박스 ---------- */
.ai-box { margin-top: 16px; }
.ai-sub { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 12px; }

.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ai-chip {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.12s;
}
.ai-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.ai-messages { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.ai-messages:not(:empty) { margin-bottom: 12px; }

.ai-bubble { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 0.95rem; line-height: 1.6; }
.ai-bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ai-bubble.assistant { align-self: flex-start; background: var(--primary-soft); color: var(--ink); border-bottom-left-radius: 4px; }
.ai-bubble.error { align-self: flex-start; background: #fff2f2; color: #b3423f; border: 1px solid #f3cfcf; }
.ai-bubble.loading { color: var(--ink-soft); }
.ai-bubble p + p, .ai-bubble ul { margin-top: 6px; }
.ai-bubble ul { padding-left: 18px; }
.ai-bubble .dots { animation: ai-blink 1.2s infinite; }
@keyframes ai-blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.ai-form { display: flex; gap: 8px; }
.ai-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  font: inherit;
  font-size: 0.93rem;
  outline: none;
}
.ai-input:focus { border-color: var(--primary); }
.ai-send { padding: 10px 18px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 100;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 반응형 ---------- */
@media (max-width: 640px) {
  .entry-grid { grid-template-columns: 1fr; }
  .picker-columns { grid-template-columns: 1fr; }
  .tip-columns { grid-template-columns: 1fr; }
  .comm-grid { grid-template-columns: repeat(2, 1fr); }
  .nav a { padding: 7px 10px; font-size: 0.88rem; }
  .card { padding: 18px; }
  .result-vs { font-size: 1.15rem; }
}
