/* =========================================================
   리스크 라이브 (Risk Live) — Samsung Life AI Search
   CSS v1.0 — Responsive, iframe-compatible
   ========================================================= */

/* ── Variables ── */
:root {
  --color-primary:     #003087;
  --color-primary-dk:  #001e5a;
  --color-primary-lt:  #e8eef8;
  --color-accent:      #0057d9;
  --color-cancer:      #7c3aed;   /* 퍼플 */
  --color-cancer-lt:   #f5f0ff;
  --color-cancer-bg:   #faf5ff;
  --color-heart:       #e53e3e;   /* 레드 */
  --color-heart-lt:    #fff5f5;
  --color-brain:       #2563eb;   /* 블루 */
  --color-brain-lt:    #eff6ff;
  --color-official:    #0d6643;
  --color-official-lt: #e6f4ee;
  --color-ref:         #7b5d2b;
  --color-ref-lt:      #fdf6ec;
  --color-gray-50:     #f4f6fb;
  --color-gray-100:    #eef0f6;
  --color-gray-200:    #e0e4ef;
  --color-gray-400:    #9ba3b5;
  --color-gray-600:    #5a6476;
  --color-gray-800:    #1e2433;
  --color-white:       #ffffff;
  --color-text:        #1e2433;
  --color-text-sub:    #5a6476;
  --color-text-muted:  #9ba3b5;

  --font-base: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);

  --content-max: 1200px;
  --gap-xs:  4px;
  --gap-sm:  8px;
  --gap-md:  16px;
  --gap-lg:  24px;
  --gap-xl:  32px;
  --gap-2xl: 48px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-base);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: #f4f6fb;
  min-height: 100vh;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }

/* ── Access Blocked Screen ── */
.access-blocked {
  position: fixed; inset: 0;
  background: var(--color-gray-50);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  flex-direction: column;
}
.blocked-content {
  text-align: center;
  padding: var(--gap-xl);
  max-width: 420px;
}
.blocked-icon {
  font-size: 56px;
  color: var(--color-gray-400);
  margin-bottom: var(--gap-lg);
}
.blocked-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: var(--gap-sm);
  color: var(--color-gray-800);
}
.blocked-content p { color: var(--color-text-sub); font-size: 15px; }
.blocked-sub { margin-top: var(--gap-sm); font-size: 13px; color: var(--color-text-muted); }
.hidden { display: none !important; }

/* ── App Container ── */
.app-container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gap-md);
  padding-bottom: var(--gap-2xl);
}

/* ── Header ── */
.app-header {
  background: #ffffff;
  color: var(--color-gray-800);
  padding: 0 var(--gap-lg);
  margin: 0 calc(-1 * var(--gap-md));
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid #eef0f6;
}
/* 우상단 AI 블루 글로우 장식 — 레퍼런스 느낌 */
.app-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -20px;
  width: 220px; height: 120px;
  background: radial-gradient(ellipse, rgba(90,129,250,.08) 0%, transparent 70%);
  pointer-events: none;
}
.app-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 30%;
  width: 160px; height: 80px;
  background: radial-gradient(ellipse, rgba(121,216,237,.06) 0%, transparent 70%);
  pointer-events: none;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap-md);
  height: 60px;
  position: relative; z-index: 1;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* 서비스 태그 — LIVE + 타이틀 세로 스택 제거, 가로 배치 */
.header-service-tag { display: contents; }
.header-service-label { display: none; }
.header-brand { display: flex; align-items: center; gap: 10px; }

/* 🟢 LIVE 뱃지 */
.brand-badge {
  background: rgba(16,185,129,.08);
  border: 1px solid rgba(16,185,129,.35);
  color: #059669;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 100px;
  letter-spacing: .12em;
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.live-pulse {
  width: 5px; height: 5px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-green 2s ease infinite;
}
@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.55); }
  60%  { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* 타이틀 */
.brand-title {
  font-size: clamp(16px, 2.8vw, 20px);
  font-weight: 800;
  letter-spacing: -.03em;
  color: #1a1f36;
  line-height: 1.2;
}
.brand-sub {
  font-weight: 400;
  font-size: .6em;
  color: #a0abc0;
  letter-spacing: .04em;
  margin-left: 1px;
}

/* 세로 구분선 */
.header-divider {
  width: 1px;
  height: 24px;
  background: #e4e8f0;
  flex-shrink: 0;
}

/* 헤더 부제목 — 구분선 오른쪽 */
.header-desc-inline {
  font-size: 11.5px;
  color: #a0abc0;
  line-height: 1.4;
}

/* 오른쪽 메타 */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative; z-index: 1;
}
.official-badge {
  background: #f4f6fb;
  border: 1px solid #e4e8f0;
  color: #6b7a99;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 100px;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.official-badge i { color: #a0abc0; font-size: 10px; }
.data-updated {
  font-size: 11px;
  color: #b0bcd0;
  white-space: nowrap;
}
.header-meta { display: none; }
.header-desc { display: none; }

/* ── Tab Navigation — 라이트 + 언더라인 스타일 ── */
.tab-nav {
  display: flex;
  gap: 0;
  background: #ffffff;
  padding: 0 var(--gap-md);
  margin: 0 calc(-1 * var(--gap-md));
  margin-bottom: var(--gap-lg);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-bottom: 1.5px solid #eef0f6;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 1;
  min-width: 76px;
  padding: 12px var(--gap-md) 11px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 600;
  color: #a0abc0;
  transition: color .15s ease;
  white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  position: relative;
}
.tab-btn:hover { color: #5a81fa; }
.tab-btn.active { color: #5a81fa; border-bottom-color: #5a81fa; }
.tab-btn[data-tab="cancer"].active { color: var(--color-cancer); border-bottom-color: var(--color-cancer); }
.tab-btn[data-tab="heart"].active  { color: var(--color-heart);  border-bottom-color: var(--color-heart);  }
.tab-btn[data-tab="brain"].active  { color: var(--color-brain);  border-bottom-color: var(--color-brain);  }
.tab-btn[data-tab="cancer"]:hover  { color: var(--color-cancer); }
.tab-btn[data-tab="heart"]:hover   { color: var(--color-heart);  }
.tab-btn[data-tab="brain"]:hover   { color: var(--color-brain);  }

/* ── Card (Base) ── */
.card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-gray-200);
  overflow: hidden;
}

/* ── Input Card ── */
.input-card { padding: var(--gap-lg); margin-bottom: var(--gap-lg); }
.card-header { margin-bottom: var(--gap-md); }
.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-primary);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.card-desc { font-size: 13px; color: var(--color-text-sub); }
.input-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--gap-md);
  align-items: end;
}
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-action { grid-column: span 1; }
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-gray-600);
}
.optional { font-weight: 400; color: var(--color-text-muted); }
.field-select {
  padding: 10px 14px;
  border: 1.5px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%239ba3b5' d='M8 11L2 5h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
}
.field-select:focus { outline: none; border-color: var(--color-accent); }
.gender-toggle { display: flex; gap: var(--gap-sm); }
.gender-btn {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gray-600);
  background: var(--color-white);
  transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.gender-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.gender-btn.selected[data-gender="male"] {
  background: #ebf3ff; border-color: var(--color-accent); color: var(--color-accent); font-weight: 700;
}
.gender-btn.selected[data-gender="female"] {
  background: #fff0f3; border-color: var(--color-cancer); color: var(--color-cancer); font-weight: 700;
}
.btn-primary {
  width: 100%;
  padding: 11px var(--gap-lg);
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--color-accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  padding: 9px var(--gap-lg);
  background: var(--color-gray-100);
  color: var(--color-gray-600);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-secondary:hover { background: var(--color-gray-200); }
.btn-danger {
  padding: 9px var(--gap-lg);
  background: var(--color-cancer);
  color: white;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-danger:hover { filter: brightness(.9); }

/* ── Personal Result ── */
.personal-result {
  margin-bottom: var(--gap-lg);
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-md);
}
.result-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
}
.reset-btn {
  font-size: 13px;
  color: var(--color-text-sub);
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-gray-200);
  background: var(--color-white);
  transition: all .15s;
}
.reset-btn:hover { color: var(--color-primary); border-color: var(--color-primary); }
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-md);
}
.result-cohort-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-gray-200);
  padding: var(--gap-md);
  box-shadow: var(--shadow-sm);
}
.result-cohort-card.cancer { border-top: 3px solid var(--color-cancer); }
.result-cohort-card.heart  { border-top: 3px solid var(--color-heart);  }
.result-cohort-card.brain  { border-top: 3px solid var(--color-brain);  }
.cohort-icon { font-size: 20px; margin-bottom: 8px; }
.cohort-title { font-size: 13px; font-weight: 600; color: var(--color-text-sub); margin-bottom: 4px; }
.cohort-main-stat {
  font-size: 22px; font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}
.result-cohort-card.cancer .cohort-main-stat { color: var(--color-cancer); }
.result-cohort-card.heart .cohort-main-stat  { color: var(--color-heart);  }
.result-cohort-card.brain .cohort-main-stat  { color: var(--color-brain);  }
.cohort-sub { font-size: 12px; color: var(--color-text-sub); line-height: 1.4; }
.cohort-source { font-size: 11px; color: var(--color-text-muted); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--color-gray-100); }

/* ── Section Block ── */
.section-block { margin-bottom: var(--gap-xl); }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-gray-800);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: var(--gap-md);
}
.section-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-sub);
  background: var(--color-gray-100);
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
}
.year-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-gray-100);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .01em;
}
.txt-cancer { color: var(--color-cancer); }
.txt-heart  { color: var(--color-heart);  }
.txt-brain  { color: var(--color-brain);  }

/* ── Live Counter ── */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--color-cancer);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.75); }
}
.counter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-md);
}

/* 카드 — 좌측 컬러 라인 제거, 클린 박스 */
.counter-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-gray-200);
  padding: 14px var(--gap-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  transition: box-shadow .2s;
}
.counter-card:hover { box-shadow: var(--shadow-md); }
/* 좌측 컬러 라인 없음 — border-left 제거 */
.counter-cancer { border-left: none; }
.counter-heart  { border-left: none; }
.counter-brain  { border-left: none; }

/* 아이콘 원형 배지 */
.counter-icon {
  font-size: 17px;
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.counter-cancer .counter-icon { color: var(--color-cancer); background: var(--color-cancer-lt); }
.counter-heart  .counter-icon { color: var(--color-heart);  background: var(--color-heart-lt);  }
.counter-brain  .counter-icon { color: var(--color-brain);  background: var(--color-brain-lt);  }

/* 본문 영역 */
.counter-body { flex: 1; min-width: 0; }
.counter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-sub);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 숫자 + 단위 가로 배치 */
.counter-number-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
}
.counter-number {
  font-size: clamp(24px, 3.8vw, 34px);
  font-weight: 800;
  color: var(--color-gray-800);
  font-variant-numeric: tabular-nums;
  transition: color .3s;
  line-height: 1;
}
.counter-number.updated { color: var(--color-primary); }
.counter-unit-inline {
  font-size: clamp(13px, 1.6vw, 15px);
  font-weight: 700;
  color: var(--color-gray-600);
  line-height: 1;
}

/* 하단 설명 문구 — 작고 명확하게 */
.counter-sub {
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.counter-sub-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-gray-200);
  flex-shrink: 0;
  display: inline-block;
}

/* 구버전 호환 — 숨김 */
.counter-unit { display: none; }
.counter-footer { display: none; }
.counter-interval { display: none; }
.counter-source { display: none; }

.counter-disclaimer {
  margin-top: var(--gap-sm);
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-gray-50);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  display: flex; align-items: center; gap: 5px;
  line-height: 1.5;
}
.counter-disclaimer i { color: var(--color-accent); flex-shrink: 0; }

/* ══════════════════════════════════════════
   Insight Card — 움직이는 AI 그라디언트
══════════════════════════════════════════ */

/* ─────────────────────────────────────────────────
   Insight Card — 움직이는 AI 그라디언트 (분홍+파랑)
───────────────────────────────────────────────── */

/* 배경 그라디언트 이동 */
@keyframes ai-gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
/* shimmer 흐름 */
@keyframes ai-shimmer {
  0%   { transform: translateX(-120%) skewX(-18deg); opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateX(350%) skewX(-18deg); opacity: 0; }
}
/* 글로우 블롭 부유 */
@keyframes blob-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(12px, -8px) scale(1.08); }
  66%       { transform: translate(-8px, 10px) scale(.95); }
}

.insight-card {
  padding: var(--gap-lg) var(--gap-lg) var(--gap-md);
  /*
   * cyan #06b6d4 → blue #3b5bdb → violet #7c3aed
   * → pink #db2777 (포인트, 25%) → back to indigo
   * 비율: cyan 많이, 블루 메인, 보라 중간, 분홍 살짝
   */
  background: linear-gradient(
    125deg,
    #0d1f6e 0%,      /* 딥 네이비 */
    #1a56a8 14%,     /* 오션 블루 */
    #0891b2 28%,     /* cyan-700 */
    #1e40af 42%,     /* 블루 */
    #4c1d95 56%,     /* 딥 바이올렛 */
    #7c3aed 68%,     /* 바이올렛 */
    #9d174d 80%,     /* 로즈 — 한 톤 낮춤 */
    #1e40af 90%,     /* 블루로 회귀 */
    #0d1f6e 100%
  );
  background-size: 300% 300%;
  animation: ai-gradient-shift 10s ease infinite;
  border: none;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 6px 32px rgba(12, 145, 178, .20),   /* cyan 그림자 */
    0 2px 8px rgba(76, 29, 149, .18),     /* 바이올렛 그림자 */
    0 1px 2px rgba(0,0,0,.12);
}

/* shimmer 광택 레이어 */
.insight-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 35%; height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,.055) 50%,
    transparent 100%
  );
  animation: ai-shimmer 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* 상단 우측 — cyan+보라 블롭 */
.insight-card::after {
  content: '';
  position: absolute;
  top: -50px; right: -30px;
  width: 200px; height: 200px;
  background: radial-gradient(circle,
    rgba(6, 182, 212, .26) 0%,    /* cyan */
    rgba(124, 58, 237, .16) 50%,  /* 바이올렛 */
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  animation: blob-float 7s ease-in-out infinite;
}

/* 좌측 하단 블롭 — 분홍 포인트 */
.insight-card .insight-blob {
  position: absolute;
  bottom: -40px; left: -20px;
  width: 160px; height: 160px;
  background: radial-gradient(circle,
    rgba(190, 24, 93, .10) 0%,    /* 분홍 — 더 은은하게 */
    rgba(29, 78, 216, .12) 55%,   /* 블루 */
    transparent 72%
  );
  pointer-events: none;
  z-index: 0;
  animation: blob-float 10s ease-in-out infinite reverse;
}

/* ── 헤더 ── */
.insight-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--gap-md);
  position: relative; z-index: 1;
}
.insight-label {
  font-size: 10px;
  font-weight: 700;
  /* cyan 계열 — 배경 대비 충분 */
  color: #67e8f9;
  display: flex; align-items: center; gap: 7px;
  letter-spacing: .1em;
  text-transform: uppercase;
  flex-wrap: wrap;
}

/* 로봇 아이콘 박스 */
.insight-label-icon {
  width: 24px; height: 24px;
  background: rgba(6,182,212,.18);
  border: 1px solid rgba(103,232,249,.3);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: #a5f3fc;  /* cyan-200 */
  flex-shrink: 0;
}

/* AI Curated 뱃지 */
.insight-ai-badge {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,.88);
  border: 1px solid rgba(103,232,249,.3);
  background: linear-gradient(90deg, rgba(6,182,212,.15), rgba(124,58,237,.15));
  padding: 2px 9px;
  border-radius: 100px;
  letter-spacing: .07em;
}

/* ── 액션 버튼 ── */
.insight-actions { display: flex; align-items: center; gap: 6px; position: relative; z-index: 1; }
.insight-refresh-btn {
  font-size: 11px;
  font-weight: 600;
  /* 흰색 계열 — 어두운 배경 위 충분한 대비 */
  color: rgba(255,255,255,.82);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 100px;
  padding: 4px 12px;
  background: rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 4px;
  transition: all .2s;
}
.insight-refresh-btn:hover {
  background: rgba(255,255,255,.2);
  border-color: rgba(255,255,255,.4);
  color: #fff;
}
.insight-refresh-btn.spinning i { animation: spin .5s linear; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.insight-report-btn {
  font-size: 12px;
  color: rgba(255,255,255,.3);
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  transition: color .15s;
}
.insight-report-btn:hover { color: rgba(251,146,152,.8); }

/* ── 본문 텍스트 — WCAG AA 기준 (배경 대비 4.5:1 이상) ── */
.insight-text {
  font-size: 15.5px;
  font-weight: 600;      /* 500→600: 굵기로도 가독성 보완 */
  color: #ffffff;        /* 순백 — 어두운 배경 위 최고 대비 */
  line-height: 1.78;
  min-height: 52px;
  transition: opacity .25s;
  position: relative; z-index: 1;
  letter-spacing: -.01em;
  /* 배경 그라디언트 위 텍스트 선명도 강화 */
  text-shadow:
    0 1px 12px rgba(0,0,0,.35),
    0 0px 2px rgba(0,0,0,.2);
}
.insight-text.loading { opacity: .2; }

/* 깜빡이는 AI 커서 — cyan→바이올렛, 하단에 분홍 포인트 */
.insight-cursor {
  display: inline-block;
  width: 2px; height: .88em;
  background: linear-gradient(180deg, #67e8f9 0%, #818cf8 55%, #f472b6 100%);
  margin-left: 3px;
  vertical-align: text-bottom;
  border-radius: 2px;
  animation: blink .9s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── 푸터 ── */
.insight-footer {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  margin-top: var(--gap-md);
  padding-top: var(--gap-sm);
  border-top: 1px solid rgba(255,255,255,.14);
  gap: var(--gap-xs);
  position: relative; z-index: 1;
}
/* 출처 텍스트 — 충분히 밝게 (배경 대비 WCAG AA 경계 확보) */
.insight-source { font-size: 11px; color: rgba(165,243,252,.65); }  /* cyan-200 계열 */
.insight-disclaimer { font-size: 10px; color: rgba(255,255,255,.5); }

/* ── Stats Grid (All Tab) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-md);
}
.stat-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-gray-200);
  padding: var(--gap-lg);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--gap-sm);
}
.stat-cancer { border-top: none; }
.stat-heart  { border-top: none; }
.stat-brain  { border-top: none; }
.stat-icon { font-size: 22px; }
.stat-cancer .stat-icon { color: var(--color-cancer); }
.stat-heart  .stat-icon { color: var(--color-heart);  }
.stat-brain  .stat-icon { color: var(--color-brain);  }
.stat-body { flex: 1; }
.stat-main { font-size: 26px; font-weight: 800; color: var(--color-gray-800); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--color-text-sub); font-weight: 600; margin-top: 4px; }
.stat-sub { font-size: 13px; color: var(--color-text-sub); margin-top: 6px; }
.stat-source { font-size: 11px; color: var(--color-text-muted); padding-top: 8px; border-top: 1px solid var(--color-gray-100); }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-md);
}
.kpi-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-gray-200);
  padding: var(--gap-lg);
  box-shadow: var(--shadow-sm);
}
.kpi-card.kpi-highlight {
  background: var(--color-primary-lt);
  border-color: #b8ccf0;
}
.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--color-gray-800);
  line-height: 1.1;
  margin-bottom: 6px;
}
.kpi-highlight .kpi-value { color: var(--color-primary); }
.kpi-unit { font-size: .55em; font-weight: 600; color: var(--color-text-sub); }
.kpi-label { font-size: 13px; font-weight: 700; color: var(--color-text-sub); }
.kpi-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
  line-height: 1.4;
}
.kpi-source {
  font-size: 11px; color: var(--color-text-muted);
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--color-gray-100);
}
.framing-note { color: var(--color-official) !important; font-style: italic; }
.alert-badge {
  display: inline-block;
  background: #fff3cd;
  color: #b36b00;
  font-size: 12px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── Alert Box ── */
.alert-box {
  background: #fff8ec;
  border: 1px solid #f0c060;
  border-left: 4px solid #e6900a;
  border-radius: var(--radius-md);
  padding: var(--gap-md) var(--gap-lg);
  display: flex; align-items: flex-start; gap: var(--gap-md);
}
.alert-icon { font-size: 20px; color: #e6900a; flex-shrink: 0; margin-top: 2px; }
.alert-box strong { display: block; font-size: 15px; font-weight: 700; color: var(--color-gray-800); margin-bottom: 4px; }
.alert-box p { font-size: 14px; color: var(--color-text-sub); }
.alert-source { display: block; font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }

/* ── Burden (Insurance) Card ── */
.burden-main-card {
  padding: var(--gap-xl);
}
.burden-header {
  display: flex; align-items: flex-start; gap: var(--gap-md);
  margin-bottom: var(--gap-lg);
}
.burden-icon { font-size: 28px; color: var(--color-official); flex-shrink: 0; }
.burden-title { font-size: 16px; font-weight: 700; color: var(--color-gray-800); }
.burden-note { font-size: 12px; color: var(--color-text-sub); margin-top: 4px; }
.burden-amount {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--gap-md);
}
.burden-value { font-size: 1em; }
.burden-unit { font-size: .6em; font-weight: 600; color: var(--color-text-sub); }
.burden-period { font-size: .45em; font-weight: 500; color: var(--color-text-muted); }
.burden-source-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
  padding-bottom: var(--gap-md);
  border-bottom: 1px solid var(--color-gray-100);
}
.burden-source-tag {
  font-size: 12px;
  background: var(--color-official-lt);
  color: var(--color-official);
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 600;
}
.burden-disclaimer { font-size: 11px; color: var(--color-text-muted); }
.burden-by-age {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-sm);
}
.age-burden-item {
  background: var(--color-gray-50);
  border-radius: var(--radius-sm);
  padding: var(--gap-sm) var(--gap-md);
  text-align: center;
}
.age-label { font-size: 12px; color: var(--color-text-sub); display: block; margin-bottom: 3px; }
.age-value { font-size: 14px; font-weight: 700; color: var(--color-primary); }
.burden-extra-row {
  padding-top: var(--gap-md);
}
.burden-extra-item {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--color-gray-50);
  border-radius: var(--radius-sm);
  padding: var(--gap-sm) var(--gap-md);
}
.extra-label { font-size: 13px; color: var(--color-text-sub); }
.extra-value { font-size: 15px; font-weight: 700; color: var(--color-primary); }
.official-tag {
  font-size: 12px; font-weight: 600;
  color: var(--color-official);
  background: var(--color-official-lt);
  padding: 2px 8px; border-radius: 4px;
}

/* ── Reference Info Card ── */
.ref-notice {
  background: var(--color-ref-lt);
  border: 1px solid #f0d080;
  border-left: 4px solid var(--color-ref);
  border-radius: var(--radius-sm);
  padding: var(--gap-sm) var(--gap-md);
  font-size: 13px;
  color: var(--color-ref);
  display: flex; align-items: flex-start; gap: 6px;
  margin-bottom: var(--gap-md);
  line-height: 1.5;
}
.ref-notice i { flex-shrink: 0; margin-top: 2px; }
.ref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-md);
}
.ref-card {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ref-card-header {
  background: var(--color-gray-50);
  padding: var(--gap-sm) var(--gap-md);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-gray-600);
  border-bottom: 1px solid var(--color-gray-200);
  display: flex; align-items: center; gap: 6px;
}
.ref-list { padding: var(--gap-md); display: flex; flex-direction: column; gap: var(--gap-sm); }
.ref-list-item {
  padding: var(--gap-sm) var(--gap-md);
  background: var(--color-gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-gray-100);
}
.ref-item-name { font-size: 13px; font-weight: 600; color: var(--color-gray-800); }
.ref-item-cost { font-size: 14px; font-weight: 700; color: var(--color-ref); margin: 3px 0; }
.ref-item-unit { font-size: 11px; color: var(--color-text-muted); }
.ref-item-source { font-size: 11px; color: var(--color-text-muted); margin-top: 3px; }
.ref-item-note { font-size: 11px; color: var(--color-text-muted); font-style: italic; }
.ref-tag {
  font-size: 12px; font-weight: 600;
  color: var(--color-ref);
  background: var(--color-ref-lt);
  padding: 2px 8px; border-radius: 4px;
}
.ref-disclaimer {
  font-size: 12px; color: var(--color-text-muted);
  margin-top: var(--gap-md);
  padding: 8px 12px;
  background: var(--color-gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-gray-100);
}

/* ── Chart ── */
.chart-wrapper {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-gray-200);
  padding: var(--gap-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
  max-height: 360px;
  overflow: hidden;
}
.chart-wrapper canvas {
  max-height: 300px !important;
}
.chart-donut-wrapper { max-width: 440px; margin: 0 auto; max-height: 320px; }
.chart-donut-wrapper canvas { max-height: 280px !important; }
.chart-desc {
  font-size: 12.5px;
  color: var(--color-text-sub);
  margin-bottom: var(--gap-sm);
  line-height: 1.5;
}
.chart-source {
  font-size: 12px; color: var(--color-text-muted);
  margin-top: var(--gap-sm);
  text-align: right;
}

/* ── Top 6 Grid ── */
.top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-md);
}
/* TOP6 캔버스 높이 제한 */
.top-grid canvas {
  max-height: 200px !important;
}
.top-col-header {
  font-size: 13px; font-weight: 700;
  padding: 6px var(--gap-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--gap-sm);
  display: flex; align-items: center; gap: 6px;
}
.male-header   { background: #f0f4ff; color: var(--color-accent);  }
.female-header { background: #f5f0ff; color: var(--color-cancer);  }

/* ── Projection Card ── */
.projection-card { padding: var(--gap-lg); }
.projection-intro {
  font-size: 14px; color: var(--color-text-sub);
  margin-bottom: var(--gap-lg);
  display: flex; align-items: center; gap: 6px;
}
.projection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-md);
  margin-bottom: var(--gap-md);
}
.proj-item {
  text-align: center;
  background: var(--color-gray-50);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
  border: 1px solid var(--color-gray-200);
}
.proj-year { font-size: 13px; color: var(--color-text-muted); margin-bottom: 4px; }
.proj-value { font-size: 20px; font-weight: 800; color: var(--color-brain); }
.proj-change { font-size: 12px; color: var(--color-cancer); font-weight: 600; margin-top: 4px; }
.projection-source { font-size: 12px; color: var(--color-text-muted); }

/* ── Tab Content ── */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .25s ease; }

/* ── Footer ── */
.app-footer {
  background: var(--color-white);
  border-top: 1px solid var(--color-gray-200);
  padding: var(--gap-xl) var(--gap-lg);
  margin: 0 calc(-1 * var(--gap-md));
  margin-top: var(--gap-2xl);
}
.footer-inner { max-width: var(--content-max); margin: 0 auto; }
.footer-title { font-size: 13px; font-weight: 700; color: var(--color-gray-600); margin-bottom: var(--gap-sm); }
.footer-list { display: flex; flex-direction: column; gap: 5px; }
.footer-list li {
  font-size: 12px; color: var(--color-text-muted); padding-left: 14px; position: relative;
  line-height: 1.5;
}
.footer-list li::before { content: '•'; position: absolute; left: 0; }
.footer-disclaimer { margin-bottom: var(--gap-lg); }
.footer-data-sources { margin-bottom: var(--gap-md); }
.footer-sources-title { font-size: 12px; font-weight: 700; color: var(--color-gray-600); margin-bottom: 6px; }
.footer-sources-list {
  display: flex; flex-wrap: wrap; gap: var(--gap-sm);
}
.footer-sources-list span {
  font-size: 11px; color: var(--color-text-muted);
  background: var(--color-gray-100);
  padding: 3px 8px; border-radius: 100px;
}
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--color-gray-100);
  font-size: 12px; color: var(--color-text-muted);
}
.footer-product { font-weight: 600; color: var(--color-primary); }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--gap-md);
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  cursor: pointer;
}
.modal-content {
  position: relative;
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: var(--gap-xl);
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--color-gray-800); margin-bottom: var(--gap-sm); display: flex; align-items: center; gap: 8px; }
.modal-desc { font-size: 14px; color: var(--color-text-sub); margin-bottom: var(--gap-md); line-height: 1.6; }
.modal-label { font-size: 13px; font-weight: 600; color: var(--color-gray-600); display: block; margin-bottom: 6px; }
.modal-field { margin-bottom: var(--gap-md); }
.modal-actions { display: flex; gap: var(--gap-sm); justify-content: flex-end; }

/* ── Notification Toast ── */
.toast {
  position: fixed;
  bottom: var(--gap-lg);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--color-gray-800);
  color: white;
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 14px; font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease, toastOut .25s ease 2.5s forwards;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  white-space: normal;
  text-align: center;
}
@keyframes toastIn  { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ═══════════════════════════════════════════════════
   RESPONSIVE DESIGN  —  Tablet → Mobile → 320px
═══════════════════════════════════════════════════ */

/* ── Tablet (768px ~ 1023px) ── */
@media (max-width: 1023px) {
  .kpi-grid      { grid-template-columns: repeat(2, 1fr); }
  .burden-by-age { grid-template-columns: repeat(2, 1fr); }
  .stats-grid    { grid-template-columns: repeat(3, 1fr); }
}

/* ── Mobile Portrait (max 767px) ── */
@media (max-width: 767px) {
  /* ─ 기본 여백 축소 ─ */
  .app-container { padding: 0 12px; padding-bottom: var(--gap-xl); }

  /* ─ 헤더 ─ */
  .app-header { padding: 0 12px; margin: 0 -12px; }
  .header-inner { height: 50px; gap: 6px; flex-wrap: nowrap; }
  .header-left  { gap: 7px; min-width: 0; }
  .header-right { gap: 4px; flex-shrink: 0; }
  .header-divider    { display: none; }
  .header-desc-inline{ display: none; }
  .data-updated      { display: none; }
  .official-badge    { padding: 4px 8px; font-size: 10px; }
  .brand-title       { font-size: clamp(14px, 4vw, 17px); }
  .brand-sub         { display: none; }

  /* ─ 탭 ─ */
  .tab-nav { padding: 0 12px; margin: 0 -12px; }
  .tab-btn { padding: 10px 8px 9px; font-size: 12px; min-width: 56px; gap: 3px; }

  /* ─ 입력 카드 ─ */
  .input-card { padding: var(--gap-md); }
  .card-title { font-size: 15px; }
  .card-desc  { font-size: 12px; }
  .input-fields {
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-sm);
  }
  .input-fields .field-group:nth-child(3) { grid-column: 1 / -1; }
  .field-action { grid-column: 1 / -1; }
  .field-label  { font-size: 12px; }
  .field-select { padding: 9px 12px; font-size: 13px; padding-right: 32px; }
  .gender-btn   { padding: 9px 8px; font-size: 13px; }

  /* ─ 개인화 결과 ─ */
  .result-grid { grid-template-columns: 1fr; gap: var(--gap-sm); }
  .result-title { font-size: 16px; }
  .cohort-main-stat { font-size: 20px; }

  /* ─ 섹션 공통 ─ */
  .section-block  { margin-bottom: var(--gap-lg); }
  .section-title  { font-size: 14px; gap: 6px; margin-bottom: 10px; }
  .year-badge     { font-size: 11px; padding: 2px 6px; }

  /* ─ 통계 그리드 ─ */
  .stats-grid  { grid-template-columns: 1fr; gap: var(--gap-sm); }
  .stat-card   { padding: var(--gap-md); flex-direction: row; align-items: center; gap: var(--gap-md); }
  .stat-icon   { font-size: 18px; flex-shrink: 0; }
  .stat-main   { font-size: 20px; }
  .stat-label  { font-size: 12px; }
  .stat-sub    { font-size: 11px; }

  /* ─ KPI ─ */
  .kpi-grid  { grid-template-columns: 1fr 1fr; gap: var(--gap-sm); }
  .kpi-card  { padding: var(--gap-md); }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 12px; }
  .kpi-sub   { font-size: 11px; }

  /* ─ 차트 섹션 헤더 + 예측 버튼 ─ */
  .chart-section-header { flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 10px; }
  .forecast-toggle-btn  { font-size: 11px; padding: 5px 10px 5px 9px; }
  .forecast-btn-badge   { display: none; }

  /* ─ 차트 ─ */
  .chart-wrapper {
    padding: var(--gap-sm);
    max-height: 280px;
    border-radius: var(--radius-md);
  }
  .chart-wrapper canvas { max-height: 240px !important; }
  .chart-donut-wrapper  { max-height: 260px; }
  .chart-donut-wrapper canvas { max-height: 220px !important; }
  .chart-source { font-size: 11px; }
  .chart-desc   { font-size: 12px; }

  /* ─ 예측 안내 박스 ─ */
  .forecast-notice {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11.5px;
    padding: 8px 10px;
  }
  .forecast-what-btn { margin-left: 0; }

  /* ─ TOP6 차트 ─ */
  .top-grid { grid-template-columns: 1fr; gap: var(--gap-md); }
  .top-grid canvas { max-height: 180px !important; }

  /* ─ 부담 카드 ─ */
  .burden-main-card  { padding: var(--gap-md); }
  .burden-header     { flex-direction: column; gap: var(--gap-sm); }
  .burden-icon       { font-size: 22px; }
  .burden-title      { font-size: 14px; }
  .burden-amount     { font-size: clamp(24px, 7vw, 32px); }
  .burden-by-age     { grid-template-columns: 1fr 1fr; gap: var(--gap-xs); }
  .age-value         { font-size: 13px; }
  .burden-extra-item { flex-direction: column; align-items: flex-start; gap: 4px; }

  /* ─ 참고 정보 ─ */
  .ref-grid   { grid-template-columns: 1fr; }
  .ref-notice { font-size: 12px; }

  /* ─ 경고 박스 ─ */
  .alert-box  { padding: var(--gap-md); gap: var(--gap-sm); }
  .alert-box strong { font-size: 14px; }
  .alert-box p      { font-size: 13px; }

  /* ─ 전망 카드 ─ */
  .projection-grid { grid-template-columns: 1fr; gap: var(--gap-sm); }
  .proj-item       { padding: var(--gap-sm) var(--gap-md); display: flex; align-items: center; justify-content: space-between; text-align: left; gap: var(--gap-sm); }
  .proj-year  { margin-bottom: 0; font-size: 12px; }
  .proj-value { font-size: 17px; }
  .proj-change{ margin-top: 0; }

  /* ─ 인사이트 카드 ─ */
  .insight-card    { padding: var(--gap-md); }
  .insight-text    { font-size: 14px; min-height: 44px; }
  .insight-header  { margin-bottom: 10px; }
  .insight-label   { font-size: 9px; gap: 5px; }
  .insight-refresh-btn { padding: 4px 9px; font-size: 10px; }

  /* ─ 카운터 ─ */
  .counter-grid   { grid-template-columns: 1fr; gap: var(--gap-sm); }
  .counter-number { font-size: clamp(26px, 8vw, 34px); }

  /* ─ 푸터 ─ */
  .app-footer    { padding: var(--gap-lg) 12px; margin: 0 -12px; margin-top: var(--gap-xl); }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
  .footer-list li { font-size: 11.5px; }
  .footer-sources-list span { font-size: 10.5px; }
}

/* ── 소형 모바일 (max 480px) ── */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 18px; }

  .stats-grid .stat-main { font-size: 18px; }

  /* 차트 높이 더 축소 */
  .chart-wrapper { max-height: 250px; }
  .chart-wrapper canvas { max-height: 210px !important; }

  /* 인사이트 액션 버튼 줄바꿈 방지 */
  .insight-actions { gap: 4px; }
  .insight-refresh-btn { padding: 3px 7px; }
}

/* ── 극소형 (max 380px) ── */
@media (max-width: 380px) {
  .app-container { padding: 0 10px; padding-bottom: var(--gap-lg); }
  .app-header    { padding: 0 10px; margin: 0 -10px; }
  .tab-nav       { padding: 0 10px; margin: 0 -10px; }
  .app-footer    { padding: var(--gap-md) 10px; margin: 0 -10px; }

  .header-inner  { height: 46px; }
  .brand-title   { font-size: 13px; }
  .brand-badge   { font-size: 8px; padding: 2px 6px; }
  .official-badge{ display: none; }

  .tab-btn { font-size: 11px; min-width: 48px; padding: 9px 6px 8px; }

  /* 입력 폼 — 전부 1열로 */
  .input-fields { grid-template-columns: 1fr; }
  .input-fields .field-group:nth-child(3) { grid-column: auto; }

  .section-title { font-size: 13px; }
  .kpi-grid      { grid-template-columns: 1fr 1fr; gap: 6px; }
  .kpi-card      { padding: 10px 12px; }
  .kpi-value     { font-size: 17px; }
  .kpi-label     { font-size: 11px; }
  .kpi-sub       { font-size: 10px; }

  .stat-main  { font-size: 17px; }
  .stat-label { font-size: 11px; }

  .chart-wrapper { padding: 8px; max-height: 230px; }
  .chart-wrapper canvas { max-height: 190px !important; }

  .burden-amount { font-size: 22px; }
  .burden-by-age { grid-template-columns: 1fr 1fr; }
  .age-label     { font-size: 11px; }
  .age-value     { font-size: 12px; }

  .insight-text  { font-size: 13px; line-height: 1.65; }

  .forecast-toggle-btn { font-size: 10.5px; padding: 5px 8px; }
  .forecast-notice     { font-size: 11px; }
  .forecast-what-btn   { font-size: 10.5px; padding: 2px 6px; }

  .proj-value { font-size: 15px; }
  .result-cohort-card { padding: 12px; }
  .cohort-main-stat   { font-size: 18px; }
}

/* ── 320px 이하 극소 ── */
@media (max-width: 320px) {
  .app-container { padding: 0 8px; }
  .app-header    { padding: 0 8px; margin: 0 -8px; }
  .tab-nav       { padding: 0 8px; margin: 0 -8px; }
  .app-footer    { padding: var(--gap-md) 8px; margin: 0 -8px; }

  .brand-title { font-size: 12px; }
  .tab-btn     { font-size: 10.5px; min-width: 44px; padding: 8px 5px; }

  .kpi-grid    { grid-template-columns: 1fr; }
  .kpi-value   { font-size: 22px; }

  .burden-by-age { grid-template-columns: 1fr 1fr; }

  .chart-wrapper { max-height: 210px; border-radius: var(--radius-sm); }
  .chart-wrapper canvas { max-height: 175px !important; }

  .chart-section-header { gap: 4px; }
  .forecast-toggle-btn  { font-size: 10px; padding: 4px 7px; }

  .insight-card { padding: 12px; }
  .insight-text { font-size: 12.5px; }
}

/* ── Large Desktop (1440px+) ── */
@media (min-width: 1440px) {
  .app-container { padding: 0 var(--gap-xl); }
}

/* ── Print / iframe safe ── */
@media print {
  .insight-actions, .reset-btn, .btn-primary, .tab-nav,
  .forecast-toggle-btn, .forecast-what-btn { display: none; }
}

/* =========================================================
   예측 토글 — Forecast Toggle UI
   ========================================================= */

/* 차트 섹션 헤더: 제목 + 버튼을 한 줄에 */
.chart-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}
.chart-section-header .section-title {
  margin-bottom: 0;
}

/* 예측 토글 버튼 기본 */
.forecast-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 12px;
  border-radius: 20px;
  border: 1.5px dashed rgba(124, 58, 237, .45);
  background: rgba(124, 58, 237, .04);
  color: #7c3aed;
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--font-base);
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.forecast-toggle-btn:hover {
  background: rgba(124, 58, 237, .10);
  border-color: rgba(124, 58, 237, .7);
  box-shadow: 0 2px 8px rgba(124, 58, 237, .15);
}
.forecast-toggle-btn:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

/* 활성(예측 보이는 상태) */
.forecast-toggle-btn--active {
  background: rgba(124, 58, 237, .12);
  border-style: solid;
  border-color: #7c3aed;
  color: #5b21b6;
  box-shadow: 0 2px 10px rgba(124, 58, 237, .18);
}
.forecast-toggle-btn--active .forecast-btn-icon {
  animation: none;
  color: #7c3aed;
}

/* 심장 색상 변형 */
.forecast-toggle-btn--heart {
  border-color: rgba(229, 62, 62, .45);
  background: rgba(229, 62, 62, .04);
  color: #c53030;
}
.forecast-toggle-btn--heart:hover {
  background: rgba(229, 62, 62, .10);
  border-color: rgba(229, 62, 62, .7);
  box-shadow: 0 2px 8px rgba(229, 62, 62, .15);
}
.forecast-toggle-btn--heart.forecast-toggle-btn--active {
  background: rgba(229, 62, 62, .12);
  border-color: #e53e3e;
  color: #9b1c1c;
  box-shadow: 0 2px 10px rgba(229, 62, 62, .18);
}

/* 뇌 색상 변형 */
.forecast-toggle-btn--brain {
  border-color: rgba(37, 99, 235, .45);
  background: rgba(37, 99, 235, .04);
  color: #1d4ed8;
}
.forecast-toggle-btn--brain:hover {
  background: rgba(37, 99, 235, .10);
  border-color: rgba(37, 99, 235, .7);
  box-shadow: 0 2px 8px rgba(37, 99, 235, .15);
}
.forecast-toggle-btn--brain.forecast-toggle-btn--active {
  background: rgba(37, 99, 235, .12);
  border-color: #2563eb;
  color: #1e3a8a;
  box-shadow: 0 2px 10px rgba(37, 99, 235, .18);
}

/* 버튼 내부 아이콘 — 별/마법 느낌으로 sparkle 애니 */
.forecast-btn-icon {
  font-size: 11px;
  opacity: .75;
  animation: forecast-sparkle 2.4s ease-in-out infinite;
}
@keyframes forecast-sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: .75; }
  50%       { transform: scale(1.25) rotate(15deg); opacity: 1; }
}

/* AI 예측 뱃지 */
.forecast-btn-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(124,58,237,.18), rgba(37,99,235,.14));
  color: #5b21b6;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .03em;
  line-height: 1.4;
}
.forecast-toggle-btn--heart .forecast-btn-badge {
  background: linear-gradient(90deg, rgba(229,62,62,.15), rgba(249,115,22,.12));
  color: #9b1c1c;
}
.forecast-toggle-btn--brain .forecast-btn-badge {
  background: linear-gradient(90deg, rgba(37,99,235,.15), rgba(6,182,212,.12));
  color: #1e3a8a;
}

/* 예측 안내 문구 */
.forecast-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 6px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(124, 58, 237, .05);
  border-left: 3px solid rgba(124, 58, 237, .4);
  color: var(--color-text-sub);
  font-size: 12px;
  line-height: 1.5;
  animation: forecast-notice-in .22s ease-out;
}
.forecast-notice i {
  color: #7c3aed;
  margin-top: 1px;
  flex-shrink: 0;
  font-size: 12px;
}
.forecast-notice strong {
  color: var(--color-text);
  font-weight: 600;
}
@keyframes forecast-notice-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 반응형: 모바일에서 버튼 폰트 축소 */
@media (max-width: 767px) {
  .chart-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .forecast-toggle-btn {
    font-size: 11.5px;
    padding: 6px 12px 6px 10px;
  }
  .forecast-btn-badge {
    display: none;
  }
}

/* ── 예측 안내 박스 내 "이게 뭔가요?" 버튼 + 팝업 ── */
.forecast-what-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(124,58,237,.35);
  background: rgba(124,58,237,.07);
  color: #7c3aed;
  font-size: 11px;
  font-family: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.forecast-what-btn:hover,
.forecast-what-btn[aria-expanded="true"] {
  background: rgba(124,58,237,.15);
  border-color: rgba(124,58,237,.6);
}
.forecast-what-btn i { font-size: 10px; }

/* 팝업 말풍선 */
.forecast-what-popup {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .25s ease, opacity .2s ease, margin .2s ease, padding .2s ease;
  margin-top: 0;
  padding: 0 10px;

  background: var(--color-white);
  border: 1px solid rgba(124,58,237,.22);
  border-left: 3px solid #7c3aed;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--color-text-sub);
  line-height: 1.6;
  box-shadow: 0 2px 8px rgba(124,58,237,.08);
}
.forecast-what-popup.is-open {
  max-height: 100px;
  opacity: 1;
  margin-top: 8px;
  padding: 9px 12px;
}
.forecast-what-popup strong {
  color: var(--color-text);
  font-weight: 600;
  font-size: 12px;
}
.forecast-what-popup em {
  color: #7c3aed;
  font-style: normal;
  font-weight: 500;
}

/* ── 예측 면책 푸터 항목 ── */
.footer-forecast-note {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--color-gray-200);
  color: var(--color-text-muted);
  font-size: 11.5px;
  line-height: 1.55;
  position: relative;
}

/* 물음표 버튼 */
.forecast-method-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--color-gray-200);
  background: var(--color-gray-50);
  color: var(--color-text-muted);
  font-size: 11px;
  font-family: var(--font-base);
  cursor: pointer;
  vertical-align: middle;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.forecast-method-btn:hover,
.forecast-method-btn[aria-expanded="true"] {
  background: var(--color-primary-lt);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.forecast-method-btn i {
  font-size: 10px;
}

/* 툴팁 팝업 */
.forecast-method-tooltip {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .28s ease, opacity .22s ease, margin .22s ease;
  margin-top: 0;

  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 11.5px;
  color: var(--color-text-sub);
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
.forecast-method-tooltip.is-open {
  max-height: 120px;
  opacity: 1;
  margin-top: 8px;
  padding: 10px 12px;
}
.forecast-method-tooltip strong {
  color: var(--color-text);
  font-weight: 600;
}
.forecast-method-tooltip em {
  color: var(--color-primary);
  font-style: normal;
  font-weight: 500;
}
