:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #191f28;
  --sub: #6b7684;
  --line: #e5e8eb;
  /* 차분한 파랑: 글자 · 테두리는 accent, 버튼 바탕은 accent-fill, 맨 위 요약은 summary-bg */
  --accent: #3462c4;
  --accent-fill: #3d63b3;
  --accent-soft: #edf2fb;
  --summary-bg: #2d4a83;
  --good: #0f9d58;
  --good-soft: #e6f6ee;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --bad: #d93025;
  --radius: 16px;
  --header-h: 60px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --card: #1b1e22;
    --text: #eceef1;
    --sub: #9aa3ad;
    --line: #2c3036;
    --accent: #8aaae0;
    --accent-fill: #3b5687;
    --accent-soft: #1c2433;
    --summary-bg: #24324b;
    --good: #3ccf86;
    --good-soft: #15302a;
    --warn: #f0a23b;
    --warn-soft: #33281a;
    --bad: #ff6b60;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
a { color: var(--accent); }
.container { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 720px; }

/* ---- 머리 · 꼬리 ---- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-header .logo { font-weight: 800; font-size: 18px; text-decoration: none; color: var(--text); white-space: nowrap; }
.site-header nav { display: flex; gap: 4px; }
.site-header nav a { font-size: 14px; color: var(--sub); text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.site-header nav a:hover { background: var(--card); color: var(--text); }
.site-header nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 24px 0 96px; font-size: 12px; color: var(--sub); }
.site-footer p { margin: 4px 0; }

/* ---- 첫 화면 ---- */
.hero { padding: 28px 0 20px; }
.hero h1 { font-size: 24px; line-height: 1.35; margin: 0 0 8px; letter-spacing: -0.02em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--sub); margin: 0; font-size: 15px; max-width: 640px; }

/* ---- 화면 나누기: 핸드폰 한 줄 → 태블릿 · PC 두 칸 ---- */
.layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 860px) {
  .hero { padding: 40px 0 28px; }
  .hero h1 { font-size: 30px; }
  .layout { grid-template-columns: 360px minmax(0, 1fr); gap: 28px; }
  .panel {
    position: sticky; top: calc(var(--header-h) + 16px);
    max-height: calc(100vh - var(--header-h) - 32px); overflow-y: auto;
    overscroll-behavior: contain; scrollbar-width: thin;
    padding-right: 4px;
  }
  .results-col { min-height: 60vh; }
}
@media (min-width: 1100px) {
  .layout { grid-template-columns: 400px minmax(0, 1fr); }
}

/* ---- 카드 ---- */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 2px; }
.card .hint { color: var(--sub); font-size: 13px; margin: 0 0 14px; }

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

/* ---- 입력 ---- */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.field .sub { color: var(--sub); font-weight: 400; font-size: 12px; margin-left: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer; font-family: inherit;
  min-height: 36px; transition: background .12s, border-color .12s;
}
.chips button:hover { border-color: var(--accent); }
.chips button[aria-pressed="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.chips button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.money { display: flex; align-items: center; gap: 8px; }
input[type=number], select {
  width: 100%; font-size: 16px; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-family: inherit;
}
.money span { white-space: nowrap; color: var(--sub); }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); margin-top: 8px; }

details.more summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: ' ▾'; color: var(--sub); }
details.more[open] summary::after { content: ' ▴'; }
details.more .inner { margin-top: 16px; }

/* ---- 결과 ---- */
.result-head { font-size: 14px; font-weight: 600; color: var(--sub); margin: 20px 4px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.result-head:first-child { margin-top: 0; }
.result-head small { font-weight: 400; font-size: 12px; }
.baseline { font-size: 14px; color: var(--sub); }
.baseline b { color: var(--text); }
.baseline .hint-s { font-size: 12px; }

.summary { background: var(--summary-bg); color: #fff; border: 0; }
.summary .k { font-size: 13px; opacity: .85; }
.summary .nums, .policy .nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 20px; margin: 10px 0 12px; }
.summary .l, .policy .l { font-size: 13px; opacity: .85; }
.summary .v { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
.summary .s, .policy .s { font-size: 12px; opacity: .8; }
.summary .d { font-size: 14px; background: rgba(255, 255, 255, .1); border-radius: 10px; padding: 8px 12px; }
.summary .d b { font-weight: 800; }
.policy .l { color: var(--sub); opacity: 1; }
.policy .nums .v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
.policy .s { color: var(--sub); opacity: 1; }
.policy .diff-line { font-size: 14px; color: var(--sub); }
.policy .diff-line .big { font-size: 16px; }

/* 순위 카드: 받는 이자 → 만기에 받는 돈 → 기준보다 얼마 더 (중요한 순서대로 크기) */
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 24px; align-items: start; }
.item .head { display: flex; gap: 12px; min-width: 0; }
.item .rank { font-weight: 800; font-size: 18px; color: var(--accent); width: 20px; flex: none; line-height: 1.4; }
.item .name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.item .bank { color: var(--sub); font-size: 13px; }
.item .money { display: flex; gap: 24px; text-align: right; }
.item .money .l { font-size: 12px; color: var(--sub); white-space: nowrap; }
.item .money .v1, .item .money .v2 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; white-space: nowrap; }
.item .extra { min-width: 0; padding-left: 32px; }
.item .diff { font-size: 13px; color: var(--sub); text-align: right; white-space: nowrap; align-self: start; }
.item .diff b { color: var(--good); font-weight: 700; }
.item .diff.minus b { color: var(--sub); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--bg); color: var(--sub); }
.tag.ok { background: var(--good-soft); color: var(--good); }
.tag.no { text-decoration: line-through; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.item details { margin-top: 8px; font-size: 12px; color: var(--sub); }
.item details summary { cursor: pointer; }
.item details p { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .item { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .item .money { text-align: left; justify-content: space-between; padding-left: 32px; gap: 12px; }
  .item .money .v1, .item .money .v2 { font-size: 21px; }
  .item .diff { text-align: left; padding-left: 32px; white-space: normal; }
  .item .extra { order: 4; }
}

.more-btn {
  display: block; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.more-btn:hover { border-color: var(--accent); }

.policy { border: 1px solid var(--accent-fill); }
.policy .badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; margin-bottom: 8px; }
.badge.eligible { background: var(--good-soft); color: var(--good); }
.badge.check { background: var(--warn-soft); color: var(--warn); }
.badge.no { background: var(--bg); color: var(--sub); }
.policy .big { font-weight: 800; color: var(--good); }
.policy ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--sub); }
.policy .closed { margin-top: 12px; background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

.foot { font-size: 12px; color: var(--sub); margin: 8px 4px; }

/* ---- 핸드폰: 아래에 붙는 결과 바 ---- */
.mobile-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--text); color: var(--bg); text-decoration: none;
  padding: 14px 18px; border-radius: 14px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.mobile-bar[hidden] { display: none; }
.mobile-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-bar b { white-space: nowrap; }
@media (min-width: 860px) { .mobile-bar { display: none !important; } }

/* ---- 가이드 ---- */
article { padding: 28px 0 0; }
article h1 { font-size: 26px; line-height: 1.3; margin: 0 0 4px; }
article .meta { color: var(--sub); font-size: 13px; margin-bottom: 20px; }
article h2 { font-size: 18px; margin: 0 0 10px; }
article table { width: 100%; border-collapse: collapse; font-size: 14px; }
article th, article td { text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
article th { width: 34%; color: var(--sub); font-weight: 500; padding-right: 12px; }
article ol, article ul { padding-left: 20px; margin: 0; }
article li { margin-bottom: 6px; }
article .foot { margin: 24px 0 0; }
@media (min-width: 860px) {
  article { padding-top: 40px; }
  article h1 { font-size: 32px; }
}
.cta { display: block; text-align: center; background: var(--accent-fill); color: #fff; text-decoration: none; font-weight: 700; padding: 14px; border-radius: 12px; margin: 20px 0; }

/* ---- 탭: 예적금 비교 / 청년 정책상품 ---- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 16px; max-width: 100%; }
.tabs button {
  border: 0; background: none; color: var(--sub); font: inherit; font-size: 15px; font-weight: 600;
  padding: 9px 16px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--accent-fill); color: #fff; }
@media (max-width: 480px) { .tabs { display: flex; } .tabs button { flex: 1; padding: 9px 8px; } }
body[data-mode="savings"] [data-only="policy"],
body[data-mode="policy"] [data-only="savings"] { display: none !important; }
.teaser { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-decoration: none; color: var(--text); border: 1px dashed var(--accent); background: var(--accent-soft); box-shadow: none; }
.teaser b { color: var(--accent); white-space: nowrap; }
/* 핸드폰에서 머리 메뉴는 탭과 겹치니 가이드만 남긴다 */
@media (max-width: 600px) { .site-header nav a[data-tab-link] { display: none; } }

/* ---- 청년미래적금 월 한도 강조 ---- */
.hint .cap { color: var(--accent); }
.cap-note { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600; }
.cap-note[hidden] { display: none; }
.policy .cap-box { margin: 4px 0 12px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.policy .cap-box b { color: inherit; }
.policy .cap-box a { color: inherit; font-weight: 700; }
