/* ZapyLab — 봄 새벽 하늘과 서풍 */
:root {
  --sky-1: #eaf0fa;          /* 하늘 위쪽 */
  --sky-2: #f8eef2;          /* 지평선의 꽃빛 */
  --ink: #161a3a;            /* 깊은 남색 */
  --ink-2: #4a5078;
  --ink-3: #7d83a6;
  --rule: rgba(22, 26, 58, 0.12);
  --wind: #3b5b85;           /* 바람: 차분한 청회색 */
  --blossom: #a8697b;        /* 꽃잎: 톤 다운한 장밋빛 */
  --veil: rgba(238, 242, 250, 0.72);
  --panel: rgba(255, 255, 255, 0.55);
  --code-bg: #161a3a;
  --code-ink: #e8ebfa;
  --display: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", "Noto Sans CJK KR", "Nanum Gothic", "Segoe UI", Roboto, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", "Noto Sans CJK KR", "Nanum Gothic", "Segoe UI", Roboto, sans-serif;   /* 기기에 이미 있는 고딕 글꼴. 내려받는 글꼴 없음 */
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky-1: #12163a;
    --sky-2: #251c47;
    --ink: #eef0fb;
    --ink-2: #b9bedb;
    --ink-3: #8a90b4;
    --rule: rgba(238, 240, 251, 0.14);
    --wind: #a8bcd9;
    --blossom: #d9afbb;
    --veil: rgba(18, 22, 58, 0.7);
    --panel: rgba(255, 255, 255, 0.05);
    --code-bg: #0b0e28;
  }
}

@view-transition { navigation: auto; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--sky-2); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.8;
  word-break: keep-all;
  overflow-wrap: break-word;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--wind); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--wind); outline-offset: 3px; border-radius: 4px; }

/* 하늘 (고정 배경). background-attachment: fixed 는 휴대폰에서 스크롤을 버벅이게 해서 쓰지 않음 */
body::before {
  content: ""; position: fixed; left: 0; top: 0; width: 100%;
  height: 100vh; height: 100lvh;
  z-index: -2; pointer-events: none;
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 100%);
}
/* 3D 바람 배경. 높이를 lvh 로 고정해 휴대폰 주소창이 접혀도 크기가 변하지 않게 함 */
#wind {
  position: fixed; left: 0; top: 0; width: 100%;
  height: 100vh; height: 100lvh;
  z-index: -1; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
}
#wind.on { opacity: 1; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 28px; }
.wrap-narrow { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 22px; }

/* 헤더 */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--veil);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--rule);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 34px; height: 34px; }
.brand b { font-weight: 400; }
.site-nav { display: flex; align-items: center; gap: 26px; font-size: 15px; }
.site-nav a { color: var(--ink-2); }
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav .lang { padding: 5px 13px; border: 1px solid var(--rule); border-radius: 999px; color: var(--ink); font-size: 14px; }
.site-nav .lang:hover { border-color: var(--wind); color: var(--wind); }

/* 홈 */
.hero { min-height: calc(100vh - 64px); min-height: calc(100svh - 64px); display: flex; flex-direction: column; justify-content: center; padding-top: 40px; padding-bottom: 24vh; }
.hero h1 {
  font-family: var(--display);
  font-size: clamp(36px, 6.4vw, 84px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin: 0 0 28px;
}
/* 윗줄은 글자색, 아랫줄은 차분한 청회색 */
.hero h1 span + span { color: var(--wind); }
.hero h1 span { display: block; }
.hero h1 span + span { padding-left: 1.1em; }   /* 바람에 한 칸 밀린 둘째 줄 */
.lead { font-size: clamp(17px, 1.6vw, 20px); color: var(--ink-2); max-width: 34em; margin: 0; }
.hero .more { margin-top: 36px; }
.button { display: inline-block; padding: 12px 24px; border-radius: 999px; background: var(--ink); color: var(--sky-1); font-weight: 600; font-size: 15px; }
.button:hover { text-decoration: none; background: var(--wind); }

.section { padding-bottom: 96px; }
.section-title, .page-title { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; }
.list-page { padding-top: 72px; }

/* 글 목록: 한 줄에 한 편 */
.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.post-row { display: grid; grid-template-columns: 4.2rem 1fr auto; gap: 8px 24px; align-items: baseline; padding: 28px 0; border-bottom: 1px solid var(--rule); color: var(--ink); }
.post-row:hover { text-decoration: none; }
.post-row .no { font-family: var(--display); font-size: 30px; font-weight: 300; color: var(--ink-3); line-height: 1; }
.post-row .cat { display: block; font-size: 13.5px; font-weight: 600; color: var(--wind); margin-bottom: 4px; }
.post-row h3 { font-family: var(--display); font-size: clamp(20px, 2.4vw, 26px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.4; margin: 0 0 6px; transition: color .15s; }
.post-row:hover h3 { color: var(--wind); }
.post-row p { margin: 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.7; max-width: 40em; }
.post-row .when { font-size: 14px; color: var(--ink-3); white-space: nowrap; }

/* 글 */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; background: linear-gradient(90deg, var(--wind), var(--blossom)); transform-origin: 0 50%; transform: scaleX(0); }
@supports (animation-timeline: scroll()) {
  .progress { animation: grow linear both; animation-timeline: scroll(root); }
  @keyframes grow { to { transform: scaleX(1); } }
}
.post { padding-top: 88px; padding-bottom: 96px; }
.post-head { margin-bottom: 48px; }
.post-head .category { color: var(--wind); font-weight: 600; font-size: 15px; margin: 0 0 14px; }
.post-head h1 { font-family: var(--display); font-size: clamp(30px, 5vw, 48px); font-weight: 700; line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 20px; text-wrap: balance; }
.post-head .meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--ink-3); font-size: 14.5px; margin: 0; }

.prose h2 { font-family: var(--display); font-size: 27px; font-weight: 700; line-height: 1.4; letter-spacing: -0.02em; margin: 72px 0 18px; }
.prose h3 { font-size: 19px; font-weight: 700; margin: 42px 0 10px; }
.prose p { margin: 0 0 20px; }
.prose strong { font-weight: 700; }
.prose blockquote { margin: 24px 0; padding: 18px 22px; background: var(--panel); border-radius: 12px; color: var(--ink-2); font-size: 0.94em; }
.prose blockquote p:last-child { margin-bottom: 0; }
/* 글 맨 위의 요약: 박스 없이 조금 큰 도입 문단 */
.prose > blockquote:first-child { margin: 0 0 8px; padding: 0; background: none; border-radius: 0; color: var(--ink-2); font-size: 1.2em; line-height: 1.7; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 22px; }
.prose li { margin: 6px 0; }
.prose code { font-family: var(--mono); font-size: 0.88em; background: var(--panel); padding: 2px 5px; border-radius: 4px; }

.table-wrap { overflow-x: auto; margin: 24px 0 28px; border: 1px solid var(--rule); border-radius: 12px; background: var(--panel); }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.6; }
.prose th, .prose td { padding: 12px 15px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.prose th { font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.prose tr:last-child td { border-bottom: 0; }

.math { margin: 24px 0; padding: 20px 14px; overflow-x: auto; background: var(--panel); border-radius: 12px; }
.katex-display { margin: 0 !important; }

pre.code { background: var(--code-bg); color: var(--code-ink); padding: 20px 22px; border-radius: 12px; overflow-x: auto; font-size: 14px; line-height: 1.65; margin: 24px 0; }
pre.code code { font-family: var(--mono); background: none; padding: 0; font-size: inherit; }

/* 차트 */
.chart { margin: 36px 0; }
.chart .c-title { font-family: var(--display); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.45; margin: 0 0 4px; color: var(--ink); }
.chart .c-sub { font-size: 14px; line-height: 1.6; color: var(--ink-3); margin: 0 0 14px; }
.c-scroll { overflow-x: auto; }
.chart svg { width: 100%; min-width: 560px; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--body); }
.c-grid { stroke: var(--rule); }
.c-zero { stroke: var(--ink-3); }
.c-tick { font-size: 13px; fill: var(--ink-3); }
.c-ref { stroke: var(--ink-3); stroke-dasharray: 4 4; }
.c-note { font-size: 13.5px; fill: var(--ink-2); }
.c-line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.c-line.dash { stroke-dasharray: 6 5; }
.c-line.s-main { stroke: var(--wind); }
.c-line.s-main2 { stroke: var(--wind); opacity: 0.5; }
.c-line.s-alt { stroke: var(--blossom); }
.c-line.s-muted { stroke: var(--ink-3); }
.c-line.s-ghost { stroke: var(--ink-3); stroke-width: 1; opacity: 0.38; }
.c-dot.s-main { fill: var(--wind); }
.c-dot.s-alt { fill: var(--blossom); }
.c-dot.s-muted { fill: var(--ink-3); }
.c-end { font-size: 13.5px; font-weight: 600; }
.c-end.s-main { fill: var(--wind); }
.c-end.s-main2 { fill: var(--wind); opacity: 0.7; }
.c-end.s-alt { fill: var(--blossom); }
.c-end.s-muted { fill: var(--ink-2); }
.c-bar.s-main { fill: var(--wind); }
.c-bar.s-alt { fill: var(--blossom); }
.c-bar.s-muted { fill: var(--ink-3); opacity: 0.55; }
.c-name { font-size: 14px; fill: var(--ink-2); }
.c-val { font-size: 14px; font-weight: 700; fill: var(--ink); }
.chart figcaption { font-size: 13.5px; line-height: 1.65; color: var(--ink-3); margin-top: 10px; }

/* 이전/다음 글 */
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 72px; padding-top: 28px; border-top: 1px solid var(--rule); }
.post-nav a { display: block; color: var(--ink); font-weight: 600; line-height: 1.5; }
.post-nav a span { display: block; font-size: 13px; font-weight: 400; color: var(--ink-3); margin-bottom: 4px; }
.post-nav .next { text-align: right; }

/* 푸터 */
.site-footer { border-top: 1px solid var(--rule); padding: 28px 0 44px; font-size: 14px; color: var(--ink-2); background: var(--veil); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 32px; }
.site-footer p { margin: 0; }
.site-footer .note { color: var(--ink-3); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding: 0 18px; }
  .wrap-narrow { padding: 0 18px; }
  .site-nav { gap: 16px; }
  .hero { padding-bottom: 34vh; }
  .hero h1 span + span { padding-left: 0.5em; }
  .post { padding-top: 56px; padding-bottom: 72px; }
  .prose h2 { font-size: 23px; margin-top: 56px; }
  .post-row { grid-template-columns: 2.6rem 1fr; }
  .post-row .no { font-size: 24px; }
  .post-row .when { grid-column: 2; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #wind { transition: none; }
}

/* ---------- 글 속 실험("직접 해보기")과 도구 ---------- */
.lab { margin: 40px 0; padding: 22px 22px 20px; border: 1px solid var(--rule); border-radius: 14px; background: var(--panel); }
.lab-title { font-size: 18px; font-weight: 700; line-height: 1.45; margin: 0 0 4px !important; }
.lab-desc { font-size: 15px; color: var(--ink-2); margin: 0 0 16px !important; }
.lab-note { font-size: 13.5px; color: var(--ink-3); margin: 14px 0 0 !important; }
.lab-body p { margin: 0; }
.lab-chart { margin: 10px 0 6px; min-height: 200px; }
.lab-chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.lab-chart text { font-family: var(--body); }
.lab-status { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.lab-result { font-size: 15.5px; line-height: 1.75; margin-top: 12px !important; min-height: 3.4em; }
.lab-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 24px; margin: 6px 0 10px; }
.lab-field { display: block; }
.lab-label { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.lab-label output { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.lab-field input[type=range] { width: 100%; accent-color: var(--wind); margin: 0; height: 28px; }
.lab-field select { width: 100%; font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sky-1); color: var(--ink); }
.lab-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }
.lab-btn { font: inherit; font-size: 15px; font-weight: 600; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--sky-1); cursor: pointer; }
.lab-btn:hover:not(:disabled) { background: var(--wind); border-color: var(--wind); }
.lab-btn:disabled { opacity: 0.4; cursor: default; }
.lab-btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); font-weight: 400; }
.lab-btn.ghost:hover:not(:disabled) { background: transparent; border-color: var(--wind); color: var(--wind); }
.lab-btn.ghost.on { border-color: var(--wind); background: var(--wind); color: var(--sky-1); }
.lab-btn[hidden] { display: none; }
.lab-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13.5px; margin-top: 6px !important; }
.lab-legend .lg::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.lab-legend .s-main { color: var(--wind); }
.lab-legend .s-alt { color: var(--blossom); }
.lab-legend .s-muted { color: var(--ink-3); }
.lab .table-wrap { margin: 14px 0 0; background: none; }
.lab table { font-size: 14px; }
.lab td, .lab th { padding: 9px 12px; white-space: nowrap; }
/* 백테스트 놀이터 */
.bt-h { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-3); margin: 26px 0 6px !important; padding-top: 14px; border-top: 1px solid var(--rule); }
.lab-body > .bt-h:first-child { margin-top: 4px !important; padding-top: 0; border-top: 0; }
.bt-desc { font-size: 14.5px; line-height: 1.7; color: var(--ink-2); margin: 4px 0 10px !important; }
.bt-presets .lab-btn { font-size: 14px; padding: 7px 14px; }
.bt-note { align-self: center; font-size: 14px; color: var(--ink-2); word-break: break-all; }
/* 호가창 */
.lab-book { margin: 14px 0 6px; max-width: 360px; }
.lab-book table { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.lab-book th, .lab-book td { padding: 3px 10px; text-align: right; border-bottom: 0; }
.lab-book th { font-size: 12.5px; text-align: center; border-bottom: 1px solid var(--rule); }
.lab-book td.p { text-align: center; font-weight: 600; }
.lab-book td.ask { color: var(--wind); }      /* 국내 HTS처럼 매도 호가는 푸른 쪽, 매수 호가는 붉은 쪽 */
.lab-book td.bid { color: var(--blossom); }
.lab-book td.q { color: var(--ink-2); }
.lab-book tr.hit td { background: color-mix(in srgb, var(--wind) 13%, transparent); }
.lab-book tr.hit td.q { color: var(--ink); font-weight: 700; }
.bias-q { padding: 16px 0; border-top: 1px solid var(--rule); }
.bias-q:first-child { border-top: 0; padding-top: 4px; }
.bias-text { font-weight: 600; margin-bottom: 10px !important; }
.bias-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.bias-opts .lab-btn { font-size: 14.5px; padding: 8px 14px; text-align: left; border-radius: 10px; }
.bias-result { scroll-margin-top: 80px; }
.bias-item { padding: 14px 0; border-top: 1px solid var(--rule); font-size: 15.5px; }
.bias-name { font-weight: 700; color: var(--ink-3); margin-bottom: 4px !important; }
.bias-item.hit .bias-name { color: var(--blossom); }

/* ---------- 용어 설명 ---------- */
a.term { color: inherit; text-decoration: underline dotted var(--ink-3); text-underline-offset: 4px; cursor: help; }
a.term:hover { text-decoration: underline dotted var(--wind); }
.tip { position: absolute; z-index: 30; max-width: min(340px, calc(100vw - 20px)); padding: 12px 14px; border-radius: 10px; background: var(--ink); color: var(--sky-1); font-size: 14px; line-height: 1.65; box-shadow: 0 8px 24px rgba(10, 14, 40, 0.22); pointer-events: none; }
.tip strong { display: block; margin-bottom: 2px; }
.tip small { display: block; margin-top: 6px; opacity: 0.7; font-size: 12.5px; }
.tip[hidden] { display: none; }
.page-lead { color: var(--ink-2); max-width: 40em; margin: 0 0 24px; }
.post-head .page-lead { margin: 0; }
.post-head .category a { color: inherit; }
.glossary { margin: 0; }
.g-item { padding: 18px 0; border-top: 1px solid var(--rule); scroll-margin-top: 84px; }
.g-item:target { background: var(--panel); margin: 0 -14px; padding: 18px 14px; border-radius: 10px; }
.g-item dt { font-weight: 700; font-size: 18px; }
.g-item dt span { font-weight: 400; font-size: 14px; color: var(--ink-3); margin-left: 6px; }
.g-item dd { margin: 6px 0 0; color: var(--ink-2); }
.tool-row .no { font-weight: 300; }

@media (max-width: 640px) {
  .lab { padding: 18px 16px; margin-left: -6px; margin-right: -6px; }
  .site-nav { gap: 13px; font-size: 14.5px; }
  .site-nav .lang { padding: 4px 10px; font-size: 13px; }
  .brand { font-size: 18px; gap: 7px; }
  .brand svg { width: 28px; height: 28px; }
}
@media (max-width: 400px) {
  .brand span { display: none; }   /* 아주 좁은 화면에서는 로고 그림만 */
}
.tools-page .cat { display: none; }

/* 두 갈래 실험, 닻 내림, 손실 회피 재기 */
.split-q { font-weight: 600; line-height: 1.7; margin: 4px 0 12px !important; }
.split-gap { margin-top: 22px !important; }
.split-bars { display: grid; gap: 8px; margin: 4px 0 6px; }
.split-bar { display: grid; grid-template-columns: minmax(0, 1fr) 30% 3.6em; gap: 10px; align-items: center; font-size: 14.5px; line-height: 1.5; }
.split-bar.stack { grid-template-columns: 1fr 5.5em; }
.split-bar.stack .split-opt { grid-column: 1 / -1; }
.split-track { display: block; height: 14px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.split-fill { display: block; height: 100%; border-radius: 4px; background: var(--ink-3); }
.split-bar.mine .split-fill { background: var(--blossom); }
.split-bar.mine .split-opt { font-weight: 700; }
.split-num { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.anchor-expr { font-size: clamp(22px, 5vw, 34px); font-weight: 700; letter-spacing: 0.02em; text-align: center; padding: 28px 0 !important; font-variant-numeric: tabular-nums; }
.anchor-input { font: inherit; font-size: 17px; padding: 9px 14px; width: 11em; max-width: 100%; border: 1px solid var(--rule); border-radius: 999px; background: var(--sky-1); color: var(--ink); }
@media (max-width: 640px) { .split-bar { grid-template-columns: 1fr 3.6em; } .split-bar .split-opt { grid-column: 1 / -1; } }
