/* ===== 투자 계산기 — 디자인 토큰 ===== */
:root {
  --bg: #0b1120;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #16203a 0%, #0b1120 55%);
  --panel-bg: #111a2e;
  --panel-bg-2: #0e1728;
  --input-bg: #0d1526;
  --border: #22304d;
  --border-soft: #1a2540;
  --text: #eef2fb;
  --text-muted: #9fb0cf;
  --text-dim: #6b7a99;
  --accent: #f5c542;          /* 골드 */
  --accent-strong: #ffd86b;
  --accent-contrast: #1a1204;
  --brand: #4e8cff;           /* 포인트 블루 */
  --profit: #22c993;          /* 수익 */
  --profit-bg: #0f2a22;
  --loss: #ff5d6c;            /* 손실 */
  --loss-bg: #2a1017;
  --chip-bg: #16223c;
  --shadow: 0 18px 50px rgba(0,0,0,.45);
  --radius: 16px;
  --radius-sm: 10px;
}
:root[data-theme="light"] {
  --bg: #eef1f7;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, #eef1f7 55%);
  --panel-bg: #ffffff;
  --panel-bg-2: #f6f8fc;
  --input-bg: #f1f4fa;
  --border: #d8deea;
  --border-soft: #e6ebf4;
  --text: #131a2b;
  --text-muted: #55627c;
  --text-dim: #8a94ab;
  --accent: #d99a00;
  --accent-strong: #c98a00;
  --accent-contrast: #ffffff;
  --brand: #2f6bde;
  --profit: #0f9d63;
  --profit-bg: #e4f7ee;
  --loss: #d83a4a;
  --loss-bg: #fbe7e9;
  --chip-bg: #eef2fa;
  --shadow: 0 12px 34px rgba(30,42,70,.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== 광고 레일 (승인 후 코드 삽입) ===== */
.ad-rail {
  display: none;
  position: fixed;
  top: 90px;
  width: 160px;
  min-height: 600px;
}
.ad-rail-left { left: 12px; }
.ad-rail-right { right: 12px; }
@media (min-width: 1400px) { .ad-rail { display: block; } }

/* ===== 레이아웃 ===== */
.app { max-width: 880px; margin: 0 auto; padding: 0 18px 80px; }

header.site {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand .logo { width: 30px; height: 30px; }
.theme-toggle {
  background: var(--chip-bg); color: var(--text); border: 1px solid var(--border);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 17px;
  transition: .15s;
}
.theme-toggle:hover { border-color: var(--accent); }

.sibling-nav {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin: 4px 0 0;
}
.sibling-nav-link {
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--text-muted);
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  text-decoration: none; transition: .15s;
}
.sibling-nav-link:hover { border-color: var(--accent); color: var(--accent-strong); }

.hero { text-align: center; padding: 14px 0 22px; }
.hero h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.25; margin: 0 0 10px; letter-spacing: -.03em; }
.hero h1 .hl { color: var(--accent); }
.hero p { color: var(--text-muted); margin: 0 auto; max-width: 560px; font-size: 15.5px; }

/* ===== 탭 ===== */
.tabs {
  display: flex; flex-direction: column; gap: 16px;
  margin: 6px 0 24px; padding: 16px; border-radius: var(--radius);
  background: var(--panel-bg-2); border: 1px solid var(--border-soft);
}
.tab-search { margin-bottom: 4px; }
.tab-search input { padding: 12px 16px; }
.tab-empty { text-align: center; color: var(--text-dim); font-size: 13.5px; padding: 10px 0 2px; margin: 0; }
.tab-group { display: flex; flex-direction: column; gap: 9px; }
.tab-group-label {
  font-size: 12px; font-weight: 800; color: var(--text-dim);
  letter-spacing: .04em; text-align: center; text-transform: uppercase;
}
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tab {
  border: 1px solid var(--border); background: var(--panel-bg); color: var(--text-muted);
  padding: 11px 16px; border-radius: 999px; cursor: pointer; font-size: 14.5px; font-weight: 600;
  transition: .15s; display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: var(--accent-contrast); border-color: transparent; box-shadow: 0 6px 18px rgba(245,197,66,.28);
}

/* ===== 패널 ===== */
.panel {
  background: linear-gradient(180deg, var(--panel-bg), var(--panel-bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow);
}
.panel.hidden { display: none; }
.panel h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.panel .sub { color: var(--text-muted); font-size: 14px; margin: 0 0 20px; }

/* ===== 입력 ===== */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .unit {
  position: absolute; right: 12px; color: var(--text-dim); font-size: 13px; pointer-events: none;
}
input[type="number"], input[type="text"], select {
  width: 100%; background: var(--input-bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 12px 40px 12px 13px;
  font-size: 16px; font-variant-numeric: tabular-nums; transition: .15s;
  -moz-appearance: textfield;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,197,66,.15); }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select { padding-right: 13px; cursor: pointer; }

.seg { display: flex; gap: 6px; background: var(--input-bg); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
.seg button {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  padding: 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 600; transition: .12s;
}
.seg button.active { background: var(--brand); color: #fff; }

.actions { display: flex; gap: 10px; margin-top: 20px; }
.btn {
  flex: 1; border: none; border-radius: var(--radius-sm); padding: 14px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: .15s;
}
.btn-primary { background: linear-gradient(180deg, var(--accent-strong), var(--accent)); color: var(--accent-contrast); }
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost { flex: 0 0 auto; background: var(--chip-bg); color: var(--text-muted); border: 1px solid var(--border); padding: 14px 18px; }
.btn-ghost:hover { color: var(--text); }

/* ===== 결과 ===== */
.result { margin-top: 22px; border-top: 1px dashed var(--border); padding-top: 20px; }
.result-hero {
  text-align: center; padding: 18px; border-radius: var(--radius-sm); margin-bottom: 16px;
  background: var(--chip-bg); border: 1px solid var(--border-soft);
}
.result-hero .label { font-size: 13px; color: var(--text-muted); }
.result-hero .value { font-size: clamp(26px, 6vw, 34px); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.result-hero.profit { background: var(--profit-bg); border-color: var(--profit); }
.result-hero.profit .value { color: var(--profit); }
.result-hero.loss { background: var(--loss-bg); border-color: var(--loss); }
.result-hero.loss .value { color: var(--loss); }

.rows { display: grid; gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: hidden; }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 15px; background: var(--panel-bg); font-size: 14.5px;
}
.row .k { color: var(--text-muted); }
.row .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.row .v.profit { color: var(--profit); }
.row .v.loss { color: var(--loss); }
.row.total { background: var(--panel-bg-2); }
.row.total .v { font-size: 16px; }

.chartbox { margin-top: 16px; }
.chartbox svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.hint { font-size: 12.5px; color: var(--text-dim); margin-top: 14px; text-align: center; }

.page-nav-fab {
  /* .app의 max-width(880px)가 뷰포트 중앙에 있으니, 그 오른쪽 바깥에 바짝 붙인다.
     뷰포트가 넓을수록 브라우저 가장자리가 아니라 실제 콘텐츠 옆에 떠 있어야
     내용과 연관돼 보인다. 좁은 화면에서는 아래 미디어쿼리로 고정폭으로 전환. */
  position: fixed; right: max(16px, calc(50vw - 440px - 16px)); top: 50%; transform: translateY(-50%);
  z-index: 40; display: flex; flex-direction: column; gap: 10px;
}
.page-nav-btn {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--text);
  border-radius: 50%; cursor: pointer; font-size: 19px; line-height: 1;
  box-shadow: var(--shadow); transition: .15s;
}
.page-nav-btn:hover { border-color: var(--accent); color: var(--accent-strong); transform: scale(1.06); }
#scrollTopFab { display: none; } /* 스크롤 좀 내려가야 의미 있어서 JS가 필요할 때만 보여준다 */
@media (max-width: 560px) {
  .page-nav-fab { right: 10px; }
  .page-nav-btn { width: 38px; height: 38px; font-size: 16px; }
}

.share-wrap { margin-top: 18px; text-align: center; }
.share-wrap .share-btn { min-width: 180px; }
.related { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border); }
.related-label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 9px; }
.related-links { display: flex; gap: 8px; flex-wrap: wrap; }
.related-link {
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--text);
  padding: 9px 14px; border-radius: 999px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: .15s; display: inline-block; text-decoration: none;
}
.related-link:hover { border-color: var(--accent); color: var(--accent-strong); }
.err { color: var(--loss); font-size: 13.5px; margin-top: 12px; text-align: center; display: none; }
.err.show { display: block; }

/* ===== 설명(SEO) 콘텐츠 ===== */
.info { margin-top: 46px; }
.info h3 { font-size: 18px; margin: 30px 0 10px; letter-spacing: -.02em; }
.info p, .info li { color: var(--text-muted); font-size: 14.5px; }
.info .faq { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-top: 12px; }
.info details { border-bottom: 1px solid var(--border-soft); background: var(--panel-bg); }
.info details:last-child { border-bottom: none; }
.info summary { padding: 14px 16px; cursor: pointer; font-weight: 600; color: var(--text); list-style: none; }
.info summary::-webkit-details-marker { display: none; }
.info summary::after { content: "+"; float: right; color: var(--accent); }
.info details[open] summary::after { content: "–"; }
.info details p { padding: 0 16px 14px; margin: 0; }

footer.site { text-align: center; color: var(--text-dim); font-size: 12.5px; padding: 40px 0 10px; }
footer.site a { color: var(--text-muted); text-decoration: none; }
footer.site a:hover { color: var(--accent); }
footer.site .sibling-sites { margin-top: 8px; }

/* ===== 반응형 ===== */
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .panel { padding: 20px 16px; }
}

/* ================= 계산기 아래 본문 글 =================
   계산기만 있고 읽을 글이 없어서 "가치가 별로 없는 콘텐츠" 판정을 받았다.
   tools/build-articles.js 가 넣는 <article class="guide"> 영역의 스타일. */
.guide {
  max-width: 760px;
  margin: 34px auto 0;
  padding: 26px 28px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.9;
  color: var(--text-muted);
}

.guide h2 {
  margin: 34px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 20px;
  color: var(--text);
}
.guide h2:first-child { margin-top: 0; }
.guide h3 { margin: 26px 0 8px; font-size: 16px; color: var(--text); }
.guide p { margin: 0 0 14px; font-size: 15px; }
.guide strong { color: var(--text); }
.guide a { color: var(--brand); }
.guide ul, .guide ol { margin: 8px 0 16px; padding-left: 22px; font-size: 15px; }
.guide li { margin-bottom: 8px; }

.guide-table-wrap { overflow-x: auto; margin: 14px 0 20px; }
.guide-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 420px; }
.guide-table th, .guide-table td {
  border: 1px solid var(--border-soft);
  padding: 9px 12px;
  text-align: left;
  color: var(--text-muted);
  white-space: nowrap;
}
.guide-table thead th { background: var(--chip-bg); color: var(--text); font-weight: 700; }
.guide-table tbody th { background: var(--panel-bg-2); color: var(--text); font-weight: 600; }

.guide-note {
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--panel-bg-2);
  font-size: 14px;
}

.guide-faq {
  margin: 8px 0;
  padding: 12px 14px;
  background: var(--panel-bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.guide-faq summary { cursor: pointer; color: var(--text); font-weight: 600; font-size: 15px; }
.guide-faq p { margin: 10px 0 0; font-size: 14px; }

/* 기준 시점과 출처. 세금 글에서 이게 없으면 언제 기준인지 알 수 없어 쓸모가 없다. */
.guide-meta {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
}
.guide-meta p { margin: 0 0 8px; font-size: 13px; }
.guide-sources a { margin-right: 4px; }
.guide-disclaimer { color: var(--text-dim); }

@media (max-width: 560px) {
  .guide { padding: 20px 16px; margin-top: 24px; }
  .guide h2 { font-size: 18px; }
  .guide p, .guide li { font-size: 14px; }
}
