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

/* Theme variables */
:root {
  --bg-panel: rgba(0, 0, 0, 0.75);
  --bg-panel-solid: #1a1a2e;
  --text-primary: white;
  --text-secondary: #bbb;
  --text-muted: #666;
  --text-legend: #ccc;
  --accent: #6c5ce7;
  --accent-hover: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.5);
  --border-light: rgba(255, 255, 255, 0.2);
  --border-hover: rgba(255, 255, 255, 0.5);
  --bg-button: rgba(255, 255, 255, 0.1);
  --bg-button-hover: rgba(255, 255, 255, 0.2);
  --bg-thumb: rgba(0, 0, 0, 0.3);
  --bg-tooltip: rgba(0, 0, 0, 0.9);
  --scrollbar-track: rgba(255, 255, 255, 0.1);
  --scrollbar-thumb: rgba(255, 255, 255, 0.3);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.5);
  --scene-bg: #1a1a2e;
  --edge-color: #ffffff;
}

body.light-mode {
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-panel-solid: #f5f5f5;
  --text-primary: #222;
  --text-secondary: #555;
  --text-muted: #999;
  --text-legend: #444;
  --accent: #6c5ce7;
  --accent-hover: #5a4acf;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --border-light: rgba(0, 0, 0, 0.15);
  --border-hover: rgba(0, 0, 0, 0.4);
  --bg-button: rgba(0, 0, 0, 0.05);
  --bg-button-hover: rgba(0, 0, 0, 0.1);
  --bg-thumb: rgba(255, 255, 255, 0.8);
  --bg-tooltip: rgba(50, 50, 50, 0.95);
  --scrollbar-track: rgba(0, 0, 0, 0.1);
  --scrollbar-thumb: rgba(0, 0, 0, 0.2);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.4);
  --scene-bg: #e8e8f0;
  --edge-color: #333333;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

#container {
  width: 100vw;
  height: 100vh;
}

/* Left control panel */
#controls {
  position: fixed;
  top: 20px;
  left: 20px;
  max-height: calc(100vh - 100px);
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-panel);
  padding: 16px;
  border-radius: 10px;
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  width: 250px;
}

.control-group {
  margin-bottom: 16px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

#shape-buttons {
  flex-direction: column;
}

/* Collapsible category sections */
.category-section {
  margin-bottom: 12px;
  width: 100%;
}

.category-section:last-child {
  margin-bottom: 0;
}

.category-label {
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-label:hover {
  color: var(--accent-hover);
}

.collapse-icon {
  font-size: 14px;
  width: 14px;
  text-align: center;
  font-weight: normal;
}

.category-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 10px;
}

.category-content {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 6px;
  user-select: none;
}

.category-section.collapsed .category-content {
  display: none;
}

/* Scrollable Johnson section */
.category-section.scrollable .category-content {
  max-height: 200px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

.category-section.scrollable .category-content::-webkit-scrollbar {
  width: 5px;
}

.category-section.scrollable .category-content::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 3px;
}

.category-section.scrollable .category-content::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

.category-section.scrollable .category-content::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

button {
  background: var(--bg-button);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s ease;
}

button:hover {
  background: var(--bg-button-hover);
}

button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Shape thumbnails */
.shape-thumb {
  width: 44px;
  height: 44px;
  border-radius: 5px;
  border: 2px solid var(--border-light);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-thumb);
  position: relative;
}

.shape-thumb:hover {
  border-color: var(--border-hover);
  transform: scale(1.05);
}

.shape-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.shape-thumb img {
  width: 100%;
  height: 100%;
  display: block;
}

.shape-thumb .tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tooltip);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  margin-bottom: 4px;
  z-index: 100;
}

.shape-thumb:hover .tooltip {
  opacity: 1;
}

/* Color Legend - compact inline */
#color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

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

.color-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Bottom info bar */
#info-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  padding: 12px 24px;
  border-radius: 8px;
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  text-align: center;
}

#shape-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

#shape-info .shape-name {
  font-size: 16px;
  font-weight: 600;
}

#shape-info .shape-stats {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
}

#shape-info .shape-stats span {
  display: inline-block;
}

/* Scrollbar styling */
#controls::-webkit-scrollbar {
  width: 5px;
}

#controls::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 3px;
}

#controls::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

#controls::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Theme toggle button */
#theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

#theme-toggle:hover {
  background: var(--bg-button-hover);
}
