:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --fill: #f2f4f6;
  --fill-hover: #e8ebef;
  --text: #191f28;
  --sub: #4e5968;
  --muted: #8b95a1;
  --line: #e5e8eb;
  --blue: #3182f6;
  --blue-press: #1b64da;
  --blue-soft: #e8f3ff;
  --on-blue: #ffffff;
  --red: #f04452;
  --red-soft: #ffeeee;
  --green-soft: #e5f8ee;
  --orange-soft: #fff3e0;
  --purple-soft: #f3edff;
  --radius-l: 24px;
  --radius-m: 16px;
  --radius-s: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101013;
    --surface: #1d1d22;
    --fill: #2c2c33;
    --fill-hover: #35353d;
    --text: #f2f2f5;
    --sub: #c3c3c9;
    --muted: #8a8a94;
    --line: #2c2c33;
    --blue: #4a95ff;
    --blue-press: #6aa8ff;
    --blue-soft: #1d2a40;
    --on-blue: #ffffff;
    --red: #ff6a72;
    --red-soft: #3a2224;
    --green-soft: #1d3328;
    --orange-soft: #3a2f1d;
    --purple-soft: #2b2540;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); letter-spacing: -0.03em; }
.logo:hover { text-decoration: none; }
.logo-mark { display: block; width: 30px; height: 30px; border-radius: 9px; }
.top-nav { display: flex; gap: 2px; }
.top-nav a { color: var(--sub); font-size: 15px; font-weight: 600; padding: 8px 12px; border-radius: 10px; }
.top-nav a:hover { background: var(--fill); text-decoration: none; }
.top-nav a[aria-current] { color: var(--blue); }
.logo { white-space: nowrap; }
@media (max-width: 420px) {
  .top-nav a { font-size: 14px; padding: 8px 8px; }
}
@media (max-width: 340px) {
  .top-nav { display: none; }
}

/* ---------- page title ---------- */
.page-head { padding: 28px 4px 20px; }
.crumb { display: flex; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.crumb a { color: var(--muted); }
.page-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px;
  font-size: 30px; margin-bottom: 14px; background: var(--blue-soft);
}
.cat-house .page-icon, .cat-house .tile-icon { background: var(--purple-soft); }
h1 { font-size: 28px; line-height: 1.35; margin: 0; font-weight: 800; letter-spacing: -0.035em; }
.lead { margin: 8px 0 0; color: var(--sub); font-size: 17px; }
.asof {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 14px;
  font-size: 13px; font-weight: 600; color: var(--sub); background: var(--surface);
  padding: 6px 12px; border-radius: 999px;
}
.asof::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }
h2 { font-size: 22px; line-height: 1.4; margin: 0 0 14px; font-weight: 800; letter-spacing: -0.03em; }
h3 { font-size: 18px; margin: 24px 0 8px; }

main > h2 { margin: 32px 4px 12px; }

/* ---------- calculator card ---------- */
.calc { background: var(--surface); border-radius: var(--radius-l); padding: 24px 20px; }
@media (min-width: 560px) { .calc { padding: 28px; } }
.calc + .calc, h2 + .calc { margin-top: 12px; }
.calc-form { display: grid; gap: 20px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 440px) { .row-2 { grid-template-columns: 1fr; gap: 20px; } }
.field { display: grid; gap: 8px; min-width: 0; }
.field > span, .field legend { font-size: 15px; font-weight: 600; color: var(--sub); }
.field small { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.field small.kor { color: var(--blue); font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input, .field select, .field input[type="date"] {
  width: 100%; height: 56px; padding: 0 48px 0 18px;
  font: inherit; font-size: 19px; font-weight: 600; color: var(--text); letter-spacing: -0.02em;
  background: var(--fill); border: 2px solid transparent; border-radius: var(--radius-m);
  font-variant-numeric: tabular-nums; transition: border-color .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
.field input[type="date"] { padding-right: 18px; font-size: 17px; }
.field select {
  padding-right: 44px; font-size: 16.5px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238b95a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 18px center;
}
.input-wrap input:hover, .field select:hover, .field input[type="date"]:hover { background-color: var(--fill-hover); }
input:focus, select:focus { outline: none; border-color: var(--blue) !important; background-color: var(--surface) !important; }
.input-wrap em { position: absolute; right: 18px; font-style: normal; font-size: 17px; font-weight: 600; color: var(--sub); pointer-events: none; }

fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--fill); border-radius: var(--radius-m); }
.seg label { flex: 1 1 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 11px 6px; border-radius: 12px;
  font-size: 15px; font-weight: 600; color: var(--sub); cursor: pointer; transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); }
.check {
  display: flex; gap: 12px; align-items: flex-start; font-size: 15.5px; color: var(--text); cursor: pointer;
  padding: 2px 0; line-height: 1.5;
}
.check input {
  -webkit-appearance: none; appearance: none; flex: none; width: 24px; height: 24px; margin: 0;
  border-radius: 8px; background: var(--fill); border: 2px solid var(--line); cursor: pointer; transition: all .15s;
}
.check input:checked {
  background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='11' viewBox='0 0 14 11'%3E%3Cpath d='M1.5 5.5l4 4 7-8' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center no-repeat;
  border-color: var(--blue);
}
.muted { color: var(--muted); }
.calc-form > small.muted { font-size: 13.5px; margin-top: -8px; }

/* ---------- result ---------- */
.result { margin-top: 28px; }
.result-main { padding: 0 2px 4px; }
.result-main .label { font-size: 15px; font-weight: 600; color: var(--sub); }
.result-main .value {
  font-size: 36px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.25; margin-top: 4px;
  color: var(--blue); font-variant-numeric: tabular-nums;
}
.result-main .sub { font-size: 14.5px; color: var(--muted); margin-top: 6px; }
.result table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 15.5px; }
.result td { padding: 11px 0; color: var(--sub); }
.result td:last-child { text-align: right; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 12px; }
.result tr.total td { border-top: 1px solid var(--line); padding-top: 14px; color: var(--text); font-weight: 800; }
.result tr.total + tr td { padding-top: 14px; }
.result tr.minus td:last-child { color: var(--red); }
.result .note { font-size: 13.5px; color: var(--muted); margin: 14px 0 0; line-height: 1.55; }
.result .alert {
  background: var(--red-soft); color: var(--red); border-radius: var(--radius-s);
  padding: 12px 14px; font-size: 14.5px; font-weight: 600; margin: 16px 0 0; line-height: 1.5;
}
.result .empty { color: var(--muted); font-size: 15px; background: var(--fill); padding: 18px; border-radius: var(--radius-m); text-align: center; margin: 0; }

/* ---------- DSR loans ---------- */
.loans { display: grid; gap: 10px; }
.loan { border-radius: var(--radius-m); padding: 16px; display: grid; gap: 14px; border: 2px solid var(--fill); }
.loan .input-wrap input, .loan select { background-color: var(--fill); }
.loan-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 16px; }
.btn {
  font: inherit; font-size: 15.5px; font-weight: 700; border: 0; background: var(--blue-soft); color: var(--blue);
  border-radius: var(--radius-s); height: 50px; padding: 0 16px; cursor: pointer; transition: background .15s;
}
.btn:hover { filter: brightness(0.97); }
.btn-text { border: 0; background: none; color: var(--muted); padding: 4px 6px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-text:hover { color: var(--red); }

/* ---------- article ---------- */
.article { margin-top: 12px; display: grid; gap: 12px; }
.article > section, .article.plain { background: var(--surface); border-radius: var(--radius-l); padding: 26px 20px; min-width: 0; }
@media (min-width: 560px) { .article > section, .article.plain { padding: 30px 28px; } }
.article p { margin: 0 0 12px; color: var(--sub); font-size: 16px; line-height: 1.75; }
.article p:last-child { margin-bottom: 0; }
.article strong { color: var(--text); }
.article ul, .article ol { margin: 0 0 12px; padding-left: 20px; color: var(--sub); line-height: 1.75; }
.article li { margin-bottom: 6px; }
.article li:last-child { margin-bottom: 0; }
.table-scroll { overflow-x: auto; margin: 0 0 14px; border-radius: var(--radius-s); border: 1px solid var(--line); }
.table-scroll:last-child { margin-bottom: 0; }
.article table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.article th, .article td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: normal; }
.article tr:last-child td { border-bottom: 0; }
.article th { background: var(--fill); font-weight: 700; color: var(--sub); }
.article td { color: var(--text); }
.formula {
  background: var(--blue-soft); color: var(--text) !important; border-radius: var(--radius-s);
  padding: 14px 16px; font-size: 15.5px !important; font-weight: 600; line-height: 1.7 !important;
}
.faq details { border-bottom: 1px solid var(--line); }
.faq details:last-child { border-bottom: 0; }
.faq summary {
  list-style: none; cursor: pointer; padding: 16px 32px 16px 0; font-weight: 700; font-size: 16px; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 4px; top: 50%; width: 9px; height: 9px; margin-top: -7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s;
}
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.faq details p { padding-bottom: 16px; margin: 0; }

/* ---------- home ---------- */
.hero { padding: 40px 4px 24px; }
.hero h1 { font-size: 30px; }
@media (min-width: 560px) { .hero h1 { font-size: 36px; } }
.hero p { color: var(--sub); margin: 12px 0 0; font-size: 17px; }
.search { position: relative; margin-top: 24px; }
.search input {
  width: 100%; height: 58px; padding: 0 18px 0 52px; border: 2px solid transparent; border-radius: var(--radius-m);
  background: var(--surface); font: inherit; font-size: 17px; color: var(--text);
}
.search svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-empty { color: var(--muted); padding: 20px 4px; }
.category { margin-top: 28px; }
.category-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 4px; margin-bottom: 12px; }
.category-head h2 { margin: 0; font-size: 20px; }
.category-head span { font-size: 14px; color: var(--muted); }
.tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  display: flex; flex-direction: column; gap: 12px; height: 100%; padding: 18px; background: var(--surface);
  border-radius: 20px; color: var(--text); transition: transform .12s, background .15s;
}
.tile:hover { text-decoration: none; background: color-mix(in srgb, var(--surface) 92%, var(--blue)); }
.tile:active { transform: scale(0.97); }
.tile-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-size: 24px; background: var(--blue-soft); }
.tile strong { font-size: 16.5px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.35; }
.tile span { font-size: 13.5px; color: var(--muted); line-height: 1.45; margin-top: -6px; }

/* related */
.related { margin-top: 12px; background: var(--surface); border-radius: var(--radius-l); padding: 26px 20px; }
@media (min-width: 560px) { .related { padding: 30px 28px; } }
.related h2 { font-size: 19px; }
.related ul { list-style: none; padding: 0; margin: 0; }
.related li a {
  display: flex; align-items: center; gap: 14px; padding: 10px 0; color: var(--text); font-weight: 600; font-size: 16px;
}
.related li a:hover { text-decoration: none; color: var(--blue); }
.related .tile-icon { width: 40px; height: 40px; font-size: 21px; border-radius: 12px; flex: none; }
.related li a::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 22px; font-weight: 400; }

/* ---------- ads ---------- */
.ad { margin: 12px 0; }
.ad-placeholder {
  min-height: 100px; display: grid; place-items: center; border: 2px dashed var(--line); border-radius: var(--radius-l);
  color: var(--muted); font-size: 13px; background: var(--surface);
}

/* ---------- footer ---------- */
.site-footer { margin-top: 48px; padding: 32px 0 48px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.footer-nav a { color: var(--sub); font-weight: 600; }
.site-footer p { margin: 0 0 6px; }
