:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --line: #dfe3e8;
  --brand: #1f5eff;
  --brand-ink: #ffffff;
  --accent-bg: #eef3ff;
  --warn-bg: #fff6e0;
  --warn-ink: #7a5200;
  --ok-ink: #0b6b3a;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1f25;
    --text: #e8ebef;
    --muted: #a3acb8;
    --line: #2d343d;
    --brand: #6f9bff;
    --brand-ink: #0b1020;
    --accent-bg: #1c2740;
    --warn-bg: #3a2f12;
    --warn-ink: #ffd88a;
    --ok-ink: #7ee2a8;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px; line-height: 1.65; word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--brand); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 52px; gap: 12px; }
.brand { font-weight: 800; text-decoration: none; color: var(--text); font-size: 17px; }
.nav-toggle summary { cursor: pointer; list-style: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.nav-toggle summary::-webkit-details-marker { display: none; }
.nav { position: absolute; right: 16px; left: 16px; top: 52px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; box-shadow: 0 8px 24px rgba(0,0,0,.08); max-height: calc(100vh - 64px); overflow-y: auto; }
.nav a { padding: 10px 10px; font-size: 15px; border-radius: 8px; text-decoration: none; color: var(--text); }
.nav a[aria-current="page"], .nav a:hover { background: var(--accent-bg); color: var(--brand); }
/* 계산기가 16개라 화면 너비와 관계없이 '메뉴' 버튼으로 연다. 760px 이상에서는 2열 드롭다운. */
@media (min-width: 760px) {
  .nav-toggle:not([open]) > .nav { display: none; }
  .nav-toggle[open] > .nav { display: grid; grid-template-columns: 1fr 1fr; position: absolute; left: auto; right: 16px; width: 440px; top: 52px; }
  .nav a { padding: 8px 10px; font-size: 14.5px; }
  .header-inner { max-width: 1000px; }
}

h1 { font-size: 26px; line-height: 1.3; margin: 18px 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 32px 0 10px; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 20px 0 8px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-top: 14px; }
.breadcrumb a { color: var(--muted); }
.lead { color: var(--muted); margin-top: 6px; }
.badges { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-bg); color: var(--brand); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.field { margin-bottom: 14px; }
.field > label, .field > .label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.field .hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } .row-3 { grid-template-columns: 1fr 1fr 1fr; } }
input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 44px; }
.input-unit .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { flex: 1 1 auto; text-align: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 15px; background: var(--bg); min-height: 44px; display: flex; align-items: center; justify-content: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--brand); font-weight: 700; }
.seg label:has(input:checked) { border-color: var(--brand); background: var(--accent-bg); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; }
.check input { width: 20px; height: 20px; margin-top: 3px; }
.actions { display: flex; gap: 8px; margin-top: 6px; }
.btn { font: inherit; font-weight: 700; border: 0; background: var(--brand); color: var(--brand-ink); padding: 12px 18px; border-radius: 10px; cursor: pointer; flex: 1; min-height: 48px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); flex: 0 0 auto; }
.error { color: #c62828; font-size: 14px; margin: 6px 0 0; }

.result h2 { margin-top: 0; font-size: 18px; }
.big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0; }
.big small { font-size: 16px; font-weight: 600; color: var(--muted); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.kpi { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 18px; font-weight: 800; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 800; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.schedule th, .schedule td { padding: 6px 4px; font-size: 12.5px; white-space: nowrap; }
.basis { margin-top: 12px; background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.basis summary { cursor: pointer; font-weight: 700; }
.basis ol, .basis ul { padding-left: 20px; margin: 8px 0 0; }
.basis li { margin-bottom: 4px; }
.note { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.ok { color: var(--ok-ink); }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.formula { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 12px; font-size: 15px; overflow-x: auto; }
.content ul, .content ol { padding-left: 22px; }
.content li { margin-bottom: 4px; }
.faq-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq-item summary { cursor: pointer; font-weight: 700; }
.faq-a { padding-top: 6px; color: var(--text); }
.disclaimer { margin-top: 28px; font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.related { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0 !important; }
.related a { display: inline-block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; background: var(--surface); }
.home-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 16px 0; }
@media (min-width: 560px) { .home-grid { grid-template-columns: 1fr 1fr; } }
.tool { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tool:hover { border-color: var(--brand); }
.tool strong { display: block; font-size: 17px; }
.tool span { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
.conf { font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.conf-확인 { background: #e3f6ea; color: #0b6b3a; }
.conf-보도 { background: #eef3ff; color: #1f4fd1; }
.conf-미확인 { background: var(--warn-bg); color: var(--warn-ink); }
@media (prefers-color-scheme: dark) { .conf-확인 { background: #12351f; color: #7ee2a8; } .conf-보도 { background: #1c2740; color: #9bb8ff; } }

.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 18px 0 28px; font-size: 13.5px; background: var(--surface); }
.footer-links a { color: var(--text); }

/* 광고 자리: 승인 전에는 숨김, 승인 후(html.ads-on) 높이를 미리 확보해 CLS 방지 */
.ad-slot { display: none; }
.ads-on .ad-slot { display: block; min-height: 280px; margin: 20px 0; }
@media print { .site-header, .site-footer, .ad-slot, .actions { display: none !important; } }

/* 계산 예시 (빌드 시 계산 엔진으로 채운 숫자) */
.example { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.example h3 { margin: 0 0 8px; font-size: 16.5px; }
.example ul { margin: 0; }
.example p { margin: 6px 0; }
.exv { white-space: nowrap; }

/* 해설 글 (/guides/) */
.guide-meta { margin: 0 0 8px; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 16px 0; }
.toc .toc-title { font-size: 15px; margin: 0 0 6px; }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 4px 0; }
.toc a { text-decoration: none; }
.guide-body h2, #related-tools, #sources { scroll-margin-top: 72px; }
.guide-body .example h3 { overflow-wrap: anywhere; }
.guide-body .formula { overflow-wrap: anywhere; }
.lawref { white-space: normal; }
.tag-unverified { display: inline-block; background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; padding: 0 6px; font-size: 0.9em; font-weight: 600; }
.nav .nav-guides { font-weight: 700; }
.exv[data-fmt="raw"] { white-space: normal; }
