/* Tempo — spec §4 : français simple, 18 px minimum, interlignage 1,5, police système, contraste AA,
   boutons de 48 px, mode sombre selon le système. Aucune action cachée dans un geste. */
:root {
  --fond: #f6f7fb;
  --carte: #ffffff;
  --texte: #16202e;
  --texte-2: #4b5565;
  --bord: #d9dee8;
  --accent: #1d4ed8;
  --accent-texte: #ffffff;
  --ok: #15803d;
  --ok-texte: #ffffff;
  --attention: #b45309;
  --attention-fond: #fef3c7;
  --refus: #b91c1c;
  --refus-fond: #fee2e2;
  --gris: #e5e8ef;
  --gris-2: #c9cfdb;
  --maintenant: #dc2626;
  --ombre: 0 2px 10px rgba(20, 30, 50, 0.08);
  --rayon: 14px;
  --nav: 64px;
  --panneau: 236px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0b1220;
    --carte: #151e2e;
    --texte: #eef2f8;
    --texte-2: #a9b4c6;
    --bord: #2a3547;
    --accent: #60a5fa;
    --accent-texte: #0b1220;
    --ok: #4ade80;
    --ok-texte: #0b1220;
    --attention: #fbbf24;
    --attention-fond: #3b2f0a;
    --refus: #f87171;
    --refus-fond: #3f1414;
    --gris: #202b3d;
    --gris-2: #334155;
    --ombre: 0 2px 10px rgba(0, 0, 0, 0.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--fond); color: var(--texte); }
body {
  font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
p { margin: 0 0 8px; }
.noscript { padding: 24px; }
.sr { position: absolute; left: -9999px; }

/* Boutons */
.btn {
  min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 2px solid var(--bord);
  background: var(--carte); color: var(--texte); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--ok-texte); }
.btn.discret { border-color: transparent; background: transparent; color: var(--accent); }
.btn.large { width: 100%; font-size: 20px; min-height: 56px; }
.btn.rond { width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 22px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns > .btn { flex: 1; }

/* Entêtes et navigation */
.entete { padding: max(12px, env(safe-area-inset-top)) 16px 10px; background: var(--carte); border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 5; }
.entete .ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.entete .sous { color: var(--texte-2); font-size: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.entete .fin-prevue { font-weight: 700; color: var(--texte); }
.entete .btn { white-space: nowrap; }
.entete .lien-jour { min-height: 48px; padding: 0 8px; margin-left: auto; }
.entete h1 { font-size: 21px; flex: 1; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--carte); border-top: 1px solid var(--bord); z-index: 6; }
.nav button { flex: 1; border: 0; background: transparent; color: var(--texte-2); font-size: 16px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.nav button .ico { font-size: 22px; }
.nav button.actif { color: var(--accent); }
.contenu { flex: 1; padding: 16px; padding-bottom: calc(var(--nav) + 24px + env(safe-area-inset-bottom)); }

/* Bandeaux */
#bandeaux { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; flex-direction: column; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 12px 0; pointer-events: none; }
.bandeau { pointer-events: auto; padding: 12px 16px; border-radius: 12px; background: var(--carte); color: var(--texte); box-shadow: var(--ombre); border: 1px solid var(--bord); font-weight: 600; }
.bandeau.attention { background: var(--attention-fond); color: var(--attention); border-color: transparent; }
.bandeau.refus { background: var(--refus-fond); color: var(--refus); border-color: transparent; }
.bandeau.ok { background: var(--carte); color: var(--ok); }
.avertissement { padding: 10px 16px; background: var(--attention-fond); color: var(--attention); font-weight: 600; }

/* Aujourd'hui : colonne horaire */
.aujourdhui { display: flex; flex-direction: column; height: 100dvh; }
.colonne-cadre { flex: 1; overflow-y: auto; position: relative; background: var(--fond); }
.colonne { position: relative; margin-left: 56px; margin-right: 12px; border-left: 1px solid var(--bord); }
.heure-label { position: absolute; left: -56px; width: 48px; text-align: right; font-size: 14px; color: var(--texte-2); transform: translateY(-50%); }
.heure-trait { position: absolute; left: 0; right: 0; border-top: 1px solid var(--bord); }
.plage { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.contrainte { position: absolute; left: 6px; right: 6px; background: var(--gris); color: var(--texte-2); border-radius: 8px; padding: 2px 10px; font-size: 15px; overflow: hidden; }
.contrainte .trajet { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, var(--gris-2) 6px 10px); opacity: 0.8; }
.contrainte .trajet.haut { top: 0; }
.contrainte .trajet.bas { bottom: 0; }
.contrainte .titre { position: relative; z-index: 1; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.libre { position: absolute; left: 12px; right: 12px; display: flex; align-items: center; justify-content: center; color: var(--texte-2); font-size: 15px; }
.carte-bloc {
  position: absolute; left: 6px; right: 6px; border-radius: 10px; background: var(--carte); border: 1px solid var(--bord); border-left: 6px solid var(--couleur, var(--accent));
  padding: 2px 10px; overflow: hidden; display: flex; align-items: center; gap: 8px; box-shadow: var(--ombre); text-align: left; font-size: 18px; line-height: 1.25; color: var(--texte);
}
.carte-bloc.selection { outline: 3px solid var(--accent); outline-offset: 1px; }
.carte-bloc.fait, .carte-bloc.reporte, .carte-bloc.non_valide { opacity: 0.7; }
.carte-bloc.en_cours { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--carte)); }
.carte-bloc .titre { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.carte-bloc .duree { color: var(--texte-2); font-size: 15px; white-space: nowrap; }
.carte-bloc .etat { font-size: 16px; }
.maintenant { position: absolute; left: -8px; right: 0; border-top: 2px solid var(--maintenant); z-index: 3; }
.maintenant::before { content: ""; position: absolute; left: 0; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--maintenant); }

/* Panneau du bloc actif */
.panneau { background: var(--carte); border-top: 1px solid var(--bord); padding: 12px 16px calc(12px + env(safe-area-inset-bottom) + var(--nav)); box-shadow: 0 -4px 16px rgba(0,0,0,0.06); }
.panneau .matiere { display: inline-block; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--couleur, var(--accent)); }
.panneau .titre-ligne { display: flex; align-items: flex-start; gap: 8px; }
.panneau .titre-ligne h2 { flex: 1; }
.panneau .consigne { color: var(--texte-2); margin: 4px 0 8px; }
.panneau .etat-ligne { color: var(--texte-2); margin-bottom: 8px; }
.panneau .duree-ligne { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.panneau select { min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--bord); background: var(--carte); font-weight: 600; }
.cadenas { font-size: 16px; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre); margin-bottom: 12px; }
.carte.ok { border-color: var(--ok); }
.carte.attention { background: var(--attention-fond); color: var(--attention); border-color: transparent; }
.gris { color: var(--texte-2); }
.petit { font-size: 18px; }
.etiquette { font-size: 15px; }

/* Bloc en cours : plein écran */
.bloc-plein { min-height: 100dvh; display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.bloc-plein .haut { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bloc-plein .consigne-grande { font-size: 22px; margin: 8px 0 16px; }
.disque { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 8px 0 20px; }
.disque svg { width: 200px; height: 200px; transform: rotate(-90deg); }
.disque .fond { stroke: var(--gris); }
.disque .reste { stroke: var(--accent); transition: stroke-dashoffset 1s linear; }
.disque .chiffres { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: -130px; height: 130px; display: flex; align-items: center; }
.disque .legende { color: var(--texte-2); }
.bloc-plein .bas { margin-top: auto; display: grid; gap: 10px; }

/* Feuille basse (Signaler) et fenêtre (changements) */
.voile { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 30; display: flex; align-items: flex-end; }
.feuille { background: var(--carte); width: 100%; max-height: 92dvh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.feuille .poignee { width: 44px; height: 5px; border-radius: 3px; background: var(--gris-2); margin: 0 auto 12px; }
.feuille h2 { margin-bottom: 10px; }
.champ { display: block; margin-bottom: 12px; }
.champ span { display: block; font-weight: 600; margin-bottom: 4px; }
.champ input, .champ select { width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--bord); background: var(--carte); }
.puces { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.puce { min-height: 48px; padding: 6px 14px; border-radius: 22px; border: 2px solid var(--bord); background: var(--carte); font-weight: 600; }
.puce.actif { border-color: var(--accent); color: var(--accent); }
.liste { list-style: none; margin: 0 0 12px; padding: 0; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--bord); }
.liste li .texte { flex: 1; }
.fenetre { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.fenetre .boite { background: var(--carte); border-radius: var(--rayon); padding: 20px; width: 100%; max-width: 420px; max-height: 85dvh; overflow-y: auto; }
.fenetre .boite .haut, .feuille .haut { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fenetre .boite .haut h2, .feuille .haut h2 { margin: 0; }
.changements { list-style: none; padding: 0; margin: 8px 0 16px; }
.changements li { padding: 8px 0; border-bottom: 1px solid var(--bord); }

/* Connexion */
.connexion { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 14px; max-width: 420px; margin: 0 auto; }
.connexion input { font-size: 32px; letter-spacing: 0.3em; text-align: center; min-height: 64px; border-radius: 14px; border: 2px solid var(--bord); background: var(--carte); width: 100%; }
.erreur { color: var(--refus); font-weight: 600; }

/* Suivi */
.journal { list-style: none; padding: 0; margin: 0; }
.journal li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--bord); }
.journal .heure { color: var(--texte-2); font-variant-numeric: tabular-nums; min-width: 56px; }
.vignettes { display: flex; gap: 8px; flex-wrap: wrap; }
.vignettes img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--bord); }
.photo-pleine { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; align-items: center; justify-content: center; }
.photo-pleine .fermer { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; background: #fff; color: #000; }
.photo-pleine img { max-width: 100%; max-height: 100%; }
.code-grand { font-size: 40px; letter-spacing: 0.2em; font-weight: 700; text-align: center; margin: 12px 0; font-variant-numeric: tabular-nums; }
.apercu { width: 100%; max-height: 40dvh; object-fit: contain; border-radius: 12px; background: #000; }
