:root, html.dark {
    /* Base Dark Theme (Default) */
    --color-white: #ffffff;
    --studio-black: #08080a;
    --studio-card: #121218;
    --studio-card-hover: #181824;
    --studio-border: rgba(255, 255, 255, 0.08);
    --studio-border-hover: rgba(255, 255, 255, 0.16);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.4);
    --secondary: #06b6d4;
    --text-muted: #9ca3af;
    --studio-text: #f3f4f6;
    --studio-input-bg: rgba(255, 255, 255, 0.04);
    --studio-input-border: rgba(255, 255, 255, 0.12);
    
    /* Legacy variables for CSS */
    --bg-dark: #08080a;
    --text-main: #f3f4f6;
    --glass-bg: rgba(18, 18, 24, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
}

html.light-mode {
    /* Light Theme Overrides */
    --color-white: #0f172a;
    --studio-black: #f8fafc;
    --studio-card: #ffffff;
    --studio-card-hover: #f1f5f9;
    --studio-border: rgba(0, 0, 0, 0.08);
    --studio-border-hover: rgba(0, 0, 0, 0.15);
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-glow: rgba(124, 58, 237, 0.25);
    --secondary: #0284c7;
    --text-muted: #475569;
    --studio-text: #0f172a;
    --studio-input-bg: #ffffff;
    --studio-input-border: #cbd5e1;
    
    /* Legacy variables for CSS */
    --bg-dark: #f8fafc;
    --text-main: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dynamic Background Orbs */
.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    animation: float 20s infinite alternate ease-in-out;
}

html.light-mode .orb {
    opacity: 0.25 !important;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--secondary);
    bottom: -50px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 100px) scale(1.2); }
}

/* Container */
.container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    z-index: 1;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
    animation: pulse 2s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
}

h1 span {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

/* Upload Section */
.upload-section {
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 2rem;
}

html.light-mode .upload-section {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.12);
}

.upload-section:hover, .upload-section.dragover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.05);
    transform: translateY(-2px);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.upload-content h3 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.highlight {
    color: var(--primary);
    font-weight: 600;
}

/* File Info */
#file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 12px;
}

html.light-mode #file-info {
    background: rgba(0, 0, 0, 0.04);
}

#file-name {
    font-weight: 600;
    color: var(--secondary);
    word-break: break-all;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s ease;
}

.icon-btn:hover {
    color: #ef4444;
}

/* Settings Section */
.settings-section {
    margin-bottom: 2rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

.custom-select {
    width: 100%;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2394a3b8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1.5rem top 50%;
    background-size: 0.8rem auto;
    transition: border-color 0.3s ease;
}

.custom-select:focus {
    border-color: var(--primary);
}

/* Buttons */
.glow-btn {
    width: 100%;
    padding: 1.2rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white !important;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 10px 20px -10px var(--primary-glow);
    display: flex;
    justify-content: center;
    align-items: center;
}

.glow-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -10px var(--primary-glow);
}

.glow-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--glass-border);
    box-shadow: none;
}

.outline-btn {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--primary);
    border-radius: 12px;
    background: transparent;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.outline-btn:hover {
    background: rgba(139, 92, 246, 0.1);
}

/* Status Message */
.status-message {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--secondary);
    font-weight: 600;
    animation: fadeIn 0.5s ease;
}

/* Result Section */
.result-panel {
    margin-top: 2rem;
    text-align: center;
    animation: slideUp 0.6s ease cubic-bezier(0.16, 1, 0.3, 1);
}

.result-panel h2 {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.audio-player-container {
    margin-bottom: 1.5rem;
    width: 100%;
}

audio {
    width: 100%;
    height: 40px;
    border-radius: 8px;
}

/* Loader */
.loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.hidden {
    display: none !important;
}

/* ==========================================================================
   LIGHT MODE COMPREHENSIVE TAILWIND & UI RETHEMING
   ========================================================================== */

html.light-mode header {
    background-color: rgba(255, 255, 255, 0.88) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    backdrop-filter: blur(16px);
}

html.light-mode .bg-studio-black,
html.light-mode .bg-studio-card,
html.light-mode .bg-\[\#0d0d11\],
html.light-mode .bg-\[\#0a0a0d\],
html.light-mode .bg-\[\#121215\],
html.light-mode .bg-\[\#16161a\],
html.light-mode .bg-\[\#121218\] {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02) !important;
}

html.light-mode .text-white {
    color: #0f172a !important;
}

html.light-mode .text-text-muted,
html.light-mode .text-gray-400,
html.light-mode .text-slate-400,
html.light-mode .text-zinc-400 {
    color: #475569 !important;
}

html.light-mode .text-slate-200,
html.light-mode .text-slate-300,
html.light-mode .text-gray-200,
html.light-mode .text-gray-300 {
    color: #1e293b !important;
}

html.light-mode .border-white\/5,
html.light-mode .border-white\/10,
html.light-mode .border-white\/20,
html.light-mode .border-white\/30,
html.light-mode .border-studio-border {
    border-color: rgba(0, 0, 0, 0.08) !important;
}

html.light-mode .hover\:bg-white\/5:hover,
html.light-mode .hover\:bg-white\/10:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
}

html.light-mode .bg-black\/50,
html.light-mode .bg-black\/40,
html.light-mode .bg-black\/60,
html.light-mode .bg-black\/70,
html.light-mode .bg-black\/80 {
    background-color: rgba(15, 23, 42, 0.4) !important;
}

/* Ensure text inside primary buttons and badges remains white */
html.light-mode button[class*="bg-primary"],
html.light-mode button[class*="from-primary"],
html.light-mode a[class*="from-primary"],
html.light-mode .glow-btn,
html.light-mode .glow-btn *,
html.light-mode .btn-primary,
html.light-mode .btn-primary * {
    color: #ffffff !important;
}

/* Form Controls in Light Mode */
html.light-mode input[type="text"],
html.light-mode input[type="number"],
html.light-mode input[type="file"],
html.light-mode textarea,
html.light-mode select {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

html.light-mode select option {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

/* Drawer / Modals in Light Mode */
html.light-mode #history-drawer {
    background-color: #ffffff !important;
    border-left: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.08) !important;
}

html.light-mode pre, html.light-mode code {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}

/* ==========================================================================
   AUDIO PLAYER & RANGE SLIDER CURSOR RETHEMING
   ========================================================================== */

/* Universal Range Sliders (Timeline & Volume) */
input[type="range"] {
    accent-color: var(--primary);
}

input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: var(--primary);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-top: -5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease, background-color 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* Light Mode Range Slider & Cursors */
html.light-mode input[type="range"] {
    accent-color: #7c3aed !important;
}

html.light-mode input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(0, 0, 0, 0.15) !important;
}

html.light-mode input[type="range"]::-webkit-slider-thumb {
    background: #7c3aed !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.5) !important;
}

html.light-mode input[type="range"]::-moz-range-thumb {
    background: #7c3aed !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.5) !important;
}

/* Audio Player Footer in Light Mode */
html.light-mode footer {
    background-color: rgba(255, 255, 255, 0.92) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.05) !important;
    backdrop-filter: blur(16px);
}

html.light-mode #master-play-btn {
    background: #7c3aed !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35) !important;
}

html.light-mode #master-play-btn * {
    color: #ffffff !important;
}

html.light-mode #footer-track-name {
    color: #0f172a !important;
}

html.light-mode #footer-artist-name,
html.light-mode #current-time,
html.light-mode #duration-time,
html.light-mode #volume-icon {
    color: #475569 !important;
}

html.light-mode #volume-icon:hover {
    color: #0f172a !important;
}

/* History Drawer Action Buttons */
html.light-mode .history-play-btn,
html.light-mode button[onclick*="playHistoryAudio"] {
    background-color: #7c3aed !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.25) !important;
}

html.light-mode button[onclick*="playHistoryAudio"] * {
    color: #ffffff !important;
}

