/* Porcelaine bleu et blanc : l'assiette est le seul element fort, le reste reste calme. */
:root {
  --fond: #F5F8FC;
  --surface: #FFFFFF;
  --encre: #13203B;
  --encre-douce: #5A6884;
  --cobalt: #1E4FA8;
  --cobalt-vif: #2D63CC;
  --brume: #DDE7F5;
  --ambre: #B7770A;
  --ambre-fond: #FFF4DD;
  --menthe: #12806F;
  --rouge: #B3261E;
  --assiette-centre: #FFFFFF;
  --assiette-bord: #EAF0F9;
  --motif: #1E4FA8;
  --rayon: 18px;
  --ombre: 0 1px 2px rgba(19, 32, 59, .06), 0 8px 24px rgba(19, 32, 59, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0C1730;
    --surface: #14244A;
    --encre: #E8EEF9;
    --encre-douce: #9DAACA;
    --cobalt: #7FA6F0;
    --cobalt-vif: #9BBBF7;
    --brume: #22355F;
    --ambre: #F0B54A;
    --ambre-fond: #3A2E14;
    --menthe: #4CC3AE;
    --rouge: #F2857D;
    --assiette-centre: #1C3060;
    --assiette-bord: #122247;
    --motif: #7FA6F0;
    --ombre: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Lexend", system-ui, sans-serif;
  font-weight: 400;
  background: var(--fond);
  color: var(--encre);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  line-height: 1.45;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--cobalt-vif); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; padding: env(safe-area-inset-top) 20px calc(96px + env(safe-area-inset-bottom)); }

.entete { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 6px; }
.entete h1 { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.01em; margin: 0; }
.liaison { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--encre-douce); }
.liaison i { width: 8px; height: 8px; border-radius: 50%; background: var(--encre-douce); }
.liaison.ok i { background: var(--menthe); }
.liaison.ko i { background: var(--rouge); }

/* ---------- L'assiette ---------- */
.assiette { position: relative; width: min(100%, 340px); aspect-ratio: 1; margin: 12px auto 8px; }
.assiette svg { width: 100%; height: 100%; display: block; overflow: visible; }
.aile { fill: var(--surface); stroke: var(--brume); stroke-width: 1.5; filter: drop-shadow(0 10px 22px rgba(19,32,59,.10)); }
@media (prefers-color-scheme: dark) { .aile { filter: none; } }
#motif ellipse { fill: var(--motif); opacity: .8; }
#motif circle { fill: var(--motif); opacity: .6; }
.piste { fill: none; stroke: var(--brume); stroke-width: 9; }
.progression {
  fill: none; stroke: var(--cobalt); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 804.25; stroke-dashoffset: 804.25;
  transition: stroke-dashoffset 1.2s cubic-bezier(.2,.8,.2,1);
}
.creux { stroke: var(--brume); stroke-width: 1; }
.assiette.hors-ligne .progression, .assiette.hors-ligne #motif { opacity: .25; }
.assiette.en-cours #motif { animation: tourne 60s linear infinite; transform-origin: 160px 160px; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .assiette.en-cours #motif { animation: none; }
  .progression { transition: none; }
}
.centre {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 0 22%;
}
.temps { font-size: clamp(2.6rem, 13vw, 3.6rem); font-weight: 300; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.temps small { font-size: .45em; font-weight: 400; letter-spacing: 0; color: var(--encre-douce); margin-left: 2px; }
.phase { margin-top: 10px; font-size: 1rem; font-weight: 500; color: var(--cobalt); min-height: 1.4em; }
.programme { font-size: .9rem; color: var(--encre-douce); }

/* ---------- Alertes ---------- */
.alertes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.alertes li {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start;
  background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--ombre);
  font-size: .92rem;
}
.alertes li b { display: block; font-weight: 500; }
.alertes li span { color: var(--encre-douce); }
.alertes li.attention { background: var(--ambre-fond); box-shadow: none; }
.alertes li.attention svg { stroke: var(--ambre); }
.alertes svg { width: 24px; height: 24px; fill: none; stroke: var(--cobalt); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }

/* ---------- Boutons ---------- */
.actions { margin-top: 22px; }
.bouton {
  border: 0; border-radius: 999px; padding: 15px 24px; font-weight: 500; font-size: 1rem;
  transition: transform .12s ease, background-color .2s ease;
}
.bouton:active { transform: scale(.97); }
.bouton.principal { background: var(--cobalt); color: #fff; width: 100%; }
@media (prefers-color-scheme: dark) { .bouton.principal { color: #0C1730; } }
.bouton.principal.danger { background: var(--surface); color: var(--rouge); box-shadow: inset 0 0 0 1.5px var(--rouge); }
.bouton.secondaire { background: var(--brume); color: var(--encre); }
.bouton.fantome { background: transparent; color: var(--rouge); }
.bouton.large { width: 100%; }
.bouton:disabled { opacity: .5; }

/* ---------- Programmes ---------- */
.rubrique { font-size: 1rem; font-weight: 500; color: var(--encre-douce); margin: 22px 0 10px; }
.liste-perso { display: grid; gap: 10px; margin-bottom: 12px; }
.carte-perso {
  position: relative; text-align: left; border: 0; width: 100%;
  background: var(--surface); border-radius: var(--rayon); padding: 16px 18px; box-shadow: var(--ombre);
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
}
.carte-perso.vedette {
  background: var(--cobalt); color: #fff; overflow: hidden;
  background-image: radial-gradient(circle at 110% -10%, rgba(255,255,255,.22) 0 30%, transparent 31%),
                    radial-gradient(circle at 110% -10%, rgba(255,255,255,.12) 0 45%, transparent 46%);
}
@media (prefers-color-scheme: dark) { .carte-perso.vedette { color: #0C1730; } }
.carte-perso .nom { font-weight: 500; font-size: 1.08rem; }
.carte-perso .desc { grid-column: 1; font-size: .85rem; opacity: .8; }
.carte-perso .modif {
  grid-row: 1 / span 2; grid-column: 2; border: 0; background: transparent; color: inherit;
  opacity: .7; padding: 8px; border-radius: 10px; font-size: .85rem;
}
.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tuile {
  border: 0; text-align: left; background: var(--surface); border-radius: 16px; padding: 14px;
  box-shadow: var(--ombre); display: flex; flex-direction: column; gap: 2px; min-height: 92px;
}
.tuile .num { font-size: .78rem; color: var(--encre-douce); }
.tuile .nom { font-weight: 500; }
.tuile .info { font-size: .82rem; color: var(--encre-douce); margin-top: auto; }

/* ---------- Reglages ---------- */
.bloc { background: var(--surface); border-radius: var(--rayon); padding: 18px; box-shadow: var(--ombre); margin-top: 14px; }
.bloc h2 { font-size: 1.02rem; font-weight: 500; margin: 0 0 6px; }
.bloc p { margin: 0 0 12px; color: var(--encre-douce); font-size: .92rem; }
.bloc p b { color: var(--encre); font-weight: 500; }
.petit { font-size: .82rem !important; }
.etat-reco { margin-top: 10px !important; color: var(--cobalt) !important; }
.replie { margin-top: 14px; }
.replie summary { cursor: pointer; color: var(--encre-douce); font-size: .9rem; }
.replie label, .champ { display: grid; gap: 6px; font-size: .88rem; color: var(--encre-douce); margin: 12px 0; }
input {
  border: 1.5px solid var(--brume); background: var(--fond); border-radius: 12px; padding: 12px 14px;
  font-size: 16px; color: var(--encre);
}
input:focus { outline: none; border-color: var(--cobalt); }

/* ---------- Onglets ---------- */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--brume);
}
.onglets button {
  flex: 1; max-width: 140px; border: 0; background: transparent; color: var(--encre-douce);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .75rem; padding: 6px 0;
  border-radius: 12px;
}
.onglets svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.onglets button[aria-current="page"] { color: var(--cobalt); font-weight: 500; }

/* ---------- Feuilles (bas d'ecran) ---------- */
.voile { position: fixed; inset: 0; background: rgba(8, 16, 34, .42); z-index: 10; animation: apparait .2s ease; }
.feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; margin: 0 auto; max-width: 560px;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 22px calc(22px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  animation: monte .28s cubic-bezier(.2,.9,.25,1);
}
@keyframes monte { from { transform: translateY(100%); } }
@keyframes apparait { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .feuille, .voile { animation: none; } }
.poignee { width: 40px; height: 5px; border-radius: 3px; background: var(--brume); margin: 0 auto 14px; }
.feuille h2 { font-size: 1.35rem; font-weight: 500; margin: 0; }
.fl-sous { color: var(--encre-douce); margin: 4px 0 14px; font-size: .92rem; }

.option {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--brume);
}
.option > b { grid-column: 1; grid-row: 1; font-weight: 500; font-size: .98rem; }
.option > .aide { grid-column: 1; grid-row: 2; color: var(--encre-douce); font-size: .84rem; }
.interrupteur { grid-row: 1 / span 2; grid-column: 2; position: relative; width: 52px; height: 32px; }
.interrupteur input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.interrupteur i {
  position: absolute; inset: 0; border-radius: 999px; background: var(--brume); transition: background .2s;
  pointer-events: none;
}
.interrupteur i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.3,.9,.3,1);
}
.interrupteur input:checked + i { background: var(--cobalt); }
.interrupteur input:checked + i::after { transform: translateX(20px); }
.interrupteur input:focus-visible + i { outline: 3px solid var(--cobalt-vif); outline-offset: 2px; }

.differe { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 6px; }
.differe > span { font-weight: 500; }
.pas { display: flex; align-items: center; gap: 12px; }
.pas output { min-width: 104px; text-align: center; font-variant-numeric: tabular-nums; }
.rond { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--brume); font-size: 1.3rem; line-height: 1; }
.fin-prevue { color: var(--encre-douce); font-size: .9rem; margin: 4px 0 16px; }

.etiquette { font-size: .88rem; color: var(--encre-douce); margin: 14px 0 8px; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce { border: 1.5px solid var(--brume); background: transparent; border-radius: 999px; padding: 8px 14px; font-size: .88rem; }
.puce[aria-pressed="true"] { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
@media (prefers-color-scheme: dark) { .puce[aria-pressed="true"] { color: #0C1730; } }
.ligne-boutons { display: flex; gap: 10px; margin-top: 18px; }
.ligne-boutons .principal { flex: 1; }

/* ---------- Divers ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--encre); color: var(--fond); padding: 12px 18px; border-radius: 14px; z-index: 20;
  font-size: .92rem; max-width: calc(100% - 40px); box-shadow: 0 8px 30px rgba(0,0,0,.2);
  animation: apparait .2s ease;
}
.ecran-vide { max-width: 420px; margin: 0 auto; padding: 18vh 28px; text-align: center; }
.ecran-vide h1 { font-weight: 500; font-size: 1.35rem; }
.ecran-vide p { color: var(--encre-douce); }
.mini-assiette { width: 96px; fill: none; stroke: var(--cobalt); stroke-width: 3; }
