/* ============ Base ============ */
:root {
  --accent: #2f6f62;
  --ink: #1d2422;
  --ink-2: #4a5552;
  --muted: #6c7774;
  --line: #dfe4e1;
  --bg: #f5f6f3;
  --card: #ffffff;
  --ok: #2c7a4b;
  --danger: #b3261e;
  --info-bg: #eef4fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --accent-ink: color-mix(in srgb, var(--accent) 80%, black);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem); letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
a { color: var(--accent-ink); }
img, video, iframe { max-width: 100%; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, white); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; }
code { background: #eef0ed; padding: .15em .4em; border-radius: 6px; word-break: break-all; }

/* ============ Layout ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem clamp(1rem, 3vw, 2rem); background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; text-decoration: none; color: var(--ink); }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--accent);
  box-shadow: inset -6px -6px 0 color-mix(in srgb, var(--accent) 60%, white); }
.topbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--ink-2); }
.topbar nav a:hover { color: var(--ink); }
.container { max-width: 1180px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.crumbs { margin: 0 0 .2rem; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.cols { display: flex; gap: 1rem; flex-wrap: wrap; }
.cols > * { flex: 1 1 140px; }
.cols > .grow, .row > .grow { flex: 3 1 260px; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.inline { display: inline; margin: 0; }
.center { text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 2.5vw, 1.5rem); box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.narrow { max-width: 460px; margin: 2rem auto; }
.card.empty { text-align: center; color: var(--ink-2); }
.big-num { font-size: 3rem; font-weight: 800; color: var(--accent); margin: 0; }

/* ============ Formulaires ============ */
label, .field { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .95rem; }
label.row, label.check { flex-direction: row; align-items: center; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
input[type=date], input[type=time], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-weight: 400; color: var(--ink);
  padding: .6rem .75rem; border: 1px solid #cdd4d0; border-radius: 8px; background: #fff;
}
textarea { resize: vertical; }
input[type=color] { width: 3rem; height: 2.2rem; padding: 0; border: 1px solid #cdd4d0; border-radius: 8px; background: #fff; }
input[type=file] { font: inherit; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.radio-row { flex-direction: row; gap: 1.25rem; }
.radio-row label { flex-direction: row; align-items: center; font-weight: 500; }
.prefix-input { display: flex; align-items: stretch; }
.prefix-input span { display: flex; align-items: center; padding: 0 .6rem; background: #eef0ed; border: 1px solid #cdd4d0; border-right: 0; border-radius: 8px 0 0 8px; color: var(--muted); font-weight: 400; }
.prefix-input input { border-radius: 0 8px 8px 0; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { flex: 1; min-width: 0; font-size: .9rem; background: #f8f9f7; }
.form-actions { margin-top: .5rem; }

/* ============ Boutons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer;
  padding: .6rem 1rem; border-radius: 8px; border: 1px solid #cdd4d0; background: #fff; color: var(--ink);
  min-height: 44px; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { width: 100%; margin-bottom: .5rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); cursor: pointer; text-align: left; }
.linklike:hover { color: var(--ink); text-decoration: underline; }
.linklike.danger { color: var(--danger); }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1rem; padding: .35rem .5rem; border-radius: 6px; }
.icon-btn:hover { background: #fbeceb; color: var(--danger); }

/* ============ Messages ============ */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: #edf7f0; border-color: #b9dcc5; color: #1e5a35; }
.flash-erreur { background: #fcefee; border-color: #f0c4c0; color: #8a1f18; }
.flash-info { background: var(--info-bg); border-color: #c8d9ee; color: #23466e; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; }
.badge-ok { background: #e3f3e8; color: var(--ok); }
.badge-draft { background: #eef0ed; color: var(--muted); }

/* ============ Cartes de parcours ============ */
.grid-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 1.1rem 1rem; overflow: hidden; display: flex; flex-direction: column; gap: .4rem; }
.pcard-link { text-decoration: none; color: inherit; display: block; }
.pcard-band { display: block; height: 6px; background: var(--accent); margin: 0 -1.1rem 1rem; }
.pcard h2 { margin: .5rem 0 .3rem; }
.pcard p { margin: .2rem 0; }

.bar { height: 8px; background: #e7ebe8; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.bar-lg { height: 12px; }

/* ============ Éditeur ============ */
.editor { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.editor-side .card h2 { font-size: 1rem; }
.chapitres { display: flex; flex-direction: column; gap: 1rem; }
.chapitre { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .75rem; border-top: 4px solid var(--accent); }
.chapitre-head { display: flex; align-items: center; gap: .4rem; }
.chap-title-form { flex: 1; margin: 0; }
.chap-title { font-weight: 700 !important; font-size: 1.05rem !important; border-color: transparent !important; background: transparent !important; }
.chap-title:hover, .chap-title:focus { border-color: #cdd4d0 !important; background: #fff !important; }
.handle { cursor: grab; color: #a2aba7; user-select: none; padding: .2rem .35rem; font-size: 1.1rem; touch-action: none; }
.etapes { list-style: none; margin: .5rem 0; padding: 0; min-height: 2.5rem; border-radius: 8px; }
.etapes:empty { border: 2px dashed var(--line); }
.etapes:empty::before { content: "Déposez une étape ici"; display: block; padding: .6rem; color: var(--muted); font-size: .9rem; text-align: center; }
.etape-row { display: flex; align-items: center; gap: .5rem; padding: .5rem; border-radius: 8px; background: #fafbf9; border: 1px solid var(--line); margin-bottom: .4rem; }
.etape-row form { margin: 0; }
.etape-icone { font-size: 1.15rem; }
.etape-titre { flex: 1; display: flex; flex-direction: column; text-decoration: none; color: var(--ink); font-weight: 600; min-width: 0; }
.etape-titre:hover { color: var(--accent-ink); }
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.add-etape summary, .danger-zone summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; padding: .35rem .25rem; }
.type-picker { list-style: none; padding: 0; margin: .4rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .4rem; }
.type-picker a { display: block; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); background: #fff; }
.type-picker a:hover { border-color: var(--accent); background: var(--accent-soft); }
.add-chapitre { margin-top: 1rem; }
.add-chapitre input { flex: 1 1 220px; width: auto; }
.save-status { min-height: 1.4em; font-size: .875rem; color: var(--muted); }
.danger-zone { margin-top: 1rem; }
.danger-zone summary { color: var(--danger); }

/* Éditeur de texte enrichi */
.rte { border: 1px solid #cdd4d0; border-radius: 8px; background: #fff; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: .25rem; padding: .35rem; border-bottom: 1px solid var(--line); background: #f8f9f7; border-radius: 8px 8px 0 0; }
.rte-toolbar button { font: inherit; font-size: .85rem; border: 1px solid transparent; background: none; padding: .3rem .55rem; border-radius: 6px; cursor: pointer; }
.rte-toolbar button:hover { background: #fff; border-color: var(--line); }
.rte-area { min-height: 220px; padding: .75rem 1rem; font-weight: 400; }
.rte-area:focus { outline: none; }

/* ============ Tableau de suivi ============ */
.table-wrap { overflow-x: auto; padding: 0; }
.suivi { border-collapse: collapse; width: 100%; font-size: .9rem; }
.suivi th, .suivi td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.suivi thead th { background: #f8f9f7; font-size: .8rem; color: var(--ink-2); white-space: nowrap; }
.suivi tbody th { font-weight: 600; min-width: 180px; }
.suivi .col-etape { text-align: center; padding: .5rem .3rem; }
.suivi .col-etape small { display: block; color: var(--muted); }
.tick { color: var(--ok); font-weight: 800; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: .2rem .6rem; border-radius: 6px; font-weight: 700; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: .6rem .8rem; display: flex; flex-direction: column; gap: .5rem; white-space: nowrap; }
.menu-pop form { margin: 0; }
.legend { columns: 2 260px; margin-top: .5rem; }

/* ============ Page apprenant ============ */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem;
  background: linear-gradient(135deg, var(--accent-soft), #fff 70%);
  border: 1px solid var(--line); border-radius: 18px; padding: clamp(1.25rem, 4vw, 2.25rem); margin-bottom: 2rem;
  border-left: 6px solid var(--accent);
}
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }
.hero-desc { color: var(--ink-2); max-width: 65ch; }
.meta { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; gap: .5rem; flex-wrap: wrap; }
.meta li { background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: .2rem .75rem; font-size: .875rem; color: var(--ink-2); }
.hero-side { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; align-self: start; }
.progress-box p { margin: .2rem 0; }
#pct { font-size: 1.6rem; color: var(--accent-ink); }
.share { margin-top: .75rem; }
.share summary { cursor: pointer; font-size: .9rem; color: var(--ink-2); }
.share .copy-row { margin-top: .6rem; }
.qrcode { margin-top: .75rem; display: flex; justify-content: center; }
.qrcode svg, .qrcode img { width: 180px; height: 180px; }

.chap { margin-bottom: 2rem; }
.chap-title { display: flex; align-items: center; gap: .65rem; font-size: 1.3rem; margin-bottom: 1rem; }
.chap-num { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--accent); color: #fff; font-size: 1rem; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: .75rem; }
.step-rail { position: relative; display: flex; justify-content: center; }
.step-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line); }
.step:first-child .step-rail::before { top: 1.25rem; }
.step:last-child .step-rail::before { bottom: calc(100% - 1.25rem); }
.step-num { position: relative; z-index: 1; margin-top: .65rem; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: .9rem; color: var(--ink-2); }
.step.is-done .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.is-done .step-num { font-size: 0; }
.step.is-done .step-num::after { content: "✓"; font-size: .95rem; }
.step-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: .75rem; overflow: hidden; }
.step-head { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; cursor: pointer; list-style: none; }
.step-head::-webkit-details-marker { display: none; }
.step-head.locked { cursor: default; opacity: .8; }
details[open] > .step-head { border-bottom: 1px solid var(--line); }
.step-icone { font-size: 1.35rem; width: 2rem; text-align: center; }
.step-titles { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.step-title { font-weight: 650; }
.step-meta { font-size: .85rem; color: var(--muted); }
.done-badge { font-size: .75rem; font-weight: 700; color: var(--ok); background: #e3f3e8; border-radius: 99px; padding: .15rem .6rem; }
.step-body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .85rem; }
.step-body > * { margin: 0; }
.consigne { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: .65rem .85rem; border-radius: 0 8px 8px 0; }
.toggle-done { align-self: flex-start; }
.toggle-done.is-done { color: var(--ok); border-color: #b9dcc5; background: #edf7f0; }

.prose { max-width: 70ch; }
.prose > :first-child { margin-top: 0; }
.prose blockquote { margin: .8rem 0; padding: .6rem 1rem; border-left: 3px solid var(--accent); background: #f8f9f7; border-radius: 0 8px 8px 0; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-native { width: 100%; border-radius: 10px; background: #000; }
.pdf-frame { height: min(75vh, 720px); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pdf-frame iframe { width: 100%; height: 100%; border: 0; }
@media (max-width: 600px) { .pdf-frame { display: none; } }
.doc-img { border-radius: 10px; border: 1px solid var(--line); }
.session { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.session dt { color: var(--muted); font-size: .9rem; }
.session dd { margin: 0; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .topbar, .share, .toggle-done, .hero-side form { display: none; } details > .step-body { display: block; } }
