body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    /* Tons pastel */
    background-color: #f0f8ff; 
    padding: 10px;
    box-sizing: border-box;
}

/* ---------------------------------------------------------------------- */
/* --- CONTENEUR GLOBAL ET METADATA (Haut Droit) --- */
/* ---------------------------------------------------------------------- */

#metadataControls {
    position: fixed;
    top: 10px; 
    right: 10px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end; 
}

#toggleTagsButton {
    background-color: #add8e6;
    color: #333;
    border: 1px solid #a0b7c7;
    padding: 6px 10px; 
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    margin-bottom: 5px;
    transition: background-color 0.3s;
}

#toggleTagsButton:hover {
    background-color: #90c8d7;
}

#allMetadataDisplay {
    width: 200px; 
    max-height: 50vh; 
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.85);
    border: 1px solid #d4e0e8; 
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); 
    font-family: monospace;
    font-size: 0.7em; 
    overflow-y: auto; 
}

.hidden {
    display: none;
}

#allMetadataDisplay h4 {
    margin-top: 0;
    color: #4682b4;
    border-bottom: 1px solid #e0f2f7;
    padding-bottom: 5px;
}

#allTagsContent {
    white-space: pre-wrap;
    margin: 0;
    padding: 0;
}

/* ---------------------------------------------------------------------- */
/* --- LECTEUR PRINCIPAL (Player Wrapper) --- */
/* ---------------------------------------------------------------------- */

/* Conteneur Flexbox parent pour aligner le lecteur et les boutons */
.player-wrapper {
    display: flex;
    /* Aligner le lecteur et les boutons sur la même ligne (grand écran) */
    flex-direction: row; 
    align-items: flex-start; /* Aligner en haut */
    gap: 20px; /* Espace entre le lecteur et les boutons */
    
    width: 90vw; 
    max-width: 950px; /* Largeur maximale pour le lecteur + les boutons */
    position: relative; 
    box-sizing: border-box; 
    padding: 0; 
}

/* Conteneur du lecteur et des contrôles (Gère TOUTES les bordures externes et le radius) */
.player-and-controls {
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
    max-width: 800px; 
    
    /* NOUVEAU: BORDURE SUR TOUS LES CÔTÉS et RAYON DE BORDURE */
    border: 5px solid #a9b9c9;
    border-radius: 5px; 
    
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); 
}

/* Conteneur principal du lecteur (l'image de fond) */
#audioPlayer {
    width: 100%; 
    height: 0; 
    padding-bottom: 66.625%; /* Ratio 3:2 (laisse l'espace pour l'image) */
    
    position: relative; 
    /* CONSERVER: La bordure du bas pour la délimitation */
    border-bottom: 5px solid #a9b9c9; 
    
    /* Supprimer les autres bordures et radius */
    border-top: none;
    border-left: none; 
    border-right: none; 
    border-radius: 0; 
    
    /* Image par défaut pour le fond du lecteur (SANS !important) */
    background-image: url('default_cover.jpg'); 

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #c0d9e9; 
    overflow: hidden;
    margin-bottom: 0;
}

/* Positionnement des éléments internes */
#audioElement {
    position: absolute;
}


/* Métadonnées principales (Titre/Artiste/Album) - Positionnement Corrigé dans la zone de contrôle */
#metadataDisplay {
    
    /* Rendu visible dans le flux normal (pas de position absolu) */
    flex-grow: 1; /* Prend l'espace restant à droite */
    margin-left: 15px; /* Espace entre les boutons et le texte */
    
    padding: 8px 12px; 
    background-color: rgba(224, 242, 247, 0.85); 
    color: #333; 
    font-family: sans-serif;
    border-radius: 5px;
    z-index: 10;
    font-size: 0.85em;
    
    box-sizing: border-box; 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

#metadataDisplay p {
    margin: 0;
    font-weight: normal; 
    text-align: left; /* Aligne le texte à gauche de l'espace disponible */
}

/* Cible le Titre de la piste pour remettre le gras ET augmenter la taille */
#trackTitle {
    font-weight: bold;
    font-size: 1.1em; 
}


/* ---------------------------------------------------------------------- */
/* --- SÉLECTEURS DE FICHIERS (Maintenant en Flex) --- */
/* ---------------------------------------------------------------------- */

.file-selectors {
    /* Positionnement normal dans le flux Flexbox */
    position: relative; 
    
    display: flex;
    flex-direction: column;
    gap: 8px; 
    
    padding: 0; 
    width: 120px; /* Largeur fixe pour la colonne des boutons */
    flex-shrink: 0; /* Ne pas laisser les boutons rétrécir */
}

.custom-file-upload {
    display: inline-block;
    background-color: #8fbc8f; /* Pastel menthe */
    color: #333; 
    padding: 6px 8px; 
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75em; 
    text-align: center;
    transition: background-color 0.3s;
}

.custom-file-upload:hover {
    background-color: #7ba37b;
}

input[type="file"] {
    display: none;
}

/* ---------------------------------------------------------------------- */
/* --- CONTRÔLES (BARRE DE PROGRESSION ET DISQUE) --- */
/* ---------------------------------------------------------------------- */

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

#progressBarControls {
    width: 100%;
    background-color: #c3d6e8; 
    padding: 10px;
    box-sizing: border-box;
    display: flex;
}

/* Conteneur Principal de Contrôles (Horizontal : Disque + Stack Droite) */
#controls-main-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%; 
    gap: 10px;
}

/* Pile Verticale des Contrôles de Droite (Progression + Boutons/Meta) */
.right-controls-stack {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 5px; /* Espace entre la barre de progression et la rangée des boutons */
}

/* Disque Vinyle */
#vinylDisc {
    /* Taille pour écrans Desktop/Large (105px) */
    width: 105px;
    height: 105px;
    
    border-radius: 50%;
    /* Bordure du disque */
    border: 1px solid #111; 
    
    /* Couleur de fond bleu très clair */
    background-color: #e0f8ff; 

    /* Image par défaut pour le disque (SANS !important) */
    background-image: url('image_disq.jpg');
    
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.1s linear;
}

#vinylDisc.playing {
    animation: spin 5s linear infinite; 
}

/* Style pour le trou central (20px + bordure) */
#discCenter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Augmenté à 20px */
    width: 20px;
    height: 20px;
    /* Même couleur que le fond du disque */
    background-color: #e0f8ff; 
    /* Bordure identique à celle du disque */
    border: 1px solid #111;
    border-radius: 50%;
    z-index: 2; 
}

/* Conteneur de la barre de progression et du temps (Haut de la pile droite) */
.progress-details {
    display: flex;
    flex-direction: column; 
    gap: 8px; 
}

/* Conteneur des boutons et métadonnées (Bas de la pile droite - Alignement Horizontal) */
#bottom-controls-row {
    display: flex;
    align-items: center; /* Aligner les boutons et les métadonnées verticalement */
    justify-content: flex-start; 
    width: 100%;
}

/* Affichage du temps (Centré) */
#timeDisplay {
    color: #333; 
    font-family: monospace;
    /* TAILLE AUGMENTÉE POUR VISIBILITÉ */
    font-size: 1.0em; 
    margin-bottom: 3px; 
    text-align: center; 
}

/* Barre de progression Conteneur (PISTE) */
#progressBarContainer {
    width: 100%;
    height: 6px; 
    background-color: #a0b7c7; 
    border-radius: 3px; 
    position: relative;
    cursor: pointer;
}

/* Barre de progression Verte (REMPLISSAGE) */
#progressBar {
    height: 100%;
    width: 0%; 
    /* Dégradé de vert clair à vert foncé */
    background: linear-gradient(to right, #98fb98, #66CDAA); 
    border-radius: 3px; 
    /* Transition rétablie à 0.1s */
    transition: width 0.1s linear; 
    position: relative; 
}

/* Poignée de navigation (seekHandle) */
#seekHandle {
    position: absolute;
    right: -7px; 
    top: 50%; 
    transform: translateY(-50%); 
    
    width: 14px;
    height: 14px;
    background-color: white;
    border: 3px solid #add8e6;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
/* CORRECTION : Augmenter la priorité d'affichage pour qu'il passe devant les métadonnées */
    z-index: 100;	
}

#seekHandle.dragging {
    cursor: grabbing;
    transform: translateY(-50%) scale(1.1);
}

/* --- Boutons de Lecture --- */

.playback-buttons {
    display: flex;
    gap: 10px; 
    margin-top: 0; 
    padding: 0; 
    flex-shrink: 0;
}

.playback-buttons button {
    background-color: #add8e6; 
    border: none;
    color: #333; 
    padding: 8px 15px; 
    font-size: 1.2em; 
    cursor: pointer;
    border-radius: 4px;
    transition: box-shadow 0.3s, background-color 0.3s;
}

.playback-buttons button:disabled {
    background-color: #b0c4de;
    color: #6c757d;
    cursor: not-allowed;
    box-shadow: none;
}

.playback-buttons button:not(:disabled):hover {
    box-shadow: 0 0 15px rgba(173, 216, 230, 0.8);
    background-color: #90c8d7;
}

.playback-buttons .icon {
    line-height: 1;
}

/* ---------------------------------------------------------------------- */
/* --- MEDIA QUERY pour les petits écrans (SMARTPHONES < 700px) --- */
/* ---------------------------------------------------------------------- */

@media (max-width: 700px) { 
    
    /* Le wrapper passe en mode colonne (stacking) */
    .player-wrapper {
        flex-direction: column; 
        align-items: center;
        max-width: 100%; 
    }
    
    /* Retirer toutes les bordures et l'ombre pour le petit écran */
    .player-and-controls {
        width: 100%;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    /* Les sélecteurs de fichiers passent sous le lecteur et sont horizontaux */
    .file-selectors {
        width: 100%;
        flex-direction: row; 
        justify-content: center; 
        gap: 10px;
        margin-top: 10px;
        margin-bottom: 10px;
    }
    
    .custom-file-upload {
        flex-grow: 1; 
        font-size: 0.8em; 
        padding: 10px 5px;
    }

    /* Le bloc de tags se positionne normalement au-dessus du lecteur */
    #metadataControls {
        position: static; 
        width: 100%;
        align-items: center;
        margin-bottom: 10px;
    }
    
    #toggleTagsButton {
        width: 90%;
        font-size: 0.9em;
        padding: 10px;
    }
    
    #allMetadataDisplay {
        width: 90%;
        font-size: 0.8em;
        margin-top: 5px;
    }

    /* Réduction des contrôles */
    #progressBarControls {
        padding: 8px;
        /* Rétablissement des bordures pour les petits écrans sans le parent */
        border-bottom: 5px solid #a9b9c9;
        border-top: none;
        border-left: 5px solid #a9b9c9;
        border-right: 5px solid #a9b9c9;
    }
    
    /* Rétablissement des bordures pour les petits écrans sans le parent */
    #audioPlayer {
        border-top: 5px solid #a9b9c9;
        border-bottom: 5px solid #a9b9c9;
        border-left: 5px solid #a9b9c9;
        border-right: 5px solid #a9b9c9;
        position: relative; 
    }
    
    /* Sur mobile, on empile tous les éléments de la rangée principale verticalement et au centre */
    #controls-main-row {
        flex-direction: column; 
        align-items: center;
        justify-content: center;
        gap: 15px; /* Plus d'espace entre le disque et le reste */
    }
    
    /* La pile de droite passe en pleine largeur */
    .right-controls-stack {
        width: 100%; 
    }

    /* Ajustement de la taille du disque pour les petits écrans (80px) */
    #vinylDisc {
        width: 80px; 
        height: 80px;
    }
    
    /* Maintient le trou central à la bonne taille */
    #discCenter {
        width: 20px;
        height: 20px;
    }

    #seekHandle {
        right: -6px; 
        width: 12px;
        height: 12px;
        border: 2px solid #add8e6;
    }

    /* Sur mobile, les contrôles et les métadonnées sont empilés verticalement et centrés */
    #bottom-controls-row {
        flex-direction: column;
        align-items: center; 
        gap: 10px;
    }

    /* METADONNÉES SUR MOBILE (Plein écran et centré) */
    #metadataDisplay {
        font-size: 0.8em;
        max-width: 90%;
        margin-left: 0;
        text-align: center;
        width: 100%; /* Prend toute la largeur disponible */
    }
    
    #metadataDisplay p {
        text-align: center; 
        margin-bottom: 2px;
        font-weight: normal; 
    }
    
    /* Le titre reste en gras et en grande taille */
    #trackTitle {
        font-weight: bold;
        font-size: 1.1em;
    }

    .playback-buttons {
        padding: 0;
    }

    .playback-buttons button {
        padding: 10px 18px;
        font-size: 1.4em;
    }
}

/* ---------------------------------------------------------------------- */
/* --- MEDIA QUERY pour les très petits écrans (SMARTPHONES < 500px) --- */
/* ---------------------------------------------------------------------- */

@media (max-width: 500px) {
    
    /* Réduction du disque pour les très petits écrans */
    #vinylDisc {
        width: 65px; 
        height: 65px;
    }
    
    .playback-buttons button {
        /* On réduit la taille des boutons pour qu'ils tiennent mieux */
        padding: 8px 15px;
        font-size: 1.2em;
    }
}