/* =========================================================
   디자인 토큰 — 신뢰감 있는 블루그린 + 귀여운 민트(콩닥이)
   ========================================================= */
:root {
  --primary: #0B6E8A;        /* 흰 글자 대비 5.9:1 */
  --primary-hover: #095A71;
  --primary-soft: #E7F3F7;
  --accent: #047857;         /* 건강 그린 */
  --accent-soft: #E6F4EE;

  --bg: #F7FAFB;
  --card: #FFFFFF;
  --fg: #12303B;
  --fg-muted: #4A5F68;       /* 흰 배경 대비 6.6:1 */
  --border: #D5E3E8;
  --danger: #B42318;
  --danger-soft: #FEF2F1;

  /* 콩닥이 */
  --buddy: #3FA796;
  --buddy-strong: #1F7A6B;   /* 흰 글자 대비 5.2:1 */
  --buddy-soft: #EAF8F5;
  --buddy-pink: #FF8A95;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 1px 2px rgba(18, 48, 59, .06), 0 4px 16px rgba(18, 48, 59, .06);
  --shadow-lg: 0 12px 40px rgba(18, 48, 59, .18);

  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* 글자 크기 단계 (4050 가독성) — 기본 18px */
html { font-size: 112.5%; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html[data-fs="2"] { font-size: 125%; }
html[data-fs="3"] { font-size: 137.5%; }

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.7;
  word-break: keep-all;          /* 한국어 단어 단위 줄바꿈 */
  overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.35; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: var(--primary); }
img, svg { display: block; }
button { font: inherit; cursor: pointer; }

.ic { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--fg); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 6px; }

/* ===== 응급 띠 ===== */
.emergency-bar { background: var(--danger-soft); color: var(--danger); border-bottom: 1px solid #F6D3D0; font-size: .85rem; }
.emergency-inner { display: flex; align-items: center; gap: 10px; padding-top: 8px; padding-bottom: 8px; }
.emergency-bar a { color: var(--danger); }

/* ===== 헤더 ===== */
.site-header { position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 28px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: #fff; }
.brand-name { font-weight: 800; font-size: 1.15rem; }
/* 사이트 이름 빈칸 */
.brand-name.is-empty { display: inline-block; min-width: 7.5em; height: 1.6em; border: 2px dashed var(--border); border-radius: 8px; }

.main-nav { display: flex; gap: 4px; margin-right: auto; }
.main-nav a { padding: 10px 14px; border-radius: var(--radius-sm); text-decoration: none; color: var(--fg); font-weight: 600; transition: background .2s var(--ease), color .2s var(--ease); }
.main-nav a:hover { background: var(--primary-soft); color: var(--primary); }

.header-tools { display: flex; align-items: center; gap: 12px; }
.font-size { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.font-size-label { font-size: .75rem; color: var(--fg-muted); padding: 0 6px 0 8px; }
.font-size button { width: 44px; height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--fg); font-weight: 700; transition: background .2s var(--ease); }
.font-size button[data-fs="1"] { font-size: 15px; }
.font-size button[data-fs="2"] { font-size: 18px; }
.font-size button[data-fs="3"] { font-size: 21px; }
.font-size button:hover { background: var(--primary-soft); }
.font-size button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.menu-btn { display: none; width: 48px; height: 48px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--fg); place-items: center; }

/* ===== 버튼 ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 24px; border: 0; border-radius: 14px; font-weight: 700; font-size: 1rem; text-decoration: none; transition: background .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-buddy { background: var(--buddy-strong); color: #fff; border-radius: 999px; box-shadow: 0 4px 14px rgba(31,122,107,.28); }
.btn-buddy:hover { background: #18665A; }

/* ===== 히어로 ===== */
.hero { background: linear-gradient(180deg, #fff 0%, var(--primary-soft) 100%); border-bottom: 1px solid var(--border); }
/* 모든 화면: 채팅창이 맨 위, 그 아래 제목·검색 (한 줄로 쌓기) */
.hero-grid { display: grid; grid-template-columns: 1fr; gap: 40px; padding-top: 28px; padding-bottom: 56px; }
.hero-copy { max-width: 760px; }
.hero-grid .msg-col { max-width: min(calc(100% - 44px), 760px); }
.hero-grid .msg-user .msg-body { max-width: min(85%, 640px); }
.hero-grid .chat { order: -1; }
.hero-grid .search { max-width: none; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 6px 14px; border-radius: 999px; margin-bottom: 20px; }
.hero h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); font-weight: 800; margin-bottom: 18px; }
.lead { font-size: 1.05rem; color: var(--fg-muted); margin-bottom: 32px; }

.search { position: relative; display: flex; gap: 8px; background: #fff; padding: 8px; border: 2px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); max-width: 600px; transition: border-color .2s var(--ease); }
.search:focus-within { border-color: var(--primary); }
.search-ic { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--fg-muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 1rem; padding: 0 12px 0 46px; background: transparent; color: var(--fg); }
.search input::placeholder { color: #6B7F87; }
.popular { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; font-size: .85rem; }
.popular span { color: var(--fg-muted); margin-right: 4px; }
.popular a { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--border); color: var(--fg); text-decoration: none; }
.popular a:hover { border-color: var(--primary); color: var(--primary); }

.hero-buddy { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 24px 28px; box-shadow: var(--shadow); }
.bubble { position: relative; background: var(--buddy-soft); color: var(--fg); padding: 14px 18px; border-radius: 18px; text-align: center; font-size: .95rem; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); border: 10px solid transparent; border-top-color: var(--buddy-soft); border-bottom: 0; }
.kd-hero { width: 150px; height: 150px; animation: bob 3.2s ease-in-out infinite; }

/* ===== 신뢰 ===== */
.trust { background: #fff; border-bottom: 1px solid var(--border); }
.trust-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding-top: 32px; padding-bottom: 32px; }
.trust-item { display: flex; gap: 14px; align-items: flex-start; }
.trust-ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.trust-item h2 { font-size: 1rem; margin-bottom: 4px; }
.trust-item p { font-size: .9rem; color: var(--fg-muted); }

/* ===== 섹션 공통 ===== */
.section { padding: 72px 0; }
.section-tint { background: #fff; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { margin-bottom: 32px; }
.section-head.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 800; margin-bottom: 8px; }
.section-head p { color: var(--fg-muted); }
.link-more { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; text-decoration: none; padding: 10px 4px; }

/* ===== 주제 카드 ===== */
.topic-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.topic { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 24px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--fg); transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease); }
.topic:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.topic strong { font-size: 1.1rem; margin-top: 10px; }
.topic span:last-child { color: var(--fg-muted); font-size: .9rem; }
.topic-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; }
.topic-ic .ic { width: 26px; height: 26px; }
.t1 { background: #FDECEC; color: #B4232E; }
.t2 { background: #E7F0FD; color: #1D4F9C; }
.t3 { background: #FFF3E0; color: #9A4A00; }
.t4 { background: #F6ECFA; color: #7A2E95; }
.t5 { background: #EEF2F4; color: #3D5560; }
.t6 { background: #E6F4EE; color: #0B6B49; }
.t7 { background: #ECEFFD; color: #3442A0; }
.t8 { background: #E5F5F8; color: #0B6E8A; }

/* ===== 탭 / 검진 ===== */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 16px; }
.tabs button { min-width: 104px; min-height: 48px; border: 0; border-radius: 10px; background: transparent; color: var(--fg-muted); font-weight: 700; transition: background .2s var(--ease), color .2s var(--ease); }
.tabs button[aria-selected="true"] { background: var(--primary); color: #fff; }
.checkup-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 24px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .ic { color: var(--accent); margin-top: 4px; }
.checklist strong { display: block; font-size: 1.05rem; }
.checklist span { color: var(--fg-muted); font-size: .95rem; }
.source { margin-top: 14px; font-size: .8rem; color: var(--fg-muted); }

/* ===== 칼럼 ===== */
.article-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.article { display: flex; flex-direction: column; gap: 10px; padding: 26px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); transition: box-shadow .2s var(--ease); }
.article:hover { box-shadow: var(--shadow); }
.tag { align-self: flex-start; font-size: .8rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 4px 10px; border-radius: 8px; }
.article h3 { font-size: 1.15rem; }
.article h3 a { color: var(--fg); text-decoration: none; }
.article h3 a:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 4px; }
.article p { color: var(--fg-muted); font-size: .95rem; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--fg-muted); padding-top: 12px; border-top: 1px solid var(--border); }
.meta span:first-child { color: var(--accent); font-weight: 700; }

/* ===== 콩닥이 소개 ===== */
.buddy-card { display: grid; grid-template-columns: 260px 1fr; gap: 40px; align-items: center; padding: 48px; border-radius: var(--radius-lg); background: var(--buddy-soft); border: 1px solid #CDEEE7; }
.kd-promo { width: 220px; height: 220px; margin: 0 auto; animation: bob 3.2s ease-in-out infinite; }
.buddy-eyebrow { color: var(--buddy-strong); background: #fff; }
.buddy-copy h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 800; margin-bottom: 12px; }
.buddy-copy > p { color: var(--fg-muted); margin-bottom: 18px; }
.buddy-points { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 8px; }
.buddy-points li { display: flex; gap: 10px; align-items: flex-start; }
.buddy-points .ic { color: var(--buddy-strong); margin-top: 4px; }

/* ===== 푸터 ===== */
.site-footer { background: #12303B; color: #C9D8DD; padding: 48px 0 40px; font-size: .9rem; }
.footer-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.15); margin-bottom: 20px; }
.brand-name-footer { color: #fff; }
.brand-name-footer.is-empty { border-color: rgba(255,255,255,.3); }
.footer-top nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer-top a { color: #E3EDF0; text-decoration: none; padding: 6px 0; }
.footer-top a:hover { text-decoration: underline; }
.disclaimer { margin-bottom: 12px; max-width: 820px; }
.copy { color: #9DB3BA; font-size: .8rem; }

/* =========================================================
   콩닥이 챗봇
   ========================================================= */
.chat { width: 100%; height: 580px; display: flex; flex-direction: column; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 2px solid #CDEEE7; overflow: hidden; scroll-margin-top: 96px; }

.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; background: var(--buddy-soft); border-bottom: 1px solid #CDEEE7; }
.kd-head { width: 52px; height: 52px; background: #fff; border-radius: 50%; padding: 3px; }
.chat-title-wrap { flex: 1; }
.chat-head h2 { font-size: 1.1rem; }
.chat-head p { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--fg-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22A06B; }
.chat-close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--fg); }
.chat-close:hover { background: rgba(0,0,0,.06); }

.chat-notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 16px; font-size: .78rem; color: #7A4B00; background: #FFF8E6; border-bottom: 1px solid #F5E3B5; line-height: 1.55; }
.chat-notice .ic { width: 1.1em; height: 1.1em; margin-top: 2px; }
.chat-notice a { color: #7A4B00; font-weight: 700; }

.chat-log { position: relative; flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; background: #FBFDFD; overscroll-behavior: contain; }
.msg { display: flex; gap: 8px; max-width: 100%; animation: rise .25s var(--ease); }
.msg-bot .avatar { width: 36px; height: 36px; flex-shrink: 0; background: var(--buddy-soft); border-radius: 50%; padding: 2px; }
.msg-body { padding: 12px 15px; border-radius: 18px; font-size: .95rem; line-height: 1.65; white-space: pre-wrap; }
.msg-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: calc(100% - 44px); }
.msg-bot .msg-body { background: #fff; border: 1px solid var(--border); border-top-left-radius: 6px; }

/* 상품 카드 */
.products { display: grid; gap: 8px; }
.product { display: flex; align-items: center; gap: 12px; padding: 12px; background: #fff; border: 1px solid #CDEEE7; border-radius: 14px; }
.product-ic { display: grid; place-items: center; width: 64px; height: 64px; flex-shrink: 0; border-radius: 12px; background: var(--buddy-soft); color: var(--buddy-strong); overflow: hidden; }
.product-ic.has-img { background: #fff; border: 1px solid var(--border); }
.product-ic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.45; }
.product-info strong { font-size: .95rem; }
.product-info span { font-size: .82rem; color: var(--fg-muted); }
.product-go { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; flex-shrink: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem; text-decoration: none; white-space: nowrap; transition: background .2s var(--ease); }
.product-go:hover { background: #036148; }
.ad-note { font-size: .75rem; color: var(--fg-muted); padding-left: 4px; }
.msg-user { justify-content: flex-end; }
.msg-user .msg-body { background: var(--primary); color: #fff; border-top-right-radius: 6px; max-width: 85%; }
.msg-error .msg-body { background: var(--danger-soft); border-color: #F6D3D0; color: var(--danger); }

.typing { display: inline-flex; gap: 5px; padding: 16px 18px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--buddy); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; border-top: 1px solid var(--border); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips[hidden] { display: none; }
.chip { flex-shrink: 0; min-height: 40px; padding: 0 14px; border: 1px solid #BFE6DE; border-radius: 999px; background: var(--buddy-soft); color: var(--buddy-strong); font-size: .82rem; font-weight: 600; transition: background .2s var(--ease); }
.chip:hover { background: #D6F1EB; }

.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: #fff; }
.chat-form textarea { flex: 1; resize: none; min-height: 48px; max-height: 140px; padding: 12px 14px; border: 2px solid var(--border); border-radius: 14px; font: inherit; font-size: .95rem; line-height: 1.5; color: var(--fg); outline: 0; transition: border-color .2s var(--ease); }
.chat-form textarea:focus { border-color: var(--buddy-strong); }
.send { display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 14px; background: var(--buddy-strong); color: #fff; flex-shrink: 0; transition: background .2s var(--ease); }
.send:hover { background: #18665A; }
.send:disabled { background: #9DB3BA; cursor: not-allowed; }

/* ===== 애니메이션 ===== */
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%,80%,100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.kd-eyes { transform-origin: 60px 72px; animation: eye 4.5s infinite; }
@keyframes eye { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

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

/* ===== 반응형 ===== */
@media (max-width: 1024px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .article-grid { grid-template-columns: 1fr 1fr; }
  .font-size-label { display: none; }
}
@media (max-width: 860px) {
  .header-inner { gap: 12px; }
  .menu-btn { display: grid; }
  .main-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; background: #fff; border-bottom: 1px solid var(--border); padding: 8px 16px 16px; box-shadow: var(--shadow); }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 14px; }
  .header-tools { margin-left: auto; }
  .hero-grid { padding-top: 20px; padding-bottom: 48px; gap: 32px; }
  .br-desk { display: none; }
  .trust-grid { grid-template-columns: 1fr; gap: 18px; }
  .article-grid { grid-template-columns: 1fr; }
  .buddy-card { grid-template-columns: 1fr; padding: 32px 24px; text-align: left; gap: 16px; }
  .kd-promo { width: 160px; height: 160px; }
  .section { padding: 56px 0; }
}
@media (max-width: 520px) {
  .container { padding: 0 16px; }
  .topic-grid { gap: 12px; }
  .topic { padding: 18px; }
  .font-size button { width: 40px; height: 40px; }
  .brand-name.is-empty { min-width: 4.5em; }
  .search { flex-wrap: wrap; }
  .search input { min-height: 48px; }
  .search .btn { width: 100%; }
  .search-ic { top: 32px; }
  .chat { height: 520px; }
}
