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

body {
  overflow: hidden;
  background: #000;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: #e0e0e0;
}

canvas {
  display: block;
}

/* Loading overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0a0a1a 0%, #000 100%);
  transition: opacity 0.8s ease-out;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#loading-overlay h1 {
  font-size: 1.8rem;
  font-weight: 300;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #f0c060;
  margin-bottom: 2rem;
  text-shadow: 0 0 30px rgba(240, 192, 96, 0.4);
}

#loading-overlay .subtitle {
  font-size: 0.85rem;
  color: #888;
  letter-spacing: 0.15em;
  margin-bottom: 2.5rem;
}

.progress-container {
  width: 300px;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f0c060, #ff8040);
  border-radius: 2px;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(240, 192, 96, 0.5);
}

#loading-status {
  margin-top: 1.2rem;
  font-size: 0.75rem;
  color: #666;
  letter-spacing: 0.1em;
}

/* Info overlay */
#info-panel {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(240, 192, 96, 0.15);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 0.7rem;
  color: #999;
  line-height: 1.6;
  pointer-events: none;
}

#info-panel .title {
  font-size: 0.8rem;
  color: #f0c060;
  font-weight: 500;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

#fps-counter {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 100;
  font-size: 0.65rem;
  color: #555;
  font-family: "Courier New", monospace;
  pointer-events: none;
}
/* ─── HUD Frame Overlay ─── */
#hud-frame {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

/* Corner brackets */
.hud-corner {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: rgba(240, 192, 96, 0.4);
  border-style: solid;
  border-width: 0;
}

.hud-corner.top-left {
  top: 8px; left: 8px;
  border-top-width: 2px;
  border-left-width: 2px;
}

.hud-corner.top-right {
  top: 8px; right: 8px;
  border-top-width: 2px;
  border-right-width: 2px;
}

.hud-corner.bottom-left {
  bottom: 8px; left: 8px;
  border-bottom-width: 2px;
  border-left-width: 2px;
}

.hud-corner.bottom-right {
  bottom: 8px; right: 8px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

/* Edge scan lines */
.hud-edge {
  position: absolute;
  background: rgba(240, 192, 96, 0.08);
}

.hud-edge.top, .hud-edge.bottom {
  left: 48px; right: 48px;
  height: 1px;
}

.hud-edge.top { top: 8px; }
.hud-edge.bottom { bottom: 8px; }

.hud-edge.left, .hud-edge.right {
  top: 48px; bottom: 48px;
  width: 1px;
}

.hud-edge.left { left: 8px; }
.hud-edge.right { right: 8px; }

/* Top bar */
.hud-top-bar {
  position: absolute;
  top: 8px;
  left: 48px;
  right: 48px;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: rgba(10, 10, 26, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(240, 192, 96, 0.12);
  pointer-events: auto;
}

.hud-title {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: rgba(240, 192, 96, 0.6);
  text-transform: uppercase;
  flex: 1;
}

.hud-status {
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: #4f4;
  padding: 1px 6px;
  border: 1px solid rgba(68, 255, 68, 0.25);
  border-radius: 3px;
  background: rgba(68, 255, 68, 0.06);
  animation: hud-pulse 2s ease-in-out infinite;
}

@keyframes hud-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.hud-close {
  background: rgba(255, 85, 85, 0.1);
  border: 1px solid rgba(255, 85, 85, 0.3);
  color: #ff5555;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
  padding: 0;
}

.hud-close:hover {
  color: #ff5555;
  border-color: rgba(255, 85, 85, 0.4);
  background: rgba(255, 85, 85, 0.1);
}

/* View presets */
#view-presets {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  gap: 6px;
  align-items: center;
}

#view-presets .preset-group {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(240, 192, 96, 0.2);
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.25s ease;
}

#view-presets .preset-group:hover {
  border-color: rgba(240, 192, 96, 0.45);
}

#view-presets .preset-name {
  background: none;
  border: none;
  color: #ccc;
  padding: 7px 10px;
  font-size: 0.7rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.25s ease;
  white-space: nowrap;
  font-family: inherit;
}

#view-presets .preset-name:hover {
  color: #f0c060;
  background: rgba(240, 192, 96, 0.08);
}

#view-presets .preset-action {
  background: none;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  color: #666;
  padding: 7px 5px;
  font-size: 0.55rem;
  cursor: pointer;
  transition: all 0.25s ease;
  line-height: 1;
}

#view-presets .preset-action:hover {
  color: #f0c060;
  background: rgba(240, 192, 96, 0.1);
}

#view-presets .preset-action.remove:hover {
  color: #ff5555;
  background: rgba(255, 85, 85, 0.1);
}

#view-presets .preset-add {
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(240, 192, 96, 0.2);
  color: #888;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}

#view-presets .preset-add:hover {
  border-color: rgba(240, 192, 96, 0.6);
  color: #f0c060;
  background: rgba(240, 192, 96, 0.08);
  box-shadow: 0 0 16px rgba(240, 192, 96, 0.15);
}

/* ─── Compact/Dense GUI Overrides ─── */
.lil-gui {
  --background-color: rgba(15, 15, 20, 0.85);
  --text-color: #d0d0d0;
  --title-background-color: rgba(0, 0, 0, 0.6);
  --widget-color: #333;
  --hover-color: #444;
  --focus-color: #555;
  --number-color: #f0c060;
  --string-color: #f0c060;
  --font-size: 10px;
  --input-font-size: 10px;
  --padding: 4px;
  --spacing: 4px;
  --slider-knob-width: 2px;
  --slider-input-width: 40px;
  --folder-indent: 6px;
}

.lil-gui.root {
  width: 320px !important;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lil-gui .title {
  padding-top: 3px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lil-gui .controller {
  margin-bottom: 1px;
}

.lil-gui .controller .name {
  width: 40%;
}

/* ─── Instance Card Styling ───
   Applied to individual fixture/iceberg/generator/strand folders
   to visually separate them as distinct configurable entities */
.lil-gui.gui-card {
  margin: 3px 0 !important;
  border-radius: 6px !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  background: rgba(20, 20, 30, 0.6) !important;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.lil-gui.gui-card > .title {
  border-radius: 5px 5px 0 0;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.lil-gui.gui-card.closed > .title {
  border-radius: 5px;
}

.lil-gui.gui-card:hover {
  border-color: rgba(255, 255, 255, 0.12) !important;
  background: rgba(25, 25, 38, 0.7) !important;
}

/* Selected / focused card — warm gold accent */
.lil-gui.gui-card.gui-card-selected {
  border-color: rgba(240, 192, 96, 0.7) !important;
  background: rgba(240, 192, 96, 0.08) !important;
  box-shadow: 0 0 16px rgba(240, 192, 96, 0.18), inset 0 0 0 1px rgba(240, 192, 96, 0.12);
}

.lil-gui.gui-card.gui-card-selected > .title {
  color: #f5d070 !important;
  background: rgba(240, 192, 96, 0.15) !important;
}

.lil-gui.gui-card.gui-card-selected:hover {
  border-color: rgba(240, 192, 96, 0.85) !important;
  box-shadow: 0 0 22px rgba(240, 192, 96, 0.22), inset 0 0 0 1px rgba(240, 192, 96, 0.15);
}

/* ─── Recursive indentation for nested folders ─── */
.lil-gui .lil-gui > .children {
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

/* Slightly brighter guide for deeper nesting */
.lil-gui .lil-gui .lil-gui > .children {
  border-left-color: rgba(255, 255, 255, 0.04);
}

/* Even deeper levels */
.lil-gui .lil-gui .lil-gui .lil-gui > .children {
  border-left-color: rgba(255, 255, 255, 0.03);
}

/* ─── Pattern Editor Panel ─── */
#pattern-editor-panel {
  position: fixed;
  top: 60px;
  left: 14px;
  width: 400px;
  height: 520px;
  min-width: 300px;
  min-height: 200px;
  max-width: 800px;
  max-height: 90vh;
  z-index: 95;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(240, 192, 96, 0.2);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  transition: height 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
  font-family: inherit;
  resize: both;
}

#pattern-editor-panel.hidden {
  display: none;
}

#pattern-editor-panel.collapsed {
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  border-radius: 8px;
  resize: none;
  overflow: hidden;
}

/* Header bar */
.pe-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(240, 192, 96, 0.12);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

.pe-header:active {
  cursor: grabbing;
}

.pe-header .pe-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: rgba(240, 192, 96, 0.8);
  text-transform: uppercase;
  flex: 1;
}

.pe-header .pe-btn {
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: #aaa;
  font-size: 0.65rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.pe-header .pe-btn:hover {
  border-color: rgba(240, 192, 96, 0.5);
  color: #f0c060;
  background: rgba(240, 192, 96, 0.1);
}

.pe-header .pe-btn.pe-run {
  border-color: rgba(68, 255, 68, 0.3);
  color: rgba(120, 255, 120, 0.9);
  background: rgba(30, 60, 30, 0.3);
}

.pe-header .pe-btn.pe-run:hover {
  border-color: rgba(68, 255, 68, 0.6);
  color: #7f7;
  background: rgba(40, 80, 40, 0.4);
  box-shadow: 0 0 12px rgba(68, 255, 68, 0.15);
}

.pe-header .pe-btn.pe-save {
  border-color: rgba(240, 192, 96, 0.3);
  color: rgba(240, 192, 96, 0.9);
  background: rgba(60, 48, 20, 0.3);
}
.pe-header .pe-btn.pe-save:hover {
  border-color: rgba(240, 192, 96, 0.6);
  color: #f0c060;
  background: rgba(80, 60, 20, 0.4);
  box-shadow: 0 0 12px rgba(240, 192, 96, 0.15);
}

/* Preset bar */
.pe-presets {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}
.pe-preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
}
.pe-preset-buttons button {
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
  color: #aaa;
  font-size: 0.6rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pe-preset-buttons button:hover {
  border-color: rgba(240, 192, 96, 0.4);
  color: #f0c060;
  background: rgba(240, 192, 96, 0.08);
}
.pe-preset-buttons button.active {
  border-color: rgba(240, 192, 96, 0.5);
  color: #f0c060;
  background: rgba(240, 192, 96, 0.12);
  font-weight: 600;
}
.pe-preset-toolbar {
  display: flex;
  gap: 2px;
  margin-left: 4px;
}
.pe-toolbar-btn {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  color: #999;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.pe-toolbar-btn:hover {
  border-color: rgba(240, 192, 96, 0.5);
  color: #f0c060;
  background: rgba(240, 192, 96, 0.1);
}
.pe-toolbar-btn.pe-danger:hover {
  border-color: rgba(255, 80, 80, 0.5);
  color: #f55;
  background: rgba(255, 80, 80, 0.1);
}

/* Code textarea */
.pe-code-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pe-textarea {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: rgba(0, 0, 0, 0.3);
  color: #d4d4d4;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 12px 14px;
  tab-size: 2;
  overflow: auto;
}

.pe-textarea::selection {
  background: rgba(240, 192, 96, 0.25);
}

.pe-textarea:focus {
  background: rgba(0, 0, 0, 0.4);
}

/* Status / error bar */
.pe-status {
  padding: 6px 12px;
  font-size: 0.65rem;
  font-family: "Consolas", monospace;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pe-status.ok {
  color: rgba(120, 255, 120, 0.8);
}

.pe-status.error {
  color: #ff6666;
  background: rgba(80, 20, 20, 0.3);
  border-top-color: rgba(255, 60, 60, 0.15);
}

.pe-status .pe-status-icon {
  font-size: 0.75rem;
}

/* Preset buttons row */
.pe-presets {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pe-presets button {
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.03);
  color: #888;
  font-size: 0.6rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pe-presets button:hover {
  border-color: rgba(240, 192, 96, 0.4);
  color: #f0c060;
  background: rgba(240, 192, 96, 0.06);
}

/* API reference panel */
.pe-docs {
  padding: 10px 14px;
  font-size: 0.6rem;
  color: #888;
  line-height: 1.5;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
  max-height: 140px;
  overflow-y: auto;
  flex-shrink: 0;
}

.pe-docs code {
  color: #8cc0ff;
  font-family: "Consolas", monospace;
  font-size: 0.6rem;
}

.pe-docs .pe-docs-title {
  color: rgba(240, 192, 96, 0.7);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ─── sACN Monitor Panel ─── */
#sacn-monitor-panel {
  position: fixed;
  top: 60px;
  left: 14px;
  width: 280px;
  height: 380px;
  min-width: 220px;
  min-height: 200px;
  max-width: 400px;
  max-height: 80vh;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(96, 192, 240, 0.2);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  transition: height 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
  font-family: inherit;
  resize: both;
}

#sacn-monitor-panel.hidden {
  display: none;
}

#sacn-monitor-panel.collapsed {
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  border-radius: 8px;
  resize: none;
  overflow: hidden;
}

.sacn-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(96, 192, 240, 0.12);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

.sacn-header:active {
  cursor: grabbing;
}

.sacn-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: rgba(96, 192, 240, 0.8);
  text-transform: uppercase;
  flex: 1;
}

.sacn-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  transition: background 0.3s ease;
}

.sacn-status-dot.connected {
  background: #4cdf6e;
  box-shadow: 0 0 6px rgba(76, 223, 110, 0.5);
}

.sacn-status-dot.receiving {
  background: #60c0f0;
  box-shadow: 0 0 6px rgba(96, 192, 240, 0.5);
  animation: sacn-pulse 1s ease infinite;
}

@keyframes sacn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.sacn-body {
  padding: 8px 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.sacn-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.sacn-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
}

.sacn-label {
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.55rem;
}

.sacn-value {
  color: rgba(255, 255, 255, 0.85);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.65rem;
}

.sacn-log-title {
  font-size: 0.55rem;
  color: rgba(96, 192, 240, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}

.sacn-log {
  flex: 1;
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.5;
}

.sacn-log .sacn-entry {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sacn-log .sacn-entry.source {
  color: rgba(96, 192, 240, 0.8);
}

.sacn-log .sacn-entry.warn {
  color: rgba(240, 192, 96, 0.8);
}

.sacn-log .sacn-entry.error {
  color: rgba(240, 96, 96, 0.8);
}
