/* 주식·코인 분석 앱 스타일. 기본은 어두운 테마, 시스템·설정에 따라 밝은 테마 */
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #151a21;
  --panel-2: #1c222b;
  --border: #272e39;
  --grid: #1d232c;
  --text: #e7eaee;
  --muted: #8a93a3;
  --accent: #4c8dff;
  --accent-weak: rgba(76, 141, 255, 0.14);
  --warn: #f5a524;
  --error: #ff6b6b;
  --success: #2fbf71;
  --up: #f04452;
  --down: #3182f6;
  --up-a: rgba(240, 68, 82, 0.45);
  --down-a: rgba(49, 130, 246, 0.45);
  --bb: #7c8799;
  --support: #2fbf71;
  --resist: #f5a524;
  --trend: #a78bfa;
  --draw: #e7eaee;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --chart-base: 440px;
  --pane-h: 110px;
  --top-h: 56px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f3f5f8;
    --panel: #ffffff;
    --panel-2: #f1f3f6;
    --border: #e1e5eb;
    --grid: #eef1f4;
    --text: #191f28;
    --muted: #6b7684;
    --accent-weak: rgba(76, 141, 255, 0.12);
    --bb: #94a3b8;
    --draw: #191f28;
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --border: #e1e5eb;
  --grid: #eef1f4;
  --text: #191f28;
  --muted: #6b7684;
  --accent-weak: rgba(76, 141, 255, 0.12);
  --bb: #94a3b8;
  --draw: #191f28;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}
/* 해외식: 상승 초록, 하락 빨강 */
:root[data-colors="global"] {
  --up: #16c784;
  --down: #ea3943;
  --up-a: rgba(22, 199, 132, 0.45);
  --down-a: rgba(234, 57, 67, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

h2, h3, h4 { letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--error); }
.up { color: var(--up); }
.down { color: var(--down); }
.grow { flex: 1; }
.note { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.empty { padding: 24px 0; text-align: center; }

/* ---------- 상단·레이아웃 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 800; text-decoration: none; white-space: nowrap; }
.brand span { color: var(--text); font-size: 15px; }
.top-search { flex: 1; max-width: 560px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }

.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
.sidebar {
  position: sticky;
  top: var(--top-h);
  height: calc(100vh - var(--top-h));
  overflow-y: auto;
  padding: 14px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.main { min-width: 0; padding: 0 20px 48px; }
.main > .view { display: none; }
.main > .view.active { display: block; }

.tabs {
  position: sticky;
  top: var(--top-h);
  z-index: 30;
  display: flex;
  gap: 2px;
  margin: 0 -20px 16px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.tabs button {
  padding: 13px 14px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-color: var(--accent); }
.bottom-nav { display: none; }

.view-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin: 4px 0 14px; }
.view-head h2 { margin: 0; font-size: 20px; }

/* ---------- 공용 컴포넌트 ---------- */
.card {
  margin-bottom: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; font-size: 15px; }
.card h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card .cards { margin-bottom: 0; }
.stat { padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.card .stat { background: var(--panel-2); border-color: transparent; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-value { margin-top: 4px; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-sub { margin-top: 3px; font-size: 12px; font-variant-numeric: tabular-nums; }

.btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.buy { background: var(--up); border-color: var(--up); color: #fff; }
.btn.sell { background: var(--down); border-color: var(--down); color: #fff; }
.btn.danger { color: var(--error); }
.btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.btn.on { border-color: var(--warn); color: var(--warn); }
.icon-btn {
  display: inline-flex;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

.seg { display: inline-flex; padding: 2px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; }
.seg button {
  padding: 6px 11px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.seg.small button { padding: 4px 8px; font-size: 12px; }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; padding: 9px; }
.seg button.buy.active { background: var(--up); color: #fff; }
.seg button.sell.active { background: var(--down); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }

input, select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
input:disabled { opacity: 0.7; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 12px; color: var(--muted); }
.field > span { font-weight: 700; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.form-row .field { flex: 1 1 120px; }
.form-row .field.grow { flex: 2 1 160px; }
.form-row .field.grow2 { flex: 3 1 240px; }
.form-row .field.actions { flex: 0 0 auto; flex-direction: row; gap: 6px; }
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; cursor: pointer; }

.mk { flex: none; display: inline-block; padding: 2px 5px; border-radius: 4px; font-size: 10px; font-weight: 800; line-height: 1.25; }
.mk-KR { background: rgba(76, 141, 255, 0.16); color: #4c8dff; }
.mk-US { background: rgba(47, 191, 113, 0.16); color: #2fbf71; }
.mk-CRYPTO { background: rgba(245, 165, 36, 0.18); color: #e09612; }
.cell-name { display: flex; align-items: center; gap: 6px; min-width: 0; }

.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.tbl.compact td { padding: 6px 8px; }
.tbl.clickable tbody tr { cursor: pointer; }
.tbl.clickable tbody tr:hover { background: var(--panel-2); }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.actions-cell { display: flex; gap: 4px; justify-content: flex-end; }
.open-row td { background: var(--accent-weak); }

.tag { padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 800; }
.tag.support { color: var(--support); background: color-mix(in srgb, var(--support) 15%, transparent); }
.tag.resistance { color: var(--resist); background: color-mix(in srgb, var(--resist) 15%, transparent); }

/* ---------- 검색 ---------- */
.search-box { position: relative; }
.search-box input {
  padding-left: 34px;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 11px center;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.search-item.active, .search-item:hover { background: var(--panel-2); }
.si-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-code { flex: none; color: var(--muted); font-size: 12px; }
.si-extra { margin-left: auto; max-width: 35%; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 10px; color: var(--muted); }

/* ---------- 관심종목 ---------- */
.wl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.wl-head h2 { margin: 0; font-size: 16px; }
#wl-filter { display: flex; margin: 10px 0 6px; }
#wl-filter button { flex: 1; }
.wl-list { display: flex; flex-direction: column; gap: 2px; }
.wl-item { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 8px; border-radius: 10px; cursor: pointer; }
.wl-item:hover, .wl-item.active { background: var(--panel-2); }
.wl-name { flex: 1; min-width: 0; }
.wl-title { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.wl-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-code { margin-top: 2px; font-size: 11px; }
.wl-quote { text-align: right; font-variant-numeric: tabular-nums; }
.wl-price { font-weight: 800; }
.wl-chg { font-size: 12px; }
.wl-del { padding: 2px 4px; border: 0; background: none; color: var(--muted); font-size: 16px; opacity: 0; cursor: pointer; }
.wl-item:hover .wl-del { opacity: 1; }
@media (hover: none) { .wl-del { opacity: 0.6; } }

/* ---------- 차트 ---------- */
.chart-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; padding: 2px 0 12px; }
.sym-info { flex: 1 1 260px; min-width: 0; }
.sym-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sym-title h2 { margin: 0; font-size: 22px; }
.sym-sub { margin-top: 3px; font-size: 12px; }
.sym-price { text-align: right; font-variant-numeric: tabular-nums; }
.price-big { font-size: 26px; font-weight: 800; }
.sym-actions { display: flex; gap: 6px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; }

.chart-wrap { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.chart { height: calc(var(--chart-base) + var(--extra-panes, 1) * var(--pane-h)); }
.chart-wrap.drawing .chart { cursor: crosshair; }
.legend { position: absolute; top: 6px; left: 8px; z-index: 3; max-width: calc(100% - 100px); font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; }
.lg-row { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 1px 4px; border-radius: 6px; background: color-mix(in srgb, var(--panel) 78%, transparent); }
.lg-row:empty { display: none; }
.chart-msg { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--panel); color: var(--muted); text-align: center; }
.chart-msg.error { color: var(--error); }
.chart-hint {
  position: absolute;
  top: 44px;
  left: 50%;
  z-index: 5;
  padding: 6px 12px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.chart-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.chart-info .card { margin-bottom: 0; }
.sig-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.sig { display: flex; align-items: center; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.sig-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sig span:last-child { color: var(--text); }

/* ---------- 분석 패널 ---------- */
.insight { margin-top: 14px; }
.ins-tabs { margin-bottom: 14px; }
.ins-body h4 { margin: 14px 0 8px; color: var(--text); font-size: 13px; }
.ins-body h4:first-child { margin-top: 0; }
.ins-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.sum-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 12px; }
.sum-title { font-size: 17px; font-weight: 800; }
.gauge { display: flex; width: 220px; max-width: 100%; height: 10px; overflow: hidden; border-radius: 99px; background: var(--panel-2); }
.g-bull { background: var(--up); }
.g-bear { background: var(--down); }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 4px 20px; }
.sum-group h4 { margin: 10px 0 6px !important; color: var(--muted) !important; font-size: 12px !important; }
.sum-group ul { margin: 0; padding: 0; list-style: none; }
.sum-group li { display: flex; gap: 8px; padding: 3px 0; font-size: 13px; line-height: 1.5; }
.sum-group li i { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--muted); }
.sum-group li.tone-bull i { background: var(--up); }
.sum-group li.tone-bear i { background: var(--down); }
.pat-card { padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; }
.pat-card.bull { border-left-color: #22c55e; }
.pat-card.bear { border-left-color: #f97316; }
.pat-card.neutral { border-left-color: #a78bfa; }
.pat-card .muted { margin-top: 4px; }
.tag.bull { color: #16a34a; background: rgba(34, 197, 94, 0.14); }
.tag.bear { color: #ea580c; background: rgba(249, 115, 22, 0.14); }
.tag.neutral { color: #8b5cf6; background: rgba(167, 139, 250, 0.16); }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.metric { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--panel-2); border-radius: 10px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric b { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.consensus { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; line-height: 1.6; }
.fin-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 16px 0 8px; }
.fin-head h4 { margin: 0 !important; }
.peer-list { display: flex; flex-wrap: wrap; gap: 6px; }
.peer { display: flex; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 99px; background: none; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.peer:hover { background: var(--panel-2); }
.desc { margin-top: 12px; font-size: 13px; }
.desc summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.desc p { line-height: 1.6; white-space: pre-line; }
.flow-chart { height: 220px; margin-top: 6px; }
.ins-tabs { overflow-x: auto; scrollbar-width: none; }
.ins-tabs button { flex: 1 0 auto; white-space: nowrap; }

/* AI 분석 */
.ai-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.ai-ok { color: var(--success); font-weight: 800; }
.ai-warn { color: var(--warn); font-weight: 800; }
.ai-model { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ai-model select { width: auto; padding: 5px 8px; }
.ai-meta { margin: 12px 0 6px; }
.ai-text { padding: 4px 2px; font-size: 14.5px; line-height: 1.75; }
.ai-text h4 { margin: 18px 0 6px !important; color: var(--text) !important; font-size: 15px !important; }
.ai-text p { margin: 4px 0; }
.ai-text ul { margin: 4px 0; padding-left: 20px; }
.progress .bar span.indet { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* 차트 쉬운 해설 */
.explain-card { margin-top: 14px; }
.ex-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.ex-head h3 { margin: 0; }
.ex-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.ex-list li { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); cursor: pointer; }
.ex-list li:hover { outline: 1px solid var(--accent); }
.ex-num { flex: none; font-size: 20px; line-height: 1.1; color: var(--accent); font-weight: 800; }
.ex-list p { margin: 4px 0 0; font-size: 13px; line-height: 1.65; }
.sw { display: inline-block; width: 10px; height: 10px; margin: 0 4px 0 2px; border-radius: 3px; vertical-align: -1px; }
.chip[data-k="explain"].active { background: var(--accent); color: #fff; }

/* 쉽게 보기 */
.easy-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.easy-badge:hover { border-color: var(--accent); }
.easy-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.easy-icon { font-size: 44px; line-height: 1; }
.easy-title { font-size: 19px; font-weight: 800; }
.easy-rets { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.easy-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.easy-flags span { padding: 4px 10px; border-radius: 99px; background: rgba(245, 165, 36, 0.14); color: var(--warn); font-size: 12px; font-weight: 700; }
.easy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 14px; }
.eg { padding: 12px; border-radius: 12px; background: var(--panel-2); }
.eg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.eg-text { font-weight: 800; }
.eg-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin: 8px 0; }
.eg-bar i { height: 8px; border-radius: 3px; background: var(--border); }
.eg-bar i.fill { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.eg-bar i.on { background: var(--accent); }
.eg p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text); }
.range-bar { position: relative; height: 8px; margin: 10px 0 2px; border-radius: 99px; background: linear-gradient(90deg, var(--down-a), var(--border), var(--up-a)); }
.range-bar span { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: var(--text); }
.range-ends { display: flex; justify-content: space-between; margin-bottom: 6px; }
.easy-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.easy-list { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.8; }
.easy-list li.support::marker { color: var(--support); }
.easy-list li.resistance::marker { color: var(--resist); }
.easy-ev { padding: 8px 0; border-bottom: 1px solid var(--border); }
.easy-ev p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.glossary { margin-top: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.glossary summary { cursor: pointer; font-weight: 700; }
.glossary dl { margin: 10px 0 0; }
.glossary dt { margin-top: 10px; font-weight: 800; }
.glossary dd { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* 패턴 통계 */
.stats-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.base-box, .now-box { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); font-size: 13px; line-height: 1.6; }
.now-box { background: var(--accent-weak); }
.now-box h4 { margin: 0 0 4px !important; }
.now-box p { margin: 4px 0; }
.stats-tbl tr.grp td { padding-top: 14px; color: var(--muted); font-size: 12px; font-weight: 800; border-bottom: 0; }
.stats-tbl tbody tr[data-occ] { cursor: pointer; }
.stats-tbl tbody tr[data-occ]:hover { background: var(--panel-2); }
.stats-tbl tr.is-now td { background: var(--accent-weak); }
.wr { position: relative; display: inline-block; width: 60px; height: 6px; margin-right: 6px; border-radius: 99px; background: var(--panel-2); vertical-align: middle; }
.wr span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--accent); }
.wr .base { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--text); opacity: 0.6; }
.wr.small-n { opacity: 0.45; }
.dot.tone-bull { background: #22c55e; }
.dot.tone-bear { background: #f97316; }
.dot.tone-neutral { background: #a78bfa; }
.occ-row td { background: var(--panel-2); white-space: normal; }
.occ-list { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; }
.occ { white-space: nowrap; color: var(--muted); }

/* 유사 차트 */
.sim-controls { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; }
.sim-controls > div { display: flex; align-items: center; gap: 6px; }
.sim-sum p { margin: 4px 0; line-height: 1.6; }
.warn-box { padding: 8px 12px; border-radius: 10px; background: rgba(245, 165, 36, 0.14); color: var(--warn); font-size: 13px; }
.sim-chart { height: 320px; margin: 10px 0 4px; }

/* ---------- 포트폴리오 ---------- */
.alloc-bar { display: flex; height: 14px; overflow: hidden; border-radius: 99px; background: var(--panel-2); }
.alloc-bar span { display: block; height: 100%; }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 16px; font-size: 12px; }
.alloc-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }

/* ---------- 모의투자 ---------- */
.grid-2 { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 14px; align-items: start; }
.order-card > * + * { margin-top: 10px; }
.order-sym { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 10px; background: var(--panel-2); border-radius: 10px; }
.order-price { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quick { display: flex; gap: 6px; }
.quick button { flex: 1; padding: 5px; border: 1px solid var(--border); border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.quick button:hover { color: var(--text); }
.order-est > div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.order-est .total { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 15px; }

/* ---------- 백테스트 ---------- */
.bt-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.bt-form { align-self: start; }
.bt-form > * + * { margin-top: 10px; }
.bt-form .param-grid { margin: 0; }
.bt-chart { height: 480px; }
.legend-inline { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.ln { display: inline-block; width: 14px; height: 2px; margin: 0 4px 0 8px; vertical-align: middle; }
.ln.accent { background: var(--accent); }
.ln.muted { background: var(--muted); }

/* ---------- 백테스트 조건 조합 ---------- */
.bt-custom { display: flex; flex-direction: column; gap: 8px; }
.cb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.cb-head h4 { margin: 0; font-size: 13px; }
.cb-head select { width: auto; padding: 4px 8px; font-size: 12px; }
.cond-row { display: flex; align-items: flex-start; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.cond-row select { flex: 1 1 100%; padding: 6px 8px; font-size: 13px; }
.cond-row .cond-params { flex: 1; margin-top: 0; }
.cond-row .icon-btn { margin-left: auto; font-size: 14px; }
.bt-custom > .btn { align-self: flex-start; }
.row-btns .grow { flex: 1; }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.bt-chart.small { height: 340px; }

/* ---------- 조건검색 ---------- */
.preset-row { margin-top: 10px; }
.cond-group { margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.cond-list + .cond-group { margin-top: 18px; }
td.matched { white-space: normal; min-width: 180px; }
td.matched .tag { display: inline-block; margin: 1px 0; font-weight: 600; }
.cond-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin-top: 14px; }
.cond { padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.cond.on { border-color: var(--accent); background: var(--accent-weak); }
.cond-params { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; }
.cond:not(.on) .cond-params { opacity: 0.5; }
.cond-param { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.cond-param input { width: 72px; padding: 4px 6px; }
.progress { margin-top: 14px; }
.progress .bar { height: 6px; overflow: hidden; border-radius: 99px; background: var(--panel-2); }
.progress .bar span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 0.3s; }
.progress .small { margin-top: 6px; }

/* ---------- 대화상자·알림 ---------- */
.dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 20px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.dialog h3 { margin: 0 0 14px; font-size: 17px; }
.dialog h4 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); }
.dialog form > label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dialog fieldset { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.dialog legend { padding: 0 4px; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.fee-tbl input { width: 110px; padding: 5px 8px; }
.dialog { overflow-y: auto; }
.dialog.wide { width: min(720px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-head h3 { margin: 0; }
.dialog form > * + * { margin-top: 10px; }
.dialog .param-grid { margin: 0; }

/* ---------- 알림 ---------- */
.bell { position: relative; }
.bell-badge {
  position: absolute;
  top: 0;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--up);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}
.al-body { margin-top: 14px; min-height: 160px; }
.al-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ev-list, .al-list { display: flex; flex-direction: column; gap: 6px; }
.ev {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ev:hover { background: var(--panel-2); }
.ev.unread { border-color: var(--accent); background: var(--accent-weak); }
.ev-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ev-top .muted { margin-left: auto; }
.ev-msg { margin-top: 4px; font-size: 13px; color: var(--muted); }
.al-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.al-item.off { opacity: 0.6; }
.al-main { flex: 1; min-width: 0; cursor: pointer; }
.al-main > div + div { margin-top: 2px; }
.switch { position: relative; flex: none; width: 38px; height: 22px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border); transition: background 0.15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ch { padding: 12px 0; border-bottom: 1px solid var(--border); }
.ch h4 { margin: 0 0 6px; color: var(--text); font-size: 14px; }
.ch p { margin: 4px 0; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.phone-grid { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; margin-bottom: 10px; }
.qr { width: 150px; height: 150px; padding: 6px; background: #fff; border-radius: 10px; }
.steps { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.mono { font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
@media (max-width: 520px) { .phone-grid { grid-template-columns: minmax(0, 1fr); justify-items: center; } }
.sub-h { margin: 14px 0 6px; font-size: 13px; color: var(--text); }
.users-tbl { margin: 8px 0 12px; }
.users-tbl .row-actions { text-align: right; white-space: nowrap; }
.users-tbl .row-actions .btn + .btn { margin-left: 4px; }
#users-section { margin-top: 14px; }
.me-chip {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: transparent;
  color: var(--text); font: inherit; font-size: 12px; cursor: pointer; max-width: 9em; overflow: hidden; text-overflow: ellipsis;
}
.me-chip:hover { border-color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  transform: translate(-50%, 16px);
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--error); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

/* ---------- 모바일 ---------- */
@media (max-width: 899px) {
  :root { --chart-base: 300px; --pane-h: 86px; --top-h: 52px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span, #fx { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: static; height: auto; padding: 12px 16px 96px; border-right: 0; background: transparent; }
  body[data-view="watchlist"] .sidebar { display: block; }
  body[data-view="watchlist"] .main { display: none; }
  .tabs { display: none; }
  .main { padding: 12px 16px 96px; }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--panel);
    border-top: 1px solid var(--border);
  }
  .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 7px;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
  }
  .bottom-nav .ico { font-size: 17px; line-height: 1.1; filter: grayscale(1); opacity: 0.75; }
  .bottom-nav button.active { color: var(--accent); }
  .bottom-nav button.active .ico { filter: none; opacity: 1; }

  .chart-head { gap: 8px 12px; }
  .sym-title h2 { font-size: 18px; }
  .price-big { font-size: 22px; }
  .sym-actions { width: 100%; }
  .sym-actions .btn { flex: 1; }
  #c-tf { display: flex; width: 100%; }
  #c-tf button { flex: 1; padding: 7px 0; }
  .legend { font-size: 11px; max-width: calc(100% - 90px); }
  .lg-row + .lg-row { display: none; }
  .chips, .tools { flex-wrap: nowrap; width: 100%; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .chip, .tools .btn { flex: none; }
  .table-scroll .tbl th:first-child, .table-scroll .tbl td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); }
  .chart-info, .grid-2, .bt-layout, .ins-cols { grid-template-columns: minmax(0, 1fr); }
  .sum-grid { grid-template-columns: minmax(0, 1fr); }
  .ins-tabs { display: flex; }
  .ins-tabs button { padding: 7px 10px; font-size: 12px; white-space: nowrap; letter-spacing: -0.02em; }
  .sim-chart { height: 260px; }
  .easy-cols { grid-template-columns: minmax(0, 1fr); }
  .easy-grid { grid-template-columns: minmax(0, 1fr); }
  .easy-icon { font-size: 36px; }
  .easy-title { font-size: 17px; }
  .bt-form { position: static; }
  .bt-chart { height: 400px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px; }
  .stat-value { font-size: 16px; }
  .card { padding: 14px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
