:root {
  --fond: #f4f1ea; --carte: #fffdf8; --texte: #22201c; --doux: #78726a; --ligne: #e3ddd0;
  --accent: #2f6f5e; --sur-accent: #fff; --perso: #c08a2e; --danger: #b3412f;
  --ombre: 0 1px 2px rgba(60,50,30,.06), 0 3px 10px rgba(60,50,30,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #171614; --carte: #23211e; --texte: #ece8e0; --doux: #a39d91; --ligne: #37332d;
    --accent: #62b59d; --sur-accent: #0e1e19; --perso: #e2aa4f; --danger: #e5735e; --ombre: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond); color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }

/* ---------- Connexion ---------- */
.login {
  min-height: 100dvh; max-width: 340px; margin: 0 auto; padding: 24px;
  display: flex; flex-direction: column; justify-content: center; gap: 12px; text-align: center;
}
.login img { margin: 0 auto; border-radius: 18px; }
.login h1 { margin: 4px 0 12px; font-size: 1.5rem; }
.login input {
  padding: 14px; border: 1px solid var(--ligne); border-radius: 12px; background: var(--carte);
}
.btn-principal { background: var(--accent); color: var(--sur-accent); padding: 14px; border-radius: 12px; font-weight: 600; }
.erreur { color: var(--danger); min-height: 1.4em; margin: 0; }

/* ---------- Barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 2; background: var(--fond);
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.barre h1 { margin: 0; font-size: 1.6rem; flex: 1; letter-spacing: -.01em; }
.btn-moi { padding: 6px 12px; border-radius: 999px; background: var(--carte); border: 1px solid var(--ligne); font-size: .9rem; }
.btn-icone { width: 40px; height: 40px; border-radius: 50%; font-size: 1.3rem; flex: none; }
.btn-icone:active { background: var(--ligne); }

/* ---------- Liste des notes ---------- */
.filtres { display: flex; gap: 8px; padding: 0 16px 12px; overflow-x: auto; }
.filtres button {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--ligne);
  background: var(--carte); font-size: .9rem; white-space: nowrap;
}
.filtres button.actif { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); }

.liste { display: grid; gap: 10px; padding: 0 16px 110px; }
@media (min-width: 640px) { .liste { grid-template-columns: 1fr 1fr; } }
.carte {
  text-align: left; background: var(--carte); border: 1px solid var(--ligne); border-left: 4px solid var(--perso);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--ombre); display: block; width: 100%;
}
.carte.partagee { border-left-color: var(--accent); }
.carte h2 { margin: 0 0 4px; font-size: 1.05rem; }
.carte .apercu {
  color: var(--doux); font-size: .92rem; white-space: pre-line; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.carte .meta { margin-top: 8px; font-size: .78rem; color: var(--doux); }
.vide { text-align: center; color: var(--doux); padding: 48px 16px; }

.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 18px; background: var(--accent); color: var(--sur-accent);
  font-size: 2rem; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.choix {
  position: fixed; right: 20px; bottom: calc(92px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.choix button {
  background: var(--carte); border: 1px solid var(--ligne); padding: 12px 18px;
  border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.15); font-weight: 600;
}

/* ---------- Éditeur ---------- */
#vue-note:not([hidden]) { display: flex; flex-direction: column; min-height: 100dvh; }
.titre {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 1.25rem; font-weight: 650; padding: 6px 4px;
}
.note { flex: 1; display: flex; flex-direction: column; padding: 0 16px; }
#note-texte {
  flex: 1; min-height: 60vh; border: 0; outline: none; resize: none; background: none;
  padding: 8px 4px; line-height: 1.55;
}
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.item input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.item input[type=text], .ajout-item input {
  flex: 1; min-width: 0; border: 0; border-bottom: 1px solid transparent; background: none; outline: none; padding: 8px 2px;
}
.item input[type=text]:focus, .ajout-item input:focus { border-bottom-color: var(--ligne); }
.item.coche input[type=text] { text-decoration: line-through; color: var(--doux); }
.item .suppr { width: 32px; height: 32px; color: var(--doux); font-size: 1.2rem; flex: none; border-radius: 50%; }
.ajout-item { display: flex; align-items: center; gap: 10px; color: var(--doux); }
.ajout-item span { width: 22px; text-align: center; font-size: 1.3rem; }
.coches-entete {
  display: flex; align-items: center; gap: 14px; margin-top: 18px; padding-top: 12px;
  border-top: 1px solid var(--ligne); font-size: .88rem; color: var(--doux);
}
.coches-entete span { flex: 1; }
.coches-entete button { color: var(--accent); font-weight: 600; }

.pied {
  position: sticky; bottom: 0; background: var(--fond); border-top: 1px solid var(--ligne);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.partage { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.info { font-size: .78rem; color: var(--doux); }
.switch {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 44px; height: 26px; border-radius: 13px; background: var(--ligne); position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 21px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 10px; font-size: .92rem;
  max-width: calc(100% - 32px); z-index: 10;
}
