/* ==========================================================================
   Design System & Premium Aesthetics (Hearmetic.com)
   ========================================================================== */

   :root {
    --bg-primary: #09090b;
    --panel-bg: rgba(20, 20, 23, 0.65);
    --panel-border: rgba(63, 63, 70, 0.4);
    --accent: #8b5cf6;
    --accent-hover: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.35);
    --danger: #ef4444;
    --danger-hover: #f87171;
    --danger-glow: rgba(239, 68, 68, 0.25);
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }
  
  /* Legibility and Accessibility Contrast Overrides */
  .text-\[9px\] {
    font-size: 10px !important;
  }
  .text-\[10px\] {
    font-size: 11px !important;
    letter-spacing: 0.04em !important;
  }
  .text-zinc-500 {
    color: #a1a1aa !important; /* Upgraded to zinc-400 equivalent for WCAG AA readability */
  }

  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  body, html {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow-x: hidden;
    
    /* 2.3 Interface Hardening: Defensive rules to block standard scraper tools */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
  }
  
  /* Reset interaction exceptions for inputs and controls */
  input, textarea, button, select, [contenteditable="true"] {
    -webkit-user-select: auto !important;
    -moz-user-select: auto !important;
    -ms-user-select: auto !important;
    user-select: auto !important;
  }
  
  /* Ambient Background Orb */
  .ambient-glow {
    position: fixed;
    top: -150px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.12) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    pointer-events: none;
    transition: background 1s ease;
  }
  
  .ambient-glow.playing {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.18) 0%, rgba(0, 0, 0, 0) 70%);
  }
  
  .ambient-glow.danger {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.18) 0%, rgba(0, 0, 0, 0) 70%);
  }
  
  /* Logo Orb */
  .logo-orb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, #d8b4fe 100%);
    box-shadow: 0 0 10px var(--accent-glow);
  }
  
  /* Glassmorphic Panel Card */
  .glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .glass-panel:hover {
    border-color: rgba(139, 92, 246, 0.3);
  }
  
  /* Forms */
  .form-input {
    width: 100%;
    background: rgba(9, 9, 11, 0.8);
    border: 1px solid rgba(63, 63, 70, 0.5);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-family: var(--font-sans);
    outline: none;
    transition: all 0.2s ease;
  }
  
  .form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }
  
  .form-checkbox {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid rgba(63, 63, 70, 0.8);
    border-radius: 4px;
    background: rgba(9, 9, 11, 0.8);
    cursor: pointer;
    display: inline-grid;
    place-content: center;
    outline: none;
    transition: all 0.2s ease;
  }
  
  .form-checkbox:checked {
    background: var(--accent);
    border-color: var(--accent);
  }
  
  .form-checkbox:checked::before {
    content: "";
    width: 8px;
    height: 8px;
    background-color: white;
    clip-path: polygon(14% 44%, 0 58%, 38% 96%, 100% 16%, 86% 2%, 38% 68%);
  }
  
  /* Buttons */
  .btn {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.5;
    outline: none;
  }
  
  .btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
    border-color: rgba(167, 139, 250, 0.2);
    box-shadow: 0 4px 12px 0 rgba(124, 58, 237, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
  }
  
  .btn-primary:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 6px 16px 0 rgba(124, 58, 237, 0.4), inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-1.5px);
  }
  
  .btn-primary:active {
    transform: translateY(0.5px);
    box-shadow: 0 2px 6px 0 rgba(124, 58, 237, 0.2);
  }
  
  .btn-secondary {
    background: rgba(24, 24, 27, 0.6);
    border: 1px solid rgba(63, 63, 70, 0.6);
    color: #e4e4e7;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2);
  }
  
  .btn-secondary:hover {
    background: rgba(39, 39, 42, 0.8);
    border-color: rgba(139, 92, 246, 0.4);
    color: white;
    transform: translateY(-1.5px);
  }
  
  .btn-secondary:active {
    transform: translateY(0.5px);
  }

  button:disabled, .btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    background: rgba(39, 39, 42, 0.4) !important;
    border-color: rgba(63, 63, 70, 0.3) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
    transform: none !important;
  }
  
  .btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(63, 63, 70, 0.6);
    background: rgba(24, 24, 27, 0.6);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.15);
  }
  
  .btn-icon:hover {
    color: white;
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(39, 39, 42, 0.8);
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 6px 14px 0 rgba(139, 92, 246, 0.2);
  }

  .btn-icon:active {
    transform: translateY(0.5px) scale(0.98);
  }
  
  .btn-utility {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: rgba(24, 24, 27, 0.6);
    border: 1px solid rgba(63, 63, 70, 0.6);
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    outline: none;
    line-height: 1.5;
  }

  .btn-utility:hover {
    color: white;
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(39, 39, 42, 0.8);
    transform: translateY(-1px);
  }

  .btn-utility:active {
    transform: translateY(0.5px);
  }
  
  /* Error banner */
  .error-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
  }
  
  /* Amber Warning Box */
  .amber-warning-box {
    background: rgba(217, 119, 6, 0.15);
    border: 1px solid rgba(217, 119, 6, 0.4);
    color: #fbbf24;
    box-shadow: 0 0 10px rgba(217, 119, 6, 0.1);
  }

  /* Version Item */
  .version-item {
    background: rgba(24, 24, 27, 0.6);
  }
  .version-item:hover {
    background: rgba(39, 39, 42, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  
  /* Drag and Drop Zone */
  .drop-zone {
    border: 2px dashed rgba(63, 63, 70, 0.8);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    background: rgba(9, 9, 11, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  .drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.05);
  }
  
  .upload-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
  }
  
  /* Upload Progress Card */
  .upload-progress-card {
    background: rgba(9, 9, 11, 0.6);
    border: 1px solid rgba(63, 63, 70, 0.5);
    border-radius: 14px;
    padding: 14px;
  }
  
  .progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(39, 39, 42, 0.8);
    border-radius: 9999px;
    overflow: hidden;
  }
  
  .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #a78bfa 100%);
    border-radius: 9999px;
    transition: width 0.1s ease;
  }
  
  /* Access Matrix Options */
  .matrix-option {
    cursor: pointer;
  }
  
  .matrix-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
  }
  
  .matrix-card {
    background: rgba(9, 9, 11, 0.8);
    border: 1px solid rgba(63, 63, 70, 0.6);
    border-radius: 12px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    transition: all 0.2s ease;
  }
  
  .matrix-option input:checked + .matrix-card {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
  }
  
  .matrix-option input:checked + .matrix-card.text-danger {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
  }
  
  .matrix-title {
    font-size: 13px;
    font-weight: 600;
    color: white;
  }
  
  .matrix-desc {
    font-size: 10px;
    color: var(--text-secondary);
  }
  
  /* HLS Custom Player Elements */
  .player-card {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  .player-disk {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle, #27272a 35%, #09090b 100%);
    border: 2px solid rgba(63, 63, 70, 0.8);
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
  }
  
  .disk-center {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  
  /* Disc Rotation Animation when playing */
  @keyframes rotateDisk {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }
  
  .player-disk.playing {
    animation: rotateDisk 4s linear infinite;
  }
  
  /* Custom Timeline Seekbar */
  .timeline-container {
    width: 100%;
    height: 4px;
    background: rgba(63, 63, 70, 0.4);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    transition: height 0.15s ease;
  }
  
  .timeline-container:hover {
    height: 6px;
  }
  
  .timeline-progress {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
  }
  
  .timeline-handle {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
  }
  
  .timeline-container:hover .timeline-handle {
    opacity: 1;
  }
  
  /* Custom Utilities */
  .hidden {
    display: none !important;
  }
  
  .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid white;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  /* Track List custom scrollbar */
  #track-list::-webkit-scrollbar {
    width: 4px;
  }
  #track-list::-webkit-scrollbar-track {
    background: transparent;
  }
  #track-list::-webkit-scrollbar-thumb {
    background: rgba(63, 63, 70, 0.5);
    border-radius: 10px;
  }
  #track-list::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
  }
  
  /* SPA Animation states */
  .spa-section {
    transition: opacity 0.25s ease-in-out, transform 0.25s ease-in-out;
    opacity: 0;
    transform: translateY(10px);
  }
  
  .spa-section.active {
    opacity: 1;
    transform: translateY(0);
  }

  /* PWA Update Toast styling */
  .update-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(24, 24, 27, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
    font-size: 12px;
    color: #E4E4E7;
    font-weight: 500;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .update-toast-btn {
    padding: 6px 12px;
    border-radius: 6px;
    background: #7C3AED;
    color: #FFFFFF;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
  }

  .update-toast-btn:hover {
    background: #6D28D9;
  }

  @keyframes slideUp {
    from {
      transform: translate(-50%, 30px);
      opacity: 0;
    }
    to {
      transform: translate(-50%, 0);
      opacity: 1;
    }
  }

  /* Studio Sub-Tab Navigation (Pill-Segment Style) */
  .studio-subtab-container {
    display: flex;
    background: rgba(24, 24, 27, 0.4);
    border: 1px solid rgba(63, 63, 70, 0.3);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
    margin-bottom: 8px;
  }

  .studio-subtab-btn {
    flex: 1;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: transparent;
    border: none;
    text-align: center;
    white-space: nowrap;
    outline: none;
  }

  .studio-subtab-btn:hover {
    color: white;
    background: rgba(39, 39, 42, 0.3);
  }

  .studio-subtab-btn.active {
    color: white;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.25);
    box-shadow: 0 0 12px 0 rgba(139, 92, 246, 0.08);
  }

  /* Responsive Dashboard Grid Layouts */
  .dashboard-grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.5rem;
  }

  .dashboard-grid-3col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
  }

  @media (max-width: 768px) {
    .dashboard-grid-2col, .dashboard-grid-3col {
      grid-template-columns: 1fr;
    }
  }

  /* Storage Plan Selector Card Styling */
  .storage-option-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .storage-option-card.active-card {
    border-color: #7c3aed !important;
    background-color: rgba(124, 58, 237, 0.15) !important;
    box-shadow: 0 0 12px 1px rgba(124, 58, 237, 0.2);
  }
  .storage-option-card:hover:not(.active-card) {
    border-color: #3f3f46 !important;
    background-color: #18181b !important;
  }

  /* Mobile-First Progressive Disclosure UI Layout */
  #mobile-hud {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  #desktop-workspace {
    display: none;
  }

  /* Desktop Dual-Pane Layout */
  @media (min-width: 768px) {
    #mobile-hud {
      display: none !important;
    }
    
    #desktop-workspace {
      display: flex !important;
      flex-direction: row;
      gap: 1.5rem;
      width: 100%;
    }
    
    #desktop-left-pane {
      width: 40%;
      min-width: 320px;
      display: flex;
      flex-direction: column;
      gap: 1.5rem;
    }
    
    #desktop-right-pane {
      width: 60%;
      display: flex;
      flex-direction: column;
      gap: 1.5rem;
    }
    
    #desktop-left-pane .dashboard-grid-2col {
      grid-template-columns: 1fr !important;
    }
  }

  /* Styling for active take switcher pills and responsive overlays */
  .btn-desktop-take, .btn-remote-take {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(63, 63, 70, 0.4);
    background-color: rgba(24, 24, 27, 0.6);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
  }

  .btn-desktop-take:hover, .btn-remote-take:hover {
    border-color: rgba(139, 92, 246, 0.4);
    color: white;
    background-color: rgba(39, 39, 42, 0.8);
  }

  .active-pill {
    border-color: #7c3aed !important;
    background-color: rgba(124, 58, 237, 0.15) !important;
    color: #c084fc !important;
    box-shadow: 0 0 10px 0 rgba(124, 58, 237, 0.15) !important;
  }

  /* Remote Pairing Modal Vanilla CSS overrides */
  #pairing-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 9999 !important;
    padding: 1.5rem;
  }

  #pairing-modal.hidden {
    display: none !important;
  }

  #pairing-qr-box {
    width: 144px !important;
    height: 144px !important;
    background-color: #ffffff !important;
    padding: 0.5rem !important;
    border-radius: 0.5rem !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    flex-shrink: 0;
  }

  #pairing-qr-svg {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    color: #000000 !important;
  }

