/* CCTP et notice descriptive — démo Forge Labs. S'appuie sur ../_shared/demo.css et archi.css. */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "P052", "URW Palladio L", Georgia, "Noto Serif", serif;
}

[hidden] { display: none !important; }

/* ---------- Mise en page ---------- */
.cc { max-width: 1440px; margin: 0 auto; padding: 28px var(--gutter) 48px; display: grid; gap: 28px; }
.cc > * { min-width: 0; }
.cc h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); max-width: 22em; margin: 10px 0 10px; }
.cc .lead { font-size: clamp(1rem, 1.3vw, 1.12rem); max-width: 52rem; margin-bottom: 16px; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .9rem; font-weight: 600; color: var(--slate-800); }
.steps li { display: inline-flex; align-items: center; gap: 8px; }
.steps span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--slate-800); color: #fff; font-size: .78rem; }

.stage { display: grid; gap: 22px; align-items: start; grid-template-columns: minmax(290px, 340px) minmax(0, 1fr) minmax(260px, 300px); grid-template-areas: "params doc reg"; }
.params { grid-area: params; }
.doc-col { grid-area: doc; min-width: 0; }
.reg { grid-area: reg; }
@media (min-width: 1281px) { .reg { position: sticky; top: 76px; } }
@media (max-width: 1280px) {
  .stage { grid-template-columns: minmax(290px, 360px) minmax(0, 1fr); grid-template-areas: "params doc" "reg doc"; }
}
@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "params" "doc" "reg"; }
}

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; min-width: 0; box-shadow: 0 1px 2px rgba(20, 27, 33, .05), 0 8px 24px -14px rgba(20, 27, 33, .2); }
.panel-head h2 { font-size: 1.15rem; margin: 0 0 2px; }
.panel-head { margin-bottom: 14px; }
.panel-head p { margin: 0; }

/* ---------- Paramètres ---------- */
.params fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.params legend { font-weight: 700; font-size: .9rem; margin-bottom: 8px; padding: 0; color: var(--slate-900); }
.opgroup { display: grid; gap: 6px; }
.opgroup label { position: relative; display: block; }
.opgroup input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opgroup span { display: block; padding: 10px 12px 10px 38px; border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; font-weight: 600; cursor: pointer; position: relative; line-height: 1.3; background: var(--calque-50); }
.opgroup span small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.opgroup span::before { content: ""; position: absolute; left: 12px; top: 12px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--slate-300); background: #fff; }
.opgroup input:checked + span { border-color: var(--slate-800); background: var(--slate-100); }
.opgroup input:checked + span::before { border-color: var(--slate-800); box-shadow: inset 0 0 0 3px #fff; background: var(--slate-800); }
.opgroup input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }

.lots { display: grid; gap: 2px; }
.lots label { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: .9rem; cursor: pointer; padding: 2px 4px; border-radius: 8px; }
.lots label:hover { background: var(--calque-50); }
.lots input { width: 18px; height: 18px; accent-color: var(--slate-800); flex: none; margin: 0; }
.lots .ln { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; font-size: .8rem; width: 1.8em; }

.opts-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.opts-grid label { grid-template-columns: 6.6em minmax(0, 1fr); align-items: center; gap: 8px !important; }
@media (max-width: 1280px) and (min-width: 901px) { .opts-grid label { grid-template-columns: 1fr; } }
.opts-grid label { display: grid; gap: 4px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.opts-grid select { font: inherit; font-weight: 500; font-size: .88rem; padding-right: 4px !important; color: var(--ink); padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--calque-50); min-height: 42px; width: 100%; }
.opts-grid select:disabled { opacity: .55; }

.notes label { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 6px; color: var(--slate-900); }
.notes textarea { width: 100%; font: 400 .9rem/1.5 var(--font-body); color: var(--ink); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--calque-50); resize: vertical; min-height: 140px; }
.notes textarea.listening { border-color: var(--slate-800); box-shadow: 0 0 0 3px rgba(47, 62, 74, .15); }
.notes-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.flags { margin: 10px 0 0; color: var(--muted); }
.flags:empty { display: none; }
.flags .chip { display: inline-block; margin: 3px 4px 0 0; padding: 3px 9px; border-radius: 999px; background: var(--slate-100); color: var(--slate-800); font-weight: 600; font-size: .78rem; }

.btn-sm { min-height: 40px; padding: .5em .95em; font-size: .86rem; }
.btn-soft { background: #fff; color: var(--slate-900); border-color: var(--line); }
.btn-soft:hover { border-color: var(--slate-800); }
.btn-soft:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--slate-700); text-decoration: underline; padding-left: 6px; padding-right: 6px; }
.btn-gen { width: 100%; margin-top: 18px; }
.btn-gen[aria-busy="true"] { opacity: .8; cursor: progress; }
.gen-status { margin: 8px 0 0; min-height: 1.4em; color: var(--muted); }

/* ---------- Document ---------- */
.warn { display: flex; gap: 12px; align-items: flex-start; background: var(--verif-100); border: 1px solid var(--verif-200); border-left: 5px solid var(--verif-500); color: #3e2a03; border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.warn svg { flex: none; color: var(--verif-500); margin-top: 1px; }
.warn p { margin: 0; font-size: .92rem; line-height: 1.5; }
.warn strong { display: block; font-size: 1rem; margin-bottom: 4px; color: #2f2002; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin-bottom: 12px; }
.counter { margin: 0; display: inline-flex; align-items: baseline; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--slate-900); color: var(--calque-100); font-weight: 600; font-size: .92rem; }
.counter b { font: 700 1.35rem/1 var(--font-display); color: var(--verif-200); font-variant-numeric: tabular-nums; }
.counter.done { background: var(--ok-600); }
.counter.done b { color: #fff; }
.counter.bump b { animation: bump .45s ease; }
@keyframes bump { 40% { transform: scale(1.35); } }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.print-warn { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--warn-100); color: #6a2d06; font-size: .9rem; border: 1px solid rgba(165, 71, 13, .35); }
.print-warn[hidden] { display: none; }

.sheet-frame { border-radius: 14px; background: var(--beton-200); padding: clamp(10px, 2vw, 24px); }
@media (min-width: 901px) { .sheet-frame { max-height: calc(100vh - 230px); min-height: 520px; overflow-y: auto; scroll-behavior: smooth; } }
.sheet { background: #fff; color: #1b2228; max-width: 780px; margin: 0 auto; padding: clamp(18px, 4vw, 48px) clamp(16px, 4vw, 52px); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 14px 36px -18px rgba(20, 27, 33, .45); font: 400 .95rem/1.6 var(--serif); min-height: 480px; }
.sheet.is-empty { display: grid; place-items: center; text-align: center; color: var(--muted); font-family: var(--font-body); }
.empty-in { max-width: 30em; }
.empty-in svg { margin: 0 auto 12px; color: var(--slate-300); }
.empty-in p { margin: 0 0 6px; }

.cart { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1.5px solid #1b2228; font: 400 .74rem/1.35 var(--font-body); margin-bottom: 22px; }
.cart > div { padding: 6px 8px; border-right: 1px solid rgba(27, 34, 40, .4); border-bottom: 1px solid rgba(27, 34, 40, .4); min-width: 0; overflow-wrap: anywhere; }
.cart > div:nth-child(4n) { border-right: 0; }
.cart > div:nth-last-child(-n+4) { border-bottom: 0; }
.cart dt, .cart .k { display: block; font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; color: #5c6770; font-weight: 700; }
.cart .v { font-weight: 600; }
.cart .wide { grid-column: span 2; }
@media (max-width: 560px) {
  .cart { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cart > div { border-right: 1px solid rgba(27, 34, 40, .4) !important; border-bottom: 1px solid rgba(27, 34, 40, .4) !important; }
  .cart > div:nth-child(2n) { border-right: 0 !important; }
  .cart .wide { grid-column: 1 / -1; border-right: 0 !important; }
}
.sheet-title { font: 700 1.35rem/1.2 var(--font-display); letter-spacing: -.01em; margin: 0 0 4px; color: #11181d; }
.sheet-sub { margin: 0 0 18px; color: #5c6770; font: 400 .85rem/1.4 var(--font-body); }
.draft { display: inline-block; font: 700 .7rem/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--warn-600); border: 1.5px solid currentColor; padding: 4px 8px; border-radius: 4px; margin-bottom: 12px; }
.draft.ok { color: var(--ok-600); }
.lot { margin-top: 22px; }
.lot h3 { font: 700 1rem/1.3 var(--font-body); text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--slate-800); padding: 7px 12px; margin: 0 0 12px; border-radius: 3px; }
.art { margin: 0 0 12px; }
.art h4 { font: 700 .92rem/1.35 var(--font-body); margin: 0 0 4px; color: #11181d; display: flex; gap: 10px; }
.art h4 .an { font-variant-numeric: tabular-nums; color: var(--slate-600); min-width: 2.6em; }
.art p { margin: 0 0 6px; padding-left: calc(2.6em + 10px); hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
@media (max-width: 560px) { .art p { padding-left: 0; } .sheet { font-size: .92rem; } }
.typing::after { content: ""; display: inline-block; width: 2px; height: 1em; background: var(--slate-800); margin-left: 2px; vertical-align: -2px; animation: caret .8s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.sheet-end { margin-top: 26px; padding-top: 12px; border-top: 1px solid rgba(27, 34, 40, .2); font: 400 .78rem/1.5 var(--font-body); color: #5c6770; }

/* Références surlignées */
.ref { display: inline; font: inherit; line-height: inherit; color: inherit; border: 0; padding: 1px 3px; margin: 0 1px; border-radius: 3px; background: var(--verif-200); box-shadow: inset 0 -2px 0 var(--verif-500); cursor: pointer; text-align: left; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.ref:hover { background: #f3cf72; }
.ref .ref-code { font-weight: 700; white-space: nowrap; }
.ref .ref-badge { display: inline-block; font: 800 .6rem/1 var(--font-body); letter-spacing: .08em; text-transform: uppercase; background: var(--verif-500); color: #fff; padding: 3px 5px; border-radius: 3px; margin-left: 5px; vertical-align: 2px; white-space: nowrap; }
.ref.todo { background: #fbe1d3; box-shadow: inset 0 -2px 0 var(--warn-600); }
.ref.todo .ref-badge { background: var(--warn-600); }
.ref.todo .ref-code { white-space: normal; font-style: italic; font-weight: 600; }
.ref.ok { background: var(--ok-100); box-shadow: inset 0 -2px 0 var(--ok-600); }
.ref.ok .ref-badge { background: var(--ok-600); }
.ref.flash { animation: flash 1.1s ease; }
@keyframes flash { 0%, 60% { background: #f0b43a; } }

/* Fenêtre de vérification */
.refpop { position: absolute; z-index: 60; width: min(340px, calc(100vw - 24px)); background: var(--slate-950); color: var(--calque-100); border-radius: 12px; padding: 14px 16px; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .55); }
.refpop[hidden] { display: none; }
.refpop p { margin: 0; }
.refpop-k { font: 700 .7rem/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--verif-200); margin-bottom: 6px !important; }
.refpop-code { font: 700 1.1rem/1.25 var(--font-display); color: #fff; }
.refpop-t { font-size: .88rem; line-height: 1.4; margin-top: 4px !important; color: rgba(239, 239, 234, .9); }
.refpop-h { margin-top: 8px !important; color: rgba(239, 239, 234, .7); line-height: 1.45; }
.refpop-a { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.refpop .btn-primary { background: var(--verif-200); color: #2b1d02; }
.refpop .btn-primary:hover { background: #fff; }
.refpop .btn-link { color: var(--calque-100); }

/* ---------- Registre ---------- */
.reg-bar { height: 8px; border-radius: 99px; background: var(--calque-100); overflow: hidden; margin-bottom: 12px; }
.reg-bar span { display: block; height: 100%; width: 0; background: var(--ok-600); border-radius: 99px; transition: width .3s ease; }
.reg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.reg-list li { border: 1px solid var(--line); border-left: 4px solid var(--verif-500); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; background: var(--calque-50); }
.reg-list li.todo { border-left-color: var(--warn-600); }
.reg-list li.ok { border-left-color: var(--ok-600); background: #fff; }
.rc { white-space: nowrap; font-weight: 700; font-size: .86rem; color: var(--slate-900); }
.rt { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); line-height: 1.35; }
.rw { font-size: .72rem; color: var(--muted); }
.st { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; white-space: nowrap; justify-self: end; }
.st-v { background: var(--verif-100); color: #6b4705; }
.st-t { background: var(--warn-100); color: #7a3209; }
.st-ok { background: var(--ok-100); color: #24462c; }
.rb { justify-self: end; font: 600 .76rem/1 var(--font-body); min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--slate-900); cursor: pointer; white-space: nowrap; }
.rb:hover { border-color: var(--slate-800); }
@media (min-width: 901px) { .reg-list { max-height: calc(100vh - 330px); min-height: 200px; overflow-y: auto; padding-right: 4px; } }
.legal { margin: 14px 0 0; color: var(--muted); line-height: 1.45; }

@media (max-width: 480px) {
  .panel { padding: 16px 14px; }
  .tool-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .tool-actions #print { grid-column: 1 / -1; }
  .tool-actions #skip { grid-column: 1 / -1; }
  .counter { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .typing::after { display: none; }
  .sheet-frame { scroll-behavior: auto; }
}

/* ---------- Impression : le CCTP seul, en A4 ---------- */
@page { size: A4; margin: 16mm 16mm 18mm; }
.print-only { display: none; }
@media print {
  html, body { background: #fff !important; }
  .topbar, .demo-banner, .intro, .params, .reg, .warn, .toolbar, .print-warn, .cta-end, .foot, .skip, .refpop, .noscript { display: none !important; }
  .cc, .stage, .doc-col, .sheet-frame { display: block !important; padding: 0 !important; margin: 0 !important; background: none !important; max-width: none !important; max-height: none !important; overflow: visible !important; border-radius: 0 !important; }
  .sheet { box-shadow: none; padding: 0; max-width: none; font-size: 10.4pt; min-height: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block; }
  .lot h3 { break-after: avoid; }
  .art h4 { break-after: avoid; }
  .art { break-inside: avoid; }
  .ref { box-shadow: none; padding: 0 2px; }
  .ref.ok { background: none; }
  .ref.ok .ref-badge { display: none; }
  .typing::after { display: none; }
}
.reg-list li.todo .rc { white-space: normal; }
.reg-list .rs { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
