/* interest.speech.pe.kr — 복리 계산기
   토큰 체계는 ip.speech.pe.kr / seo.speech.pe.kr 과 동일하게 맞췄다.
   차트 계열색(--series-*)은 dataviz 검증기를 통과한 값이다:
     light #2a78d6 / #eb6834  (surface #ffffff)  adjacent CVD ΔE 24.7
     dark  #3987e5 / #d95926  (surface #1a1d24)  adjacent CVD ΔE 26.8 */

:root {
  --bg: #f2f3f6;
  --bg-glow: #e7eaf3;
  --card-bg: #ffffff;
  --card-border: #e3e5ea;
  --text: #1c1e24;
  --text-muted: #6b6f7b;
  --text-faint: #9498a3;
  --accent: #3b6ff0;
  --accent-contrast: #ffffff;
  --badge-bg: #eef2fe;
  --badge-text: #3b6ff0;
  --error: #d33d3d;
  --field-bg: #fbfbfd;
  --field-border: #d9dce4;
  --grid-line: #e9ebf0;

  --series-principal: #2a78d6;
  --series-principal-fill: rgba(42, 120, 214, 0.22);
  --series-interest: #eb6834;
  --series-interest-fill: rgba(235, 104, 52, 0.26);

  --shadow: 0 1px 2px rgba(20, 22, 30, 0.04), 0 12px 28px -14px rgba(20, 22, 30, 0.18);
  --radius-lg: 20px;
  --radius-md: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101217;
    --bg-glow: #171a21;
    --card-bg: #1a1d24;
    --card-border: #2a2e38;
    --text: #eef0f4;
    --text-muted: #9599a6;
    --text-faint: #6c7080;
    --accent: #6d93f7;
    --accent-contrast: #10131a;
    --badge-bg: #1c2333;
    --badge-text: #8caaf9;
    --error: #f28b8b;
    --field-bg: #14171d;
    --field-border: #333845;
    --grid-line: #262b35;

    --series-principal: #3987e5;
    --series-principal-fill: rgba(57, 135, 229, 0.26);
    --series-interest: #d95926;
    --series-interest-fill: rgba(217, 89, 38, 0.30);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 20px 40px -20px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.65;
  font-size: 16px;
}

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-contrast);
  padding: 10px 16px; border-radius: 0 0 var(--radius-md) 0; z-index: 10;
}
.skip-link:focus { left: 0; }

/* ---------- 헤더 ---------- */

.site-head { padding: 48px 0 28px; }
.eyebrow {
  margin: 0 0 10px;
  display: inline-block;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--badge-text); background: var(--badge-bg);
  padding: 4px 10px; border-radius: 999px;
}
.site-head h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.2; letter-spacing: -0.02em;
}
.lede { margin: 0; color: var(--text-muted); max-width: 60ch; }
.lede strong { color: var(--text); font-weight: 600; }

/* ---------- 카드 ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.01em; }
.card-sub { margin: 0 0 18px; color: var(--text-muted); font-size: 14px; }
.card-title + .grid, .card-title + form { margin-top: 18px; }

/* ---------- 폼 ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px 20px;
}
.field label {
  display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px;
}
.optional { font-weight: 400; color: var(--text-faint); }

.input-money { position: relative; display: block; }
.input-money .unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 14px; pointer-events: none;
}
input[type="text"], select {
  width: 100%;
  padding: 11px 42px 11px 14px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  transition: border-color .15s, box-shadow .15s;
}
select { padding-right: 14px; text-align: left; }
input[type="text"]:focus, select:focus, button:focus-visible, summary:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input.invalid { border-color: var(--error); }

.hint { margin: 7px 0 0; font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }
.calc-note { margin-top: 12px; }

.switch-row {
  margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--card-border);
}
.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.error { margin: 14px 0 0; color: var(--error); font-size: 14px; font-weight: 600; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.btn-ghost {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 16px; border-radius: var(--radius-md);
  color: var(--text); background: var(--field-bg);
  border: 1px solid var(--field-border); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost[data-done="1"] { color: var(--accent); border-color: var(--accent); }

/* ---------- 결과 ---------- */

.hero-label { margin: 18px 0 0; font-size: 13px; color: var(--text-muted); font-weight: 600; }
.hero-sub { color: var(--text-faint); font-weight: 400; }
.hero {
  margin: 2px 0 0;
  font-size: clamp(30px, 8vw, 46px);
  font-weight: 700; letter-spacing: -0.03em; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.hero-korean { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; margin: 24px 0 0; padding: 1px;
  background: var(--card-border); border-radius: var(--radius-md); overflow: hidden;
}
.stat { background: var(--card-bg); padding: 14px 16px; }
.stat dt { font-size: 12.5px; color: var(--text-muted); margin-bottom: 3px; }
.stat dd {
  margin: 0; font-size: 17px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}

/* ---------- 차트 ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.swatch-principal { background: var(--series-principal); }
.swatch-interest { background: var(--series-interest); }
.legend-note { color: var(--text-faint); }

.chart-figure { margin: 0; }
.chart-holder { position: relative; width: 100%; touch-action: pan-y; }
#chart { display: block; width: 100%; height: 260px; overflow: visible; }

.tooltip {
  position: absolute; z-index: 3; pointer-events: none;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px; box-shadow: var(--shadow);
  padding: 9px 12px; font-size: 12.5px; line-height: 1.55;
  white-space: nowrap; font-variant-numeric: tabular-nums;
  transform: translate(-50%, -100%);
}
.tooltip b { display: block; font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 3px; }
.tooltip .row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .row span:last-child { font-weight: 600; }
.tooltip .dot { width: 8px; height: 8px; border-radius: 2px; flex: none; margin-right: -2px; }

.table-details { margin-top: 20px; border-top: 1px solid var(--card-border); padding-top: 14px; }
.table-details summary { cursor: pointer; font-size: 14px; font-weight: 600; border-radius: 6px; }
.table-scroll { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--card-border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; font-weight: 600; }

/* ---------- 본문 ---------- */

.prose h3 { margin: 26px 0 8px; font-size: 15.5px; letter-spacing: -0.01em; }
.prose h3:first-of-type { margin-top: 20px; }
.prose p, .prose li { color: var(--text-muted); font-size: 15px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose em { color: var(--text); font-style: normal; border-bottom: 2px solid var(--badge-bg); }
.prose ul { margin: 8px 0 0; padding-left: 20px; }
.prose li { margin-bottom: 6px; }

/* ---------- 광고 ---------- */

.ad-slot { margin: 0 0 20px; min-height: 0; text-align: center; }
.ad-slot:empty { display: none; }
.ad-slot ins { display: block; }

/* ---------- 푸터 ---------- */

.site-foot { padding: 12px 0 56px; }
.site-foot p { margin: 0 0 10px; font-size: 13px; color: var(--text-faint); }
.site-foot strong { color: var(--text-muted); }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; }
.site-foot a { color: var(--text-muted); text-decoration: none; border-bottom: 1px solid var(--card-border); }
.site-foot a:hover { color: var(--accent); border-color: var(--accent); }
.foot-legal { line-height: 1.6; }

@media (max-width: 480px) {
  .card { padding: 20px 16px; border-radius: 16px; }
  .site-head { padding: 32px 0 20px; }
  #chart { height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
