/* app.css — 토스증권 WTS 레이아웃 + 모바일 네이티브 호환 + lottery-site 정밀 타이포/표 */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-md);
  line-height: var(--lh-ui);
  font-weight: 430;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: var(--lh-tight);
  letter-spacing: -.016em;
  font-weight: 650;
  color: var(--ink);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font-family: inherit; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--ink-3); }
.ok-ink { color: var(--ok); }
.gold-ink { color: var(--gold); }

/* ── 상단 글로벌/국내 시황 티커 바 ── */
.ticker-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--line-2);
  font-size: var(--fs-2xs);
}
.ticker-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.ticker-inner::-webkit-scrollbar { display: none; }
.tk-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  line-height: 1;
  white-space: nowrap;
  flex: none;
}
.tk-name { color: var(--ink-3); font-weight: 560; }
.tk-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.tk-chg { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.tk-meta { margin-left: auto; color: var(--ink-3); white-space: nowrap; font-size: var(--fs-3xs); flex: none; }

/* ── 메인 상단 네비게이션 (토스증권 PC WTS 스타일) ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 720;
  font-size: 1.02rem;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 3px;
  background: var(--accent);
  display: inline-block;
}
.brand-accent { color: var(--accent); font-weight: 600; }

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 540;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  cursor: pointer;
  min-width: 196px;
  transition: border-color var(--t), background var(--t);
}
.search-trigger:hover { border-color: var(--accent); color: var(--ink); }
.search-trigger .kbd { margin-left: auto; }

.kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 550;
  cursor: pointer;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.icon-btn:hover { border-color: var(--accent); color: var(--ink); background: var(--surface-2); }
.icon-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.icon-btn.primary:hover { background: var(--accent-2); color: var(--on-accent); }
.icon-btn:disabled { opacity: .6; cursor: wait; }

/* ── 본문 컨테이너 ── */
.page {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 20px 56px;
  flex: 1;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 20px;
}
.page-title { font-size: var(--fs-3xl); }
.page-sub { margin: 5px 0 0; font-size: var(--fs-sm); color: var(--ink-3); word-break: keep-all; }

/* ── 카드 · 패널 ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow-1);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-title { font-size: var(--fs-lg); font-weight: 650; }
.panel-more { font-size: var(--fs-xs); font-weight: 560; color: var(--accent); white-space: nowrap; }

/* ── KPI 타일 4열 ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
.kpi-label { font-size: var(--fs-2xs); color: var(--ink-3); font-weight: 560; }
.kpi-val {
  margin-top: 6px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}
.kpi-note { margin-top: 5px; font-size: var(--fs-3xs); color: var(--ink-3); }

/* ── 홈 하단 2단 레이아웃 (TOP 10 + 오늘의 국장) ── */
.home-grid,
.home-bottom-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
  align-items: start;
}
.home-grid > .panel,
.home-bottom-grid > .panel {
  min-width: 0;
}

/* ── 국내 지수 · 수급 카드 ── */
.idx-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.idx-box {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 13px 14px;
}
.idx-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.idx-name { font-size: var(--fs-sm); font-weight: 650; display: inline-flex; align-items: center; gap: 6px; }
.idx-sess {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
}
.idx-close { font-family: var(--mono); font-size: 1.25rem; font-weight: 700; margin-top: 4px; }
.idx-obs { font-size: 10.5px; margin-top: 2px; }
.idx-chg { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 650; }
.spark-svg { width: 100%; height: 38px; display: block; margin: 8px 0 6px; }

.breadth-block { margin-top: 4px; }
.breadth-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-3xs);
  margin-bottom: 5px;
}
.breadth-top-meta b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 680; }
.breadth-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
}
.breadth-up { background: var(--up); }
.breadth-flat { background: var(--ink-3); opacity: .5; }
.breadth-dn { background: var(--down); }
.breadth-flat-track {
  position: relative;
  height: 24px;
  margin-top: 2px;
}
.breadth-pointer {
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid var(--ink-3);
  opacity: .7;
  transform: translateX(-50%);
}
.breadth-flat-pill {
  position: absolute;
  top: 6px;
  left: clamp(38px, var(--mid, 50%), calc(100% - 38px));
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  line-height: 1.2;
  border-bottom: 1px dotted var(--line);
  cursor: help;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-2);
}
.flow-cell {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  padding: 7px 6px;
  text-align: center;
  min-width: 0;
}
.flow-lbl {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.2;
}
.flow-val {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.macro-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.macro-mini-card {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  min-width: 0;
}
.mm-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.mm-name { font-size: var(--fs-3xs); color: var(--ink-3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-sess { font-size: 10px; color: var(--ink-3); white-space: nowrap; }
.mm-val { margin-top: 3px; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.mm-chg { margin-top: 1px; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-3xs); font-weight: 650; }
.mm-obs { margin-top: 3px; font-size: 10px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 업종 히트맵 (OKLab 9단계 · 전 단계 AA 4.5:1+ 대비 + 범례) ── */
.hm-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
}
.hm-leg-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 5px;
  line-height: 1.3;
}
.hm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 8px;
}
.hm-cell {
  display: block;
  padding: 10px 11px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: transform var(--t), border-color var(--t);
  color: var(--ink);
}
.hm-cell:hover { text-decoration: none; border-color: var(--ink); transform: translateY(-1px); }
.hm-name { font-size: var(--fs-xs); font-weight: 660; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-val { margin-top: 4px; font-family: var(--mono); font-size: var(--fs-sm); font-weight: 720; }
.hm-sub { margin-top: 2px; font-size: var(--fs-3xs); font-weight: 540; opacity: 1; }

.hm-0  { background: var(--hm-0);  color: var(--ink); }
.hm-p1 { background: var(--hm-p1); color: var(--ink); }
.hm-p2 { background: var(--hm-p2); color: var(--ink); }
.hm-p3 { background: var(--hm-p3); color: #ffffff; }
.hm-p4 { background: var(--hm-p4); color: #ffffff; }
.hm-n1 { background: var(--hm-n1); color: var(--ink); }
.hm-n2 { background: var(--hm-n2); color: var(--ink); }
.hm-n3 { background: var(--hm-n3); color: #ffffff; }
.hm-n4 { background: var(--hm-n4); color: #ffffff; }
:root[data-theme="dark"] .hm-p3,
:root[data-theme="dark"] .hm-p4,
:root[data-theme="dark"] .hm-n3,
:root[data-theme="dark"] .hm-n4 { color: #0f1114; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hm-p3,
  :root:not([data-theme="light"]) .hm-p4,
  :root:not([data-theme="light"]) .hm-n3,
  :root:not([data-theme="light"]) .hm-n4 { color: #0f1114; }
}

/* ── 배지 & 범례 (첨부 스크린샷 정밀 반영) ── */
.legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.lbadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-2xs);
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.lbadge:hover { border-color: var(--accent); }
.lbadge.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.lbadge-in { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.lbadge-out { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }

.tag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  vertical-align: middle;
}
.tag-in  { border: 1px solid var(--gold); color: var(--gold); background: var(--gold-soft); }
.tag-out { border: 1px solid var(--bad); color: var(--bad); background: var(--bad-soft); }
.tag-mkt { border: 1px solid var(--line); color: var(--ink-3); background: var(--surface-2); font-weight: 540; }

/* ── 스크리너 탭 & 필터 툴바 ── */
.tab-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tab-strip::-webkit-scrollbar { display: none; }
.tab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 0 14px;
  font-size: var(--fs-sm);
  font-weight: 580;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  transition: color var(--t);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); font-weight: 700; }
.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--gold);
}
.tab-cnt {
  font-family: var(--mono);
  font-size: var(--fs-3xs);
  color: var(--ink-3);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) 2.2fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.filter-bar .search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.filter-selects {
  display: grid;
  grid-template-columns: repeat(4, minmax(108px, 1fr));
  gap: 8px;
  align-items: center;
}
.filter-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 40px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-2xs);
  font-weight: 620;
  white-space: nowrap;
  cursor: pointer;
}
.filter-toggle-btn[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.f-cnt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
}
.results-anchor { scroll-margin-top: 112px; outline: none; }
.weekly-note-box {
  padding: 11px 14px;
  margin-bottom: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.weekly-note-box[hidden] { display: none; }
.filter-bar input[type="search"],
.filter-bar select {
  width: 100%;
  height: 38px;
  margin: 0;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background-color: var(--surface);
  color: var(--ink);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 36px;
  vertical-align: middle;
}
.filter-bar select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2388919e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px 12px;
}
.filter-bar select::-ms-expand { display: none; }
.filter-bar select::picker-icon { display: none; }
.filter-bar select option {
  background: var(--surface);
  color: var(--ink);
}
.filter-bar input[type="search"]::placeholder {
  color: var(--ink-3);
  line-height: normal;
}
.filter-bar input:focus, .filter-bar select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.view-switch {
  display: inline-flex;
  align-items: stretch;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  flex: none;
}
.view-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 0 14px;
  font-size: var(--fs-2xs);
  font-weight: 580;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.view-switch button.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 680;
}

/* ── 스크리너 테이블 (첨부 스크린샷 컬럼 구조 완벽 재현) ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-1);
}
table.stbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
table.stbl thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 10px 10px;
  font-size: var(--fs-2xs);
  font-weight: 620;
  color: var(--ink-3);
  white-space: nowrap;
  text-align: right;
  cursor: pointer;
  user-select: none;
}
table.stbl thead th:first-child,
table.stbl thead th:nth-child(2) { text-align: left; }
table.stbl thead th:hover { color: var(--ink); }
table.stbl thead th.sort-asc::after { content: " ▲"; font-size: 9px; }
table.stbl thead th.sort-desc::after { content: " ▼"; font-size: 9px; }

table.stbl tbody tr {
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  transition: background var(--t);
}
table.stbl tbody tr:last-child { border-bottom: 0; }
table.stbl tbody tr:hover { background: var(--surface-2); }

table.stbl tbody td {
  padding: 10px 10px;
  white-space: nowrap;
  vertical-align: middle;
}
.td-rank { width: 42px; color: var(--ink-3); font-family: var(--mono); font-size: var(--fs-xs); text-align: left; }
.td-stock { min-width: 185px; text-align: left; }
.st-main { display: flex; align-items: center; gap: 6px; }
.st-name { font-weight: 640; color: var(--ink); }
.st-sub { font-size: var(--fs-3xs); color: var(--ink-3); margin-top: 1px; }
.star-btn {
  border: 0; background: transparent; color: var(--ink-3);
  padding: 2px 3px; cursor: pointer; font-size: 14px; line-height: 1;
}
.star-btn.saved { color: var(--gold); }

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
}
.sc-high { background: var(--ok-soft); color: var(--ok); }
.sc-gold { background: var(--gold-soft); color: var(--gold); }
.sc-mid  { background: var(--surface-2); color: var(--ink-2); }
.sc-low  { color: var(--ink-3); }

.dd-deep { color: var(--down); font-weight: 600; }
.dd-zero { color: var(--up); font-weight: 650; }
.dd-mid  { color: var(--ink-2); }

/* ── 모바일 카드 뷰 (핸드폰 한 손 조작 최적화) ── */
.card-list { display: none; gap: 10px; }
.card-list.active { display: grid; }
.stock-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 14px;
  box-shadow: var(--shadow-1);
  cursor: pointer;
}
.sc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sc-price-box { text-align: right; }
.sc-close { font-family: var(--mono); font-size: 1.05rem; font-weight: 700; }
.sc-scores {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 9px;
}
.sc-dd-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line-2);
  text-align: center;
}
.sc-dd-item span { display: block; font-size: 10.5px; color: var(--ink-3); }
.sc-dd-item b { font-family: var(--mono); font-size: var(--fs-2xs); font-weight: 650; }

.pager-top {
  position: sticky;
  top: 56px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  box-shadow: var(--shadow-1);
}
.pager-top[hidden] { display: none; }
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.pager-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.pg-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.pg-num:hover:not(:disabled) { border-color: var(--accent); color: var(--ink); background: var(--surface-2); }
.pg-num.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.pg-num:disabled { opacity: .45; cursor: not-allowed; }
.pg-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 34px;
  color: var(--ink-3);
  font-family: var(--mono);
}

/* ── 토스증권식 슬라이드오버 종목 상세 드로어 (모바일=바텀시트) ── */
.drawer-veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 12, 16, .48);
}
.drawer-veil[hidden] { display: none; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 85;
  width: min(520px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 200ms cubic-bezier(.25, .8, .25, 1), visibility 200ms;
}
.drawer.open { transform: translateX(0); visibility: visible; pointer-events: auto; }
.drawer-handle { display: none; }
.drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drawer-body {
  padding: 18px 20px 28px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.drawer-price-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.drawer-price { font-family: var(--mono); font-size: 1.65rem; font-weight: 720; }
.chart-box {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 10px 10px 6px;
  margin-bottom: 16px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-3xs);
  color: var(--ink-3);
  margin-bottom: 6px;
}
.tf-strip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px;
  margin-bottom: 4px;
}
.tf-btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  min-height: 36px;
  min-width: 40px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: var(--fs-2xs);
  font-weight: 620;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.tf-btn:hover { color: var(--ink); }
.tf-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 720;
}
.chart-state {
  padding: 36px 14px;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.chart-svg-focus { outline: none; border-radius: 6px; touch-action: pan-y; }
.chart-svg-focus:focus-visible { outline: 2px solid var(--accent); }
.risk-panel {
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--ink-2);
  word-break: keep-all;
}
.risk-panel.risk-warn {
  border-color: color-mix(in srgb, var(--warn) 38%, var(--line));
  background: var(--warn-soft);
  color: var(--warn);
}
.risk-panel b { color: var(--ink); }
.risk-panel.risk-warn b { color: var(--warn); }
.cred-unreviewed {
  background: var(--surface-3);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.chart-readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--ink-2);
  min-height: 18px;
  margin-bottom: 4px;
}
.drawer-dd-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}
.dd-tile {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 8px 4px;
  text-align: center;
}
.dd-tile span { display: block; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.dd-tile b { font-family: var(--mono); font-size: var(--fs-sm); display: block; margin-top: 2px; }

.check-sec { margin-bottom: 16px; }
.check-sec h3 { font-size: var(--fs-sm); margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  font-size: var(--fs-xs);
}
.chk-dot {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  font-size: 11px; font-weight: 700; margin-top: 1px;
}
.chk-ok { background: var(--ok-soft); color: var(--ok); }
.chk-no { background: var(--surface-3); color: var(--ink-3); }
.chk-detail { color: var(--ink-3); font-size: var(--fs-2xs); margin-top: 2px; word-break: keep-all; }

.ext-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.ext-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--fs-2xs);
  font-weight: 600;
}
.ext-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ── 09:00 멀티컷 시황 만화 (진짜 만화책/인스타툰 컷 레이아웃) ── */
.comic-sheet {
  background: #ffffff;
  border: 2px solid #14161a;
  border-radius: 6px;
  padding: 16px;
  box-shadow: var(--shadow-2);
  margin-bottom: 26px;
  color: #14161a;
}
:root[data-theme="dark"] .comic-sheet {
  background: #1b1e24;
  border-color: #3a414d;
  color: var(--ink);
}
.comic-sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 2px solid #14161a;
}
:root[data-theme="dark"] .comic-sheet-head { border-bottom-color: #3a414d; }
.comic-sheet-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.02em;
}
.comic-sheet-full img {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: block;
  border: 2px solid #14161a;
  border-radius: 3px;
  cursor: zoom-in;
}

.comic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.comic-panel {
  position: relative;
  background: #fcfbf8;
  border: 2.2px solid #14161a;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
:root[data-theme="dark"] .comic-panel {
  background: #14171c;
  border-color: #3f4754;
}
.comic-cut-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  background: #14161a;
  color: #ffffff;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
}
.comic-img-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #f3f2ee;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.comic-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.comic-placeholder {
  padding: 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: var(--fs-xs);
}
/* 만화 나레이션 박스 + 캐릭터 말풍선 영역 */
.comic-dialogue-strip {
  padding: 10px 12px 12px;
  border-top: 2px solid #14161a;
  background: #ffffff;
  color: #14161a;
  display: grid;
  gap: 7px;
}
:root[data-theme="dark"] .comic-dialogue-strip {
  border-top-color: #3f4754;
  background: #181c22;
  color: var(--ink);
}
.comic-narration {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  background: #f7efdb;
  color: #5c3d09;
  border: 1.4px solid #d4b46a;
  border-radius: 3px;
  line-height: 1.4;
  word-break: keep-all;
}
:root[data-theme="dark"] .comic-narration {
  background: #2b2214;
  color: #e6bf7d;
  border-color: #5a4622;
}
.comic-bubbles {
  display: grid;
  gap: 6px;
}
.speech-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}
.speech-row.right { flex-direction: row-reverse; }
.speech-who {
  font-size: 11px;
  font-weight: 750;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 5px;
}
.speech-row.right .speech-who { color: var(--up); }
.speech-bubble {
  position: relative;
  padding: 7px 11px;
  border-radius: 12px;
  border: 1.6px solid #14161a;
  background: #ffffff;
  color: #14161a;
  font-size: 13px;
  font-weight: 560;
  line-height: 1.45;
  word-break: keep-all;
}
:root[data-theme="dark"] .speech-bubble {
  border-color: #4b5565;
  background: #222730;
  color: #eef0f3;
}
.speech-row.right .speech-bubble {
  background: #f3f7fb;
}
:root[data-theme="dark"] .speech-row.right .speech-bubble {
  background: #1a2634;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.topic-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 13px 14px;
  box-shadow: var(--shadow-1);
}
.topic-card-btn {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
  color: inherit;
  min-height: 126px;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}
.topic-card-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}
.topic-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.topic-badge { font-size: var(--fs-3xs); font-weight: 700; color: var(--accent); }
.cred-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.cred-high { background: var(--ok-soft); color: var(--ok); }
.cred-mid  { background: var(--accent-soft); color: var(--accent); }
.cred-warn { background: var(--warn-soft); color: var(--warn); }
.topic-hl {
  margin: 7px 0 10px;
  font-size: var(--fs-xs);
  font-weight: 640;
  line-height: 1.44;
  word-break: keep-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line-2);
}
.topic-meta { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.topic-cta { font-size: 11.5px; font-weight: 680; color: var(--accent); white-space: nowrap; }

.summary-box {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 13px 14px;
  margin-bottom: 14px;
  font-size: var(--fs-sm);
  line-height: 1.68;
  color: var(--ink);
  word-break: keep-all;
}
.bv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.bv-card {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  font-size: var(--fs-xs);
  line-height: 1.55;
  word-break: keep-all;
}
.bv-bull { background: var(--up-soft); border-color: color-mix(in srgb, var(--up) 25%, var(--line)); }
.bv-bear { background: var(--down-soft); border-color: color-mix(in srgb, var(--down) 25%, var(--line)); }
.bv-card b { display: block; margin-bottom: 4px; font-size: var(--fs-2xs); }

.media-cols {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
}
.media-cols > .panel { min-width: 0; }
.news-list { list-style: none; padding: 0; margin: 0; }
.news-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}
.news-item:last-child { border-bottom: 0; }
.news-item a { color: var(--ink); font-weight: 560; font-size: var(--fs-sm); display: block; line-height: 1.45; word-break: keep-all; }
.news-item a:hover { color: var(--accent); }
.news-meta { margin-top: 3px; font-size: var(--fs-3xs); color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }

.yt-item {
  display: flex;
  gap: 11px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
  align-items: flex-start;
  min-width: 0;
}
.yt-item:last-child { border-bottom: 0; }
.yt-item > a,
.yt-thumb-link {
  flex: 0 0 104px;
  width: 104px;
  min-width: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-3);
}
.yt-thumb {
  display: block;
  width: 100%;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-3);
}
.yt-info { flex: 1 1 auto; min-width: 0; }
.yt-title { font-size: var(--fs-xs); font-weight: 600; color: var(--ink); line-height: 1.4; display: block; word-break: keep-all; overflow-wrap: anywhere; }
.yt-title:hover { color: var(--accent); }

/* ── 가이드 · 용어집 ── */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.guide-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
}
.guide-card p { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--ink-2); line-height: var(--lh-prose); word-break: keep-all; }

/* ── ⌘K 빠른 검색 모달 ── */
.cmdk { position: fixed; inset: 0; z-index: 95; display: grid; place-items: start center; padding-top: min(14vh, 110px); }
.cmdk[hidden] { display: none; }
.cmdk-veil { position: fixed; inset: 0; background: rgba(10, 12, 16, .52); }
.cmdk-box {
  position: relative;
  width: min(560px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.cmdk-field {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}
.cmdk-field input {
  flex: 1; border: 0; background: transparent; color: var(--ink);
  font-size: 16px; outline: none;
}
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 380px; overflow-y: auto; }
.cmdk-list li button {
  width: 100%; border: 0; background: transparent; color: var(--ink);
  text-align: left; padding: 9px 11px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  cursor: pointer; font-size: var(--fs-sm);
}
.cmdk-list li button:hover, .cmdk-list li button.sel { background: var(--surface-2); }
.cmdk-foot {
  padding: 8px 14px; border-top: 1px solid var(--line-2);
  font-size: var(--fs-3xs); color: var(--ink-3); display: flex; gap: 12px;
}

/* ── 라이트박스 (만화 확대) ── */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 12, 16, .84);
  display: grid; place-items: center; padding: 16px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: min(920px, 96vw); max-height: 88dvh; border-radius: var(--r); }

/* ── 하단 고지 (투자 권유가 아닙니다.) ── */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 20px 20px 28px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.disclaimer-strong {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
}

/* ── 모바일 하단 탭바 (토스앱 스타일) ── */
.mobile-nav { display: none; }

@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid, .home-bottom-grid { grid-template-columns: 1fr; }
  .media-cols { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .ticker-inner { padding: 6px 12px; }
  .topbar-inner { padding: 0 12px; height: 52px; gap: 8px; }
  .pager-top { top: 52px; padding: 6px 10px; gap: 6px; }
  .topnav { display: none; }
  .search-trigger { min-width: 0; padding: 0 10px; }
  .search-trigger span, .search-trigger .kbd { display: none; }
  .tt-label, .refresh-label { display: none; }

  .page { padding: 14px 12px 92px; }
  .page-title { font-size: 1.32rem; }
  .panel { padding: 14px 13px; }
  .idx-cards { grid-template-columns: 1fr; }
  .macro-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .comic-grid { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: 1fr; }
  .bv-grid { grid-template-columns: 1fr; }

  /* UI 3: 모바일 필터 1줄 컴팩트(검색+필터토글+표/카드), 4개 셀렉트는 클릭 시 2x2 펼침 */
  .filter-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .filter-bar .search-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 6px;
    align-items: center;
  }
  .filter-toggle-btn { display: inline-flex; }
  .filter-selects {
    display: none;
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .filter-selects.open { display: grid; }
  .filter-bar input[type="search"] {
    height: 40px;
    line-height: 38px;
    font-size: 15px;
  }
  .filter-bar select {
    height: 40px;
    line-height: 38px;
    font-size: 14px;
  }
  .view-switch {
    height: 40px;
  }
  .tf-btn { min-height: 42px; min-width: 44px; padding: 0 10px; }
  .pager { justify-content: center; }
  .pager-btns { justify-content: center; }
  .results-anchor { scroll-margin-top: 106px; }

  /* 모바일 드로어 → 네이티브 바텀시트 */
  .drawer {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100vw;
    height: 90dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .drawer.open { transform: translateY(0); }
  .drawer-handle {
    display: block;
    width: 40px; height: 4px;
    border-radius: 999px;
    background: var(--line);
    margin: 9px auto 2px;
  }
  .drawer-head { padding: 10px 16px 12px; }
  .drawer-body { padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }

  .site-footer { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .mobile-nav a, .mobile-nav button {
    border: 0;
    background: transparent;
    color: var(--ink-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    font-size: 11px;
    font-weight: 560;
    cursor: pointer;
    text-decoration: none;
  }
  .mobile-nav a.active { color: var(--accent); font-weight: 700; }
}
