:root {
  --bg: #0a0e13; --panel: #11171f; --panel2: #161e28; --line: #232e3b; --text: #e7edf3; --muted: #8a97a6;
  --accent: #3d8bfd; --up: #f04452; --down: #3182f6; --warn: #f5a524; --ok: #2ecc8f;
  --r: 14px; --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
html[lang="en"] { --up: #16c784; --down: #ea3943; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.6;
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* 머리말 */
.top { border-bottom: 1px solid var(--line); background: rgba(10, 14, 19, .9); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(8px); }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.logo { font-weight: 800; letter-spacing: -.02em; color: var(--text); font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo svg { width: 22px; height: 22px; }
.logo:hover { text-decoration: none; }
.nav { display: flex; gap: 14px; margin-left: auto; font-size: 14px; }
.nav a { color: var(--muted); }
.nav a[aria-current="page"], .nav a:hover { color: var(--text); text-decoration: none; }
.lang { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }

/* 광고 자리 — 흐름 안에만 둔다(덮지 않음). 광고가 꺼져 있으면 숨김 */
.ad { display: none; }
.ads-on .ad, .ad-preview .ad { display: flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--muted); font-size: 12px; overflow: hidden; }
.ad-preview .ad { border: 1px dashed #3a4757; background: repeating-linear-gradient(45deg, #0f141b, #0f141b 10px, #121922 10px, #121922 20px); }
.ad-preview .ad::before { content: attr(data-label); }
.ad-top { min-height: 100px; margin: 16px 0 0; }
.ad-result { min-height: 250px; margin: 16px 0; }
.ad-side { min-height: 600px; position: sticky; top: 72px; }

/* 좌우 레일 — 본문 바깥 여백에만, 넓은 화면(1500px+)에서만. 광고 여러 개를 세로로 쌓는다 */
.rail { display: none; }
@media (min-width: 1500px) {
  .frame { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1120px) minmax(0, 1fr); column-gap: 8px; }
  .rail { display: flex; flex-direction: column; gap: 24px; padding: 16px 0 48px; }
  .rail-l { align-items: flex-end; } .rail-r { align-items: flex-start; }
  .ad-rail { width: 160px; min-height: 600px; flex: none; }
}

/* 본문 배치 */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; padding: 24px 0 48px; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } .side { display: none; } .ad-top { min-height: 60px; } }
h1 { font-size: clamp(24px, 4vw, 34px); line-height: 1.25; letter-spacing: -.02em; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 20px; }

/* 계산기 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { all: unset; cursor: pointer; padding: 7px 14px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: #243244; color: var(--text); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field { position: relative; }
input[type="text"] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  padding: 12px 44px 12px 12px; font: 600 18px/1.2 var(--mono); font-variant-numeric: tabular-nums;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61, 139, 253, .2); }
.unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.mode { margin: 18px 0 12px; }
.second { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details .grid input { font-size: 15px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 결과 */
.result { margin-top: 18px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.big { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.big .v { font: 800 clamp(30px, 6vw, 42px)/1.1 var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.badge { font: 600 14px var(--mono); padding: 3px 8px; border-radius: 6px; background: #1c2633; }
.up { color: var(--up); } .down { color: var(--down); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin-top: 16px; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } }
.kv div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font: 600 14px var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.msg { color: var(--warn); font-size: 14px; }
.bar { position: relative; height: 34px; margin: 20px 0 6px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.bar i { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; }
.bar i::after { content: attr(data-l); position: absolute; top: 40px; transform: translateX(-50%); font: 11px var(--mono); color: var(--muted); white-space: nowrap; }
.bar .pin-old { background: var(--muted); } .bar .pin-new { background: var(--accent); width: 3px; } .bar .pin-now { background: var(--warn); }
.bar .pin-old::after { top: -18px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 26px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 3px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.legend .l-old { color: var(--muted); } .legend .l-new { color: var(--accent); } .legend .l-now { color: var(--warn); }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn { all: unset; cursor: pointer; padding: 9px 14px; border-radius: 10px; background: #1d2a3a; color: var(--text); font-size: 14px; font-weight: 600; }
.btn:hover { background: #24364b; } .btn:focus-visible { outline: 2px solid var(--accent); }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* 글 */
.prose { max-width: 720px; }
.prose h2 { font-size: 21px; margin: 32px 0 8px; letter-spacing: -.01em; }
.prose h3 { font-size: 17px; margin: 22px 0 6px; }
.prose p, .prose li { color: #cdd6df; }
.prose code, .prose .formula { font-family: var(--mono); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.prose .formula { display: block; padding: 12px 14px; margin: 12px 0; overflow-x: auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 12px 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.prose th { background: var(--panel2); }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.guides { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.guides a { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }
.guides a:hover { border-color: #33465c; text-decoration: none; }
.guides small { display: block; color: var(--muted); }
.side h2 { font-size: 14px; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.side .guides { margin-bottom: 20px; }
.cta { margin-top: 28px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }

.foot { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 13px; }
.foot nav { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.foot a { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: no-preference) { .result { transition: border-color .2s; } }
