/* ============================================================
   뚝딱계산기 — 공용 디자인 시스템
   ============================================================ */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface2: #f2f4f6;
  --border: #e5e8eb;
  --text: #191f28;
  --text2: #4e5968;
  --text3: #8b95a1;
  --accent: #3182f6;
  --accent-strong: #1b64da;
  --accent-soft: #e8f1fe;
  --good: #0ca678;
  --warn: #e8590c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(25, 31, 40, .06), 0 8px 24px rgba(25, 31, 40, .05);
}
:root[data-theme="dark"] {
  --bg: #101418;
  --surface: #1a2027;
  --surface2: #232b33;
  --border: #2c353f;
  --text: #ecf0f3;
  --text2: #b0b8c1;
  --text3: #798492;
  --accent: #4593fc;
  --accent-strong: #6aa8fd;
  --accent-soft: #1d3252;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101418;
    --surface: #1a2027;
    --surface2: #232b33;
    --border: #2c353f;
    --text: #ecf0f3;
    --text2: #b0b8c1;
    --text3: #798492;
    --accent: #4593fc;
    --accent-strong: #6aa8fd;
    --accent-soft: #1d3252;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 헤더 ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.site-header .wrap {
  max-width: 960px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.logo { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.logo:hover { text-decoration: none; }
.logo span { color: var(--accent); }
.theme-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--text);
}

/* ---------- 계산기 바로가기 칩바 ---------- */
.chipbar {
  max-width: 960px; margin: 0 auto; padding: 12px 20px 0;
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chipbar::-webkit-scrollbar { display: none; }
.chipbar a {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text2); font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.chipbar a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.chipbar a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 레이아웃 ---------- */
.container { max-width: 720px; margin: 0 auto; padding: 24px 20px 64px; }
.container.wide { max-width: 960px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin: 16px 0 6px; }
.page-desc { color: var(--text2); font-size: 15px; margin: 0 0 20px; }
.badge-year {
  display: inline-block; background: var(--accent-soft); color: var(--accent-strong);
  font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  vertical-align: middle; margin-left: 6px;
}

/* ---------- 계산기 카드 ---------- */
.calc-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 14px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input, .input-wrap select {
  width: 100%; padding: 13px 44px 13px 14px;
  font-size: 17px; font-weight: 600; color: var(--text);
  background: var(--surface2); border: 1.5px solid transparent; border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, background .15s;
  font-family: inherit;
}
.input-wrap select { padding-right: 14px; appearance: auto; }
.input-wrap input:focus, .input-wrap select:focus { border-color: var(--accent); background: var(--surface); }
.input-wrap .suffix {
  position: absolute; right: 14px; color: var(--text3); font-size: 14px; font-weight: 600;
  pointer-events: none;
}
.num-reading { min-height: 18px; margin-top: 5px; font-size: 13px; font-weight: 600; color: var(--accent); }
.field .hint { margin-top: 5px; font-size: 12.5px; color: var(--text3); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; gap: 0; } }

/* 세그먼트 토글 */
.seg { display: flex; background: var(--surface2); border-radius: var(--radius-sm); padding: 4px; gap: 4px; }
.seg button {
  flex: 1; padding: 9px 4px; border: none; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--text3); font-size: 14px; font-weight: 700; font-family: inherit;
  transition: all .15s;
}
.seg button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* 체크박스 */
.check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text2); cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* 버튼 */
.btn-primary {
  display: block; width: 100%; margin-top: 22px; padding: 15px;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 16.5px; font-weight: 800; cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-strong); }

/* ---------- 결과 ---------- */
.result { display: none; margin-top: 20px; }
.result.show { display: block; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.result-hero {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-radius: var(--radius); padding: 24px; color: #fff; text-align: center;
}
.result-hero .lbl { font-size: 14px; font-weight: 600; opacity: .85; }
.result-hero .val { font-size: 34px; font-weight: 800; letter-spacing: -1px; margin-top: 4px; }
.result-hero .sub { font-size: 13.5px; opacity: .8; margin-top: 6px; }
@media (max-width: 520px) { .result-hero .val { font-size: 28px; } }

.result-table {
  width: 100%; margin-top: 14px; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; font-size: 14.5px;
}
.result-table th, .result-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.result-table tr:last-child th, .result-table tr:last-child td { border-bottom: none; }
.result-table th { color: var(--text2); font-weight: 600; width: 46%; }
.result-table td { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-table tr.total th, .result-table tr.total td { background: var(--surface2); color: var(--text); font-weight: 800; }
.result-table td.minus { color: var(--warn); }
.result-table td.plus { color: var(--good); }

/* 스케줄 표 (대출 등) */
.schedule-wrap {
  margin-top: 14px; max-height: 420px; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.schedule-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.schedule-wrap th, .schedule-wrap td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.schedule-wrap th { background: var(--surface2); color: var(--text2); position: sticky; top: 0; font-weight: 700; }
.schedule-wrap td:first-child, .schedule-wrap th:first-child { text-align: center; color: var(--text3); }

/* ---------- 광고 자리 ---------- */
.ad-slot {
  margin: 28px 0; min-height: 100px; border: 2px dashed var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 12px; letter-spacing: 2px; background: var(--surface);
}

/* ---------- 본문 콘텐츠 (SEO) ---------- */
.content-section { margin-top: 40px; }
.content-section h2 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; margin: 32px 0 12px; }
.content-section p { color: var(--text2); font-size: 15px; margin: 10px 0; }
.content-section ul, .content-section ol { color: var(--text2); font-size: 15px; padding-left: 22px; }
.content-section li { margin: 6px 0; }
.info-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 14px 0; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.info-table th, .info-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.info-table thead th { background: var(--surface2); font-weight: 700; color: var(--text2); }
.info-table tbody tr:last-child th, .info-table tbody tr:last-child td { border-bottom: none; }
.info-table td { color: var(--text2); }
.table-scroll { overflow-x: auto; }
.table-scroll .info-table { min-width: 480px; }

/* FAQ */
details.faq {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 18px; margin: 10px 0;
}
details.faq summary {
  cursor: pointer; font-weight: 700; font-size: 15px; padding: 15px 0;
  list-style: none; position: relative; padding-right: 24px;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: "+"; position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  color: var(--text3); font-size: 18px; font-weight: 400;
}
details.faq[open] summary::after { content: "−"; }
details.faq p { color: var(--text2); font-size: 14.5px; margin: 0 0 15px; }

/* ---------- 관련 계산기 그리드 ---------- */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; }
.calc-item {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; color: var(--text);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.calc-item:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.calc-item .ico { font-size: 26px; }
.calc-item .name { font-weight: 800; font-size: 15.5px; margin-top: 8px; letter-spacing: -.3px; }
.calc-item .desc { font-size: 13px; color: var(--text3); margin-top: 3px; line-height: 1.45; }

/* ---------- 홈 히어로 ---------- */
.home-hero { text-align: center; padding: 44px 0 28px; }
.home-hero h1 { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin: 0; }
.home-hero h1 em { font-style: normal; color: var(--accent); }
.home-hero p { color: var(--text2); font-size: 16px; margin: 10px 0 0; }
@media (max-width: 520px) { .home-hero h1 { font-size: 26px; } }
.home-section-title { font-size: 18px; font-weight: 800; margin: 36px 0 4px; letter-spacing: -.4px; }

/* ---------- 푸터 ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; background: var(--surface); }
.site-footer .wrap { max-width: 960px; margin: 0 auto; padding: 28px 20px; }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13.5px; margin-bottom: 14px; }
.site-footer .links a { color: var(--text2); }
.site-footer .notice { font-size: 12.5px; color: var(--text3); line-height: 1.7; margin: 0; }

/* 유틸 */
.mt0 { margin-top: 0; }
.hidden { display: none !important; }
textarea.big {
  width: 100%; min-height: 260px; padding: 16px; resize: vertical;
  background: var(--surface2); border: 1.5px solid transparent; border-radius: var(--radius-sm);
  font-size: 15.5px; color: var(--text); font-family: inherit; line-height: 1.7; outline: none;
}
textarea.big:focus { border-color: var(--accent); background: var(--surface); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; text-align: center;
}
.stat .k { font-size: 12.5px; color: var(--text3); font-weight: 600; }
.stat .v { font-size: 21px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat .v small { font-size: 12px; color: var(--text3); font-weight: 600; }
