/* Modern Dark Theme Variables */
:root {
  --bg-dark: #121212;
  --bg-card: #1e1e1e;
  --text-main: #ffffff;
  --text-muted: #a0a0a0;
  --accent-neon: #ff007f;
  --accent-play: #1db954;
  --accent-stop: #e91429;
  --accent-wait: #f5a623;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- ANIMIERTER NEON-TITEL --- */
h2 {
  font-weight: 900;
  font-size: 2.2rem; /* Etwas größer */
  text-transform: uppercase;
  letter-spacing: 4px;
  margin-bottom: 25px;
  
  /* Farbverlauf, der sich bewegt */
  background: linear-gradient(45deg, var(--accent-neon), #7000ff, #00d4ff, var(--accent-neon));
  background-size: 300% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  
  /* Animation für Verlauf und pulsierendes Leuchten */
  animation: shineText 4s linear infinite, pulseGlow 2s ease-in-out infinite alternate;
}

/* Die Keyframes für den Titel-Effekt (am besten direkt unter das h2 packen) */
@keyframes shineText {
  to { background-position: 300% center; }
}

@keyframes pulseGlow {
  from { filter: drop-shadow(0 0 5px rgba(255, 0, 127, 0.4)); }
  to { filter: drop-shadow(0 0 15px rgba(255, 0, 127, 0.8)); }
}

/* --- THE CAMERA FIX: Perfect Square, No Stretching --- */
#qr-reader {
  width: 90%;
  max-width: 350px;
  aspect-ratio: 1 / 1; /* Forces a perfect square */
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--accent-neon);
  margin-bottom: 20px;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#qr-video {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Crops the video to fit the square beautifully */
}

/* Modern App Buttons */
.button, .button_startscan, .button_startstop {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: none;
  padding: 16px 32px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  margin: 10px 0;
  width: 90%;
  max-width: 350px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.button:active, .button_startscan:active, .button_startstop:active {
  transform: scale(0.96);
}
.button_startscan {
  background: linear-gradient(135deg, #ff007f, #7000ff);
  color: white;
}
.button_startstop {
  background-color: var(--accent-play);
}

/* Hide Debug Info by Default */
#videoid, #videotitle, #videoduration, #videoyear {
  display: none;
  background-color: var(--bg-card);
  padding: 15px 20px;
  border-radius: 12px;
  margin: 5px 0;
  width: 90%;
  max-width: 350px;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  font-size: 14px;
  color: var(--text-muted);
}
#videotitle span, #video-duration {
  color: var(--text-main);
  font-weight: bold;
}

.hidden {
  display: none;
}

/* Settings Toggle Button */
#show_hide_settings {
  background-color: var(--bg-card);
  border-radius: 50px;
  margin: 20px 0 10px 0;
  width: 90%;
  max-width: 350px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: transform 0.1s ease;
}
#show_hide_settings:active {
  transform: scale(0.96);
}
#show_hide_settings label {
  color: var(--text-main);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 14px;
  cursor: pointer;
  display: block;
  padding: 16px 32px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  border-radius: 50px;
}
#show_hide_settings input[type="checkbox"] {
  display: none;
}

/* --- THE SETTINGS UI FIX: Clean & Modern --- */
.settings_div {
  background-color: transparent;
  width: 90%;
  max-width: 350px;
  margin: 5px 0;
}
.text-block {
  background-color: var(--bg-card);
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 15px;
  border-left: 4px solid var(--accent-neon);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.heading {
  font-weight: 800;
  color: var(--accent-neon);
  margin-bottom: 12px;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 1px;
}
.settings_div label {
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
}
.settings_div input[type="checkbox"] {
  accent-color: var(--accent-neon);
  transform: scale(1.3);
  margin-right: 12px;
  cursor: pointer;
}
.settings_div input[type="number"] {
  background-color: var(--bg-dark);
  border: 1px solid #444;
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  width: 80px;
  margin-top: 10px;
  font-family: inherit;
  font-weight: bold;
  font-size: 14px;
}

hr {
  border: 0;
  height: 1px;
  background: #333;
  width: 100%;
  max-width: 350px;
  margin: 20px 0;
}

/* The Equalizer Animation - Verbessert & Lücke gefixt */
.equalizer-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 0;         /* Schrumpft auf 0, wenn inaktiv */
  margin: 0;         /* Nimmt keinen Platz weg */
  overflow: hidden;  /* Versteckt den Inhalt beim Schrumpfen */
  gap: 8px;          /* Etwas mehr Platz zwischen den Balken */
  opacity: 0;
  /* Weicher Übergang beim Aufklappen */
  transition: height 0.3s ease, margin 0.3s ease, opacity 0.3s ease;
}

.equalizer-container.playing {
  height: 50px;      /* Volle Höhe beim Abspielen */
  margin: 20px 0;    /* Schöner Abstand */
  opacity: 1;
}

/* --- DER KORRIGIERTE, DYNAMISCHE EQUALIZER --- */
.bar {
  width: 14px; 
  background: linear-gradient(to top, var(--accent-neon), #7000ff);
  border-radius: 6px;
  box-shadow: 0 0 12px var(--accent-neon);
  transform-origin: bottom;
  /* WICHTIG: Hier hat die Basis-Zeit (1s) gefehlt, sonst streikt der Browser! */
  animation: soundWave 1s infinite ease-in-out alternate;
}

/* Wir geben jedem Balken wieder seine eigene Höhe PLUS individuelles Chaos */
.bar:nth-child(1) { height: 30%; animation-duration: 0.7s; animation-delay: 0.0s; }
.bar:nth-child(2) { height: 60%; animation-duration: 1.1s; animation-delay: 0.2s; }
.bar:nth-child(3) { height: 100%; animation-duration: 0.8s; animation-delay: 0.4s; }
.bar:nth-child(4) { height: 70%; animation-duration: 1.0s; animation-delay: 0.1s; }
.bar:nth-child(5) { height: 40%; animation-duration: 0.9s; animation-delay: 0.3s; }

/* Die neue Animation: Höhen und Farben ändern sich */
@keyframes soundWave {
  0% { 
    transform: scaleY(0.1); 
    filter: hue-rotate(0deg); /* Startfarbe (Pink/Lila) */
  }
  50% { 
    transform: scaleY(0.6); 
  }
  100% { 
    transform: scaleY(1); 
    filter: hue-rotate(45deg); /* Endfarbe (wechselt leicht ins Bläuliche/Rote) */
    box-shadow: 0 0 20px #7000ff; /* Der Glow ändert sich mit */
  }
}

/* Modernes Link-Styling für den GitHub-Link */
a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 8px 16px;
  border-radius: 8px;
  background-color: transparent;
  transition: all 0.2s ease;
  display: inline-block;
  text-align: center;
}

a:hover, a:active {
  color: var(--text-main);
  background-color: var(--bg-card); /* Leichter Hintergrund beim Hovern */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* --- REPORT BUTTON & MODAL --- */
.button_report {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--bg-card);
  color: var(--accent-wait);
  border: 2px solid var(--accent-wait);
  padding: 10px 16px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  width: auto;          /* Overrides the large width */
  max-width: none;
  text-transform: uppercase;
  transition: all 0.2s ease;
  z-index: 100;         /* Keeps it on top of other elements */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); /* Nice floating drop-shadow */
}

.button_report:active {
  transform: scale(0.96);
}

.modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-content {
  width: 90%;
  max-width: 350px;
  box-sizing: border-box;
}
.modern-select {
  width: 100%;
  padding: 12px;
  margin: 10px 0 20px 0;
  background-color: var(--bg-dark);
  color: var(--text-main);
  border: 1px solid #444;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.modern-select:focus {
  border-color: var(--accent-neon);
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-actions button {
  width: 100%;
  margin: 0;
}