/* Ateliers Kafel — charte Setechnology.
   Papier #F2F2ED, encre #1A1815, vermillon #FF4D2E en aplat uniquement (jamais en texte sur papier).
   Angles droits, filets plutôt qu'ombres, hiérarchie par la taille. Archivo (titres), Inter (texte). */

@font-face { font-family: 'Inter'; src: url('/static/fonts/inter-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/static/fonts/inter-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/static/fonts/inter-latin-600-normal.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'Archivo'; src: url('/static/fonts/archivo-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Archivo'; src: url('/static/fonts/archivo-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face {
  font-family: 'Kafel Naskh';
  src: url('/static/fonts/noto-naskh-arabic-arabic-400-normal.woff2') format('woff2');
  font-weight: 400 500; font-display: swap; size-adjust: 112%;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}
@font-face {
  font-family: 'Kafel Naskh';
  src: url('/static/fonts/noto-naskh-arabic-arabic-700-normal.woff2') format('woff2');
  font-weight: 600 800; font-display: swap; size-adjust: 112%;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}

:root {
  --paper: #f2f2ed;
  --surface: #ffffff;
  --surface-2: #f8f8f5;
  --ink: #1a1815;
  --ink-2: #46453f;
  --muted: #61605a;
  --rule: #e0e0da;
  --rule-strong: #c8c8c0;
  --accent: #ff4d2e;          /* aplat */
  --accent-line: #e63a1e;     /* traits, icônes fines, anneau de focus */
  --accent-wash: #fff1ed;
  --green: #1f7a4d;
  --green-wash: #e8f3ed;
  --blue: #2b59c3;
  --blue-wash: #edf2fc;
  --sans: 'Kafel Naskh', 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --display: 'Kafel Naskh', 'Archivo', 'Inter', 'Segoe UI', system-ui, Arial, sans-serif;
  --topbar-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--ink);
  background: var(--paper); font-feature-settings: 'tnum' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #ffd2c8; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
a { color: var(--ink); text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sprite { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: 0;
  background: none; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: #000; }
.btn-accent { background: var(--accent); color: var(--ink); }
.btn-accent:hover { background: #ff6a50; }
.btn-line { border-color: var(--rule-strong); background: var(--surface); color: var(--ink); }
.btn-line:hover { border-color: var(--ink); }
.btn-quiet { color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled { color: #a3a29b; border-color: var(--rule); background: transparent; cursor: not-allowed; }
.btn[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 1px solid transparent; border-radius: 0; background: none; color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { border-color: var(--rule-strong); color: var(--ink); background: var(--surface); }

/* ---------- Barre du haut ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  min-height: var(--topbar-h); padding: 10px 24px;
  background: var(--surface); border-top: 3px solid var(--accent); border-bottom: 1px solid var(--rule);
}
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar h1 { font-size: 17px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; }
.topbar h1 .ar, .topbar h1 .sub { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 14px; letter-spacing: 0; }
.topbar-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qui { color: var(--muted); font-size: 15px; }
.date-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 500; }
input[type='date'] {
  min-height: 44px; padding: 0 10px; border: 1px solid var(--rule-strong); border-radius: 0;
  background: var(--surface); color: var(--ink); font-weight: 500;
}
input[type='date']:focus { outline: 2px solid var(--accent-line); outline-offset: -1px; }

.save { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; font-size: 14px; color: var(--muted); }
.save .ico { width: 16px; height: 16px; }
.save[data-state='saving'] { color: var(--ink-2); }
.save[data-state='saving'] .ico { opacity: 0.3; }
.save[data-state='saved'] { color: var(--green); }
.save[data-state='error'] { color: var(--ink); background: var(--accent-wash); border: 1px solid var(--accent-line); font-weight: 600; }

/* ---------- Mise en page atelier ---------- */

.atelier { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 32px; max-width: 1640px; margin: 0 auto; padding: 32px 24px 120px; }
.grilles { container-type: inline-size; min-width: 0; display: grid; gap: 48px; }

/* Rail des sections : liste compacte, barre de progression segmentée par ligne */
.rail { position: sticky; top: calc(var(--topbar-h) + 24px); align-self: start; }
.anim-on .rail { top: calc(var(--topbar-h) + var(--anim-h, 0px) + 24px); }
.rail-list { list-style: none; margin: 0; padding: 0; display: grid; border: 1px solid var(--rule); background: var(--surface); }
.rail-seg + .rail-seg { border-top: 1px solid var(--rule); }
.rail-seg a { display: grid; gap: 8px; padding: 14px 16px; text-decoration: none; color: var(--ink); position: relative; transition: background-color 150ms ease-out; }
.rail-seg a:hover { background: var(--surface-2); }
.rail-seg a[aria-current='true'] { background: var(--ink); color: #fff; }
.rail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rail-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.rail-count { font-size: 12px; color: var(--muted); font-weight: 500; }
.rail-seg a[aria-current='true'] .rail-count { color: #c9c8c1; }

/* Barre segmentée : un segment par ligne, coloré par statut */
.marks { display: flex; gap: 2px; height: 6px; }
.m { display: block; flex: 1 1 0; min-width: 3px; background: var(--rule); }
.m.st-confirme { background: var(--green); }
.m.st-corrige { background: var(--accent); }
.m.st-ouvert { background: var(--blue); }
.rail-seg a[aria-current='true'] .m.st-propose { background: #4a4842; }

/* ---------- Sections et grilles ---------- */

.section { scroll-margin-top: calc(var(--topbar-h) + var(--anim-h, 0px) + 24px); }
.section-head { display: grid; gap: 6px; margin-bottom: 16px; }
.section-head h2 { font-size: 21px; }
.section-note { color: var(--muted); font-size: 14px; max-width: 75ch; }

.paper { background: var(--surface); border: 1px solid var(--rule); overflow: clip; }

.row {
  display: grid; grid-template-columns: 128px minmax(0, 1fr) 48px; align-items: stretch;
  border-bottom: 1px solid var(--rule); transition: background-color 150ms ease-out;
}
.rows .row:last-child { border-bottom: 0; }
.row > .margin { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 0 12px 16px; }
.row > .cells { display: grid; grid-template-columns: var(--cols); gap: 0 20px; padding: 0 0 0 16px; align-items: start; }
.row > .row-tools { display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; }
.row:hover:not(.head) { background: #fcfcfa; }
.row.head {
  background: var(--surface-2); border-bottom: 1px solid var(--rule-strong); font-size: 12px; font-weight: 600; color: var(--muted);
  position: sticky; top: calc(var(--topbar-h) + var(--anim-h, 0px)); z-index: 6; /* en-têtes visibles pendant le défilement */
}
.row.head > .margin, .row.head .cell { padding-top: 12px; padding-bottom: 12px; }
/* Ligne en cours de saisie : fond chaud et libellé renforcé */
.row:focus-within:not(.head) { background: #fffaf7; box-shadow: inset 0 0 0 1px var(--rule-strong); }
.row.st-ouvert { background: var(--blue-wash); }
.row.st-ouvert:hover { background: #e6edfb; }
.row.is-archived, .row.is-filtered { display: none; }
.section.is-filtered-out { display: none; }
.show-archived .row.is-archived { display: grid; opacity: 0.55; }
.show-archived .row.is-archived .cell-input, .show-archived .row.is-archived .cell-text { text-decoration: line-through; }
.row.is-new { animation: arrive 500ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes arrive { from { background-color: var(--accent-wash); } }

/* Statut : pastille carrée */
.mark {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px 0 8px;
  border: 1px solid var(--rule-strong); border-radius: 0; background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; position: relative;
}
.mark::after { content: ''; position: absolute; inset: -4px; } /* cible tactile ≥ 44 px */
.mark-ico { width: 16px; height: 16px; stroke-width: 2.2; }
.mark:hover { border-color: var(--ink); }
.st-confirme .mark { background: var(--green); border-color: var(--green); color: #fff; }
.st-corrige .mark { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.st-ouvert .mark { background: var(--blue); border-color: var(--blue); color: #fff; }
.st-confirme .mark:hover, .st-corrige .mark:hover, .st-ouvert .mark:hover { border-color: var(--ink); }
.mark.is-stamped { animation: pop 240ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes pop { from { transform: scale(0.92); } }

/* Confirmer en un toucher : seulement sur les lignes encore proposées */
.quick-confirm {
  display: none; align-items: center; gap: 4px; min-height: 32px; padding: 0 8px 0 6px; position: relative;
  border: 0; background: none; color: var(--green); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.quick-confirm::after { content: ''; position: absolute; inset: -6px -4px; }
.quick-confirm .ico { width: 16px; height: 16px; stroke-width: 2.4; }
.quick-confirm:hover { background: var(--green-wash); }
.st-propose .quick-confirm { display: inline-flex; }

/* Cellules */
.cell { min-width: 0; padding: 6px 0; display: flex; flex-direction: column; }
.cell-lab { display: none; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.cell-text { padding: 8px 0; font-weight: 600; white-space: pre-wrap; overflow-wrap: break-word; hyphens: auto; }
.cell-input {
  display: block; width: 100%; min-height: 38px; margin: 0; padding: 8px 8px;
  border: 0; border-radius: 0; background: transparent; resize: none; overflow: hidden;
  color: var(--ink); line-height: 22px; overflow-wrap: break-word; hyphens: auto;
  box-shadow: inset 0 -1px 0 var(--rule);
  transition: background-color 150ms ease-out, box-shadow 150ms ease-out;
}
.cell-input::placeholder { color: #8d8c85; }
.cell-input.is-seed { color: var(--ink-2); }
.cell-input.a-confirmer { background: var(--accent-wash); text-decoration: underline dashed var(--accent-line) 1px; text-underline-offset: 5px; }
.cell-input:hover { box-shadow: inset 0 -1px 0 var(--rule-strong); }
.cell-input:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); }
.cell-titre .cell-input { font-weight: 600; }
.cell-orig { display: block; padding: 3px 8px 0; font-size: 12.5px; line-height: 1.35; color: var(--muted); text-decoration: line-through; text-decoration-color: var(--accent-line); overflow-wrap: break-word; }
.cell-orig::before { content: 'Proposé : '; text-decoration: none; display: inline-block; margin-inline-end: 4px; }
.cell-orig[hidden] { display: none; }
.cell-titre .cell-input:placeholder-shown { box-shadow: inset 0 -2px 0 var(--ink); }
.cell-input.is-fresh { box-shadow: inset 0 -2px 0 var(--accent); }
.cell-input.is-fresh:focus { box-shadow: inset 0 0 0 2px var(--ink); }

.check {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px 0 10px;
  border: 1px solid var(--rule-strong); border-radius: 0; background: var(--surface); cursor: pointer;
  color: var(--ink-2); font-weight: 600; font-size: 14px; align-self: flex-start;
}
.check .ico { width: 22px; height: 22px; padding: 2px; border: 1.5px solid var(--rule-strong); stroke: transparent; stroke-width: 3; }
.check:hover { border-color: var(--ink); }
.check[aria-checked='true'] { color: var(--ink); border-color: var(--ink); }
.check[aria-checked='true'] .ico { stroke: #fff; background: var(--ink); border-color: var(--ink); }
.seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--rule-strong); background: var(--surface); }
.seg button {
  min-height: 42px; padding: 0 14px; border: 0; border-radius: 0; background: none;
  color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button[aria-checked='true'] { background: var(--ink); color: #fff; }

/* Filtres de lecture */
.filtres { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: -24px; }
.filtres-lab { font-size: 13px; font-weight: 600; color: var(--muted); }
.seg-filtres button { display: inline-flex; align-items: center; gap: 6px; }
.seg-filtres button[aria-pressed='true'] { background: var(--ink); color: #fff; }
.seg-filtres .nb { font-size: 12px; font-weight: 500; color: var(--muted); }
.seg-filtres button[aria-pressed='true'] .nb { color: #c9c8c1; }

.paper-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--rule); background: var(--surface-2); flex-wrap: wrap; }
.add-row {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 12px;
  border: 1px solid var(--rule-strong); border-radius: 0; background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer;
}
.add-row .ar { font-weight: 400; color: var(--muted); }
.add-row:hover { border-color: var(--ink); }
.vide { padding: 20px 16px; color: var(--muted); }

/* Menu contextuel */
.menu {
  position: fixed; z-index: 50; min-width: 240px; padding: 4px;
  background: var(--surface); border: 1px solid var(--ink); border-radius: 0;
  box-shadow: 0 8px 24px rgb(26 24 21 / 0.16);
}
.menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 12px;
  border: 0; border-radius: 0; background: none; text-align: start; cursor: pointer; font-weight: 600;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button[aria-checked='true'] { background: var(--paper); }
.menu .ico { width: 22px; height: 22px; padding: 3px; }
.menu small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.menu .st-confirme .ico { background: var(--green); color: #fff; }
.menu .st-corrige .ico { background: var(--accent); color: var(--ink); }
.menu .st-ouvert .ico { background: var(--blue); color: #fff; }
.menu .st-propose .ico { border: 1px solid var(--rule-strong); color: var(--ink-2); }

/* ---------- Mode animateur ---------- */

.anim { position: sticky; top: var(--topbar-h); z-index: 25; background: var(--ink); color: #f2f2ed; padding: 12px 24px 16px; }
.anim-steps { list-style: none; margin: 0 auto 12px; padding: 0; display: flex; gap: 2px; max-width: 1640px; }
.anim-steps li {
  flex: var(--d) 1 0; min-width: 0; padding: 5px 8px 6px; background: #2e2c28; color: #c9c8c1;
  font-size: 12.5px; line-height: 1.25; cursor: pointer; display: flex; flex-direction: column; overflow: hidden;
}
.anim-steps li:hover { background: #3a3833; }
.anim-steps li.is-done { background: #46453f; color: #e0e0da; }
.anim-steps li.is-now { background: var(--accent); color: var(--ink); }
.anim-step-t { opacity: 0.8; font-size: 11.5px; }
.anim-step-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.anim-now { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 32px; align-items: center; max-width: 1640px; margin: 0 auto; }
.anim-etape { font-family: var(--display); font-size: 19px; font-weight: 700; }
.anim-consigne { color: #c9c8c1; font-size: 14.5px; max-width: 75ch; }
.anim-chrono { display: grid; justify-items: end; }
.anim-time { font-family: 'Inter', sans-serif; font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.anim-time.is-late { color: #ff8a73; }
.anim-plan { font-size: 13px; color: #a3a29b; }
.anim-ctrl { display: flex; gap: 8px; }
.anim .btn-line { background: transparent; color: #fff; border-color: #61605a; }
.anim .btn-line:hover { border-color: #fff; }
.anim .btn-line:disabled { color: #61605a; border-color: #3a3833; }
.anim .btn-ink { background: var(--accent); color: var(--ink); }
.anim .btn-ink:hover { background: #ff6a50; }
.anim .btn-ink:disabled { background: #3a3833; color: #8d8c85; }

/* ---------- Compte rendu ---------- */

.cr-paper { padding: 28px 32px; display: grid; gap: 20px; }
.cr-body { display: grid; gap: 16px; }
.cr-body h3 { font-size: 18px; margin-top: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.cr-body h4 { font-family: var(--sans); font-size: 12.5px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.cr-entete { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 16px 24px; align-items: end; }
.cr-field { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.cr-wide { grid-column: 1 / -1; }
.cr-input {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--rule-strong); border-radius: 0;
  background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 400; line-height: 22px; resize: vertical;
}
textarea.cr-input { min-height: 80px; }
.cr-input:hover { border-color: #a3a29b; }
.cr-input:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.cr-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cr-table th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--rule-strong); }
.cr-table td { padding: 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.cr-table td:first-child { width: 50%; padding-top: 14px; }
.cr-table .cr-input { min-height: 40px; padding: 7px 10px; font-size: 14px; }
.tag { display: inline-block; padding: 3px 8px; font-size: 12.5px; font-weight: 600; background: var(--paper); color: var(--ink-2); white-space: nowrap; }
.tag.st-confirme { background: var(--green); color: #fff; }
.tag.st-corrige { background: var(--accent); color: var(--ink); }
.tag.st-ouvert { background: var(--blue); color: #fff; }
.cr-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--rule); }
.cr-body.is-stale { opacity: 0.55; transition: opacity 200ms ease-out; }

/* ---------- Accueil ---------- */

.accueil { max-width: 1120px; margin: 0 auto; padding: 48px 24px 72px; display: grid; gap: 40px; }
.accueil > h1 { font-size: 28px; }
.cahiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 24px; }
.cahier { display: grid; gap: 20px; align-content: start; padding: 28px; background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--ink); }
.cahier-lien { text-decoration: none; color: var(--ink); display: grid; gap: 6px; }
.cahier-lien:hover h2 { text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 4px; }
.cahier h2 { font-size: 20px; }
.cahier .ar { font-size: 16px; color: var(--muted); }
.cahier-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; color: var(--muted); font-size: 14px; }
.duree { display: inline-flex; align-items: center; gap: 6px; }
.cahier-marks { display: grid; gap: 10px; padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.cahier-marks .marks { height: 10px; }
.marks-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg[class*='st-']::before { content: ''; width: 10px; height: 10px; background: var(--rule); }
.lg.st-confirme::before { background: var(--green); }
.lg.st-corrige::before { background: var(--accent); }
.lg.st-ouvert::before { background: var(--blue); }
.lg.st-propose::before { background: var(--rule-strong); }
.cahier > .btn { justify-self: start; }
.sauvegarde { display: grid; gap: 12px; padding: 28px; background: var(--surface); border: 1px solid var(--rule); }
.sauvegarde h2 { font-size: 18px; }
.sauvegarde p { color: var(--muted); max-width: 72ch; font-size: 14px; }
.sauvegarde-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.save-global:empty { display: none; }
.save-global { font-weight: 600; color: var(--green); }
.save-global.is-error { color: var(--ink); background: var(--accent-wash); padding: 8px 12px; }

/* ---------- Connexion / erreur ---------- */

.login {
  max-width: 440px; margin: 12vh auto 0; padding: 36px; display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--accent);
}
.login h1 { font-size: 24px; }
.login-sub { color: var(--muted); }
.login-form { display: grid; gap: 6px; margin-top: 12px; }
.login-form label { font-weight: 600; font-size: 14px; margin-top: 10px; }
.login-form .aide { font-weight: 400; color: var(--muted); }
.login-form input { min-height: 48px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 0; background: var(--surface); color: var(--ink); }
.login-form input:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.login-form .btn { margin-top: 18px; min-height: 48px; }
.erreur { color: var(--ink); font-weight: 600; background: var(--accent-wash); border: 1px solid var(--accent-line); padding: 10px 14px; }

/* ---------- Historique ---------- */

.historique { max-width: 1440px; margin: 0 auto; padding: 32px 24px 72px; overflow-x: auto; }
.journal { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; border: 1px solid var(--rule); }
.journal th { text-align: start; padding: 12px; background: var(--surface-2); color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--rule-strong); }
.journal td { padding: 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.journal .t { white-space: nowrap; color: var(--muted); }
.journal .j-sec { display: block; font-size: 12.5px; color: var(--muted); }
.journal .j-old { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.journal .j-new { color: var(--ink); font-weight: 500; }
.journal .is-undone td { opacity: 0.5; }
.journal .is-undo td { background: var(--surface-2); }

/* ---------- Responsive ---------- */

@media (max-width: 1099px) {
  .atelier { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 16px 16px 96px; }
  .topbar { padding: 8px 16px; }
  .rail { position: sticky; top: var(--topbar-h); z-index: 20; margin: -16px -16px 0; padding: 0; background: var(--surface); border-bottom: 1px solid var(--rule); }
  .anim-on .rail { position: static; }
  .rail-list { display: flex; overflow-x: auto; scrollbar-width: none; border: 0; }
  .rail-seg { flex: 1 0 140px; }
  .rail-seg + .rail-seg { border-top: 0; border-left: 1px solid var(--rule); }
  .rail-seg a { padding: 10px 12px; gap: 6px; height: 100%; }
  .rail-seg a[aria-current='true'] { background: var(--surface); color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); }
  .rail-seg a[aria-current='true'] .rail-count { color: var(--muted); }
  .rail-seg a[aria-current='true'] .m.st-propose { background: var(--rule); }
  .rail-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .marks { height: 4px; }
  .section { scroll-margin-top: calc(var(--topbar-h) + 84px); }
  .anim-on .section { scroll-margin-top: calc(var(--topbar-h) + var(--anim-h, 0px) + 12px); }
  .anim { padding: 8px 16px 12px; }
  .anim-steps { margin-bottom: 8px; }
  .anim-now { grid-template-columns: minmax(0, 1fr) auto; }
  .anim-ctrl { grid-column: 1 / -1; }
  .anim-ctrl .btn-ink { flex: 1; }
  .topbar h1 { font-size: 16px; }
  .topbar-tools { gap: 4px; }
  .topbar-tools .btn-undo span { display: none; }
  .topbar-tools .btn-undo { padding: 0 12px; }
  .date-field .date-txt { display: none; }
}

/* Grille étroite : chaque ligne devient une fiche, libellés visibles */
@container (max-width: 899px) {
  .row.head { display: none; }
  .row { grid-template-columns: 124px minmax(0, 1fr) 44px; }
  .row > .margin { padding: 12px 0 12px 12px; }
  .row > .cells { grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr)); gap: 0 16px; padding: 4px 0 12px 8px; }
  .cell.cell-titre { grid-column: 1 / -1; }
  .cell.cell-choice { grid-column: span 2; }
  .cell-lab { display: block; }
  .cell-titre .cell-lab { display: none; }
  .cell-titre .cell-text, .cell-titre .cell-input { font-size: 16px; }
  .cr-paper { padding: 20px 16px; }
  .cr-entete { grid-template-columns: minmax(0, 1fr); }
  .cr-table, .cr-table tbody, .cr-table tr, .cr-table td { display: block; width: 100%; }
  .cr-table thead { display: none; }
  .cr-table tr { padding: 10px 0; border-bottom: 1px solid var(--rule); }
  .cr-table td { border: 0; padding: 4px 0; }
  .cr-table td:first-child { width: 100%; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  .topbar h1 .ar { display: none; }
  .topbar-tools .btn span { display: none; }
  .anim-time { font-size: 32px; }
  .accueil { padding-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Vue imprimable (A4) ---------- */

.page-print { background: var(--paper); }
.print-bar { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; background: var(--surface); border-top: 3px solid var(--accent); border-bottom: 1px solid var(--rule); z-index: 5; }
.print { max-width: 210mm; margin: 24px auto 48px; padding: 14mm; background: #fff; border: 1px solid var(--rule); font-size: 10.5pt; line-height: 1.35; color: var(--ink); }
.p-head { display: grid; gap: 2mm; padding-bottom: 4mm; border-bottom: 0.6mm solid var(--ink); margin-bottom: 6mm; position: relative; }
.p-head::before { content: ''; display: block; width: 14mm; height: 1.4mm; background: var(--accent); margin-bottom: 3mm; }
.p-head h1 { font-size: 18pt; }
.p-head .ar { font-size: 13pt; }
.p-meta { color: var(--ink-2); }
.p-section { margin-bottom: 7mm; }
.p-section h2 { font-size: 13pt; margin-bottom: 2mm; break-after: avoid; }
.p-section h3 { font-size: 11.5pt; margin: 4mm 0 1.5mm; break-after: avoid; }
.p-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.p-table th, .p-table td { border: 0.25mm solid var(--rule-strong); padding: 1.5mm 2mm; text-align: start; vertical-align: top; }
.p-table th { background: var(--paper); font-weight: 600; }
.p-table tr { break-inside: avoid; }
.p-table .t { white-space: nowrap; width: 1%; }
.p-table td.st-confirme, .p-table td.st-corrige, .p-table td.st-ouvert { font-weight: 700; }
.vide-print { height: 9mm; }
.p-libre { white-space: pre-wrap; min-height: 6mm; padding: 1mm 0; }
p.vide-print { border-bottom: 0.25mm dotted var(--rule-strong); height: 12mm; }
.p-sign { margin-top: 8mm; text-align: end; font-weight: 600; }

@media print {
  @page { size: A4; margin: 12mm; }
  body, .page-print { background: #fff; }
  .no-print, .sprite { display: none !important; }
  .print { margin: 0; padding: 0; max-width: none; border: 0; }
  .page-atelier .topbar, .page-atelier .rail, .page-atelier .anim, .paper-foot, .row-tools, .cr-actions { display: none !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
