:root {
  --accent: #00ff41;
  --accent-dim: #00aa2a;
  --accent-glow: rgba(0,255,65,0.3);
  --bg: #0a0a0a;
  --panel: #111111;
  --panel-border: #222;
  --text: #c0c0c0;
  --text-dim: #666;
}

body.amber {
  --accent: #ffb000;
  --accent-dim: #aa7500;
  --accent-glow: rgba(255,176,0,0.3);
}

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

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

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 3px; }

/* HEADER */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid #222;
  background: #0d0d0d;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

#app-title {
  font-family: 'VT323', monospace;
  font-size: 26px;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
  letter-spacing: 3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.subtitle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: #666;
}

/* MAIN LAYOUT */
#main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 260px;
  min-width: 220px;
  padding: 12px;
  background: #0d0d0d;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#left-sidebar { border-right: 1px solid #222; }
#right-sidebar { border-left: 1px solid #222; }

#center-panel {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* CONTROL PANEL */
.control-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 12px;
}

.panel-title {
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

/* BUTTONS */
.toggle-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  color: var(--text-dim);
  padding: 4px 10px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 2px;
  white-space: nowrap;
}

.toggle-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.toggle-btn:hover {
  border-color: var(--accent-dim);
}

.preset-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  color: var(--accent);
  padding: 6px 12px;
  font-family: 'VT323', monospace;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 2px;
  white-space: nowrap;
}

.preset-btn:hover {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 8px var(--accent-glow);
}

.button-row {
  display: flex;
  gap: 8px;
}

.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* DROP ZONE */
.drop-zone {
  border: 2px dashed var(--accent-dim);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: rgba(0,255,65,0.02);
}

body.amber .drop-zone { background: rgba(255,176,0,0.02); }

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(0,255,65,0.05);
  box-shadow: 0 0 20px var(--accent-glow);
}

body.amber .drop-zone:hover, body.amber .drop-zone.dragover {
  background: rgba(255,176,0,0.05);
}

.drop-icon {
  color: var(--accent);
  font-size: 24px;
  font-family: 'VT323', monospace;
}

.drop-text {
  color: #666;
  font-size: 12px;
  margin-top: 4px;
}

.drop-hint {
  color: #444;
  font-size: 10px;
}

/* SLIDERS */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #222;
  border-radius: 3px;
  outline: none;
  border: 1px solid #333;
  width: 100%;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-glow);
  border: 2px solid var(--accent-dim);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-glow);
  border: 2px solid var(--accent-dim);
}

.full-width { width: 100%; }

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

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

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.static-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.flex-slider { flex: 1; }

.knob-label {
  font-family: 'VT323', monospace;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.knob-value {
  font-family: 'VT323', monospace;
  font-size: 13px;
  color: var(--accent);
}

/* RADIO */
.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #888;
  cursor: pointer;
  padding: 2px 0;
}

.radio-label.active-radio {
  color: var(--accent);
}

.radio-label input[type="radio"] {
  accent-color: var(--accent);
}

.info-text {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 10px;
  color: #555;
  margin-top: 8px;
}

/* TABS */
#tab-bar {
  display: flex;
}

.tab-btn {
  background: #111;
  border: 1px solid #333;
  border-bottom: none;
  color: var(--text-dim);
  padding: 6px 16px;
  font-family: 'VT323', monospace;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: -1px;
}

.tab-btn.active {
  background: var(--panel);
  color: var(--accent);
  border-color: var(--accent-dim);
  border-bottom: 1px solid var(--panel);
  position: relative;
  z-index: 1;
}

/* DISPLAY AREA */
#display-area {
  flex: 1;
  border: 1px solid #333;
  border-top: none;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  min-height: 400px;
}

.view-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* CRT */
.crt-bezel {
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0d0d0d 100%);
  border-radius: 20px;
  padding: 16px;
  box-shadow:
    inset 0 0 30px rgba(0,0,0,0.8),
    0 0 15px rgba(0,0,0,0.5),
    0 4px 20px rgba(0,0,0,0.6);
  position: relative;
  max-width: 720px;
  width: 100%;
}

.crt-bezel::before {
  content: '';
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  border-radius: 18px;
  border: 1px solid #333;
  pointer-events: none;
}

.crt-screen {
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 40px var(--accent-glow), inset 0 0 20px rgba(0,0,0,0.5);
  transform: perspective(800px) rotateX(0.5deg);
  filter: contrast(1.1) brightness(1.05);
}

.crt-screen canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  image-rendering: auto;
}

.crt-screen::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.25) 1px,
    rgba(0,0,0,0.25) 2px
  );
  pointer-events: none;
}

/* CRT warm-up */
@keyframes crt-warmup {
  0% { transform: perspective(800px) rotateX(0.5deg) scaleY(0.005) scaleX(0.8); filter: brightness(3) blur(2px); }
  30% { transform: perspective(800px) rotateX(0.5deg) scaleY(0.005) scaleX(1); filter: brightness(2) blur(1px); }
  50% { transform: perspective(800px) rotateX(0.5deg) scaleY(0.6) scaleX(1); filter: brightness(1.5) blur(0.5px); }
  100% { transform: perspective(800px) rotateX(0.5deg) scaleY(1) scaleX(1); filter: contrast(1.1) brightness(1.05) blur(0); }
}

.crt-warmup {
  animation: crt-warmup 1.5s ease-out forwards;
}

/* LED Display */
.led-display {
  font-family: 'VT323', monospace;
  color: var(--accent);
  background: #0a0a0a;
  border: 1px solid #222;
  padding: 6px 12px;
  border-radius: 2px;
  text-shadow: 0 0 6px var(--accent-glow);
  font-size: 14px;
  margin-top: 12px;
  letter-spacing: 2px;
}

/* Scope */
.scope-screen {
  background: #050505;
  border: 1px solid #333;
  border-radius: 4px;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
  width: 100%;
}

.scope-screen canvas {
  display: block;
  width: 100%;
  height: 320px;
}

.legend-row {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 12px;
  color: #666;
  flex-wrap: wrap;
}

.accent-text { color: var(--accent); }

/* NTSC joke */
.ntsc-joke {
  font-size: 11px;
  color: #ff4444;
  font-style: italic;
  opacity: 0;
  transition: opacity 0.3s;
  height: 0;
  overflow: hidden;
}

.ntsc-joke.visible {
  opacity: 1;
  height: auto;
  margin-top: 2px;
}

/* Info tip */
.info-tip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #222;
  border: 1px solid #444;
  color: var(--accent);
  font-size: 10px;
  text-align: center;
  line-height: 13px;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
}

.info-tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  border: 1px solid var(--accent-dim);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text);
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  max-width: 280px;
  white-space: normal;
  width: max-content;
}

/* Educational info */
#info-drawer {
  margin-top: 10px;
}

#info-drawer summary {
  list-style: none;
}

#info-drawer summary::-webkit-details-marker { display: none; }

#info-drawer[open] summary {
  margin-bottom: 10px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.info-card {
  background: #0d0d0d;
  border: 1px solid #222;
  border-radius: 4px;
  padding: 12px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  color: #aaa;
  line-height: 1.6;
}

.info-card ul {
  margin-left: 16px;
  margin-top: 4px;
  list-style: disc;
}

.info-card-title {
  color: var(--accent);
  font-family: 'VT323', monospace;
  font-size: 16px;
  margin-bottom: 8px;
}

/* Video info */
#video-info {
  margin-top: 8px;
  font-size: 12px;
  color: #888;
}

#video-info .video-name {
  color: var(--accent);
}

/* FOOTER */
#app-footer {
  background: linear-gradient(180deg, #0d0d0d, #080808);
  border-top: 1px solid #222;
  padding: 12px 20px;
  font-family: 'VT323', monospace;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

#app-footer a {
  color: var(--accent);
  text-decoration: none;
}

#app-footer a:hover { text-decoration: underline; }

.footer-sep { color: #444; }

/* Responsive */
@media (max-width: 1024px) {
  #main-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100% !important;
    max-width: 100% !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #222;
  }
  #display-area { min-height: 300px; }
}

/* Full page layout */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#main-layout {
  flex: 1;
}