:root {
  --bg: #0d0d1a;
  --bg2: #141428;
  --bg3: #1c1c3a;
  --accent1: #00d4ff;
  --accent2: #ff2d95;
  --accent3: #39ff14;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --glass: rgba(20, 20, 50, 0.7);
  --glass-border: rgba(100, 100, 200, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

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

/* HEADER */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(135deg, #120e2a 0%, #0a1628 100%);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.logo {
  font-weight: 900;
  font-size: 1.5rem;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  letter-spacing: -0.5px;
}
.logo-emoji { -webkit-text-fill-color: initial; }
.subtitle {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 300;
  letter-spacing: 0.5px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }

.rec-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ff4444;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
}
.rec-pulse {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #ff4444;
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* MAIN */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  overflow: hidden;
}

#canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.08), 0 0 60px rgba(255, 45, 149, 0.05);
  border: 1px solid var(--glass-border);
  aspect-ratio: 4/3;
}
#canvas {
  width: 100%;
  height: 100%;
  display: block;
}
#effect-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent1);
  border: 1px solid rgba(0, 212, 255, 0.2);
}
#fps-display {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.5);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--accent3);
}
#no-camera-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  pointer-events: none;
}
.no-cam-icon { font-size: 3rem; }
.no-cam-sub { font-size: 0.7rem; color: var(--text-dim); }

/* VOICE PANEL */
#voice-panel-toggle { text-align: center; }
.pill-btn {
  background: var(--bg3);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  transition: all 0.2s;
}
.pill-btn:hover { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.pill-btn.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }

#voice-panel {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}
.voice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.voice-header h3 { font-size: 0.9rem; font-weight: 800; }

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.75rem;
}
.toggle-switch input { display: none; }
.toggle-slider {
  width: 38px;
  height: 20px;
  background: #333;
  border-radius: 10px;
  position: relative;
  transition: background 0.3s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #888;
  transition: all 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent3); }
.toggle-switch input:checked + .toggle-slider::after { left: 20px; background: #fff; }

.voice-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.voice-preset-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: var(--bg2);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 1.3rem;
}
.voice-preset-btn span {
  font-size: 0.5rem;
  color: var(--text-dim);
  margin-top: 1px;
}
.voice-preset-btn:hover { border-color: var(--accent2); transform: scale(1.08); }
.voice-preset-btn.active { border-color: var(--accent2); background: rgba(255, 45, 149, 0.15); box-shadow: 0 0 12px rgba(255, 45, 149, 0.3); }

.voice-sliders {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.voice-sliders label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
}
.voice-sliders input[type="range"] {
  flex: 1;
  accent-color: var(--accent1);
  height: 4px;
}
.voice-sliders span {
  font-family: 'JetBrains Mono', monospace;
  min-width: 32px;
  text-align: right;
  color: var(--accent1);
  font-size: 0.7rem;
}

#audio-viz {
  width: 100%;
  max-width: 100%;
  height: 50px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

/* CATEGORIES */
#categories-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}
#categories-bar::-webkit-scrollbar { height: 0; }
.cat-tab {
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  transition: all 0.2s;
  white-space: nowrap;
}
.cat-tab:hover { color: var(--text); border-color: var(--accent1); }
.cat-tab.active { background: var(--accent1); color: #000; border-color: var(--accent1); }

/* EFFECTS STRIP */
#effects-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}
#effects-strip::-webkit-scrollbar { height: 4px; }
#effects-strip::-webkit-scrollbar-track { background: var(--bg2); border-radius: 2px; }
#effects-strip::-webkit-scrollbar-thumb { background: var(--accent1); border-radius: 2px; }

.fx-tile {
  flex-shrink: 0;
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.15s;
}
.fx-tile:hover { transform: scale(1.08); }
.fx-tile:active { transform: scale(0.95); }
.fx-tile-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--bg2);
  transition: all 0.2s;
}
.fx-tile.active .fx-tile-icon {
  border-color: var(--accent1);
  box-shadow: 0 0 14px rgba(0, 212, 255, 0.4);
  background: rgba(0, 212, 255, 0.1);
}
.fx-tile-label {
  font-size: 0.55rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.1;
  font-weight: 600;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* CONTROLS BAR */
#controls-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: linear-gradient(180deg, transparent, var(--bg2));
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg3);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  transition: all 0.2s;
  min-width: 60px;
}
.ctrl-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-dim);
}
.ctrl-btn:hover { border-color: var(--accent1); background: rgba(0, 212, 255, 0.08); }
.ctrl-btn:active { transform: scale(0.95); }
.ctrl-btn.recording { border-color: #ff4444; background: rgba(255, 68, 68, 0.15); animation: rec-glow 1.5s ease-in-out infinite; }
.ctrl-btn.slideshow-active { border-color: var(--accent3); background: rgba(57, 255, 20, 0.1); }

@keyframes rec-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 68, 68, 0.3); }
  50% { box-shadow: 0 0 20px rgba(255, 68, 68, 0.6); }
}

/* FOOTER */
footer {
  padding: 10px 20px;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-dim);
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
}
footer a { color: var(--accent1); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--bg2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 280px;
  max-width: 360px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 { font-weight: 800; }
.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.82rem;
  font-weight: 600;
  border-bottom: 1px solid var(--glass-border);
}
.setting-row input[type="checkbox"] { accent-color: var(--accent1); width: 18px; height: 18px; }
.setting-row input[type="range"] { width: 120px; accent-color: var(--accent1); }
.setting-row span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--accent1);
  min-width: 36px;
  text-align: right;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  .logo { font-size: 1.2rem; }
  .subtitle { font-size: 0.6rem; }
  header { padding: 8px 12px; }
  main { padding: 8px; gap: 8px; }
  .ctrl-btn { padding: 6px 10px; font-size: 1rem; min-width: 50px; }
  .fx-tile { width: 56px; }
  .fx-tile-icon { width: 48px; height: 48px; font-size: 1.2rem; }
  #canvas-wrapper { aspect-ratio: 4/3; }
}