/* ============================================================================
   Fiches — photographier une fiche, la ranger, ne pas oublier de la rendre.
   Même langage que le centre de contrôle : graphite chaud, un seul accent ambre
   qui veut dire MAINTENANT. Pas de mouvement en boucle.
   ========================================================================== */

:root {
  --deep:  #100f0d;
  --page:  #141312;
  --card:  #1b1a17;
  --card2: #232220;
  --raise: #2a2825;

  --line:        rgba(239, 233, 222, .08);
  --line-fort:   rgba(239, 233, 222, .16);

  --ink:   #efe9de;
  --ink-2: #a8a196;
  --ink-3: #857f76;

  --accent:     #e8a33d;
  --accent-ink: #f3c07b;

  --pos:  #4cc38a;
  --neg:  #e5484d;

  --r: 14px;
  --r-s: 10px;
  --ease: cubic-bezier(.22, 1, .36, 1);

  --bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 21px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(96px + var(--bas));
  overscroll-behavior-y: contain;
}

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

/* ------------------------------------------------------------- en-tête --- */

.entete {
  position: sticky; top: 0; z-index: 20;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 12px;
  background: linear-gradient(var(--page) 72%, rgba(20, 19, 18, 0));
}
.titre { font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -.03em; }
.sous { color: var(--ink-3); font-size: 12.5px; line-height: 17px; margin-top: 1px; }

/* --------------------------------------------------------------- liste --- */

main { padding: 0 16px; }

.groupe { margin-top: 22px; }
.groupe-h {
  display: flex; align-items: baseline; gap: 8px;
  padding: 0 4px 8px;
  font-size: 11.5px; line-height: 16px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3);
}
.groupe-h .n { margin-left: auto; letter-spacing: 0; }

.carte {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 14px;
  margin-bottom: 8px;
  text-align: left;
  width: 100%;
  transition: transform .14s var(--ease), background-color .14s var(--ease);
}
.carte:active { transform: scale(.985); background: var(--card2); }

.carte .marque {
  flex: 0 0 34px; height: 34px; border-radius: var(--r-s);
  display: grid; place-items: center;
  background: var(--card2);
  border: 1px solid var(--line);
  font-size: 11px; font-weight: 600; letter-spacing: -.02em;
  color: var(--ink-2);
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
}
.carte .corps { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.carte .t {
  font-size: 14.5px; line-height: 20px;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.carte .m {
  color: var(--ink-3); font-size: 12px; line-height: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.carte .quand {
  flex: 0 0 auto; text-align: right; padding-top: 2px;
  font-size: 11.5px; line-height: 16px; color: var(--ink-3);
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
}
.carte .quand b { display: block; color: var(--ink-2); font-weight: 500; }

/* l'urgence se dit par la couleur, une seule fois */
.carte.retard { border-color: rgba(229, 72, 77, .32); }
.carte.retard .quand b { color: var(--neg); }
.carte.aujourdhui { border-color: rgba(232, 163, 61, .45); }
.carte.aujourdhui .quand b { color: var(--accent); }
.carte.faite { opacity: .5; }
.carte.faite .t { text-decoration: line-through; }

.vide {
  padding: 56px 24px; text-align: center; color: var(--ink-3);
  font-size: 14px; line-height: 21px;
}
.vide b { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }

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

.fab {
  position: fixed; z-index: 30;
  right: 20px; bottom: calc(22px + var(--bas));
  width: 62px; height: 62px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #1a1610;
  display: grid; place-items: center;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .55), 0 1px 0 rgba(255, 255, 255, .22) inset;
  transition: transform .14s var(--ease), opacity .14s var(--ease);
}
.fab:active { transform: scale(.94); }
.fab svg { width: 28px; height: 28px; }
.fab[disabled] { opacity: .55; }

button { cursor: pointer; border-radius: var(--r-s); border: 1px solid var(--line-fort); background: var(--card2); padding: 12px 16px; }
button:active { transform: translateY(1px); }

button.principal { background: #e6e0d4; border-color: #e6e0d4; color: #141312; font-weight: 600; }
button.secondaire { background: transparent; color: var(--ink-2); }
button.lien { background: none; border: none; padding: 6px 0; color: var(--ink-2); font-size: 13.5px; }
button.lien.danger { color: var(--neg); }
button.large { width: 100%; margin-top: 10px; }

/* ------------------------------------------------------- feuille (sheet) --- */

.voile {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .55);
  animation: voile .2s var(--ease) both;
}
@keyframes voile { from { opacity: 0 } to { opacity: 1 } }

.feuille {
  position: fixed; z-index: 50;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh; overflow-y: auto;
  background: var(--card);
  border-top: 1px solid var(--line-fort);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(28px + var(--bas));
  animation: monte .26s var(--ease) both;
}
@keyframes monte { from { transform: translateY(18px); opacity: 0 } to { transform: none; opacity: 1 } }

.feuille-h {
  display: flex; align-items: center; gap: 12px;
  padding: 2px 0 12px;
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.feuille-t { flex: 1; text-align: center; font-size: 13px; color: var(--ink-3); }

.apercu { margin: 0 0 14px; }
.apercu img {
  width: 100%; max-height: 26vh; object-fit: contain;
  background: var(--deep); border-radius: var(--r-s); border: 1px solid var(--line);
  display: block;
}
.apercu:empty { display: none; }

.champ { display: block; margin-bottom: 12px; }
.champ > span { display: block; font-size: 11.5px; line-height: 16px; color: var(--ink-3); margin-bottom: 5px; }

input[type="text"], input[type="date"], textarea {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 12px 13px;
  font-size: 15px;
  color: var(--ink);
  resize: vertical;
  transition: border-color .14s var(--ease), background-color .14s var(--ease);
}
input::placeholder, textarea::placeholder { color: #6e6862; }
input:focus, textarea:focus { outline: none; border-color: rgba(232, 163, 61, .5); background: #262421; }
input[type="date"] { color-scheme: dark; }

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

.note { margin: 12px 0 0; font-size: 12px; line-height: 17px; color: var(--ink-3); min-height: 17px; }
.note.bad { color: var(--neg); }

/* --------------------------------------------------------------- toast ---- */

.toast {
  position: fixed; z-index: 70;
  left: 16px; right: 16px;
  bottom: calc(98px + var(--bas));
  margin: 0 auto;
  max-width: 420px;
  background: var(--raise);
  border: 1px solid rgba(232, 163, 61, .38);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 13px; line-height: 18px;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.vu { opacity: 1; transform: none; }


/* ------------------------------------------------------------ etats ------- */

.chargement {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; gap: 14px;
  background: rgba(16, 15, 13, .82);
  color: var(--ink-2); font-size: 13.5px;
  animation: voile .16s var(--ease) both;
}
.chargement .rond {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line-fort);
  border-top-color: var(--accent);
  animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg) } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
