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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0f;
  font-family: system-ui, -apple-system, sans-serif;
  color: #e0e0e0;
}

#app {
  display: flex;
  width: 100%;
  height: 100%;
}

#toolbar {
  width: 200px;
  background: #141420;
  border-right: 1px solid #2a2a3a;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  overflow-y: auto;
}

#toolbar h2 {
  font-size: 14px;
  font-weight: 600;
  color: #8888aa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #1e1e2e;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  color: #c0c0d0;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tool-btn:hover {
  background: #282840;
  border-color: #404060;
}

.tool-btn.active {
  background: #2a2a50;
  border-color: #6060a0;
  color: #ffffff;
}

.tool-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ── Component sub-groups ── */
.component-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.group-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: none;
  border: none;
  color: #777799;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s;
}

.group-toggle:hover {
  color: #aaaacc;
}

.group-toggle .chevron {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.2s ease;
}

.group-toggle.collapsed .chevron {
  transform: rotate(-90deg);
}

.group-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}

.group-items.collapsed {
  max-height: 0;
  opacity: 0;
}

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

#simulation {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#parameter-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 220px;
  background: rgba(20, 20, 32, 0.95);
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: 12px;
  display: none;
  backdrop-filter: blur(8px);
}

#parameter-panel.visible {
  display: block;
}

#parameter-panel h3 {
  font-size: 13px;
  font-weight: 600;
  color: #8888aa;
  margin-bottom: 8px;
}

.param-group {
  margin-bottom: 8px;
}

.param-group label {
  display: block;
  font-size: 11px;
  color: #8888aa;
  margin-bottom: 2px;
}

.param-group input[type="range"] {
  width: 100%;
  accent-color: #6060a0;
}

.param-group .param-value {
  font-size: 11px;
  color: #c0c0d0;
  text-align: right;
}

#performance-hud {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 11px;
  color: #555570;
  font-family: monospace;
  pointer-events: none;
}

/* Pinned detector output panels */
#pinned-container {
  position: absolute;
  bottom: 28px;
  right: 12px;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  pointer-events: none;
}

.pinned-detector {
  pointer-events: auto;
  width: 190px;
  background: rgba(20, 20, 32, 0.92);
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  padding: 6px;
  backdrop-filter: blur(6px);
}

.pinned-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.pinned-title {
  font-size: 10px;
  color: #8888aa;
  font-weight: 600;
}

.pinned-close {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}
.pinned-close:hover {
  color: #ff6644;
}

.pinned-profile, .pinned-trace {
  width: 100%;
  border-radius: 3px;
  background: rgba(0,0,0,0.25);
  display: block;
}
.pinned-profile {
  height: 40px;
  margin-bottom: 3px;
}
.pinned-trace {
  height: 32px;
}
