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

:root {
  --bg-deep: #0a0c14;
  --bg-panel: #0d1017;
  --bg-control: #111520;
  --bg-section: #0f1319;
  --border: #1a2030;
  --border-glow: #1e2a40;
  --cyan: #00e5ff;
  --cyan-dim: #007a8a;
  --blue: #2196f3;
  --orange: #ff9800;
  --orange-dim: #a06000;
  --green: #39ff14;
  --green-dim: #1a8a0a;
  --amber: #ffb300;
  --white: #e0e6f0;
  --text-dim: #5a6a80;
  --red: #ff3d3d;
}

body {
  background: var(--bg-deep);
  color: var(--white);
  font-family: 'Share Tech Mono', monospace;
  overflow-x: hidden;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  background: linear-gradient(180deg, #0e1220 0%, var(--bg-deep) 100%);
  border-bottom: 1px solid var(--border-glow);
  padding: 10px 16px;
  position: relative;
  z-index: 10;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1800px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 8px;
}

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

header h1 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--green);
  text-shadow: 0 0 20px rgba(57, 255, 20, 0.5), 0 0 40px rgba(57, 255, 20, 0.2);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-top: 2px;
}

/* Antenna Icon */
.antenna-icon {
  position: relative;
  width: 30px;
  height: 36px;
}

.tower {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 24px;
  background: var(--green);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--green);
}

.tower::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--green);
}

.wave {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  border: 1.5px solid var(--green);
  border-radius: 50%;
  opacity: 0;
}

.antenna-icon.broadcasting .w1 {
  width: 16px; height: 16px;
  animation: pulse-wave 2s ease-out infinite;
}
.antenna-icon.broadcasting .w2 {
  width: 24px; height: 24px;
  animation: pulse-wave 2s ease-out 0.5s infinite;
}
.antenna-icon.broadcasting .w3 {
  width: 32px; height: 32px;
  animation: pulse-wave 2s ease-out 1s infinite;
}

@keyframes pulse-wave {
  0% { opacity: 0.8; transform: translateX(-50%) scale(0.5); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.2); }
}

.header-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-btn, .ctrl-btn {
  background: var(--bg-control);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.preset-btn:hover, .ctrl-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.preset-btn.active {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 8px rgba(57, 255, 20, 0.2);
}

/* Main Layout */
#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Controls Panel */
#controls-panel {
  width: 280px;
  min-width: 280px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
}

.control-section {
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
}

.section-badge {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 3px;
  margin-bottom: 10px;
  display: inline-block;
}

.am-badge {
  background: rgba(0, 229, 255, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.3);
}

.fm-badge {
  background: rgba(255, 152, 0, 0.1);
  color: var(--orange);
  border: 1px solid rgba(255, 152, 0, 0.3);
}

.combined-badge {
  background: rgba(57, 255, 20, 0.1);
  color: var(--green);
  border: 1px solid rgba(57, 255, 20, 0.3);
}

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

.control-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.control-group .val {
  color: var(--white);
  font-weight: bold;
}

/* Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  outline: none;
  cursor: pointer;
}

.am-section input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  cursor: pointer;
}

.fm-section input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 8px var(--orange);
  cursor: pointer;
}

.combined-section input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.am-section input[type="range"]::-moz-range-thumb { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.fm-section input[type="range"]::-moz-range-thumb { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.combined-section input[type="range"]::-moz-range-thumb { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* Dropdown */
select {
  width: 100%;
  background: var(--bg-deep);
  color: var(--white);
  border: 1px solid var(--border);
  padding: 4px 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
}

select:focus { border-color: var(--cyan); }

/* Toggle */
.toggle-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-group label { margin-bottom: 0; }

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle-track {
  width: 44px;
  height: 22px;
  background: var(--bg-deep);
  border: 2px solid var(--border);
  border-radius: 11px;
  position: relative;
  transition: all 0.3s;
}

.toggle-thumb {
  width: 16px;
  height: 16px;
  background: var(--text-dim);
  border-radius: 50%;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: all 0.3s;
}

.toggle-switch.active .toggle-track {
  border-color: var(--green);
  background: rgba(57, 255, 20, 0.15);
}

.toggle-switch.active .toggle-thumb {
  left: 23px;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

.toggle-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  width: 24px;
}

.toggle-switch.active .toggle-label {
  color: var(--green);
}

/* Display Area */
#display-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

#scope-canvas {
  flex: 3;
  width: 100%;
  min-height: 0;
}

#spectrum-canvas {
  flex: 1;
  width: 100%;
  min-height: 0;
  border-top: 1px solid var(--border);
}

#info-panel {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 0.72rem;
  color: var(--text-dim);
  min-height: 32px;
  display: flex;
  align-items: center;
}

#info-text {
  line-height: 1.4;
}

/* Education Panel */
#education-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 10px;
  transition: all 0.3s;
}

#education-panel.hidden { display: none; }

.edu-card {
  background: rgba(13, 16, 23, 0.95);
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.1);
}

.edu-card h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  color: var(--green);
  margin-bottom: 8px;
}

.edu-card p {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  line-height: 1.5;
}

.edu-card em { color: var(--amber); font-style: italic; }
.edu-card strong { color: var(--white); }

/* Static Overlay */
#static-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 40px;
  background: #111;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

#static-overlay.hidden { display: none; }

#static-overlay canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.static-text {
  position: relative;
  z-index: 21;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.5rem;
  color: var(--white);
  text-align: center;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
  animation: flicker 0.1s infinite alternate;
}

.static-text .small {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
}

@keyframes flicker {
  0% { opacity: 0.9; }
  100% { opacity: 1; }
}

/* Tooltip */
#hover-tooltip {
  position: absolute;
  background: rgba(10, 12, 20, 0.95);
  border: 1px solid var(--green);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.65rem;
  color: var(--green);
  pointer-events: none;
  z-index: 15;
  white-space: nowrap;
}

#hover-tooltip.hidden { display: none; }

/* Footer */
footer {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  color: var(--text-dim);
}

footer a {
  color: var(--green);
  text-decoration: none;
}

footer a:hover {
  text-shadow: 0 0 8px var(--green);
}

/* Scrollbar */
#controls-panel::-webkit-scrollbar { width: 6px; }
#controls-panel::-webkit-scrollbar-track { background: var(--bg-deep); }
#controls-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
  #main-layout {
    flex-direction: column;
  }
  
  #controls-panel {
    width: 100%;
    min-width: 100%;
    max-height: 260px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
  }
  
  .control-section {
    min-width: 240px;
    flex-shrink: 0;
  }
  
  header h1 { font-size: 1rem; }
  .header-buttons { gap: 4px; }
  .preset-btn, .ctrl-btn { padding: 4px 6px; font-size: 0.65rem; }
}