:root {
  --bg: #fbf7ef;
  --surface: #ffffff;
  --surface-2: #f4eee5;
  --text: #382c3b;
  --muted: #685e68;
  --line: #ded3ce;
  --accent: #286b57;
  --accent-soft: #e2f0e7;
  --accent-text: #ffffff;
  --warn-bg: #fff6e0;
  --warn-text: #6b4e00;
  --radius: 24px;
  --shadow: 0 5px 0 rgba(73, 52, 67, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #211e27;
    --surface: #2c2832;
    --surface-2: #36313c;
    --text: #f7eee6;
    --muted: #c6bbc8;
    --line: #544b5a;
    --accent: #a0dfbf;
    --accent-soft: #273e35;
    --accent-text: #211e27;
    --warn-bg: #2f2710;
    --warn-text: #f1d68a;
    --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.6 -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
[id] { scroll-margin-top: 110px; } /* 목차 링크로 이동할 때 고정 머리말에 가리지 않게 */
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* 상단 */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: inline-flex; align-items: center; gap: 8px; padding: 12px 0 6px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
.nav a[aria-current='page'] { background: var(--accent); color: var(--accent-text); font-weight: 700; }

main { padding: 24px 0 40px; }
h1 { font-size: 26px; line-height: 1.3; margin: 0 0 8px; }
h2 { font-size: 19px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 20px 0 6px; }
.lead { color: var(--muted); margin: 0 0 20px; }

/* 계산기 레이아웃 */
.calc { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .calc { grid-template-columns: 1.1fr 1fr; align-items: start; } .calc .result { position: sticky; top: 120px; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .help { font-size: 13px; color: var(--muted); margin-top: 4px; }
/* 라디오·체크 묶음(fieldset): 브라우저 기본 테두리·여백을 없애 일반 입력 묶음과 같은 모양으로 */
fieldset.field { border: 0; padding: 0; margin-top: 0; margin-left: 0; margin-right: 0; min-width: 0; }
fieldset.field > legend { padding: 0; }
.tbl tr.current { font-weight: 700; }
input[type='text'], input[type='number'], input[type='date'], select {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.unit { position: relative; }
.unit input { padding-right: 44px; }
.unit::after { content: attr(data-unit); position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.money-hint { font-size: 13px; color: var(--accent); min-height: 1.3em; margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 선택 버튼(라디오) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-size: 15px; background: var(--surface); }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.check input { width: 18px; height: 18px; }
.hidden { display: none !important; }

/* 결과 */
.result .big { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.25; }
.result .big-sub { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.rows .row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.rows .row:first-child { border-top: 0; }
.rows .row b { text-align: right; font-variant-numeric: tabular-nums; }
.rows .row.strong { font-weight: 800; font-size: 16px; }
.rows .row.sub { color: var(--muted); font-size: 14px; padding-left: 10px; }
.note { background: var(--warn-bg); color: var(--warn-text); border-radius: 9px; padding: 10px 12px; font-size: 13.5px; margin-top: 12px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 7px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.tbl th { background: var(--surface-2); text-align: center; font-weight: 700; }
.tbl td { white-space: nowrap; }
.tbl.left td, #zoneTable td { white-space: normal; }
@media (max-width: 480px) { .tbl { font-size: 13px; } .tbl th, .tbl td { padding: 6px 6px; } }
.tbl td:first-child { text-align: center; }
.tbl-wrap { overflow-x: auto; border-radius: 9px; }
.tbl.left td { text-align: left; }

.share { margin-top: 12px; width: 100%; font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); cursor: pointer; font-weight: 600; }
.share:hover { background: var(--accent-soft); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.callout { background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; margin: 16px 0; }
.callout p { margin: 4px 0; }
.cta { display: inline-block; margin: 8px 0; padding: 10px 16px; border-radius: 9px; background: var(--accent); color: var(--accent-text); text-decoration: none; font-weight: 700; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 12px 0 8px; font-size: 15px; }
.toc ol { margin: 6px 0 0; padding-left: 20px; }

/* 설명 글 */
.guide { margin-top: 12px; }
.guide p, .guide li { color: var(--text); }
.guide ul { padding-left: 20px; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 700; }
details p { margin: 8px 0 0; color: var(--muted); }
.asof { font-size: 13px; color: var(--muted); margin-top: 24px; }

/* 광고 자리 — 광고 코드를 넣기 전에는 공간을 차지하지 않는다 */
.ad-slot:empty { display: none; }
.ad-slot { margin: 20px 0; min-height: 100px; }

/* 홈 */
.hero { padding: 8px 0 12px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--accent); }
.tile .ico { font-size: 22px; }
.tile h3 { margin: 6px 0 4px; font-size: 17px; }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }
.related { margin-top: 32px; }

footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; padding: 20px 0 28px; }
footer a { color: var(--muted); }
footer .links { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }

/* 모아의 계산방: 숫자는 또렷하게, 장식은 가장자리에만 둔다. */
html { scroll-padding-bottom: 100px; }
body { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
.wrap { max-width: 1080px; padding-inline: 20px; }
main.wrap { padding-top: 26px; padding-bottom: 40px; }
.top { position: relative; border-bottom: 1px solid var(--line); }
.brand { gap: 10px; padding: 12px 0; font-size: 18px; letter-spacing: -.5px; }
.brand-mark { width: 40px; height: 38px; background: none; border-radius: 0; }
.nav { display: none; }
h1 { font-size: clamp(25px, 4vw, 36px); letter-spacing: -1px; line-height: 1.35; }
h2 { letter-spacing: -.4px; }
.lead { font-size: 15px; line-height: 1.8; }
a { text-underline-offset: 4px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 50; padding: 12px; background: var(--surface); }
.skip-link:focus { top: 8px; }
.hero { display: flex; align-items: center; gap: 12px; padding: 24px 20px; margin-bottom: 28px; border: 1px solid var(--line); border-radius: 28px 28px 28px 8px; background: var(--accent-soft); }
.hero-copy { flex: 1; min-width: 0; }
.hero > img { width: 86px; height: auto; flex: none; }
.hero h1 { font-size: 26px; margin-top: 8px; }
.hero .lead { margin-bottom: 8px; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 800; }
.hero-greeting { color: var(--accent); font-size: 14px; font-weight: 700; margin: 10px 0 0; }
.section-label { margin-top: 0; }
.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 18px 14px; border-radius: 22px; transition: transform .15s; }
.tile:hover { transform: translateY(-2px); }
.tile .ico { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 16px; background: var(--surface-2); font-size: 25px; }
.tile h3 { font-size: 16px; line-height: 1.5; margin-top: 12px; }
.tile p { font-size: 13px; line-height: 1.65; }
.calc-cards .tile { position: relative; border-radius: 8px 24px 24px 24px; }
.calc-cards .tile p { display: none; }
.calc-cards .tile:nth-child(3n + 2) .ico { background: var(--accent-soft); }
.card { padding: 22px 18px; min-width: 0; }
.calc { gap: 20px; }
.field { margin-bottom: 20px; }
.field > label, .field > .label { font-size: 15px; }
input[type='text'], input[type='number'], input[type='date'], select { min-height: 54px; border-radius: 14px; background: var(--surface-2); font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.unit::after { top: 27px; transform: translateY(-50%); }
.unit input { padding-right: 40px; }
.grid2 { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.seg { gap: 8px; }
.seg label { flex: 1 0 auto; text-align: center; }
.seg span { display: grid; place-items: center; min-height: 48px; padding: 10px 12px; border-radius: 14px; }
.field > label.check { display: flex; min-height: 44px; margin: 0; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.result { border: 2px solid var(--accent); background: var(--surface); border-radius: 10px 28px 28px 28px; }
.cat-status { display: flex; align-items: center; gap: 10px; min-height: 58px; padding-bottom: 12px; margin-bottom: 18px; border-bottom: 2px dashed var(--line); color: var(--accent); font-size: 14px; font-weight: 700; }
.cat-status img { flex: none; }
.result h2 { font-size: 16px; }
.result .big { font-size: clamp(27px, 7.8vw, 38px); letter-spacing: -.8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result .big-sub { margin-top: 8px; }
.rows .row { padding: 12px 0; align-items: baseline; }
.rows .row > * { min-width: 0; }
.rows .row b { flex-shrink: 0; max-width: 62%; }
.rows .row.strong { color: var(--accent); }
.note:empty { display: none; }
.result[data-state='error'] .cat-status { color: var(--warn-text); }
.result[data-state='error'] .big, .result[data-state='sleepy'] .big { display: none; }
.result[data-state='error'] .rows, .result[data-state='error'] .big-sub,
.result[data-state='error'] .note, .result[data-state='error'] .share,
.result[data-state='sleepy'] .rows, .result[data-state='sleepy'] .big-sub,
.result[data-state='sleepy'] .note, .result[data-state='sleepy'] .share { display: none; }
.share, .cta, .calculate { min-height: 48px; border-radius: 15px; padding: 12px 16px; }
.calculate { width: 100%; border: 0; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 800; cursor: pointer; margin-top: 16px; }
.share { background: var(--accent-soft); }
.tbl-wrap { border: 1px solid var(--line); border-radius: 16px; }
.tbl th, .tbl td { padding: 12px 10px; }
summary { min-height: 44px; padding-block: 10px; }
details { border-radius: 18px; padding-block: 4px; }
.crumbs a, footer .links a, .toc a { display: inline-flex; align-items: center; min-height: 44px; }
.guide { line-height: 1.85; }
.ad-slot { display: none !important; }
.bottom-tabs { position: fixed; z-index: 30; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 24px #00000008; }
.bottom-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; gap: 2px; font-size: 12px; color: var(--muted); text-decoration: none; border-radius: 16px; }
.bottom-tabs a > span { font-size: 24px; line-height: 1.2; }
.bottom-tabs a[aria-current='page'] { background: var(--accent-soft); color: var(--accent); font-weight: 800; }
footer { padding: 24px 0; }
footer .links { gap: 6px 16px; }
@media (max-width: 389px) { .hero { display: block; position: relative; } .hero > img { position: absolute; width: 56px; right: 14px; top: 12px; } .hero .eyebrow { padding-right: 44px; } .hero h1 { font-size: 24px; } }
@media (min-width: 680px) { .cards { grid-template-columns: repeat(3,minmax(0,1fr)); } .hero { padding: 32px; } .hero > img { width: 140px; } .hero h1 { font-size: 36px; } .calc-cards .tile p { display: block; } }
@media (min-width: 820px) { body { padding-bottom: 0; } .nav { display: flex; padding-bottom: 12px; } .nav a { min-height: 44px; display: inline-flex; align-items: center; } .bottom-tabs { display: none; } .calc .result { top: 24px; } .card { padding: 26px; } }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }

/* 직접 그린 선 그림 아이콘 (src/icons.mjs): 글자색을 따라가고 숫자 위에는 놓지 않는다 */
.tile .ico { color: var(--accent); }
.tile .ico svg { width: 27px; height: 27px; }
.bottom-tabs a > span { display: grid; place-items: center; height: 28px; }
.bottom-tabs a > span svg { width: 25px; height: 25px; }

/* 설치형 앱: 가로로 눕힌 아이폰의 노치·홈 막대에 내용이 가리지 않게 한다 */
.wrap { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.bottom-tabs { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }

/* 한 줄 안내 (src/js/pwa.js): 새 버전은 화면 아래에 떠 있고, 홈 화면에 추가는 본문 안에 놓인다(.app-bar-inline) */
.app-bar { position: fixed; z-index: 40; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: calc(86px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'cat msg close' 'act act act'; align-items: center; gap: 4px 10px; padding: 10px 8px 10px 14px; background: var(--surface); color: var(--text); border: 2px solid var(--accent); border-radius: 22px 22px 22px 8px; box-shadow: 0 8px 28px #00000026; font-size: 14px; line-height: 1.55; }
.app-bar img { grid-area: cat; }
.app-bar p { grid-area: msg; margin: 0; }
.app-bar-action { grid-area: act; min-height: 46px; margin: 4px 6px 2px 0; padding: 10px 16px; border: 0; border-radius: 15px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 800; cursor: pointer; }
.app-bar-action:disabled { opacity: .6; cursor: default; }
.app-bar-close { grid-area: close; width: 44px; height: 44px; border: 0; border-radius: 14px; background: none; color: var(--muted); font: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
@media (min-width: 560px) { .app-bar { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: 'cat msg act close'; } .app-bar-action { margin: 0; } }
@media (min-width: 820px) { .app-bar { left: auto; right: 20px; bottom: 20px; max-width: 540px; } }
.app-bar.app-bar-inline { position: static; max-width: none; margin: 28px 0 0; box-shadow: none; }
.hero + .app-bar.app-bar-inline { margin: -8px 0 28px; }
@media print { .app-bar, .bottom-tabs { display: none; } }
.app-bar[data-kind='update'] { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: 'cat msg act close'; }
.app-bar[data-kind='update'] .app-bar-action { margin: 0; }
