/* 놓치면 손해 계산기 - 공통 스타일
 * 구성: 회색 바탕 위에 흰 카드를 쌓는 한 단 레이아웃. 글은 크게, 줄 간격은 넉넉하게.
 * 색: 남색 계열 강조 + 노란 포인트(블로그 「놓치면 손해」 사진과 같은 색감) */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --title: #191f28;
  --text: #333d4b;
  --muted: #6b7684;
  --faint: #8b95a1;
  --line: #e5e8eb;
  --accent: #2456d9;
  --accent-strong: #1b45b5;
  --accent-ink: #ffffff;
  --accent-soft: #edf2ff;
  --point: #ffc93c;
  --point-soft: #fff6d6;
  --warn-bg: #fff4e5;
  --warn-ink: #8a4b00;
  --error: #d22030;
  --input-bg: #f2f4f6;
  --shadow: 0 1px 2px rgba(25, 31, 40, 0.04);
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --surface: #1b1f26;
    --surface-2: #222730;
    --title: #f2f4f6;
    --text: #d1d6db;
    --muted: #9ba3ad;
    --faint: #7d8691;
    --line: #2c323b;
    --accent: #6d9bff;
    --accent-strong: #8fb2ff;
    --accent-ink: #0d1424;
    --accent-soft: #1d2a45;
    --point: #ffcf4d;
    --point-soft: #3a3115;
    --warn-bg: #33270f;
    --warn-ink: #f6c97a;
    --error: #ff7a85;
    --input-bg: #262b34;
    --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: var(--font);
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
strong, b { color: var(--title); font-weight: 700; }
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ── 머리글 ─────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 58px; }
.brand {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  font-weight: 800; font-size: 17px; color: var(--title); text-decoration: none; letter-spacing: -0.02em;
}
.brand::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: var(--point); box-shadow: 0 0 0 3px var(--point-soft);
}
.top-nav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin-left: auto; font-size: 15px; font-weight: 600;
}
.top-nav::-webkit-scrollbar { display: none; }
.top-nav a {
  flex: none; color: var(--muted); text-decoration: none;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.top-nav a:hover { background: var(--bg); color: var(--title); }
.top-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 560px) {
  .site-header .wrap { flex-wrap: wrap; gap: 0; padding-top: 10px; }
  .top-nav { margin: 6px -4px 8px; width: calc(100% + 8px); }
}

/* ── 본문 뼈대 ─────────────────────────── */
main { padding-top: 28px; padding-bottom: 48px; }
h1 {
  color: var(--title); font-size: 28px; line-height: 1.32; font-weight: 800;
  letter-spacing: -0.03em; margin: 0 0 10px; text-wrap: balance;
}
h2 {
  color: var(--title); font-size: 22px; line-height: 1.4; font-weight: 700;
  letter-spacing: -0.02em; margin: 40px 0 14px; text-wrap: balance;
}
h3 { color: var(--title); font-size: 18px; line-height: 1.45; font-weight: 700; margin: 28px 0 10px; }
p { margin: 0 0 16px; }
.lead { color: var(--muted); font-size: 17px; margin-bottom: 24px; }
.muted { color: var(--muted); }
small, .small { font-size: 15px; }
ul, ol { padding-left: 1.25em; margin: 0 0 16px; }
li { margin: 6px 0; padding-left: 2px; }
li::marker { color: var(--faint); }

/* 계산기 아래 설명 글은 섹션마다 흰 카드에 담아 읽기 쉽게 */
article > section:not(.calc), main > section, .related {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 22px 12px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
article > section:not(.calc) > h2:first-child, main > section > h2:first-child, .related > h2:first-child { margin-top: 0; }

/* ── 계산기 ─────────────────────────────── */
.calc {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px 22px 24px;
  margin: 8px 0 12px;
  box-shadow: var(--shadow);
}
.calc h2 { margin: 0 0 20px; font-size: 20px; }
.field { margin: 0 0 20px; }
.field > label, .field > .label {
  display: block; margin-bottom: 8px;
  color: var(--text); font-size: 15px; font-weight: 600;
}
.field .hint { display: block; color: var(--faint); font-size: 14px; margin-top: 8px; line-height: 1.55; }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit span {
  position: absolute; right: 16px; color: var(--muted); font-size: 16px; font-weight: 600; pointer-events: none;
}
input[type="text"], input[type="date"], select {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--title);
  background-color: var(--input-bg);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder { color: var(--faint); font-weight: 500; }
input[type="text"]:focus, input[type="date"]:focus, select:focus {
  outline: none; border-color: var(--accent); background-color: var(--surface);
}
input[type="text"] { text-align: right; font-variant-numeric: tabular-nums; }
/* 단위(원·시간)가 숫자와 겹치지 않게 오른쪽 자리를 비운다. 위 input 규칙보다 뒤에 둬야 이긴다 */
.input-unit input[type="text"] { padding-right: 64px; }
select {
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b95a1' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
fieldset.field { border: 0; padding: 0; min-width: 0; }
fieldset.field > legend { padding: 0; display: block; margin-bottom: 8px; color: var(--text); font-size: 15px; font-weight: 600; }
.choice { display: flex; flex-wrap: wrap; gap: 8px; }
.choice label {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px;
  padding: 0 16px; border-radius: var(--radius-sm); background: var(--input-bg);
  font-size: 16px; font-weight: 600; color: var(--text); cursor: pointer;
  border: 2px solid transparent;
}
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.check {
  display: flex !important; gap: 10px; align-items: flex-start;
  font-size: 16px !important; font-weight: 500 !important; color: var(--text) !important; cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.btn {
  display: block; width: 100%; height: 58px; margin-top: 8px;
  font: inherit; font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: var(--radius); cursor: pointer;
  transition: background-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: scale(0.99); }

/* ── 결과 ───────────────────────────────── */
.result {
  margin-top: 24px; padding: 24px 20px 18px;
  border-radius: var(--radius); background: var(--surface-2);
}
.result[hidden] { display: none; }
.result .big-label { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--muted); }
.result .big {
  margin: 0 0 16px; font-size: 36px; line-height: 1.2; font-weight: 800; letter-spacing: -0.03em;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.result .sub {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  margin: 0 0 18px; border-radius: var(--radius-sm); overflow: hidden; background: var(--line);
}
.result .sub div { background: var(--surface); padding: 14px 14px 12px; min-width: 0; }
.result .sub span { display: block; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.result .sub b { display: block; margin: 2px 0; font-size: 18px; line-height: 1.35; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 599px) {
  /* 휴대폰에서는 카드 안쪽 여백을 줄여 결과 숫자가 한 줄에 들어가게 */
  .calc { padding: 24px 18px 20px; }
  .result { margin-left: -6px; margin-right: -6px; padding: 22px 14px 16px; }
  .result .sub div { padding: 12px 12px 10px; }
}
.result h3 { margin: 18px 0 10px; font-size: 16px; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; font-size: 15.5px; line-height: 1.6; }
.steps li {
  counter-increment: step; position: relative;
  margin: 0; padding: 10px 0 10px 34px; border-top: 1px solid var(--line);
}
.steps li:first-child { border-top: 0; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 11px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; font-weight: 700; line-height: 22px; text-align: center;
}
.round-note { margin: 14px 0 0; font-size: 14px; line-height: 1.6; color: var(--faint); }
.warn {
  margin: 0 0 14px; padding: 14px 16px;
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: var(--radius-sm); font-size: 15.5px; line-height: 1.6;
}
.error { margin: 0; color: var(--error); font-weight: 700; }

/* ── 표 ─────────────────────────────────── */
.table-wrap {
  overflow-x: auto; margin: 6px 0 20px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
table { border-collapse: collapse; width: 100%; font-size: 15.5px; line-height: 1.55; }
th, td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th { background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
td { color: var(--text); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.num { color: var(--title); font-weight: 600; }

/* ── 예시 ───────────────────────────────── */
.example {
  margin: 12px 0; padding: 20px 20px 6px;
  background: var(--surface-2); border-radius: var(--radius);
}
.example h3 { margin: 0 0 10px; font-size: 17px; }
.example ol { margin: 0 0 14px; padding-left: 1.3em; font-size: 16px; }
.example li { margin: 6px 0; }
.example strong { color: var(--accent); }

/* ── 자주 묻는 질문 ─────────────────────── */
details { border-top: 1px solid var(--line); }
details:first-of-type { border-top: 0; }
summary {
  position: relative; cursor: pointer; list-style: none;
  padding: 18px 36px 18px 0; color: var(--title); font-size: 17px; font-weight: 600; line-height: 1.5;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ""; position: absolute; right: 4px; top: 50%; width: 9px; height: 9px; margin-top: -7px;
  border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint);
  transform: rotate(45deg); transition: transform 0.2s;
}
details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
details > p, details > ul { margin: 0 0 18px; color: var(--text); font-size: 16px; }

.sources { font-size: 15px; color: var(--muted); }
.sources li { margin: 8px 0; }

/* ── 홈 첫 화면 ─────────────────────────── */
.hero { padding: 12px 2px 8px; }
.hero .kicker {
  display: inline-block; margin: 0 0 12px; padding: 5px 12px; border-radius: 999px;
  background: var(--point-soft); color: var(--title); font-size: 14px; font-weight: 700;
}
.hero h1 { font-size: 32px; margin-bottom: 12px; }
.hero .lead { margin-bottom: 20px; }

/* ── 계산기 카드 목록 ───────────────────── */
.cards { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 600px) { .cards { grid-template-columns: 1fr 1fr; } }
.cards li { margin: 0; padding: 0; }
.cards a {
  display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; align-items: start;
  height: 100%; padding: 18px; text-decoration: none; color: var(--text);
  background: var(--surface-2); border-radius: var(--radius);
  transition: background-color 0.15s, transform 0.15s;
}
.cards a:hover { background: var(--accent-soft); }
.cards a:active { transform: scale(0.99); }
.cards .mark {
  grid-row: span 2; width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 19px; font-weight: 800;
}
.cards strong { display: block; color: var(--title); font-size: 18px; line-height: 1.4; margin: 1px 0 2px; }
.cards span:not(.mark) { display: block; font-size: 15px; color: var(--muted); line-height: 1.55; }

/* ── 바닥글 ─────────────────────────────── */
.site-footer { color: var(--faint); font-size: 14px; line-height: 1.65; }
.site-footer .wrap { padding-top: 8px; padding-bottom: 40px; }
.site-footer p { margin: 0 0 8px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 18px; font-weight: 600; }
.foot-links a { color: var(--muted); text-decoration: none; }

@media (min-width: 600px) {
  main { padding-top: 40px; }
  h1 { font-size: 34px; }
  .hero h1 { font-size: 40px; }
  .calc { padding: 32px 32px 28px; }
  article > section:not(.calc), main > section, .related { padding: 36px 32px 20px; }
  .result { padding: 28px 26px 22px; }
  .result .big { font-size: 40px; }
  .result .sub { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
