/* Une liste du jour sur un téléphone : gros doigts, une main, dehors. Les
   couleurs suivent celles de la grille — ambiance sombre par défaut, claire si
   le système la demande. */

:root {
  color-scheme: dark light;
  --fond: #14161c;
  --surface: #1c1f27;
  --surface-haut: #242833;
  --bord: #2f3441;
  --texte: #e6e8ee;
  --texte-doux: #a3a9b8;
  --texte-tenu: #6d7484;
  --accent: #5a9cf8;
  --fait: #63c48a;
  --reporte: #e0b64a;
  --echoue: #e0655a;
  --externe: #a98ae0;
  --rayon: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --fond: #f5f6f8;
    --surface: #ffffff;
    --surface-haut: #eef0f4;
    --bord: #d9dde5;
    --texte: #1b1e25;
    --texte-doux: #5a6172;
    --texte-tenu: #8b93a3;
  }
}

* { 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;
  /* L'encoche et la barre de gestes des téléphones récents. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.screen { max-width: 720px; margin: 0 auto; }

/* --- Enrôlement ------------------------------------------------------- */

#enroll { padding: 32px 20px; }
#enroll h1 { font-size: 28px; margin: 0 0 8px; }
.lede { color: var(--texte-doux); margin: 0 0 24px; }

form { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 13px; color: var(--texte-tenu); margin-top: 10px; }

input {
  font: inherit;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 13px 14px;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#enroll-code { text-transform: uppercase; letter-spacing: 0.12em; font-size: 20px; }

button {
  font: inherit;
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  background: var(--surface-haut);
  color: var(--texte);
  padding: 13px 16px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #0b0d12; font-weight: 600; margin-top: 18px; }
button.ghost { background: transparent; }
button:active { filter: brightness(1.15); }

.error { color: var(--echoue); margin-top: 14px; }

/* --- Application ------------------------------------------------------ */

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 10px;
}
header h1 { font-size: 22px; margin: 0; }
header .title p { margin: 2px 0 0; color: var(--texte-tenu); font-size: 13px; }
header .title { flex: 1; min-width: 0; }

button.icon {
  width: 44px; height: 44px;
  border-radius: 22px;
  font-size: 20px;
  padding: 0;
  flex: none;
}
button.icon.spinning { animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

.status {
  margin: 0 18px 8px;
  min-height: 18px;
  font-size: 13px;
  color: var(--texte-tenu);
}
.status.warn { color: var(--reporte); }
.status.bad { color: var(--echoue); }

.view { padding: 0 14px 92px; }

.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--bord);
  border-left-width: 4px;
  border-radius: var(--rayon);
  padding: 12px 14px;
}
.task.pending   { border-left-color: var(--texte-tenu); }
.task.done      { border-left-color: var(--fait); }
.task.postponed { border-left-color: var(--reporte); }
.task.failed    { border-left-color: var(--echoue); }
.task.external  { border-left-color: var(--externe); }
/* Une modification pas encore poussée : elle est déjà dans la file. */
.task.en-attente { border-style: dashed; }

.task .check {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 8px;
  background: transparent;
  font-size: 17px;
  line-height: 1;
  padding: 0;
  color: var(--fait);
}
.task .body { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; color: inherit; }
.task .titre { display: block; word-wrap: break-word; }
.task.done .titre { color: var(--texte-doux); text-decoration: line-through; }
.task .meta { display: block; font-size: 12px; color: var(--texte-tenu); margin-top: 3px; }

.empty { color: var(--texte-tenu); text-align: center; padding: 42px 12px; }

.jour { margin-top: 18px; }
.jour > h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--texte-tenu);
  margin: 0 4px 8px;
}

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

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--bord);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  flex: 1;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--texte-tenu);
  font-size: 13px;
  padding: 10px 4px;
}
.tabs button.active { color: var(--accent); background: var(--surface-haut); }

/* --- Feuille d'actions ------------------------------------------------ */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.sheet-panel {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--rayon) var(--rayon) 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sheet-panel h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; word-wrap: break-word; }
.sheet-actions,
#sheet-extra { display: flex; flex-direction: column; gap: 8px; }
.sheet-panel textarea {
  font: inherit;
  color: var(--texte);
  background: var(--fond);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 12px;
  width: 100%;
  min-height: 92px;
  resize: vertical;
}
