/* ══ TOKENS ══ */
:root {
  --c-bg: #f7f5f0;
  --c-surface: #ffffff;
  --c-primary: #1a1a2e;
  --c-accent: #4f5fcf;
  --c-accent2: #c0392b;
  --c-text: #1a1a2e;
  --c-muted: #6b7280;
  --c-border: #ddd8cf;
  --c-selected: #eef0fb;
  --c-error: #dc2626;

  --rpt-bg: #fdfcf9;
  --rpt-ink: #1a1a2e;
  --rpt-rule: #e8e4dc;
  --rpt-accent: #4f5fcf;

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow: 0 2px 16px rgba(0,0,0,.08);

  --font: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  overflow-x: hidden;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideQ {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══ SCREENS ══ */
.screen { display: none; min-height: 100vh; animation: fadeUp .4s ease; }
.screen.active { display: block; }

.container { max-width: 680px; margin: 0 auto; padding: 0 24px; }
.center-v {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; text-align: center;
}

/* ══ BUTTONS ══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; border-radius: var(--r-md);
  font-family: var(--font); font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: all .18s ease; text-decoration: none;
  padding: 10px 22px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { font-size: .82rem; padding: 7px 16px; }
.btn-primary { background: var(--c-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3d4ab8; box-shadow: 0 4px 16px rgba(79,95,207,.35); }
.btn-secondary { background: var(--c-surface); color: var(--c-primary); border: 1.5px solid var(--c-border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--c-accent); color: var(--c-accent); }

/* ══ INTRO SCREEN ══ */
#screen-intro {
  display: none;
  background: radial-gradient(circle at 10% 20%, rgba(79, 95, 207, 0.05) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(249, 115, 22, 0.03) 0%, transparent 40%),
              var(--c-bg);
  min-height: 100vh;
  padding: 40px 20px;
}
#screen-intro.active { display: flex; align-items: center; justify-content: center; }
.intro-inner {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: 56px 48px;
  box-shadow: 0 10px 40px rgba(0,0,0,.03);
  max-width: 580px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Premium Logo Animation */
.intro-logo {
  position: relative;
  width: 60px;
  height: 60px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-circle {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid var(--c-accent);
  opacity: 0.25;
  animation: logoPulse 3s infinite ease-in-out;
}
.logo-inner-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-accent);
  box-shadow: 0 0 20px rgba(79,95,207,.6);
}
@keyframes logoPulse {
  0%, 100% { transform: scale(0.95); opacity: 0.25; }
  50% { transform: scale(1.25); opacity: 0.5; }
}

.intro-badge {
  display: inline-block;
  background: rgba(79,95,207,.08);
  color: var(--c-accent);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .15em;
  padding: 6px 16px;
  border-radius: 100px;
  margin-bottom: 28px;
  border: 1px solid rgba(79,95,207,.12);
  text-transform: uppercase;
}
.intro-title {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--c-primary);
  line-height: 1.35;
  margin-bottom: 32px;
  word-break: keep-all;
}
.intro-body {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--c-muted);
  word-break: keep-all;
  margin-bottom: 16px; /* 버튼 위 마진 줄이기 */
  text-align: center;
}
.intro-body p { margin-bottom: 14px; }
.intro-body .note {
  font-size: .88rem;
  color: var(--c-accent);
  font-weight: 600;
}
.intro-start { min-width: 200px; font-size: 1.15rem; padding: 16px 40px; }
.intro-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px; /* 버튼 위 마진 줄이기 */
}

/* ══ SURVEY SCREEN ══ */
.survey-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247,245,240,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
  padding: 12px 20px;
}
.survey-header-inner { max-width: 680px; margin: 0 auto; }
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: .76rem; color: var(--c-muted); margin-bottom: 6px;
}
.progress-track {
  height: 5px; background: var(--c-border);
  border-radius: 100px; overflow: hidden;
}
#progress-bar {
  height: 100%;
  background: var(--c-accent);
  border-radius: 100px; transition: width .35s ease;
}
.survey-body { padding: 36px 20px 100px; max-width: 680px; margin: 0 auto; }
#question-list {
  display: flex; flex-direction: column;
  gap: 24px; margin-bottom: 24px;
}
#question-list.slide-in { animation: slideQ .25s cubic-bezier(.25,.46,.45,.94); }

/* Question card */
.question-item {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: 36px;
  box-shadow: var(--shadow);
  transition: all .3s ease;
}
.question-item.answered { opacity: .45; transform: scale(.98); }
.question-item.focused {
  opacity: 1;
  border-color: var(--c-accent);
  box-shadow: 0 4px 20px rgba(79,95,207,.18);
  transform: scale(1);
}
.q-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.q-number { font-size: .78rem; font-weight: 700; color: var(--c-muted); letter-spacing: .06em; }
.q-text {
  font-size: 1.4rem; line-height: 1.7;
  color: var(--c-primary); font-weight: 700; margin-bottom: 32px;
  word-break: keep-all;
}

/* Linear scale — 5 circles */
.q-linear-scale {
  display: flex; justify-content: space-between;
  align-items: flex-start; position: relative; padding: 0 4%;
}
/* 연결선: 숫자(위) 아래의 원 중심을 지나도록 위치 */
.q-linear-scale::before {
  content: ''; position: absolute;
  top: 40px; left: 10%; right: 10%;
  height: 2px; background: var(--c-border); z-index: 0;
}
.scale-option {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  cursor: pointer; z-index: 1; width: 60px;
}
.scale-num {
  font-size: .82rem; font-weight: 700; color: var(--c-muted);
  line-height: 16px; height: 16px;
}
.scale-circle {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--c-surface); border: 3px solid var(--c-border);
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.scale-option:hover .scale-circle { border-color: var(--c-accent); transform: scale(1.1); }
.scale-option.selected .scale-circle {
  background: var(--c-accent); border-color: var(--c-accent);
  box-shadow: 0 0 0 5px rgba(79,95,207,.2); transform: scale(1.1);
}
.scale-label {
  font-size: .7rem; color: var(--c-muted); font-weight: 500;
  text-align: center; line-height: 1.3; word-break: keep-all; min-height: 1px;
}
.scale-option.selected .scale-num,
.scale-option.selected .scale-label { color: var(--c-accent); font-weight: 700; }

/* 설문 첫 화면 상단 안내 배너 */
.survey-guide {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-accent);
  border-radius: var(--r-md);
  padding: 24px 28px;
  margin-bottom: 40px;
  box-shadow: var(--shadow);
}
.survey-guide p {
  font-size: 1rem; color: var(--c-muted);
  line-height: 1.7; margin-bottom: 4px; word-break: keep-all;
}
.survey-guide p:last-child { margin-bottom: 0; }
.survey-guide strong { color: var(--c-primary); }

/* Nav */
.survey-nav {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 32px;
}
.survey-nav .btn {
  flex: 1;
  padding: 14px 20px;
  font-size: 1rem;
}

/* ══ RESULT SCREEN ══ */
#screen-result {
  background: var(--c-bg); min-height: 100vh; padding-bottom: 90px;
}
.report-action-bar {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 12px 0; position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  box-shadow: 0 -4px 16px rgba(0,0,0,.05);
}
.report-action-bar .container {
  max-width: 900px; display: flex;
  align-items: center; justify-content: center;
}
.report-action-btns {
  display: flex; gap: 12px;
  width: 100%; max-width: 400px;
  justify-content: center;
}
.report-action-btns .btn {
  flex: 1;
  padding: 14px 28px;
  font-size: 1.05rem;
}

/* PDF page */
.pdf-page {
  width: 1040px; margin: 24px auto;
  background: var(--rpt-bg); border-radius: var(--r-lg);
  box-shadow: 0 4px 32px rgba(0,0,0,.12);
}
.page-inner { padding: 40px 60px; }

/* Report sections */
.rpt-title {
  font-size: 1.7rem; font-weight: 900;
  color: var(--rpt-ink); margin-bottom: 6px;
  margin-top: 24px; /* 늘려준 최상단 타이틀 위 여백 */
}
.rpt-subtitle {
  font-size: .9rem; color: var(--c-muted);
  margin-bottom: 20px; line-height: 1.6; word-break: keep-all;
}
.rpt-divider { border: none; border-top: 1.5px solid var(--rpt-rule); margin: 16px 0; }
.rpt-section { margin-bottom: 48px; }
.rpt-section.rpt-first {
  margin-top: 36px;
}
@media (min-width: 681px) {
  .rpt-stress-rank {
    margin-bottom: 72px;
  }
}
.rpt-section-title {
  font-size: 1.25rem; font-weight: 800;
  color: var(--rpt-ink); margin-bottom: 28px;
  display: flex; align-items: center; gap: 8px;
}
.rpt-section-title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 18px;
  background: var(--c-accent);
  border-radius: 3px;
}

/* Stress index */
.stress-index-wrap {
  display: flex; align-items: center; gap: 24px;
  background: linear-gradient(135deg,#eaf2fc,#f5f9ff);
  border: 1px solid #d2e0f0;
  border-radius: var(--r-lg); padding: 18px 24px; margin-bottom: 12px;
}
.stress-index-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  text-align: center;
}
.stress-index-num {
  font-size: 4.2rem; font-weight: 900;
  color: #2b3b9a; line-height: 1;
}
.stress-index-level {
  font-size: 0.82rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 100px;
  margin-top: 8px;
  display: inline-block;
  text-align: center;
  white-space: nowrap;
  background: transparent;
}
.stress-index-right { flex: 1; }
.stress-gauge-track {
  height: 14px; border-radius: 100px; overflow: hidden;
  background: linear-gradient(90deg, #22c55e 0%, #eab308 35%, #f97316 65%, #ef4444 100%);
  position: relative; margin-bottom: 6px;
}
.stress-gauge-needle {
  position: absolute; top: -4px; width: 4px; height: calc(100% + 8px);
  background: var(--c-primary); border-radius: 2px;
  transform: translateX(-50%); transition: left .6s cubic-bezier(.4,0,.2,1);
}
.stress-gauge-labels {
  position: relative; height: 14px;
  font-size: .68rem; color: var(--c-muted); font-weight: 600;
}
.stress-gauge-labels span {
  position: absolute; transform: translateX(-50%);
  white-space: nowrap;
}
.stress-comment {
  margin-top: 12px;
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 14px 18px; font-size: .95rem; color: var(--c-primary);
  line-height: 1.6; word-break: keep-all;
}

/* Ranking bars */
.rank-bar-list { display: flex; flex-direction: column; gap: 6px; }
.rank-bar-row { display: flex; align-items: center; gap: 10px; }
.rank-bar-rank {
  width: 24px; font-size: .78rem; font-weight: 800;
  color: var(--c-muted); text-align: center; flex-shrink: 0;
}
.rank-bar-label {
  width: 60px; font-size: .88rem; font-weight: 700;
  color: var(--c-muted); flex-shrink: 0;
}
.rank-bar-score {
  font-size: .88rem; font-weight: 700;
  color: var(--c-muted);
}
.rank-bar-track {
  flex: 1; height: 16px; background: var(--c-border);
  border-radius: 100px; overflow: hidden;
}
.rank-bar-fill { height: 100%; border-radius: 100px; transition: width .6s ease; }
.rank-bar-score {
  width: 44px; font-size: .82rem; font-weight: 700;
  text-align: right; flex-shrink: 0;
}

/* Head visualization — 인라인 SVG (텍스트가 같은 좌표계라 정확히 매핑) */
.head-wrap {
  width: 360px;
  margin: 0; /* PC에서는 좌측 정렬 */
}
.head-wrap svg {
  width: 90%; height: auto; display: block;
  margin: 0; /* PC에서는 좌측 정렬 */
}

/* Top3 meditation cards */
.top3-cards { display: flex; flex-direction: column; gap: 16px; }
.top3-card {
  background: #eaf1fa; border-radius: var(--r-lg);
  border: 1px solid #d2e0f0;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.top3-card-header {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: nowrap;
}
.top3-rank-badge {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 900; flex-shrink: 0;
}
.top3-cat-name { font-size: 1.25rem; font-weight: 800; color: var(--c-primary); }
.top3-band-tag {
  display: inline-block; font-size: .75rem; font-weight: 700;
  padding: 2px 9px; border-radius: 100px;
}
.top3-comment { font-size: .88rem; color: #374151; line-height: 1.6; word-break: keep-all; margin-left: 40px; }

/* Page footer */
.page-footer {
  text-align: center; font-size: .75rem; color: var(--c-muted);
  margin-top: 24px; padding-top: 12px;
  border-top: 1px solid var(--rpt-rule);
}

.rpt-bottom-row {
  display: flex; gap: 40px; align-items: flex-start; flex-wrap: wrap;
  margin-top: 24px;
}
.rpt-head-column {
  flex: 0 0 auto;
}

/* @print */
@media print {
  .report-action-bar, .no-print { display: none !important; }
  .pdf-page { margin: 0; border-radius: 0; box-shadow: none; }
}

/* @pdf-capture */
body.pdf-capture {
  width: 1040px !important;
  min-width: 1040px !important;
}
body.pdf-capture .pdf-page {
  width: 1040px !important;
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
body.pdf-capture .page-inner {
  padding: 40px 60px !important;
}
body.pdf-capture .stress-index-wrap {
  display: flex !important;
  flex-direction: row !important;
  gap: 24px !important;
  padding: 18px 24px !important;
  margin-bottom: 12px !important;
}
body.pdf-capture .stress-index-num {
  font-size: 3.8rem !important;
  min-width: 120px !important;
}
body.pdf-capture .rank-bar-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
}
body.pdf-capture .rank-bar-row {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}
body.pdf-capture .rank-bar-track {
  flex: 1 !important;
  height: 16px !important;
}
body.pdf-capture .rpt-bottom-row {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 32px !important;
  align-items: flex-start !important;
}
body.pdf-capture .top3-cards {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}
body.pdf-capture .top3-card {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding: 14px 18px !important;
}
body.pdf-capture .head-wrap {
  width: 360px !important;
}

@media (max-width: 680px) {
  #screen-result { background: var(--rpt-bg); padding-bottom: 80px; }
  .intro-inner { padding: 40px 24px; }
  .pdf-page { width: 100%; margin: 0; border-radius: 0; box-shadow: none; }
  .page-inner { padding: 32px 20px; }
  .stress-index-wrap { flex-direction: column; gap: 16px; }
  .stress-index-left { min-width: 100%; }
  .stress-index-num { font-size: 3.4rem; min-width: unset; }
  .stress-index-right { width: 100%; }
  .top3-card { padding: 14px 16px; }
  .top3-comment { margin-left: 0; }
  .rpt-head-column {
    width: 100%;
    margin-bottom: 24px;
  }
  .report-action-bar { padding: 12px 16px; }
  .report-action-bar .container { padding: 0; max-width: 100%; }
  .report-action-btns { max-width: 100%; }
  .head-wrap {
    width: 310px; /* 모바일 이전 대비 15% 확대 */
    margin: 0 auto; /* 모바일은 중앙 정렬 유지 */
  }
  .head-wrap svg {
    width: 100%;
    margin: 0 auto;
  }
  .question-item { padding: 24px 18px; }
  .q-text { font-size: 1.25rem; font-weight: 700; }
  .scale-option { width: 42px; }
  .scale-num { font-size: .72rem; }
  .scale-label { font-size: .58rem; }
  .intro-title { font-size: 2.2rem; }
  .intro-buttons {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 12px;
  }
  .intro-buttons .btn {
    width: 100%;
    min-width: unset;
    padding: 16px 20px;
    font-size: 1.1rem;
  }
}
