:root {
  --ink: #15181c;
  --ink-2: #4a525c;
  --line: #d9dcd8;
  --paper: #f2f3ef;
  --white: #fff;
  --board: #17191c;
  --board-2: #2b2f34;
  --board-text: #f4f5f2;
  --board-muted: #a9b0b8;
  --up: #c4122f;
  --down: #0a56a8;
  --up-board: #ff7d87;
  --down-board: #74b6ff;
  --mark: #f3b63f;
  --base-bar: #0d8ba1;
  --profit-bar: #c8102e;
  --focus: #0a56a8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Pretendard Variable, Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 17px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: break-word;
}
a { color: var(--down); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { width: min(1180px, 100% - 40px); margin-inline: auto; }

/* 머리글 */
.site-head { background: var(--board); color: var(--board-text); }
.bar { display: flex; align-items: center; gap: 28px; min-height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; }
.logo svg { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: var(--board-muted); text-decoration: none; font-size: 15.5px; font-weight: 600; padding: 19px 9px 16px; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--board-text); }
.nav a[aria-current="page"] { color: var(--board-text); border-bottom-color: var(--mark); }
.menu-btn { display: none; margin-left: auto; background: none; color: var(--board-text); border: 1px solid #5a616a; border-radius: 8px; font: inherit; font-size: 15px; font-weight: 600; padding: 6px 14px; cursor: pointer; }

/* 작업대 */
.bench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; padding: 30px 0 36px; align-items: start; }
.head { grid-column: 1 / -1; margin-bottom: 20px; }
.head h1 { margin: 0; font-size: clamp(26px, 3vw, 32px); line-height: 1.25; letter-spacing: -0.025em; font-weight: 800; }
.head p { margin: 8px 0 0; color: var(--ink-2); max-width: 44em; }

.tool { background: var(--white); border-radius: 10px; padding: 24px; }
.tabs { display: flex; gap: 22px; border-bottom: 2px solid var(--line); margin: -4px 0 20px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 4px 0 10px; font: inherit; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: block; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span, .row-head { display: block; font-size: 15px; font-weight: 700; margin-bottom: 5px; }
.input { position: relative; display: block; }
.input input, .field select {
  width: 100%;
  height: 50px;
  border: 2px solid #c6cac6;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0 44px 0 12px;
}
.field select { padding-right: 12px; font-size: 16px; }
.input input:focus, .field select:focus { border-color: var(--ink); outline: none; }
.input i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--ink-2); font-size: 15px; pointer-events: none; }
.field small { display: block; color: var(--ink-2); font-size: 14.5px; line-height: 1.45; margin-top: 5px; }

.buys { margin-top: 20px; border-top: 2px solid var(--line); padding-top: 16px; }
.buy-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; margin-bottom: 8px; }
.buy-labels { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 5px; }
.buys.multi .buy-row, .buys.multi .buy-labels { grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) 44px; }
.buy-labels span:first-child { grid-column: 2; }
.buy-row b { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.text-btn { background: none; border: 0; padding: 6px 2px; font: inherit; font-size: 15px; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.sub-btn { background: var(--white); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 15.5px; font-weight: 700; cursor: pointer; margin-top: 4px; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.share p { margin: 0; font-size: 15px; color: var(--ink-2); }
.copy { background: var(--board); color: var(--board-text); border: 0; border-radius: 8px; padding: 11px 16px; font: inherit; font-size: 15.5px; font-weight: 700; cursor: pointer; }

/* 결과 시세판 */
.board { background: var(--board); color: var(--board-text); border-radius: 10px; padding: 26px; position: sticky; top: 14px; font-variant-numeric: tabular-nums; }
.big-label { margin: 0; color: var(--board-muted); font-size: 15.5px; font-weight: 600; }
.big-num { margin: 2px 0 0; font-size: clamp(38px, 5vw, 54px); font-weight: 800; line-height: 1.15; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.big-num span { font-size: 22px; font-weight: 700; margin-left: 4px; letter-spacing: 0; }
.big-num.up { color: var(--up-board); }
.big-num.down { color: var(--down-board); }
.big-sub { margin: 6px 0 0; color: var(--board-text); font-size: 16px; }
.big-empty { margin: 8px 0 0; font-size: 19px; font-weight: 600; }
.lines { margin: 20px 0 0; }
.line { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--board-2); }
.line dt { color: var(--board-muted); font-size: 15.5px; }
.line dd { margin: 0; font-weight: 700; text-align: right; font-size: 16.5px; }
.line dd.up { color: var(--up-board); }
.line dd.down { color: var(--down-board); }
.warn { margin: 14px 0 0; padding-top: 12px; border-top: 2px solid var(--mark); font-size: 15.5px; line-height: 1.5; }

/* 가격 위치: 높은 값이 위 */
.ladder { list-style: none; margin: 18px 0 0; padding: 0; border-top: 2px solid var(--board-2); }
.ladder li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 9px 0 9px 12px; font-size: 15.5px; }
.ladder li::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 2px; background: var(--board-muted); }
.ladder li span { color: var(--board-muted); }
.ladder li.mark::before { background: var(--mark); }
.ladder li.mark span, .ladder li.mark strong { color: var(--mark); }

/* 보조 표 */
.extra { padding-bottom: 8px; }
.extra-block { background: var(--white); border-radius: 10px; padding: 24px; margin-bottom: 24px; }
.extra-block h2, .sessions-box h2 { margin: 0; font-size: 22px; line-height: 1.35; letter-spacing: -0.015em; }
.extra-block > p { margin: 6px 0 0; color: var(--ink-2); font-size: 15.5px; }
.tbl { overflow-x: auto; margin-top: 14px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 16px; }
caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
th, td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 500; white-space: nowrap; }
thead th { font-size: 14.5px; color: var(--ink-2); font-weight: 700; border-bottom: 2px solid var(--ink); }
tbody th { font-weight: 700; }
.n { text-align: right; padding-left: 12px; padding-right: 0; }
.up { color: var(--up); }
.down { color: var(--down); }

/* 차트 */
.chart { margin: 18px 0 8px; }
.legend { display: flex; gap: 16px; font-size: 15px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.key.base { background: var(--base-bar); }
.key.profit { background: var(--profit-bar); }
.plot { position: relative; height: 280px; margin: 12px 0 30px 78px; }
.ticks { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; }
.ticks li { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.ticks span { position: absolute; right: calc(100% + 8px); top: -10px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.bars { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.bars li { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; outline-offset: 0; }
.bars li:hover .bar-base, .bars li:focus .bar-base { background: #5f6873; }
.bars li:hover .bar-profit, .bars li:focus .bar-profit { background: #9c0c24; }
.bar-base { display: block; background: var(--base-bar); }
.bar-profit { display: block; background: var(--profit-bar); border-radius: 4px 4px 0 0; }
.bars i { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); font-style: normal; font-size: 13.5px; color: var(--ink-2); }
.tip { position: absolute; left: 8px; top: 0; margin: 0; max-width: calc(100% - 16px); background: var(--board); color: var(--board-text); padding: 7px 11px; border-radius: 6px; font-size: 14.5px; line-height: 1.4; font-variant-numeric: tabular-nums; pointer-events: none; }
.all-years { margin-top: 14px; }
.all-years summary { cursor: pointer; list-style: none; display: inline-block; background: var(--white); border: 2px solid var(--ink); border-radius: 8px; padding: 8px 14px; font-size: 15.5px; font-weight: 700; }
.all-years summary::-webkit-details-marker { display: none; }
.all-years summary::after { content: " 펼치기"; }
.all-years[open] summary::after { content: " 접기"; }
.chart figcaption { font-size: 14.5px; color: var(--ink-2); }

/* 미국 증시 */
.sessions-box { background: var(--white); border-radius: 10px; padding: 24px; }
.sessions { margin: 14px 0 0; }
.sessions div { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 13px 0; border-bottom: 1px solid var(--line); }
.sessions dt { font-weight: 600; color: var(--ink-2); }
.sessions dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.sessions .main dt, .sessions .main dd { color: var(--ink); font-weight: 800; }
.session-note { margin: 12px 0 0; font-size: 15.5px; color: var(--ink-2); }

/* 안내 글 */
.article { padding: 30px 0 48px; }
.prose { max-width: 760px; }
.prose h2 { font-size: 25px; line-height: 1.35; letter-spacing: -0.02em; margin: 40px 0 10px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 19px; margin: 24px 0 6px; line-height: 1.45; }
.prose p { margin: 10px 0; }
.prose ul, .prose ol { padding-left: 22px; margin: 10px 0; }
.prose li { margin: 5px 0; }
.prose .formula { background: var(--white); border-left: 4px solid var(--ink); padding: 11px 14px; font-weight: 600; margin: 14px 0; font-variant-numeric: tabular-nums; }
.prose .tbl { margin: 14px 0; background: var(--white); padding: 4px 14px; border-radius: 8px; }
.prose dl dt { font-weight: 800; margin-top: 18px; }
.prose dl dd { margin: 4px 0 0; }

.others { background: var(--white); padding: 34px 0; }
.others h2 { margin: 0 0 14px; font-size: 22px; }
.others ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 28px; }
.others a { display: block; color: inherit; text-decoration: none; padding: 12px 0; border-top: 2px solid var(--line); height: 100%; }
.others a:hover strong { text-decoration: underline; }
.others strong { display: block; font-size: 17.5px; }
.others span { font-size: 15px; color: var(--ink-2); line-height: 1.5; display: block; }

footer { background: var(--board); color: var(--board-muted); padding: 26px 0 32px; font-size: 15px; }
footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
footer a { color: var(--board-text); }
footer p { margin: 4px 0; max-width: 54em; line-height: 1.6; }

.plain-head { padding: 28px 0 0; }
.plain-head h1 { margin: 0; font-size: clamp(28px, 4vw, 38px); letter-spacing: -0.02em; }

@media (max-width: 1040px) {
  .others ul { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .bench { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 22px; }
  .head { margin-bottom: 4px; }
  .board { position: static; }
  /* 미국 증시는 남은 시간이 핵심이라 휴대폰에서 먼저 보여 준다. */
  .sessions-box { order: 2; }
}
@media (max-width: 720px) {
  .bar { flex-wrap: wrap; gap: 0; min-height: 0; padding: 12px 0; }
  .menu-btn { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; gap: 0; margin: 12px 0 -4px; }
  .nav.open { display: flex; }
  .nav a { padding: 11px 0; border-bottom: 0; border-top: 1px solid var(--board-2); }
  .nav a[aria-current="page"] { color: var(--mark); }
}
@media (max-width: 560px) {
  .wrap { width: calc(100% - 32px); }
  .tool, .board, .extra-block, .sessions-box { padding: 18px; }
  .fields { gap: 13px; }
  .input input { font-size: 17px; padding: 0 34px 0 10px; }
  .field select { font-size: 15.5px; padding: 0 4px 0 8px; }
  .input i { right: 9px; font-size: 14.5px; }
  .others ul { grid-template-columns: 1fr; }
  .plot { height: 240px; }

  /* 추가 매수: 회차 줄 아래에 이름 붙은 입력칸 둘 */
  .buy-labels { display: none; }
  .buy-row, .buys.multi .buy-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-bottom: 14px; gap: 4px 8px; }
  .buy-row b { grid-column: 1; grid-row: 1; }
  .buy-row .input { grid-row: 2; }
  .buy-row .text-btn { grid-column: 2; grid-row: 1; justify-self: end; padding: 0 2px; }
  .buy-row .input::before { content: attr(data-label); display: block; font-size: 15px; font-weight: 700; margin-bottom: 5px; }
  .buy-row .input i { top: auto; bottom: 15px; transform: none; }

  /* 표: 3열 이하는 글자를 접고, 4열 이상은 행마다 쌓는다. */
  th, td { white-space: normal; }
  .tbl { overflow-x: visible; }
  .prose .tbl { padding: 4px 12px; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.stack, table.stack tbody, table.stack tr, table.stack th[scope="row"] { display: block; width: 100%; }
  table.stack tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack th[scope="row"] { border: 0; padding: 0 0 4px; }
  table.stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border: 0; padding: 2px 0; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--ink-2); font-size: 15px; font-weight: 500; text-align: left; }
}
@media (max-width: 360px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .buy-row, .buys.multi .buy-row { grid-template-columns: minmax(0, 1fr) auto; }
  .buy-row .input { grid-column: 1 / -1; grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
