/* ANVIL-Chrono — feuille de style sobre, neutre, dense.
   Pas de gradient, pas de flou, pas d'animation décorative. */

:root {
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #d6d9dd;
  --border-strong: #b8bdc4;
  --text: #1b1f24;
  --text-muted: #5b6470;
  --text-faint: #868e98;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --done: #1f7a3d;
  --done-bg: #eef6f0;
  --danger: #9a2a2a;
  --warn-bg: #fbf6e9;
  --radius: 4px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --surface: #1f2228;
    --surface-alt: #23272e;
    --border: #353a42;
    --border-strong: #474d57;
    --text: #e6e8eb;
    --text-muted: #a3acb8;
    --text-faint: #7b838e;
    --accent: #4a86c5;
    --accent-text: #ffffff;
    --done: #5bbd7a;
    --done-bg: #1d2a22;
    --danger: #d77;
    --warn-bg: #2a2820;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

a { color: var(--accent); }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); }
.btn:active { background: var(--bg); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-sm { padding: 4px 8px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }

/* --- En-tête --------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 700;
  letter-spacing: .04em;
  font-family: var(--mono);
  white-space: nowrap;
}
.topbar .brand span { color: var(--text-faint); font-weight: 400; }
.topbar .spacer { flex: 1; }
.topbar select {
  max-width: 40vw;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.save-state {
  font-size: 13px;
  color: var(--text-faint);
  min-width: 84px;
  text-align: right;
  white-space: nowrap;
}
.save-state.saving { color: var(--text-muted); }
.save-state.saved { color: var(--done); }
.save-state.error { color: var(--danger); }

/* --- Disposition ----------------------------------------------------------- */

.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

/* --- Progression ----------------------------------------------------------- */

.doc-head { margin-bottom: 16px; }
.doc-title { font-size: 22px; margin: 0 0 4px; }
.doc-meta { color: var(--text-muted); font-size: 13px; font-family: var(--mono); }
.doc-meta span { margin-right: 14px; }

.progress {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress .bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress .bar > i {
  display: block;
  height: 100%;
  background: var(--done);
  width: 0;
}
.progress .pct { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-muted); white-space: nowrap; }

/* --- Sections -------------------------------------------------------------- */

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.section > header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.section.collapsed > header { border-bottom: none; }
.section > header .caret { color: var(--text-faint); width: 12px; }
.section > header h2 { font-size: 15px; margin: 0; flex: 1; }
.section > header .count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-family: var(--mono);
}
.section .section-desc {
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.section.collapsed .steps,
.section.collapsed .section-desc { display: none; }

/* --- Étapes ---------------------------------------------------------------- */

.step {
  border-bottom: 1px solid var(--border);
  padding: 9px 14px 9px 12px;
}
.step:last-child { border-bottom: none; }
.step.done { background: var(--done-bg); }

.step-main { display: flex; align-items: flex-start; gap: 10px; }

/* Case à cocher : grande cible tactile */
.check {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.check:checked { background: var(--done); border-color: var(--done); }
.check:checked::after {
  content: "";
  position: absolute;
  left: 6px; top: 2px;
  width: 6px; height: 11px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.step-body { flex: 1; min-width: 0; }
.step-title { font-weight: 500; }
.step.done .step-title { color: var(--text-muted); text-decoration: line-through; }
.step-desc { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.badges { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
.badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Checklist imbriquée */
.checklist { margin: 8px 0 2px; padding: 0; list-style: none; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
}
.check-sm { width: 18px; height: 18px; }
.check-sm:checked::after { left: 4.5px; top: 1px; width: 5px; height: 9px; }
.checklist .ck-text { font-size: 14px; }
.checklist li.done .ck-text { color: var(--text-muted); text-decoration: line-through; }

/* Zone notes/remarques/améliorations */
.step-extra { margin-top: 6px; }
.extra-toggle {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.extra-toggle:hover { color: var(--accent); }
.extra-toggle .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); display: none;
}
.extra-toggle.has-content .dot { display: inline-block; }

.extra-fields { margin-top: 8px; display: grid; gap: 8px; }
.extra-fields.hidden { display: none; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  margin-bottom: 3px;
}
.field textarea {
  width: 100%;
  min-height: 46px;
  resize: vertical;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
  line-height: 1.4;
}
.field.improvements textarea { background: var(--warn-bg); }
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* --- État vide / import ---------------------------------------------------- */

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}
.empty h2 { color: var(--text); font-weight: 600; }
.dropzone {
  margin: 20px auto 0;
  max-width: 460px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 16px;
  background: var(--surface);
  cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: var(--surface-alt); }
.dropzone p { margin: 6px 0; }
.hint { color: var(--text-faint); font-size: 13px; }

.hidden { display: none !important; }

/* --- Login ----------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.login-card .brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .05em;
  margin: 0 0 2px;
}
.login-card .sub { color: var(--text-faint); font-size: 13px; margin: 0 0 20px; }
.login-card label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--text-muted); }
.login-card input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
  margin-bottom: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-card .btn-primary { width: 100%; justify-content: center; }
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

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

@media (max-width: 640px) {
  body { font-size: 15px; }
  .wrap { padding: 12px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .brand .full { display: none; }
  .topbar select { max-width: 36vw; }
  .toolbar .btn { flex: 1 1 auto; justify-content: center; }
  .badges { display: flex; margin: 4px 0 0; }
  .step-title { display: block; }
}
