/* ROOL'ECO AGENT - interface mobile, fond crème verdâtre */
:root {
  color-scheme: light;
  --bg: #F3F6EA;
  --surface: #FFFFFF;
  --surface-2: #E8EEDA;
  --ink: #0F2A28;
  --deep: #052B2A;
  --teal-dark: #0B5F5E;
  --teal: #007F7E;
  --teal-mid: #309F8F;
  --green: #5CC430;
  --green-dark: #3F8F1E;
  --lime: #85B049;
  --sage: #BCD599;
  --mint: #E2EDCF;
  --text: #17302D;
  --muted: #5A6F68;
  --line: rgba(5, 43, 42, .09);
  --line-strong: rgba(5, 43, 42, .16);
  --danger: #B9442F;
  --amber: #B8860B;
  --shadow: 0 1px 2px rgba(5, 43, 42, .05), 0 6px 20px rgba(5, 43, 42, .06);
  --shadow-up: 0 -1px 0 rgba(5, 43, 42, .06), 0 -8px 24px rgba(5, 43, 42, .05);
  --radius: 20px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
  --appbar-h: 60px;
  --tabbar-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overflow: hidden; max-width: 100%; height: 100%; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; min-height: var(--tg-viewport-stable-height, 100dvh);
  color: var(--text); background: var(--bg);
  font: 15px/1.5 "Manrope", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
body.is-loading { overflow: hidden; }
body.sheet-open { overflow: hidden; }
img, video { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Écran de chargement ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 26px;
  background: var(--bg); transition: opacity .5s var(--ease), visibility .5s;
}
.splash img { width: 112px; height: auto; animation: pop .8s var(--ease) both; }
.splash.done { opacity: 0; visibility: hidden; }
.bar { width: 120px; height: 3px; background: var(--mint); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 40%; border-radius: 3px; background: var(--green); animation: sweep 1.2s var(--ease) infinite; }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
@keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(260%); } }

/* ---------- En-tête fixe ---------- */
.appbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--appbar-h) + var(--safe-top));
  padding: var(--safe-top) calc(14px + var(--safe-right)) 0 calc(14px + var(--safe-left));
  display: flex; align-items: center; gap: 10px;
  background: rgba(243, 246, 234, .88); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
body.scrolled .appbar { border-bottom-color: var(--line); }
.appbar-logo { width: 44px; height: auto; flex: none; }
.appbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.appbar-title small { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; color: var(--teal-mid); }
.appbar-title b { font: 600 19px/1.2 "Fraunces", Georgia, serif; color: var(--deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; flex: none; margin-left: -6px; border: 0; border-radius: 12px; background: transparent;
  display: grid; place-items: center; color: var(--deep); cursor: pointer;
}
.icon-btn:active { background: var(--mint); }
.help-btn {
  flex: none; height: 38px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--deep); font-weight: 700; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; box-shadow: var(--shadow);
}
.help-btn:active { transform: scale(.96); }

/* ---------- Contenu ----------
   Chaque écran = une zone fixe en haut (.view-head) + une zone qui défile (.view-scroll).
   La zone de contenu occupe tout l'espace entre l'en-tête et la barre de navigation. */
main {
  --pad-l: max(calc(16px + var(--safe-left)), calc((100% - 528px) / 2));
  --pad-r: max(calc(16px + var(--safe-right)), calc((100% - 528px) / 2));
  position: fixed; left: 0; right: 0; z-index: 1;
  top: calc(var(--appbar-h) + var(--safe-top));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  display: flex; flex-direction: column; overflow: hidden;
}
main > .banner { flex: none; margin: 10px var(--pad-r) 4px var(--pad-l); }
.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.view-head { flex: none; padding: 10px var(--pad-r) 0 var(--pad-l); }
.view-scroll {
  flex: 1 1 auto; min-height: 0; height: 100%;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  touch-action: pan-y; padding: 10px var(--pad-r) 28px var(--pad-l);
}
.view-head + .view-scroll { padding-top: 2px; }
.view.enter { animation: enter .38s var(--ease) both; }
.view.enter-back { animation: enter-back .38s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateX(18px); } }
@keyframes enter-back { from { opacity: 0; transform: translateX(-18px); } }

.banner {
  display: grid; gap: 2px; padding: 14px 16px; margin-bottom: 14px; border-radius: 16px;
  background: #FFF6DA; border: 1px solid #EBDDA8; color: #5C4A12; font-size: 13.5px;
}
.banner b { color: #3F320A; }

.intro { padding: 10px 4px 18px; }
.intro.small { padding-bottom: 14px; }
.intro h1 { margin: 0; font: 600 30px/1.1 "Fraunces", Georgia, serif; color: var(--deep); letter-spacing: -.01em; }
.intro.small h1 { font-size: 26px; }
.intro h1 em { font-style: normal; color: var(--teal); }
.intro p { margin: 8px 0 0; color: var(--muted); }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head.spaced { margin-top: 20px; }
.card-title { font-weight: 800; font-size: 15px; color: var(--deep); }
.hint { font-size: 12.5px; color: var(--muted); }
.muted { color: var(--muted); }
.eyebrow { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--teal-mid); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 18px; border-radius: 16px; border: 0; cursor: pointer;
  font-weight: 800; font-size: 15px; text-decoration: none; text-align: center;
  transition: transform .15s var(--ease), background .2s, opacity .2s; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.big { width: 100%; min-height: 56px; font-size: 16px; border-radius: 18px; }
.btn.primary { background: var(--deep); color: #F3F6EA; box-shadow: 0 8px 20px rgba(5, 43, 42, .18); }
.btn.primary:active { background: var(--teal-dark); }
.btn.soft { background: var(--mint); color: var(--deep); }
.btn.soft.danger { color: var(--danger); background: #F8E6E0; }
.btn.whatsapp { background: #1FAF5A; color: #fff; box-shadow: 0 8px 20px rgba(31, 175, 90, .22); }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 13.5px; border-radius: 12px; }
.btn.loading::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .btn { width: 100%; font-size: 14px; padding: 10px 12px; }
.btn.link { width: 100%; background: none; color: var(--teal-dark); font-size: 14px; min-height: 40px; padding: 6px 10px; gap: 6px; }

/* ---------- Formulaire Créer ---------- */
.drop {
  position: relative; display: grid; place-items: center; min-height: 220px; padding: 0; overflow: hidden; cursor: pointer;
  border: 2px dashed var(--sage); background: linear-gradient(180deg, #FFFFFF, #F8FBF1);
  transition: border-color .2s, transform .15s var(--ease);
}
.drop:active { transform: scale(.99); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-empty { display: grid; justify-items: center; gap: 4px; padding: 26px; text-align: center; }
.drop-empty b { color: var(--deep); font-size: 16px; margin-top: 8px; }
.drop-empty small { color: var(--muted); }
.drop-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--mint); color: var(--teal-dark); }
.drop img { width: 100%; max-height: 360px; object-fit: cover; }
.drop.has-image { border-style: solid; border-color: transparent; }
.drop-change {
  position: absolute; right: 12px; bottom: 12px; padding: 8px 12px; border-radius: 999px;
  background: rgba(5, 43, 42, .78); color: #fff; font-size: 12.5px; font-weight: 700; backdrop-filter: blur(6px);
}
.drop.invalid { border-color: var(--danger); animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

textarea {
  width: 100%; resize: none; border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px 14px;
  font: inherit; font-size: 16px; color: var(--text); background: #FBFCF7; outline: none; transition: border-color .2s, box-shadow .2s;
}
textarea:focus { border-color: var(--teal-mid); box-shadow: 0 0 0 3px rgba(48, 159, 143, .15); }
textarea::placeholder { color: #8C9C95; }
.count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 6px; }

.segmented { display: grid; gap: 8px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px;
  padding: 10px 6px; border-radius: 14px; background: #F4F7EC; border: 1.5px solid transparent;
  font-weight: 800; color: var(--deep); transition: all .2s var(--ease);
}
.segmented small { font-weight: 600; font-size: 11.5px; color: var(--muted); }
.segmented input:checked + span { background: #EAF5E0; border-color: var(--green); box-shadow: 0 4px 12px rgba(92, 196, 48, .18); }
.segmented label:active span { transform: scale(.96); }
.ratio { display: block; border: 2px solid currentColor; border-radius: 3px; margin-bottom: 4px; opacity: .8; }
.r916 { width: 12px; height: 20px; } .r11 { width: 17px; height: 17px; } .r169 { width: 24px; height: 14px; }

.status { min-height: 20px; margin: 10px 4px 0; font-size: 13.5px; color: var(--teal-dark); text-align: center; }
.status.error { color: var(--danger); font-weight: 600; }

/* ---------- Suivi ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border-radius: 16px; padding: 12px 6px; text-align: center;
  box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 0;
}
.stat b { display: block; font: 600 24px/1.1 "Fraunces", Georgia, serif; color: var(--deep); }
.stat span { font-size: 11px; font-weight: 700; color: var(--muted); }
.stat.accent { background: var(--deep); border-color: var(--deep); }
.stat.accent b { color: #fff; } .stat.accent span { color: var(--sage); }

/* Filtres : même grille que les compteurs (4 colonnes égales), sans défilement horizontal.
   La police suit la largeur de l'écran pour que chaque libellé tienne sur une ligne. */
.chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; padding: 2px 0; }
.chip {
  min-width: 0; min-height: 38px; padding: 8px 4px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--deep); font-weight: 700; font-size: clamp(10px, 3.3vw, 13.5px); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
  cursor: pointer; transition: all .2s var(--ease);
}
.chip.on { background: var(--deep); border-color: var(--deep); color: #fff; }
.chip:active { transform: scale(.95); }

.list { display: grid; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; border-radius: 18px; min-width: 0;
  background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); color: inherit; text-decoration: none;
  transition: transform .15s var(--ease);
}
.item:active { transform: scale(.98); }
.thumb { flex: none; width: 64px; height: 64px; border-radius: 14px; overflow: hidden; background: var(--mint); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-top small { color: var(--muted); font-size: 12px; font-weight: 600; }
.item-body b { font-size: 14.5px; color: var(--deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-body > small { font-size: 12.5px; }
.chev { flex: none; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; background: var(--mint); color: var(--teal-dark); white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-sent, .s-processing { background: #E3F1EF; color: var(--teal); }
.s-ready { background: #FFF1CC; color: #8A6100; }
.s-approved { background: #E3F4D8; color: var(--green-dark); }
.s-revision { background: #E7ECF8; color: #3D57A0; }
.s-rejected, .s-failed { background: #F8E6E0; color: var(--danger); }

.progress { height: 6px; border-radius: 6px; background: var(--mint); overflow: hidden; margin: 14px 0 4px; }
.progress.thin { height: 4px; margin: 4px 0 0; }
.progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--green)); transition: width .6s var(--ease); }
.progress.live i { background-size: 200% 100%; animation: flow 1.6s linear infinite; background-image: linear-gradient(90deg, var(--teal), var(--green), var(--teal)); }
@keyframes flow { to { background-position: -200% 0; } }

.empty-state { text-align: center; display: grid; gap: 6px; justify-items: center; padding: 28px 20px; }
.empty-state b { color: var(--deep); font-size: 16px; }
.empty-state p { margin: 0 0 8px; color: var(--muted); }
.center { text-align: center; }
.skeleton { height: 86px; border-radius: 18px; background: linear-gradient(90deg, #E9EEDD, #F7F9F1, #E9EEDD); background-size: 200% 100%; animation: flow 1.4s linear infinite; }

/* ---------- Détail ---------- */
.stage {
  position: relative; border-radius: 24px; overflow: hidden; background: var(--deep); margin-bottom: 14px;
  aspect-ratio: 4 / 5; max-height: 62vh; box-shadow: var(--shadow); display: grid; place-items: center;
}
.stage.r-9x16 { aspect-ratio: 9 / 16; } .stage.r-1x1 { aspect-ratio: 1; } .stage.r-16x9 { aspect-ratio: 16 / 9; }
.stage.r-9x16 { width: min(100%, calc(62vh * 9 / 16)); margin-left: auto; margin-right: auto; }
.stage img, .stage video { width: 100%; height: 100%; object-fit: cover; grid-area: 1 / 1; }
.stage video { object-fit: contain; background: #000; }
.stage.working img { filter: saturate(.7) brightness(.75); }
.stage-veil { grid-area: 1 / 1; z-index: 2; display: grid; justify-items: center; gap: 6px; color: #fff; text-align: center; padding: 20px; }
.stage-veil b { font-size: 16px; }
.stage-veil small { font-weight: 700; opacity: .85; }
.pulse { display: flex; gap: 6px; margin-bottom: 6px; }
.pulse i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); animation: bounce 1s infinite ease-in-out; }
.pulse i:nth-child(2) { animation-delay: .15s; } .pulse i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
.stage .pill { position: absolute; top: 12px; left: 12px; z-index: 3; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }

.d-title { margin: 4px 0 4px; font: 600 21px/1.25 "Fraunces", Georgia, serif; color: var(--deep); }
#d-message { margin: 0; }
#d-message:empty { display: none; }
.steps { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.steps li { display: grid; justify-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; }
.steps span { width: 12px; height: 12px; border-radius: 50%; background: var(--mint); border: 2px solid var(--sage); }
.steps li.done { color: var(--green-dark); } .steps li.done span { background: var(--green); border-color: var(--green); }
.steps li.now { color: var(--deep); } .steps li.now span { background: #fff; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(0, 127, 126, .15); }
.steps li.bad { color: var(--danger); } .steps li.bad span { border-color: var(--danger); background: #F8E6E0; box-shadow: none; }

.decision { border: 1.5px solid var(--sage); background: linear-gradient(180deg, #FFFFFF, #F6FAEE); }
.decision > p { margin: 6px 0 14px; }
.decide { display: grid; gap: 10px; }
.revise { display: grid; gap: 10px; }

.outcome { display: flex; gap: 14px; align-items: center; }
.outcome p { margin: 2px 0 0; }
.outcome b { color: var(--deep); }
.s-pub-pending, .s-pub-sending, .s-pub-scheduled, .s-pub-unconfirmed { background: #FFF1CC; color: #8A6100; }
.s-pub-published { background: #E3F4D8; color: var(--green-dark); }
.s-pub-partial, .s-pub-failed { background: #F8E6E0; color: var(--danger); }
.pub { margin-top: 0; }
.pub-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pub-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.pub-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: #F6F8EF; }
.pub-list li b { color: var(--deep); font-size: 14px; }
.pub-list li .why { grid-column: 1 / -1; font-size: 12.5px; color: var(--danger); font-weight: 700; }
.pub-list li .raw { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); word-break: break-word; }
.pub-list li.live .pill::before { animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
.pub-note { margin: 10px 0 0; font-size: 12.5px; }
.outcome-icon { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 18px; }

#d-download { margin-bottom: 14px; }
.specs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 0; }
.specs div { background: #F6F8EF; border-radius: 12px; padding: 10px; min-width: 0; }
.specs dt { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.specs dd { margin: 2px 0 0; font-weight: 800; color: var(--deep); font-size: 13.5px; }
.brief { margin-top: 12px; background: #F6F8EF; border-radius: 12px; padding: 10px 12px; }
.brief small { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.brief p { margin: 2px 0 0; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 14px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--mint); }
.timeline .dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--sage); }
.timeline li.latest .dot { background: var(--green); box-shadow: 0 0 0 4px rgba(92, 196, 48, .18); }
.timeline b { display: block; font-size: 14px; color: var(--deep); font-weight: 700; }
.timeline small { color: var(--muted); font-size: 12px; }

/* ---------- Bibliothèque ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.vcard { background: var(--surface); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.vthumb { position: relative; display: block; aspect-ratio: 1; background: var(--mint); overflow: hidden; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s var(--ease); }
.vthumb:active img { transform: scale(1.04); }
.vthumb .play {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); display: grid; place-items: center; color: var(--deep); box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.vthumb .pill { position: absolute; top: 8px; left: 8px; }
.vthumb .fmt { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 8px; background: rgba(5, 43, 42, .75); color: #fff; font-size: 11px; font-weight: 700; }
.vbody { padding: 10px; display: grid; gap: 8px; }
.vbody small { color: var(--muted); font-weight: 700; font-size: 12px; }
.vbody .btn { width: 100%; }

/* ---------- Rapport ---------- */
.report-head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.report-head img { width: 64px; height: auto; }
.report-head b { display: block; font: 600 18px/1.2 "Fraunces", Georgia, serif; color: var(--deep); }
.report-head small { color: var(--muted); font-weight: 600; }
.report-head-text { flex: 1; min-width: 0; }
.report-dl {
  position: relative; flex: none; margin-left: auto; width: 46px; min-height: 46px; padding: 0; border-radius: 15px;
  overflow: visible; isolation: isolate;
  transition: transform .2s var(--ease), background .35s var(--ease), color .35s var(--ease), box-shadow .35s var(--ease);
}
.report-dl:active { transform: scale(.92); }
.report-dl .dl-icon { overflow: visible; }
.report-dl .dl-arrow, .report-dl .dl-tray { transition: opacity .25s var(--ease), transform .35s var(--ease); transform-box: view-box; transform-origin: 12px 18px; }
.report-dl .dl-check { stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; stroke-width: 2.4; }
.report-dl .dl-ring {
  position: absolute; inset: -3px; border-radius: 18px; padding: 2.5px; opacity: 0; pointer-events: none; z-index: -1;
  background: conic-gradient(from 0deg, transparent 0 25%, var(--teal-mid) 55%, var(--green) 75%, transparent 76% 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  transition: opacity .3s var(--ease);
}
/* Préparation : la flèche plonge dans le plateau, un anneau tourne autour du bouton. */
.report-dl.loading { opacity: 1; background: var(--surface); color: var(--teal-dark); box-shadow: 0 6px 18px rgba(0, 127, 126, .18); }
.report-dl.loading::after { content: none; }
.report-dl.loading .dl-ring { opacity: 1; animation: dl-spin 1.1s linear infinite; }
.report-dl.loading .dl-arrow { animation: dl-drop 1.1s var(--ease) infinite; }
.report-dl.loading .dl-tray { animation: dl-tray 1.1s var(--ease) infinite; }
/* Terminé : coche dessinée, bouton vert, petite onde. */
.report-dl.done { background: var(--green); color: #fff; box-shadow: 0 8px 22px rgba(92, 196, 48, .35); animation: dl-pop .5s var(--ease); }
.report-dl.done .dl-arrow, .report-dl.done .dl-tray { opacity: 0; transform: scale(.4); }
.report-dl.done .dl-check { opacity: 1; animation: draw .45s .12s var(--ease) forwards; }
.report-dl.done::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1;
  box-shadow: 0 0 0 0 rgba(92, 196, 48, .45); animation: dl-wave .9s var(--ease) forwards;
}
.report-dl.fail { animation: shake .35s; color: var(--danger); background: #F8E6E0; }
@keyframes dl-spin { to { transform: rotate(360deg); } }
@keyframes dl-drop {
  0% { transform: translateY(-9px); opacity: 0; }
  30% { opacity: 1; }
  60% { transform: translateY(1px); opacity: 1; }
  100% { transform: translateY(6px); opacity: 0; }
}
@keyframes dl-tray { 0%, 50% { transform: scaleX(1); } 65% { transform: scaleX(1.12) translateY(.6px); } 85%, 100% { transform: scaleX(1); } }
@keyframes dl-pop { 0% { transform: scale(.86); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes dl-wave { to { box-shadow: 0 0 0 12px rgba(92, 196, 48, 0); } }
#r-download.done { background: var(--green-dark); }
@media (prefers-reduced-motion: reduce) {
  .report-dl.loading .dl-ring, .report-dl.loading .dl-arrow, .report-dl.loading .dl-tray, .report-dl.done, .report-dl.done::before { animation: none; }
  .report-dl.done .dl-check { animation: none; stroke-dashoffset: 0; }
}
.totals { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.totals li { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 12px; background: #F6F8EF; }
.totals li b { font-size: 16px; color: var(--deep); }
.report-total { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--deep); color: #fff; font-weight: 700; }
.report-total b { font: 600 22px "Fraunces", Georgia, serif; }
#r-download { margin-bottom: 4px; }
.mini-table { margin-top: 10px; display: grid; }
.mini-row { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; min-width: 0; }
.mini-row:first-child { border-top: 0; }
.mini-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.mini-row span:first-child { font-weight: 700; color: var(--deep); }

/* ---------- Barre de navigation fixe ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 6px calc(6px + var(--safe-right)) var(--safe-bottom) calc(6px + var(--safe-left));
  background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: var(--shadow-up);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #7E8F88; text-decoration: none; font-size: 11px; font-weight: 700; border-radius: 14px; transition: color .2s;
}
.tabbar a svg { transition: transform .25s var(--ease); }
.tabbar a::before {
  content: ""; position: absolute; top: 2px; width: 54px; height: 30px; border-radius: 999px; background: var(--mint);
  opacity: 0; transform: scale(.6); transition: all .25s var(--ease); z-index: -1;
}
.tabbar a.on { color: var(--deep); }
.tabbar a.on::before { opacity: 1; transform: none; }
.tabbar a:active svg { transform: scale(.9); }
.tabbar a > * { position: relative; }
.badge {
  position: absolute !important; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--green); color: #fff; font: 800 10.5px/18px "Manrope", sans-serif; font-style: normal; text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

/* ---------- Feuille d'aide ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(5, 43, 42, .35); animation: fadein .25s ease both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-width: 560px; margin: 0 auto;
  padding: 10px calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: 0 -10px 40px rgba(5, 43, 42, .15);
  display: grid; gap: 10px; animation: up .35s var(--ease) both;
}
.sheet-grip { justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin-bottom: 6px; }
.sheet h3 { margin: 0; font: 600 22px/1.2 "Fraunces", Georgia, serif; color: var(--deep); }
.sheet p { margin: 0 0 8px; }
@keyframes fadein { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; z-index: 70; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: var(--deep); color: #fff;
  font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(5, 43, 42, .25);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all .3s var(--ease);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--danger); }

@media (min-width: 420px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 340px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip { font-size: 13px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Confirmation d'envoi ---------- */
.sent {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: rgba(5, 43, 42, .22); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .3s var(--ease);
}
.sent.show { opacity: 1; }
.sent-card {
  display: grid; justify-items: center; gap: 4px; min-width: 210px; padding: 24px 28px 22px; border-radius: 24px;
  background: var(--deep); color: #F3F6EA; text-align: center; box-shadow: 0 20px 50px rgba(5, 43, 42, .35);
  transform: scale(.88) translateY(8px); transition: transform .45s var(--ease);
}
.sent.show .sent-card { transform: none; }
.sent-card b { font: 600 20px/1.2 "Fraunces", Georgia, serif; margin-top: 8px; }
.sent-card small { color: var(--sage); font-weight: 600; font-size: 13.5px; }
.sent-check { width: 56px; height: 56px; color: var(--green); }
.sent-check circle { stroke-dasharray: 151; stroke-dashoffset: 151; }
.sent-check path { stroke-dasharray: 36; stroke-dashoffset: 36; }
.sent.show .sent-check circle { animation: draw .55s var(--ease) .1s forwards; }
.sent.show .sent-check path { animation: draw .35s var(--ease) .5s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.item.is-new { animation: pop .45s var(--ease); box-shadow: 0 0 0 2px var(--green), var(--shadow); }

/* ---------- Miniatures sans photo ---------- */
.thumb, .vthumb { display: grid; place-items: center; }
.thumb > img, .vthumb > img { grid-area: 1 / 1; }
.no-photo { color: var(--teal-mid); opacity: .7; }
.vthumb .no-photo { width: 76px; height: 76px; opacity: .28; }

/* Aide › Supprimer (réinitialisation) */
.help-reset { margin: 18px 0 10px; padding-top: 16px; border-top: 1px solid rgba(0,0,0,.08); }
.help-reset .muted { font-size: 13px; margin: 0 0 10px; }
.btn.loading { opacity: .7; pointer-events: none; }
