:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --text: #1a1f2b;
  --muted: #5b6475;
  --border: #e2e6ec;
  --accent: #1f6feb;
  --accent-strong: #1554b8;
  --accent-soft: #e8f0fe;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --warn: #8a5a00;
  --warn-soft: #fff5e0;
  --info: #24527a;
  --info-soft: #eaf3fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1f2430;
    --text: #e8ebf1;
    --muted: #a0a8b8;
    --border: #2b3240;
    --accent: #6ea8ff;
    --accent-strong: #9cc2ff;
    --accent-soft: #1b2a44;
    --danger: #ff8a80;
    --danger-soft: #3a1c1c;
    --warn: #ffcc66;
    --warn-soft: #362a12;
    --info: #9ccaf2;
    --info-soft: #172838;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
img, svg { max-width: 100%; }
.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Header / Footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); text-decoration: none; font-size: 17px; white-space: nowrap; }
.logo svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
@media (max-width: 420px) {
  .logo span { display: none; }
  .nav a { padding: 8px 8px; font-size: 14px; }
}
.site-footer { margin-top: 48px; padding: 28px 0 40px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 0 0 12px; list-style: none; }
.footer-links a { color: var(--muted); }
.site-footer p { margin: 4px 0; }

/* Typography */
main { padding-top: 20px; }
h1 { font-size: 24px; line-height: 1.35; margin: 8px 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 21px; line-height: 1.4; margin: 40px 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 24px 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; }
@media (min-width: 768px) { h1 { font-size: 30px; } h2 { font-size: 23px; } }
.article p, .article li { margin: 0 0 12px; }
.article ul, .article ol { padding-left: 22px; }
code { background: var(--surface-2); border-radius: 6px; padding: 1px 6px; font-size: .92em; }
.formula-box { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; font-weight: 700; margin: 12px 0 16px; }
.note { font-size: 14px; color: var(--muted); }
.breadcrumb { font-size: 14px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; }
@media (min-width: 768px) { .card { padding: 24px; } }

/* Form */
.calc-form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > label, .field > legend { font-weight: 700; font-size: 15px; padding: 0; }
.field-hint { font-size: 13px; color: var(--muted); margin: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type="number"], select {
  width: 100%; height: 48px; padding: 0 12px; font: inherit; font-size: 17px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type="number"]:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group { display: flex; gap: 8px; }
.with-unit { position: relative; }
.input-group .with-unit { flex: 1; }
.with-unit input { padding-right: 36px; }
.with-unit .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 48px; padding: 0 14px;
  font: inherit; font-size: 15px; font-weight: 700; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); width: 100%; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary, .btn-primary:hover { color: #0f1218; } }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { text-align: center; padding: 10px 6px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 15px; color: var(--muted); line-height: 1.3; }
.segmented input:checked + label { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.segmented input:focus-visible + label { outline: 3px solid var(--accent); }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-weight: 600; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }

details.options { border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; }
details.options summary { cursor: pointer; padding: 12px 0; font-weight: 700; }
details.options[open] { padding-bottom: 14px; }
details.options .field { margin-top: 4px; }

/* Results */
.results { margin-top: 20px; display: grid; gap: 16px; }
.hero { background: linear-gradient(135deg, var(--accent) 0%, #5a4bd6 100%); color: #fff; border: 0; }
.hero .label { font-size: 15px; opacity: .9; margin: 0; }
.hero .big { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin: 2px 0 8px; }
.hero .net { margin: 0; font-size: 16px; }
.hero .net strong { font-size: 20px; }
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(135deg, #1d4ea8 0%, #3f2fa8 100%); } }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.kpi { background: rgba(255, 255, 255, .15); border-radius: 10px; padding: 10px 8px; text-align: center; }
.kpi .k { font-size: 12px; opacity: .9; display: block; line-height: 1.4; }
.kpi .v { font-size: 16px; font-weight: 800; display: block; line-height: 1.4; }
@media (min-width: 768px) { .kpi .v { font-size: 19px; } .kpi .k { font-size: 13px; } }

.alerts { display: grid; gap: 8px; }
.alerts:empty { display: none; }
.alert { border-radius: 10px; padding: 10px 14px; font-size: 14px; line-height: 1.6; }
.alert-danger { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--info-soft); color: var(--info); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
thead th { font-size: 13px; color: var(--muted); font-weight: 700; background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.breakdown th { font-weight: 600; }
.breakdown .formula { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.breakdown .minus td.num { color: var(--danger); }
.breakdown .subtotal th, .breakdown .subtotal td { background: var(--surface-2); font-weight: 800; }
.breakdown .total th, .breakdown .total td { font-weight: 800; font-size: 17px; border-bottom: 0; color: var(--accent); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); vertical-align: 2px; margin-left: 4px; }
.result-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.toast { font-size: 14px; color: var(--accent); }
.rates-asof { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* Content */
.article table { margin: 8px 0 16px; }
.example-list, .article .example-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.example-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0; }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 700; list-style-position: outside; }
.faq details > div { padding: 0 0 14px; }
.faq details > div p:last-child { margin-bottom: 0; }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 420px; height: 54px; margin: 28px auto;
  font-size: 16px; text-decoration: none; border-radius: 12px;
  box-shadow: 0 4px 14px rgba(31, 111, 235, .28);
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(31, 111, 235, .36); }
.cta:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(31, 111, 235, .28); }
@media (prefers-color-scheme: dark) { .cta, .cta:hover, .cta:active { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .cta { transition: none; } .cta:hover { transform: none; } }
.disclaimer { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: var(--muted); margin-top: 32px; }

/* Ads: 빈 슬롯은 레이아웃을 밀지 않음 */
.ad-slot { min-height: 0; margin: 0; }
.ad-slot:empty { display: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 좌우 사이드 광고 (PC 전용)
   본문(760px) 바깥 여백에 고정. 화면이 좁거나 낮으면 숨김.
   1140px 이상: 160×600 / 1420px 이상: 300×600 */
.ad-rail { display: none; }
@media (min-width: 1140px) and (min-height: 680px) {
  .ad-rail:not(:empty) {
    display: block; position: fixed; top: 80px; z-index: 1;
    width: 160px; max-height: calc(100vh - 100px); overflow: hidden;
  }
  .ad-rail-left { left: calc(50% - 380px - 24px - 160px); }
  .ad-rail-right { right: calc(50% - 380px - 24px - 160px); }
}
@media (min-width: 1420px) and (min-height: 680px) {
  .ad-rail:not(:empty) { width: 300px; }
  .ad-rail-left { left: calc(50% - 380px - 24px - 300px); }
  .ad-rail-right { right: calc(50% - 380px - 24px - 300px); }
}
/* 광고가 채워지지 않은 경우 빈 공간 제거 */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }

/* ===== 가독성: 여백·구분 강화 ===== */
main { padding-top: 24px; }
.breadcrumb { margin-bottom: 12px; }
.lead { margin-bottom: 28px; }
.article { line-height: 1.8; }
.article p { margin: 0 0 18px; }
.article ul, .article ol { margin: 0 0 22px; }
.article li { margin: 0 0 10px; }
.article li:last-child { margin-bottom: 0; }

/* 섹션 제목: 위 구분선 + 넉넉한 간격 */
.article h2 {
  margin: 48px 0 18px; padding-top: 40px;
  border-top: 1px solid var(--border);
}
.article h3 { margin: 32px 0 12px; }
.article > h1 + .lead + h2, .article > .lead + h2 { margin-top: 0; padding-top: 0; border-top: 0; }

/* 표: 카드처럼 테두리·배경 */
.article .table-wrap, .card .table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin: 18px 0 26px;
}
.card .table-wrap { margin: 8px 0 0; }
.article table { margin: 0; }
.article th, .article td { padding: 13px 14px; line-height: 1.6; }
.article thead th { padding-top: 11px; padding-bottom: 11px; }
.article tbody tr:last-child th, .article tbody tr:last-child td { border-bottom: 0; }
.breakdown th, .breakdown td { padding: 12px 12px; }

/* 공식·예시·안내 박스 */
.formula-box { margin: 20px 0 24px; padding: 18px 20px; line-height: 1.6; }
.example-list, .article .example-list { gap: 14px; margin: 18px 0 26px; }
.example-list li, .article .example-list li { padding: 16px 18px; margin: 0; line-height: 1.7; }
.note { margin-top: -6px; }
.disclaimer { margin-top: 40px; padding: 16px 18px; line-height: 1.7; }

/* 함께 보면 좋은 글 */
.article .related {
  margin: 8px 0 0; padding: 16px 18px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); line-height: 1.9;
}
.article .related strong { display: block; margin-bottom: 4px; }

/* 계산기·결과 영역 */
.calc-form { gap: 22px; }
.results { gap: 20px; margin-top: 24px; }
.alerts { gap: 10px; }
.alert { padding: 12px 16px; }
.faq summary { padding: 16px 0; }
.faq details > div { padding-bottom: 18px; }
.site-footer { margin-top: 64px; }
.site-footer p { margin: 6px 0; }
@media (max-width: 480px) {
  .article th, .article td { padding: 12px 10px; }
  .article tbody th { min-width: 84px; }
}
h2, h3, [id] { scroll-margin-top: 72px; }
