/* REX KORENN. Deux registres, deux couleurs reprises de la zone REX de Folio :
   violet pour la conception, orange pour le chantier. Le reste est neutre. */
:root {
  --fond: #f5f2ee; --carte: #ffffff; --encre: #1e1925; --doux: #6b6475; --trait: #e4dee4;
  --con: #6a1b9a; --con-pale: #f3e9f8; --cha: #c25400; --cha-pale: #fdf0e4;
  --ok: #2e7d32; --ok-pale: #e8f3e9; --alerte: #a33b1f; --bandeau: #2a1638;
  --ombre: 0 1px 2px rgba(30, 20, 40, .06), 0 4px 14px rgba(30, 20, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #15111a; --carte: #211b29; --encre: #eee8f2; --doux: #a59db0; --trait: #362e40;
    --con: #c08ae0; --con-pale: #2e2138; --cha: #ff9d4d; --cha-pale: #36261a;
    --ok: #7cc982; --ok-pale: #1d2e20; --alerte: #ff8a6b; --bandeau: #1b1024;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 15px/1.45 -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.bandeau {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bandeau); color: #fff;
}
.marque { display: flex; align-items: center; gap: 10px; }
.marque img { width: 34px; height: 34px; border-radius: 9px; }
.marque b { display: block; font: 600 20px/1 Georgia, "Times New Roman", serif; letter-spacing: .04em; }
.marque small { display: block; font-size: 12px; opacity: .72; margin-top: 2px; }
.pastille {
  display: flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,.22); background: transparent;
  color: #fff; border-radius: 99px; padding: 4px 11px; font-size: 12px; max-width: 52vw;
}
.pastille span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pastille i { width: 8px; height: 8px; border-radius: 50%; background: #9a93a3; flex: none; }
.pastille[data-e=ok] i { background: #6fd27a; }
.pastille[data-e=envoi] i { background: #f3c25a; }
.pastille[data-e=hors-ligne] i, .pastille[data-e=code] i { background: #ff7a59; }

.page { max-width: 860px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }

/* ---------- dépôt ---------- */
.depot {
  --r: var(--con); --r-pale: var(--con-pale);
  background: var(--carte); border-radius: 16px; box-shadow: var(--ombre); padding: 14px;
  border-top: 4px solid var(--r);
}
.depot[data-registre=chantier] { --r: var(--cha); --r-pale: var(--cha-pale); }
.registres { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.registres button {
  border: 1px solid var(--trait); background: transparent; border-radius: 10px; padding: 9px 6px;
  font-weight: 600; color: var(--doux);
}
.registres button span { font-weight: 400; font-size: 12px; letter-spacing: .06em; margin-right: 2px; }
.registres button[data-r=conception][aria-selected=true] { background: var(--con); border-color: var(--con); color: #fff; }
.registres button[data-r=chantier][aria-selected=true] { background: var(--cha); border-color: var(--cha); color: #fff; }
@media (prefers-color-scheme: dark) {
  .registres button[aria-selected=true] { color: #15111a !important; }
}
textarea {
  width: 100%; border: 1px solid var(--trait); border-radius: 10px; padding: 11px 12px; resize: vertical;
  background: var(--fond); min-height: 120px; font-size: 16px; /* 16 px : iOS ne zoome pas sur le champ */
}
textarea:focus, input[type=search]:focus, #champCode:focus { outline: 2px solid var(--r, var(--con)); outline-offset: 1px; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.aide { flex: 1; font-size: 12px; color: var(--doux); }
@media (hover: none) { .aide { visibility: hidden; } }
.bouton {
  border: 1px solid var(--trait); background: var(--carte); border-radius: 10px; padding: 9px 16px; font-weight: 600;
}
.bouton.fort { background: var(--r, var(--con)); border-color: var(--r, var(--con)); color: #fff; }
.bouton.fort:disabled { opacity: .4; cursor: default; }
.bouton.discret { color: var(--doux); font-weight: 500; }
@media (prefers-color-scheme: dark) { .bouton.fort { color: #15111a; } }

.vignettes { display: flex; flex-wrap: wrap; gap: 8px; }
.vignettes:not(:empty) { margin-top: 10px; }
.vignette { position: relative; width: 72px; height: 72px; border-radius: 9px; overflow: hidden; background: var(--trait); border: 0; padding: 0; }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette .x {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 13px; line-height: 22px; padding: 0;
}

/* ---------- filtres ---------- */
.outils { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 22px 0 6px; }
.puces { display: flex; gap: 4px; flex-wrap: wrap; }
.puces button {
  border: 1px solid var(--trait); background: transparent; border-radius: 99px; padding: 4px 12px; font-size: 13px; color: var(--doux);
}
.puces button.on { background: var(--encre); border-color: var(--encre); color: var(--fond); }
.puces button b { font-weight: 700; margin-left: 4px; }
input[type=search] {
  flex: 1 1 180px; min-width: 0; border: 1px solid var(--trait); border-radius: 99px; padding: 6px 14px; background: var(--carte); font-size: 16px;
}
.resume { color: var(--doux); font-size: 13px; margin: 8px 2px 10px; }

/* ---------- liste ---------- */
.liste { display: flex; flex-direction: column; gap: 10px; }
.rex {
  --r: var(--con); --r-pale: var(--con-pale);
  background: var(--carte); border-radius: 14px; box-shadow: var(--ombre); padding: 12px 14px 12px 16px;
  border-left: 4px solid var(--r); min-width: 0;
}
.rex[data-registre=chantier] { --r: var(--cha); --r-pale: var(--cha-pale); }
.rex header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12px; color: var(--doux); }
.rex .code { font-weight: 700; color: var(--r); font-size: 13px; letter-spacing: .02em; }
.rex .statut { margin-left: auto; border-radius: 99px; padding: 1px 9px; background: var(--fond); font-weight: 600; white-space: nowrap; }
.rex .statut[data-s=a-trancher] { background: #fff3cd; color: #7a5600; }
.rex .statut[data-s=a-verser] { background: var(--r-pale); color: var(--r); }
.rex .statut[data-s=ventilee] { background: var(--ok-pale); color: var(--ok); }
.rex .statut[data-s=modifiee] { background: #fde3dc; color: var(--alerte); }
@media (prefers-color-scheme: dark) {
  .rex .statut[data-s=a-trancher] { background: #3a3014; color: #f3cf6a; }
  .rex .statut[data-s=modifiee] { background: #3a1e17; }
}
.rex .texte { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }
.rex .texte.replie { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.rex .plus { border: 0; background: none; color: var(--r); padding: 2px 0; font-size: 13px; font-weight: 600; }
.rex .source { font-size: 12px; color: var(--doux); margin-top: 6px; }
.rex .outils-rex { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.rex .outils-rex button { border: 1px solid var(--trait); background: transparent; border-radius: 8px; padding: 3px 10px; font-size: 13px; color: var(--doux); }
.rex textarea { margin-top: 8px; min-height: 140px; }

.analyse { margin-top: 10px; border-top: 1px dashed var(--trait); padding-top: 9px; }
.analyse .par { font-size: 12px; color: var(--doux); }
.analyse .lu { margin: 3px 0 8px; font-style: italic; }
.dest { display: grid; grid-template-columns: 26px 1fr auto; gap: 2px 8px; padding: 8px 0; border-top: 1px solid var(--trait); }
.dest:first-of-type { border-top: 0; }
.dest input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--r); }
.dest .vers { font-weight: 600; }
.dest .vers small { font-weight: 400; color: var(--doux); }
.dest p { margin: 3px 0 0; }
.dest .propose { grid-column: 2 / 4; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--fond); border-radius: 8px; padding: 6px 9px; font-size: 14px; }
.dest .pourquoi { grid-column: 2 / 4; font-size: 12px; color: var(--doux); }
.dest .ecarter { border: 0; background: none; color: var(--doux); font-size: 12px; padding: 0 2px; align-self: start; }
.dest[data-e=ecarte] .vers, .dest[data-e=ecarte] .propose { text-decoration: line-through; opacity: .55; }
.dest[data-e=verse] .coche { color: var(--ok); font-weight: 700; text-align: center; }
.dest .fait { grid-column: 2 / 4; font-size: 12px; color: var(--ok); }
.vide { text-align: center; color: var(--doux); padding: 30px 10px; }
.pied { font-size: 13px; color: var(--doux); text-align: center; margin-top: 28px; }

/* ---------- code, visionneuse, toast ---------- */
dialog { border: 0; border-radius: 18px; padding: 26px 22px; width: min(360px, calc(100vw - 32px)); background: var(--carte); color: var(--encre); text-align: center; }
dialog::backdrop { background: rgba(20, 10, 30, .7); }
dialog .logo { width: 64px; height: 64px; border-radius: 16px; }
dialog h1 { font: 600 22px Georgia, serif; margin: 10px 0 4px; }
dialog p { color: var(--doux); margin: 4px 0 12px; }
#champCode { width: 100%; text-align: center; font-size: 26px; letter-spacing: .3em; padding: 8px; border: 1px solid var(--trait); border-radius: 10px; background: var(--fond); }
.erreur { color: var(--alerte) !important; min-height: 1.2em; font-size: 13px; }
.visionneuse { position: fixed; inset: 0; z-index: 20; background: rgba(10, 6, 14, .92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.visionneuse img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--encre); color: var(--fond); padding: 9px 16px; border-radius: 10px; font-size: 14px; transition: .2s; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
