/* Formula X 인사이트 — 사이트 자체 중립 토큰. 브랜드 토큰 사용 금지.
 * 팔레트: 잉크·회색 + 포인트 1색(남색 계열 --accent).
 * 텍스트 대비는 test/design.test.cjs 가 라이트/다크 모두 강제한다. */
:root {
  --bg: #ffffff;
  --surface: #f4f6f8;
  --surface-2: #e9edf1;
  --fg: #1a1d21;
  --muted: #5b6470;
  --border: #dfe4ea;
  --accent: #0f4c81;
  --link: #0f4c81;
  --link-visited: #4a3f7a;
  --btn-bg: #0f4c81;
  --btn-fg: #ffffff;
  --btn-secondary-bg: #ffffff;
  --btn-secondary-fg: #1a1d21;
  --btn-secondary-border: #6b7480;
  --answer-bg: #eef4f8;
  --answer-border: #0f4c81;
  --banner-bg: #5c4a00;
  --banner-fg: #ffffff;
  --focus: #0f4c81;
  --ok: #1c6b3a;
  --err: #b3261e;
  --radius: 8px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --surface: #1b1f24;
    --surface-2: #262c33;
    --fg: #eceff3;
    --muted: #a7b0bc;
    --border: #2c333b;
    --accent: #8fc3e8;
    --link: #8fc3e8;
    --link-visited: #c0aee0;
    --btn-bg: #e8edf2;
    --btn-fg: #101418;
    --btn-secondary-bg: #1b1f24;
    --btn-secondary-fg: #eceff3;
    --btn-secondary-border: #6b7480;
    --answer-bg: #1a2833;
    --answer-border: #8fc3e8;
    --banner-bg: #967e00;
    --banner-fg: #101418;
    --focus: #8fc3e8;
    --ok: #7ed09a;
    --err: #f2a49e;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  line-height: 1.7;
  font-size: 16px;
}

img, svg, video, table { max-width: 100%; }
img { height: auto; }

a { color: var(--link); }
a:visited { color: var(--link-visited); }

/* 긴 URL·제목이 360px 화면을 밀지 않게 */
p, li, .card a, .sources a, .toc a, .breadcrumb a { overflow-wrap: break-word; }
.sources a, .card a { overflow-wrap: anywhere; }

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

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand { font-weight: 800; font-size: 18px; color: var(--fg); text-decoration: none; }
.brand:visited { color: var(--fg); }
.tagline { color: var(--muted); font-size: 13px; margin: 0; }

.site-nav { display: flex; flex-wrap: wrap; gap: 4px 4px; margin-left: auto; }
.site-nav a {
  color: var(--fg);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 15px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}
.site-nav a:visited { color: var(--fg); }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] { font-weight: 700; text-decoration: underline; }
.site-nav a.nav-cta {
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
}
.site-nav a.nav-cta:visited { color: var(--btn-fg); }
.site-nav a.nav-cta:hover { background: var(--btn-bg); }
.site-nav a.nav-cta[aria-current="page"] { text-decoration: underline; }

/* 360~430px: 내비는 접지 않고 한 줄 가로 스크롤(페이지 자체 스크롤 0) */
@media (max-width: 640px) {
  .site-header .wrap { flex-direction: column; align-items: stretch; }
  .brand-block { width: 100%; }
  .site-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-left: 0;
    max-width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
}

.draft-banner {
  background: var(--banner-bg);
  color: var(--banner-fg);
  text-align: center;
  font-weight: 700;
  padding: 8px 16px;
  font-size: 14px;
}

main { padding: 24px 0 48px; }

h1 { font-size: 28px; line-height: 1.4; margin: 0 0 12px; }
h2 { font-size: 22px; line-height: 1.45; margin: 36px 0 12px; }
h3 { font-size: 18px; margin: 28px 0 8px; }
p { margin: 0 0 14px; }
ul, ol { margin: 0 0 14px; padding-left: 24px; }
li { margin-bottom: 6px; }

.answer {
  background: var(--answer-bg);
  border: 1px solid var(--answer-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 20px;
}
.answer-tag {
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.table-scroll { overflow-x: auto; margin: 0 0 16px; }
.table-scroll table { border-collapse: collapse; width: 100%; font-size: 15px; }
.table-scroll th, .table-scroll td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}
.table-scroll thead th { background: var(--surface); }

blockquote {
  margin: 0 0 14px;
  padding: 8px 14px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
}
pre {
  background: var(--surface);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 14px;
}
pre code { background: none; padding: 0; }

.meta { color: var(--muted); font-size: 14px; }
.meta-list { list-style: none; padding: 0; }
.meta-list li { margin-bottom: 4px; }

.card-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.card-list > * { min-width: 0; }
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg);
}
.card h2, .card h3 { margin: 0 0 6px; font-size: 18px; }
.card p { margin: 0 0 6px; }
.card p:last-child { margin-bottom: 0; }

/* 홈 첫 화면: 한 줄 가치 제안 + 두 진입 버튼 */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin: 0 0 32px;
}
.hero h1 { margin-bottom: 8px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0 0; }

/* 대표 질문 바로가기: 질문형 링크 목록 */
.question-list { list-style: none; padding: 0; margin: 0 0 8px; }
.question-list li { margin: 0; border-bottom: 1px solid var(--border); }
.question-list li:first-child { border-top: 1px solid var(--border); }
.question-list a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 4px;
  font-weight: 600;
  text-decoration: none;
}
.question-list a:hover { text-decoration: underline; }

/* 넓은 화면 그리드는 카드에만. 본문은 한 줄 흐름 유지 */
@media (min-width: 600px) {
  .card-list { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 700px) {
  .space-grid { grid-template-columns: repeat(3, 1fr); }
}

.stat p strong { font-size: 22px; }
.stat .meta { margin-bottom: 0; }

/* 글 목차(H2 3개 이상일 때만 출력) */
.toc {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 20px;
}
.toc p { margin: 0 0 8px; }
.toc ol { margin: 0; padding-left: 22px; }
.toc li { margin-bottom: 4px; }

/* 관련 도구 카드 */
.tool-card { background: var(--surface); margin: 24px 0; }
.tool-card p:last-child { margin-bottom: 0; }

/* 저자 상자(글 하단·출처 위)와 저자 소개 카드: 기존 토큰만 사용, 새 색 없음 */
.author-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
  margin: 24px 0;
}
.author-box p { margin: 0 0 8px; }
.author-box p:last-child { margin-bottom: 0; }
.author-box a { overflow-wrap: anywhere; }
.author-profile { margin: 0 0 16px; }

.btn {
  display: inline-block;
  background: var(--btn-bg);
  color: var(--btn-fg);
  text-decoration: none;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
}
.btn:visited { color: var(--btn-fg); }
.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-fg);
  border-color: var(--btn-secondary-border);
}
.btn-secondary:visited { color: var(--btn-secondary-fg); }

.cta-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  margin: 32px 0;
  text-align: center;
}
.cta-box p { margin: 0 0 12px; }

.sources { font-size: 15px; }
.sources li { margin-bottom: 12px; }
.sources li::marker { color: var(--muted); }
.sources a { font-weight: 600; }

.faq h3 { font-size: 17px; }
.faq-item { border-bottom: 1px solid var(--border); padding: 10px 0; }

.breadcrumb { font-size: 14px; color: var(--muted); margin: 0 0 16px; }
.breadcrumb a { color: var(--muted); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 40px;
  color: var(--muted);
  font-size: 14px;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; }

form.lead-form { display: grid; gap: 14px; margin: 20px 0; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; }
.field .req { color: var(--err); font-weight: 700; }
.field input[type="text"],
.field input[type="tel"],
.field select,
.field textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--btn-secondary-border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}
.field textarea { min-height: 120px; resize: vertical; }
.checks { display: grid; gap: 8px; }
.checks label { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; }

/* 지점 수·관심사는 칩 형태. input은 화면에 감추되 포커스·선택은 유지 */
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
fieldset.field legend .opt { font-weight: 400; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-block; }
.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--btn-secondary-border);
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  background: var(--bg);
  color: var(--fg);
}
.chip input:checked + span {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-color: transparent;
  font-weight: 700;
}
.chip input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.form-actions { margin: 4px 0 0; }
.form-actions .btn { min-width: 200px; text-align: center; }
.consent-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  font-size: 14px;
}
.hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.form-msg { padding: 12px 14px; border-radius: var(--radius); font-weight: 700; }
.form-msg.ok { background: var(--answer-bg); color: var(--fg); }
.form-msg.err { color: var(--err); border: 1px solid var(--err); }

.tool-grid { display: grid; gap: 12px; margin: 16px 0; }
.tool-field { display: grid; gap: 6px; }
.tool-field label { font-weight: 700; }
.tool-field input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--btn-secondary-border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}
.tool-result {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  margin: 16px 0;
}
.tool-result dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.tool-result dt { color: var(--muted); }
.tool-result dd { margin: 0; font-weight: 700; }

/* 도구 결과 아래 CTA 강조: 결과와 붙은 띠 형태 */
.tool-cta {
  border: 1px solid var(--answer-border);
  border-radius: var(--radius);
  background: var(--answer-bg);
  padding: 16px 18px;
  margin: 0 0 16px;
}
.tool-cta p { margin: 0 0 10px; }
.tool-cta p:last-child { margin-bottom: 0; }
.tool-cta .btn { font-size: 17px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--btn-bg); color: var(--btn-fg); padding: 8px 12px; z-index: 10; }

@media (max-width: 480px) {
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .tool-result dl { grid-template-columns: 1fr; }
  .hero { padding: 20px 16px; }
  .hero-actions .btn { flex: 1 1 auto; text-align: center; }
  .form-actions .btn { width: 100%; }
}
