:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #58a6ff;
  --danger: #f85149;
  --ok: #3fb950;
  --warn: #d29922;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  height: 95vh;
}

.home-link {
  position: fixed;
  top: 12px;
  left: 12px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  z-index: 100;
}

header {
  text-align: center;
  padding: 16px 0 4px;
}

header h1 {
  font-size: 24px;
  margin: 0;
  font-weight: 800;
}

.badge {
  font-size: 11px;
  background: var(--accent);
  color: #0d1117;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
  font-family: 'JetBrains Mono', monospace;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 16px;
}

.layout {
  height: -webkit-fill-available;
  display: flex;
  gap: 16px;
  padding: 0 16px 32px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: stretch;
}

.canvas-wrap {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

canvas {
  background: #010409;
  border-radius: 6px;
  aspect-ratio: 1 / 1;
  max-width: 90vw;
  max-height: 90vh;
  height: -webkit-fill-available;
}

.controls {
  width: 320px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition:
    width 0.25s ease,
    padding 0.25s ease,
    opacity 0.2s ease;
  overflow: hidden;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

/* Collapsed sidebar state */
.controls.collapsed {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  border-width: 0;
  margin: 0;
}

.controls.collapsed > * {
  display: none;
}

/* Sidebar toggle button */
.sidebar-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  width: auto;
  flex: none;
  background: var(--panel);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

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

  .controls {
    width: 100%;
  }

  .controls.collapsed {
    width: 100%;
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  canvas {
    max-width: 100%;
  }
}

.ctrl-group {
  margin-bottom: 14px;
}

.ctrl-group label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.ctrl-group input[type='range'] {
  width: 100%;
}

.ctrl-group select,
.ctrl-group input[type='number'] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.val {
  color: var(--accent);
  float: right;
  font-family: 'JetBrains Mono', monospace;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

button {
  flex: 1;
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

button.secondary {
  background: var(--border);
  color: var(--text);
}

button:hover {
  opacity: 0.9;
}

.metrics {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.metric-row .m-val {
  color: var(--accent);
}

.metric-row .m-val.ok {
  color: var(--ok);
}

.metric-row .m-val.bad {
  color: var(--danger);
}

#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
}

#loading.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.legend {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
