:root {
  --bg-deep: #05060b;
  --panel-bg: rgba(10, 13, 24, 0.74);
  --panel-border: rgba(120, 160, 255, 0.16);
  --panel-highlight: rgba(255, 255, 255, 0.06);
  --text-main: #eef2ff;
  --text-muted: #8b9bb8;
  --accent-cyan: #00f2fe;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

#simCanvas {
  position: fixed;
   inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
  z-index: 1;
}

.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(2, 4, 10, 0.65) 100%),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.012) 0px,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 3px
    );
}

/* Glassmorphism UI Base */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 var(--panel-highlight);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

body.zen-mode .side-dock,
body.zen-mode .bottom-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

body.zen-mode .top-bar {
  opacity: 0.18;
}

body.zen-mode .top-bar:hover {
  opacity: 1;
}

/* Top Telemetry Header */
.top-bar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  height: 60px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.argon-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.18), rgba(168, 85, 247, 0.25));
  border: 1px solid rgba(0, 242, 254, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(0, 242, 254, 0.22);
  position: relative;
}

.atomic-num {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--accent-cyan);
  line-height: 1;
  opacity: 0.9;
}

.atomic-sym {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

.brand-titles .title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-titles h1 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #ffffff, #a5f3fc, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #d8b4fe;
}

.subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Telemetry Strip */
.telemetry-strip {
  display: flex;
  align-items: center;
  gap: 22px;
  background: rgba(3, 5, 12, 0.55);
  padding: 6px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.metric-value.cyan { color: var(--accent-cyan); }
.metric-value.purple { color: #c084fc; }
.metric-value.emerald { color: var(--accent-emerald); }

#energySparkline {
  display: block;
  margin-top: 2px;
}

/* Top Buttons */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.btn-glow.active {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 18px rgba(0, 242, 254, 0.28);
}

.dot-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  transition: all 0.2s ease;
}

.btn-glow.active .dot-indicator {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.btn-record {
  border-color: rgba(244, 63, 94, 0.35);
}

.btn-record.recording {
  background: rgba(244, 63, 94, 0.22);
  border-color: var(--accent-rose);
  color: #fecdd3;
  animation: pulseRec 1.2s infinite;
}

.rec-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-rose);
}

@keyframes pulseRec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); }
}

.btn-icon {
  padding: 8px 9px;
}

/* Left Control Dock */
.side-dock {
  position: fixed;
  top: 86px;
  left: 14px;
  width: 280px;
  max-height: calc(100vh - 156px);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dock-header {
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
}

.dock-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #cbd5e1;
}

.collapse-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.collapse-btn:hover {
  color: #fff;
}

.dock-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dock-body::-webkit-scrollbar {
  width: 4px;
}

.dock-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.07em;
}

.section-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #64748b;
}

/* Preset Grid */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-chip {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.preset-chip.active {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.16), rgba(168, 85, 247, 0.18));
  border-color: rgba(0, 242, 254, 0.55);
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.15);
}

/* Matrix Section */
.mini-actions {
  display: flex;
  gap: 4px;
}

.mini-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mini-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.mini-btn.accent {
  border-color: rgba(168, 85, 247, 0.5);
  color: #e9d5ff;
  background: rgba(168, 85, 247, 0.15);
}

.matrix-help {
  font-size: 10px;
  color: var(--text-muted);
}

.txt-attract { color: #34d399; font-weight: 600; }
.txt-repel { color: #fb7185; font-weight: 600; }

.matrix-wrapper {
  display: flex;
  justify-content: center;
  background: rgba(3, 5, 12, 0.65);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#matrixCanvas {
  cursor: pointer;
  border-radius: 6px;
}

/* Sliders */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.slider-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #cbd5e1;
}

.slider-meta span:last-child {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.7);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Toggle Pills */
.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.toggle-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-pill.active {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.14);
  color: #a7f3d0;
}

/* Footer DNA & Snapshot */
.footer-section {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 10px;
}

.dna-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(3, 5, 12, 0.6);
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.dna-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

#dnaInput {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 10px;
  outline: none;
  cursor: pointer;
}

.action-buttons-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 6px;
}

.btn-secondary {
  justify-content: center;
  font-size: 10px;
  padding: 8px 6px;
}

.btn-primary {
  justify-content: center;
  font-size: 10px;
  padding: 8px 6px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.22), rgba(168, 85, 247, 0.28));
  border-color: rgba(0, 242, 254, 0.5);
  color: #fff;
}

.btn-primary:hover {
  box-shadow: 0 0 18px rgba(0, 242, 254, 0.3);
}

/* Bottom Bar */
.bottom-bar {
  position: fixed;
  bottom: 14px;
  left: 308px;
  right: 14px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-right: 6px;
  letter-spacing: 0.06em;
}

.tool-btn {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.tool-btn.active {
  background: rgba(0, 242, 254, 0.16);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 14px rgba(0, 242, 254, 0.2);
}

.key-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
}

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

kbd {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(10, 14, 28, 0.92);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 99px;
  box-shadow: 0 10px 30px rgba(0, 242, 254, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments */
@media (max-width: 1100px) {
  .telemetry-strip { display: none; }
  .bottom-bar { left: 14px; }
  .shortcut-legend { display: none; }
}
