/* ── 토큰 ──────────────────────────────────────────────
   심해 잉크 배경 + 계기판 타이포(Chakra Petch) + 선종별 시그널 컬러 */
:root {
  --bg: #0B1622;
  --panel: #0F1D2CF2;
  --line: #1E3450;
  --text: #DCE8F2;
  --muted: #7A90A6;
  --accent: #45CDEB;

  --c-cargo: #E8A33D;
  --c-tanker: #E85D4A;
  --c-ferry: #45CDEB;
  --c-largeferry: #4D8DF0;
  --c-cruise: #B48CF2;
  --c-fishing: #5FC98E;
  --c-tug: #9AA7B8;
  --c-highspeed: #F2E05C;
  --c-other: #5C6B7E;

  --font-data: 'Chakra Petch', monospace;
  --font-body: 'IBM Plex Sans KR', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}

#map { position: absolute; inset: 52px 0 0 0; background: var(--bg); }

/* ── 상단바 ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 20;
  display: flex; align-items: center; gap: 20px; padding: 0 16px;
  background: linear-gradient(180deg, #0D1A28 0%, #0B1622 100%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 20px; }
.brand-name { font-family: var(--font-data); font-size: 16px; letter-spacing: 3px; font-weight: 700; }

.mode-switch {
  display: flex; margin-left: 6px;
  border: 1px solid var(--line); border-radius: 5px; overflow: hidden;
}
.mode {
  padding: 4px 12px; font-family: var(--font-data); font-size: 11px;
  letter-spacing: 2px; text-decoration: none; color: var(--muted);
  transition: color .15s, background .15s;
}
.mode:hover { color: var(--text); background: #16283C; }
.mode.active { color: #0B1622; background: var(--accent); font-weight: 700; }

.search { flex: 0 1 340px; }
.search input {
  width: 100%; height: 32px; padding: 0 12px;
  background: #0A1420; border: 1px solid var(--line); border-radius: 4px;
  color: var(--text); font-family: var(--font-data); font-size: 13px;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search input::placeholder { color: var(--muted); font-family: var(--font-body); }

.statusbar { margin-left: auto; display: flex; gap: 18px; font-size: 12px; color: var(--muted); }
.stat em { font-style: normal; font-family: var(--font-data); font-size: 14px; color: var(--text); }
.stat.mode { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #E85D4A; display: inline-block; }
.dot.live { background: #5FC98E; box-shadow: 0 0 8px #5FC98E88; animation: pulse 2s infinite; }
.dot.demo { background: var(--c-highspeed); }
@keyframes pulse { 50% { opacity: .5; } }

/* ── 좌측 필터 레일 ── */
.rail {
  position: fixed; top: 64px; left: 12px; z-index: 15; width: 200px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; backdrop-filter: blur(8px);
}
.rail-title {
  font-family: var(--font-data); font-size: 11px; letter-spacing: 2px;
  color: var(--muted); margin-bottom: 10px;
}
.filter-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 4px;
  cursor: pointer; border-radius: 4px; user-select: none;
}
.filter-item:hover { background: #16283C; }
.filter-item.off { opacity: .35; }
.filter-chip { width: 10px; height: 10px; flex: none; }
.filter-chip.tri { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.filter-label { flex: 1; font-size: 13px; }
.filter-count { font-family: var(--font-data); font-size: 12px; color: var(--muted); }
.rail-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.toggle { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); padding: 3px 0; cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.rail-note { margin-top: 10px; font-size: 11px; line-height: 1.7; color: #4E6379; }

/* ── 상세 패널 ── */
.panel {
  position: fixed; top: 64px; right: 12px; z-index: 15; width: 300px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px; backdrop-filter: blur(8px);
}
.panel-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; line-height: 1;
}
.panel-close:hover { color: var(--text); }
.panel-cat {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  color: #0B1622; margin-bottom: 8px;
}
.panel-name { font-family: var(--font-data); font-size: 18px; font-weight: 600; letter-spacing: 1px; }
.panel-sub { font-family: var(--font-data); font-size: 12px; color: var(--muted); margin: 2px 0 14px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.cell { background: #0C1926; padding: 8px 10px; }
.cell label { display: block; font-size: 10px; color: var(--muted); letter-spacing: 1px; margin-bottom: 2px; }
.cell b { font-family: var(--font-data); font-size: 15px; font-weight: 600; }

.row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 2px; border-bottom: 1px solid #14243A; }
.row label { font-size: 12px; color: var(--muted); }
.row b { font-family: var(--font-data); font-size: 13px; font-weight: 500; text-align: right; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wx { margin-top: 14px; }
.wx-title { font-size: 12px; color: var(--muted); letter-spacing: 1px; margin-bottom: 8px; }
#wx-loading { font-size: 11px; color: var(--accent); }

/* MapLibre 컨트롤 다크 보정 */
.maplibregl-ctrl-group { background: var(--panel) !important; border: 1px solid var(--line); }
.maplibregl-ctrl button span { filter: invert(.85); }
.maplibregl-ctrl-attrib { background: #0B1622CC !important; color: var(--muted) !important; font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

/* 반응형 */
@media (max-width: 720px) {
  .search { display: none; }
  .rail { width: 160px; left: 8px; }
  .panel { width: calc(100vw - 16px); right: 8px; top: auto; bottom: 8px; max-height: 55vh; overflow-y: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.live { animation: none; }
}
