/* ---------- 토큰 ---------- */
:root {
  color-scheme: light;
  --page: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #ebeae5;
  --line: rgba(11, 11, 11, 0.1);
  --accent: #5b4bc4;
  --accent-weak: rgba(91, 75, 196, 0.1);
  /* 한국 시장 관례: 상승 빨강, 하락 파랑 */
  --up: #d6312f;
  --down: #1f6bc9;
  --up-weak: rgba(214, 49, 47, 0.1);
  --down-weak: rgba(31, 107, 201, 0.1);
  --heat-mid: #ecebe7;
  --ma1: #eda100;
  --ma2: #1baf7a;
  --ma3: #4a3aa7;
  --warning: #fab219;
  --critical: #d03b3b;
  --notice-bg: #fff4d6;
  --notice-ink: #5c4300;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #161616;
    --surface-2: #1f1f1e;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #9085e9;
    --accent-weak: rgba(144, 133, 233, 0.14);
    --up: #f06a6a;
    --down: #5598e7;
    --up-weak: rgba(240, 106, 106, 0.14);
    --down-weak: rgba(85, 152, 231, 0.14);
    --heat-mid: #383835;
    --ma1: #c98500;
    --ma2: #199e70;
    --ma3: #9085e9;
    --notice-bg: #2a2210;
    --notice-ink: #f5d68a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #161616;
  --surface-2: #1f1f1e;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #9085e9;
  --accent-weak: rgba(144, 133, 233, 0.14);
  --up: #f06a6a;
  --down: #5598e7;
  --up-weak: rgba(240, 106, 106, 0.14);
  --down-weak: rgba(85, 152, 231, 0.14);
  --heat-mid: #383835;
  --ma1: #c98500;
  --ma2: #199e70;
  --ma3: #9085e9;
  --notice-bg: #2a2210;
  --notice-ink: #f5d68a;
}

/* ---------- 기본 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.num, table { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink-2); }
.loading, .empty { padding: 48px 0; text-align: center; color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 16px;
  height: 56px; display: flex; align-items: center; gap: 16px;
}
@media (min-width: 768px) { .topbar-inner { padding: 0 24px; gap: 24px; } }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.search { position: relative; flex: 1; max-width: 380px; margin-left: auto; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 36px; padding: 0 12px 0 32px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.search input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.search-results {
  position: absolute; top: 42px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16); max-height: 360px; overflow-y: auto;
}
.search-results li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--surface-2); }
.search-results .kind { font-size: 11px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; white-space: nowrap; align-self: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 8px; row-gap: 8px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .search { order: 4; max-width: none; flex-basis: 100%; }
  .icon-btn { margin-left: auto; }
}

.notice {
  display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding: 8px 16px; background: var(--notice-bg); color: var(--notice-ink); font-size: 12.5px; text-align: center;
}
.notice-pill {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor;
}

/* ---------- 레이아웃 ---------- */
#app { padding-top: 20px; padding-bottom: 40px; outline: none; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.col { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 1080px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; min-width: 0;
}
@media (max-width: 600px) { .card { padding: 16px; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head .sub { font-size: 12px; color: var(--ink-2); font-weight: 400; margin-left: 6px; }
.more { font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.crumbs { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- 컨트롤 ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; cursor: pointer;
  color: var(--ink-2); font-weight: 600; font-size: 12.5px; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--accent); }
select, .field input {
  height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 10px;
}
.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.star {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  height: 32px; padding: 0 10px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.star[aria-pressed="true"] { color: var(--ink); border-color: var(--warning); background: color-mix(in oklab, var(--warning) 14%, var(--surface)); }
.star svg { color: var(--warning); }
.icon-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; font-size: 16px; line-height: 1; }
.icon-x:hover { color: var(--ink); }

/* ---------- 지수 스트립 ---------- */
.strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 20px; scrollbar-width: thin; }
.chip {
  flex: none; min-width: 132px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.chip:hover { border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); }
.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip .name { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.chip .val { font-size: 16px; font-weight: 700; margin-top: 2px; }
.chip .chg { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.strip-label { flex: none; align-self: center; font-size: 11px; color: var(--muted); font-weight: 700; writing-mode: vertical-rl; letter-spacing: 0.1em; }

/* ---------- 헤드라인 숫자 ---------- */
.eyebrow { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.quote { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.quote .big { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.quote .chg { font-size: 15px; font-weight: 700; }
@media (max-width: 600px) { .quote .big { font-size: 26px; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
/* 칸마다 오른쪽·아래 구분선 — 마지막 줄이 덜 차도 빈 칸이 회색으로 보이지 않게 */
.tile { background: var(--surface); padding: 12px 14px; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.tile .k { font-size: 12px; color: var(--ink-2); }
.tile .v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.tile .s { font-size: 11.5px; color: var(--ink-2); margin-top: 1px; }

/* ---------- 차트 ---------- */
.chart-box { position: relative; width: 100%; }
.chart-legend {
  position: absolute; top: 6px; left: 8px; z-index: 3; pointer-events: none;
  display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2);
  background: color-mix(in oklab, var(--surface) 82%, transparent); padding: 2px 6px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.chart-legend b { color: var(--ink); font-weight: 600; }
/* 좁은 화면: 범례가 캔들을 가리지 않도록 차트 위로 */
@media (max-width: 600px) {
  .chart-legend { position: static; background: none; padding: 0; margin-bottom: 6px; gap: 4px 10px; }
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin: 10px 0 6px; }
.sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: 0; margin-right: 5px; }
.dot.ring { background: transparent; border: 1.5px solid; }
.dot.hollow { background: transparent; border: 1.4px solid var(--muted); }
/* 실거래 점 그래프 SVG */
.trade-svg text.ax, .line-svg text.ax { fill: var(--muted); font-size: 11px; }
.line-svg { display: block; width: 100%; }
.trade-svg text.ax.hi { fill: var(--ink-2); }
.trade-svg text.ax.vlab { fill: var(--muted); font-size: 10px; }
.tooltip .warn-tx { color: var(--warning); }
/* 게이지 */
.gauge { margin: 4px 0 2px; }
.gauge-track { position: relative; height: 22px; border-radius: 6px; background: color-mix(in oklab, var(--muted) 22%, transparent); overflow: visible; }
.gauge-fill { height: 100%; border-radius: 6px; }
.gauge-warn { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--up); }
.gauge-warn span { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--up); white-space: nowrap; font-weight: 600; }
.gauge-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); margin-top: 6px; }
.verdict { font-weight: 700; }
/* 미니 지표(상승거래 비중·거래량) */
.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .mini { grid-template-columns: 1fr; } }
.mini-card .mini-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mini-card .mini-t { font-size: 13px; font-weight: 600; }
.mini-card .mini-v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-card svg { display: block; width: 100%; height: auto; margin-top: 4px; }
.mini-card .mini-cap { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }
/* 연식별 평단가 */
.age-bands { display: grid; gap: 10px; }
.age-band { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 12px; }
.age-lab { font-size: 13px; font-weight: 600; }
.age-bar-wrap { height: 16px; background: color-mix(in oklab, var(--muted) 16%, transparent); border-radius: 5px; overflow: hidden; }
.age-bar { height: 100%; background: var(--accent); border-radius: 5px; }
.age-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 520px) { .age-band { grid-template-columns: 76px 1fr auto; gap: 8px; } }
.sw-box { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.note { font-size: 12px; color: var(--ink-2); margin: 10px 0 0; }
.toolbar { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 16px 0 8px; }

/* 등락 비율 막대 */
.breadth { margin-top: 16px; }
.breadth-bar { display: flex; height: 8px; gap: 2px; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.breadth-bar span { display: block; height: 100%; }
.breadth-row { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; }

/* ---------- 트리맵 ---------- */
.treemap { position: relative; width: 100%; height: 440px; border-radius: 8px; overflow: hidden; background: var(--surface); }
@media (max-width: 600px) { .treemap { height: 380px; } }
.tm-group { position: absolute; }
.tm-group-label {
  position: absolute; left: 0; top: 0; right: 0; height: 18px; padding: 0 5px;
  font-size: 11px; font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; line-height: 18px;
}
.tm-tile {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 3px; cursor: pointer; text-align: center; color: var(--ink); line-height: 1.2; padding: 2px;
}
.tm-tile.hot { color: #fff; }
.tm-tile:hover { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 2; }
.tm-tile .n { font-weight: 700; white-space: nowrap; }
.tm-tile .p { font-weight: 600; font-variant-numeric: tabular-nums; opacity: 0.92; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-2); margin-top: 10px; flex-wrap: wrap; }
.scale-bar { width: 180px; height: 8px; border-radius: 4px; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: right; font-weight: 600; font-size: 12px; color: var(--ink-2);
  padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th[aria-sort="descending"]::after { content: " ↓"; }
th[aria-sort="ascending"]::after { content: " ↑"; }
.rank-no { color: var(--muted); width: 28px; font-weight: 700; }
.cx-name { font-weight: 700; }
.cx-sub { font-size: 12px; color: var(--ink-2); }
td .cx-name + .cx-sub { margin-top: 1px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 5px; line-height: 18px;
  border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; vertical-align: 1px;
}
.badge.high { color: var(--up); border-color: color-mix(in oklab, var(--up) 45%, transparent); background: var(--up-weak); }
.badge.cancel { color: var(--ink); border-color: color-mix(in oklab, var(--warning) 70%, transparent); background: color-mix(in oklab, var(--warning) 18%, var(--surface)); }
.badge.reb { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 45%, transparent); background: var(--accent-weak); }
tr.canceled td.price { text-decoration: line-through; color: var(--muted); }
.spark { display: block; }
.show-more { display: block; width: 100%; margin-top: 10px; }

/* ---------- 피드 ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { border-bottom: 1px solid var(--grid); }
.feed li:last-child { border-bottom: 0; }
.feed a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 9px 0; }
.feed a:hover { color: inherit; }
.feed a:hover .cx-name { color: var(--accent); }
.feed .r { text-align: right; font-variant-numeric: tabular-nums; }
.feed .cx-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .meta { font-size: 12px; color: var(--ink-2); }
.feed .price { font-weight: 700; font-size: 13.5px; }

/* ---------- 광고 자리 ---------- */
.ad {
  display: grid; place-items: center; text-align: center; gap: 2px;
  border: 1px dashed color-mix(in oklab, var(--muted) 60%, transparent); border-radius: var(--radius);
  color: var(--muted); font-size: 12px; background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in oklab, var(--muted) 6%, transparent) 10px 11px);
}
.ad b { font-size: 11px; letter-spacing: 0.12em; }
.ad-wrap { min-width: 0; }
.ad-label { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; margin: 0 0 4px 2px; }
/* 그리드(.col) 밖에서는 위아래 여백을 직접 준다 */
.ad-wrap, .ad { margin: 20px 0; }
.col > .ad-wrap, .col > .ad { margin: 0; }
@media (max-width: 1080px) { .ad-desktop-only { display: none !important; } }

/* ---------- 단지 헤더 ---------- */
.cx-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.cx-meta { font-size: 13px; color: var(--ink-2); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 4px; }
.tabs button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px;
  cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2);
}
.tabs button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--surface-2); }

/* ---------- 포트폴리오 폼 ---------- */
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 14px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.field input { width: 100%; }
.field.grow { flex: 1 1 200px; }

/* ---------- 툴팁 ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 150px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18); padding: 10px 12px; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.tooltip .t { font-weight: 700; margin-bottom: 4px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-2); }
.tooltip .row b { color: var(--ink); font-weight: 600; }

/* ---------- 개인정보처리방침 ---------- */
.legal h1 { margin-bottom: 4px; }
.legal h2 { font-size: 15px; margin: 22px 0 8px; }
.legal p, .legal li { color: var(--ink-2); line-height: 1.65; }
.legal ol, .legal ul { margin: 6px 0; padding-left: 20px; }
.legal li { margin: 4px 0; }
.legal b { color: var(--ink); font-weight: 600; }
.legal a { text-decoration: underline; }
.legal-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.legal-table th, .legal-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.legal-table th { background: var(--surface-2); font-weight: 600; }

/* ---------- 푸터 ---------- */
.footer { padding-top: 20px; padding-bottom: 40px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 12px; }
.footer p { margin: 4px 0; }
.footer a { text-decoration: underline; }


/* ---------- 내 시트 ---------- */
.sheet .btn {
  background: var(--surface); color: var(--ink); border-color: var(--line);
  font-weight: 600; font-size: 13px; height: 32px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.sheet .btn:hover { filter: none; border-color: var(--ink-2); }
.sheet .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sheet .btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.sheet .btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.sheet .btn-danger { color: var(--critical); }
.linkbtn { border: 0; background: none; padding: 4px 2px; font: inherit; font-size: 12.5px; color: var(--accent); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

.sheet-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.stab-group { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.stab-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.stab-empty { font-size: 12.5px; color: var(--muted); }
.stab {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: 8px; padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer;
}
.stab:hover { color: var(--ink); border-color: var(--ink-2); }
.stab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 700; }

.sheet-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.sheet-name {
  font: inherit; font-size: 16px; font-weight: 700; color: var(--ink);
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  padding: 4px 8px; min-width: 0; width: 16ch; max-width: 100%;
}
.sheet-name:hover { border-color: var(--line); }
.sheet-name:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.dirty { font-size: 12px; color: var(--warning); font-weight: 600; }
.bar-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.sheet-filters, .sheet-cols {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px; border-radius: 10px; background: var(--surface-2); margin-bottom: 8px;
}
.sheet-filters input[type=search], .sheet-filters input[type=number], .sheet-cols input[type=number] {
  height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--ink); padding: 0 8px; font: inherit; font-size: 13px;
}
.sheet-filters select { height: 32px; font-size: 13px; color: var(--ink); }
.f-q { width: 170px; }
.range { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.range input[type=number] { width: 62px; }
.cash { margin-left: auto; }
.cash .hint { font-size: 11px; color: var(--muted); }

.dd { position: relative; }
.dd summary {
  list-style: none; cursor: pointer; height: 32px; display: flex; align-items: center;
  padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 13px; color: var(--ink); position: relative; white-space: nowrap;
}
.dd summary::-webkit-details-marker { display: none; }
.dd summary::after { content: '▾'; position: absolute; right: 10px; color: var(--muted); }
.dd-body {
  position: absolute; z-index: 20; top: 38px; left: 0; width: min(420px, 86vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.14); padding: 10px 12px;
}
.dd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px 10px; }

.fchip {
  display: inline-flex; align-items: center; border-radius: 999px; overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--accent) 40%, var(--line)); background: var(--accent-weak);
}
.fchip button { border: 0; background: none; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink); padding: 5px 8px; }
.fchip-edit { font-weight: 600; padding-left: 11px !important; }
.fchip-del { color: var(--muted) !important; }
.fchip-del:hover { color: var(--critical) !important; }

/* ---------- 비교함 (단지를 담아 나란히 보기) ---------- */
.pickbar {
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--line));
  background: color-mix(in oklab, var(--accent) 4%, var(--surface));
  border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
}
.pick-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.pick-head strong { font-size: 13.5px; }
.pick-only { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; margin-left: auto; cursor: pointer; }
.pick-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pick-search { position: relative; flex: 1 1 260px; min-width: 200px; }
.pick-search input {
  width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}
.pick-sug {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px;
  list-style: none; max-height: 260px; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}
.pick-sug li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.pick-sug li:hover, .pick-sug li[aria-selected="true"] { background: var(--surface-2); }
.pick-sug li[aria-disabled="true"] { cursor: default; }
.pick-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pchip {
  display: inline-flex; align-items: center; border-radius: 999px; overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--accent) 40%, var(--line)); background: var(--accent-weak);
}
.pchip a { padding: 5px 4px 5px 11px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.pchip button { border: 0; background: none; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--muted); padding: 5px 9px 5px 6px; }
.pchip button:hover { color: var(--critical); }

.pick-cell { width: 1%; }
.pick-btn {
  width: 28px; height: 28px; line-height: 1; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px;
}
.pick-btn:hover { border-color: var(--accent); color: var(--accent); }
.pick-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 비교표 — 행이 지표, 열이 단지 */
table.cmp th.cmp-cx { position: relative; min-width: 132px; text-align: center; vertical-align: top; padding-top: 10px; }
table.cmp th.cmp-cx .cx-sub { font-weight: 400; }
table.cmp th.cmp-m { white-space: nowrap; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
table.cmp td { text-align: center; }
table.cmp .chip-x {
  position: absolute; top: 4px; right: 4px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 12px; line-height: 1; padding: 3px 4px; border-radius: 5px;
}
table.cmp .chip-x:hover { color: var(--critical); background: var(--surface-2); }
td.cmp-hi { background: color-mix(in oklab, var(--accent) 24%, transparent); font-weight: 700; }
td.cmp-lo { background: color-mix(in oklab, var(--muted) 20%, transparent); }
tr.cmp-same td { color: var(--ink-2); }
tr.cmp-same th.cmp-m { font-weight: 400; }
.cmp-eq { font-size: 10.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; margin-left: 6px; }
.cmp-legend { font-size: 12px; color: var(--ink-2); margin: 8px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cmp-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.cmp-legend .sw.hi { background: color-mix(in oklab, var(--accent) 24%, transparent); }
.cmp-legend .sw.lo { background: color-mix(in oklab, var(--muted) 20%, transparent); }

@media (max-width: 640px) {
  .pick-only { margin-left: 0; }
  table.cmp th.cmp-cx { min-width: 110px; }
}

.sheet-panel { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; background: var(--surface); }
.col-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.col-groups fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.col-groups legend { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }

.fe { display: flex; flex-direction: column; gap: 10px; }
.fe-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.fe-row input {
  flex: 1; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px;
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
}
.fe-row input:focus { border-color: var(--accent); outline: none; }
.fe-expr { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; }
.fe-msg { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.fe-msg.ok { color: #1a8f5a; }
.fe-msg.err { color: var(--critical); }
.fe-vars { display: flex; flex-wrap: wrap; gap: 5px; }
.vchip {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px;
  padding: 4px 8px; font: inherit; font-size: 12.5px; color: var(--ink); cursor: pointer;
}
.vchip span { font-size: 10.5px; color: var(--muted); margin-left: 3px; }
.vchip:hover { border-color: var(--accent); background: var(--accent-weak); }
.vchip.op { font-family: ui-monospace, Menlo, monospace; min-width: 30px; font-weight: 700; }
.fe-tpls { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.fe-actions { display: flex; gap: 6px; }

.sheet-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin: 12px 0 8px; font-size: 13px; font-weight: 600; }
.sheet-meta .note { font-weight: 400; margin: 0; }
.sheet-more { display: flex; justify-content: center; margin-top: 12px; }
.fx-h { color: var(--accent); }
.jr-hi { color: var(--critical); font-weight: 700; }

.btn-sheet {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 600; text-decoration: none;
}
.btn-sheet:hover { border-color: var(--accent); color: var(--accent); }


.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 120;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .bar-actions { margin-left: 0; }
  .cash { margin-left: 0; }
  .f-q { width: 100%; }
}

/* ---------- 내 시트: 틀 고정 (열 제목·단지명) ---------- */
.sheet .table-wrap {
  max-height: min(75vh, 860px); overflow: auto; margin: 0;
  border: 1px solid var(--line); border-radius: 10px; overscroll-behavior-x: contain;
}
.sheet thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); box-shadow: inset 0 -1px 0 var(--line); }
/* 고정 열은 목록 표에만 — 비교표(.cmp)는 첫 열이 '지표'라 따로 고정한다 */
.sheet table:not(.cmp) thead th:nth-child(-n+2), .sheet table:not(.cmp) tbody td:nth-child(-n+2) { position: sticky; z-index: 2; background: var(--surface); }
.sheet table:not(.cmp) thead th:first-child, .sheet table:not(.cmp) tbody td:first-child { left: 0; box-sizing: border-box; width: 44px; min-width: 44px; max-width: 44px; }
.sheet table:not(.cmp) thead th:nth-child(2), .sheet table:not(.cmp) tbody td:nth-child(2) { left: 44px; box-shadow: inset -1px 0 0 var(--line); }
.sheet table:not(.cmp) tbody td:nth-child(2) { white-space: normal; min-width: 130px; max-width: 200px; }
.sheet table:not(.cmp) thead th:nth-child(-n+2) { z-index: 4; }
.sheet table:not(.cmp) tbody tr:hover td:nth-child(-n+2) { background: var(--surface-2); }
.sheet table.cmp thead th:first-child { position: sticky; left: 0; z-index: 4; }
.sheet table.cmp tbody th.cmp-m { position: sticky; left: 0; z-index: 2; box-shadow: inset -1px 0 0 var(--line); }

.hidden-note { font-weight: 400; font-size: 12.5px; color: var(--ink-2); }
.hidden-note .warn { color: var(--critical); font-weight: 700; }

.filter-toggle { display: none; }
@media (max-width: 640px) {
  .filter-toggle {
    display: block; width: 100%; margin-bottom: 8px; padding: 9px 12px; text-align: left;
    border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
    font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .filter-toggle::after { content: ' ▾'; color: var(--muted); }
  .filter-toggle[aria-expanded="true"]::after { content: ' ▴'; }
  .sheet-filters.collapsed { display: none; }
  .sheet .table-wrap { max-height: 70vh; }
  .sheet table:not(.cmp) thead th:first-child, .sheet table:not(.cmp) tbody td:first-child { width: 34px; min-width: 34px; max-width: 34px; padding-left: 6px; padding-right: 4px; }
  .sheet table:not(.cmp) thead th:nth-child(2), .sheet table:not(.cmp) tbody td:nth-child(2) { left: 34px; }
  .sheet table:not(.cmp) tbody td:nth-child(2) { min-width: 104px; max-width: 128px; }
}

/* ---------- 지수 쉽게 읽기 · 계산 방법 ---------- */
.money-line { margin: 8px 0 4px; font-size: 15px; color: var(--ink); line-height: 1.5; }
.money-line b { font-size: 16px; }
.explain { margin: 12px 0 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.explain summary {
  cursor: pointer; list-style: none; padding: 10px 14px; font-size: 13.5px; font-weight: 700; color: var(--accent);
}
.explain summary::-webkit-details-marker { display: none; }
.explain summary::before { content: '▸ '; }
.explain[open] summary::before { content: '▾ '; }
.explain > :not(summary) { margin-left: 14px; margin-right: 14px; }
.explain > :last-child { margin-bottom: 12px; display: inline-block; }
.explain-steps { padding-left: 18px; margin-top: 0; font-size: 13.5px; line-height: 1.7; color: var(--ink-2); }
.explain-steps b { color: var(--ink); }
.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.7;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 12px; margin: 10px 0; color: var(--ink); overflow-x: auto;
}
.formula .small { font-family: var(--font); color: var(--ink-2); }
.explain-calc {
  font-size: 13.5px; line-height: 1.7; background: var(--accent-weak); border-radius: 8px;
  padding: 10px 12px; margin: 10px 0; color: var(--ink);
}
.explain-calc .k { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }

.lead { font-size: 14.5px; line-height: 1.7; color: var(--ink-2); margin: 8px 0 12px; }
.method-toc { display: flex; flex-wrap: wrap; gap: 2px 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.method-toc .linkbtn { font-size: 13.5px; }
.method-sec { scroll-margin-top: 80px; }
.method-sec h2 { margin-bottom: 10px; }
.method-sec h3 { font-size: 14.5px; margin: 16px 0 6px; }
.method-sec p, .method-sec li { font-size: 14px; line-height: 1.75; color: var(--ink-2); }
.method-sec b { color: var(--ink); }
.method-sec ul { padding-left: 18px; }
.method-vars code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--accent); }
.method-vars td, .method-vars th { white-space: normal; }
.method-vars tbody tr { cursor: default; }

.disclaimer { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }

/* 구 드릴다운 빵부스러기 · 자체 산출 라벨 */
.tm-crumb[hidden] { display: none; }
.tm-crumb { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.tm-crumb a { color: var(--accent); }
.self-tag { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-weak); border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: 1px; }
