:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c2230; --line: #2a3140; --text: #e6edf3; --muted: #8b949e;
  --entry: #00c853; --watch: #ff9800; --none: #6e7681; --up: #ef5350; --down: #4c8bf5; --accent: #58a6ff;
  --ok: #3fb950; --bad: #f85149;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: rgba(13,17,23,.95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
#topbar h1 { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-wrap { min-width: 0; flex: 1; }
#subtitle { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; font-size: 30px; line-height: 1; padding: 0 8px 4px 0; cursor: pointer; }

main { padding: 10px 12px 24px; max-width: 900px; margin: 0 auto; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tab { padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #0d1117; }
.market-info { font-size: 12.5px; color: var(--muted); margin: 8px 2px; }
.market-info b { color: var(--text); }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 2px; margin-bottom: 8px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.seg button.active { background: var(--panel2); color: var(--text); font-weight: 600; }
.seg.small button { padding: 5px 10px; font-size: 14px; }
.toolbar { display: flex; gap: 6px; }
#search { flex: 1; min-width: 0; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
#sort { padding: 9px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 11px; font-size: 13px; color: var(--muted); }
.chip.active { border-color: var(--accent); color: var(--accent); }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card-item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; cursor: pointer; }
.card-item:active { background: var(--panel2); }
.ci-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-name small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.ci-right { text-align: right; }
.ci-price { font-variant-numeric: tabular-nums; }
.ci-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dots { display: inline-flex; gap: 3px; }
.dot { font-size: 11px; width: 18px; height: 18px; display: inline-grid; place-items: center; border-radius: 5px; background: #21262d; color: #6e7681; }
.dot.on { background: rgba(63,185,80,.18); color: var(--ok); font-weight: 700; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: #21262d; color: var(--muted); }
.tag.today { background: rgba(88,166,255,.15); color: var(--accent); }
.star { color: #f1c40f; }
.up { color: var(--up); } .down { color: var(--down); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--none); color: #fff; }
.badge.entry { background: var(--entry); color: #04210f; }
.badge.watch { background: var(--watch); color: #2b1800; }
.badge.big { font-size: 15px; padding: 4px 12px; }

.hist-day { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.hist-day h3 { margin: 0; font-size: 14px; padding: 9px 12px; background: var(--panel2); display: flex; justify-content: space-between; }
.hist-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 14px; }
.hist-row.link { cursor: pointer; }
.hist-row .r { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* chart view */
#view-chart { padding-left: 0; padding-right: 0; }
#view-chart > *:not(#chart) { margin-left: 12px; margin-right: 12px; }
.quote { display: flex; justify-content: space-between; align-items: center; }
.price { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.change { font-size: 14px; margin-left: 6px; }
.controls { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.controls .seg { margin: 0; }
.toggle { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 5px 10px; font-size: 14px; color: var(--muted); }
.toggle.on { color: var(--accent); border-color: var(--accent); }
.layers { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; }
.layers .chip { padding: 5px 10px; }
.legend { font-size: 11.5px; color: var(--muted); min-height: 34px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.legend span { margin-right: 7px; white-space: nowrap; }
#chart { width: 100%; height: min(62vh, 560px); min-height: 380px; position: relative; }

#card { margin-top: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.panel h2 { font-size: 14px; margin: 0; padding: 9px 12px; background: var(--panel2); display: flex; justify-content: space-between; align-items: center; }
.verdict-head { padding: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.verdict-head .score { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row { display: grid; grid-template-columns: 26px 1fr auto; gap: 2px 8px; padding: 8px 12px; border-top: 1px solid var(--line); align-items: start; }
.row:first-of-type { border-top: 0; }
.row .ic { font-size: 16px; line-height: 1.3; }
.row .lbl { font-weight: 600; font-size: 14px; }
.row .pts { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); white-space: nowrap; }
.row .pts.got { color: var(--ok); font-weight: 700; }
.row .txt { grid-column: 2 / 4; font-size: 13px; color: var(--muted); }
.row .txt em { font-style: normal; color: var(--accent); margin-right: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; padding: 10px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.easy { margin: 0; padding: 10px 12px 10px 12px; list-style: none; font-size: 14px; }
.easy li { padding: 3px 0; }
.warn { color: #ffb74d; }
details.raw { padding: 0 12px 10px; font-size: 12px; color: var(--muted); }
.disclaimer { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 16px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #30363d; padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90vw; }
@media (min-width: 700px) { #chart { height: 600px; } }
