:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --text: #1b2420;
  --muted: #5d6b64;
  --line: #dde4df;
  --brand: #0f7a5a;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3ec;
  --accent: #c2410c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 4px 16px rgba(16, 32, 24, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --surface: #19201d; --surface-2: #212a26; --text: #e6ece9; --muted: #9aa9a1;
    --line: #2c3632; --brand: #3cc497; --brand-ink: #0b1310; --brand-soft: #1b3229; --accent: #fb923c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111614; --surface: #19201d; --surface-2: #212a26; --text: #e6ece9; --muted: #9aa9a1;
  --line: #2c3632; --brand: #3cc497; --brand-ink: #0b1310; --brand-soft: #1b3229; --accent: #fb923c;
  --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 "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  word-break: keep-all;
}
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: 16px; height: 56px; }
.logo { font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.logo span { color: var(--brand); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }

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

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

/* 폼 */
.form { display: grid; gap: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { 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-unit { position: relative; }
.input-unit input { padding-right: 44px; }
.input-unit .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%; height: 48px; padding: 0 14px; font: inherit; font-size: 17px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; }
.seg label { flex: 1; text-align: center; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 9px 4px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid 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: 20px; border-top: 1px dashed var(--line); padding-top: 20px; }
.big { text-align: center; padding: 18px; background: var(--brand-soft); border-radius: 12px; }
.big .k { font-size: 14px; color: var(--muted); }
.big .v { font-size: 32px; font-weight: 800; color: var(--brand); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.big .s { font-size: 14px; color: var(--muted); }
.lines { list-style: none; margin: 16px 0 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.lines li:last-child { border-bottom: 0; }
.lines .num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.lines li.total { font-weight: 700; }
.lines li.minus .num { color: var(--accent); }
.notice { font-size: 13px; color: var(--muted); margin-top: 12px; }
.warn { background: #fff4e5; color: #8a4b00; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-top: 12px; }
:root[data-theme="dark"] .warn { background: #33240f; color: #fbbf77; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warn { background: #33240f; color: #fbbf77; } }

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

/* 광고 자리 (애드센스 승인 후 사용) */
.ad-slot { margin: 28px 0; min-height: 0; }
.ad-slot:empty { display: none; }

/* 글 */
article p, article li { color: var(--text); }
article ul, article ol { padding-left: 22px; }
.formula { background: var(--surface-2); border-radius: 10px; padding: 12px 16px; font-size: 15px; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 600; padding: 14px 0; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; float: right; color: var(--muted); }
details[open] summary::after { content: "−"; }
details p { margin: 0 0 14px; }

/* 카드 목록 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
@media (max-width: 520px) { .tile { padding: 14px; } .tile .t { font-size: 16px; } .tile .d { font-size: 13px; } }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s; }
.tile:hover { border-color: var(--brand); }
.tile .t { font-weight: 700; font-size: 17px; }
.tile .d { color: var(--muted); font-size: 14px; margin-top: 4px; }
.tile .ico { font-size: 24px; margin-bottom: 6px; }

.related { margin-top: 40px; }

/* 푸터 */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; font-size: 13px; color: var(--muted); }
.site-footer a { color: var(--muted); margin-right: 14px; }
.site-footer p { margin: 8px 0 0; }

/* 제휴 링크 (아고다·쿠팡) */
.aff { margin: 28px 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.aff-note { display: block; font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.aff > .aff-note { margin: 0 0 10px; }
.aff iframe { max-width: 100%; }
.aff-btn { display: block; text-align: center; margin-top: 16px; padding: 13px 16px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-weight: 700; text-decoration: none; }
.aff-btn:hover { filter: brightness(1.05); }
.aff-title { font-weight: 700; margin: 0 0 10px; }
.aff-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.aff-links a { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); font-size: 14px; background: var(--surface-2); }
.aff-links a:hover { border-color: var(--brand); color: var(--brand); }
.aff > .aff-note:last-child { margin: 10px 0 0; }
