:root {
  --bg:      #0d1117;
  --surface: #161b22;
  --border:  #30363d;
  --text:    #e6edf3;
  --muted:   #7d8590;
  --accent:  #7eaaff;
  --point:   #ff7070;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

/* ── Top bar ──────────────────────────────────────────────── */

#topbar {
  height: 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.repo-by {
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 699px) {
  .repo-by { display: block; }
}

.topbar-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
}

.topbar-link:hover { color: var(--text); }

/* ── Main layout ──────────────────────────────────────────── */

#layout {
  position: fixed;
  top: 36px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
}

/* ── Canvas area ──────────────────────────────────────────── */

#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#gp-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ── Control panel ────────────────────────────────────────── */

#panel {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctrl-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ctrl-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ctrl-val {
  font-size: 12px;
  color: var(--text);
}

.divider {
  height: 1px;
  background: var(--border);
}

/* ── Slider ───────────────────────────────────────────────── */

.slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  accent-color: var(--accent);
  cursor: pointer;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}

.btn:hover { background: rgba(255,255,255,0.04); }

/* Kernel toggle */
.kernel-toggle {
  display: flex;
  gap: 6px;
}

.kernel-toggle .btn { flex: 1; text-align: center; font-size: 12px; }

.kernel-hint { color: var(--muted); font-weight: 400; font-size: 11px; }
.kernel-btn.active .kernel-hint { color: rgba(126,170,255,0.55); }

.kernel-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(126,170,255,0.08);
}

#btn-clear {
  width: 100%;
  color: var(--muted);
  border-color: var(--border);
}

#btn-clear:hover { color: var(--point); border-color: var(--point); }

/* ── Legend ───────────────────────────────────────────────── */

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.legend-swatch {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--point);
  flex-shrink: 0;
}

/* ── Loading overlay ──────────────────────────────────────── */

#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

#loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(126,170,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-status { color: var(--text); font-size: 14px; }

#loading-sub {
  color: var(--muted);
  font-size: 12px;
  max-width: 260px;
}

/* ── Mobile ───────────────────────────────────────────────── */

@media (max-width: 699px) {
  #layout { flex-direction: column; }

  #panel {
    width: 100%;
    height: 220px;
    flex-shrink: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: auto;
    gap: 14px;
    padding: 12px;
  }

  .ctrl-group { min-width: 130px; flex: 1; }
  .divider    { display: none; }
}
