:root {
  --bg: #0b0f17; --panel: #111722; --panel2: #171e2c; --line: #232c3d;
  --text: #e6e9ef; --muted: #8b95a7; --up: #f04452; --down: #3b82f6; --accent: #7aa2ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; }
a { color: inherit; }

header.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: rgba(11, 15, 23, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; white-space: nowrap; text-decoration: none; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a.active { background: var(--panel2); color: var(--text); }
.top-right { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; white-space: nowrap; }

button, input {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
}
button { cursor: pointer; }
button:hover { border-color: #3a475e; }
input:focus { outline: 1px solid var(--accent); }

main { padding: 20px; max-width: 1880px; margin: 0 auto; }
.page-head h1 { margin: 0; font-size: 22px; }
.sub { color: var(--muted); margin: 4px 0 16px; }
.hint { color: var(--muted); font-size: 12px; }
.loading { color: var(--muted); padding: 24px; text-align: center; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.sy { color: var(--muted); font-size: 11px; font-weight: 400; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* main page */
.group { margin-bottom: 22px; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.group-head h2 { font-size: 15px; margin: 0; color: var(--muted); font-weight: 600; }
.more { color: var(--accent); text-decoration: none; font-size: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.card {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; text-decoration: none; transition: border-color .15s;
}
.card:hover { border-color: #3a475e; }
.card-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.card-top .name { font-weight: 600; }
.price { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.chg { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.spark { width: 100%; height: 34px; display: block; margin: 6px 0 4px; }
.mini { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini b { font-weight: 600; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 14px; margin-bottom: 14px; }
.split .panel { margin-bottom: 0; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-head h2 { margin: 0; font-size: 18px; }
.detail-price { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-price .chg { font-size: 15px; margin-left: 6px; }
.detail-perf { display: flex; gap: 6px; flex-wrap: wrap; }
.pchip { background: var(--panel2); border-radius: 8px; padding: 4px 10px; font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 64px; }
.pchip span { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.tf-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1500px) { .tf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .tf-grid { grid-template-columns: minmax(0, 1fr); } }
.tf { background: var(--panel2); border-radius: 10px; padding: 10px; min-width: 0; }
.tf-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.tf-title { font-weight: 700; font-size: 13px; }
.tf-legend { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tf-chart { height: 340px; position: relative; }
.item-row { scroll-margin-top: 64px; }
.item-row.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(122, 162, 255, .35); } 100% { border-color: var(--line); box-shadow: none; } }
.view-bar {
  position: sticky; top: 53px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 8px 0; margin-bottom: 10px; background: var(--bg);
}
.view-bar .seg button { font-size: 13px; padding: 5px 12px; }
.main-bar { gap: 14px; padding: 10px 0; }
.main-title { margin: 0; font-size: 20px; }
.main-bar .seg-tf button { font-size: 14px; padding: 6px 20px; }
.tf-price small { font-size: 10px; font-weight: 400; opacity: .8; }
.tf-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.tf-wall .tf-card { margin-bottom: 0; padding: 10px 12px; min-width: 0; }
.tf-card .tf-head { margin-bottom: 2px; }
.tf-price { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.tf-price span { font-size: 12px; margin-left: 4px; }
.tf-legend-line { margin: 0 0 4px; display: block; }
.tf-card .tf-chart { height: 280px; }
@media (max-width: 640px) {
  .tf-wall { grid-template-columns: minmax(0, 1fr); }
  .view-bar { position: static; }
}
.hub-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 16px; }
.hub { display: inline-flex; gap: 8px; align-items: baseline; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; font-size: 13px; }
.hub:hover { border-color: var(--accent); }
.log-btn { padding: 2px 8px; font-size: 11px; flex: none; }
.log-btn.on { background: var(--accent); color: #0b0f17; border-color: var(--accent); }
.ma-key { display: inline-flex; gap: 8px; font-size: 10px; color: var(--muted); }
.ma-key i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 3px; }

/* compare */
.cmp-chart { height: 360px; }
.cmp-range { display: inline-flex; gap: 6px; align-items: center; }
.cmp-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 8px; }
.cmp-note { margin-left: auto; }
.cmp-tf-wrap { display: flex; gap: 8px; align-items: center; }
.seg-tf button { font-size: 13px; font-weight: 600; padding: 5px 16px; }
.cmp-panel .cmp-chart { height: 440px; min-width: 0; }
.cmp-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
@media (max-width: 1000px) { .cmp-body { grid-template-columns: minmax(0, 1fr); } }
.cmp-board { background: var(--panel2); border-radius: 10px; padding: 10px 10px 6px; max-height: 440px; overflow-y: auto; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 2px 8px; font-size: 12px; }
.board-head b { font-variant-numeric: tabular-nums; }
.brow {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; column-gap: 8px; row-gap: 4px;
  padding: 6px 6px 7px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.brow:hover { background: rgba(255, 255, 255, .05); }
.brow.off { opacity: .32; }
.brow .sw { width: 10px; height: 10px; border-radius: 3px; }
.brow .bn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow .blv { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.brow .bv { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }
.brow .bb { grid-column: 2 / -1; height: 3px; background: rgba(255, 255, 255, .06); border-radius: 2px; overflow: hidden; }
.brow .bb i { display: block; height: 100%; border-radius: 2px; opacity: .85; }
.log-btn:disabled { opacity: .35; cursor: default; }
.cmp-range input[type=date] { padding: 3px 8px; font-size: 12px; color-scheme: dark; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 12px; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip.off { opacity: .35; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.seg button.on { background: var(--line); color: var(--text); }

/* table */
.table-wrap { overflow-x: auto; }
table.perf { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.perf th { font-size: 11px; color: var(--muted); font-weight: 600; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.perf th.num { text-align: right; }
.perf th.sortable { cursor: pointer; user-select: none; }
.perf th.sortable:hover { color: var(--text); }
.perf td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, .04); white-space: nowrap; }
.perf tbody tr { cursor: pointer; }
.perf tbody tr:hover td { background-color: rgba(255, 255, 255, .03); }
.perf tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.perf .nm { font-weight: 600; }
.perf .spark { width: 90px; height: 24px; margin: 0; }

/* manage */
details.manage summary { cursor: pointer; font-weight: 600; }
details.manage summary .hint { font-weight: 400; margin-left: 6px; }
.add-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; align-items: center; }
.add-form input[type=text] { min-width: 180px; flex: 1; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chk input { padding: 0; }
.manage-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px; }
.manage-list li { display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 8px; padding: 6px 8px; }
.manage-list .nm { font-weight: 600; }
.manage-list .sy { margin-right: auto; }
.ic { padding: 2px 8px; font-size: 12px; }
.danger { color: #ff7b86; }

@media (max-width: 640px) {
  main { padding: 12px 16px; }
  header.top { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  nav.tabs { order: 3; flex-basis: 100%; }
  .tf-chart { height: 300px; }
  .cmp-chart { height: 280px; }
}
