/* AnonyTask — la page des tâches, pensée d'abord pour le téléphone.
   Vert de la suite (#2e7d32), thème sombre comme les autres outils. */

:root {
  --vert: #2e7d32;
  --vert-clair: #e8f3ea;
  --trait: #d7e0d9;
  --texte: #1c2b21;
  --doux: #55645a;
  --fond: #e6efe8;
  --danger: #a3231b;
  --surface: #ffffff;
  --surface-douce: #f6f9f7;
  --toile: #ffffff;
  --ombre: 0 1px 2px rgba(20, 40, 26, 0.08), 0 8px 24px rgba(20, 40, 26, 0.06);
  --etoile: #b7791f;
  --barre-hauteur: 48px;
  --detail-largeur: 380px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --vert: #9ed3a4;
    --vert-clair: #1f2a22;
    --trait: #2c362e;
    --texte: #e6eee7;
    --doux: #a8b6ac;
    --fond: #0f1411;
    --danger: #ef8b84;
    --surface: #161d18;
    --surface-douce: #121813;
    --toile: #0f1411;
    --etoile: #e0b64a;
    --ombre: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

[data-theme='dark'] {
  --vert: #9ed3a4;
  --vert-clair: #1f2a22;
  --trait: #2c362e;
  --texte: #e6eee7;
  --doux: #a8b6ac;
  --fond: #0f1411;
  --danger: #ef8b84;
  --surface: #161d18;
  --surface-douce: #121813;
  --toile: #0f1411;
  --etoile: #e0b64a;
  --ombre: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* La page reste cachée tant que `garder()` n'a pas confirmé le coffre. */
body.en-attente > :not(.ecran-garde) {
  display: none !important;
}

.ecran-garde {
  display: none;
}

body.en-attente .ecran-garde {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--doux);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* --------------------------------------------------------------- la barre */

/* M-5 — la barre est celle de la suite : elle prend toute la largeur (comme
   sur l'agenda) et **défile** avec la page. AnonyTask la surchargeait encore
   (`flex-wrap: wrap` et `position: sticky`) : à 390 px elle passait sur trois
   lignes collées en haut (109 px) et l'écran utile du téléphone perdait 13 %.
   Les règles mobiles de `commun/theme.css` (une ligne qui défile
   horizontalement, Réglages et Verrouiller retenus à droite) font le reste. */
.barre {
  max-width: none;
  margin: 0;
  border: 0;
  border-bottom: 1px solid #1b5e20;
  border-radius: 0;
  padding: 8px 6px;
  font-size: 13px;
}

/* Couleurs, survol et page active : ceux de `commun/theme.css` (vert profond),
   dans les deux thèmes. Ici, seulement la taille des liens. */
.barre a,
.barre .lien {
  padding: 6px 8px;
}

.barre .barre-droite {
  margin-left: auto;
  display: flex;
  gap: 4px;
  align-items: center;
}

.barre .lien {
  cursor: pointer;
}

/* --------------------------------------------------------------- l'ensemble */

.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 45px);
}

.app[hidden] {
  display: none !important;
}

.entete {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: none;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--trait);
  border-radius: 0;
  padding: 10px 14px;
  background: var(--surface);
}

.marque {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--vert);
}

.marque .icon {
  width: 22px;
  height: 22px;
}

.entete-outils {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--doux);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--vert-clair);
  color: var(--vert);
}

.icon-button:focus-visible,
.bouton:focus-visible,
.rond:focus-visible,
.tache:focus-visible {
  outline: 2px solid var(--vert);
  outline-offset: 2px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  /* M-4 — le libellé disparaît à 390 px : sans largeur minimale, le témoin
     tombait à 30 px de large. */
  min-width: 44px;
  padding: 0 10px;
  border: 1px solid var(--trait);
  border-radius: 999px;
  background: var(--surface);
  color: var(--doux);
  font-size: 12px;
  cursor: pointer;
}

.sync-pill .point {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vert);
}

.sync-pill[data-etat='attente'] .point {
  background: var(--etoile);
}

.sync-pill[data-etat='hors-ligne'] .point {
  background: var(--danger);
}

/* ---------------------------------------------------------------- listes */

.listes {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px 24px;
  background: var(--surface);
  border-right: 1px solid var(--trait);
  overflow-y: auto;
  max-height: calc(100vh - 45px);
}

.listes-titre {
  margin: 10px 8px 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--doux);
}

.liste-lien {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--texte);
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.liste-lien:hover {
  background: var(--surface-douce);
}

.liste-lien[aria-current='true'] {
  background: var(--vert-clair);
  color: var(--vert);
  font-weight: 700;
}

.liste-lien .liste-nom {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.liste-lien .liste-nombre {
  font-size: 12px;
  color: var(--doux);
}

/* Déposer une tâche sur le nom d'une liste (PC). */
.liste-lien.cible {
  background: var(--vert-clair);
  box-shadow: inset 0 0 0 2px var(--vert);
}

.listes-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.listes-actions .bouton {
  flex: 1;
}

/* --------------------------------------------------------------- contenu */

.contenu {
  padding: 18px 16px 120px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.titre-vue {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.titre-ligne {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.titre-ligne .titre-vue {
  margin: 0;
  flex: 1;
}

.sous-titre-vue {
  margin: -8px 0 16px;
  color: var(--doux);
  font-size: 13px;
}

.ajout {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.ajout input {
  flex: 1;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--trait);
  border-radius: 12px;
  background: var(--surface);
  color: var(--texte);
}

.ajout input:focus {
  outline: 2px solid var(--vert);
  outline-offset: -1px;
}

.ajout .bouton {
  min-height: 48px;
}

.apercu {
  margin: 4px 2px 12px;
  font-size: 12px;
  color: var(--doux);
}

.aide-saisie {
  margin: 0 2px 14px;
  font-size: 12px;
  color: var(--doux);
}

.aide-saisie code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--vert-clair);
  color: var(--vert);
}

/* --------------------------------------------------------------- tâches */

.taches {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.groupe {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tache {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--trait);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--ombre);
}

.tache.terminee {
  opacity: 0.62;
}

.tache.terminee .tache-titre {
  text-decoration: line-through;
}

.tache.en-retard .echeance {
  color: var(--danger);
  font-weight: 600;
}

.tache.sous-tache {
  margin-left: 26px;
  border-left: 3px solid var(--vert-clair);
}

.tache.selectionnee {
  border-color: var(--vert);
  box-shadow: 0 0 0 2px var(--vert-clair);
}

.tache.glisse-origine {
  opacity: 0.4;
}

.coche {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -4px 0 -4px -6px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--doux);
  border-radius: 50%;
  flex: none;
}

.coche .rond-coche {
  width: 22px;
  height: 22px;
  border: 2px solid var(--doux);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.coche:hover .rond-coche {
  border-color: var(--vert);
}

.coche[aria-pressed='true'] .rond-coche {
  background: var(--vert);
  border-color: var(--vert);
}

.coche .icon {
  width: 14px;
  height: 14px;
  color: #fff;
  opacity: 0;
  stroke-width: 2.6;
}

.coche[aria-pressed='true'] .icon {
  opacity: 1;
}

.tache-corps {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
}

.tache-principale {
  display: block;
  font-size: 11px;
  color: var(--doux);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tache-titre {
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
  cursor: text;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  color: inherit;
  /* M-4 — une ligne de titre mesurait 20 px de haut : c'était la seule zone
     qui ouvrait le détail. La carte entière réagit au doigt (taches.js) et le
     titre garde une hauteur confortable. */
  display: flex;
  align-items: center;
  min-height: 44px;
}

.tache-titre:focus-visible {
  outline: 2px solid var(--vert);
  outline-offset: 2px;
  border-radius: 4px;
}

.tache-titre-modif {
  width: 100%;
  min-height: 32px;
  padding: 4px 6px;
  border: 1px solid var(--vert);
  border-radius: 8px;
  background: var(--surface);
}

.tache-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--doux);
}

.tache-details .element {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tache-details .icon {
  width: 13px;
  height: 13px;
}

.tache-details .echeance.en-retard,
.tache-details .en-retard {
  color: var(--danger);
}

.pastille-liste {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--vert-clair);
  color: var(--vert);
  font-weight: 600;
}

.tache-details .repetition {
  color: var(--doux);
}

.tache-details .dans-agenda {
  color: var(--vert);
}

.tache-outils {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: -6px -6px -6px 0;
}

.etoile-bouton {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--doux);
  cursor: pointer;
  border-radius: 10px;
}

.etoile-bouton[aria-pressed='true'] {
  color: var(--etoile);
}

.etoile-bouton .icon {
  width: 18px;
  height: 18px;
}

.etoile-bouton[aria-pressed='true'] .icon {
  fill: currentColor;
}

.plier {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--doux);
  cursor: pointer;
  border-radius: 8px;
}

.plier .icon {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.plier[aria-expanded='false'] .icon {
  transform: rotate(-90deg);
}

/* ------------------------------------------------------------- terminées */

.terminees {
  margin-top: 18px;
  border-top: 1px solid var(--trait);
  padding-top: 10px;
}

.terminees > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--doux);
  padding: 8px 2px;
  list-style: none;
}

.terminees > summary::-webkit-details-marker {
  display: none;
}

.terminees > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}

.terminees[open] > summary::before {
  transform: rotate(90deg);
}

.terminees-liste {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.terminees-actions {
  margin: 10px 0 4px;
}

.vide {
  padding: 28px 10px;
  text-align: center;
  color: var(--doux);
}

.vide .icon {
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  color: var(--vert);
}

/* ---------------------------------------------------------- panneau détail */

.detail {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow-y: auto;
  padding: 0 16px 32px;
}

.detail[hidden] {
  display: none !important;
}

.detail-tete {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--trait);
  margin: 0 -16px 12px;
  padding: 0 10px;
}

.detail-tete .espace {
  flex: 1;
}

.detail-titre {
  margin: 10px 0;
  font-size: 22px;
  font-weight: 700;
}

.detail-groupes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.detail-ligne {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.detail-ligne > span,
.champ-etiquette {
  font-size: 12px;
  font-weight: 600;
  color: var(--doux);
}

.detail-ligne input,
.detail-ligne textarea,
.detail-ligne select,
.champ input,
.champ select,
/* M-8 — le champ « Notes » du panneau n'avait pas le style des autres champs
   (bord noir, coins droits). */
.champ textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--trait);
  border-radius: 10px;
  background: var(--surface-douce);
  color: var(--texte);
}

.detail-ligne textarea {
  min-height: 96px;
  resize: vertical;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.detail-sous-taches {
  border-top: 1px solid var(--trait);
  margin-top: 14px;
  padding-top: 10px;
}

.detail-sous-taches h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--doux);
}

.detail-sous-taches ul {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-sous-taches li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--surface-douce);
}

.detail-sous-taches li span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-dans-agenda {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--vert-clair);
  color: var(--vert);
  font-size: 13px;
}

.detail-dans-agenda a {
  color: inherit;
  font-weight: 700;
}

/* --------------------------------------------------------------- boutons */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--trait);
  border-radius: 10px;
  background: var(--surface);
  color: var(--texte);
  font-weight: 600;
  cursor: pointer;
}

.bouton:hover {
  border-color: var(--vert);
  color: var(--vert);
}

.bouton.principal {
  background: var(--vert);
  border-color: var(--vert);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .bouton.principal {
    color: #102014;
  }
}

.bouton.danger {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}

.bouton.discret {
  border-color: transparent;
  background: transparent;
  color: var(--doux);
}

.bouton[disabled] {
  opacity: 0.55;
  cursor: default;
}

/* Bouton rond « + » du téléphone : toujours visible. */
.rond {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--vert);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(20, 40, 26, 0.28);
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .rond {
    color: #102014;
  }
}

.rond .icon {
  width: 26px;
  height: 26px;
  stroke-width: 2.4;
}

/* --------------------------------------------------------------- messages */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #1f2a22;
  color: #f2f7f3;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}

.toast.part {
  opacity: 0;
  transform: translateY(6px);
}

.toast.erreur {
  background: #7c1d16;
}

.toast .toast-texte {
  flex: 1;
  font-size: 13px;
}

.toast-action {
  border: 0;
  background: none;
  color: #b7e4bc;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
}

/* ----------------------------------------------------------- dialogues */

.dialogue {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(520px, calc(100vw - 24px));
  width: 100%;
}

.dialogue::backdrop {
  background: rgba(10, 18, 12, 0.45);
}

.dialogue-carte {
  background: var(--surface);
  color: var(--texte);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.dialogue-tete {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.dialogue-titre {
  margin: 0;
  flex: 1;
  font-size: 18px;
}

.dialogue-texte {
  margin: 0 0 8px;
  color: var(--doux);
}

.dialogue-corps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialogue-pied {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.dialogue-pied .gauche {
  margin-right: auto;
}

.champ {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Un choix par bouton radio : la case garde sa taille. */
.champ-choix {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 2px;
  cursor: pointer;
}

.champ-choix input {
  width: auto;
  min-height: auto;
  margin: 0;
  accent-color: var(--vert);
}

/* ------------------------------------------------------- ordinateur (≥ 860px) */

@media (min-width: 860px) {
  .app {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .rond {
    display: none;
  }

  .detail {
    position: static;
    inset: auto;
    grid-column: 2;
    border-left: 1px solid var(--trait);
    box-shadow: -8px 0 24px rgba(20, 40, 26, 0.05);
    padding-bottom: 32px;
  }

  .app.detail-ouvert {
    grid-template-columns: 240px minmax(0, 1fr) var(--detail-largeur);
  }

  .app.detail-ouvert .detail {
    grid-column: 3;
  }

  .contenu {
    padding-bottom: 40px;
  }

  .toasts {
    bottom: 24px;
  }

  .tache.sous-tache {
    margin-left: 34px;
  }
}

/* Très petits écrans : la barre et les listes se replient. */
@media (max-width: 700px) {
  .app {
    grid-template-columns: 1fr;
    /* NI-4 — sur téléphone il y a trois rangées : l'en-tête, les listes et le
       contenu. Sans cette ligne, les deux rangées déclarées laissaient la
       troisième (les onglets « Mes tâches / Favoris ») prendre tout l'espace
       libre : 300 px de haut avec une seule tâche, 224 px avec deux. */
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .listes {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--trait);
    min-height: 52px;
  }

  .listes-titre {
    display: none;
  }

  .liste-lien {
    width: auto;
    flex: none;
    white-space: nowrap;
    border: 1px solid var(--trait);
    min-height: 44px;
    padding: 4px 12px;
  }

  .liste-lien .liste-nombre {
    display: none;
  }

  .listes-actions {
    margin: 0;
    flex: none;
  }

  .listes-actions .bouton {
    min-height: 44px;
    padding: 4px 10px;
    white-space: nowrap;
  }

  .contenu {
    padding: 14px 12px 120px;
  }

  .entete {
    padding: 8px 10px;
  }

  .titre-vue {
    font-size: 21px;
  }

  .tache.sous-tache {
    margin-left: 16px;
  }

  .sync-pill .sync-libelle {
    display: none;
  }
}

/* Le doigt : on ne sélectionne pas le texte en glissant une tâche. */
body.glisse,
body.glisse * {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}

.fantome {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  opacity: 0.92;
  transform: rotate(-1deg);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  background: var(--surface);
  border: 1px solid var(--vert);
}

.repere {
  height: 3px;
  margin: 2px 0;
  border-radius: 3px;
  background: var(--vert);
}
