:root {
  --bg: #040910;
  --bg-2: #07111d;
  --panel: rgba(8, 19, 31, 0.78);
  --line: rgba(86, 167, 219, 0.16);
  --line-strong: rgba(86, 167, 219, 0.32);
  --text: #dcecf8;
  --muted: #6e8ca3;
  --cyan: #58e6ff;
  --green: #6dffb0;
  --orange: #ffae63;
  --red: #ff6b81;
  --radius: 16px;
  --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 800px at 18% 35%, rgba(24, 104, 170, 0.16), transparent 62%),
    radial-gradient(900px 700px at 85% 80%, rgba(18, 58, 95, 0.18), transparent 65%),
    linear-gradient(160deg, #03070c 0%, #06111c 55%, #03080e 100%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(5, 13, 22, 0.92), rgba(5, 13, 22, 0.55));
  backdrop-filter: blur(14px);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 260px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(88, 230, 255, 0.35);
  background:
    radial-gradient(circle at 50% 50%, rgba(88, 230, 255, 0.25), rgba(4, 12, 20, 0.4) 65%),
    linear-gradient(145deg, rgba(35, 118, 170, 0.4), rgba(4, 12, 20, 0.8));
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(40, 170, 220, 0.18), inset 0 0 18px rgba(88, 230, 255, 0.12);
}

.brand-mark span {
  position: absolute;
  border: 1px solid rgba(88, 230, 255, 0.72);
  border-radius: 50%;
}
.brand-mark span:nth-child(1) { width: 26px; height: 26px; opacity: 0.45; }
.brand-mark span:nth-child(2) { width: 16px; height: 16px; opacity: 0.8; }
.brand-mark span:nth-child(3) { width: 4px; height: 4px; background: var(--cyan); border: 0; box-shadow: 0 0 10px var(--cyan); }

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.metric {
  min-width: 82px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(11, 26, 41, 0.55);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.metric-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric strong {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  color: #e8f7ff;
  font-variant-numeric: tabular-nums;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 24, 38, 0.7);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px var(--orange);
}

.status[data-state="online"] .status-dot { background: var(--green); box-shadow: 0 0 12px var(--green); }
.status[data-state="online"] .status-text { color: #b6ffd9; }
.status[data-state="offline"] .status-dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
.status[data-state="offline"] .status-text { color: #ffc3cb; }

/* ---------- layout ---------- */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 14px;
  padding: 14px;
}

.globe-panel {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(18, 63, 99, 0.15), transparent 60%),
    rgba(3, 9, 15, 0.55);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.45);
}

#globe {
  position: absolute;
  inset: 0;
}

#globe canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#globe canvas:active { cursor: grabbing; }

.globe-overlay {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.globe-overlay.top-left { top: 16px; left: 16px; }
.globe-overlay.bottom-left { bottom: 16px; left: 16px; }

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 5px 11px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: #c8f6ff;
  border: 1px solid rgba(88, 230, 255, 0.28);
  background: rgba(9, 40, 56, 0.6);
}

.pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(88, 230, 255, 0.65);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(88, 230, 255, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(88, 230, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(88, 230, 255, 0); }
}

.store-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  padding-left: 3px;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 7px;
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.new { background: #ffffff; box-shadow: 0 0 10px #9ef4ff, 0 0 4px #fff; }
.dot.cached { background: var(--cyan); box-shadow: 0 0 8px rgba(88, 230, 255, 0.8); }

.hint {
  font-size: 11px;
  color: rgba(110, 140, 163, 0.8);
  letter-spacing: 0.02em;
}

.corner-glow {
  position: absolute;
  right: -120px;
  bottom: -160px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(26, 112, 168, 0.14), transparent 65%);
  pointer-events: none;
  z-index: 1;
}

.tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  max-width: 260px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid rgba(88, 230, 255, 0.3);
  background: rgba(4, 14, 23, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 18px rgba(47, 170, 220, 0.12);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text);
  backdrop-filter: blur(8px);
}

.tooltip .tt-ip { font-family: var(--mono); color: var(--cyan); font-size: 12px; }
.tooltip .tt-place { color: #a9c5d9; }
.tooltip .tt-src { color: var(--muted); font-size: 10.5px; }
.tooltip .tt-hash { font-family: var(--mono); color: var(--muted); font-size: 10px; word-break: break-all; }

/* ---------- side panel ---------- */

.side-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.panel-head {
  padding: 14px 15px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.counter {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--cyan);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(88, 230, 255, 0.24);
  background: rgba(21, 77, 104, 0.28);
}

.filter {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(4, 13, 22, 0.7);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 11px;
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter::placeholder { color: rgba(110, 140, 163, 0.65); }

.filter:focus {
  border-color: rgba(88, 230, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(88, 230, 255, 0.08);
}

.list-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  padding: 8px 15px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(110, 140, 163, 0.75);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(88, 230, 255, 0.18) transparent;
}

.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: rgba(88, 230, 255, 0.16); border-radius: 999px; }
.list::-webkit-scrollbar-track { background: transparent; }

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  padding: 10px 9px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}

@keyframes item-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.item:hover {
  background: rgba(27, 64, 92, 0.25);
  border-color: rgba(88, 230, 255, 0.16);
}

.item + .item { border-top: 1px solid rgba(86, 167, 219, 0.07); border-top-left-radius: 0; border-top-right-radius: 0; }

.item-main { min-width: 0; }

.item-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.type {
  flex: 0 0 auto;
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 5px;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
  opacity: 0.92;
}

.type-video { color: #7fd4ff; background: rgba(56, 148, 200, 0.12); }
.type-audio { color: #9dffcf; background: rgba(56, 190, 130, 0.1); }
.type-image { color: #ffc46e; background: rgba(200, 148, 54, 0.1); }
.type-doc { color: #c4a7ff; background: rgba(136, 98, 210, 0.1); }
.type-program { color: #ff9b8f; background: rgba(200, 88, 76, 0.1); }
.type-archive { color: #7de0d2; background: rgba(58, 176, 160, 0.1); }
.type-other { color: #93a8b8; background: rgba(110, 140, 163, 0.1); }

.name {
  font-size: 12.5px;
  font-weight: 500;
  color: #e4f2fb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.item-meta .sep { opacity: 0.35; }
.item-meta .hash { font-family: var(--mono); font-size: 10px; color: rgba(110, 140, 163, 0.8); }

.item-source {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 3px;
  text-align: right;
}

.ip {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #9fd6ee;
  white-space: nowrap;
}

.place {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 132px;
}

.place.pending { color: rgba(110, 140, 163, 0.55); }

.empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

.panel-foot {
  flex: 0 0 auto;
  padding: 9px 15px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: rgba(110, 140, 163, 0.8);
}

#geo-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .metrics .metric:nth-child(n+5) { display: none; }
}

@media (max-width: 820px) {
  html, body { overflow: auto; }
  #app { height: auto; min-height: 100dvh; }
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .brand { min-width: 0; flex: 1; }
  .brand p { display: none; }
  .metrics { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .metric { min-width: 70px; }
  .layout {
    display: flex;
    flex-direction: column;
    padding: 10px;
  }
  .globe-panel { height: 58vh; min-height: 380px; flex: 0 0 auto; }
  .side-panel { height: 52vh; min-height: 340px; }
  .list-head, .item { grid-template-columns: minmax(0, 1fr) 112px; }
  .place { max-width: 112px; }
}
