:root {
  --paper: #f6f3ea;
  --paper-2: #efe9da;
  --card: #fffdf8;
  --ink: #1c2a20;
  --muted: #6f7a6f;
  --line: #e4ddcd;
  --green: #2e7d32;
  --green-deep: #1f4d2e;
  --green-soft: #e7f1e6;
  --accent-bright: #7cc081;  /* version claire de l'accent, lisible sur fond sombre */
  --amber: #d6892a;
  --amber-soft: #fbe6cf;
  --alert: #c0392b;
  --alert-soft: #fbe4e0;
  --warn: #c97a16;
  --shadow: 0 1px 2px rgba(28,42,32,.05), 0 6px 20px rgba(28,42,32,.06);
  /* Jetons de thème (redéfinis dans themes.css) */
  --on-action: #fff;                 /* texte sur un bouton plein */
  --on-soft: var(--green-deep);      /* texte sur une surface douce */
  --halo: #eef4e8;                   /* lueur en haut à droite du fond */
  --texture: none;                   /* motif de fond */
  --font-display: "Fraunces", Georgia, serif;
  --header-bg: linear-gradient(180deg, var(--green-deep), color-mix(in srgb, var(--green-deep), #000 34%));
}

/* ---------- Thème sombre ---------- */
/* On ne bascule que les surfaces structurelles (fond, cartes, texte, lignes).
   Les pastilles colorées (assignee, badges) restent des puces claires, lisibles
   sur fond sombre — comme des étiquettes. */
:root[data-theme="dark"] {
  --paper: #13160f;
  --paper-2: #262b20;
  --card: #1c2017;
  --ink: #e7e9e0;
  --muted: #9aa492;
  --line: #313a2e;
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 6px 20px rgba(0,0,0,.4);
}
:root[data-theme="dark"] { --halo: #17241a; --on-soft: var(--ink); }
/* Champs : sinon fond blanc codé en dur → texte clair illisible. */
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: #11140d; color: var(--ink); border-color: var(--line); }
/* Barre d'onglets : fond clair codé en dur → on l'assombrit. */
:root[data-theme="dark"] .tabbar { border-top-color: var(--line); }
/* Ligne d'habitant inactif : fond gris clair codé en dur → on l'assombrit. */
:root[data-theme="dark"] .team-row.inactive { background: #23271d; }
/* Accents vert foncé utilisés comme TEXTE : éclaircis pour rester lisibles. */
:root[data-theme="dark"] .tab.active { color: var(--accent-bright); }
:root[data-theme="dark"] .tab.active svg { stroke: var(--accent-bright); }
:root[data-theme="dark"] .cp-author,
:root[data-theme="dark"] details.commenter summary,
:root[data-theme="dark"] details.edit-line summary { color: var(--accent-bright); }
/* Liens simples (sans classe), ex. « ← Accueil » : bleu UA illisible sur sombre. */
a:not([class]) { color: var(--green-deep); }
:root[data-theme="dark"] a:not([class]) { color: var(--accent-bright); }

/* Bouton bascule de thème (soleil / lune) dans l'en-tête */
.theme-toggle {
  flex: 0 0 auto; width: 38px; height: 38px; min-width: 38px; padding: 0; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  overflow: hidden; line-height: 0;
  color: #fdfbf4; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
}
.theme-toggle:hover { background: rgba(255,255,255,.2); }
/* width/height aussi en attribut sur le <svg> (Firefox ne dimensionne pas l'inline
   SVG via la seule CSS) ; pointer-events:none pour que le clic atteigne le bouton. */
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
/* Clair : on propose la lune (passer au sombre) ; sombre : on propose le soleil. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  background-color: var(--paper);
  background-image: var(--texture), radial-gradient(1200px 500px at 100% -10%, var(--halo) 0%, transparent 60%);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 84px; /* place pour la barre d'onglets mobile */
}

h1, h2, h3, .brand {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.15;
}
h1 { font-size: 1.7rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .65rem 1.2rem;
  background: var(--green-deep);  /* repli si color-mix non supporté */
  background: var(--header-bg);
  color: #f4f1e8;
  box-shadow: 0 2px 14px rgba(28,42,32,.18);
}
.brand {
  flex: 1 1 0;
  color: #fdfbf4; text-decoration: none;
  font-size: 1.25rem; display: inline-flex; align-items: center; gap: .35rem;
  white-space: nowrap;
}
.brand-leaf { font-family: initial; }

/* Nav desktop : centrée, grande et bien visible */
.topnav { display: none; align-items: center; gap: .5rem; }
.topnav a {
  color: #eaf2e6; text-decoration: none;
  padding: .6rem 1.5rem; border-radius: 999px;
  font-weight: 700; font-size: 1.3rem; letter-spacing: .01em;
  transition: background .15s, color .15s, transform .05s;
}
.topnav a:hover { background: rgba(255,255,255,.16); color: #fff; }
.topnav a.active {
  background: #fffdf8; color: var(--green-deep);
  box-shadow: 0 3px 10px rgba(0,0,0,.22);
}
.topbar-right { display: none; flex: 1 1 0; justify-content: flex-end; gap: .5rem; }
.who-chip {
  color: #fdfbf4; text-decoration: none;
  padding: .45rem .9rem; border-radius: 999px; font-weight: 600;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
}
.who-chip:hover { background: rgba(255,255,255,.2); }
.who-chip.active { background: #fffdf8; color: var(--green-deep); }
/* Aide « ❔ » dans l'en-tête : visible sur mobile (la barre de droite y est masquée),
   cachée sur desktop où le chip « Comment ça marche ? » prend le relais à droite. */
.topbar-help-mobile {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 1.2rem; line-height: 1;
  color: #fdfbf4; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
}
.topbar-help-mobile:hover { background: rgba(255,255,255,.2); }
.topbar-help-mobile.active { background: #fffdf8; color: var(--green-deep); }

/* ---------- Barre d'onglets (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(28,42,32,.08);
  padding: .35rem .2rem calc(.35rem + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; text-decoration: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .35rem 0; border-radius: 12px; font-size: .72rem; font-weight: 600;
  max-width: 25%;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.tab.active { color: var(--green-deep); }
.tab.active svg { stroke: var(--green); }
.tab.active::after { content: ""; position: absolute; }

/* ---------- Conteneur & cartes ---------- */
.container { max-width: 720px; margin: 0 auto; padding: 1.1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 400px; margin: 2.4rem auto; }

.muted { color: var(--muted); }
.error { color: var(--alert); font-weight: 600; }

.banner { padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 600; }
.banner.alert { background: var(--alert-soft); color: var(--alert); border: 1px solid #f0c8c1; }
.banner.info { background: var(--green-soft); color: var(--on-soft); border: 1px solid var(--line); }

/* ---------- Formulaires ---------- */
label { display: block; margin: .7rem 0; font-weight: 600; font-size: .9rem; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: .6rem .7rem; margin-top: .25rem;
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft);
}
textarea { min-height: 64px; resize: vertical; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
label.check input { width: auto; margin: 0; }
.collchk { width: auto; margin: .4rem .4rem 0 0; vertical-align: middle; }
.check-inline { display: inline; font-weight: 600; }
.quota-field { display: none; margin-top: .5rem; padding: .6rem .7rem; background: var(--green-soft); border-radius: 10px; }
.collchk:checked ~ .quota-field { display: block; }

button {
  background: var(--green); color: var(--on-action); border: 0; cursor: pointer;
  padding: .58rem 1rem; border-radius: 10px; font: inherit; font-weight: 600;
  transition: transform .05s, filter .15s;
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button.secondary { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
button.secondary:hover { background: var(--line); }
button.danger { background: var(--alert-soft); color: var(--alert); border: 1px solid #f0c8c1; }
button.danger:hover { background: #f6d6cf; }
/* État « occupé » (envoi d'une photo en cours) : bouton grisé + petit spinner. */
button.is-busy { cursor: progress; opacity: .85; }
button.is-busy::after {
  content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .5em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -.12em; animation: btnspin .6s linear infinite;
}
@keyframes btnspin { to { transform: rotate(360deg); } }

.btn-add {
  display: inline-block; background: var(--green); color: #fff; text-decoration: none;
  padding: .6rem 1.1rem; border-radius: 10px; font-weight: 700;
  box-shadow: var(--shadow);
}
.btn-add:hover { filter: brightness(1.06); }

.stack > * { margin-bottom: .45rem; }
.inline { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; margin-top: .45rem; }
.inline input, .inline select, .inline textarea { width: auto; flex: 1 1 auto; margin-top: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* ---------- Listes de tâches ---------- */
.task-list { list-style: none; padding: 0; margin: 0; }
.task { border-top: 1px solid var(--line); padding: .8rem 0; }
.task:first-child { border-top: 0; }
.task.overdue { border-left: 3px solid var(--alert); padding-left: .6rem; }
.task-main { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
/* Titre de tâche : le cœur de l'app — volontairement plus gros pour attirer l'œil. */
.task-title { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.12rem; line-height: 1.25; }
a.task-title:hover { text-decoration: underline; }
.sub-count { font-size: .76rem; color: var(--green-deep); background: var(--green-soft); padding: .12rem .5rem; border-radius: 999px; font-weight: 600; }
.gear { text-decoration: none; font-size: 1.05rem; margin-left: auto; opacity: .8; }
.gear:hover { opacity: 1; }

/* Liste équipe (drag & drop) */
.team-list { list-style: none; padding: 0; margin: 0; }
.team-row {
  display: flex; align-items: center; gap: .6rem; padding: .6rem .5rem;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; background: var(--card);
  /* flex-wrap : sur petit écran, les contrôles (rôle, Désactiver) passent à la
     ligne au lieu de déborder. touch-action:none : le glisser tactile reste
     fiable même en appuyant hors de la poignée. */
  flex-wrap: wrap; row-gap: .45rem; touch-action: none;
}
/* Pastilles num/avatar/poignée : taille fixe, jamais écrasées par le flex. */
.team-row .num, .team-row .drag, .team-row .assignee .av { flex: 0 0 auto; }
.team-row .assignee { flex: 0 1 auto; }
.team-row .inline { margin-top: 0; }
/* Le sélecteur de rôle garde une largeur sobre (ne s'étire pas sur toute la ligne). */
.team-row form.inline select { flex: 0 0 auto; width: auto; min-width: 6rem; }
.team-row.dragging { box-shadow: 0 8px 22px rgba(28,42,32,.22); transform: scale(1.02); background: var(--card); border-color: var(--green); }
/* Pendant un glisser tactile, on ne sélectionne pas le texte des lignes. */
.team-list { -webkit-user-select: none; user-select: none; }
.team-row.is-current { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
/* Poignée de glisser : touch-action:none pour empêcher le scroll pendant le drag au doigt. */
.team-row .drag {
  color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: grab;
  touch-action: none; padding: .2rem .35rem; user-select: none; -webkit-user-select: none;
}
.subhead { color: var(--muted); font-size: .95rem; margin: .9rem 0 .4rem; }
.title-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .4rem; }
.title-row h1 { margin: 0; }
.team-row .num {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.team-row.inactive { background: #f0f0ee; opacity: .7; }
.push-right { margin-left: auto; }
.who { color: var(--muted); font-size: .9rem; }

/* Pastille « responsable » bien visible */
.assignee {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--green-soft); color: var(--on-soft);
  padding: .18rem .6rem .18rem .22rem; border-radius: 999px;
  font-weight: 700; font-size: .82rem;
}
.assignee .av {
  width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: .72rem; font-family: "Fraunces", serif;
}
.assignee.unassigned { background: var(--amber-soft); color: var(--warn); }
.assignee.unassigned .av { background: var(--amber); color: #2a1a06; }

/* Tag reliant une sous-tâche à sa tâche-mère */
.parent-tag {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .74rem; color: #7a5a1f; background: var(--amber-soft);
  padding: .1rem .55rem; border-radius: 999px; text-decoration: none; font-weight: 600;
}
.parent-tag:hover { filter: brightness(.97); text-decoration: underline; }

/* Sélecteur de tri */
.sort-toggle { display: flex; gap: .4rem; align-items: center; font-size: .85rem; flex-wrap: wrap; }
.sort-toggle .lbl { color: var(--muted); }
.sort-toggle a { text-decoration: none; color: var(--muted); padding: .25rem .65rem; border-radius: 999px; border: 1px solid var(--line); }
.sort-toggle a.active { background: var(--green); color: #fff; border-color: var(--green); }

/* Lien « Changer de profil » (page profil) */
.switch-link {
  text-decoration: none; color: var(--green-deep); white-space: nowrap;
  border: 1px solid var(--line); background: var(--card);
  padding: .4rem .8rem; border-radius: 999px; font-weight: 600; font-size: .9rem;
}
.switch-link:hover { background: var(--green-soft); }
:root[data-theme="dark"] .switch-link { color: var(--accent-bright); }
.switch-bottom { margin: 1.6rem 0 .4rem; text-align: center; }

/* ---------- Page « Comment ça marche ? » ---------- */
.aide-lead { font-size: 1.05rem; margin: -.2rem 0 1.2rem; max-width: 62ch; }
.aide-list { margin: .2rem 0 0; padding-left: 1.2rem; }
.aide-list li { margin: .45rem 0; }
.aide-outro { text-align: center; color: var(--green-deep); font-weight: 600; margin: 1.4rem 0 .6rem; }
:root[data-theme="dark"] .aide-outro { color: var(--accent-bright); }

/* Bandeau de stats (page profil) */
.stats-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: .2rem 0 1.1rem; }
.stat { flex: 1 1 90px; text-align: center; background: var(--green-soft); border-radius: 12px; padding: .6rem .5rem; }
.stat-num { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; color: var(--on-soft); line-height: 1.1; }
.stat-lbl { font-size: .76rem; color: var(--muted); }

/* Tuile « tâches effectuées » (vue d'ensemble) : un raccourci vers la section. */
.tuile-faites { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .8rem 1rem .1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.tuile-faites:hover { border-color: var(--green-deep); }
.tuile-titre { display: block; font-weight: 600; margin-bottom: .5rem; }
.tuile-faites .stats-row { margin-bottom: .7rem; }
.banner a, :root[data-theme="dark"] .banner a:not([class]) { color: inherit; }

/* Sélecteur de couleur (page profil) */
.task-meta { color: var(--muted); font-size: .82rem; margin: .25rem 0 .35rem; }
/* Date mise en avant (vue chronologique) : l'échéance est l'info recherchée. */
.task-due { margin: .35rem 0; }
.due-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-weight: 700; font-size: .92rem; color: var(--green-deep);
  background: var(--green-soft); padding: .22rem .65rem; border-radius: 999px;
}
:root[data-theme="dark"] .due-chip { color: var(--accent-bright); }
.due-chip.due-overdue { background: var(--alert-soft); color: var(--alert); }
.due-chip.due-none { background: var(--paper-2); color: var(--muted); font-weight: 600; }
.actions { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
/* Boutons/champs d'action compacts : secondaires par rapport au titre de tâche. */
.actions button { padding: .38rem .7rem; font-size: .85rem; border-radius: 8px; }
.actions input, .actions select { padding: .38rem .5rem; font-size: .85rem; margin-top: 0; }

/* ---------- Accueil : tâches en cartes délimitées ----------
   Sur l'accueil, chaque tâche est une carte encadrée (mieux séparée que de
   simples filets) et les actions secondaires sont rangées derrière « ⋯ Plus »
   pour éviter le « mur de boutons ». */
.task-list.cards { display: flex; flex-direction: column; gap: .7rem; }
.task-list.cards > .task {
  border: 1px solid var(--line); border-top: 1px solid var(--line);
  border-radius: 14px; padding: .85rem .95rem; background: var(--card);
  box-shadow: var(--shadow);
}
.task-list.cards > .task.overdue { border-left: 3px solid var(--alert); }
.task-list.cards > .task.mine { border-left: 3px solid var(--amber); }

/* Menu « ⋯ Plus » : regroupe les actions secondaires d'une tâche. */
details.more-actions { margin-top: 0; }
details.more-actions > summary {
  cursor: pointer; list-style: none;
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .38rem .7rem; border-radius: 8px; font-size: .85rem; font-weight: 600;
  background: var(--paper-2); color: var(--ink); border: 1px solid var(--line);
}
details.more-actions > summary::-webkit-details-marker { display: none; }
details.more-actions > summary:hover { background: #e6dfcd; }
:root[data-theme="dark"] details.more-actions > summary:hover { background: var(--line); }
.more-menu {
  margin-top: .55rem; padding: .65rem; border: 1px solid var(--line);
  border-radius: 10px; background: var(--paper);
  display: flex; flex-direction: column; gap: .55rem; align-items: stretch;
}
.more-menu form.inline { margin-top: 0; }
.more-menu .more-info { font-size: .82rem; color: var(--muted); }

/* Tâche en deux colonnes : contenu à gauche, commentaires à droite */
.task-row { display: flex; gap: 1rem; align-items: flex-start; }
.task-left { flex: 1 1 auto; min-width: 0; }
.task-comments { flex: 0 0 40%; max-width: 40%; border-left: 1px solid var(--line); padding-left: .85rem; }
.comment-preview { font-size: .85rem; line-height: 1.35; }
.cp-author { font-weight: 700; color: var(--green-deep); margin-right: .3rem; }
.cp-all { font-size: .76rem; color: var(--green); text-decoration: none; }
.cp-all:hover { text-decoration: underline; }
/* Vignette photo dans l'aperçu de commentaire (accueil). */
.cp-thumb { display: inline-block; margin: .4rem 0 .2rem; }
.cp-thumb img { display: block; width: 100%; max-width: 160px; height: auto; border-radius: 10px; border: 1px solid var(--line); }
details.commenter, details.edit-line { margin-top: .45rem; }
details.commenter summary, details.edit-line summary {
  cursor: pointer; color: var(--green-deep); font-weight: 600; font-size: .85rem;
  list-style: none; display: inline-flex; align-items: center;
}
details.commenter summary::-webkit-details-marker,
details.edit-line summary::-webkit-details-marker { display: none; }
details.commenter[open] summary, details.edit-line[open] summary { margin-bottom: .4rem; }
@media (max-width: 600px) {
  .task-row { flex-direction: column; gap: .6rem; }
  .task-comments { flex-basis: auto; max-width: 100%; border-left: 0; padding-left: 0; border-top: 1px dashed var(--line); padding-top: .6rem; }
}

/* ---------- Badges ---------- */
.badge {
  font-size: .68rem; padding: .16rem .55rem; border-radius: 999px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.status-a_faire { background: #e6eefb; color: #1c4fb0; }
.status-fait { background: var(--green-soft); color: var(--green-deep); }
.status-reporte { background: var(--amber-soft); color: var(--warn); }
.status-en_retard { background: var(--alert-soft); color: var(--alert); }
.status-parking { background: #ede7f6; color: #5e35b1; }
.status-supprimee { background: #eceff1; color: #546e7a; }
.badge-backlog { background: var(--amber-soft); color: var(--warn); font-size: .68rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-commune { background: #e0f2f1; color: #00695c; font-size: .68rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-collective { background: #ede7f6; color: #5e35b1; font-size: .68rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-mine { background: var(--amber); color: #2a1a06; font-size: .68rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-invite { background: #eef1ee; color: var(--muted); font-size: .68rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.assignee.other { background: #eef1ee; color: var(--muted); }
.assignee.other .av { background: #b9c2b9; color: #fff; }
.task.mine { border-left: 3px solid var(--amber); padding-left: .6rem; }
.communes-card { border-color: #b2dfdb; }
:root[data-theme="dark"] .communes-card { border-color: var(--line); }
.add-commune summary { color: var(--green-deep); }

/* ---------- Choix du prénom ---------- */
.whoami-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: 1rem; }
.whoami-grid form { margin: 0; }
.whoami-btn { width: 100%; padding: 1rem; font-size: 1.1rem; font-family: "Fraunces", serif; }

/* ---------- Notes (commentaires & photos) ---------- */
.notes { list-style: none; padding: 0; margin: 0 0 1rem; }
.note { display: flex; gap: .6rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.note:first-child { border-top: 0; }
.note-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  background: var(--green-soft); color: var(--green-deep);
  display: grid; place-items: center; font-weight: 700; font-family: "Fraunces", serif;
}
.note-body { flex: 1; }
.note-meta { color: var(--muted); font-size: .78rem; }
.note-photo { margin-top: .4rem; max-width: 220px; border-radius: 10px; border: 1px solid var(--line); display: block; cursor: zoom-in; }
.note-photo-link { display: inline-block; }

/* Lightbox photo (pur CSS via :target) */
.lightbox { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(15,20,16,.88); }
.lightbox:target { display: flex; }
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); cursor: zoom-out; }
.lightbox-backdrop { position: absolute; inset: 0; }
.lightbox-imglink { position: relative; z-index: 1; display: flex; }
.lightbox-close {
  position: absolute; top: 1rem; right: 1.2rem; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff; font-size: 1.5rem;
  display: grid; place-items: center; text-decoration: none; line-height: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,.3); }

/* Section sous-tâches repliable (cas rare, en bas du détail) */
details.subtasks > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; }
details.subtasks > summary::-webkit-details-marker { display: none; }
details.subtasks > summary::before { content: "▸"; color: var(--muted); font-size: 1rem; }
details.subtasks[open] > summary::before { content: "▾"; }
details.subtasks > summary h2,
details.subtasks > summary h3 { margin: 0; }
details.subtasks.archive { margin-top: .6rem; }

/* ---------- Historique ---------- */
.history { list-style: none; padding: 0; margin: 0; }
.history li { border-top: 1px solid var(--line); padding: .55rem 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.history li:first-child { border-top: 0; }
.hist-task { font-weight: 700; color: var(--green-deep); text-decoration: none; }
:root[data-theme="dark"] .hist-task, :root[data-theme="dark"] .ligne-t { color: var(--ink); }
:root[data-theme="dark"] .badge-collective, :root[data-theme="dark"] .badge-genre-reunion { background: var(--green-soft); color: var(--on-soft); }
a.hist-task:hover { text-decoration: underline; }
.hist-meta { color: var(--muted); font-size: .8rem; margin-left: auto; }
/* En thème sombre, le vert foncé du nom de tâche ressort mal → on l'éclaircit. */
:root[data-theme="dark"] .hist-task { color: var(--ink); }
:root[data-theme="dark"] a.hist-task { color: var(--accent-bright); }

/* Historique repliable : année > mois (les 2 mois récents ouverts par défaut). */
details.hist-year { border-top: 1px solid var(--line); }
details.hist-year:first-child { border-top: 0; }
details.hist-year > summary,
details.hist-month > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem;
}
details.hist-year > summary::-webkit-details-marker,
details.hist-month > summary::-webkit-details-marker { display: none; }
details.hist-year > summary::before,
details.hist-month > summary::before { content: "▸"; color: var(--muted); font-size: .9rem; }
details.hist-year[open] > summary::before,
details.hist-month[open] > summary::before { content: "▾"; }
details.hist-year > summary {
  font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.15rem;
  padding: .6rem 0; color: var(--ink);
}
details.hist-month > summary {
  font-weight: 600; font-size: .95rem; color: var(--green-deep);
  padding: .4rem 0 .4rem 1rem;
}
:root[data-theme="dark"] details.hist-month > summary { color: var(--accent-bright); }
.hist-year .hy-count, .hist-month .hm-count {
  font-size: .7rem; color: var(--muted); background: var(--paper-2);
  padding: .1rem .5rem; border-radius: 999px; font-weight: 600;
}
details.hist-month { padding-left: 1rem; }
.act-creee { background: #e6eefb; color: #1c4fb0; }
.act-modifiee { background: #fff3e0; color: #b06a00; }
.act-reassignee { background: #f3e8fd; color: #7e22ce; }
.act-reportee { background: var(--amber-soft); color: var(--warn); }
.act-validee { background: var(--green-soft); color: var(--green-deep); }
.act-parkee { background: #ede7f6; color: #5e35b1; }
.act-supprimee { background: var(--alert-soft); color: var(--alert); }
.act-restauree { background: #e6eefb; color: #1c4fb0; }
.act-commentee { background: var(--amber-soft); color: var(--warn); }
.act-echeance { background: #fff3e0; color: var(--warn); }
.act-tour_passe { background: #e8f0fe; color: #1a56db; }
.act-permutation { background: #f3e8fd; color: #7e22ce; }
.act-tournus { background: #e0f2f1; color: #00695c; }
.act-equipe { background: #eceff1; color: #455a64; }

/* ---------- Desktop : en-tête complet, pas de barre d'onglets ---------- */
@media (min-width: 721px) {
  body { padding-bottom: 0; }
  .topnav { display: flex; }
  .topbar-right { display: flex; }
  .topbar-help-mobile { display: none; }  /* le chip « Comment ça marche ? » s'affiche à droite */
  .tabbar { display: none; }
  h1 { font-size: 2rem; }
}

/* ---------- Petit mobile : actions empilées ---------- */
@media (max-width: 480px) {
  .actions { flex-direction: column; align-items: stretch; }
  .actions .inline { width: 100%; }
  .actions .inline select, .actions .inline input, .actions .inline button { width: 100%; flex: 1 1 100%; }
}

/* Détail d'une tâche : le « quand et où », puis le descriptif. Ni l'un ni
   l'autre n'apparaît dans les listes, qui ne montrent que le titre. */
.task-when {
  font-size: .92rem;
  font-weight: 600;
  color: var(--green-deep);
  margin-top: .25rem;
}
.task-desc {
  margin: .45rem 0 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* --- Projets ------------------------------------------------------------- */
/* La barre d'avancement est le signal principal : elle se lit avant le texte. */
.proj-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.proj-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.proj-row { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.proj-name { font-weight: 700; font-size: 1.02rem; text-decoration: none; }
.proj-when { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.proj-when-big { font-weight: 600; color: var(--accent-bright, var(--accent)); margin: .2rem 0; }
.proj-bar {
  background: var(--line);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
}
.proj-bar.big { height: 11px; }
.proj-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}
.proj-sub { font-size: .85rem; color: var(--muted); margin: 0; }
.proj-head { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }

/* Les trois groupes de la page projet : toujours les mêmes, toujours dans cet ordre. */
.group-head {
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1rem 0 .4rem;
  display: flex;
  gap: .45rem;
  align-items: baseline;
}
.group-head:first-child { margin-top: 0; }
.group-head em { font-style: normal; font-weight: 700; color: var(--accent-bright, var(--accent)); }

/* Pastille de rattachement : le seul élément visuel ajouté aux listes. */
.projet-pastille {
  display: inline-block;
  font-size: .74rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

/* --- Calendrier ---------------------------------------------------------- */
.jour-titre { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.jour-date { font-size: .82rem; font-weight: 400; color: var(--muted); }
.agenda { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; }
.agenda-item {
  display: flex;
  gap: .75rem;
  padding: .5rem 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.agenda-item:first-child { border-top: 0; }
.agenda-heure {
  flex: none;
  min-width: 3.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--muted);
}
.genre-reunion .agenda-heure { color: var(--accent-bright, var(--accent)); }
.agenda-corps { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: baseline; }
.agenda-titre { font-weight: 600; text-decoration: none; }
.agenda-chip {
  font-size: .72rem;
  padding: .08rem .4rem;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.genre-reunion .agenda-chip { background: var(--accent); color: #fff; }
.agenda-meta { font-size: .82rem; color: var(--muted); width: 100%; }
.ics-url code {
  display: block;
  overflow-x: auto;
  padding: .5rem .6rem;
  background: var(--line);
  border-radius: 6px;
  font-size: .8rem;
  white-space: nowrap;
}
.accueil-liens { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-add.secondaire { background: transparent; border: 1px solid var(--accent); color: var(--accent); }

/* L'astuce de fin d'aide : une carte, mais qui se détache un peu. */
.aide-astuce { border-left: 3px solid var(--accent); }

/* Formulaire d'ajout : choix du type en quatre pastilles, champs propres à chacun.
   Bascule en CSS pur : les radios sont frères des blocs .f-* qu'ils révèlent. */
.add-form .type-radio { position: absolute; opacity: 0; width: 1px; height: 1px; }
.add-form .type-chip { display: inline-block; margin: .2rem .3rem .5rem 0; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); font-weight: 600; cursor: pointer; }
.add-form .type-radio:checked + .type-chip { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
.add-form .type-radio:focus-visible + .type-chip { outline: 2px solid var(--green-deep); outline-offset: 2px; }
.add-form .f-tache, .add-form .f-coll, .add-form .f-reu, .add-form .f-projet, .add-form .f-rdv, .add-form .f-limite { display: none; }
.add-form #t-tache:checked ~ .f-tache,
.add-form #t-coll:checked ~ .f-coll,
.add-form #t-reu:checked ~ .f-reu,
.add-form #t-projet:checked ~ .f-projet,
.add-form #t-coll:checked ~ .f-rdv,
.add-form #t-reu:checked ~ .f-rdv,
.add-form #t-projet:checked ~ .f-rdv,
.add-form #t-coll:checked ~ details .f-limite { display: block; }
/* Champs d'une tâche seule (« avant le », date prévue) : sans objet pour un rendez-vous ni un projet. */
.add-form #t-coll:checked ~ .f-solo,
.add-form #t-reu:checked ~ .f-solo,
.add-form #t-projet:checked ~ .f-solo,
.add-form #t-coll:checked ~ details .f-solo,
.add-form #t-reu:checked ~ details .f-solo,
.add-form #t-projet:checked ~ details .f-solo { display: none; }
.add-form .rdv-titre { font-weight: 600; margin: .6rem 0 0; }
/* Section repliable ayant l'allure d'une carte (Faites, Corbeille). */
details.card.fold > summary { cursor: pointer; list-style: none; }
details.card.fold > summary::-webkit-details-marker { display: none; }
details.card.fold > summary h2 { display: inline; margin: 0; }
details.card.fold > summary::after { content: " ▸"; color: var(--muted); }
details.card.fold[open] > summary::after { content: " ▾"; }
details.card.fold[open] > summary { margin-bottom: .6rem; }
/* Libellés : couleur codée en dur, illisible sur fond sombre. */
:root[data-theme="dark"] label { color: var(--ink); }


/* ---------- Accueil en tuiles ----------
   Une tuile = une question, un chiffre. À zéro, elle reste en place mais s'efface. */
.tuiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin: 0 0 1rem; }
.tuile {
  min-height: 9.5rem; border-radius: 18px; padding: .95rem; text-decoration: none;
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid transparent; box-shadow: var(--shadow); transition: transform .08s;
}
.tuile:active { transform: scale(.98); }
.tuile:focus-visible { outline: 3px solid var(--green-deep); outline-offset: 2px; }
.tuile-n { font-family: var(--font-display); font-size: 2.8rem; font-weight: 700; line-height: 1; }
.tuile-txt { display: flex; flex-direction: column; gap: .15rem; }
.tuile-l { font-size: 1.08rem; font-weight: 700; }
.tuile-s { font-size: .84rem; line-height: 1.3; }
.tuile-faire { background: var(--green); color: var(--on-action); }
.tuile-prendre { background: var(--amber-soft); color: #6b3f08; border-color: #f3d3ad; }
.tuile-cours { background: var(--green-soft); color: var(--on-soft); border-color: color-mix(in srgb, var(--green-soft), var(--on-soft) 14%); }
.tuile-fait { background: var(--card); color: var(--ink); border-color: var(--line); }
.tuile.tuile-vide { background: var(--paper-2); color: var(--muted); border-color: var(--line); box-shadow: none; }

/* Bouton « Ajouter » de l'en-tête : l'action principale, accessible partout. */
.btn-ajouter {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 38px; padding: 0 .95rem;
  border-radius: 999px; background: var(--green); color: var(--on-action); text-decoration: none;
  font-weight: 700; border: 1px solid rgba(255,255,255,.25); white-space: nowrap;
}
.btn-ajouter:hover { filter: brightness(1.08); color: var(--on-action); }
.btn-ajouter svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* Retour vers la page mère (les listes ouvertes par les tuiles, les pages de Moi). */
.retour { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; color: var(--green); }
:root[data-theme="dark"] .retour { color: var(--accent-bright); }

/* Pastilles de la carte « Bientôt » (genres de l'agenda). */
.badge-genre-reunion { background: #ede7f6; color: #4b2f7a; }
.badge-genre-tache { background: #e6eefb; color: #1c4fb0; }
.badge-genre-echeance { background: var(--amber-soft); color: #8a520c; }
.badge-genre-projet { background: #fce7da; color: #9c3d12; }
[class*="badge-genre-"] { font-size: .68rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }


/* Liste de liens de « Moi » (la maison, l'aide) : de grandes lignes faciles à toucher. */
.card.liens { padding-top: .2rem; padding-bottom: .2rem; }
.lien {
  display: flex; align-items: center; justify-content: space-between; min-height: 48px;
  color: var(--ink); text-decoration: none; font-weight: 600; border-top: 1px solid var(--line);
}
.lien:first-child { border-top: 0; }
.lien:hover { color: var(--green-deep); }
:root[data-theme="dark"] .lien:hover { color: var(--accent-bright); }


/* ---------- Infobulles à l'appui long (bulles.js) ---------- */
.bulle {
  position: fixed; z-index: 100; max-width: min(300px, calc(100vw - 16px));
  padding: .65rem .8rem; border-radius: 12px; background: #1f1a2e; color: #fff;
  font-size: .92rem; line-height: 1.4; box-shadow: 0 8px 28px rgba(0,0,0,.28);
  pointer-events: none; animation: bulle-in .12s ease-out;
}
.bulle::after {
  content: ""; position: absolute; left: var(--fleche, 50%); width: 12px; height: 12px;
  margin-left: -6px; background: inherit; transform: rotate(45deg);
}
.bulle-dessus::after { bottom: -5px; }
.bulle-dessous::after { top: -5px; }
:root[data-theme="dark"] .bulle { background: #f5f3f8; color: #1f1a2e; }
@keyframes bulle-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bulle { animation: none; } }
/* Un appui long ne doit ni sélectionner le texte ni ouvrir le menu du navigateur. */
button, .tuile, .tab, .topnav a, .btn-ajouter, .badge, [class*="badge-"], .assignee,
.projet-pastille, .type-chip, details > summary, .retour, .gear {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}

.astuce-bulles {
  display: flex; align-items: center; gap: .7rem; justify-content: space-between;
  padding: .7rem .9rem; margin-bottom: 1rem; border-radius: 12px;
  background: var(--card); border: 1px dashed var(--line); font-size: .92rem;
}
.astuce-bulles[hidden] { display: none; }
.astuce-bulles button { flex-shrink: 0; }


/* ---------- Journal en phrases ---------- */
.journal-filtres { display: flex; gap: .45rem; flex-wrap: wrap; margin: -.4rem 0 1rem; }
.chip-filtre {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 .9rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.chip-filtre.actif { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
ul.history li.journal-ligne { display: flex; gap: .65rem; align-items: flex-start; }
.journal-ligne .av {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--green-soft); color: var(--on-soft); font-weight: 700; font-size: .8rem;
}
.journal-corps { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.journal-phrase { line-height: 1.4; }
.merci { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .2rem; }
.merci form.inline { margin: 0; }
.merci-btn {
  min-height: 34px; padding: 0 .8rem; border-radius: 999px; font-size: .85rem;
  background: var(--card); color: var(--on-soft); border: 1px solid var(--line);
}
.merci-btn.merci-dit { background: var(--green-soft); border-color: var(--green-soft); }
:root[data-theme="dark"] .merci-btn { color: var(--accent-bright); }
.merci-qui { font-size: .82rem; color: var(--muted); }
/* Admin : « × » discret en bout de ligne pour effacer une trace (essais). */
.journal-corps { flex: 1; }
.journal-effacer { margin: 0 0 0 auto; }
.effacer-btn {
  width: 30px; height: 30px; padding: 0; border-radius: 999px; font-size: 1.1rem; line-height: 1;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.effacer-btn:hover { color: var(--ink); background: var(--paper-2); }


/* ---------- Listes allégées (À faire, À prendre) ----------
   Une ligne : un titre qui ouvre la page, une ligne d'info, un seul bouton. */
ul.liste { list-style: none; margin: 0; padding: 0; }
.ligne {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .75rem 0; border-top: 1px solid var(--line);
}
.ligne:first-child { border-top: 0; padding-top: .2rem; }
.ligne-g { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.ligne-t { font-weight: 700; font-size: 1.02rem; color: var(--ink); text-decoration: none; }
.ligne-t:hover { color: var(--green-deep); text-decoration: underline; }
:root[data-theme="dark"] .ligne-t:hover { color: var(--accent-bright); }
.ligne-m { font-size: .86rem; color: var(--muted); }
.ligne form { margin: 0; flex-shrink: 0; }
.ligne button { min-height: 44px; white-space: nowrap; }
.ligne-d { display: flex; gap: .4rem; flex-shrink: 0; }
.status-attente { background: var(--amber-soft); color: #8a520c; font-size: .68rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 700; letter-spacing: .02em; }
@media (max-width: 420px) {
  .ligne { flex-wrap: wrap; }
  .ligne form, .ligne-d { margin-left: auto; }
}
.journal-corps .hist-meta { margin: 0; text-align: left; font-size: .8rem; color: var(--muted); }
.partage { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; }
:root[data-theme="dark"] .task-when { color: var(--accent-bright); }




/* Moi › Notifications : une case par catégorie, avec son explication. */
[hidden] { display: none !important; }
.notif-choix { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.notif-choix:last-of-type { border-bottom: 0; }
.notif-choix input { margin-top: .25rem; width: 1.15rem; height: 1.15rem; flex: none; }
/* Bandeau de l'admin qui voit l'app comme un voisin : texte + bouton de retour. */
.admin-emprunt { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.admin-emprunt button { margin-left: auto; }
/* Moi : l'ancre des onglets En cours / Historique s'arrête sous l'en-tête fixe,
   en laissant voir le titre « Mon activité ». */
.onglets-activite { scroll-margin-top: 6rem; }
