/* ViralLab 공통 스타일 — 모바일 퍼스트 */

:root {
  --primary: #5b6cff;
  --theme-bg: #eef0ff;
  --text: #1f2330;
  --text-sub: #5c6270;
  --text-muted: #8a909c;
  --surface: #ffffff;
  --page-bg: #f5f6fa;
  --line: #e6e8ee;
  --danger: #e5484d;
  --kakao: #fee500;
  --radius: 18px;
  --shadow: 0 4px 18px rgba(31, 35, 48, 0.06);
  --font: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--page-bg);
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

.page {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  background: var(--page-bg);
}

/* ───────── 헤더 / 푸터 ───────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  height: 56px;
  margin: 0 -16px;
  padding: 0 16px;
  background: rgba(245, 246, 250, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.logo {
  font-size: 19px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.site-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ───────── 메인 ───────── */

.hero {
  padding: 18px 0 14px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  color: var(--text-sub);
  font-size: 15px;
}

.search input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font: inherit;
  font-size: 16px; /* iOS 자동 확대 방지 */
  color: var(--text);
  outline: none;
}

.search input:focus {
  border-color: var(--primary);
}

.chips {
  display: flex;
  gap: 8px;
  margin: 14px -16px 4px;
  padding: 0 16px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

/* 마우스 환경(PC)에서는 가로 스크롤 대신 여러 줄로 보여준다 */
@media (hover: hover) and (pointer: fine) {
  .chips {
    flex-wrap: wrap;
    overflow-x: visible;
  }
}

.chip {
  flex: none;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
}

.chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.test-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.test-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.test-card:active {
  transform: scale(0.98);
}

.test-thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 16px;
  overflow: hidden;
}

.test-thumb img {
  width: 80px;
  height: 80px;
}

.test-info {
  min-width: 0;
}

.test-info h2 {
  margin: 2px 0 2px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.test-info p {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  font-size: 13px;
  color: var(--text-muted);
}

.badges {
  display: flex;
  gap: 4px;
  min-height: 0;
}

.badge {
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.badge-hot {
  background: #ffe9e0;
  color: #e5532d;
}

.badge-new {
  background: #e8f0ff;
  color: #3b6ef5;
}

.badge-done {
  background: #e6f6ee;
  color: #1d9a5b;
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
}

/* ───────── 버튼 ───────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-lg {
  min-height: 56px;
  font-size: 17px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-soft {
  background: var(--theme-bg);
  color: var(--primary);
}

.btn-kakao {
  background: var(--kakao);
  color: #191919;
}

.btn-text {
  background: none;
  color: var(--text-sub);
  font-weight: 600;
  min-height: 44px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
}

.stack {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ───────── 테스트 시작 ───────── */

.loading,
.analyzing {
  padding: 120px 0;
  text-align: center;
  color: var(--text-sub);
}

.intro {
  padding: 16px 0;
  text-align: center;
}

.intro-art {
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: var(--theme-bg);
}

.intro-art img {
  width: 220px;
  height: 220px;
}

.kicker {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.intro h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.intro-desc {
  margin: 0 0 6px;
  color: var(--text-sub);
  font-size: 16px;
}

.friend-note {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--theme-bg);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
}

/* ───────── 질문 ───────── */

.question {
  padding-top: 8px;
  overflow-x: clip;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 32px;
  font-size: 14px;
  color: var(--text-muted);
}

.progress-count b {
  color: var(--primary);
  font-size: 16px;
}

.progress {
  height: 8px;
  margin: 6px 0 28px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.35s ease;
}

.question-text {
  margin: 0 0 24px;
  min-height: 3em;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: -0.02em;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  width: 100%;
  min-height: 60px;
  padding: 14px 18px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.option:active {
  transform: scale(0.98);
}

.option.selected {
  border-color: var(--primary);
  background: var(--theme-bg);
  color: var(--primary);
}

@media (hover: hover) {
  .option:hover {
    border-color: var(--primary);
  }
  .test-card:hover {
    transform: translateY(-2px);
  }
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border: 4px solid var(--theme-bg);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ───────── 결과 ───────── */

.friend-banner {
  display: grid;
  gap: 2px;
  margin: 8px 0 4px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
}

.friend-banner b {
  font-size: 16px;
}

.friend-banner .btn {
  margin-top: 10px;
  min-height: 46px;
}

.btn-white {
  background: #fff;
  color: var(--primary);
}

.result {
  margin-top: 12px;
  padding: 24px 20px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-art {
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  margin: 12px auto 16px;
  border-radius: 50%;
  background: var(--theme-bg);
}

.result-art img {
  width: 200px;
  height: 200px;
}

.result-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

.result-name {
  margin: 2px 0 6px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.3;
}

.result-summary {
  margin: 0 0 16px;
  color: var(--primary);
  font-weight: 700;
  font-size: 17px;
}

.result-desc {
  margin: 0 0 16px;
  color: var(--text-sub);
  font-size: 15px;
  text-align: left;
}

.traits {
  margin: 0 0 18px;
  padding: 14px 16px 14px 34px;
  border-radius: 14px;
  background: var(--page-bg);
  text-align: left;
  font-size: 15px;
}

.traits li + li {
  margin-top: 4px;
}

.pairs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pair {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 16px;
  background: var(--theme-bg);
  font-size: 14px;
}

.pair img {
  width: 72px;
  height: 72px;
}

.pair-label {
  font-weight: 700;
  color: var(--primary);
}

.pair-worst .pair-label {
  color: var(--danger);
}

.pair b {
  line-height: 1.35;
}

.compat {
  margin-top: 12px;
  padding: 22px 16px;
  border-radius: 20px;
  background: var(--theme-bg);
  text-align: center;
}

.compat p {
  margin: 0;
  color: var(--text-sub);
  font-size: 14px;
}

.compat-emoji {
  font-size: 44px;
  line-height: 1.3;
}

.compat h2 {
  margin: 0;
  font-size: 22px;
  color: var(--primary);
}

.compat-worst h2 {
  color: var(--danger);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.recommend {
  margin-top: 32px;
}

.recommend h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.recommend .btn-text {
  margin-top: 8px;
}

/* ───────── 광고 영역 ───────── */

.ad-container {
  min-height: 100px;
  margin: 20px 0;
  border-radius: 12px;
  background: #eceef3;
}

/* ───────── 모달 / 토스트 ───────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 20, 0.75);
  animation: fade-in 0.2s ease;
}

.modal-body {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow: auto;
}

.modal-body img {
  width: 100%;
  max-height: 64vh;
  object-fit: contain;
  border-radius: 14px;
  -webkit-touch-callout: default;
}

.modal-guide {
  margin: 0;
  color: #fff;
  text-align: center;
  font-size: 15px;
}

.modal-actions {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 200;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(20, 22, 30, 0.92);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

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

/* ───────── 애니메이션 ───────── */

.fade-in {
  animation: fade-in 0.35s ease both;
}

.slide-next {
  animation: slide-next 0.3s ease both;
}

.slide-prev {
  animation: slide-prev 0.3s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes slide-next {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes slide-prev {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
