:root {
  --fond: #f5f6fa;
  --carte: #ffffff;
  --texte: #1c2033;
  --doux: #666c82;
  --bord: #e3e5ee;
  --accent: #4f5bd5;
  --sur-accent: #ffffff;
  --danger: #c8323f;
  --ok: #30a46c;
  --alerte: #d98200;
  --rayon: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #14161f;
    --carte: #1e2130;
    --texte: #eceef6;
    --doux: #a0a6bd;
    --bord: #303449;
    --accent: #98a1ff;
    --sur-accent: #14161f;
    --danger: #ff7a85;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Mise en page : menu en bas sur téléphone, à gauche sur grand écran */

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px calc(84px + env(safe-area-inset-bottom));
}

nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  background: var(--carte);
  border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom);
}

nav a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px 6px;
  color: var(--doux);
  text-decoration: none;
  font-size: 11px;
}

nav a.actif { color: var(--accent); font-weight: 600; }
nav .ico { position: relative; font-size: 20px; line-height: 1; filter: grayscale(0.6); }
nav a.actif .ico { filter: none; }
nav .ico .voyant { position: absolute; top: -2px; right: -8px; }

@media (min-width: 860px) {
  nav {
    inset: 0 auto 0 0;
    width: 200px;
    flex-direction: column;
    gap: 4px;
    padding: 20px 10px;
    border-top: 0;
    border-right: 1px solid var(--bord);
  }
  nav a { flex: none; flex-direction: row; gap: 12px; padding: 10px 12px; font-size: 15px; border-radius: 10px; }
  nav a.actif { background: var(--fond); }
  main { margin-left: 200px; padding: 24px 32px 40px; }
}

/* Titres et cartes */

.entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.entete h1 { margin: 0; font-size: 26px; }
.sous-titre { margin: -6px 0 12px; }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.carte.auj { border-color: var(--accent); }
.carte h2, .modal h2 { margin: 0; font-size: 16px; }
.carte > h2 { margin-bottom: 6px; }
.carte-tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.carte > p { margin: 6px 0; }
.bienvenue .btn { margin-top: 4px; }

.doux { color: var(--doux); }
.retard { color: var(--danger); }
.vide { color: var(--doux); margin: 6px 0; }
.pied { margin: 8px 0 2px; }
.grandit { flex: 1; min-width: 0; }
.centre { text-align: center; }

/* Lignes de liste */

.ligne {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 6px 0;
  border: 0;
  border-top: 1px solid var(--bord);
  background: none;
  text-align: left;
}

.carte > .ligne:first-child, .carte > h2 + .ligne, .carte-tete + .ligne, summary + .ligne { border-top: 0; }

.ligne.evt { border-left: 4px solid var(--c); padding-left: 10px; border-top: 0; margin-top: 6px; border-radius: 4px; }
.ligne .heure { width: 62px; flex: none; color: var(--doux); font-size: 13px; }
.ligne.evt .heure { width: 96px; }
.ligne.fait .texte span { text-decoration: line-through; color: var(--doux); }
.ligne input[type="checkbox"] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }

.texte { display: flex; flex-direction: column; border: 0; background: none; padding: 4px 0; text-align: left; overflow-wrap: anywhere; }
.texte small { color: var(--doux); }

.pastilles { display: flex; gap: 3px; }
.pastille {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.voyant { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--alerte); }
.voyant.ok { background: var(--ok); }
.voyant.erreur { background: var(--danger); }

/* Boutons */

.btn {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: var(--carte);
  font-weight: 600;
  white-space: nowrap;
}

.btn.principal { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.btn.danger { color: var(--danger); }
.btn.large { width: 100%; margin-top: 4px; }

.icone { width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; font-size: 22px; line-height: 1; }
.icone:hover, .btn:hover, .puce:hover { filter: brightness(0.96); }
.lien { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px; }

.puce {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 12px;
  border: 1px solid var(--bord);
  border-radius: 999px;
  background: var(--carte);
  white-space: nowrap;
}

.puce.active { border-color: var(--accent); background: var(--accent); color: var(--sur-accent); }

.barre { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.barre.defile { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.choix { display: flex; flex-wrap: wrap; gap: 8px; }

.couleur { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--carte); }
.couleur.active { box-shadow: 0 0 0 3px var(--texte); }

/* Formulaires */

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--bord);
  border-radius: 10px;
  background: var(--carte);
}

textarea { resize: vertical; }

.ajout { display: flex; gap: 8px; margin-bottom: 12px; }
.champ { display: block; margin-bottom: 12px; }
.champ > span { display: block; margin-bottom: 4px; font-size: 14px; color: var(--doux); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.case { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; }
.case input { width: 22px; height: 22px; accent-color: var(--accent); }
.actions { display: flex; gap: 8px; margin-top: 16px; }

details.carte summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details.carte .btn { margin-top: 8px; }

/* Calendrier */

.grille-mois { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 8px; }
.jour-nom { text-align: center; font-size: 12px; color: var(--doux); padding: 4px 0; }

.jour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 48px;
  padding: 5px 0;
  border: 0;
  border-radius: 10px;
  background: none;
}

.jour.hors { color: var(--doux); opacity: 0.55; }
.jour .num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; }
.jour.auj .num { color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent); }
.jour.choisi .num { background: var(--accent); color: var(--sur-accent); box-shadow: none; }
.points { display: flex; gap: 2px; height: 6px; }
.points i { width: 6px; height: 6px; border-radius: 50%; }

/* Fenêtres et messages */

.modal-fond {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 12, 24, 0.5);
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--carte);
  border-radius: 18px 18px 0 0;
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom));
}

.modal-tete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal h2 { font-size: 18px; }

@media (min-width: 600px) {
  .modal-fond { align-items: center; }
  .modal { border-radius: 18px; }
}

#toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast { max-width: 90%; padding: 10px 16px; border-radius: 999px; background: var(--texte); color: var(--fond); font-size: 14px; }
