/* Times — pensé d'abord pour le téléphone d'un parent. Couleurs en variables, thème sombre automatique. */

:root {
  --fond: #f4f2ef;
  --carte: #ffffff;
  --texte: #1c1b1f;
  --doux: #66646b;
  --bord: #e3e0db;
  --accent: #d62d3a;
  --accent-fonce: #b0202c;
  --vert: #1d8a4e;
  --vert-fond: #e3f4ea;
  --orange: #b45f06;
  --orange-fond: #fcefdc;
  --rouge: #c0262d;
  --rouge-fond: #fbe4e4;
  --gris-fond: #ecebe8;
  --ombre: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .05);
  --rayon: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121114;
    --carte: #1d1c21;
    --texte: #f1eff4;
    --doux: #a19ea8;
    --bord: #302e35;
    --accent: #ff5864;
    --accent-fonce: #ff7b85;
    --vert: #4cc884;
    --vert-fond: #173524;
    --orange: #f0a347;
    --orange-fond: #3a2a14;
    --rouge: #ff6b6f;
    --rouge-fond: #3d1a1c;
    --gris-fond: #2a2930;
    --ombre: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 0; }
h4 { font-size: .95rem; margin: 0 0 .5rem; }
code { font-size: .9em; background: var(--gris-fond); padding: .1em .35em; border-radius: 6px; word-break: break-all; }

/* ---------- Barre du haut ---------- */

.barre {
  position: sticky; top: 0; z-index: 10;
  background: var(--carte);
  border-bottom: 1px solid var(--bord);
  padding: .5rem max(16px, env(safe-area-inset-left)) 0;
}
.marque {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.15rem; color: var(--texte); text-decoration: none;
  padding-bottom: .4rem;
}
.menu {
  display: flex; gap: .25rem; align-items: center;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px .4rem;
}
.menu::-webkit-scrollbar { display: none; }
.menu a, .lien-menu {
  flex: none;
  color: var(--doux); text-decoration: none; font: inherit; font-size: .95rem;
  padding: .45rem .75rem; border-radius: 999px; border: 0; background: none; cursor: pointer;
}
.menu a[aria-current="page"] { background: var(--texte); color: var(--carte); }
.menu form { margin-left: auto; flex: none; }

@media (min-width: 760px) {
  .barre { display: flex; align-items: center; gap: 1.5rem; padding-bottom: .5rem; }
  .marque { padding-bottom: 0; }
  .menu { flex: 1; margin: 0; padding: 0; }
}

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

.page { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 4rem; }
.fil { margin: 0 0 .5rem; }
.fil a { text-decoration: none; color: var(--doux); }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1rem;
  margin-bottom: 1rem;
}
.carte-etroite { max-width: 420px; margin: 2rem auto; }
.carte-inactive { opacity: .6; }
.carte.vide { text-align: left; }
.carte-lien { display: flex; gap: .9rem; align-items: center; color: inherit; text-decoration: none; }
.carte-lien:hover { border-color: var(--doux); }

.grille-cartes, .grille-consoles { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .grille-cartes, .grille-consoles { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
}

.aide { color: var(--doux); font-size: .9rem; }
.emoji { font-style: normal; }
.emoji.grand { font-size: 2.2rem; line-height: 1; }

/* ---------- Enfants ---------- */

.enfant { margin-bottom: 1.6rem; }
.enfant > h2 {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.3rem;
  padding-left: .6rem;
  border-left: 5px solid var(--couleur, var(--accent));
}
.enfant-carte { border-left: 6px solid var(--couleur, var(--accent)); }
.enfant-infos { display: flex; flex-direction: column; gap: .1rem; }

/* ---------- Carte d'une console ---------- */

.console {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1rem;
  margin-bottom: 1rem;
  transition: opacity .2s;
}
.grille-consoles .console { margin-bottom: 0; }
.console.occupee { opacity: .55; pointer-events: none; }
.console-tete { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.console-tete .sous { color: var(--doux); font-size: .85rem; }
.btn-icone {
  border: 1px solid var(--bord); background: var(--carte); color: var(--doux);
  width: 2.4rem; height: 2.4rem; border-radius: 50%; font-size: 1.15rem; cursor: pointer; flex: none;
}
.console.occupee .btn-icone { animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

.reste { display: flex; flex-direction: column; margin: .7rem 0 .5rem; }
.reste strong { font-size: 2.1rem; line-height: 1.1; letter-spacing: -.02em; }
.reste span { color: var(--doux); font-size: .92rem; }
.reste-ok strong { color: var(--vert); }
.reste-bas strong { color: var(--orange); }
.reste-fini strong, .reste-bloque strong { color: var(--rouge); }
.reste-libre strong { color: var(--texte); }

.jauge { height: 10px; background: var(--gris-fond); border-radius: 99px; overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--vert); border-radius: 99px; }
.jauge-pleine span { background: var(--rouge); }

.chiffres { margin: .55rem 0 0; font-size: .92rem; color: var(--doux); }
.chiffres b { color: var(--texte); font-weight: 600; }

.pastilles { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0 0; padding: 0; }
.pastilles:empty { display: none; }
.pastilles li { font-size: .8rem; padding: .2rem .6rem; border-radius: 99px; background: var(--gris-fond); color: var(--doux); }
.pastilles .p-orange { background: var(--orange-fond); color: var(--orange); }
.pastilles .p-vert { background: var(--vert-fond); color: var(--vert); }
.pastilles .p-rouge { background: var(--rouge-fond); color: var(--rouge); }

.chargement { color: var(--doux); margin: 1rem 0; }
.erreur-carte { color: var(--rouge); background: var(--rouge-fond); padding: .6rem .8rem; border-radius: 10px; margin: .8rem 0 .4rem; font-size: .92rem; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.actions:empty { display: none; }
/* Boutons rapides du tableau de bord : sur une seule ligne, même sur un petit téléphone. */
.actions-rapides { flex-wrap: nowrap; gap: .4rem; }
.actions-rapides form { flex: 1 1 0; min-width: 0; }
.actions-rapides .btn { width: 100%; padding: .5rem .2rem; font-size: .9rem; }
.actions form { margin: 0; }

.bloc-actions { border-top: 1px solid var(--bord); margin-top: 1rem; padding-top: .9rem; }
.bloc-actions .actions { margin-top: 0; }
.bloc-actions .aide { margin: .5rem 0 0; }
.bloc-actions > form + form, .bloc-actions .ligne-form + form { margin-top: .6rem; }

.lien-details { display: inline-block; margin-top: .9rem; font-size: .92rem; text-decoration: none; }

.sous-titre { margin: .4rem 0 .1rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--doux); }
.liste-jeux { list-style: none; margin: 0 0 .5rem; padding: 0; }
.liste-jeux li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; }
.liste-jeux img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; background: var(--gris-fond); }
.liste-jeux span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.75rem; padding: .5rem 1rem;
  border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: progress; }
.btn-plein { background: var(--accent); color: #fff; }
.btn-plein:hover { background: var(--accent-fonce); }
.btn-vert { background: var(--vert-fond); color: var(--vert); }
.btn-orange { background: var(--orange-fond); color: var(--orange); }
.btn-rouge { background: var(--rouge-fond); color: var(--rouge); }
.btn-discret { background: var(--carte); color: var(--texte); border-color: var(--bord); white-space: normal; text-align: left; }
.btn-vert:hover, .btn-orange:hover, .btn-rouge:hover, .btn-discret:hover { filter: brightness(.96); }

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

.formulaire { display: flex; flex-direction: column; gap: .9rem; }
.formulaire label, .ligne-form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .92rem; }
.formulaire small, .ligne-form small { font-weight: 400; color: var(--doux); }
.ligne-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin: .6rem 0; }
.ligne-form label { flex: 1 1 220px; }

input, select, textarea {
  font: inherit; font-weight: 400; color: var(--texte);
  background: var(--fond); border: 1px solid var(--bord); border-radius: 10px;
  padding: .65rem .75rem; min-height: 2.75rem; width: 100%;
}
input[type="radio"], input[type="checkbox"] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

.choix { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.choix legend { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; padding: 0; }
.choix label { cursor: pointer; }
.choix input { position: absolute; opacity: 0; }
.choix-emoji span {
  display: grid; place-items: center; width: 2.6rem; height: 2.6rem; font-size: 1.4rem;
  border-radius: 12px; border: 2px solid var(--bord); background: var(--carte);
}
.choix-couleur span { display: block; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--couleur); border: 3px solid var(--carte); box-shadow: 0 0 0 1px var(--bord); }
.choix input:checked + span { border-color: var(--texte); }
.choix-couleur input:checked + span { box-shadow: 0 0 0 3px var(--texte); }
.choix input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.choix-liste { border: 1px solid var(--bord); border-radius: 10px; padding: .6rem .8rem; display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.choix-liste legend { font-weight: 600; font-size: .92rem; padding: 0 .3rem; }
.choix-liste label { flex-direction: row; align-items: center; font-weight: 400; gap: .4rem; }

details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-top: .4rem; }

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

.liste-simple { padding-left: 1.1rem; margin: .3rem 0; }
.liste-simple li { margin: .25rem 0; }
.liste-reglages { list-style: none; padding: 0; margin: 0; }
.liste-reglages li { border-bottom: 1px solid var(--bord); padding: .7rem 0; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
.liste-reglages li > div { flex: 1 1 100%; }
.ligne-titre { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ligne-titre > form { margin-left: auto; }
.btn-petit { min-height: 2.2rem; padding: .3rem .75rem; font-size: .85rem; }
.liste-reglages .ligne-form { flex: 1; margin: 0; }

.journal { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.journal li { display: grid; grid-template-columns: auto 1fr; gap: 0 .7rem; padding: .5rem 0; border-bottom: 1px solid var(--bord); }
.journal time { color: var(--doux); font-variant-numeric: tabular-nums; }
.journal .qui { font-weight: 600; }
.journal li > span:last-child { grid-column: 1 / -1; }
.journal-echec > span:last-child { color: var(--rouge); }

.etapes ol { padding-left: 1.2rem; }
.etapes li { margin-bottom: 1.2rem; }
.etapes li p { margin: 0 0 .5rem; }

.zone-danger { margin-top: 2rem; }

/* ---------- Messages ---------- */

.flash { padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .95rem; }
.flash-ok { background: var(--vert-fond); color: var(--vert); }
.flash-erreur { background: var(--rouge-fond); color: var(--rouge); }

.toast {
  position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  padding: .85rem 1rem; border-radius: 14px;
  background: var(--texte); color: var(--carte);
  box-shadow: 0 8px 30px rgb(0 0 0 / .25);
  font-size: .95rem; z-index: 20;
}
.toast.toast-erreur { background: var(--rouge); color: #fff; }
