/*
============================================
🎨 CSS Structure
1. Layout & Typography
2. Controls & Toggles
3. Groove Mode Visuals
4. Simple Metronome Mode
5. Mode Tabs & Panels
6. Footer & Version Display
7. Update Button & Spinner
8. Tooltip Dialog & Notices
9. Animations & Effects
10. Responsive Media Queries
11. Subtle invalid input feedback
12. Floating UI Notice (BPM Adjust / Info Messages)
13. UNIFIED SLIDER STYLES (Groove & Simple)
14. Time Signature Controls
15. Hierarchical Beat Visuals
16. Theme Toggle (Bottom Right, Animated Slider)
================================================== */

/* ============================================
🎨 CSS Variables for Theming
============================================ */

:root {
  /* Light mode (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f3f3f3;
  --text-primary: #333333;
  --text-secondary: #666666;
  --accent: #b22222;
  --border: #dcdcdc;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  /* Dark mode */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --text-primary: #e0e0e0;
  --text-secondary: #999999;
  --accent: #b22222;
  --border: #3a3a3a;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-hover: rgba(0, 0, 0, 0.5);
}

/* Dark mode body gradient override */
[data-theme="dark"] body {
  background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
}

/* ============================================
🎨 1. Layout & Typography
============================================ */
/* App Header */
.app-header {
  text-align: center;
  margin-bottom: 24px;
  padding-top: 8px;
}

.app-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
  line-height: 1.2;
}

.app-header .tagline {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin: 0;
  font-style: italic;
}

body {
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial;
  margin: 18px auto;
  max-width: 900px;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 0 18px;
  box-sizing: border-box;
  min-height: 100vh;
  transition: background 0.3s ease;
}
h1 {
  margin-bottom: 4px;
}
label {
  display: block;
  margin-top: 20px;
  font-weight: 600;
}
input,
textarea,
select {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 1rem;
  padding: 10px 12px;
  margin-top: 6px;
  box-sizing: border-box;
  border-radius: 6px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease,
    background-color 0.2s ease;
  min-height: 44px; /* Touch-friendly */
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(178, 34, 34, 0.1);
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--bg-secondary);
}
input[type="number"] {
  width: 90px;
}
select {
  width: 110px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23666' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  padding-right: 30px; /* Space for arrow */
  cursor: pointer;
}

/* Dark mode arrow color fix */
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23999' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  font-family: inherit; /* Match body font */
  line-height: 1.5;
}

#sessionMode {
  width: 100%;
  max-width: 260px;
}
textarea {
  width: 100%;
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.col {
  flex: 1;
  min-width: 200px;
}
button {
  padding: 10px 16px;
  margin-top: 10px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 4px var(--shadow);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px; /* Touch-friendly minimum */
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-hover);
  background: var(--text-secondary);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px var(--shadow);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--bg-secondary);
  border-color: var(--border);
  box-shadow: none;
  transform: none; /* Prevent hover effects */
}
/* Primary action buttons (Start/Stop) */
#startBtn,
#simpleStartBtn {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

#startBtn:hover:not(:disabled),
#simpleStartBtn:hover:not(:disabled) {
  background: #9a1a1a; /* Darker red */
  box-shadow: 0 4px 12px rgba(178, 34, 34, 0.4);
}

#startBtn:active:not(:disabled),
#simpleStartBtn:active:not(:disabled) {
  background: #7a1515; /* Even darker when pressed */
}
.big {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 12px;
}
.small {
  font-size: 0.92rem;
}
.status {
  margin-top: 20px;
  padding: 16px 16px 32px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
}

/* ============================================
🎛 2. Controls & Toggles
============================================ */
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.controls .toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
}
.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 24px;
  min-height: unset;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background 160ms ease;
}
.toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 160ms ease;
}
.toggle input[type="checkbox"]:checked {
  background: #4caf50;
}
.toggle input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}
/* Disabled toggle styling */
.toggle input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--text-secondary);
}

.toggle input[type="checkbox"]:disabled::after {
  opacity: 0.6;
}

.toggle:has(input[type="checkbox"]:disabled) {
  opacity: 0.6;
  cursor: not-allowed;
}

.toggle:has(input[type="checkbox"]:disabled) #tempoSyncedLabel,
.toggle:has(input[type="checkbox"]:disabled) span {
  opacity: 0.6;
  cursor: not-allowed;
  color: #999;
}
.toggle #tempoSyncedLabel {
  margin-left: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ============================================
🥁 3. Groove Mode Visuals
============================================ */
#metronomeVisuals {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-height: 160px;
  padding-top: 12px;
}
.beat-dot,
.beat-dot-simple {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: #bfbfbf;
  opacity: 0.6;
  transition: all 0.15s ease;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.35);
}
.finishing-badge {
  display: none;
  color: #8a6d00;
  font-weight: 600;
}
.finishing-badge.visible {
  display: inline;
  font-style: italic;
  transition: opacity 180ms ease;
  opacity: 1;
}
.countdown-badge {
  font-size: 2.5rem;
  font-weight: bold;
  text-align: center;
  color: var(--text-primary);
  opacity: 0.6;
  margin-bottom: 0;
  margin-top: -24px;
  min-height: 3rem;
}
.countdown-badge.pulse {
  animation: pulse 0.5s ease;
}

/* ============================================
🥁 4. Simple Metronome Mode
============================================ */

#metronomeVisualsSimple {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#simpleMetronomeDot.pulse {
  transform: scale(1.25);
  transition: transform 120ms ease;
}
.beats-and-sound-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 40px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.beats-section,
.sound-section {
  display: flex;
  flex-direction: column;
}
.beats-section label,
.sound-section label {
  font-size: 14px;
  margin-bottom: 4px;
}
#soundProfileGroove,
#soundProfileSimple {
  width: 90px;
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 8px;
  appearance: none;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23666' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
}

/* ============================================
🧭 5. Mode Tabs & Panels
============================================ */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin: 20px 0;
  padding: 8px 8px 16px 8px;
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: 0 1px 3px var(--shadow);
}
.tab {
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px var(--shadow);
}

.tab:hover:not(.disabled) {
  background: var(--text-secondary);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px var(--shadow-hover);
}

.tab.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  box-shadow: 0 2px 8px var(--shadow-hover);
}

.tab.disabled {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}
.panel {
  margin-top: 8px;
  padding: 20px;
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 1px 4px var(--shadow);
  border: 1px solid var(--border);
}
.hidden {
  display: none !important;
}

/* ============================================
🎯 6. Footer & Version Display
============================================ */
#VersionNumber {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-family: monospace;
  text-align: center;
  box-shadow: 0 2px 6px var(--shadow);
  z-index: 9999;
  opacity: 0.9;
}
#VersionNumber:hover {
  opacity: 1;
}
#VersionNumber:empty {
  display: none;
}
.footer-hidden {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease;
}
.footer-visible {
  opacity: 0.9;
  visibility: visible;
  transition: opacity 0.6s ease;
}

/* ============================================
🆕 7. Update Button & Spinner
============================================ */
#checkUpdatesBtn {
  position: fixed;
  top: 60px;
  right: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10000;
  box-shadow: 0 2px 6px var(--shadow-hover);
  transition: all 0.2s ease;
}

#checkUpdatesBtn:hover {
  background-color: var(--text-secondary);
  transform: scale(1.05);
  box-shadow: 0 4px 8px var(--shadow-hover);
}

#checkUpdatesBtn:active {
  transform: scale(0.98);
}

.update-button {
  font-size: 0.9rem;
  padding: 4px 8px;
  margin-left: 10px;
  border: 1px solid currentColor;
  background-color: transparent;
  color: inherit;
  font-weight: bold;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.update-button:hover {
  color: #ff4d00;
  border-color: #ff4d00;
}

.update-button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.update-button.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-left: -10px; /* ← Center horizontally */
  margin-top: -10px; /* ← Center vertically */
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.update-button.loading svg {
  opacity: 0; /* Hide SVG icon when spinner shows */
}

/* ============================================
🎨 SVG Icon Styling
============================================ */

/* Ensure SVGs inherit button/container colors */
button svg,
#tooltipTrigger svg {
  display: block;
  stroke: currentColor;
  transition: transform 0.2s ease;
}

/* Consistent sizing for utility buttons */
#tooltipTrigger svg,
#checkUpdatesBtn svg {
  width: 28px;
  height: 28px;
}
#themeIcon {
  display: block;
  line-height: 1;
  transition: transform 0.3s ease;
  font-size: 1.4rem; /* ← Matches original emoji size */
}

/* Slightly smaller for tap tempo */
#tapTempoBtn svg {
  width: 24px;
  height: 24px;
}

/* Hover scale effect for utility buttons */
#tooltipTrigger:hover svg,
#checkUpdatesBtn:hover svg,
#themeToggleBtn:hover svg {
  transform: scale(1.1);
}

/* =====================================
💬 8. Settings Dialog
======================================== */
#settingsTrigger {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1.4rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10000;
  box-shadow: 0 2px 6px var(--shadow-hover);
  transition: all 0.2s ease;
}

#settingsTrigger:hover {
  background: var(--text-secondary);
  transform: scale(1.05);
  box-shadow: 0 4px 8px var(--shadow-hover);
}

#settingsTrigger:active {
  transform: scale(0.98);
}

#settingsDialog {
  position: fixed;
  top: 60px;
  right: 12px;
  max-width: 340px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 9999;
}

#settingsDialog.visible {
  opacity: 1;
  pointer-events: auto;
}

.settings-section {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.settings-section h2,
.help-section h2 {
  margin-top: 0;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.settings-group {
  margin-bottom: 12px;
}

.settings-group .toggle {
  display: flex; /* Enables flexbox alignment */
  align-items: center; /* Vertically centers the switch and text */
  gap: 12px; /* Space between the switch and the text */
  cursor: pointer;
  width: 100%; /* Ensures full width clickable area */
}

/* Tweaks the text weight to match the header better */
.settings-group .toggle span {
  font-weight: 600;
  font-size: 1rem;
}

.setting-description {
  margin: 4px 0 0 5px; /* Top 4px, Left 5px indentation */
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.35;
}

.help-section ul {
  padding-left: 18px;
  margin: 8px 0 0;
}

.help-section li {
  margin-bottom: 4px;
}

.help-section kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.85rem;
  font-family: monospace;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 2px var(--shadow);
  font-weight: 600;
}

/* Mobile adjust */
@media (max-width: 600px) {
  #settingsDialog {
    max-width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
  }
}

/* ============================================
🎞️ 9. Animations & Effects
============================================ */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.4);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.6;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

@keyframes bpmFlash {
  0% {
    background-color: #f5e8b0;
  }
  100% {
    background-color: inherit;
  }
}

@keyframes bpmFlash {
  0% {
    background-color: #f5e8b0;
    box-shadow: 0 0 8px rgba(245, 232, 176, 0.8);
  }
  100% {
    background-color: #fff;
    box-shadow: none;
  }
}

.bpm-flash {
  animation: bpmFlash 0.3s ease-in-out;
}

@keyframes tapPulse {
  0% {
    transform: scale(1);
    background-color: #f7e89c;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  50% {
    transform: scale(1.15);
    background-color: #fff4b0;
    box-shadow: 0 0 12px rgba(255, 213, 0, 0.6);
  }
  100% {
    transform: scale(1);
    background-color: inherit;
    box-shadow: none;
  }
}

#tapTempoBtn.tap-pulse {
  animation: tapPulse 0.25s ease-out;
}

button#installBtn.utility-button {
  position: fixed;
  bottom: 12px;
  right: 12px;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 6px var(--shadow-hover);
  z-index: 1000;
  transition: all 0.2s ease;
}

button#installBtn.utility-button:hover {
  background-color: #9a1a1a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(178, 34, 34, 0.4);
}

button#installBtn.utility-button:active {
  transform: translateY(0);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =============================
📱 10. Responsive Media Queries
================================ */
@media (max-width: 600px) {
  body {
    margin: 12px auto;
    padding: 0 12px;
  }

  .panel {
    padding: 16px;
  }

  .status {
    padding: 14px 14px 28px 14px;
  }

  label {
    margin-top: 16px;
  }

  /* Ensure touch targets are large enough */
  button {
    min-height: 40px;
  }

  input[type="number"],
  select {
    min-height: 44px;
  }
  #VersionNumber {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  #tooltipDialog {
    max-width: calc(100vw - 24px); /* 12px margin on each side */
    right: 12px;
    left: 12px;
    top: 60px;
    max-height: calc(100vh - 100px); /* More breathing room on mobile */
  }
}

@media (max-width: 500px) {
  .beats-and-sound-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ===================================
   11. Subtle invalid input feedback
   =================================== */

.invalid-flash {
  animation: flashInvalid 0.3s ease;
  border-color: #f55 !important;
}

@keyframes flashInvalid {
  from {
    box-shadow: 0 0 6px #f55;
  }
  to {
    box-shadow: none;
  }
}

.info-flash {
  animation: flashInfo 1.2s ease;
}

@keyframes flashInfo {
  from {
    color: #00b3ff;
  }
  to {
    color: inherit;
  }
}

/* ============================================================
📢 12. Floating UI Notice (BPM Adjust / Info Messages)
============================================================ */
.ui-notice {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(150, 130, 180, 0.9); /* 🌸 muted lavender */
  color: var(--text-primary);
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}

/* When shown */
.ui-notice.show {
  opacity: 1;
  transform: translateX(-50%) translateY(5px);
}

/* When hidden */
.ui-notice.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

/* Shorter display window */
@keyframes autoFadeOut {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  10% {
    opacity: 1;
    transform: translateY(5px);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Auto fade helper (1.8s total) */
.ui-notice.auto {
  animation: autoFadeOut 1.8s ease forwards;
}

/* =================================================================
   🎚️ 13. SLIDER COMPONENTS (Unified & Clean)
   ================================================================= */

/* 📦 THE CONTAINER BOX */
.bpm-slider-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: inset 0 1px 3px var(--shadow);
  padding: 30px 0 15px 0;
  margin: 20px 0 30px 0;
  width: 100%;
  position: relative;
  display: block;
}

/* 📏 THE SLIDER TRACK */
#groove-slider,
#simpleMetronomeSlider {
  width: 85% !important; /* Force fit inside box */
  height: 12px !important;
  margin: 0 auto 20px auto !important;
  padding: 0 !important;
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border) !important;
  border-radius: 5px !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

/* 🔗 CONNECT BAR (Active Range) */
.noUi-connect {
  background: var(--accent) !important;
}

/* 🔘 HANDLES */
.noUi-horizontal .noUi-handle {
  width: 16px !important;
  height: 16px !important;
  right: -8px !important;
  top: -3px !important;
  border-radius: 50% !important;
  background: var(--accent) !important;
  border: none !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
  cursor: pointer !important;
  transition: transform 0.1s ease !important;
}

.noUi-horizontal .noUi-handle:hover {
  transform: scale(1.1) !important;
}

/* Hide default handle stripes */
.noUi-handle::before,
.noUi-handle::after {
  display: none !important;
}

/* 🔢 PIPS & TICKS CONTAINER */
.noUi-pips {
  padding-top: 4px !important;
  height: 30px !important;
  color: var(--text-secondary) !important;
  font-family: inherit !important;
}

/* ➖ TICKS (Markers) */
.noUi-marker,
.noUi-marker-large,
.noUi-marker-sub {
  width: 1px !important;
  background: var(--text-secondary) !important;
  height: 8px !important;
  transition: all 0.2s ease !important;
}

/* 🔴 ACTIVE TICK (The growing red line) */
.noUi-marker.active-marker {
  background: var(--accent) !important;
  height: 13px !important;
  box-shadow: 0 0 6px rgba(178, 34, 34, 0.8) !important;
  opacity: 1 !important;
}

/* 🔠 NUMBERS (Labels) */
.noUi-value {
  color: var(--text-secondary) !important;
  font-size: 0.75rem !important;
  padding-top: 3px !important;
  cursor: pointer !important;
  transition: all 0.1s ease !important;
}
.noUi-value:hover {
  color: var(--accent) !important;
}

/* 🔴 ACTIVE NUMBER (Red & Bold) */
.noUi-value.active-pip {
  color: var(--accent) !important;
  font-weight: 700 !important;
  text-shadow: 0 0 8px rgba(178, 34, 34, 0.4) !important;
  font-size: 0.75rem !important;
}

/* 🚫 DISABLED STATE */
#groove-slider-wrapper.disabled .noUi-connect,
#simple-slider-wrapper.disabled .noUi-connect {
  background: var(--text-secondary) !important;
}
#groove-slider-wrapper.disabled .noUi-handle,
#simple-slider-wrapper.disabled .noUi-handle {
  background: var(--text-secondary) !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}
#groove-slider-wrapper.disabled .noUi-value,
#simple-slider-wrapper.disabled .noUi-value {
  color: var(--text-secondary) !important;
  opacity: 0.5 !important;
  pointer-events: none !important;
}
#groove-slider-wrapper.disabled .noUi-marker,
#simple-slider-wrapper.disabled .noUi-marker {
  opacity: 0.5 !important;
}

/* 🧹 LEGACY CLEANUP */
.groove-ticks-container,
#slider-numbers,
#simple-slider-numbers,
#simple-ticks-container {
  display: none !important;
}

/* ============================================
🎼 14. Time Signature Controls
============================================ */
.beats-section {
  /* Use flexbox to align our new controls */
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.time-signature-controls {
  display: flex;
  flex-direction: column;
}

/* Width fix for all dropdowns in this section */
#groovePresetSelect,
#simplePresetSelect,
#grooveSubdivisionSelect,
#simpleSubdivisionSelect {
  width: 100px;
}

.custom-time-signature-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.custom-time-signature-inputs input[type="number"] {
  width: 60px;
}

/* ============================================
🎵 15. Hierarchical Beat Visuals
============================================ */

/* --- Container Alignment Fix --- */
#beat-indicator-container,
#beat-indicator-container-simple {
  display: flex;
  justify-content: center; /* ← CHANGED from flex-start */
  align-items: center;
  flex-wrap: nowrap;
  gap: 14px;
  margin-top: 14px;
  padding: 0 10px;
  overflow: hidden;
  width: 100%;
  padding: 15px 10px 30px;
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: inset 0 1px 3px var(--shadow);
}

/* --- Wrapper & Text Alignment Fix --- */
.beat-wrapper {
  position: relative; /* Establishes a positioning context for the text */
  display: flex;
  /* Center the dot horizontally and vertically */
  justify-content: center;
  align-items: center;
  margin: 0 12px;
  /* Set a fixed height that can contain the LARGEST dot + text */
  height: 100px;
}

.phonation-text {
  position: absolute;
  bottom: -22px; /* Pins the text to the absolute bottom of the wrapper */
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.1s ease-out;
  user-select: none;
}

/* --- Dot Size Hierarchy (Unchanged) --- */
.beat-dot.primary {
  width: 64px;
  height: 64px;
}
.beat-dot.secondary {
  width: 48px;
  height: 48px;
}
.beat-dot.tertiary {
  width: 36px;
  height: 36px;
}

/* --- Flashing & Accent Logic --- */
.beat-dot {
  /* Keep the smooth transition */
  transition: all 0.15s ease;
}

/* Base flashing effect: scale and shadow */
.beat-dot.flashing {
  transform: scale(1.4);
  opacity: 1;
  outline: 1px solid transparent;
}

/* COLOR for Accent Beats (Downbeat)*/
.beat-dot.flashing.accent-flash {
  background-color: #b22222; /* Red */
}

/* COLOR for Normal Beats*/
.beat-dot.flashing.normal-flash {
  background-color: #006400; /* Green */
}

/* --- Flashing Text Colors (Unchanged) --- */
.phonation-text.flash-primary {
  color: #b22222;
}
.phonation-text.flash-secondary {
  color: #1e90ff;
}
.phonation-text.flash-tertiary {
  color: #ff8c00;
}

/* ===============================================
🌙 16. Theme Toggle (Bottom Right, Animated Slider)
================================================== */

.theme-toggle-floating {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10000;
}

.theme-btn {
  background-color: var(--bg-secondary);
  width: 72px;
  height: 40px;
  border-radius: 40px;
  padding: 0 2px;
  border: 1px solid var(--border);

  box-shadow:
    inset 0 4px 30px rgba(0, 0, 0, 0.1),
    inset 0 4px 8px rgba(0, 0, 0, 0.1),
    inset 0 -2px 4px rgba(0, 0, 0, 0.05);

  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: box-shadow 0.3s ease;
}

.theme-btn:hover {
  box-shadow:
    inset 0 4px 30px rgba(0, 0, 0, 0.15),
    inset 0 4px 8px rgba(0, 0, 0, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.theme-btn__indicator {
  background-color: var(--bg-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  position: absolute;
  left: 2px; /* ← TIGHTER positioning */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.3s ease;
}

.theme-btn__icon-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.theme-btn__icon {
  position: absolute;
  width: 26px;
  height: 26px;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

/* Show/hide icons based on theme */
.sun-svg {
  color: #fbbf24;
  opacity: 1;
}

.moon-svg {
  color: #93c5fd;
  opacity: 0;
}

/* Animation for icon spin */
.theme-btn__icon.animated {
  animation: iconSpin 0.5s ease;
}

@keyframes iconSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Dark mode styles */
[data-theme="dark"] .theme-btn {
  box-shadow:
    inset 0 4px 30px rgba(0, 0, 0, 0.3),
    inset 4px 0 8px rgba(0, 0, 0, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .theme-btn__indicator {
  transform: translateX(36px);
  background-color: var(--bg-secondary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .sun-svg {
  opacity: 0;
}

[data-theme="dark"] .moon-svg {
  opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .theme-toggle-floating {
    bottom: 12px;
    right: 12px;
  }

  .theme-btn {
    width: 64px;
    height: 36px;
  }

  .theme-btn__indicator {
    width: 32px;
    height: 32px;
  }

  [data-theme="dark"] .theme-btn__indicator {
    transform: translateX(32px);
  }

  .theme-btn__icon {
    width: 22px;
    height: 22px;
  }

  /* Move up if install button is visible */
  body:has(#installBtn:not([style*="display: none"])) .theme-toggle-floating {
    bottom: 68px;
  }
}
