html, body {
  margin: 0; padding: 0; height: 100%;
  background: #121212; color: #fff;
  font-family: sans-serif;
  overflow: hidden;
  display: flex; flex-direction: column;
}

main {
  flex: 1; display: flex;
  height: calc(100% - 120px);
  overflow: hidden;
}

#playlist {
  width: 300px; height: calc(100dvh - 120px);
  background: #121212;
  border-right: 1px solid #333;
  box-sizing: border-box;
  display: flex; flex-direction: column;
}

#playlist-titre {
  padding: 1rem; border-bottom: 1px solid #333;
  position: relative; z-index: 1000;
}

#playlist-table-container {
  flex: 1; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: #1ed760 transparent;
}

#menu-deroulant { position: relative; z-index: 1000; user-select: none; font-family: sans-serif; }

ul.menu-principal, ul.sous-menu, ul.sous-menu-lateral {
  list-style: none; padding: 0; margin: 0;
  background-color: rgba(18, 18, 18, 0.98); color: white;
  border-radius: 6px; border: 1px solid #555;
}

ul.menu-principal > li, ul.sous-menu > li, ul.sous-menu-lateral > li {
  position: relative; 
  display: flex;
  flex-direction: column;
  width: 100%;
}

.titre-menu, .btn-course {
  display: block; box-sizing: border-box;
  padding: 10px 15px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: none; border: none; color: white; width: 100%; text-align: left;
  font-family: inherit; font-size: 14px;
  transition: background-color 0.2s, color 0.2s; margin: 0;
}

ul.menu-principal > li:first-child > .titre-menu,
ul.sous-menu > li:first-child > .titre-menu, ul.sous-menu > li:first-child > .btn-course,
ul.sous-menu-lateral > li:first-child > .titre-menu, ul.sous-menu-lateral > li:first-child > .btn-course {
  border-top-left-radius: 5px; border-top-right-radius: 5px;
}

ul.menu-principal > li:last-child > .titre-menu,
ul.sous-menu > li:last-child > .titre-menu, ul.sous-menu > li:last-child > .btn-course,
ul.sous-menu-lateral > li:last-child > .titre-menu, ul.sous-menu-lateral > li:last-child > .btn-course {
  border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;
}

.titre-menu:hover, .btn-course:hover { background-color: rgba(40, 40, 40, 0.9); color: #1ed760; }
.btn-course:focus { outline: none; }

ul.sous-menu, ul.sous-menu-lateral {
  display: none; position: absolute;
  min-width: 180px; width: max-content;
  box-shadow: 2px 2px 10px rgba(0,0,0,0.8);
  max-height: 40dvh; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: #1ed760 transparent;
}

ul.sous-menu { top: 100%; left: -1px; z-index: 2000; width: calc(100% + 2px); }
ul.sous-menu-lateral { top: -1px; left: 100%; z-index: 2001; }
li:hover > ul.sous-menu { display: block; }

#playlist-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.playlist-ligne { cursor: pointer; transition: background 0.2s ease; border-bottom: 1px solid #333; }
.playlist-ligne:hover, .playlist-ligne.active { background: #333; }
.playlist-ligne.active { background: ForestGreen; }
.playlist-cellule { padding: 0.5rem; vertical-align: middle; color: #fff; overflow: hidden; }
.indice { width: 35px; text-align: center; font-size: 14px; padding: 0.2rem; }
.infos-cellule { display: flex; align-items: center; gap: 10px; }
.infos-cellule img { width: 42px; height: 42px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.infos-cellule > div { min-width: 0; flex: 1; }
.duree { width: 36px; text-align: right; font-family: monospace; color: #ccc; }
.titre { font-weight: bold; font-size: 14px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artiste { font-size: 12px; color: #ccc; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#couleur {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 1rem 2rem calc(1rem + 120px); text-align: center;
  overflow-y: auto; background-color: #242424;
}

#paroles {
  font-size: 2.2rem; line-height: 2.8rem; max-height: 90%; width: 100%;
  overflow-y: auto; user-select: none;
  scrollbar-width: thin; scrollbar-color: #1ed760 transparent;
}

.vers { opacity: 0.3; transition: all 0.3s ease; margin: 0.3rem 0; cursor: pointer; }
.vers:hover { opacity: 0.8; }
.vers.active { font-weight: bold; opacity: 1; font-size: 2.6rem; }
.pas-de-paroles { font-size: 2.5em; user-select: none; pointer-events: none; line-height: 1.2; }

#en-cours-de-lecture {
  background: #121212; width: 300px; height: calc(100dvh - 120px);
  box-sizing: border-box; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 1rem;
}

#chanson-en-cours video, #chanson-en-cours img {
  width: 100%; object-fit: cover; border-radius: 0.5rem;
  filter: brightness(0.8); transition: filter 0.3s ease;
}

#chanson-en-cours video:hover, #chanson-en-cours img:hover { filter: brightness(1); }
#titre-en-cours, #artiste-en-cours { margin: 0; padding: 0 5px; overflow-wrap: break-word; word-break: break-word; }
#titre-en-cours { padding-top: 10px; font-size: 1.5rem; font-weight: bold; }
#artiste-en-cours { font-size: 1.1rem; color: #999; }

#chanson-suivante {
  display: none; background-color: #242424; border-radius: 0.5rem;
  padding: 10px; box-sizing: border-box; margin-top: auto;
}

#chanson-suivante .miniature {
  position: static; transform: none; white-space: normal;
  display: flex; align-items: center; gap: 12px; word-wrap: break-word;
  cursor: pointer; transition: filter 0.2s ease;
}

#chanson-suivante .miniature:hover { filter: brightness(0.8); }
#a-suivre { font-weight: bold; font-size: 1rem; margin-top: 0; margin-bottom: 6px; }

footer {
  position: fixed; bottom: 0; left: 0; width: 100%; height: 120px;
  background: black; border-top: 1px solid #333;
  padding: 1rem 2rem; box-sizing: border-box;
  display: flex; flex-direction: column; justify-content: space-between; z-index: 1000;
}

footer button, #boutons button {
  background: none; border: none; cursor: pointer; user-select: none;
  transition: color 0.2s ease, transform 0.2s ease;
  margin: 0.3rem; font-size: 2rem; color: white;
}

footer button img { width: 30px; height: auto; transition: transform 0.2s ease; }
footer button:hover { color: #1ed760; }
footer button:hover img { transform: scale(1.1); }

#aleatoire img, #precedent img, #suivant img, #boucle img { filter: brightness(0.8); }
#aleatoire:hover img, #precedent:hover img, #suivant:hover img, #boucle:hover img {
  filter: brightness(1); transform: scale(1.1);
}
#boucle.active img, #aleatoire.active img { filter: brightness(1); }
#boutons { position: relative; display: flex; justify-content: center; align-items: center; }

.miniature {
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%); display: flex; align-items: center; gap: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 600px;
}

.miniature img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; }
.artiste-et-titre {
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  min-width: 0;
}

#barreLecture {
  background: #4d4d4d; height: 8px; width: 100%; touch-action: none;
  border-radius: 4px; cursor: pointer; margin-top: 0.8rem; position: relative;
}

#progression { height: 100%; background: #1ed760; width: 0; border-radius: 4px; }
#temps { display: flex; justify-content: space-between; font-size: 0.85rem; color: #ccc; font-family: monospace; margin-top: 0.2rem; }

#fond-noir-mobile, #btn-menu-mobile { display: none; }

@media (max-width: 1100px) {
  #en-cours-de-lecture { display: none; }
  #paroles { font-size: 1rem; line-height: 1.3rem; }
  .vers.active { font-size: 1.4rem; }
  .pas-de-paroles { font-size: 4em; }

  #fond-noir-mobile {
    display: block; position: fixed; top: 0; left: 0;
    width: 100%; height: 85px; background: #121212;
    border-bottom: 1px solid #333; z-index: 999;
  }

  #boutons .miniature {
    position: fixed; top: 15px; left: 1.5rem; bottom: auto;
    z-index: 2000; transform: none; transition: opacity 0.3s ease;
    max-width: calc(100vw - 100px);
  }

  body.menu-mobile-ouvert #boutons .miniature { opacity: 0; pointer-events: none; }

  #btn-menu-mobile {
    display: block; position: fixed; top: 18px; right: 1.5rem;
    background: none; border: none; color: #1ed760;
    font-size: 1.8rem; cursor: pointer; z-index: 3000;
  }

  main { margin-top: 85px; height: calc(100% - 120px - 85px); }

  #playlist {
    display: flex !important; position: fixed; top: 85px; left: 0;
    width: 100%; height: calc(100dvh - 120px - 85px);
    background: rgba(18, 18, 18, 0.98); z-index: 2500;
    transform: translateY(-120dvh); transition: transform 0.3s ease-in-out;
    border-right: none;
  }
  #playlist.ouvert { transform: translateY(0); }

  #playlist-titre {
    position: absolute; top: -85px; left: 15px;
    width: calc(100% - 100px); padding: 20px 0; border: none;
  }

  ul.sous-menu-lateral {
    position: relative !important; left: 0 !important; top: 0 !important;
    width: calc(100% - 10px) !important; margin-left: 10px;
    border-left: 2px solid #1ed760; border-radius: 0;
    box-shadow: none; max-height: none; overflow: visible;
  }

  li.menu-parent.ouvert > ul.sous-menu-lateral { display: block; }
}