:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1d22;
  --sub: #5d6470;
  --line: #e3e6eb;
  --brand: #2f6bff;
  --brand-soft: #e8efff;
  --good: #12a150;
  --bad: #e5484d;
  --warn: #f5a524;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --card: #1c1f25; --text: #eceef2; --sub: #9aa2ae; --line: #2c3038;
    --brand: #6b95ff; --brand-soft: #222c44; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121418; --card: #1c1f25; --text: #eceef2; --sub: #9aa2ae; --line: #2c3038;
  --brand: #6b95ff; --brand-soft: #222c44; --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-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px; line-height: 1.6; word-break: keep-all;
}
a { color: var(--brand); text-decoration: none; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* 헤더·푸터 */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { font-weight: 800; font-size: 19px; color: var(--text); }
.logo b { color: var(--brand); }
.site-header nav a { color: var(--sub); font-size: 14px; margin-left: 14px; }
.site-footer { margin-top: 48px; padding: 28px 0 40px; color: var(--sub); font-size: 13px; border-top: 1px solid var(--line); }
.site-footer a { color: var(--sub); margin-right: 12px; }

/* 본문 */
h1 { font-size: 24px; margin: 24px 0 4px; line-height: 1.35; }
.lead { color: var(--sub); margin: 0 0 18px; font-size: 15px; }
h2 { font-size: 19px; margin: 32px 0 10px; }
h3 { font-size: 16px; margin: 20px 0 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }

/* 폼 */
.field { margin-bottom: 14px; }
.field > label, .field > .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--sub); margin-top: 4px; }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit span { position: absolute; right: 14px; color: var(--sub); font-size: 15px; pointer-events: none; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.input-unit input { padding-right: 52px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); background: var(--card); }
select { background-image: linear-gradient(45deg, transparent 50%, var(--sub) 50%), linear-gradient(135deg, var(--sub) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 220px; resize: vertical; line-height: 1.6; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.seg { display: flex; background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; font: inherit; font-size: 14.5px; color: var(--sub); padding: 9px 4px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--brand); font-weight: 700; box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 13.5px; padding: 6px 11px; border-radius: 999px; cursor: pointer; }
.chip:active, .chip.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.btn { display: inline-block; width: 100%; border: 0; background: var(--brand); color: #fff; font: inherit; font-size: 17px; font-weight: 700; padding: 14px; border-radius: 12px; cursor: pointer; text-align: center; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.small { width: auto; font-size: 14px; padding: 9px 14px; border-radius: 10px; }
.btn:active { transform: translateY(1px); }

/* 결과 */
.result { background: var(--brand-soft); border-radius: var(--radius); padding: 18px; margin-top: 4px; }
.result .big-label { font-size: 14px; color: var(--sub); }
.result .big { font-size: 30px; font-weight: 800; color: var(--brand); line-height: 1.25; margin: 2px 0 6px; word-break: break-all; }
.result .sub { font-size: 14px; color: var(--sub); }
.kv { width: 100%; border-collapse: collapse; font-size: 15px; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.kv tr.total td { border-bottom: 0; font-weight: 800; padding-top: 12px; }
.kv tr.minus td:last-child { color: var(--bad); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.grid th { position: sticky; top: 0; background: var(--card); font-weight: 700; color: var(--sub); }
table.grid td:first-child, table.grid th:first-child { text-align: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .k { font-size: 13px; color: var(--sub); }
.stat .v { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; word-break: break-all; }

/* 설명·FAQ */
.guide { font-size: 15px; color: var(--text); }
.guide p, .guide li { color: var(--sub); }
.guide ul, .guide ol { padding-left: 20px; }
details.faq { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; margin-bottom: 8px; }
details.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; list-style: none; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before { content: "Q. "; color: var(--brand); }
details.faq p { margin: 0 0 14px; color: var(--sub); font-size: 15px; }
.note { font-size: 13px; color: var(--sub); margin-top: 10px; }

/* 홈 */
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: 26px; margin: 0 0 6px; }
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .tool-grid { grid-template-columns: repeat(3, 1fr); } }
.tool { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 14px; color: var(--text); box-shadow: var(--shadow); }
.tool .ico { font-size: 26px; line-height: 1; }
.tool .name { font-weight: 700; margin-top: 8px; font-size: 15.5px; }
.tool .desc { font-size: 12.5px; color: var(--sub); margin-top: 2px; line-height: 1.45; }
.tool:active { border-color: var(--brand); }
.section-title { font-size: 15px; color: var(--sub); font-weight: 700; margin: 26px 0 10px; }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.related a { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 14px; color: var(--text); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #222; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 99; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hidden { display: none !important; }
.muted { color: var(--sub); }
.center { text-align: center; }
.mt { margin-top: 12px; }
