:root {
  --bg: #0d1117;
  --bg-1: #161b22;
  --bg-2: #1c2128;
  --border: #30363d;
  --fg: #e6edf3;
  --fg-1: #c9d1d9;
  --fg-2: #8b949e;
  --accent: #7c3aed;
  --accent-2: #58a6ff;
  --danger: #f85149;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.4);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; gap: 10px; align-items: center; }
.logo {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent), #f59e0b, #06b6d4, #10b981, #3b82f6,
    #ef4444, #ec4899, #f97316, var(--accent)
  );
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.5);
}
.title {
  font-weight: 600;
  letter-spacing: 0.2px;
}
.meta {
  font-size: 12px;
  color: var(--fg-2);
}

/* ---------------- layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  padding: 22px;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
}

.canvas-wrap {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 620px;
  position: relative;
  overflow: hidden;
}
/* faint radar grid background — CRT vibe */
.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(124, 58, 237, 0.08) 0%, transparent 65%),
    repeating-linear-gradient(0deg,   rgba(255,255,255,0.012) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(90deg,  rgba(255,255,255,0.012) 0 1px, transparent 1px 80px);
}

.canvas-inner {
  position: relative;
  flex: 1;
  min-height: 520px;
}
#radar { width: 100% !important; height: 100% !important; display: block; }

/* rotating radar-sweep beam over the canvas */
.radar-sweep {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    conic-gradient(
      from 0deg,
      transparent 0deg,
      rgba(124, 58, 237, 0.0) 30deg,
      rgba(124, 58, 237, 0.22) 60deg,
      rgba(124, 58, 237, 0.04) 90deg,
      transparent 120deg,
      transparent 360deg
    );
  -webkit-mask: radial-gradient(circle at 50% 50%, black 0%, transparent 78%);
          mask: radial-gradient(circle at 50% 50%, black 0%, transparent 78%);
  animation: sweep 6s linear infinite;
  mix-blend-mode: screen;
}
@keyframes sweep {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* core glow at centre */
.radar-core {
  position: absolute;
  width: 80px; height: 80px;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,0.45) 0%, transparent 70%);
  animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);   opacity: 0.7; }
  50%      { transform: translate(-50%, -50%) scale(1.4); opacity: 1;   }
}

/* canvas glow ring on hover */
.canvas-inner.is-hot::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: var(--radius);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.45), 0 0 24px rgba(124, 58, 237, 0.25);
}

.hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--fg-2);
  text-align: center;
}

/* ---------------- sidebar ---------------- */
.sidebar { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
}
.card h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row:first-child { margin-top: 0; }

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-1);
  cursor: pointer;
  user-select: none;
}
.switch input { accent-color: var(--accent); }

.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--fg-1);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}
.btn:hover { background: #2d333b; }
.btn.ghost { background: transparent; }

.select, .input {
  width: 100%;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent-2); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  color: var(--fg-1);
  user-select: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.active { background: #21262d; border-color: var(--accent-2); color: var(--fg); }
.chip.muted { opacity: 0.4; }

/* legend */
.legend {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: -6px;
  padding-right: 4px;
}
.legend::-webkit-scrollbar { width: 6px; }
.legend::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.legend-item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--fg-1);
  cursor: pointer;
}
.legend-item:hover { background: var(--bg-2); }
.legend-item.solo { background: rgba(124, 58, 237, 0.18); }
.legend-item.hidden { opacity: 0.35; }
.legend-item .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.legend-item .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.legend-item .meta {
  font-size: 11px;
  color: var(--fg-2);
}

.badge {
  background: var(--bg-2);
  color: var(--fg-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}

/* axis highlight banner */

/* footer */
.footer {
  text-align: center;
  padding: 16px 22px 28px;
  font-size: 12px;
  color: var(--fg-2);
}
.footer a { color: var(--fg-2); }
.footer a:hover { color: var(--accent-2); }