:root {
  color-scheme: dark;
  --ground: #0d1015;
  --surface: #141920;
  --surface-2: #1a2029;
  --line: #232a34;
  --line-soft: #1c222b;
  --ink: #e7ebf1;
  --ink-2: #b5bdc9;
  --muted: #8b95a5;
  --faint: #5d6776;
  /* 시리즈 (다크 표면 기준 검증 통과) */
  --c-blue: #4f8ff7;
  --c-orange: #d07a12;
  --c-teal: #1fa888;
  --c-purple: #8f7aee;
  /* 한국식 등락: 상승 빨강 · 하락 파랑 */
  --up: #f0616d;
  --down: #5b9bff;
  --flat: #8b95a5;
  --good: #3fbf7f;
  --usdc-row: rgba(79, 143, 247, 0.09);
  --radius: 10px;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-left, 0px)) 10px;
  background: rgba(13, 16, 21, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 8px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1200px; margin-inline: auto; width: 100%; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { width: 22px; height: 22px; border-radius: 50%; flex: none; background: radial-gradient(circle, var(--ground) 0 30%, transparent 31%), var(--c-blue); box-shadow: inset 0 0 0 3px var(--c-blue); }
.brand h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.status { margin: 0; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .warn { color: var(--up); }
.icon-btn {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font: 600 11px var(--mono); color: var(--good); letter-spacing: 0.06em; }
.live-pill i, .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

main { max-width: 1200px; margin: 0 auto; padding-top: 16px; }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); padding: 12px 14px; min-width: 0; }
.kpi .k { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .v { font: 600 clamp(17px, 4.6vw, 22px)/1.25 var(--mono); letter-spacing: -0.02em; margin-top: 2px; white-space: nowrap; }
.kpi .d { font: 500 11.5px var(--mono); margin-top: 2px; white-space: nowrap; }

.group-h { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin: 28px 2px 10px; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card.wide { grid-column: 1 / -1; }
}
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 14px 12px; min-width: 0; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.card-h .sub { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.info-btn {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: 600 13px/1 Georgia, 'Times New Roman', serif; font-style: italic; cursor: pointer;
  display: grid; place-items: center; margin: -2px -2px 0 0;
}
.info-btn[aria-expanded='true'] { background: var(--c-blue); border-color: var(--c-blue); color: #fff; }
.info {
  margin: 10px 0 2px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; line-height: 1.6; color: var(--ink-2);
}
.info p { margin: 0 0 6px; }
.info p:last-child { margin-bottom: 0; }
.info b { color: var(--ink); font-weight: 600; }
.info ul { margin: 4px 0 6px; padding-left: 18px; }
.info li { margin: 2px 0; }

.headline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-top: 12px; }
.headline .big { font: 600 clamp(24px, 7vw, 30px)/1.1 var(--mono); letter-spacing: -0.03em; }
.headline .lbl { font-size: 12px; color: var(--muted); }
.delta-line { font: 500 12px var(--mono); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.delta-line .when { font-family: var(--sans); font-size: 11.5px; color: var(--faint); }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--flat); }

.chart { position: relative; height: 210px; margin-top: 12px; }
.chart.tall { height: 250px; }
.chart.short { height: 150px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pair .mini-h { font-size: 12px; color: var(--muted); margin-top: 12px; }
.pair .mini-v { font: 600 17px var(--mono); }
.pair .chart { height: 150px; margin-top: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 2px; }
.note { font-size: 11.5px; color: var(--faint); margin: 8px 0 0; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 10px -14px 0; padding: 0 14px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
th { font-size: 11.5px; font-weight: 600; color: var(--muted); }
td { font: 13px var(--mono); }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.name { font-family: var(--sans); }
td.name b { font: 700 13px var(--mono); margin-right: 6px; color: var(--ink); }
td.name span { color: var(--muted); font-size: 12px; }
tr.hl td { background: var(--usdc-row); }
tr.hl td:first-child { box-shadow: inset 3px 0 0 var(--c-blue); padding-left: 8px; }
tr.sub-h th { padding-top: 16px; color: var(--muted); }
tr.today td { background: var(--usdc-row); }
td.strong { font-weight: 600; color: var(--ink); }
td.dim { color: var(--muted); }
.share-bar { display: inline-block; width: 44px; height: 4px; border-radius: 2px; background: var(--line); vertical-align: middle; margin-left: 8px; position: relative; overflow: hidden; }
.share-bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink-2); border-radius: 2px; }
tr.hl .share-bar i { background: var(--c-blue); }
@media (max-width: 480px) { .share-bar { display: none; } }

/* ---------- milestones ---------- */
.miles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 12px; }
.mile { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.mile .mv { font: 600 15px var(--mono); }
.mile .md { font-size: 11.5px; color: var(--muted); }
.mile.done { border-color: rgba(63, 191, 127, 0.45); }
.mile.done .mv { color: var(--good); }
.mile.next { border-style: dashed; border-color: var(--c-blue); background: rgba(79, 143, 247, 0.06); }
.progress { height: 6px; border-radius: 3px; background: var(--line); margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.prog-note { font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.prog-note b { font-family: var(--mono); }

/* ---------- CCTP diverging bars ---------- */
.flow { display: grid; grid-template-columns: minmax(64px, 96px) 1fr; gap: 8px 10px; align-items: center; margin-top: 14px; }
.flow .fname { font-size: 12.5px; color: var(--ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow .bars { display: grid; grid-template-columns: 1fr 1fr; align-items: center; position: relative; min-height: 22px; }
.flow .bars::after { content: ''; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--faint); }
.flow .side { display: flex; align-items: center; gap: 6px; min-width: 0; }
.flow .side.out { justify-content: flex-end; }
.flow .bar { height: 14px; border-radius: 3px; min-width: 2px; }
.flow .out .bar { background: var(--c-orange); border-radius: 3px 0 0 3px; }
.flow .in .bar { background: var(--c-blue); border-radius: 0 3px 3px 0; }
.flow .amt { font: 11.5px var(--mono); color: var(--ink-2); white-space: nowrap; }
.flow-axis { display: grid; grid-template-columns: minmax(64px, 96px) 1fr; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--faint); }
.flow-axis div { display: flex; justify-content: space-between; }
.more-btn { margin-top: 10px; background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12px; color: var(--muted); cursor: pointer; }

.chain-list { display: grid; gap: 6px; margin-top: 12px; }
.chain-row { display: grid; grid-template-columns: 88px 1fr 70px; gap: 8px; align-items: center; font-size: 12.5px; }
.chain-row .cn { color: var(--ink-2); }
.chain-row .cb { height: 8px; border-radius: 2px; background: var(--line); overflow: hidden; }
.chain-row .cb i { display: block; height: 100%; background: var(--c-blue); border-radius: 2px; }
.chain-row .cv { font: 12px var(--mono); text-align: right; }

.err { color: var(--up); font-size: 12px; margin-top: 8px; }
.skeleton { color: var(--faint); font-size: 12.5px; padding: 30px 0; text-align: center; }

.foot { margin-top: 28px; font-size: 11.5px; color: var(--faint); line-height: 1.6; }
.foot p { margin: 0 0 4px; }

@media (prefers-reduced-motion: reduce) {
  .live-pill i, .live-dot, .icon-btn.spin svg { animation: none; }
}

/* 휴대폰 폭: 표를 한 화면에 맞춘다 */
@media (max-width: 560px) {
  td.name b { display: block; margin: 0; }
  td.name span { display: block; font-size: 10.5px; max-width: 108px; overflow: hidden; text-overflow: ellipsis; }
  th, td { padding: 7px 4px; }
  td { font-size: 12px; }
  #c-stables td.name, #c-stables th:first-child { max-width: 110px; }
}

/* =====================================================================
   휴대폰 우선 레이아웃 (하단 탭 · 주가 · 요약)
   ===================================================================== */
[hidden] { display: none !important; }
:root { --warn: #e0a43a; --tabbar-h: 60px; }
body { padding-bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px)); -webkit-tap-highlight-color: transparent; }
main { padding-top: 12px; }

.top { gap: 0; padding-bottom: 8px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.brand h1 { font-size: 17px; }
.status .live-dot, .kpi .live-dot { margin-right: 4px; vertical-align: 1px; }
.chip-btn {
  height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.chip-btn:active, .icon-btn:active { background: var(--surface-2); }

.view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 900px) {
  .view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #c-price, #c-summary, .view .group-h, .kpis, #c-stables, #c-lending, #c-cctp, #c-pricechart, #c-short { grid-column: 1 / -1; }
}
.group-h { margin: 8px 2px -2px; display: flex; justify-content: space-between; align-items: baseline; }
.group-h span { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); }

/* 카드 · 설명 버튼: 손가락으로 누르기 쉽게 */
.card { padding: 16px 16px 14px; }
.card-h h3 { font-size: 16px; }
.info-btn { width: 30px; height: 30px; position: relative; margin: -4px -4px 0 0; }
.info-btn::after { content: ''; position: absolute; inset: -8px; }
.info { font-size: 13.5px; }
.pulse-card { animation: pulse-card 1.4s ease-out; }
@keyframes pulse-card { 0% { box-shadow: 0 0 0 2px var(--c-blue); } 100% { box-shadow: 0 0 0 2px transparent; } }

/* KPI 타일 = 버튼 */
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
button.kpi { border: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; padding: 12px 14px 13px; min-height: 84px; }
button.kpi:active { background: var(--surface-2); }
.kpi .v { font-size: clamp(18px, 5.2vw, 22px); }

/* ---------- 실시간 주가 ---------- */
.px-main { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; }
.px-last { font: 600 clamp(34px, 11vw, 44px)/1.05 var(--mono); letter-spacing: -0.035em; border-radius: 6px; padding: 0 2px; margin-left: -2px; }
.px-chg { font: 600 14px var(--mono); }
.px-chg .lbl { font: 400 12px var(--sans); color: var(--muted); }
.px-main.sm .px-last { font-size: clamp(26px, 8vw, 32px); }
.px-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.px-meta .warn { color: var(--warn); }
.flash-up { animation: flash-up 0.9s ease-out; }
.flash-down { animation: flash-down 0.9s ease-out; }
@keyframes flash-up { 0% { background: rgba(240, 97, 109, 0.35); } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: rgba(91, 155, 255, 0.35); } 100% { background: transparent; } }
.chart.spark { height: 92px; margin-top: 10px; }
.px-range { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-top: 10px; font: 11.5px var(--mono); color: var(--muted); }
.px-range .rb { position: relative; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--down), var(--line) 50%, var(--up)); opacity: 0.8; }
.px-range .rb i { position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); border: 2px solid var(--surface); transform: translate(-50%, -50%); transition: left 0.3s; }
.px-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 14px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; }
.px-stats div { background: var(--surface); padding: 9px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.px-stats span { font-size: 11px; color: var(--muted); }
.px-stats b { font: 600 14px var(--mono); white-space: nowrap; }
.px-stats small { font-size: 10.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-btn {
  display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; margin-top: 12px; min-height: 42px;
  border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 13px; cursor: pointer;
}
.link-btn svg, .sum-list svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.link-btn:active { background: var(--surface-2); }
.seg.range { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; margin-top: 12px; }
.seg.range button { padding: 8px 0; font-size: 13px; }

/* ---------- 요약 ---------- */
.sum-line { margin: 12px 0 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.45; text-wrap: balance; }
.sum-line span { white-space: nowrap; }
.sum-line .pos { color: var(--good); }
.sum-line .neg { color: var(--warn); }
.sum-line .neu { color: var(--ink); }
.sum-line i { font-style: normal; color: var(--faint); margin: 0 6px; }
.sum-count { display: flex; gap: 6px; margin-top: 8px; }
.tone {
  display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 11px; font-weight: 600; line-height: 1;
  padding: 4px 7px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.tone.pos { color: var(--good); background: rgba(63, 191, 127, 0.12); border-color: rgba(63, 191, 127, 0.3); }
.tone.neg { color: var(--warn); background: rgba(224, 164, 58, 0.12); border-color: rgba(224, 164, 58, 0.3); }
.tone.neu { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.tone.px { color: var(--ink-2); background: var(--surface-2); border-color: var(--line); }
.sum-list { list-style: none; margin: 10px -16px -6px; padding: 0; }
.sum-list li + li { border-top: 1px solid var(--line-soft); }
.sum-list button {
  width: 100%; display: grid; grid-template-columns: 52px 1fr 16px; gap: 8px; align-items: center; text-align: left;
  padding: 11px 16px; border: 0; background: transparent; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; cursor: pointer;
}
.sum-list button:active { background: var(--surface-2); }
.sum-list .tone { justify-self: start; }
.sum-list b { font-family: var(--mono); color: var(--ink); font-weight: 600; }
.sum-list .txt span { font-family: var(--mono); font-size: 12.5px; }
.sum-list svg { color: var(--faint); }

/* ---------- 하단 탭바 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 4px max(8px, env(safe-area-inset-left, 0px)) calc(4px + env(safe-area-inset-bottom, 0px));
  background: rgba(16, 20, 26, 0.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  height: var(--tabbar-h); border: 0; background: transparent; color: var(--faint); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600;
}
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="page"] { color: var(--ink); }
.tabbar button[aria-current="page"] svg { stroke: var(--c-blue); }
@media (min-width: 900px) { .tabbar { left: 50%; right: auto; width: 480px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; } }

/* ---------- 좁은 화면 표 ---------- */
.only-narrow { display: none; }
@media (max-width: 560px) {
  .opt { display: none; }
  .only-narrow { display: block; }
  .flow { grid-template-columns: 74px 1fr; }
  .flow-axis { grid-template-columns: 74px 1fr; }
}
.foot { margin-top: 20px; }
@media (prefers-reduced-motion: reduce) { .pulse-card, .flash-up, .flash-down { animation: none; } }

@media (max-width: 560px) {
  .miles { display: flex; overflow-x: auto; gap: 8px; scroll-snap-type: x mandatory; margin-inline: -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .miles::-webkit-scrollbar { display: none; }
  .mile { flex: 0 0 auto; min-width: 104px; scroll-snap-align: start; }
  .pair { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .pair .chart { height: 130px; }
}

/* ---------- 동기화 알림 · 추가 카드 ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.2s ease-out;
}
.toast.warn { border-color: rgba(224, 164, 58, 0.5); color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.status .live-dot { margin-right: 4px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pair .mini-h { margin-top: 12px; }
#c-reserve .px-stats b { font-size: 13.5px; }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- 뉴스 · 공시 탭 ---------- */
.tabbar { grid-template-columns: repeat(5, 1fr); }
.tabbar button { position: relative; }
.tab-badge {
  position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--up); color: #fff; font: 700 10px/17px var(--mono); text-align: center;
}
@media (min-width: 900px) { .tabbar { width: 560px; } }

.ns-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 12px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; }
@media (min-width: 720px) { .ns-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ns-grid div { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ns-grid span { font-size: 11.5px; color: var(--muted); }
.ns-grid b { font: 600 17px var(--mono); }
.ns-grid small { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-top { display: grid; gap: 4px; margin-top: 12px; padding: 12px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--surface-2); }
.ns-top .nt { font-size: 14.5px; font-weight: 600; line-height: 1.45; }

.news-card { padding-bottom: 8px; }
.nf { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
.nf::-webkit-scrollbar { display: none; }
.nf button {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px; border-radius: 17px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.nf button small { font: 11px var(--mono); color: var(--faint); }
.nf button[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.nf button[aria-pressed="true"] small { color: var(--ground); opacity: 0.7; }
.nf-opt { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.nf-opt input { width: 18px; height: 18px; accent-color: var(--c-blue); }
.nf-opt { flex-wrap: wrap; }
.nf-opt small { color: var(--faint); font-size: 11px; flex-basis: 100%; padding-left: 24px; }

.nl { list-style: none; margin: 8px -16px 0; padding: 0; }
.nl li.nd { padding: 14px 16px 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.nl li.empty { padding: 24px 16px; text-align: center; color: var(--faint); font-size: 13px; }
.nl a {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start;
  padding: 11px 16px; text-decoration: none; color: inherit; border-top: 1px solid var(--line-soft);
}
.nl li.nd + li a { border-top: 0; }
.nl a:active { background: var(--surface-2); }
.nl .nt { font-size: 14.5px; line-height: 1.45; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nl .nm { grid-column: 2; font-size: 11.5px; color: var(--muted); }
.nk {
  display: inline-block; min-width: 44px; padding: 3px 6px; border-radius: 5px; margin-top: 2px;
  font: 600 10.5px/1.3 var(--sans); text-align: center; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.ns-top .nk { justify-self: start; }
.nk.official { color: var(--c-blue); border-color: rgba(79, 143, 247, 0.45); background: rgba(79, 143, 247, 0.1); }
.nk.kr { color: var(--ink-2); }
.nk.en { color: var(--muted); }
.nk.filing { font-family: var(--mono); }
.nk.filing.hi { color: var(--warn); border-color: rgba(224, 164, 58, 0.5); background: rgba(224, 164, 58, 0.1); }
.nk.filing.low { color: var(--faint); }
.new { font-style: normal; font: 700 10px var(--mono); color: var(--up); margin-right: 6px; vertical-align: 1px; }

/* ---------- 서클 실적 ---------- */
.er-next { margin-top: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(79, 143, 247, 0.4); background: rgba(79, 143, 247, 0.08); }
.er-next-h { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.er-next-d { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 2px; }
.er-next-d b { font-size: 20px; font-weight: 700; }
.er-dday { font: 700 18px var(--mono); color: var(--c-blue); }
.er-next-m { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.er-next-m b { font-family: var(--mono); color: var(--ink); }
.er-next .note { margin-top: 6px; }
.er-grid b { font-size: 16px; }
.er-grid small { white-space: normal; }
.er-h { font-size: 12px; color: var(--muted); margin-top: 14px; }
.er-pair .chart { height: 150px; }
