:root {
   /* Vibrant Momentury Color Palette - High Contrast & Premium */
   --primary-purple: #A855F7;
   --primary-yellow: #FBD44C;
   --primary-green: #34D399;
   --vivid-purple: #8B5CF6;
   --vivid-green: #10B981;
   --accent-pink: #F472B6;
   
   /* Legacy support */
   --primary: #A855F7;
   --primary-hover: #9333EA;
   --secondary: #FBD44C;
   --tertiary: #34D399;
   --quaternary: #42A5F5;

   /* Contextual */
   --success: #66BB6A;
   --warning: #FFCA28;
   --danger: #EF5350;

   /* Backgrounds - Rich Dark */
   --bg-primary: #0f0f1a;
   --bg-secondary: #111118;
   --bg-tertiary: #0a0a0f;
   --bg-elevated: #080808;

   /* Text - High Contrast */
   --text-primary: #FFFFFF;
   --text-secondary: #E5E7EB;
   --text-muted: #9CA3AF;
   --text-disabled: #6B7280;

   /* Borders */
   --border-subtle: #202225;
   --border-default: #4F545C;

   /* Effects */
   --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
   --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
   --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

   /* Spacing */
   --space-1: 4px;
   --space-2: 8px;
   --space-3: 12px;
   --space-4: 16px;
   --space-5: 20px;
   --space-6: 24px;
   --space-8: 32px;

   /* Radius */
   --radius-sm: 6px;
   --radius-md: 12px;
   --radius-lg: 16px;
   --radius-xl: 20px;
   --radius-full: 50px;
   
   /* Typography */
   --font-serif: 'Instrument Serif', serif;
   --font-sans: 'Instrument Sans', sans-serif;

   /* Legacy compatibility */
   --dark: var(--bg-primary);
   --medium: var(--bg-secondary);
   --light: var(--text-primary);
   --gray: var(--bg-tertiary);
   --light-gray: var(--text-secondary);
   --gradient: linear-gradient(135deg, var(--primary), var(--secondary));
}

* {
   box-sizing: border-box;
   -webkit-tap-highlight-color: transparent;
}

body {
   font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
   background: linear-gradient(135deg, #0f0f1a 0%, #111118 50%, #080808 100%);
   color: var(--text-primary);
   margin: 0;
   padding: 0;
   font-size: 16px;
   line-height: 1.5;
   overflow-x: hidden;
   /* Progressive enhancement for viewport height stability */
   min-height: 100vh; /* Fallback for older browsers */
   min-height: 100svh; /* Small viewport height - most stable on mobile */
   touch-action: pan-y;
   overscroll-behavior: none;
}

.app-header {
   background: var(--bg-secondary);
   backdrop-filter: blur(20px);
   padding: calc(env(safe-area-inset-top) + var(--space-3)) var(--space-5) var(--space-3);
   position: fixed;
   top: 0;
   z-index: 110;
   left: 0;
   right: 0;
   box-shadow: var(--shadow-sm);
   border-bottom: 1px solid var(--border-subtle);
}

.header-content {
   display: flex;
   justify-content: space-between;
   align-items: center;
   max-width: 600px;
   margin: 0 auto;
}

.logo {
   font-size: 24px;
   font-weight: 800;
   background: linear-gradient(135deg, var(--primary), var(--secondary));
   -webkit-background-clip: text;
   -webkit-text-fill-color: transparent;
   letter-spacing: -1px;
}

.connection-status {
   display: flex;
   align-items: center;
   gap: 8px;
   font-size: 12px;
   color: var(--light-gray);
   opacity: 0;
   transition: opacity 0.3s ease;
}

.connection-status.show {
   opacity: 1;
}

.status-dot {
   width: 6px;
   height: 6px;
   border-radius: 50%;
   background: var(--primary);
   animation: pulse 2s infinite;
}

.disconnect-btn {
   background: var(--danger);
   color: white;
   border: none;
   padding: 4px 8px;
   border-radius: 12px;
   font-size: 10px;
   cursor: pointer;
   margin-left: 4px;
}

.main-container {
   padding: 80px var(--space-4) calc(110px + env(safe-area-inset-bottom));
   max-width: 600px;
   margin: 0 auto;
   /* Progressive enhancement for stable viewport height */
   min-height: 100vh; /* Fallback for older browsers */
   min-height: 100svh; /* Small viewport height - stable on mobile */
   /* Performance optimization */
   will-change: auto; /* Let browser decide what to optimize */
}

.card {
   background: var(--bg-secondary);
   border: 1px solid var(--border-subtle);
   border-radius: var(--radius-lg);
   padding: var(--space-5);
   margin-bottom: var(--space-4);
   box-shadow: var(--shadow-sm);
   transition: all 0.3s ease;
}

.card:hover {
   border-color: var(--border-default);
   box-shadow: var(--shadow-md);
}

/* Remove cards from list sections - only player needs card background */
#search-section .card,
#library-section .card,
#playlists-section .card {
   background: transparent;
   border: none;
   box-shadow: none;
   padding: 0;
   margin-bottom: 0;
}

#search-section .card:hover,
#library-section .card:hover,
#playlists-section .card:hover {
   border: none;
   box-shadow: none;
}

/* Keep card styling only for player section */
#player-section .card {
   background: var(--bg-secondary);
   border: 1px solid var(--border-subtle);
   border-radius: var(--radius-lg);
   padding: var(--space-5);
   margin-bottom: var(--space-4);
   box-shadow: var(--shadow-sm);
}

.card-title {
   color: var(--text-primary);
   font-size: 24px;
   font-weight: 700;
   margin: 0 0 var(--space-4);
   display: flex;
   justify-content: space-between;
   align-items: center;
}

.btn {
   background: linear-gradient(135deg, var(--primary), var(--primary-hover));
   color: white;
   border: none;
   padding: var(--space-3) var(--space-5);
   border-radius: var(--radius-full);
   font-size: 16px;
   font-weight: 600;
   cursor: pointer;
   transition: all 0.2s ease;
   min-height: 48px;
   display: inline-flex;
   align-items: center;
   justify-content: center;
   gap: var(--space-2);
   text-decoration: none;
   box-shadow: var(--shadow-sm);
   font-family: inherit;
}

.btn:hover { 
   transform: translateY(-2px); 
   box-shadow: var(--shadow-md);
}

.btn:active { transform: scale(0.98); }

.btn.secondary { 
   background: linear-gradient(135deg, var(--success), #4CAF50); 
}

.btn.tertiary { 
   background: linear-gradient(135deg, var(--tertiary), #FFB74D); 
}

.btn.danger { 
   background: linear-gradient(135deg, var(--danger), #F44336); 
}

.btn.outline {
   background: transparent;
   color: var(--text-primary);
   border: 2px solid var(--border-default);
   box-shadow: none;
}

.btn.outline:hover {
   border-color: var(--primary);
   background: rgba(123, 104, 238, 0.1);
}

.btn.small {
   padding: var(--space-2) var(--space-4);
   font-size: 14px;
   min-height: 36px;
}

.btn:disabled { 
   background: var(--bg-elevated); 
   cursor: not-allowed; 
   transform: none; 
}

.search-container {
   position: sticky;
   top: 41px;
   z-index: 90;
   padding: var(--space-5) 0;
   margin: 0 0 var(--space-4) 0;
}

.search-header {
   display: flex;
   align-items: center;
   gap: 12px;
   margin-bottom: 20px;
}

.back-btn {
   background: var(--gray);
   color: var(--light);
   border: none;
   width: 40px;
   height: 40px;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   cursor: pointer;
   font-size: 18px;
   transition: all 0.3s ease;
}

.back-btn:hover {
   background: var(--primary);
   transform: scale(1.05);
}

.search-input {
   width: 100%;
   max-width: 100%;
   background: var(--bg-tertiary);
   border: 2px solid var(--border-default);
   border-radius: var(--radius-full);
   padding: var(--space-4) var(--space-4);
   font-size: 16px;
   color: var(--text-primary);
   outline: none;
   transition: all 0.2s ease;
   min-height: 52px;
   box-sizing: border-box;
}

.search-input:focus {
   border-color: var(--primary);
   box-shadow: 0 0 0 4px rgba(123, 104, 238, 0.1);
}

.search-input::placeholder {
   color: var(--text-muted);
}

.track-item {
   display: flex;
   align-items: center;
   gap: var(--space-3);
   padding: var(--space-4);
   background: var(--bg-secondary);
   border: 1px solid var(--border-subtle);
   border-radius: var(--radius-md);
   margin-bottom: var(--space-3);
   cursor: pointer;
   transition: all 0.2s ease;
   position: relative;
}

.track-item:hover {
   background: var(--bg-tertiary);
   border-color: var(--primary);
   transform: translateX(4px);
}

.track-item.selected { 
   background: rgba(123, 104, 238, 0.1); 
   border-color: var(--primary); 
}

.track-item.playing { 
   background: rgba(123, 104, 238, 0.1); 
   border-color: var(--primary); 
}

.track-item.playing .track-name { 
   color: var(--primary); 
   font-weight: 600; 
}

.track-cover {
   width: 56px;
   height: 56px;
   border-radius: var(--radius-sm);
   background: var(--bg-elevated);
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 24px;
   flex-shrink: 0;
   object-fit: cover;
}

.track-info {
   flex: 1;
   min-width: 0;
}

.track-name {
   font-weight: 600;
   font-size: 16px;
   margin-bottom: var(--space-1);
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.track-artist {
   color: var(--text-secondary);
   font-size: 14px;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.track-duration {
   color: var(--light-gray);
   font-size: 12px;
   font-family: monospace;
   margin-right: 12px;
}

.track-actions {
   display: flex;
   gap: 4px;
   opacity: 0;
   transition: opacity 0.2s ease;
}

.track-item:hover .track-actions { opacity: 1; }

/* Ensure track actions are always visible on touch devices */
@media (hover: none) {
   .track-actions {
      opacity: 1;
   }
}

.track-action-btn {
   background: var(--primary);
   color: white;
   border: none;
   padding: 8px;
   border-radius: 50%;
   font-size: 12px;
   cursor: pointer;
   font-weight: 500;
   width: 32px;
   height: 32px;
   display: flex;
   align-items: center;
   justify-content: center;
}

.track-action-btn.secondary { background: var(--secondary); }
.track-action-btn.menu { background: var(--gray); }

/* Popularity Legend */
.popularity-legend {
   font-size: 10px;
   color: rgba(255, 255, 255, 0.4);
   margin-top: 6px;
   margin-bottom: 16px;
   padding: 0 2px;
   text-align: center;
   line-height: 1.2;
}

/* Track Header with Popularity Badge */
.track-header {
   display: flex;
   align-items: center;
   gap: 8px;
   margin-bottom: 2px;
}

.track-header .track-name {
   flex: 1;
   margin-bottom: 0;
}

/* Trend/Popularity Badges */
.trend-badge {
   font-size: 9px;
   font-weight: 600;
   padding: 1px 4px;
   border-radius: 8px;
   display: inline-flex;
   align-items: center;
   gap: 1px;
   flex-shrink: 0;
   background: rgba(255, 255, 255, 0.1);
   color: rgba(255, 255, 255, 0.9);
}

/* Popularity Badge Colors */
.trend-hot {
   background: rgba(255, 61, 0, 0.15);
   color: #ff6b35;
}

.trend-popular {
   background: rgba(255, 215, 0, 0.15);
   color: #ffd700;
}

.trend-gem {
   background: rgba(79, 195, 247, 0.15);
   color: #4fc3f7;
}

/* Bigger Action Buttons */
.track-action-btn.big-btn {
   width: 44px;
   height: 44px;
   padding: 12px;
   font-size: 14px;
}

/* Fix z-index for clickable icons */
.track-action-btn svg {
   pointer-events: none;
   z-index: 1;
}

/* Make menu button more prominent */
.track-action-btn.menu.big-btn {
   background: rgba(255, 255, 255, 0.12);
   border: 1px solid rgba(255, 255, 255, 0.1);
}

.track-action-btn.menu.big-btn:hover {
   background: rgba(255, 255, 255, 0.2);
}

/* Three-Dot Context Menu - IMPROVED UX */
.track-context-menu {
   position: fixed;
   background: linear-gradient(145deg, var(--card), rgba(42, 42, 42, 0.95));
   border: 1px solid rgba(255, 255, 255, 0.15);
   border-radius: 20px;
   padding: 12px 0;
   min-width: 320px;
   box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
   backdrop-filter: blur(25px);
   z-index: 1000;
   opacity: 0;
   transform: translateX(-50%) translateY(20px) scale(0.95);
   transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
   pointer-events: none;
   bottom: 120px;
   left: 50%;
   transform-origin: center bottom;
}

.track-context-menu.show {
   opacity: 1;
   transform: translateX(-50%) translateY(0) scale(1);
   pointer-events: all;
}

.context-menu-item {
   display: flex;
   align-items: center;
   gap: 18px;
   padding: 20px 28px;
   color: var(--light);
   font-size: 16px;
   font-weight: 600;
   cursor: pointer;
   transition: all 0.15s ease;
   border: none;
   background: none;
   width: 100%;
   text-align: left;
   min-height: 64px;
   position: relative;
   -webkit-tap-highlight-color: transparent;
}

/* Desktop hover only - not on touch devices */
@media (hover: hover) and (pointer: fine) {
   .context-menu-item:hover {
      background: rgba(29, 185, 84, 0.25);
      color: var(--primary);
      transform: translateX(4px);
   }
}

/* Mobile touch - immediate response, no hover state */
@media (hover: none) and (pointer: coarse) {
   .context-menu-item {
      transition: background 0.1s ease;
   }
   
   .context-menu-item:active {
      background: rgba(29, 185, 84, 0.25);
      color: var(--primary);
      transform: translateX(2px);
   }
}

.context-menu-item:active {
   background: rgba(29, 185, 84, 0.4);
   transform: translateX(4px) scale(0.95);
   color: white;
}

.context-menu-item:first-child {
   border-radius: 20px 20px 0 0;
}

.context-menu-item:last-child {
   border-radius: 0 0 20px 20px;
}

.context-menu-icon {
   font-size: 20px;
   width: 24px;
   text-align: center;
   flex-shrink: 0;
}

.context-menu-text {
   flex: 1;
   font-size: 16px;
   font-weight: 600;
}

.context-menu-overlay {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   z-index: 999;
   background: rgba(0, 0, 0, 0.3);
   opacity: 0;
   pointer-events: none;
   transition: opacity 0.2s ease;
}

.context-menu-overlay.show {
   opacity: 1;
   pointer-events: all;
}

.load-more-btn {
   width: 100%;
   background: linear-gradient(145deg, var(--gray), rgba(42, 42, 42, 0.8));
   border: 1px solid rgba(255, 255, 255, 0.08);
   color: var(--light);
   padding: 16px;
   border-radius: 12px;
   font-size: 14px;
   cursor: pointer;
   margin-top: 16px;
   transition: all 0.3s ease;
}

.load-more-btn:hover {
   background: linear-gradient(145deg, #444, #333);
   transform: translateY(-2px);
}

.now-playing {
   text-align: center;
   margin-bottom: 20px;
}

.current-track {
   font-size: 18px;
   font-weight: 600;
   margin-bottom: 4px;
}

.current-artist {
   color: var(--light-gray);
   font-size: 15px;
}

/* Smart Loop Assist */
.smart-loop-assist {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin: 16px 0 12px 0;
   padding: 10px 16px;
   background: rgba(255, 255, 255, 0.03);
   border-radius: 10px;
   border: 1px solid rgba(255, 255, 255, 0.08);
   opacity: 0;
   transform: translateY(-10px);
   transition: all 0.3s ease;
}

.smart-loop-assist.visible {
   opacity: 1;
   transform: translateY(0);
}

.smart-assist-toggle {
   display: flex;
   align-items: center;
   gap: 12px;
}

.smart-assist-label {
   font-size: 13px;
   font-weight: 600;
   color: var(--text-secondary);
   letter-spacing: 0.3px;
}

.smart-toggle {
   position: relative;
   width: 44px;
   height: 24px;
}

.smart-toggle .toggle-slider {
   position: relative;
   display: flex;
   align-items: center;
   justify-content: flex-start;
   padding: 2px;
   transition: all 0.3s ease;
}

.smart-toggle input:checked + .toggle-slider {
   justify-content: flex-end;
}

.toggle-icon {
   font-size: 12px;
   color: var(--text-muted);
   transition: all 0.3s ease;
   transform: scale(0.9);
}

.smart-toggle input:checked + .toggle-slider .toggle-icon {
   color: var(--primary);
   transform: scale(1.1);
   text-shadow: 0 0 8px var(--primary);
}

.smart-assist-score {
   font-size: 12px;
   font-weight: 600;
   color: var(--text-muted);
   background: rgba(0, 0, 0, 0.3);
   padding: 4px 8px;
   border-radius: 6px;
   border: 1px solid rgba(255, 255, 255, 0.1);
   min-width: 70px;
   text-align: center;
   transition: all 0.3s ease;
}

.smart-assist-score.scoring {
   color: var(--text-primary);
   background: rgba(0, 0, 0, 0.5);
}

/* Score color coding */
.smart-assist-score.score-low {
   background: rgba(239, 83, 80, 0.2);
   border-color: rgba(239, 83, 80, 0.3);
   color: #ef5350;
}

.smart-assist-score.score-medium {
   background: rgba(255, 202, 40, 0.2);
   border-color: rgba(255, 202, 40, 0.3);
   color: #ffca28;
}

.smart-assist-score.score-high {
   background: rgba(102, 187, 106, 0.2);
   border-color: rgba(102, 187, 106, 0.3);
   color: #66bb6a;
}

.smart-assist-score.score-perfect {
   background: rgba(29, 185, 84, 0.3);
   border-color: rgba(29, 185, 84, 0.5);
   color: var(--primary);
   box-shadow: 0 0 12px rgba(29, 185, 84, 0.3);
   animation: perfectPulse 1.5s ease-in-out infinite;
}

@keyframes perfectPulse {
   0%, 100% { transform: scale(1); }
   50% { transform: scale(1.05); }
}

/* Mini Player Container - Groups progress bar and mini player */
.mini-player {
   position: fixed;
   bottom: 60px; /* Fixed position - never moves */
   left: 0;
   right: 0;
   z-index: 95;
   background: var(--bg-secondary);
}

.mini-player-content {
   height: 50px;
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: var(--space-2) var(--space-4);
   max-width: 600px;
   margin: 0 auto;
   cursor: pointer;
   touch-action: pan-y;
}

.mini-player-cover {
   width: 40px;
   height: 40px;
   border-radius: 4px;
   margin-right: var(--space-3);
   flex-shrink: 0;
   object-fit: cover;
   background: var(--bg-tertiary);
   transition: opacity 0.2s ease;
}

.mini-track-info {
   flex: 1;
   min-width: 0;
   margin-right: var(--space-3);
}

.mini-track-title {
   font-size: 13px;
   font-weight: 600;
   color: var(--text-primary);
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
   margin-bottom: 1px;
   line-height: 1.2;
}

.mini-track-artist {
   font-size: 11px;
   color: var(--text-secondary);
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
   line-height: 1.2;
}

.mini-play-btn {
   background: none;
   border: none;
   color: var(--text-primary);
   padding: var(--space-1);
   border-radius: 50%;
   cursor: pointer;
   transition: all 0.2s ease;
   display: flex;
   align-items: center;
   justify-content: center;
   width: 28px;
   height: 28px;
}

.mini-play-btn:hover {
   background: rgba(255, 255, 255, 0.1);
   transform: scale(1.1);
}

.mini-play-btn:active {
   transform: scale(0.9);
}

.progress-container {
   height: 32px; /* Always use hover height for better precision */
   background: rgba(255, 255, 255, 0.08);
   border-radius: 8px;
   position: relative;
   margin: 24px 0;
   cursor: pointer;
   overflow: visible;
   touch-action: none;
}

.progress-bar {
   height: 100%;
   background: var(--gradient);
   border-radius: 8px;
   width: 0%;
   transition: width 0.1s linear;
   touch-action: none;
}

.loop-region {
   position: absolute;
   top: 0;
   height: 100%;
   background: rgba(29, 185, 84, 0.25);
   border-radius: 4px;
   pointer-events: none;
   border: 2px solid rgba(29, 185, 84, 0.6);
   z-index: 2;
   opacity: 0.7;
   transition: opacity 0.3s ease;
}

.progress-container:hover .loop-handle,
.loop-handle.dragging {
    opacity: 1;
}

/* Show loop region when loop is enabled */
.loop-region.show {
   opacity: 1;
}

.loop-handle {
   position: absolute;
   top: 50%;
   width: 24px;
   height: 24px;
   border-radius: 50%;
   cursor: grab;
   transform: translateY(-50%);
   z-index: 15;
   border: 3px solid white;
   box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
   opacity: 0;
   touch-action: none;
   transition: all 0.2s ease;
   visibility: hidden;
}

/* Show loop handles always when loop is enabled */
.loop-handle.show {
   visibility: visible;
   opacity: 1; /* Always visible */
}

.progress-container:hover .loop-handle.show,
.loop-handle.dragging { opacity: 1; }

.loop-handle.dragging { cursor: grabbing; width: 32px; height: 32px; }

.loop-handle.start {
   background: var(--primary);
   left: 0;
   transform: translateX(-50%) translateY(-50%);
}

.loop-handle.end {
   background: var(--secondary);
   right: 0;
   transform: translateX(-50%) translateY(-50%);
}

/* Subtle precision hint on hover */
.loop-handle::after {
   content: 'slow = precise';
   position: absolute;
   top: -18px;
   left: 50%;
   transform: translateX(-50%);
   background: rgba(0, 0, 0, 0.7);
   color: rgba(255, 255, 255, 0.6);
   padding: 2px 6px;
   border-radius: 3px;
   font-size: 9px;
   font-weight: 400;
   white-space: nowrap;
   opacity: 0;
   pointer-events: none;
   transition: opacity 0.2s ease;
   z-index: 1000;
}

.loop-handle:hover::after {
   opacity: 1;
}

.time-popup {
   position: absolute;
   bottom: 200%;
   left: 50%;
   transform: translateX(-50%);
   background: rgba(0, 0, 0, 0.95);
   color: white;
   padding: 8px 12px;
   border-radius: 8px;
   font-size: 14px;
   font-family: monospace;
   font-weight: 600;
   opacity: 0;
   transition: all 0.2s ease;
   z-index: 100;
   box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
   border: 2px solid var(--primary);
   backdrop-filter: blur(10px);
}

.time-popup.show { 
   opacity: 1; 
}

.time-display {
   display: flex;
   justify-content: space-between;
   font-size: 13px;
   color: var(--light-gray);
   margin-bottom: 16px;
   font-family: monospace;
}

.main-controls {
   display: flex;
   flex-direction: column;
   gap: 12px;
   margin: 16px 0;
}

.playback-controls {
   display: flex;
   justify-content: center;
   align-items: center;
   gap: 16px;
}

.control-btn {
   background: linear-gradient(145deg, var(--gray), rgba(42, 42, 42, 0.8));
   border: 1px solid rgba(255, 255, 255, 0.08);
   color: var(--light);
   width: 56px;
   height: 56px;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 24px;
   cursor: pointer;
   transition: all 0.3s ease;
}

.control-btn:hover { background: linear-gradient(145deg, #444, #333); transform: scale(1.05); }

/* Fix button click/touch issues - prevent SVG icons from capturing clicks */
.control-btn svg,
.delete-x-btn svg,
.track-action-btn svg,
.playlist-action-btn svg,
.loop-action-btn svg,
.btn svg,
.back-btn svg,
.drag-handle svg,
.repeat-btn svg,
.popup-close svg {
   pointer-events: none;
}

/* Improve button touch responsiveness */
.delete-x-btn,
.track-action-btn,
.playlist-action-btn,
.loop-action-btn,
.btn,
.back-btn,
.repeat-btn,
.popup-close {
   touch-action: manipulation;
   cursor: pointer;
}

.play-pause-btn {
   width: 72px;
   height: 72px;
   background: var(--gradient);
   font-size: 32px;
   border: none;
   box-shadow: 0 4px 20px rgba(29, 185, 84, 0.2);
}

#ai-toggle {
   opacity: 0.5;
   transition: opacity 0.3s;
}

#ai-toggle.active {
   opacity: 1;
   color: #9945DB;
}

.loop-controls {
   display: flex;
   flex-direction: column;
   gap: 12px;
   padding: 16px;
   background: rgba(255, 255, 255, 0.02);
   border-radius: 16px;
   border: 1px solid rgba(255, 255, 255, 0.04);
}

.loop-section {
   display: flex;
   justify-content: space-between;
   align-items: center;
}

.toggle-switch {
   position: relative;
   width: 54px;
   height: 28px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
   position: absolute;
   cursor: pointer;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   background-color: #444;
   transition: 0.3s;
   border-radius: 28px;
}

.toggle-slider:before {
   position: absolute;
   content: "";
   height: 20px;
   width: 20px;
   left: 4px;
   bottom: 4px;
   background-color: white;
   transition: 0.3s;
   border-radius: 50%;
}

input:checked + .toggle-slider { background: var(--gradient); }
input:checked + .toggle-slider:before { transform: translateX(26px); }

.loop-actions {
   display: flex;
   gap: 12px;
}

.start-loop-btn { flex: 1; }

.repeat-counter {
   display: flex;
   align-items: center;
   background: var(--gray);
   border-radius: 50px;
   padding: 6px 12px;
   border: 1px solid rgba(255, 255, 255, 0.08);
}

.repeat-btn {
   cursor: pointer;
   padding: 6px 10px;
   border-radius: 50px;
   user-select: none;
   font-weight: 500;
}

.repeat-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--primary); }

.repeat-value {
   padding: 0 12px;
   font-family: monospace;
   color: var(--primary);
   min-width: 32px;
   text-align: center;
   font-weight: 500;
}

.precision-inputs {
   padding: 0 20px;
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 16px;
   margin-bottom: 20px;
}

.precision-field {
   display: flex;
   flex-direction: column;
   gap: 8px;
}

.precision-label {
   font-size: 12px;
   color: var(--light-gray);
   text-transform: uppercase;
   font-weight: 600;
   letter-spacing: 0.5px;
}

.precision-input {
   background: var(--gray);
   border: 1px solid rgba(255, 255, 255, 0.08);
   color: white;
   padding: 12px 16px;
   border-radius: 8px;
   font-size: 14px;
   font-family: monospace;
   min-height: 44px;
   max-width: 140px;
   width: 100%;
}

.precision-input:focus {
   outline: none;
   border-color: var(--primary);
   box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.08);
}

.precision-popup {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   background: rgba(0, 0, 0, 0.7);
   backdrop-filter: blur(20px);
   z-index: 1000;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: var(--space-5);
}

.precision-popup-content {
   background: var(--bg-secondary);
   border: 1px solid var(--border-subtle);
   border-radius: var(--radius-xl);
   padding: var(--space-6);
   max-width: 500px;
   width: 100%;
   max-height: 80vh;
   overflow-y: auto;
   box-shadow: var(--shadow-lg);
}

.precision-popup-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-bottom: var(--space-5);
}

.precision-popup-header h3 {
   color: var(--text-primary);
   font-size: 20px;
   font-weight: 700;
   margin: 0;
}

.popup-close {
   background: none;
   border: none;
   color: var(--text-muted);
   font-size: 24px;
   cursor: pointer;
   padding: var(--space-2);
   border-radius: 50%;
   width: 40px;
   height: 40px;
   display: flex;
   align-items: center;
   justify-content: center;
   transition: all 0.2s ease;
}

.popup-close:hover {
   background: var(--bg-tertiary);
   color: var(--text-primary);
}

/* Duplicate hover rule removed */

.fine-tune-section {
   padding: 0 20px 20px;
}

.fine-tune-controls {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 16px;
   margin-bottom: 16px;
}

.fine-tune-group {
   display: flex;
   flex-direction: column;
   gap: 8px;
}

.fine-tune-title {
   font-size: 12px;
   color: var(--light-gray);
   text-transform: uppercase;
   font-weight: 600;
   letter-spacing: 0.5px;
   margin-bottom: 4px;
}

.fine-tune-row {
   display: flex;
   gap: 4px;
}

.fine-tune-btn {
   background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
   color: white;
   border: 1px solid rgba(255, 255, 255, 0.06);
   padding: 8px 12px;
   border-radius: 6px;
   font-size: 10px;
   cursor: pointer;
   font-family: monospace;
   font-weight: 500;
   min-height: 32px;
   flex: 1;
   user-select: none;
   transition: all 0.3s ease;
   display: flex;
   align-items: center;
   justify-content: center;
}

.fine-tune-btn:hover {
   background: linear-gradient(145deg, var(--primary), #1ed760);
   transform: translateY(-1px);
}

.fine-tune-btn.active {
   background: linear-gradient(145deg, var(--primary), #1ed760);
}

.status-bar {
   position: fixed;
   bottom: 100px;
   left: 50%;
   transform: translateX(-50%);
   background: rgba(0, 0, 0, 0.95);
   backdrop-filter: blur(10px);
   color: white;
   padding: 10px 20px;
   border-radius: 50px;
   font-size: 13px;
   z-index: 200;
   opacity: 0;
   transition: all 0.3s ease;
   max-width: 90%;
   border: 1px solid rgba(255, 255, 255, 0.08);
   font-weight: 500;
}

.status-bar.show { opacity: 1; transform: translateX(-50%) translateY(-5px); }

.mobile-nav {
   position: fixed;
   bottom: 0; /* Fixed at viewport bottom - never moves */
   left: 0;
   right: 0;
   background: var(--bg-secondary);
   padding: var(--space-2) 0 calc(var(--space-2) + 4px);
   z-index: 100;
   height: 60px;
   min-height: 60px;
}

.nav-container {
   display: flex;
   justify-content: space-around;
   align-items: center;
   max-width: 100%;
   margin: 0 auto;
   padding: 0 var(--space-4);
}

.nav-btn {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 2px;
   background: none;
   border: none;
   color: var(--text-muted);
   cursor: pointer;
   padding: var(--space-1);
   border-radius: var(--radius-sm);
   font-size: 11px;
   font-weight: 600;
   min-width: 56px;
   min-height: 44px;
   transition: all 0.2s ease;
   position: relative;
}

.nav-btn:hover { 
   color: var(--text-primary); 
   background: var(--bg-tertiary); 
}

.nav-btn.active { 
   color: var(--primary); 
}

.nav-icon { 
   font-size: 20px; 
}

.nav-label { 
   font-size: 10px; 
   font-weight: 600; 
}

.loop-count-badge {
   background: var(--primary);
   color: white;
   font-size: 8px;
   font-weight: 700;
   padding: 1px 4px;
   border-radius: 8px;
   position: absolute;
   top: 6px;
   right: 10px;
   display: none;
}

.playlist-count-badge {
   background: var(--secondary);
   color: white;
   font-size: 8px;
   font-weight: 700;
   padding: 1px 4px;
   border-radius: 8px;
   position: absolute;
   top: 6px;
   right: 10px;
   display: none;
}

/* Login Screen - New Design */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #0f0f1a 0%, #111118 50%, #080808 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}

/* Animated Background */
.animated-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.gradient-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.6;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
}

.blob-1 {
    width: 450px;
    height: 450px;
    background: 
        radial-gradient(circle at 30% 30%, #8B5CF6 0%, transparent 40%),
        radial-gradient(circle at 70% 70%, rgba(139, 92, 246, 0.8) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.4) 0%, transparent 80%);
    background-blend-mode: screen;
    top: 15%;
    left: 10%;
    animation: float-1 20s infinite;
    opacity: 0.8;
}

.blob-2 {
    width: 350px;
    height: 350px;
    background: 
        radial-gradient(circle at 40% 40%, #FBD44C 0%, transparent 35%),
        radial-gradient(circle at 60% 60%, rgba(251, 212, 76, 0.9) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(251, 212, 76, 0.5) 0%, transparent 75%);
    background-blend-mode: screen;
    bottom: 20%;
    right: 15%;
    animation: float-2 25s infinite;
    opacity: 0.7;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: 
        radial-gradient(circle at 35% 35%, #10B981 0%, transparent 30%),
        radial-gradient(circle at 65% 65%, rgba(16, 185, 129, 0.85) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.6) 0%, transparent 70%);
    background-blend-mode: screen;
    top: 35%;
    right: 25%;
    animation: float-3 30s infinite;
    opacity: 0.6;
}

/* Login Content - Exact Mobile Layout */
.login-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 375px;
    padding: 60px 32px 32px 32px;
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* Branding Section - Exact Spacing */
.login-branding {
    margin-bottom: 48px;
}

.logo-container {
    margin-bottom: 16px;
}

.logo-wordmark {
    height: auto;
    width: 150px;
    max-width: 100%;
    filter: brightness(0) saturate(100%) invert(100%);
}

.brand-tagline {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

/* Hero Text - Exact Typography */
.hero-text {
    margin-bottom: 56px;
}

.hero-title {
    margin: 0;
    line-height: 1.15;
}

.serif-text {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 46px;
    font-weight: 200;
    background: linear-gradient(135deg, #8B5CF6 0%, #FBD44C 50%, #10B981 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
    line-height: 1.06;
}

.sans-text {
    font-family: var(--font-sans);
    font-size: 46px;
    font-weight: 200;
    color: #FFFFFF;
    display: inline-block;
    line-height: 1.06;
}

/* Connect Button - Exact Design */
.connect-section {
    margin-bottom: 48px;
    width: 100%;
}

.connect-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #8B5CF6 0%, #FBD44C 50%, #10B981 100%);
    border: none;
    border-radius: 50px;
    color: #000000;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.connect-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.connect-btn:active,
.connect-btn:focus {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    outline: none;
}

.connect-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: translateY(0);
    box-shadow: none;
}

.connect-subtitle {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    margin: 12px 0 0 0;
}

/* Footer */
.login-footer {
    margin-top: auto;
}

.powered-by {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4);
    margin: 0;
}

/* Animation Keyframes */
@keyframes float-1 {
    0% { transform: translate(0, 0); }
    12.5% { transform: translate(-40px, -30px); }
    25% { transform: translate(-70px, -20px); }
    37.5% { transform: translate(-85px, 20px); }
    50% { transform: translate(-30px, 80px); }
    62.5% { transform: translate(20px, 70px); }
    75% { transform: translate(60px, 0px); }
    87.5% { transform: translate(40px, -40px); }
    95% { transform: translate(20px, -20px); }
    100% { transform: translate(0, 0); }
}

@keyframes float-2 {
    0% { transform: translate(0, 0); }
    12.5% { transform: translate(40px, -35px); }
    25% { transform: translate(75px, -25px); }
    37.5% { transform: translate(90px, 15px); }
    50% { transform: translate(45px, 80px); }
    62.5% { transform: translate(-10px, 75px); }
    75% { transform: translate(-65px, 10px); }
    87.5% { transform: translate(-50px, -30px); }
    95% { transform: translate(-25px, -15px); }
    100% { transform: translate(0, 0); }
}

@keyframes float-3 {
    0% { transform: translate(0, 0); }
    12.5% { transform: translate(-30px, -40px); }
    25% { transform: translate(-20px, -75px); }
    37.5% { transform: translate(25px, -90px); }
    50% { transform: translate(85px, -35px); }
    62.5% { transform: translate(80px, 15px); }
    75% { transform: translate(10px, 70px); }
    87.5% { transform: translate(-35px, 60px); }
    95% { transform: translate(-17px, 30px); }
    100% { transform: translate(0, 0); }
}

/* Legacy float animation for other elements */
@keyframes float {
   0%, 100% { transform: translateY(0px); }
   50% { transform: translateY(-6px); }
}

/* Responsive adjustments for mobile */
@media (max-width: 480px) {
    .serif-text,
    .sans-text {
        font-size: 38px;
    }
    
    .login-content {
        padding: 40px 24px 24px 24px;
    }
    
    .blob-1 {
        width: 300px;
        height: 300px;
    }
    
    .blob-2 {
        width: 250px;
        height: 250px;
    }
    
    .blob-3 {
        width: 200px;
        height: 200px;
    }
}

.saved-loop {
   background: linear-gradient(145deg, rgba(42, 42, 42, 0.5), rgba(26, 26, 26, 0.5));
   border: 1px solid rgba(255, 255, 255, 0.04);
   border-radius: 16px;
   padding: 18px;
   margin-bottom: 12px;
   transition: all 0.3s ease;
   position: relative;
}

.saved-loop:hover { transform: translateY(-2px); border-color: rgba(29, 185, 84, 0.2); }
.saved-loop.playing { border-color: var(--primary); background: linear-gradient(145deg, rgba(29, 185, 84, 0.08), rgba(29, 185, 84, 0.03)); }

.loop-header {
   display: flex;
   align-items: center;
   gap: 14px;
   margin-bottom: 14px;
}

.loop-thumbnail {
   width: 56px;
   height: 56px;
   border-radius: 10px;
   object-fit: cover;
   flex-shrink: 0;
}

.loop-details { flex: 1; }

.loop-track-name {
   font-weight: 500;
   font-size: 15px;
   margin-bottom: 2px;
   color: var(--light);
}

.loop-artist {
   color: var(--light-gray);
   font-size: 13px;
}

.loop-stats {
   display: flex;
   gap: 16px;
   margin-bottom: 14px;
   font-size: 12px;
}

.loop-stat {
   display: flex;
   align-items: center;
   gap: 4px;
   color: var(--light-gray);
}

.loop-stat-icon {
   color: var(--primary);
   font-size: 11px;
}

.loop-actions {
   display: flex;
   gap: 6px;
   flex-wrap: wrap;
}

.loop-action-btn {
   background: var(--gray);
   border: 1px solid rgba(255, 255, 255, 0.08);
   color: white;
   padding: 6px 12px;
   border-radius: 50px;
   font-size: 11px;
   cursor: pointer;
   display: inline-flex;
   align-items: center;
   gap: 4px;
   font-weight: 500;
}

.loop-action-btn:hover { background: rgba(29, 185, 84, 0.15); border-color: var(--primary); }
.loop-action-btn.danger:hover { background: rgba(192, 57, 43, 0.15); border-color: var(--danger); }

/* Delete X button */
.delete-x-btn {
   position: absolute;
   top: 12px;
   right: 12px;
   background: rgba(255, 255, 255, 0.05);
   border: 1px solid rgba(255, 255, 255, 0.1);
   border-radius: 50%;
   width: 28px;
   height: 28px;
   display: flex;
   align-items: center;
   justify-content: center;
   cursor: pointer;
   transition: all 0.2s ease;
   color: var(--text-secondary);
   z-index: 2;
}

.delete-x-btn:hover {
   background: rgba(239, 83, 80, 0.2);
   border-color: var(--danger);
   color: var(--danger);
   transform: scale(1.1);
}

.delete-x-btn svg {
   width: 14px;
   height: 14px;
}

/* Drag handle for playlist items */
.drag-handle {
   position: absolute;
   left: 0px;
   top: 33%;
   cursor: grab;
   color: var(--text-secondary);
   opacity: 0.7;
   transition: opacity 0.2s ease;
   padding: 12px;
   z-index: 10;
   background: var(--bg-elevated);
   border-radius: 0px 8px 8px 0px;
   touch-action: manipulation;
   user-select: none;
   min-width: 32px;
   min-height: 32px;
   display: flex;
   align-items: center;
   justify-content: center;
}

.drag-handle:hover,
.drag-handle:active {
   opacity: 1;
   background: var(--bg-secondary);
   cursor: grabbing;
}

@media (hover: none) {
   .drag-handle {
       opacity: 0.9;
       padding: 16px;
   }
}

/* Ensure the main container maintains proper flex layout */
.saved-loop.playlist-item {
   display: flex;
   flex-direction: column;
   align-items: flex-start;
   padding-left: 50px;
   position: relative;
   box-sizing: border-box;
   transition: transform 0.2s ease, box-shadow 0.2s ease;
   user-select: none;
   cursor: grab;
}

.saved-loop.playlist-item:active {
   cursor: grabbing;
}

/* Dragging state */
.saved-loop.playlist-item.dragging {
   opacity: 0.7;
   cursor: grabbing;
   z-index: 1000;
   transform: rotate(3deg) scale(1.05);
   box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
   transition: none;
   background: rgba(255, 255, 255, 0.05);
   border: 2px solid var(--primary);
}

/* Touch dragging state */
.saved-loop.playlist-item.touch-dragging {
   opacity: 0.8;
   z-index: 1000;
   transform: scale(1.05) rotate(2deg);
   box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
   transition: transform 0.1s ease;
   background: rgba(255, 255, 255, 0.05);
   border: 2px solid var(--primary);
}

/* SortableJS dragging states */
.sortable-ghost {
   opacity: 0.3;
   background: rgba(168, 85, 247, 0.15);
   border: 2px dashed var(--primary);
   transform: scale(0.9);
   filter: blur(1px);
}

.sortable-chosen {
   z-index: 90;
   transform: scale(1.05) rotate(2deg) translateY(-4px);
   box-shadow: 
      0 20px 50px rgba(0, 0, 0, 0.8),
      0 8px 25px rgba(168, 85, 247, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
   background: linear-gradient(135deg, 
      rgba(255, 255, 255, 0.15) 0%, 
      rgba(168, 85, 247, 0.1) 100%);
   border: 3px solid var(--primary);
   opacity: 0.95;
   transition: none;
   backdrop-filter: blur(10px);
}

.sortable-drag {
   opacity: 0.95;
   z-index: 95;
   transform: scale(1.05) rotate(3deg) translateY(-6px);
   box-shadow: 
      0 25px 60px rgba(0, 0, 0, 0.9),
      0 12px 30px rgba(168, 85, 247, 0.6),
      0 0 20px rgba(168, 85, 247, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
   background: linear-gradient(135deg, 
      rgba(255, 255, 255, 0.2) 0%, 
      rgba(168, 85, 247, 0.15) 50%,
      rgba(251, 212, 76, 0.1) 100%);
   border: 3px solid var(--primary);
   transition: none;
   backdrop-filter: blur(15px);
   cursor: grabbing;
}

/* Auto-scroll zones for long playlists */
.playlist-edit-view::before,
.playlist-edit-view::after {
   content: '';
   position: absolute;
   left: 0;
   right: 0;
   height: 120px;
   pointer-events: none;
   z-index: 10;
   opacity: 0;
   transition: opacity 0.3s ease;
}

.playlist-edit-view::before {
   top: 0;
   background: linear-gradient(to bottom, 
      rgba(168, 85, 247, 0.1) 0%,
      rgba(168, 85, 247, 0.05) 50%,
      transparent 100%);
}

.playlist-edit-view::after {
   bottom: 0;
   background: linear-gradient(to top, 
      rgba(168, 85, 247, 0.1) 0%,
      rgba(168, 85, 247, 0.05) 50%,
      transparent 100%);
}

/* Show scroll zones during drag */
.playlist-edit-view.sortable-active::before,
.playlist-edit-view.sortable-active::after {
   opacity: 1;
}

/* Three-dot menu styles */
.saved-loop {
   position: relative;
}

.loop-menu {
   position: absolute;
   top: 8px;
   right: 8px;
   z-index: 10;
}

.three-dot-btn {
   background: rgba(0, 0, 0, 0.3);
   backdrop-filter: blur(10px);
   border: none;
   color: var(--text-primary);
   cursor: pointer;
   padding: 6px;
   border-radius: 50%;
   width: 32px;
   height: 32px;
   display: flex;
   align-items: center;
   justify-content: center;
   transition: all 0.2s;
}

.three-dot-btn:hover {
   background: rgba(0, 0, 0, 0.5);
   transform: scale(1.1);
}

.three-dot-btn svg {
   width: 16px;
   height: 16px;
}

/* Slide-up modal backdrop */
.modal-backdrop {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   background: rgba(0, 0, 0, 0.6);
   backdrop-filter: blur(4px);
   z-index: 200;
   opacity: 0;
   pointer-events: none;
   transition: opacity 0.3s ease;
}

.modal-backdrop.active {
   opacity: 1;
   pointer-events: auto;
}

/* Slide-up action sheet */
.action-sheet {
   position: fixed;
   bottom: 0;
   left: 0;
   right: 0;
   background: var(--bg-secondary);
   border-radius: 20px 20px 0 0;
   padding: 8px;
   padding-bottom: calc(8px + env(safe-area-inset-bottom));
   max-height: 70vh;
   z-index: 201;
   transform: translateY(100%);
   transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-sheet.active {
   transform: translateY(0);
}

/* Handle bar */
.action-sheet::before {
   content: '';
   position: absolute;
   top: 8px;
   left: 50%;
   transform: translateX(-50%);
   width: 36px;
   height: 4px;
   background: var(--text-muted);
   border-radius: 2px;
   opacity: 0.5;
}

.action-sheet-header {
   padding: 20px 16px 12px;
   text-align: center;
}

.action-sheet-title {
   font-size: 14px;
   color: var(--text-muted);
   margin: 0;
}

.action-sheet-subtitle {
   font-size: 16px;
   color: var(--text-primary);
   margin: 4px 0 0;
   font-weight: 500;
}

.action-sheet-options {
   padding: 8px;
}

.action-sheet button {
   display: flex;
   align-items: center;
   gap: 16px;
   width: 100%;
   padding: 16px;
   background: transparent;
   border: none;
   color: var(--text-primary);
   font-size: 16px;
   text-align: left;
   cursor: pointer;
   border-radius: 12px;
   transition: background 0.2s;
}

.action-sheet button:hover {
   background: var(--bg-tertiary);
}

.action-sheet button svg {
   width: 20px;
   height: 20px;
   flex-shrink: 0;
}

.action-sheet button.danger {
   color: var(--danger);
}

.action-sheet button.danger:hover {
   background: rgba(239, 83, 80, 0.1);
}

/* Divider */
.action-sheet-divider {
   height: 1px;
   background: var(--border-subtle);
   margin: 8px 0;
}

/* Prebuffered playlist indicator */
.playlist-card.prebuffered::before {
   content: '⚡';
   position: absolute;
   top: 12px;
   right: 12px;
   background: var(--primary);
   color: var(--bg-primary);
   width: 24px;
   height: 24px;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 12px;
   font-weight: bold;
   box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Drag placeholder */
.drag-placeholder {
   transition: all 0.2s ease;
}


/* Playlist edit view layout */
.playlist-edit-view {
   display: flex;
   flex-direction: column;
   height: 100%;
   min-height: 0;
   flex: 1;
   overflow-y: auto;
   overflow-x: hidden;
   padding: 12px;
   background: rgba(0, 0, 0, 0.2);
   border-radius: 12px;
   border: 1px solid rgba(255, 255, 255, 0.05);
   max-height: calc(100vh - 200px);
   min-height: 300px;
   scroll-behavior: smooth;
   touch-action: pan-y;
   position: relative;
}

/* Scrollbar styles for playlist edit view */
.playlist-edit-view::-webkit-scrollbar {
   width: 6px;
}

.playlist-edit-view::-webkit-scrollbar-track {
   background: rgba(255, 255, 255, 0.05);
   border-radius: 3px;
}

.playlist-edit-view::-webkit-scrollbar-thumb {
   background: rgba(255, 255, 255, 0.2);
   border-radius: 3px;
}

.playlist-edit-view::-webkit-scrollbar-thumb:hover {
   background: rgba(255, 255, 255, 0.3);
}

.playlist-edit-header {
   flex-shrink: 0;
   margin-bottom: 8px;
}


/* ====== PREBUFFERING LOADING SCREEN ====== */
.prebuffer-loading-screen {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   background: rgba(0, 0, 0, 0.95);
   backdrop-filter: blur(20px);
   z-index: 2000;
   display: flex;
   align-items: center;
   justify-content: center;
   animation: fadeIn 0.3s ease;
}

.prebuffer-content {
   max-width: 500px;
   width: 90%;
   text-align: center;
   padding: 40px 30px;
   background: var(--bg-secondary);
   border-radius: 20px;
   border: 1px solid rgba(255, 255, 255, 0.1);
   box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.prebuffer-header h2 {
   font-size: 28px;
   margin-bottom: 8px;
   background: var(--gradient);
   -webkit-background-clip: text;
   -webkit-text-fill-color: transparent;
}

.prebuffer-header p {
   color: var(--text-secondary);
   font-size: 16px;
   margin-bottom: 30px;
}

.prebuffer-progress {
   margin: 30px 0;
   display: flex;
   justify-content: center;
}

.progress-circle {
   position: relative;
   display: inline-block;
}

.progress-circle svg {
   transform: rotate(-90deg);
   animation: pulse 2s ease-in-out infinite;
}

.progress-text {
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   font-size: 18px;
   font-weight: 700;
   color: var(--primary);
}

.prebuffer-status {
   margin: 25px 0;
}

.current-track {
   font-size: 16px;
   color: var(--text-primary);
   margin-bottom: 8px;
   font-weight: 600;
   min-height: 24px;
}

.prebuffer-stats {
   font-size: 14px;
   color: var(--text-secondary);
   margin-bottom: 5px;
}

.time-estimate {
   font-size: 13px;
   color: var(--text-muted);
   font-style: italic;
}

.prebuffer-actions {
   display: flex;
   gap: 12px;
   justify-content: center;
   margin: 25px 0;
}

.prebuffer-actions .btn {
   padding: 10px 20px;
   font-size: 14px;
}

.prebuffer-info {
   margin-top: 25px;
   padding: 20px;
   background: rgba(255, 255, 255, 0.03);
   border-radius: 12px;
   border: 1px solid rgba(255, 255, 255, 0.05);
}

.prebuffer-info p {
   font-size: 13px;
   color: var(--text-secondary);
   margin: 6px 0;
   text-align: left;
}

.prebuffer-info p:first-child {
   font-weight: 600;
   color: var(--text-primary);
   text-align: center;
   margin-bottom: 12px;
}

@keyframes pulse {
   0%, 100% { transform: rotate(-90deg) scale(1); }
   50% { transform: rotate(-90deg) scale(1.05); }
}

@keyframes fadeIn {
   from { opacity: 0; }
   to { opacity: 1; }
}

/* Progress ring animation */
#progress-ring {
   transition: stroke-dashoffset 0.3s ease;
}

/* Mobile responsive */
@media (max-width: 600px) {
   .prebuffer-content {
       width: 95%;
       padding: 30px 20px;
   }
   
   .prebuffer-header h2 {
       font-size: 24px;
   }
   
   .prebuffer-actions {
       flex-direction: column;
   }
   
   .prebuffer-actions .btn {
       width: 100%;
   }
}

.saved-loop.playlist-item .loop-stats {
   display: flex;
   gap: 16px;
   margin-bottom: 14px;
   font-size: 12px;
   flex-wrap: wrap;
   width: 100%;
   box-sizing: border-box;
}

.saved-loop.playlist-item .loop-actions {
   display: flex;
   gap: 6px;
   flex-wrap: wrap;
   width: 100%;
   box-sizing: border-box;
}


/* Editable playlist name */
.playlist-name[contenteditable="true"] {
   background: rgba(255, 255, 255, 0.05);
   padding: 2px 8px;
   border-radius: 4px;
   outline: none;
   border: 1px solid var(--primary);
}

/* Custom loop names */
.loop-custom-name {
   font-size: 13px;
   font-weight: 600;
   color: var(--primary);
   margin-bottom: 2px;
}

/* Playlist edit view */
.playlist-edit-view {
   width: 100%;
}

.playlist-edit-header {
   display: flex;
   align-items: center;
   gap: 16px;
   margin-bottom: 24px;
   padding: 16px 0;
   border-bottom: 1px solid var(--border-subtle);
}

.playlist-edit-info h2 {
   margin: 0;
   font-size: 24px;
   color: var(--text-primary);
}

.playlist-edit-info p {
   margin: 0;
   color: var(--text-secondary);
   font-size: 14px;
}

.loop-edit-form {
   display: none;
   background: rgba(0, 0, 0, 0.3);
   padding: 16px;
   border-radius: 12px;
   margin-top: 16px;
   border: 1px solid rgba(255, 255, 255, 0.1);
}

.loop-edit-form.active { display: block; }

.edit-grid {
   display: grid;
   grid-template-columns: 1fr;
   gap: 16px;
   margin-bottom: 16px;
}

.edit-field {
   display: flex;
   flex-direction: column;
   gap: 8px;
}

.edit-label {
   font-size: 12px;
   color: var(--light-gray);
   text-transform: uppercase;
   font-weight: 600;
   letter-spacing: 0.5px;
}

.edit-input {
   background: var(--gray);
   border: 1px solid rgba(255, 255, 255, 0.1);
   color: white;
   padding: 8px 12px;
   border-radius: 8px;
   font-size: 14px;
   font-family: monospace;
}

.edit-input:focus {
   outline: none;
   border-color: var(--primary);
   box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);
}

.edit-actions {
   display: flex;
   gap: 8px;
}

.edit-actions .btn {
   flex: 1;
   padding: 8px 16px;
   font-size: 12px;
}

/* Playlist Track List Header */
.playlist-tracklist-header {
   display: flex;
   align-items: center;
   gap: var(--space-3);
   padding: var(--space-4) var(--space-4) var(--space-3);
   border-bottom: 1px solid var(--border-subtle);
   margin-bottom: var(--space-3);
}

.playlist-tracklist-header .back-btn {
   background: none;
   border: none;
   color: var(--text-secondary);
   padding: var(--space-2);
   border-radius: var(--radius-sm);
   cursor: pointer;
   transition: all 0.2s ease;
   display: flex;
   align-items: center;
   justify-content: center;
}

.playlist-tracklist-header .back-btn:hover {
   background: var(--bg-tertiary);
   color: var(--text-primary);
}

.playlist-tracklist-info h3 {
   margin: 0 0 var(--space-1) 0;
   color: var(--text-primary);
   font-size: 18px;
   font-weight: 700;
}

.playlist-tracklist-info p {
   margin: 0;
   color: var(--text-secondary);
   font-size: 13px;
}

/* Playlist Track States */
.playlist-track.now-playing {
   background: rgba(123, 104, 238, 0.1);
   border-color: var(--primary);
}

.playlist-track.now-playing .track-name {
   color: var(--primary);
   font-weight: 600;
}

.playlist-track.played {
   opacity: 0.6;
}

.playlist-track.played .track-name {
   color: var(--text-muted);
}

.now-playing-indicator {
   font-size: 12px;
   color: var(--primary);
   animation: pulse 2s infinite;
}

@keyframes pulse {
   0%, 100% { opacity: 1; }
   50% { opacity: 0.5; }
}

/* Currently Playing Playlist Indicator */
.playlist-playing-indicator {
   background: var(--primary);
   color: white;
   font-size: 11px;
   font-weight: 600;
   padding: var(--space-1) var(--space-2);
   border-radius: var(--radius-sm);
   margin-bottom: var(--space-2);
   display: inline-block;
   animation: pulse 2s infinite;
}

.playlist-card.currently-playing {
   border-color: var(--primary);
   background: linear-gradient(145deg, rgba(123, 104, 238, 0.15), rgba(26, 26, 26, 0.7));
   box-shadow: 0 0 0 1px rgba(123, 104, 238, 0.3);
}

.playlist-card.currently-playing .playlist-name {
   color: var(--primary);
   font-weight: 600;
}

/* Playlist Styles */
.playlist-card {
   background: linear-gradient(145deg, rgba(153, 69, 219, 0.1), rgba(26, 26, 26, 0.5));
   border: 1px solid rgba(153, 69, 219, 0.2);
   border-radius: 16px;
   padding: 18px;
   margin-bottom: 12px;
   transition: all 0.3s ease;
   cursor: pointer;
   position: relative;
}

.playlist-card:hover {
   transform: translateY(-2px);
   border-color: var(--secondary);
   background: linear-gradient(145deg, rgba(153, 69, 219, 0.15), rgba(26, 26, 26, 0.6));
}

.playlist-card.playing {
   border-color: var(--secondary);
   background: linear-gradient(145deg, rgba(153, 69, 219, 0.2), rgba(153, 69, 219, 0.05));
}

.playlist-header {
   display: flex;
   align-items: center;
   gap: 14px;
   margin-bottom: 14px;
}

.playlist-icon {
   width: 56px;
   height: 56px;
   border-radius: 10px;
   background: var(--gradient);
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 0px;
   flex-shrink: 0;
   overflow: visible;
   position: relative;
}

.playlist-cover {
   width: 100%;
   height: 100%;
   object-fit: cover;
   position: absolute;
   top: 0;
   left: 0;
}

/* Stack effect for collections */
.playlist-stack {
   position: relative;
}

.playlist-stack-bg,
.playlist-stack-mid {
   position: absolute;
   width: 100%;
   height: 100%;
   background: #333;
   border-radius: 10px;
   border: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-stack-bg {
   top: 4px;
   left: 4px;
   z-index: 1;
   opacity: 0.6;
   transform: rotate(-2deg);
}

.playlist-stack-mid {
   top: 2px;
   left: 2px;
   z-index: 2;
   opacity: 0.8;
   transform: rotate(-1deg);
}

.playlist-cover-top {
   z-index: 3;
   position: relative;
   border-radius: 10px;
   box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Ensure SVG icon is centered when no cover */
.playlist-stack svg {
   position: relative;
   z-index: 3;
   font-size: 20px;
   width: 20px;
   height: 20px;
}

/* Hover effect for stack */
.playlist-card:hover .playlist-stack-bg {
   transform: rotate(-2.5deg) translate(5px, 5px);
   opacity: 0.7;
}

.playlist-card:hover .playlist-stack-mid {
   transform: rotate(-1.5deg) translate(3px, 3px);
   opacity: 0.85;
}

.playlist-card:hover .playlist-cover-top {
   transform: translateY(-1px);
   box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.playlist-details { flex: 1; }

.playlist-name {
   font-weight: 500;
   font-size: 15px;
   margin-bottom: 2px;
   color: var(--light);
}

.playlist-description {
   color: var(--light-gray);
   font-size: 13px;
}

.playlist-stats {
   display: flex;
   gap: 16px;
   margin-bottom: 14px;
   font-size: 12px;
}

.playlist-stat {
   display: flex;
   align-items: center;
   gap: 4px;
   color: var(--light-gray);
}

.playlist-stat-icon {
   color: var(--secondary);
   font-size: 11px;
}

.playlist-actions {
   display: flex;
   gap: 6px;
   flex-wrap: wrap;
}

.playlist-action-btn {
   background: var(--gray);
   border: 1px solid rgba(255, 255, 255, 0.08);
   color: white;
   padding: 6px 12px;
   border-radius: 50px;
   font-size: 11px;
   cursor: pointer;
   display: inline-flex;
   align-items: center;
   gap: 4px;
   font-weight: 500;
}

.playlist-action-btn:hover {
   background: rgba(153, 69, 219, 0.15);
   border-color: var(--secondary);
}

.playlist-action-btn.danger:hover {
   background: rgba(192, 57, 43, 0.15);
   border-color: var(--danger);
}

/* Playlist Editor */
.playlist-editor {
   display: none;
   background: rgba(0, 0, 0, 0.3);
   padding: 16px;
   border-radius: 12px;
   margin-top: 16px;
   border: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-editor.active { display: block; }

.playlist-items {
   display: flex;
   flex-direction: column;
   gap: 8px;
   margin-bottom: 16px;
   max-height: 300px;
   overflow-y: auto;
}

.playlist-item {
   display: flex;
   align-items: center;
   gap: 12px;
   padding: 12px;
   background: var(--gray);
   border-radius: 8px;
   border: 1px solid rgba(255, 255, 255, 0.05);
}

.playlist-item.dragging {
   opacity: 0.5;
}

.playlist-item-handle {
   cursor: grab;
   color: var(--light-gray);
   font-size: 16px;
}

.playlist-item-handle:active {
   cursor: grabbing;
}

.playlist-item-info {
   flex: 1;
   min-width: 0;
}

.playlist-item-name {
   font-size: 13px;
   font-weight: 500;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.playlist-item-type {
   font-size: 11px;
   color: var(--light-gray);
}

.playlist-item-repeat {
   background: var(--primary);
   color: white;
   padding: 2px 8px;
   border-radius: 12px;
   font-size: 10px;
   font-weight: 600;
}

.playlist-item-remove {
   background: none;
   border: none;
   color: var(--danger);
   cursor: pointer;
   font-size: 16px;
   padding: 4px;
}

/* Create Playlist Form */
.create-playlist-form {
   display: flex;
   flex-direction: column;
   gap: 16px;
}

.form-field {
   display: flex;
   flex-direction: column;
   gap: 8px;
}

.form-label {
   font-size: 12px;
   color: var(--light-gray);
   text-transform: uppercase;
   font-weight: 600;
   letter-spacing: 0.5px;
}

.form-input {
   background: var(--gray);
   border: 1px solid rgba(255, 255, 255, 0.1);
   color: white;
   padding: 12px 16px;
   border-radius: 8px;
   font-size: 14px;
}

.form-input:focus {
   outline: none;
   border-color: var(--primary);
   box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);
}

.form-textarea {
   background: var(--gray);
   border: 1px solid rgba(255, 255, 255, 0.1);
   color: white;
   padding: 12px 16px;
   border-radius: 8px;
   font-size: 14px;
   min-height: 80px;
   resize: vertical;
}

.form-textarea:focus {
   outline: none;
   border-color: var(--primary);
   box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);
}

/* Add to Playlist Popup */
.add-to-playlist-popup {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   background: rgba(10, 10, 10, 0.9);
   backdrop-filter: blur(10px);
   z-index: 1000;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 20px;
}

.add-to-playlist-content {
   background: linear-gradient(145deg, var(--medium), rgba(42, 42, 42, 0.95));
   border: 1px solid rgba(255, 255, 255, 0.1);
   border-radius: 20px;
   padding: 24px;
   max-width: 400px;
   width: 100%;
   max-height: 70vh;
   display: flex;
   flex-direction: column;
   box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.add-to-playlist-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-bottom: 20px;
}

.add-to-playlist-header h3 {
   color: var(--light);
   font-size: 18px;
   font-weight: 600;
   margin: 0;
}

.playlist-selection-list {
   flex: 1;
   overflow-y: auto;
   margin-bottom: 16px;
}

.playlist-selection-item {
   display: flex;
   align-items: center;
   gap: 12px;
   padding: 12px;
   background: var(--gray);
   border-radius: 8px;
   margin-bottom: 8px;
   cursor: pointer;
   transition: all 0.2s ease;
   border: 1px solid transparent;
}

.playlist-selection-item:hover {
   background: rgba(153, 69, 219, 0.1);
   border-color: var(--secondary);
}

.playlist-selection-icon {
   width: 40px;
   height: 40px;
   border-radius: 6px;
   background: linear-gradient(135deg, var(--secondary), #7a3db8);
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 18px;
}

.playlist-selection-info {
   flex: 1;
}

.playlist-selection-name {
   font-size: 14px;
   font-weight: 500;
   margin-bottom: 2px;
}

.playlist-selection-count {
   font-size: 12px;
   color: var(--light-gray);
}

.create-new-playlist-btn {
   width: 100%;
   background: linear-gradient(145deg, var(--secondary), #7a3db8);
   color: white;
   border: none;
   padding: 12px;
   border-radius: 8px;
   font-size: 14px;
   font-weight: 500;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   gap: 8px;
   margin-bottom: 8px;
}

.create-new-playlist-btn:hover {
   background: linear-gradient(145deg, #a855f7, var(--secondary));
}

/* Playlist Now Playing */
.playlist-now-playing {
   background: linear-gradient(145deg, rgba(153, 69, 219, 0.1), rgba(0, 0, 0, 0.3));
   border: 1px solid rgba(153, 69, 219, 0.2);
   border-radius: 12px;
   padding: 16px;
   margin-bottom: 20px;
}

.playlist-now-playing-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-bottom: 12px;
}

.playlist-now-playing-title {
   font-size: 14px;
   font-weight: 600;
   color: var(--secondary);
}

.playlist-progress {
   font-size: 12px;
   color: var(--light-gray);
   font-family: monospace;
}

.playlist-current-item {
   display: flex;
   align-items: center;
   gap: 12px;
}

.playlist-current-item-icon {
   width: 40px;
   height: 40px;
   border-radius: 6px;
   object-fit: cover;
   flex-shrink: 0;
}

.playlist-current-item-info {
   flex: 1;
}

.playlist-current-item-name {
   font-size: 14px;
   font-weight: 500;
   margin-bottom: 2px;
}

.playlist-current-item-type {
   font-size: 12px;
   color: var(--light-gray);
}

.playlist-playback-controls {
   display: flex;
   gap: 8px;
}

.playlist-control-btn {
   background: var(--gray);
   border: 1px solid rgba(255, 255, 255, 0.08);
   color: white;
   padding: 8px;
   border-radius: 50%;
   font-size: 14px;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   width: 32px;
   height: 32px;
}

.playlist-control-btn:hover {
   background: rgba(153, 69, 219, 0.2);
   border-color: var(--secondary);
}

.loading {
   display: inline-block;
   width: 18px;
   height: 18px;
   border: 2px solid rgba(255, 255, 255, 0.3);
   border-top: 2px solid var(--primary);
   border-radius: 50%;
   animation: spin 1s linear infinite;
}

.hidden { display: none !important; }

/* Mobile Responsive */
@media (max-width: 480px) {
   .main-container {
       padding: 80px var(--space-3) calc(110px + env(safe-area-inset-bottom));
   }

   .search-container {
       /*padding: var(--space-4) var(--space-3);*/
   }

   .search-input {
       padding: var(--space-3) var(--space-4);
       font-size: 16px; /* Prevent zoom on iOS */
   }

   .fine-tune-section {
       padding: 0 var(--space-4) var(--space-5);
   }

   .precision-popup-content {
       background: var(--bg-secondary);
       padding: var(--space-5);
       margin-top: 165px;
   }

   .track-item {
       padding: var(--space-3);
       gap: var(--space-2);
   }

   .track-cover {
       width: 48px;
       height: 48px;
   }
}

@keyframes pulse {
   0%, 100% { opacity: 1; transform: scale(1); }
   50% { opacity: 0.6; transform: scale(0.9); }
}

@keyframes spin {
   0% { transform: rotate(0deg); }
   100% { transform: rotate(360deg); }
}

@keyframes float {
   0%, 100% { transform: translateY(0px); }
   50% { transform: translateY(-6px); }
}

/* ===============================================
   PRECISION ZOOM UI - Clean No AI Implementation
   =============================================== */

.precision-zoom-overlay {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 20px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    pointer-events: none; /* Don't interfere with dragging */
    min-width: 400px;
    z-index: 1000;
}

.precision-zoom-overlay.active {
    opacity: 1;
    transform: translateY(0);
}

.precision-zoom-overlay::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--primary);
}

/* Header */
.precision-zoom-header {
    text-align: center;
    margin-bottom: 16px;
}

.precision-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.precision-range {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

/* Main zoom bar */
.precision-zoom-bar {
    margin-bottom: 12px;
}

.precision-background {
    position: relative;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: visible;
}

.precision-progress {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--gradient);
    border-radius: 12px;
    transition: all 0.1s ease;
    min-width: 2px;
    opacity: 0.8;
}

.precision-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.precision-marker {
    position: absolute;
    top: -6px;
    bottom: -6px;
    width: 1px;
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-50%);
}

.precision-marker.major {
    width: 2px;
    background: rgba(255, 255, 255, 0.6);
    top: -10px;
    bottom: -10px;
}

.precision-marker.major span {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--text-secondary);
    font-family: monospace;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Current handle indicator */
.precision-current-handle {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid white;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.1s ease;
}

.precision-current-handle.start {
    background: var(--primary);
    animation: precision-pulse-start 1.5s ease-in-out infinite;
}

.precision-current-handle.end {
    background: var(--secondary);
    animation: precision-pulse-end 1.5s ease-in-out infinite;
}

@keyframes precision-pulse-start {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(29, 185, 84, 0.7);
    }
    50% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 6px rgba(29, 185, 84, 0);
    }
}

@keyframes precision-pulse-end {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(153, 69, 219, 0.7);
    }
    50% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 6px rgba(153, 69, 219, 0);
    }
}

/* Time labels */
.precision-time-labels {
    display: flex;
    justify-content: space-between;
    font-family: monospace;
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.precision-start-label,
.precision-end-label {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hint text */
.precision-hint {
    text-align: center;
    font-size: 11px;
    color: var(--primary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(29, 185, 84, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(29, 185, 84, 0.3);
    animation: hint-glow 2s ease-in-out infinite;
}

@keyframes hint-glow {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.85;
        transform: scale(1.02);
    }
}

/* Enhanced loop handles during precision mode */
.loop-handle.dragging {
    width: 32px;
    height: 32px;
    z-index: 1001; /* Above precision overlay */
    animation: precision-drag-pulse 1.2s ease-in-out infinite;
}

/* Prevent iOS text selection and magnifier on loop handles */
.loop-handle {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x pan-y;
}

@keyframes precision-drag-pulse {
    0%, 100% {
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
        transform: translateX(-50%) translateY(-50%) scale(1);
    }
    50% {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
        transform: translateX(-50%) translateY(-50%) scale(1.05);
    }
}

/* Enhanced time popup during precision dragging */
.loop-handle.dragging .time-popup {
    transform: translateX(-50%) scale(1.1);
    color: var(--primary);
}

/* Progress container enhancements during precision mode */
.progress-container.precision-active {
    z-index: 999;
    box-shadow: 0 0 20px rgba(29, 185, 84, 0.3);
    border: 1px solid rgba(29, 185, 84, 0.5);
    background: rgba(29, 185, 84, 0.05);
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .precision-zoom-overlay {
        padding: 16px;
        border-radius: 12px;
        min-width: 300px;
        left: 10px !important;
        right: 10px !important;
        width: calc(100vw - 20px) !important;
    }
    
    .precision-background {
        height: 20px;
    }
    
    .precision-current-handle {
        width: 16px;
        height: 16px;
    }
    
    .precision-time-labels {
        font-size: 9px;
    }
    
    .precision-hint {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    .precision-marker.major span {
        font-size: 8px;
        top: -20px;
    }
    
    .precision-title {
        font-size: 14px;
    }
    
    .precision-range {
        font-size: 11px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .precision-zoom-overlay {
        transition: opacity 0.2s ease;
    }
    
    .precision-current-handle.start,
    .precision-current-handle.end {
        animation: none;
    }
    
    .precision-hint {
        animation: none;
    }
    
    .loop-handle.dragging {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .precision-zoom-overlay {
        border: 3px solid var(--primary);
        background: rgba(0, 0, 0, 0.98);
    }
    
    .precision-background {
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.5);
    }
    
    .precision-marker {
        background: rgba(255, 255, 255, 0.8);
    }
    
    .precision-marker.major {
        background: white;
    }
    
    .precision-current-handle {
        border: 3px solid white;
    }
}

/* Smooth entry/exit animations */
@keyframes precisionSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes precisionSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

.precision-zoom-overlay.active {
    animation: precisionSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.precision-zoom-overlay.removing {
    animation: precisionSlideOut 0.3s ease-out;
}

/* ===============================================
   VISUAL PROGRESS BAR
   =============================================== */

.visual-progress-container {
    position: relative;
    margin: 0 10px 4px 10px; /* 10px horizontal, 4px bottom margin */
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.visual-progress-container.show {
    opacity: 1;
}

.visual-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.1s ease-out;
    border-radius: 0 2px 2px 0;
}

/* Hide on larger screens where main player is visible */
@media (min-width: 768px) {
    .visual-progress-container {
       /* display: ;*/
    }
}
