/* Finble 톤: 흰 바탕 + 파랑 포인트, 둥근 카드. 색은 light-dark(라이트, 다크) 토큰 — 토글은 html[data-theme] */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f4f6fa, #111317);
  --surface: light-dark(#ffffff, #1b1e23);
  --surface-2: light-dark(#f7f9fc, #22262c);
  --text: light-dark(#191f28, #f2f4f6);
  --text-2: light-dark(#4e5968, #c1c8d0);
  --muted: #8b95a1;
  --line: light-dark(#e5e8eb, #2e333a);
  --accent: light-dark(#4f7fe8, #6f9bf2);
  --accent-soft: light-dark(#eaf1fe, #1f2c44);
  --accent-ink: light-dark(#ffffff, #0d1422);
  --up: light-dark(#d93b3b, #ff6b6b);     /* 국내 관례: 상승 빨강 */
  --down: light-dark(#2a6bd6, #6aa0ff);   /* 하락 파랑 */
  --good: #0ca30c;
  --critical: #d03b3b;
  --shadow-c: light-dark(rgba(20, 30, 50, .05), transparent);
  --shadow: 0 1px 3px var(--shadow-c), 0 4px 16px var(--shadow-c);
  /* 차트 범주색 (dataviz 기본 팔레트, 검증된 순서 — 순서 바꾸지 말 것) */
  --s1: light-dark(#2a78d6, #3987e5); --s2: light-dark(#eb6834, #d95926);
  --s3: light-dark(#1baf7a, #199e70); --s4: light-dark(#eda100, #c98500);
  --s5: light-dark(#e87ba4, #d55181); --s6: #008300;
  --s7: light-dark(#4a3aa7, #9085e9); --s8: light-dark(#e34948, #e66767);
  --s-other: light-dark(#b4b2a9, #6b6a64);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); }
.muted { color: var(--muted); } .sub { color: var(--text-2); }
.accent { color: var(--accent); }
.hidden { display: none !important; }

/* 헤더 + 탭 */
header {
  position: sticky; top: 0; z-index: 10; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar { max-width: 1080px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 12px; height: 56px; }
@media (max-width: 480px) { .logo { font-size: 16px; } nav button { padding: 8px; } }
.logo { font-weight: 800; font-size: 19px; color: var(--accent); letter-spacing: -.02em; white-space: nowrap; }
nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
nav button {
  border: 0; background: none; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-weight: 600; white-space: nowrap;
}
nav button[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 50%; width: 36px; height: 36px; cursor: pointer; flex: none; }

main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.panel { display: none; scroll-margin-top: 80px; } .panel.active { display: block; }
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }

/* 섹션·카드 */
section { margin-bottom: 36px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-head h2 { font-size: 19px; margin: 0; letter-spacing: -.01em; }
.sec-head .spacer { flex: 1; }
.eyebrow { color: var(--text-2); font-size: 14px; margin: 0 0 2px; }
.headline { font-size: 20px; font-weight: 700; margin: 0 0 16px; letter-spacing: -.01em; }
.card { background: var(--surface); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.two { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 6px 12px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-2);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { padding: 12px 28px; font-size: 16px; border-radius: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; font-size: 14px; color: var(--text-2);
}
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.tag { color: var(--accent); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }

input[type="text"], input[type="number"], input:not([type]) {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; min-width: 0;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 주요 종목 카드 */
.stock-card { display: flex; flex-direction: column; gap: 8px; }
.stock-card .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stock-card .name { font-weight: 700; font-size: 16px; }
.stock-card .price { font-size: 20px; font-weight: 700; }
.spark { height: 64px; position: relative; }
.news { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.news li { padding: 6px 0; border-top: 1px solid var(--line); }
.news a { text-decoration: none; } .news a:hover { text-decoration: underline; }
.news .src { color: var(--muted); font-size: 12px; margin-left: 4px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; padding-top: 4px; list-style: none; }
.editing-only { display: none; }
.editing .editing-only { display: revert; }
.editing .view-only { display: none; }
.editor { margin-top: 12px; }
.editor form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.editor form input { flex: 1 1 140px; }
.del-btn { border: 0; background: none; color: var(--critical); cursor: pointer; font-size: 13px; padding: 0; }

/* 차트 박스 */
.chart { position: relative; height: 280px; }
.chart.sm { height: 200px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--text-2); margin: 8px 0 0; padding: 0; list-style: none; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* 통계 타일 */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }
.tile .label { color: var(--text-2); font-size: 13.5px; }
.tile .value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.tile .note { color: var(--muted); font-size: 13px; }

/* 표 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
th:first-child, td:first-child { text-align: left; }

/* 섹터 막대 (100% 누적, 조각 사이 2px) */
.stack { display: flex; gap: 2px; height: 18px; margin: 8px 0; }
.stack span { display: block; height: 100%; min-width: 3px; }
.stack span:first-child { border-radius: 4px 0 0 4px; }
.stack span:last-child { border-radius: 0 4px 4px 0; }
.stack span:only-child { border-radius: 4px; }
.donut-row { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; }
@media (max-width: 480px) { .donut-row { grid-template-columns: 1fr; } }
.donut { position: relative; height: 180px; }

/* 브리핑 */
.brief .meta { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.brief .summary { font-size: 16px; margin: 0 0 12px; white-space: pre-line; }
.brief h3 { font-size: 14px; color: var(--text-2); margin: 16px 0 6px; }
.brief ul { margin: 0; padding-left: 18px; }
.brief li { margin: 4px 0; }
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 64px); background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dlg-head { position: sticky; top: 0; background: var(--surface); padding: 16px 20px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dlg-head h2 { margin: 0; font-size: 18px; flex: 1; }
.dlg-body { padding: 8px 20px 20px; }
.dlg-body details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.dlg-body summary { cursor: pointer; font-weight: 600; }

/* 리서치 카드 */
.research .tabs { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.research blockquote { margin: 0 0 12px; padding: 12px 16px; background: var(--accent-soft); border-radius: 12px; font-weight: 600; }
.research h4 { margin: 16px 0 6px; font-size: 14px; color: var(--text-2); }
.research ul { margin: 0; padding-left: 18px; }
.research p { margin: 6px 0; }
.verdict { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); }
.pre { white-space: pre-line; }

/* 투자 실험 */
.etf { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-top: 10px; background: var(--surface-2); }
.etf .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.etf .t { font-weight: 700; font-size: 16px; }
.etf p { margin: 6px 0; font-size: 14px; color: var(--text-2); }
.alloc { display: grid; grid-template-columns: 1fr 96px auto; gap: 8px; align-items: center; padding: 6px 0; }
.alloc input { width: 100%; text-align: right; }
.alloc .pct { display: flex; align-items: center; gap: 4px; }
.sum-line { text-align: right; color: var(--muted); margin-top: 12px; font-size: 14px; }
.sum-line.ok { color: var(--good); }
.center { text-align: center; margin-top: 20px; }
.tips details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.tips summary { cursor: pointer; font-weight: 600; }
.tips p { margin: 8px 0 0; color: var(--text-2); }
.cta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--accent); color: var(--accent-ink); border-radius: 16px; padding: 20px 24px; }
.cta button { background: none; border: 0; color: inherit; font-weight: 700; cursor: pointer; font-size: 15px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
