:root {
  --fond: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --texte: #1c1b18;
  --texte-doux: #5f5c54;
  --bord: #dcd8cc;
  --accent: #9a7414;
  --accent-fond: #f6ecd0;
  --rouge: #b42318;
  --rouge-fond: #fde8e6;
  --orange: #9a5b00;
  --orange-fond: #fff1db;
  --vert: #1f7a3a;
  --vert-fond: #e3f4e8;
  --INT: #f2a7c3; --YTS: #f5a3a3; --TTK: #8fe3e0; --YTL: #f3c77a; --YTR: #c9b3f2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121210;
    --surface: #1c1b18;
    --surface-2: #26251f;
    --texte: #f1eee6;
    --texte-doux: #b3ae9f;
    --bord: #3a382f;
    --accent: #e8c24a;
    --accent-fond: #3a3018;
    --rouge: #ff8a7a;
    --rouge-fond: #3d1a16;
    --orange: #ffc266;
    --orange-fond: #3a2a12;
    --vert: #7fd69a;
    --vert-fond: #173322;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }

.entete {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--bord);
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .55rem 16px;
}
.marque { font-weight: 700; letter-spacing: .02em; color: var(--texte); text-decoration: none; }
.marque span { color: var(--accent); }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a {
  color: var(--texte-doux); text-decoration: none; padding: .3rem .6rem; border-radius: 8px;
}
.nav a[aria-current="page"], .nav a:hover { background: var(--accent-fond); color: var(--texte); }
.qui { color: var(--texte-doux); font-size: .9rem; display: flex; gap: .5rem; align-items: center; }

main { max-width: 1180px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 1rem;
  min-width: 0;
}
.carte h2:first-child, .carte h3:first-child { margin-top: 0; }
.doux { color: var(--texte-doux); }
.petit { font-size: .85rem; }

.flash { padding: .6rem .9rem; border-radius: 10px; margin-bottom: .8rem; }
.flash.ok { background: var(--vert-fond); color: var(--vert); }
.flash.erreur { background: var(--rouge-fond); color: var(--rouge); }

.alertes { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; }
.alertes li { padding: .55rem .8rem; border-radius: 10px; border-left: 4px solid; }
.alertes .rouge { background: var(--rouge-fond); border-color: var(--rouge); }
.alertes .orange { background: var(--orange-fond); border-color: var(--orange); }
.alertes a { color: inherit; }

.jour { border-top: 1px solid var(--bord); padding: .5rem 0; display: grid; grid-template-columns: 5.2rem 1fr; gap: .6rem; }
.jour:first-child { border-top: 0; }
.jour .date { font-weight: 600; color: var(--texte-doux); }
.jour.aujourdhui .date { color: var(--accent); }
.publi { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; padding: .15rem 0; }
.publi a { color: var(--texte); text-decoration: none; }
.publi a:hover { text-decoration: underline; }
.heure { font-variant-numeric: tabular-nums; color: var(--texte-doux); min-width: 2.9rem; }

.fmt {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  padding: .05rem .4rem; border-radius: 6px; color: #111;
}
.fmt.INT { background: var(--INT); } .fmt.YTS { background: var(--YTS); } .fmt.TTK { background: var(--TTK); }
.fmt.YTL { background: var(--YTL); } .fmt.YTR { background: var(--YTR); }

.etat {
  display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 999px;
  background: var(--surface-2); color: var(--texte-doux); white-space: nowrap;
}
.etat.validation { background: var(--orange-fond); color: var(--orange); }
.etat.pret { background: var(--accent-fond); color: var(--accent); }
.etat.programme { background: var(--vert-fond); color: var(--vert); }
.etat.publie, .etat.mesure { background: var(--vert); color: var(--surface); }
.etat.ecarte { text-decoration: line-through; }

.statut { font-size: .75rem; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-2); }
.statut.attente, .statut.bloque { background: var(--orange-fond); color: var(--orange); }
.statut.en_cours { background: var(--accent-fond); color: var(--accent); }
.statut.fait { background: var(--vert-fond); color: var(--vert); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { font-size: .8rem; color: var(--texte-doux); font-weight: 600; }
.table-defile { overflow-x: auto; }

form.ligne { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
label { display: grid; gap: .2rem; font-size: .85rem; color: var(--texte-doux); }
input, select, textarea {
  font: inherit; color: var(--texte); background: var(--surface); border: 1px solid var(--bord);
  border-radius: 8px; padding: .45rem .6rem; min-width: 0;
}
textarea { width: 100%; min-height: 4rem; }
button, .bouton {
  font: inherit; cursor: pointer; border: 1px solid var(--accent); background: var(--accent);
  color: #111; border-radius: 8px; padding: .45rem .9rem; font-weight: 600; text-decoration: none;
  display: inline-block;
}
button.secondaire { background: transparent; color: var(--texte); border-color: var(--bord); }
button.lien { background: none; border: 0; color: var(--texte-doux); padding: 0; font-weight: 400; text-decoration: underline; }

.connexion { max-width: 380px; margin: 8vh auto; }
.connexion form { display: grid; gap: .8rem; }

.historique { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.historique li { padding: .3rem 0; border-bottom: 1px dashed var(--bord); }
.controles { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; font-size: .9rem; }
.controles .ok::before { content: "✓ "; color: var(--vert); font-weight: 700; }
.controles .ko::before { content: "✗ "; color: var(--rouge); font-weight: 700; }
.controles .attente::before, .controles .manquant::before { content: "○ "; color: var(--texte-doux); }
.controles .manquant { color: var(--texte-doux); }

.jeton { font-family: ui-monospace, monospace; word-break: break-all; background: var(--surface-2); padding: .6rem; border-radius: 8px; }
.texte-source { white-space: pre-wrap; font-size: .85rem; color: var(--texte-doux); }
.filtres { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }

#calendrier { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: .6rem; }
.fc { --fc-border-color: var(--bord); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2);
      --fc-list-event-hover-bg-color: var(--surface-2); --fc-today-bg-color: var(--accent-fond);
      --fc-button-bg-color: var(--surface-2); --fc-button-border-color: var(--bord); --fc-button-text-color: var(--texte);
      --fc-button-active-bg-color: var(--accent); --fc-button-active-border-color: var(--accent);
      --fc-button-hover-bg-color: var(--accent-fond); --fc-button-hover-border-color: var(--bord); }
.fc .fc-toolbar-title { font-size: 1.1rem; }
.fc a { color: var(--texte); }

@media (max-width: 640px) {
  .jour { grid-template-columns: 1fr; gap: .2rem; }
  .masque-mobile { display: none; }
  .grille { grid-template-columns: 1fr; }
}
