/* Démo DocPrêt : mise en page */

body { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* Barre supérieure */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: calc(.75rem + env(safe-area-inset-top, 0px)) clamp(1rem, 4vw, 2rem) .75rem;
  background: rgba(238, 241, 245, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; text-decoration: none; }
.brand-mark {
  width: 22px; height: 26px; background: var(--ink); border-radius: 3px;
  clip-path: polygon(0 0, 62% 0, 100% 30%, 100% 100%, 0 100%);
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; right: 0; top: 0; width: 38%; height: 30%; background: var(--you); clip-path: polygon(0 0, 100% 100%, 0 100%); }
.bar-actions { margin-left: auto; display: flex; gap: 1.25rem; }

/* Rail d'étapes */
.rail {
  list-style: none; margin: 0; padding: .9rem clamp(1rem, 4vw, 2rem);
  display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--rule); background: var(--paper);
}
.rail::-webkit-scrollbar { display: none; }
.rail li { flex: none; }
.rail button {
  display: flex; align-items: center; gap: .5rem; min-height: 36px;
  padding: .25rem .75rem .25rem .3rem; border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-3); font-size: var(--t-xs); font-weight: 500; cursor: default;
}
.rail .n { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--rule); font-weight: 600; background: var(--sheet); }
.rail .done button { color: var(--ink-2); cursor: pointer; }
.rail .done button:hover { background: var(--sheet); }
.rail .done .n { background: var(--ready); border-color: var(--ready); color: #fff; }
.rail .current button { color: var(--ink); font-weight: 600; background: var(--sheet); }
.rail .current .n { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Scène */
.stage { max-width: 1180px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 7rem; outline: none; }
.stage-head { max-width: 46rem; margin-bottom: 1.75rem; }
.stage-head h1 { font-size: var(--t-xl); }
.stage-head p { margin-top: .6rem; color: var(--ink-2); font-size: var(--t-m); }
.enter { animation: enter .35s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-l); padding: 1.35rem; }
.panel h2 { font-size: var(--t-m); }
.panel + .panel { margin-top: 1rem; }
.muted { color: var(--ink-2); }
.small { font-size: var(--t-xs); }

/* Email / document */
.mail { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-l); overflow: hidden; }
.mail-head { padding: 1rem 1.35rem; border-bottom: 1px solid var(--rule-2); display: grid; gap: .2rem; font-size: var(--t-xs); color: var(--ink-2); }
.mail-head strong { color: var(--ink); font-size: var(--t-s); font-weight: 600; }
.mail-body { padding: 1.35rem; font-family: var(--doc); font-size: 1.0625rem; line-height: 1.7; max-width: 68ch; }
.mail-body p + p { margin-top: .85rem; }
.mail-body .sig { white-space: pre-line; }

/* Plan (étape 1) */
.plan { list-style: none; margin: 1rem 0 1.5rem; padding: 0; display: grid; gap: .85rem; }
.plan li { display: grid; grid-template-columns: 1.6rem 1fr; gap: .75rem; align-items: start; }
.plan .n { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--paper); font-weight: 600; font-size: var(--t-xs); }
.plan b { display: block; font-weight: 600; }
.plan span { color: var(--ink-2); font-size: var(--t-xs); }
.promise { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--rule-2); font-size: var(--t-xs); color: var(--ink-2); }

/* Extraction (étape 2) */
.extract { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.extract li {
  display: grid; grid-template-columns: auto 1fr; gap: .75rem; align-items: start;
  padding: .7rem .85rem; border-radius: var(--r-m); background: var(--paper);
  opacity: 0; transform: translateX(8px); transition: opacity .3s, transform .3s var(--ease);
}
.extract li.on { opacity: 1; transform: none; }
.extract b { display: block; font-weight: 600; line-height: 1.3; }
.extract small { color: var(--ink-2); }
.extract li.link { background: var(--you-bg); }
mark.hl.link { outline: 2px solid var(--ink); outline-offset: 1px; }
.deadline {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; padding: .8rem 1rem;
  border-radius: var(--r-m); border: 1px solid var(--rule); background: var(--sheet);
  opacity: 0; transition: opacity .3s;
}
.deadline.on { opacity: 1; }
.deadline svg { flex: none; }

/* Recherche (étape 3) */
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.sources li { display: grid; grid-template-columns: 2.25rem 1fr auto; gap: .85rem; align-items: center; padding: .85rem 1rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-m); }
.src-ico { width: 2.25rem; height: 2.25rem; border-radius: var(--r-s); background: var(--paper); display: grid; place-items: center; color: var(--ink-2); }
.sources .count { font-weight: 600; font-variant-numeric: tabular-nums; }
.sources .bar-in { grid-column: 2 / 4; height: 3px; border-radius: 3px; background: var(--rule-2); overflow: hidden; }
.sources .bar-in i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .9s var(--ease); }
.sources li.on .bar-in i { width: 100%; }

.triage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 520px) { .triage { grid-template-columns: 1fr; } }
.triage button {
  text-align: left; padding: 1rem; border-radius: var(--r-m); border: 1px solid var(--rule); background: var(--sheet); cursor: pointer;
  display: grid; gap: .2rem; min-height: 44px; transition: border-color .15s;
}
.triage button:hover { border-color: var(--ink-3); }
.triage .big { font-size: var(--t-xl); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.triage .ok .big { color: var(--ready); }
.triage .warn .big { color: var(--you-ink); }

/* Dossier (étape 4) */
.next {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem;
  padding: 1.25rem 1.35rem; margin-bottom: 1.75rem;
  background: var(--you-bg); border: 1px solid #ecd27a; border-radius: var(--r-l);
}
.next-text { flex: 1 1 18rem; }
.next-text small { display: block; color: var(--you-ink); font-weight: 600; font-size: var(--t-xs); }
.next-text strong { display: block; font-size: var(--t-l); font-weight: 600; letter-spacing: -.01em; margin-top: .15rem; }
.next-text p { color: var(--ink-2); margin-top: .25rem; }
.next.calm { background: var(--sheet); border-color: var(--rule); }
.next.calm small { color: var(--ready); }

.overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.75rem; }
@media (max-width: 720px) { .overview { grid-template-columns: 1fr; } }
.overview div { padding: .9rem 1rem; border-radius: var(--r-m); background: var(--sheet); border: 1px solid var(--rule); display: grid; grid-template-columns: auto 1fr; column-gap: .65rem; align-items: baseline; }
.overview div::before { content: ""; width: .7rem; height: .7rem; border-radius: 50%; grid-row: 1 / 3; align-self: center; }
.overview .o-you::before { background: var(--you); box-shadow: inset 0 0 0 1px var(--you-ink); }
.overview .o-ready::before { background: var(--ready); }
.overview .o-wait::before { background: var(--wait); }
.overview b { font-size: var(--t-l); font-variant-numeric: tabular-nums; }
.overview span { display: block; color: var(--ink-2); font-size: var(--t-xs); }

.group { margin-top: 1.75rem; }
.group-head { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .6rem; }
.group-head h2 { font-size: var(--t-m); }
.group-head p { color: var(--ink-2); font-size: var(--t-xs); }
.rows { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-l); overflow: hidden; }
.rows li + li { border-top: 1px solid var(--rule-2); }
.row {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .35rem 1rem; align-items: center;
  padding: .95rem 1.15rem; border: 0; background: transparent; text-align: left; cursor: pointer;
}
.row:hover { background: #f7f9fb; }
.row .t { font-weight: 600; }
.row .d { grid-column: 2; color: var(--ink-2); font-size: var(--t-xs); }
.row .state { grid-row: 1; grid-column: 3; }
.row .open { grid-column: 3; justify-self: end; font-size: var(--t-xs); color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 560px) {
  .row { grid-template-columns: auto minmax(0, 1fr); }
  .row .state, .row .open { grid-column: 2; grid-row: auto; justify-self: start; }
}
.empty { padding: 1.1rem 1.15rem; color: var(--ink-2); background: var(--sheet); border: 1px dashed var(--rule); border-radius: var(--r-l); }

/* Question (étape 5) */
.q { max-width: 44rem; }
.q h1 { font-size: var(--t-xl); }
.q .why { margin-top: .75rem; color: var(--ink-2); font-size: var(--t-m); }
.choices { display: grid; gap: .6rem; margin: 1.5rem 0; border: 0; padding: 0; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; pointer-events: none; }
.choice label {
  display: grid; grid-template-columns: 1.25rem 1fr; gap: .9rem; align-items: start;
  padding: 1rem 1.15rem; border-radius: var(--r-m); background: var(--sheet); border: 1.5px solid var(--rule); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choice label::before { content: ""; width: 1.25rem; height: 1.25rem; margin-top: .1rem; border-radius: 50%; border: 1.5px solid var(--ink-3); background: var(--sheet); transition: box-shadow .15s, border-color .15s; }
.choice input:checked + label { border-color: var(--ink); background: #fbfcfe; }
.choice input:checked + label::before { border-color: var(--ink); box-shadow: inset 0 0 0 4px var(--sheet), inset 0 0 0 10px var(--ink); }
.choice input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice b { display: block; font-weight: 600; }
.choice span { color: var(--ink-2); font-size: var(--t-xs); }
.split-amounts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: -.5rem 0 1.25rem; padding: 1rem 1.15rem; border-radius: var(--r-m); background: var(--sheet); border: 1px solid var(--rule); }
.split-amounts label { display: grid; gap: .3rem; font-weight: 500; font-size: var(--t-xs); }
.split-amounts input { min-height: 44px; padding: 0 .75rem; border: 1px solid var(--rule); border-radius: var(--r-s); font: inherit; font-size: var(--t-m); font-variant-numeric: tabular-nums; }
.split-amounts .hint { grid-column: 1 / -1; font-size: var(--t-xs); }
.split-amounts .hint.err { color: var(--alert); font-weight: 500; }
.split-amounts .hint.ok { color: var(--ready); font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }

/* Validation (étape 6) */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.25rem; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; min-height: 44px; padding: 0 1rem; border: 0; background: none; cursor: pointer;
  color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.compose { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-l); overflow: hidden; }
.compose + .compose { margin-top: 1rem; }
.compose-head { display: grid; grid-template-columns: 4.5rem 1fr; gap: .35rem .75rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--rule-2); font-size: var(--t-xs); }
.compose-head dt { color: var(--ink-3); }
.compose-head dd { margin: 0; font-weight: 500; }
.compose textarea {
  display: block; width: 100%; min-height: 12rem; padding: 1.2rem; border: 0; resize: none; overflow: hidden;
  font: 400 1rem/1.65 var(--doc); color: var(--ink); background: var(--sheet);
}
.compose textarea:focus { outline: none; background: #fcfdfe; }
.compose textarea.short { min-height: 8rem; }
.compose-foot { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .7rem 1.2rem; border-top: 1px solid var(--rule-2); font-size: var(--t-xs); color: var(--ink-2); }
.compose-foot .edited { color: var(--you-ink); font-weight: 600; }
.attach { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem 1.2rem; border-top: 1px solid var(--rule-2); }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem; border-radius: var(--r-s); background: var(--paper); font-size: var(--t-xs); font-weight: 500; border: 0; cursor: pointer; min-height: 32px; }
.chip:hover { background: var(--rule-2); }

.tree { font-size: var(--t-s); }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 1.25rem; }
.tree > ul { padding: 0; }
.tree li { padding: .3rem 0; }
.tree .folder { font-weight: 600; }
.tree .file { color: var(--ink-2); }
.index { width: 100%; border-collapse: collapse; font-size: var(--t-xs); }
.index th, .index td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.index th { color: var(--ink-3); font-weight: 500; }
.table-wrap { overflow-x: auto; }

.sendbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem;
  padding: .9rem clamp(1rem, 4vw, 2rem) calc(.9rem + env(safe-area-inset-bottom, 0px));
  background: var(--sheet); border-top: 1px solid var(--rule);
}
.sendbar p { flex: 1 1 20rem; font-size: var(--t-xs); color: var(--ink-2); }
.sendbar p b { color: var(--ink); font-size: var(--t-s); display: block; }

.confirm { max-width: 34rem; }
.confirm ul { margin: 1rem 0 1.25rem; padding-left: 1.1rem; display: grid; gap: .4rem; }
.confirm .note { padding: .8rem 1rem; border-radius: var(--r-m); background: var(--paper); font-size: var(--t-xs); color: var(--ink-2); margin-bottom: 1.25rem; }

/* Suivi (étape 7) */
.life { display: flex; gap: 3px; margin-top: .45rem; }
.life i { flex: 1; height: 5px; border-radius: 3px; background: var(--rule-2); }
.life i.f { background: var(--wait); }
.life.complete i.f { background: var(--ready); }
.legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: var(--t-xs); color: var(--ink-2); margin-top: .5rem; }
.legend b { color: var(--ink); font-weight: 600; }
.simbox { margin-top: 1.75rem; padding: 1.15rem 1.25rem; border: 1px dashed var(--ink-3); border-radius: var(--r-l); }
.simbox h2 { font-size: var(--t-s); }
.simbox p { font-size: var(--t-xs); color: var(--ink-2); margin: .25rem 0 .85rem; }
.simbox .actions { gap: .6rem; }
.done-card { margin-top: 1.75rem; padding: 1.5rem; border-radius: var(--r-l); background: var(--ink); color: #fff; }
.done-card h2 { font-size: var(--t-l); }
.done-card p { color: #c9d1e2; margin-top: .5rem; max-width: 52ch; }
.done-card .actions { margin-top: 1.25rem; }
.done-card .btn-primary { background: var(--you); color: var(--ink); }
.done-card .btn-primary:hover { background: #f6d05a; }
.done-card .btn-link { color: #c9d1e2; }
.recap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
@media (max-width: 600px) { .recap { grid-template-columns: 1fr; } }
.recap h3 { font-size: var(--t-xs); color: #9fb0cf; font-weight: 600; }
.recap ul { margin: .4rem 0 0; padding-left: 1.1rem; display: grid; gap: .25rem; }

/* Tiroir d'inspection */
.drawer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(22, 35, 63, .28); opacity: 0; transition: opacity .2s; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(34rem, 100%); z-index: 1;
  background: var(--sheet); overflow-y: auto; padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1.5rem 2rem;
  transform: translateX(100%); transition: transform .25s var(--ease);
  border-left: 1px solid var(--rule);
}
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-scrim { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer-close { position: absolute; top: calc(1.25rem + env(safe-area-inset-top, 0px)); right: 1.5rem; }
.drawer h2 { font-size: var(--t-l); margin: 1.75rem 0 .5rem; padding-right: 3rem; }
.drawer h3 { font-size: var(--t-s); margin: 1.5rem 0 .6rem; }
.quote { margin: .9rem 0; padding: 0; font-family: var(--doc); font-size: var(--t-m); line-height: 1.7; }
.quote mark { background: linear-gradient(transparent 10%, var(--you) 10%, var(--you) 90%, transparent 90%); color: inherit; padding: 0 .1em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.quote small { display: block; font-family: var(--ui); font-size: var(--t-xs); color: var(--you-ink); margin-top: .35rem; }
.file { border: 1px solid var(--rule); border-radius: var(--r-m); padding: .85rem 1rem; display: grid; gap: .45rem; }
.file + .file { margin-top: .6rem; }
.file-top { display: flex; align-items: flex-start; gap: .75rem; }
.file-top .ico { flex: none; width: 2rem; height: 2.4rem; border-radius: 3px; background: var(--paper); display: grid; place-items: center; font-size: .625rem; font-weight: 700; color: var(--ink-2); }
.file-top b { display: block; font-weight: 600; word-break: break-word; }
.file-top span { font-size: var(--t-xs); color: var(--ink-2); }
.prov { display: grid; grid-template-columns: auto 1fr; gap: .15rem .75rem; margin: 0; font-size: var(--t-xs); }
.prov dt { color: var(--ink-3); }
.prov dd { margin: 0; color: var(--ink-2); }
.file.discarded { background: #fafbfc; border-style: dashed; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.checks li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .6rem; font-size: var(--t-s); }
.checks li svg { margin-top: .2rem; }
.checks span { color: var(--ink-2); }

/* Modale de pièce */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; pointer-events: none; opacity: 0; transition: opacity .18s; }
.modal.open { pointer-events: auto; opacity: 1; }
.modal-scrim { position: absolute; inset: 0; background: rgba(22, 35, 63, .45); }
.modal-panel { position: relative; width: min(40rem, 100%); max-height: calc(100vh - 2rem); overflow: auto; background: var(--paper); border-radius: var(--r-l); padding: 1rem; }
.modal-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: .25rem .25rem 1rem; font-size: var(--t-xs); color: var(--ink-2); }
.modal-head b { color: var(--ink); font-size: var(--t-s); display: block; }
.sheet {
  background: var(--sheet); padding: clamp(1.25rem, 5vw, 2.5rem); border-radius: 4px; font-family: var(--doc);
  box-shadow: 0 1px 0 var(--rule), 0 12px 30px -18px rgba(22, 35, 63, .35); position: relative;
}
.sheet h3 { font-family: var(--doc); font-size: 1.35rem; font-weight: 600; }
.sheet .sub { color: var(--ink-2); margin-top: .25rem; }
.sheet .per { margin-top: .9rem; font-size: .95rem; }
.sheet table { width: 100%; border-collapse: collapse; margin-top: 1.25rem; font-size: .95rem; }
.sheet td { padding: .45rem 0; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.sheet td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 1rem; }
.sheet .foot { margin-top: 1rem; font-weight: 600; }
.sheet .stamp { position: absolute; top: 1rem; right: 1rem; font-family: var(--ui); }
.sheet.draft::after { content: "PROJET"; position: absolute; inset: 0; display: grid; place-items: center; font: 700 4rem/1 var(--ui); color: rgba(179, 38, 30, .1); transform: rotate(-18deg); pointer-events: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 1rem; padding: .75rem .9rem .75rem 1.15rem; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 10px 30px -10px rgba(22, 35, 63, .5);
  max-width: calc(100vw - 2rem);
}
.toast button { background: #fff; color: var(--ink); border: 0; border-radius: 999px; min-height: 36px; padding: 0 .9rem; font-weight: 600; cursor: pointer; }
