:root {
  --bg: #060b18;
  --panel: rgba(12, 19, 38, 0.86);
  --panel-solid: #0c1326;
  --line: rgba(140, 170, 255, 0.14);
  --text: #e8eeff;
  --muted: #8d9bc0;
  --accent: #5ab0ff;
  --up: #3ddc97;
  --down: #ff6b7a;
  --warn: #ffc857;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
#globe { position: fixed; inset: 0; }

.top { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #9fd3ff, #2b6fd6 55%, #0b2a5c);
  box-shadow: 0 0 18px rgba(90, 176, 255, .6); }
h1 { font-size: 17px; margin: 0; letter-spacing: -.02em; }
.sub { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); }
.ghost { background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 13px; }
.ghost.on { background: var(--accent); color: #04122a; border-color: transparent; font-weight: 600; }

.chips { position: fixed; top: calc(58px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 5; display: flex; gap: 6px;
  overflow-x: auto; padding: 4px 16px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: rgba(12,19,38,.75); backdrop-filter: blur(8px);
  border-radius: 999px; padding: 7px 12px; font-size: 13px; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, rgba(12,19,38,.85)); }
.chip.on .dot { background: var(--c); box-shadow: 0 0 8px var(--c); }
.chip.grp { border: none; background: none; color: var(--muted); font-size: 11.5px; padding: 7px 2px 7px 8px; cursor: default; }
.chip.add { border-style: dashed; color: var(--muted); }

.panel { position: fixed; z-index: 6; right: 16px; top: 112px; bottom: 16px; width: 400px; background: var(--panel);
  backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.handle { display: none; }
.tabs { display: flex; gap: 4px; padding: 10px 10px 0; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: none; padding: 9px 4px 11px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.panel-body::-webkit-scrollbar { width: 6px; } .panel-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.co-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.co-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.co-head .tag { font-size: 12px; color: var(--muted); }
.src { font-size: 11.5px; color: var(--muted); margin: 4px 0 14px; line-height: 1.5; }
.src a { color: var(--accent); text-decoration: none; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.tile { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.tile .k { font-size: 11.5px; color: var(--muted); }
.tile .v { font-size: 19px; font-weight: 700; margin-top: 3px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
h3.sec { font-size: 13px; color: var(--muted); font-weight: 600; margin: 18px 0 8px; display: flex; justify-content: space-between; }
.bars { display: flex; flex-direction: column; gap: 2px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 8px; border-radius: 9px; background: none; border: none; text-align: left; }
.bar:hover { background: rgba(255,255,255,.05); }
.bar .n { font-size: 13.5px; } .bar .n .cnt { color: var(--muted); font-size: 12px; margin-left: 4px; }
.bar .a { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.bar .track { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.06); overflow: hidden; display: flex; }
.bar .track i { display: block; height: 100%; }

.filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.filters button { font-size: 12px; padding: 5px 10px; }
.ent { border-bottom: 1px solid var(--line); padding: 10px 2px; }
.ent-top { display: flex; justify-content: space-between; gap: 10px; cursor: pointer; }
.ent .nm { font-size: 13.5px; line-height: 1.35; word-break: break-word; }
.ent .loc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ent .loc .guess { color: var(--warn); }
.ent .amt { text-align: right; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ent .amt .rate { display: block; color: var(--muted); font-size: 12px; }
.chg { font-size: 11.5px; margin-left: 4px; } .chg.up { color: var(--up); } .chg.down { color: var(--down); }
.ent-detail { display: none; margin-top: 8px; font-size: 12.5px; color: var(--muted); background: rgba(255,255,255,.03); border-radius: 9px; padding: 9px 10px; }
.ent.open .ent-detail { display: block; }
.ent-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 8px; }
.ent-detail dt { color: var(--muted); } .ent-detail dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }
select, input, textarea { font: inherit; color: var(--text); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
select { max-width: 100%; }

.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cmp th, .cmp td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.cmp th:first-child, .cmp td:first-child { text-align: left; }
.cmp th { color: var(--muted); font-weight: 500; }

.memo label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 5px; }
.memo textarea { width: 100%; min-height: 70px; resize: vertical; line-height: 1.5; }
.memo .row { display: flex; gap: 8px; align-items: center; }
.memo input[type=number] { width: 90px; }
.saved { font-size: 11.5px; color: var(--up); margin-left: 8px; opacity: 0; transition: opacity .3s; }
.saved.show { opacity: 1; }
.pf-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.note { font-size: 11.5px; color: var(--muted); line-height: 1.6; margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.empty { color: var(--muted); font-size: 13.5px; line-height: 1.7; padding: 20px 0; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }

.legend { position: fixed; left: 16px; bottom: 16px; z-index: 5; font-size: 12px; color: var(--muted); background: rgba(12,19,38,.7);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; backdrop-filter: blur(8px); max-width: 300px; line-height: 1.6; }
.legend:empty { display: none; }

.tooltip { font-family: inherit; background: rgba(8,14,30,.92); border: 1px solid var(--line); padding: 8px 10px; border-radius: 9px; font-size: 12.5px; line-height: 1.5; }

dialog { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); width: min(420px, calc(100vw - 32px)); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.55); }
.dlg { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.dlg h3 { margin: 0; }
#addResults { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
#addResults li button { width: 100%; text-align: left; background: none; border: none; padding: 9px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
#addResults li button span { color: var(--muted); font-size: 12px; margin-left: 6px; }

@media (max-width: 760px) {
  .panel { left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 46vh; border-radius: 18px 18px 0 0; border-bottom: none;
    transition: height .25s ease; padding-bottom: env(safe-area-inset-bottom); }
  .panel.full { height: calc(100vh - 110px); height: calc(100dvh - 110px); }
  .panel.mini { height: 104px; }
  .handle { display: flex; justify-content: center; background: none; border: none; padding: 8px 0 0; }
  .handle span { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); }
  .tabs { padding-top: 2px; }
  .legend { display: none; }
  .tile .v { font-size: 17px; }
}
