:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #17201b;
  --muted: #5e6a63;
  --line: #dde2db;
  --brand: #0b7a55;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3ec;
  --accent: #c2410c;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 4px 16px rgba(16, 24, 20, .04);
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --surface: #171e1b; --surface-2: #1f2824; --text: #e7ece9; --muted: #9aa8a0;
    --line: #2a3530; --brand: #34c38f; --brand-ink: #06231a; --brand-soft: #173329; --accent: #fb923c; --danger: #f97066;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--brand); }
img { max-width: 100%; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* 헤더 */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 15px; }
.nav { margin-left: auto; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { white-space: nowrap; color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
@media (max-width: 640px) { .nav { display: none; } }

/* 본문 */
main { padding: 24px 0 48px; }
h1 { font-size: 26px; line-height: 1.3; margin: 4px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 36px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 22px 0 6px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }

/* 폼 */
.form { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }
.field label, .field .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; min-height: 1em; }
.input { position: relative; }
.input input, .field select {
  width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--text); font: 600 17px var(--font); padding: 0 52px 0 14px; outline: none;
}
.field select { padding-right: 14px; font-weight: 500; font-size: 16px; }
.input input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
input[type="date"] { padding-right: 14px; }

.segmented { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented label { flex: 1; text-align: center; margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 9px 4px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 11px; font: 500 13px var(--font); cursor: pointer; }
.chips button:hover { border-color: var(--brand); color: var(--brand); }

.check { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* 결과 */
.result { margin-top: 14px; }
.result-head { text-align: center; padding: 8px 0 18px; border-bottom: 1px dashed var(--line); }
.result-head .label { color: var(--muted); font-size: 14px; }
.result-head .big { font-size: 34px; font-weight: 800; color: var(--brand); letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; }
.result-head .sub { color: var(--muted); font-size: 14px; }
.rows { list-style: none; margin: 14px 0 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.rows li:last-child { border-bottom: 0; }
.rows li span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.rows li.total { font-weight: 700; }
.rows li.total span:last-child { color: var(--accent); }
.rows li .muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.notice { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 14px; }
.warn { color: var(--danger); font-weight: 600; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.btn { flex: 1; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 600 15px var(--font); cursor: pointer; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* 표 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }

/* 홈 */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 18px; }
.tool { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tool:hover { border-color: var(--brand); transform: translateY(-1px); }
.tool .icon { font-size: 26px; }
.tool strong { display: block; font-size: 17px; margin: 6px 0 2px; }
.tool p { margin: 0; color: var(--muted); font-size: 14px; }

/* 본문 설명 */
.article p, .article li { color: var(--text); }
.article ul, .article ol { padding-left: 20px; }
.formula { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 15px; }
details.faq { border-bottom: 1px solid var(--line); padding: 12px 0; }
details.faq summary { font-weight: 600; cursor: pointer; }
details.faq p { margin: 8px 0 0; color: var(--muted); }

/* 광고 — 콘텐츠와 구분되게, 앱에서는 숨김 (앱은 AdMob 사용) */
.ad { margin: 20px 0; min-height: 100px; text-align: center; }
.ad::before { content: "광고"; display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
html.in-app .ad { display: none; }

/* 푸터 */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 13px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; }
.site-footer a { color: var(--muted); }

.related { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.related a { text-decoration: none; border: 1px solid var(--line); background: var(--surface); padding: 8px 12px; border-radius: 10px; color: var(--text); font-size: 14px; }
.related a:hover { border-color: var(--brand); color: var(--brand); }
