:root {
  --fond: #12131a;
  --fond-carte: #1b1d27;
  --fond-champ: #23252f;
  --bord: #2f3240;
  --texte: #eceef4;
  --texte-doux: #9ba1b4;
  --accent: #e8b44a;
  --accent-texte: #1a1408;
  --danger: #e2685f;
  --rayon: 10px;
  --largeur: 780px;
}

@media (prefers-color-scheme: light) {
  :root {
    --fond: #f5f5f7;
    --fond-carte: #ffffff;
    --fond-champ: #ffffff;
    --bord: #dcdde3;
    --texte: #1a1c23;
    --texte-doux: #666c7e;
    --accent: #b8801a;
    --accent-texte: #ffffff;
  }
}

* { box-sizing: border-box; }

/* l'attribut hidden doit l'emporter sur les display: flex ci-dessous */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.3rem; margin: 0; letter-spacing: .01em; cursor: pointer; }
h2 { font-size: 1.15rem; margin: 0 0 1.2rem; }

main { max-width: var(--largeur); margin: 0 auto; padding: 1.1rem 1rem 4rem; }

/* En-tête ---------------------------------------------------------------- */

.entete {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--fond) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bord);
  padding: .85rem 1rem .8rem;
}

.entete-haut {
  max-width: var(--largeur);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}

.entete-actions { display: flex; gap: .5rem; }

.zone-recherche {
  max-width: var(--largeur);
  margin: .7rem auto 0;
  display: flex;
  gap: .5rem;
}

.zone-recherche input { flex: 1; }

input, select {
  background: var(--fond-champ);
  color: var(--texte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: .5rem .65rem;
  font: inherit;
  max-width: 100%;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.bouton, .bouton-discret {
  border-radius: var(--rayon);
  padding: .5rem .9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--bord);
  white-space: nowrap;
}

.bouton { background: var(--accent); color: var(--accent-texte); border-color: transparent; }
.bouton-discret { background: transparent; color: var(--texte); }
.bouton:hover, .bouton-discret:hover { filter: brightness(1.12); }

.lien-bouton {
  background: transparent;
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  color: var(--texte);
  padding: .3rem .6rem;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}
.lien-bouton:hover { border-color: var(--accent); }
.lien-danger { color: var(--danger); }

.bandeau {
  max-width: var(--largeur);
  margin: .7rem auto 0;
  padding: .5rem .75rem;
  border-radius: var(--rayon);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  font-size: .88rem;
}

.libelle-court { display: none; }

@media (max-width: 560px) {
  .entete-haut h1 { font-size: 1.1rem; }
  .bouton, .bouton-discret { padding: .45rem .7rem; font-size: .88rem; }
  .entete-actions { gap: .35rem; }
  .libelle-long { display: none; }
  .libelle-court { display: inline; }
}

/* Statistiques rapides --------------------------------------------------- */

/* tout sur une seule ligne, bouton compris : les écarts et les tailles se
   resserrent plutôt que de laisser le bouton décrocher */
.stats-rapides {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: clamp(.55rem, 2.6vw, 1.6rem);
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: .8rem clamp(.6rem, 2vw, 1rem);
  margin-bottom: 1rem;
}

.stat { display: flex; flex-direction: column; min-width: 0; }
.stat-chiffre {
  font-size: clamp(1rem, 4.2vw, 1.3rem);
  font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.stat-libelle {
  font-size: clamp(.65rem, 2.4vw, .75rem);
  color: var(--texte-doux);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-rapides .lien-bouton {
  margin-left: auto;
  flex: none;
  padding: .3rem clamp(.4rem, 1.8vw, .6rem);
  font-size: clamp(.72rem, 2.6vw, .82rem);
}

/* Barre de liste --------------------------------------------------------- */

.barre-liste {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}

.compteur { color: var(--texte-doux); font-size: .85rem; margin: 0; }
.tri { color: var(--texte-doux); font-size: .85rem; display: flex; align-items: center; gap: .4rem; }
.tri select { padding: .3rem .4rem; font-size: .85rem; }

/* Liste ------------------------------------------------------------------ */

.liste { display: flex; flex-direction: column; }

/* le titre occupe sa propre rangée, sur toute la largeur, avant de revenir
   à la ligne ; le reste s'aligne en dessous */
.rangee {
  display: grid;
  grid-template-columns: 5rem auto 1fr auto;
  grid-template-areas:
    "titre titre titre titre"
    "date  film  cote  modif";
  align-items: center;
  column-gap: .9rem;
  row-gap: .3rem;
  border-bottom: 1px solid var(--bord);
  padding: .7rem .35rem;
}

.rangee-modifier {
  grid-area: modif;
  background: transparent;
  border: 0;
  padding: .35rem;
  color: var(--texte-doux);
  cursor: pointer;
  border-radius: 8px;
  opacity: .45;
  display: flex;
}
.rangee-modifier svg { width: 18px; height: 18px; display: block; }
.rangee:hover .rangee-modifier { opacity: 1; }
.rangee-modifier:hover { color: var(--accent); background: var(--fond-champ); }
.rangee-modifier:focus-visible { opacity: 1; }

/* au doigt, il n'y a pas de survol : le picto reste visible */
@media (hover: none) {
  .rangee-modifier { opacity: .8; }
}

.rangee:hover { background: var(--fond-carte); }

.rangee-date {
  grid-area: date;
  display: flex;
  flex-direction: column;
  font-size: .84rem;
  color: var(--texte-doux);
  font-variant-numeric: tabular-nums;
}
.rangee-date .jour { color: var(--texte); font-weight: 600; }

.rangee-film {
  grid-area: film;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .25rem;
  min-width: 0;
}

.rangee-titre {
  grid-area: titre;
  background: transparent; border: 0; padding: 0 0 .1rem; margin: 0;
  color: inherit; font: inherit; font-weight: 600; line-height: 1.3;
  cursor: pointer; text-align: left; justify-self: start;
}
.rangee-titre:hover { color: var(--accent); }
.rangee-annee { color: var(--texte-doux); font-weight: 400; font-size: .85em; }

.vignette {
  width: 62px;
  height: 93px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--fond-champ);
  border: 1px solid var(--bord);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vignette:hover { border-color: var(--accent); }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette-vide { font-size: 1.2rem; opacity: .35; }

.rangee-lien {
  font-size: .78rem;
  color: var(--texte-doux);
  text-decoration: none;
  border-bottom: 1px dotted var(--bord);
  -webkit-touch-callout: none;
  user-select: none;
}
.rangee-lien:hover { color: var(--accent); }
.rangee-lien.copie { color: var(--accent); border-bottom-color: transparent; }

.rangee-cote { grid-area: cote; display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.rangee-lieu { font-size: .8rem; color: var(--texte-doux); }
.etoiles-lecture .moitie { cursor: default; width: 11px; height: 22px; }
.etoiles-lecture .moitie svg { width: 22px; height: 22px; }
.etoiles-lecture .moitie-d svg { left: -11px; }
.etoiles-vides { color: var(--texte-doux); font-size: .85rem; }

@media (max-width: 520px) {
  .rangee { grid-template-columns: 4.2rem auto 1fr auto; column-gap: .5rem; }
  .rangee-modifier { padding: .3rem; }
  .vignette { width: 52px; height: 78px; }
  .etoiles-lecture .moitie { width: 9px; height: 18px; }
  .etoiles-lecture .moitie svg { width: 18px; height: 18px; }
  .etoiles-lecture .moitie-d svg { left: -9px; }
}

.sentinelle { height: 1px; }

/* Formulaire d'ajout ----------------------------------------------------- */

#vue-ajout { max-width: 520px; margin: 0 auto; }

label { display: block; font-size: .8rem; color: var(--texte-doux); margin: .95rem 0 .25rem; font-weight: 600; }
.facultatif { font-weight: 400; }

#vue-ajout input[type=text] { width: 100%; }

.ligne { display: flex; gap: .8rem; }
.ligne > div { flex: 1; min-width: 0; }
.ligne input { width: 100%; }

.pied-formulaire { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.6rem; }

.suggestions {
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  margin-top: .35rem;
  overflow: hidden;
  background: var(--fond-carte);
}

.suggestion {
  display: flex; gap: .6rem; align-items: center; width: 100%;
  background: transparent; border: 0; border-bottom: 1px solid var(--bord);
  padding: .45rem .5rem; cursor: pointer; color: inherit; font: inherit; text-align: left;
}
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover { background: var(--fond-champ); }
.suggestion img, .suggestion-vide {
  width: 32px; height: 48px; object-fit: cover; border-radius: 4px; flex: none;
  background: var(--fond-champ); display: block;
}
.suggestion-meta { color: var(--texte-doux); font-size: .82rem; }

.choisi {
  display: flex; align-items: center; gap: .6rem;
  margin-top: .5rem; padding: .5rem .6rem;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: var(--rayon); font-size: .9rem;
}
.choisi img { width: 32px; height: 48px; object-fit: cover; border-radius: 4px; }
.choisi > span { flex: 1; }

.etoiles { display: inline-flex; gap: .05rem; }
.etoile { display: flex; }
.moitie {
  background: transparent; border: 0; padding: 0; cursor: pointer;
  width: 17px; height: 34px; overflow: hidden; color: var(--texte-doux);
  position: relative; display: block;
}
.moitie svg { width: 34px; height: 34px; display: block; position: absolute; top: 0; }
.moitie-g svg { left: 0; }
.moitie-d svg { left: -17px; }
.moitie.pleine { color: var(--accent); }

.note-libelle {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  margin: .4rem 0 0;
  min-height: 1.5em;
}
.erreur { color: var(--danger); font-size: .88rem; margin: .9rem 0 0; }

/* Modales ---------------------------------------------------------------- */

.modale {
  border: 1px solid var(--bord);
  border-radius: 14px;
  background: var(--fond-carte);
  color: var(--texte);
  padding: 1.3rem;
  width: min(600px, calc(100vw - 2rem));
  max-height: 88vh;
  overflow: auto;
}

.modale::backdrop { background: rgba(0, 0, 0, .6); }
.modale-pied { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.3rem; }

.fiche-haut { display: flex; gap: 1rem; }
.fiche-haut img { width: 120px; border-radius: 8px; flex: none; align-self: flex-start; }
.fiche-titre { font-size: 1.15rem; font-weight: 700; line-height: 1.25; }
.fiche-meta { color: var(--texte-doux); font-size: .87rem; margin-top: .2rem; }
.fiche-synopsis { font-size: .9rem; margin-top: .8rem; }
.fiche-liens { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.fiche-liens a {
  font-size: .82rem; text-decoration: none; color: var(--texte);
  border: 1px solid var(--bord); border-radius: var(--rayon); padding: .3rem .6rem;
}
.fiche-liens a:hover { border-color: var(--accent); }

.visionnages { margin-top: 1.2rem; border-top: 1px solid var(--bord); padding-top: .8rem; }
.visionnage {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto auto;
  gap: .6rem;
  align-items: center;
  padding: .4rem 0;
  font-size: .88rem;
  border-bottom: 1px solid var(--bord);
}
.visionnage:last-child { border-bottom: 0; }
.visionnage .date { font-variant-numeric: tabular-nums; }
.visionnage .lieu, .visionnage .note { color: var(--texte-doux); }

.modale-pied-reparti { justify-content: space-between; align-items: center; }
.pied-droite { display: flex; gap: .6rem; }

@media (max-width: 520px) {
  .fiche-haut { flex-direction: column; }
  .fiche-haut img { width: 96px; }
}

/* Films non reconnus ------------------------------------------------------ */

.explication { font-size: .88rem; color: var(--texte-doux); margin: -.6rem 0 1.2rem; }
.sous-titre-modale { margin: -.8rem 0 .4rem; }

.correction {
  border-top: 1px solid var(--bord);
  padding: .9rem 0;
}
.correction:first-child { border-top: 0; padding-top: 0; }

.correction-entete {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.correction-titre { font-weight: 600; }
.correction-meta { font-size: .8rem; color: var(--texte-doux); }
.correction-entete .lien-bouton { margin-left: auto; }

.correction-recherche { width: 100%; }

.correction-resultats {
  display: flex;
  flex-direction: column;
  margin-top: .4rem;
  max-height: 260px;
  overflow: auto;
}
.correction-resultats .suggestion { border-radius: 8px; border-bottom: 0; }
.correction-resultats .suggestion:disabled { opacity: .5; }
.correction-etat { font-size: .85rem; color: var(--texte-doux); margin: .5rem 0 0; }

/* Détail des statistiques ------------------------------------------------ */

.stats-resume { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1.3rem; }
.stats-chiffre { font-size: 1.45rem; font-weight: 700; }
.stats-libelle { font-size: .76rem; color: var(--texte-doux); }
.stats-titre { font-size: .8rem; color: var(--texte-doux); font-weight: 600; margin: 0 0 .5rem; }

.barres { display: grid; gap: .28rem; margin-bottom: 1.4rem; }
.barre-ligne { display: grid; grid-template-columns: 8.4rem 1fr 2.6rem; align-items: center; gap: .6rem; font-size: .84rem; }
.barre-piste { background: var(--fond-champ); border-radius: 4px; height: 15px; overflow: hidden; }
.barre-valeur { display: block; background: var(--accent); height: 100%; border-radius: 4px; }
.barre-nombre { text-align: right; color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.pied-stats { margin: 0; }

/* Page de connexion ------------------------------------------------------ */

.page-connexion main {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.bloc-connexion {
  width: min(340px, 100%);
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: 14px;
  padding: 1.6rem;
}

.bloc-connexion h1 { font-size: 1.2rem; margin: 0 0 1.2rem; cursor: default; }
.bloc-connexion input { width: 100%; margin-bottom: 1.2rem; }
.bloc-connexion .bouton { width: 100%; }
.bloc-connexion .erreur { margin: -.8rem 0 1rem; }
