:root {
  --bg: #0f0b1e;
  --bg-soft: #150f2b;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --primary: #a855f7;
  --primary-2: #ec4899;
  --accent: #22d3ee;
  --success: #34d399;
  --text: #f3f0ff;
  --text-muted: #a99fc9;
  --radius: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

h1, .logo, .btn, h3 {
  font-family: 'Poppins', sans-serif;
}

/* Decorative background blobs */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}

.blob-1 {
  width: 420px;
  height: 420px;
  background: var(--primary);
  top: -120px;
  left: -100px;
}

.blob-2 {
  width: 380px;
  height: 380px;
  background: var(--accent);
  bottom: -140px;
  right: -100px;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  position: relative;
  z-index: 2;
  backdrop-filter: blur(6px);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-icon {
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.logo {
  font-size: 21px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo-icon {
  filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.6));
}

.nav-right button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
}

/* Main container */
.container {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 30px 20px 60px;
  width: 100%;
  position: relative;
  z-index: 2;
}

.hero {
  text-align: center;
  margin-bottom: 34px;
}

h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.highlight {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.5;
}

.mode-switch {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 22px;
  padding: 5px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.mode-btn {
  min-width: 120px;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: 600 13px 'Poppins', sans-serif;
}

.mode-btn.active {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.3);
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 36px 20px;
  border: 2px dashed rgba(168, 85, 247, 0.45);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-label:hover {
  border-color: var(--primary);
  background: rgba(168, 85, 247, 0.07);
  transform: translateY(-2px);
}

.upload-icon {
  font-size: 30px;
}

.upload-text {
  font-weight: 600;
  font-size: 15px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.file-name {
  text-align: center;
  margin-top: 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.video-preview {
  display: block;
  width: 100%;
  max-height: 360px;
  margin-top: 18px;
  border-radius: 12px;
  background: #050507;
}

.video-actions {
  margin-top: 18px;
}

[hidden] {
  display: none !important;
}

/* Waveform */
canvas#waveform {
  width: 100%;
  height: clamp(110px, 22vw, 140px);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  display: block;
  margin-bottom: 10px;
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 22px;
  font-variant-numeric: tabular-nums;
}

/* Controls grid */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.controls-group {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px 18px;
}

.controls-group h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-a { background: var(--primary); }
.dot-b { background: var(--primary-2); }
.dot-c { background: var(--accent); }

.controls-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 12px;
  margin-bottom: 6px;
}

.val-badge {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent);
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.btn {
  min-height: 46px;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.96);
}

button:focus-visible,
input[type="range"]:focus-visible,
input[type="checkbox"]:focus-visible,
.upload-label:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.btn.primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.35);
}

.btn.primary:hover {
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.5);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--card-border);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn.success {
  background: linear-gradient(90deg, var(--success), var(--accent));
  color: #06251c;
  box-shadow: 0 6px 20px rgba(52, 211, 153, 0.3);
}

.btn.success:hover {
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.45);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.progress-panel {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.16);
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--text-muted);
  font-size: 12px;
}

#progressPercent {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

#audioProgress {
  display: block;
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}

.status-msg {
  margin-top: 16px;
  font-size: 13px;
  color: var(--accent);
  min-height: 18px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 22px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--card-border);
  position: relative;
  z-index: 2;
}

/* Light theme override */
body.light-theme {
  --bg: #f7f5fb;
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-border: rgba(0, 0, 0, 0.08);
  --text: #1e1633;
  --text-muted: #6b6280;
}

body.light-theme canvas#waveform {
  background: rgba(0, 0, 0, 0.05);
}

@media (min-width: 560px) {
  .controls-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .controls-group:last-child {
    grid-column: span 2;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 20px 16px 50px;
  }
  h1 {
    font-size: 28px;
  }

  .card {
    padding: 18px;
    border-radius: 14px;
  }

  .upload-label {
    padding: 30px 14px;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-btn {
    flex: 1;
    min-width: 0;
  }
}

@media (max-width: 360px) {
  .container {
    padding-inline: 12px;
  }

  h1 {
    font-size: 25px;
  }

  .subtitle {
    font-size: 14px;
  }

  .logo {
    font-size: 19px;
  }
}

/* Toggle switch for silence removal */
.toggle-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
  margin-bottom: 10px;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background 0.2s ease;
}

.toggle-label input[type="checkbox"]::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
}

.toggle-label input[type="checkbox"]:checked {
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.toggle-label input[type="checkbox"]:checked::before {
  transform: translateX(18px);
}

.dot-d { background: #fbbf24; }