:root {
  --vert: #0b5d3b; --vert-pale: #e6f2ec; --rouge: #c62828; --rouge-pale: #fdecec; --orange: #b45309;
  --orange-pale: #fff4e5; --bleu: #1d4ed8; --gris: #6b7280; --ligne: #e5e7eb; --fond: #f6f7f8; --carte: #fff;
  --texte: #111827; --rayon: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #0f1412; --carte: #18201c; --texte: #e8ece9; --ligne: #2a332e; --gris: #9aa3a0;
          --vert-pale: #12301f; --rouge-pale: #3a1515; --orange-pale: #3a2a12; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 120px; }
h1 { font-size: 1.35rem; margin: 8px 0 14px; }
h2 { font-size: 1.05rem; margin: 18px 0 8px; }
.muted { color: var(--gris); font-size: .9rem; }
.small { font-size: .82rem; }
.card { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 14px; margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* Barre du haut */
.top { position: sticky; top: 0; z-index: 5; background: var(--vert); color: #fff; }
.top .in { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.top a { text-decoration: none; color: #fff; }
.top .brand { font-weight: 700; flex: 1; }

/* Navigation du bas */
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; background: var(--carte); border-top: 1px solid var(--ligne);
  display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
nav.bottom a { text-decoration: none; font-size: .72rem; color: var(--gris); text-align: center; flex: 1; padding: 4px 0; }
nav.bottom a .ico { display: block; font-size: 1.3rem; }
nav.bottom a.on { color: var(--vert); font-weight: 600; }

nav.bottom.desktop-only { display: none; }
@media (min-width: 900px) {
  nav.bottom.desktop-only { display: flex; }
  /* Écran de création : le bouton Envoyer se place au-dessus de la barre */
  .send-bar { bottom: calc(57px + env(safe-area-inset-bottom)); border-bottom: 1px solid var(--ligne); }
  body:has(.send-bar) main { padding-bottom: 180px; }
}

/* Bouton flottant : nouvelle tâche + micro */
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 12px; z-index: 6; }
.fab a, .fab button { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--vert); color: #fff;
  font-size: 1.8rem; display: grid; place-items: center; text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.fab .mic { background: #fff; color: var(--vert); border: 2px solid var(--vert); font-size: 1.5rem; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--ligne); background: var(--carte); color: var(--texte); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--vert); color: #fff; border-color: var(--vert); }
.btn.danger { background: var(--rouge); color: #fff; border-color: var(--rouge); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; }
.btn.big { width: 100%; padding: 18px; font-size: 1.2rem; border-radius: 14px; }

/* Compteurs (accueil de Hugo) */
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.counters.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 600px) { .counters.four { grid-template-columns: repeat(4, 1fr); } }
.counter { display: block; text-decoration: none; border-radius: var(--rayon); padding: 16px 8px; text-align: center;
  background: var(--carte); border: 1px solid var(--ligne); }
.counter b { display: block; font-size: 2.3rem; line-height: 1.1; }
.counter span { font-size: .85rem; color: var(--gris); }
.counter.alert { background: var(--orange-pale); border-color: var(--orange); }
.counter.alert b { color: var(--orange); }
.counter.late.alert { background: var(--rouge-pale); border-color: var(--rouge); }
.counter.late.alert b { color: var(--rouge); }

/* Listes de tâches */
.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li { position: relative; overflow: hidden; border-radius: var(--rayon); margin-bottom: 8px; }
.tasks a.item { display: block; text-decoration: none; background: var(--carte); border: 1px solid var(--ligne);
  border-radius: var(--rayon); padding: 12px 14px; position: relative; transition: transform .15s; touch-action: pan-y; }
.tasks .t { font-weight: 600; }
.tasks .meta { font-size: .82rem; color: var(--gris); margin-top: 3px; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--ligne); color: var(--texte); vertical-align: middle; }
.badge.urgent { background: var(--rouge); color: #fff; }
.badge.late { background: var(--rouge-pale); color: var(--rouge); }
.badge.unread { background: var(--bleu); color: #fff; }
.badge.ai { background: #ede9fe; color: #5b21b6; }
.badge.st-nouveau { background: #dbeafe; color: #1e40af; }
.badge.st-besoin_info { background: var(--orange-pale); color: var(--orange); }
.badge.st-regle { background: #fef9c3; color: #854d0e; }
.badge.st-ferme { background: var(--vert-pale); color: var(--vert); }
.badge.st-ferme_non_valide { background: #f3f4f6; color: #6b7280; }
.swipe-bg { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 0 18px; font-weight: 700; color: #fff; border-radius: var(--rayon);
  background: linear-gradient(90deg, var(--vert) 50%, var(--orange) 50%); }

/* Formulaires */
label { display: block; font-size: .85rem; color: var(--gris); margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=datetime-local], input[type=search], input[type=number], textarea, select {
  width: 100%; padding: 12px; border: 1px solid var(--ligne); border-radius: 10px; font: inherit; background: var(--carte);
  color: var(--texte); }
textarea { resize: vertical; min-height: 90px; }
textarea.desc { min-height: 120px; font-size: 1.05rem; }

/* Création rapide */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip { border: 1.5px solid var(--ligne); background: var(--carte); color: var(--texte); border-radius: 999px;
  padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--vert); border-color: var(--vert); color: #fff; }
.chip.suggested:not(.on) { border-color: var(--vert); border-style: dashed; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--ligne); }
.thumbs .add { width: 76px; height: 76px; border-radius: 10px; border: 2px dashed var(--ligne); display: grid;
  place-items: center; font-size: 1.6rem; color: var(--gris); cursor: pointer; }
.ai-status { font-size: .85rem; color: #5b21b6; display: flex; align-items: center; gap: 6px; min-height: 1.4em; }
.spin { width: 14px; height: 14px; border: 2px solid #c4b5fd; border-top-color: #5b21b6; border-radius: 50%;
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-box { border-left: 3px solid #8b5cf6; padding: 6px 10px; background: #f5f3ff; border-radius: 6px; font-size: .9rem;
  color: #3b0764; }
@media (prefers-color-scheme: dark) { .ai-box { background: #1e1530; color: #ddd6fe; } }
.send-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--carte); border-top: 1px solid var(--ligne); z-index: 7; }
.send-bar .in { max-width: 760px; margin: 0 auto; }
details.more summary { cursor: pointer; color: var(--gris); padding: 8px 0; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 1rem; color: var(--texte); margin: 0; }
.toggle input { width: 22px; height: 22px; }
.mic-hold { width: 100%; padding: 14px; border-radius: 14px; border: 2px solid var(--vert); background: var(--carte);
  color: var(--vert); font: inherit; font-weight: 700; user-select: none; -webkit-user-select: none; touch-action: none; }
.mic-hold.rec { background: var(--rouge); border-color: var(--rouge); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .75; } }
.toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: var(--vert); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 20; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.toast.err { background: var(--rouge); }

/* Détail d'une tâche */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ligne); margin: 14px 0 10px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--gris); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--vert); border-color: var(--vert); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.proof { border: 2px solid var(--vert); background: var(--vert-pale); }
.proof h2 { margin-top: 0; color: var(--vert); }
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--carte); border: 1px solid var(--ligne);
  align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; }
.msg.mine { align-self: flex-end; background: var(--vert-pale); border-color: transparent; }
.msg .who { font-size: .75rem; font-weight: 700; color: var(--vert); }
.msg .when { font-size: .7rem; color: var(--gris); margin-top: 2px; }
.msg img { max-width: 220px; border-radius: 10px; display: block; margin-top: 6px; }
.msg.sys { align-self: center; background: transparent; border: 0; font-size: .8rem; color: var(--gris); padding: 2px; }
.mention { color: var(--bleu); font-weight: 600; }
.composer { position: sticky; bottom: env(safe-area-inset-bottom); background: var(--fond); padding: 8px 0; }
@media (min-width: 900px) { .composer { bottom: calc(57px + env(safe-area-inset-bottom)); } }
.composer .row { flex-wrap: nowrap; }
.composer textarea { min-height: 44px; height: 44px; }
.ac { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--carte); border: 1px solid var(--ligne);
  border-radius: 10px; max-height: 220px; overflow: auto; z-index: 9; }
.ac div { padding: 10px 12px; cursor: pointer; }
.ac div.on, .ac div:hover { background: var(--vert-pale); }
.timeline { list-style: none; padding: 0 0 0 18px; margin: 0; border-left: 2px solid var(--ligne); }
.timeline li { position: relative; padding: 6px 0 10px 10px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 11px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ligne); }
.timeline li.step::before { background: var(--vert); }
.timeline .gap { font-size: .75rem; color: var(--gris); margin: -4px 0 4px -10px; font-style: italic; }
.overdue { color: var(--rouge); font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--ligne); font-size: .92rem; }
dialog { border: 0; border-radius: var(--rayon); padding: 18px; width: min(520px, 92vw); background: var(--carte); color: var(--texte); }
dialog::backdrop { background: rgba(0,0,0,.4); }
