/* ============================================================
   Mon annee scolaire — feuille de style unique
   Palette definie sur :root, surchargee en clair.
   ============================================================ */

:root {
  --fond:        #0b0d13;
  --fond-2:      #12151f;
  --carte:       #161a26;
  --carte-haut:  #1d2231;
  --bordure:     #262c3d;
  --texte:       #e8eaf2;
  --texte-2:     #98a0b8;
  --texte-3:     #646d85;
  --accent:      #6d7cff;
  --accent-doux: #6d7cff22;
  --vert:        #34d399;
  --orange:      #fbbf24;
  --rouge:       #f87171;
  --bleu:        #38bdf8;
  --rose:        #f472b6;
  --ombre:       0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --rayon:       16px;
  --rayon-s:     10px;
  --entete-h:    58px;
  --onglets-h:   50px;
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

html[data-theme="clair"] {
  --fond:        #f4f5fa;
  --fond-2:      #eceef6;
  --carte:       #ffffff;
  --carte-haut:  #f7f8fc;
  --bordure:     #e0e3ee;
  --texte:       #171a24;
  --texte-2:     #5c6478;
  --texte-3:     #8b93a8;
  --accent:      #4f5bd5;
  --accent-doux: #4f5bd518;
  --vert:        #059669;
  --orange:      #d97706;
  --rouge:       #dc2626;
  --bleu:        #0284c7;
  --rose:        #db2777;
  --ombre:       0 1px 2px rgba(20,25,50,.06), 0 8px 24px -14px rgba(20,25,50,.25);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="sombre"]) {
    --fond: #f4f5fa; --fond-2: #eceef6; --carte: #ffffff; --carte-haut: #f7f8fc;
    --bordure: #e0e3ee; --texte: #171a24; --texte-2: #5c6478; --texte-3: #8b93a8;
    --accent: #4f5bd5; --accent-doux: #4f5bd518;
    --vert: #059669; --orange: #d97706; --rouge: #dc2626; --bleu: #0284c7; --rose: #db2777;
    --ombre: 0 1px 2px rgba(20,25,50,.06), 0 8px 24px -14px rgba(20,25,50,.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--police);
  background: var(--fond);
  color: var(--texte);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------- Entete ---------------- */

.entete {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(var(--entete-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: color-mix(in srgb, var(--fond) 85%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--bordure);
}
.entete-gauche { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { font-size: 22px; line-height: 1; }
.entete h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sous-titre { font-size: 12px; color: var(--texte-2); }
.entete-droite { display: flex; gap: 4px; flex-shrink: 0; }

.btn-icone {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 9px;
  color: var(--texte-2); font-size: 17px; cursor: pointer;
  transition: background .15s, color .15s, transform .3s;
}
.btn-icone:hover { background: var(--carte-haut); color: var(--texte); }
.btn-icone.tourne { transform: rotate(360deg); }

/* ---------------- Onglets ---------------- */

.onglets {
  position: sticky; top: calc(var(--entete-h) + env(safe-area-inset-top)); z-index: 39;
  display: flex; gap: 4px; padding: 8px 12px;
  overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--fond) 85%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--bordure);
}
.onglets::-webkit-scrollbar { display: none; }
.onglet {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 13px; border: 0; border-radius: 999px;
  background: transparent; color: var(--texte-2);
  font-size: 13.5px; font-weight: 550; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s;
}
.onglet:hover { background: var(--carte-haut); color: var(--texte); }
.onglet[aria-current="page"] { background: var(--accent); color: #fff; }
.onglet .pastille {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--rouge); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.onglet[aria-current="page"] .pastille { background: rgba(255,255,255,.28); }

/* ---------------- Mise en page ---------------- */

.vue { padding: 16px 16px 80px; max-width: 1280px; margin: 0 auto; }

.grille {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
.grille-large { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.col-2 { grid-column: span 2; }
@media (max-width: 560px) { .col-2 { grid-column: span 1; } }

.section { margin-bottom: 26px; }
.section-titre {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.section-titre h2 { font-size: 15px; color: var(--texte); }
.section-titre .lien { font-size: 12.5px; color: var(--accent); cursor: pointer; background: none; border: 0; }

/* ---------------- Cartes ---------------- */

.carte {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 15px;
  box-shadow: var(--ombre);
}
.carte-titre {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .05em; color: var(--texte-3); margin-bottom: 10px;
}
.carte-cliquable { cursor: pointer; transition: transform .12s, border-color .15s; }
.carte-cliquable:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 45%, var(--bordure)); }

.chiffre { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.chiffre-s { font-size: 21px; font-weight: 680; letter-spacing: -0.02em; }
.unite { font-size: 14px; font-weight: 500; color: var(--texte-3); }
.legende { font-size: 12px; color: var(--texte-2); margin-top: 5px; }

.vide {
  padding: 28px 16px; text-align: center; color: var(--texte-3); font-size: 13.5px;
  border: 1px dashed var(--bordure); border-radius: var(--rayon);
}

/* ---------------- Etiquettes & badges ---------------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--carte-haut); color: var(--texte-2);
}
.tag-matiere { color: #fff; }
.tag.vert   { background: color-mix(in srgb, var(--vert) 18%, transparent);   color: var(--vert); }
.tag.orange { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.tag.rouge  { background: color-mix(in srgb, var(--rouge) 18%, transparent);  color: var(--rouge); }
.tag.bleu   { background: color-mix(in srgb, var(--bleu) 18%, transparent);   color: var(--bleu); }

.point { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.vert-t { color: var(--vert); } .rouge-t { color: var(--rouge); }
.orange-t { color: var(--orange); } .doux { color: var(--texte-2); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------- Boutons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border: 1px solid var(--bordure); border-radius: var(--rayon-s);
  background: var(--carte-haut); color: var(--texte);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--bordure); }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primaire:hover { background: color-mix(in srgb, var(--accent) 85%, #000); }
.btn-danger { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 35%, var(--bordure)); }
.btn-fantome { background: transparent; border-color: transparent; color: var(--texte-2); }
.btn-petit { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.barre-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.pousse-droite { margin-left: auto; }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30;
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 26px; line-height: 1;
  box-shadow: 0 6px 20px -4px color-mix(in srgb, var(--accent) 60%, transparent);
  cursor: pointer;
}

/* ---------------- Formulaires ---------------- */

input, select, textarea {
  width: 100%; padding: 9px 11px;
  background: var(--fond-2); border: 1px solid var(--bordure);
  border-radius: var(--rayon-s); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux);
}
textarea { min-height: 90px; resize: vertical; font-family: inherit; }
label.champ { display: block; margin-bottom: 12px; }
label.champ > span { display: block; font-size: 12px; font-weight: 600; color: var(--texte-2); margin-bottom: 5px; }
.champs-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .champs-2 { grid-template-columns: 1fr; gap: 0; } }
.case { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; font-size: 13.5px; }
.case input { width: auto; }

/* ---------------- Listes ---------------- */

.liste { display: flex; flex-direction: column; gap: 8px; }
.ligne {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; background: var(--carte);
  border: 1px solid var(--bordure); border-left-width: 3px; border-radius: var(--rayon-s);
}
.ligne-corps { flex: 1; min-width: 0; }
.ligne-titre { font-size: 14px; font-weight: 570; }
.ligne-meta { font-size: 12px; color: var(--texte-2); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 8px; }
.ligne.fait .ligne-titre { text-decoration: line-through; color: var(--texte-3); }
.ligne-actions { display: flex; gap: 2px; flex-shrink: 0; }

.coche {
  width: 21px; height: 21px; flex-shrink: 0; border-radius: 7px;
  border: 2px solid var(--texte-3); background: transparent; cursor: pointer;
  display: grid; place-items: center; color: transparent; font-size: 13px; padding: 0;
}
.coche.ok { background: var(--vert); border-color: var(--vert); color: #fff; }

/* ---------------- Barres de progression ---------------- */

.barre { height: 6px; border-radius: 3px; background: var(--bordure); overflow: hidden; }
.barre > div { height: 100%; border-radius: 3px; transition: width .35s ease; }

/* ---------------- Emploi du temps ---------------- */

.edt-entete {
  display: grid; gap: 1px; position: sticky;
  top: calc(var(--entete-h) + var(--onglets-h) + env(safe-area-inset-top)); z-index: 20;
  background: var(--fond); padding-bottom: 4px;
}
.edt-jour-nom { text-align: center; padding: 7px 2px; font-size: 12px; font-weight: 600; color: var(--texte-2); }
.edt-jour-nom.today { color: var(--accent); }
.edt-jour-nom b { display: block; font-size: 16px; color: var(--texte); }
.edt-jour-nom.today b { color: var(--accent); }

.edt-grille { display: grid; gap: 1px; position: relative; }
.edt-heures { position: relative; }
.edt-heure {
  position: absolute; right: 6px; transform: translateY(-50%);
  font-size: 10.5px; color: var(--texte-3); font-variant-numeric: tabular-nums;
}
.edt-colonne { position: relative; border-left: 1px solid var(--bordure); }
.edt-colonne.today { background: var(--accent-doux); }
.edt-trait { position: absolute; left: 0; right: 0; border-top: 1px solid var(--bordure); opacity: .5; }

.edt-cours {
  position: absolute; left: 2px; right: 2px; overflow: hidden;
  border-radius: 8px; padding: 5px 7px; cursor: pointer;
  font-size: 11px; line-height: 1.25; color: #fff;
  border-left: 3px solid rgba(255,255,255,.5);
}
.edt-cours b { display: block; font-size: 11.5px; font-weight: 650; }
.edt-cours .salle { opacity: .85; font-size: 10.5px; }
.edt-cours.annule { opacity: .45; text-decoration: line-through; }

.edt-maintenant { position: absolute; left: 0; right: 0; height: 2px; background: var(--rouge); z-index: 5; }
.edt-maintenant::before {
  content: ''; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--rouge);
}

/* Vue liste (mobile) */
.edt-liste-jour { margin-bottom: 18px; }
.edt-liste-jour h3 { font-size: 13px; color: var(--texte-2); margin-bottom: 8px; text-transform: capitalize; }

/* ---------------- Graphiques ---------------- */

.sparkline { width: 100%; height: 34px; display: block; overflow: hidden; }
.graph { width: 100%; height: 190px; display: block; }
.anneau { transform: rotate(-90deg); }
.anneau circle { fill: none; stroke-linecap: round; }

/* ---------------- Flashcards ---------------- */

.carte-revision {
  min-height: 210px; display: grid; place-items: center; text-align: center;
  padding: 30px 22px; font-size: 19px; line-height: 1.45; cursor: pointer;
  user-select: none;
}
.carte-revision .verso { color: var(--vert); }
.revision-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ---------------- Modale ---------------- */

.fond-modale {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  display: grid; place-items: end center;
  padding: 0;
}
@media (min-width: 640px) { .fond-modale { place-items: center; padding: 20px; } }
.modale {
  width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--carte); border: 1px solid var(--bordure);
  border-radius: var(--rayon) var(--rayon) 0 0;
  animation: monte .22s ease;
}
@media (min-width: 640px) { .modale { border-radius: var(--rayon); } }
@keyframes monte { from { transform: translateY(18px); opacity: 0; } }
.modale-entete {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px 11px; border-bottom: 1px solid var(--bordure);
}
.modale-entete h2 { font-size: 16px; }
.modale-corps { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modale-pied {
  display: flex; gap: 9px; justify-content: flex-end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--bordure);
}

/* ---------------- Toasts ---------------- */

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  padding: 10px 16px; border-radius: 999px;
  background: var(--texte); color: var(--fond);
  font-size: 13px; font-weight: 550; box-shadow: var(--ombre);
  animation: monte .2s ease;
}
.toast.erreur { background: var(--rouge); color: #fff; }

/* ---------------- Chargement ---------------- */

.ecran-chargement {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: var(--fond); transition: opacity .3s;
}
.ecran-chargement.parti { opacity: 0; pointer-events: none; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--bordure); border-top-color: var(--accent);
  animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

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

.page-connexion { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.carte-connexion { width: 100%; max-width: 340px; text-align: center; display: grid; gap: 12px; }
.logo-connexion { font-size: 40px; }
.carte-connexion h1 { font-size: 19px; }
.erreur { color: var(--rouge); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
