:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #191f28; --sub: #6b7684; --line: #e5e8eb;
  --accent: #3182f6; --accent-soft: #e8f3ff; --minus: #f04452; --warn-soft: #fff4e5; --warn: #b25e00;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17171c; --card: #202027; --text: #ececf0; --sub: #9e9ea8; --line: #33333d;
    --accent: #4f95ff; --accent-soft: #1d2b42; --minus: #ff6b75; --warn-soft: #3a2a14; --warn: #ffb35c; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.6; word-break: keep-all; }
a { color: var(--accent); }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 64px; }

/* 상단 메뉴 */
header.site { position: relative; display: flex; align-items: center; gap: 20px; margin-bottom: 24px; padding: 8px 0; flex-wrap: wrap; z-index: 50; }
.logo { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo span { color: var(--accent); }
header.site nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
header.site nav > a, header.site summary { color: var(--sub); text-decoration: none; font-size: 14px; font-weight: 600; padding: 6px 10px;
  border-radius: 8px; white-space: nowrap; cursor: pointer; }
header.site nav > a:hover, header.site summary:hover, details.menu[open] summary { background: var(--card); color: var(--text); }
header.site nav > a[aria-current="page"], header.site summary.on { color: var(--accent); background: var(--accent-soft); }
.header-guide { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 700; padding: 6px 14px;
  border: 1.5px solid var(--accent); border-radius: 999px; white-space: nowrap; }
.header-guide:hover, .header-guide[aria-current="page"] { background: var(--accent); color: #fff; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; top: calc(100% + 6px); left: 0; min-width: 160px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); display: flex; flex-direction: column; }
.menu-panel a { color: var(--text); text-decoration: none; font-size: 15px; padding: 10px 12px; border-radius: 8px; white-space: nowrap; }
.menu-panel a:hover { background: var(--bg); }
.menu-panel a[aria-current="page"] { color: var(--accent); font-weight: 700; }

h1 { font-size: 26px; line-height: 1.35; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 20px 0 8px; }
.lead { color: var(--sub); margin: 0 0 20px; font-size: 15px; }
.lead:has(+ .updated) { margin-bottom: 6px; }
.updated { color: var(--sub); font-size: 12px; margin: 0 0 20px; }
.updated::before { content: "●"; color: #12b886; margin-right: 6px; font-size: 9px; vertical-align: 2px; }
.card { background: var(--card); border-radius: 20px; padding: 24px; margin-bottom: 16px; }

/* 입력 */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.field { margin-bottom: 18px; }
.input-row { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--card); }
.input-row:focus-within { border-color: var(--accent); }
.input-row input, .input-row select { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 18px; font-weight: 600; padding: 13px 0; }
.input-row .unit { color: var(--sub); font-size: 15px; margin-left: 8px; }
.hint { font-size: 13px; color: var(--sub); margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick button { border: 0; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; margin: 0; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.seg { display: flex; gap: 6px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 6px; font-size: 15px; cursor: pointer; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 결과 */
.result-top { text-align: center; padding: 8px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.result-top .k { color: var(--sub); font-size: 14px; }
.result-top .v { font-size: 36px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.result-top .s { color: var(--sub); font-size: 14px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 15px; }
.rows li .n { color: var(--sub); }
.rows li .m { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.rows li.minus .m { color: var(--minus); }
.rows li.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; font-weight: 700; }
.rows li.total .n { color: var(--text); }
/* 결과 미리보기 바 (site.js) */
.result-bar { position: sticky; z-index: 45; top: calc(env(safe-area-inset-top, 0px) + 8px); width: 100%; margin: -8px 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12); font: inherit; cursor: pointer; text-align: left;
  opacity: 0; pointer-events: none; transform: translateY(-6px); transition: opacity .15s ease, transform .15s ease; }
.result-bar.show { opacity: 1; pointer-events: auto; transform: none; }
@media (min-width: 769px) { .result-bar:not(.all) { display: none; } }
.result-bar .k { color: var(--sub); font-size: 13px; }
.result-bar .v { color: var(--accent); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-bar .v::after { content: " ↓"; font-size: 13px; color: var(--sub); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .result-bar { transition: none; } }

.notice { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-top: 12px; }

/* 광고 자리: 광고 코드를 넣기 전에는 비어 있어 보이지 않는다 */
.ad-slot { margin-bottom: 16px; min-height: 100px; }
.ad-slot:empty { display: none; }

/* 표, FAQ, 본문 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--sub); font-weight: 600; font-size: 13px; }
th:first-child, td:first-child { text-align: left; }
td.hl { color: var(--accent); font-weight: 700; }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
details:last-child { border-bottom: 0; }
summary { font-weight: 600; cursor: pointer; }
details p { color: var(--sub); margin: 8px 0 0; font-size: 15px; }
.prose p, .prose li { color: var(--sub); font-size: 15px; }
.prose p:first-child { margin-top: 0; }
.prose strong { color: var(--text); }
.formula { background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--text); margin: 8px 0; }
.rates li { color: var(--sub); font-size: 14px; }

/* 가이드 글 */
.article-meta { color: var(--sub); font-size: 13px; margin: 0 0 20px; }
.prose h2 { margin-top: 8px; }
.prose table { margin: 8px 0 4px; }
.prose .table-wrap + p { margin-top: 12px; }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--accent-soft); border-radius: 16px; padding: 16px 18px; margin-bottom: 16px; text-decoration: none; color: var(--text); }
.cta b { display: block; font-size: 16px; }
.cta span { color: var(--sub); font-size: 14px; }
.cta em { font-style: normal; font-weight: 700; color: var(--accent); white-space: nowrap; }
.sources li { font-size: 13px; color: var(--sub); word-break: break-all; }
.guide-list { list-style: none; margin: 0; padding: 0; }
.guide-list li { border-bottom: 1px solid var(--line); }
.guide-list li:last-child { border-bottom: 0; }
.guide-list a { display: block; padding: 14px 0; text-decoration: none; color: var(--text); }
.guide-list a b { display: block; font-size: 16px; }
.guide-list a span { color: var(--sub); font-size: 14px; }

/* 다른 계산기 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { display: block; background: var(--card); border-radius: 16px; padding: 18px; text-decoration: none; color: var(--text); border: 1.5px solid transparent; }
.tile:hover { border-color: var(--accent); }
.tile b { display: block; font-size: 16px; margin-bottom: 4px; }
.tile span { color: var(--sub); font-size: 14px; }
.card .tile { background: var(--bg); }

footer.site { color: var(--sub); font-size: 13px; text-align: center; margin-top: 32px; }
footer.site nav { display: flex; justify-content: center; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
footer.site nav a { color: var(--sub); text-decoration: none; }
footer.site nav a:hover { color: var(--text); }

/* 좁은 화면 헤더: 1줄 = 로고 + 가이드, 2줄 = 계산기 메뉴 */
@media (max-width: 680px) {
  header.site { gap: 6px; }
  .header-guide { order: 2; margin-left: auto; padding: 4px 12px; font-size: 13px; }
  header.site nav { order: 3; flex-basis: 100%; margin: 0 -7px; gap: 2px 0; flex-wrap: wrap; }
  header.site nav > a, header.site summary { padding: 6px 6px; font-size: 14px; letter-spacing: -0.3px; }
}
@media (max-width: 480px) {
  h1 { font-size: 22px; } .result-top .v { font-size: 30px; } .card { padding: 20px 18px; }
  header.site { margin-bottom: 16px; }
  /* 좁은 화면에서는 펼친 메뉴를 헤더 너비 전체로 */
  details.menu { position: static; }
  .menu-panel { left: 0; right: 0; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .menu-panel a { flex: 1 1 28%; text-align: center; background: var(--bg); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 370px) {
  header.site nav > a, header.site summary { padding: 6px 5px; font-size: 13px; }
}
