:root {
  --ink: #12161C;
  --ink-2: #3E4856;
  --muted: #556070;
  --line: #DDE2E8;
  --ground: #F3F5F8;
  --surface: #FFFFFF;
  --accent: #2F5BEA;
  --accent-soft: #E3EAFD;
  --accent-ink: #1E3FA8;
  --warm-soft: #FDE8DA;
  --warm-ink: #9A3F0A;
  --ok-soft: #E3F4EC;
  --ok-ink: #0B5E3B;
  --mid-soft: #FFF4D6;
  --mid-ink: #6B4A00;
  --radius: 14px;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--ground); line-height: 1.5; }
a { color: var(--accent-ink); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Structure ---------- */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 100%; background: var(--ink); color: #E8ECF1; padding: 28px 18px; display: flex; flex-direction: column; gap: 28px; }
.main { flex: 999 1 560px; min-width: 0; padding: 32px clamp(16px, 4vw, 44px) 56px; }
.wrap { max-width: 1160px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--display); font-weight: 600; line-height: 1.2; }
.brand:hover { color: #fff; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; color: #C9D1DB; text-decoration: none; font-size: 14px; }
.nav a:hover { background: #1C232E; color: #fff; }
.nav a[aria-current="page"] { background: #252D3A; color: #fff; font-weight: 600; }
.who { margin-top: auto; background: #1C232E; border-radius: 12px; padding: 14px; font-size: 13px; color: #C9D1DB; display: flex; flex-direction: column; }
.who strong { color: #fff; }
.demo-note { margin: 0; font-size: 12px; color: #9AA5B4; }

/* ---------- Typographie ---------- */
h1 { font-family: var(--display); font-size: clamp(26px, 3.2vw, 34px); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
.h1-detail { font-size: clamp(22px, 2.6vw, 28px); margin-bottom: 10px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.meta { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
p { margin: 0; }

.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.weights { font-size: 14px; color: var(--muted); }
.toplinks { display: flex; justify-content: space-between; gap: 12px; }
.jump { display: none !important; }
.back { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; text-decoration: none; }

/* ---------- Chronomètre ---------- */
.timer { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.timer strong { font-family: var(--display); font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.timer strong.late { color: var(--warm-ink); }

/* ---------- Pastilles ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; background: var(--ground); color: var(--ink-2); }
.phase-emergent { background: var(--accent-soft); color: var(--accent-ink); }
.phase-montee { background: var(--warm-soft); color: var(--warm-ink); }
.phase-pic { background: #2A313C; color: #fff; }
.phase-declin { background: #E6EAF0; color: var(--ink-2); }
.urgent { color: var(--warm-ink); }
.cert-hi { background: var(--ok-soft); color: var(--ok-ink); }
.cert-mid { background: var(--mid-soft); color: var(--mid-ink); }

/* ---------- Cartes du digest ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; transition: opacity .2s; }
.card.dimmed { opacity: .55; }
.card-top { display: flex; gap: 16px; align-items: flex-start; }
.card h2 { font-size: 17px; line-height: 1.35; margin: 0 0 8px; }
.card h2 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.ring { flex: none; width: 64px; height: 64px; border-radius: 50%; border: 3px solid #7C8BA1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-hi { border-color: var(--accent); }
.ring strong { font-family: var(--display); font-size: 22px; line-height: 1; }
.ring span { font-size: 10px; color: var(--muted); }
.qclient { font-size: 13px; color: var(--ok-ink); background: var(--ok-soft); border-radius: 10px; padding: 8px 12px; }
.facts { margin: 0; background: #F6F8FB; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.facts div { display: block; }
.facts dt { font-weight: 600; display: inline; }
.facts dt::after { content: ' :'; }
.facts dd { margin: 0 0 0 4px; display: inline; }
.bars { display: grid; grid-template-columns: minmax(120px, auto) minmax(0, 1fr) 30px; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--ink-2); }
.bars small { color: var(--muted); }
.bar { height: 8px; background: #E6EAF0; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.num { text-align: right; font-weight: 600; }

/* ---------- Boutons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; background: var(--accent); color: #fff; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { color: #fff; filter: brightness(.95); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-dark { background: var(--ink); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: #CBD2DC; font-weight: 500; }
.btn-ghost:hover { color: var(--ink); background: var(--ground); }
.btn-link { background: none; color: var(--ink-2); text-decoration: underline; font-weight: 500; }
.btn-link:hover { color: var(--ink); }

/* ---------- États ---------- */
.empty { background: var(--surface); border: 1px dashed #B8C1CD; border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.qlist { margin: 0; padding-left: 20px; }
.ecartes { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.ecartes summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.ecartes ul { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.ecartes li { display: flex; flex-direction: column; }
.ecartes li span { color: var(--muted); }
.demo-links { font-size: 13px; color: var(--muted); }
.notice { background: var(--accent-soft); color: var(--accent-ink); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.warn { background: #FFF6EF; color: #6E2E07; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.success { background: var(--ok-soft); color: var(--ok-ink); border-radius: 10px; padding: 12px 14px; font-size: 14px; }

/* ---------- Écran sujet ---------- */
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.panel .pills { margin-bottom: 12px; }
.draft { flex: 1.5 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.draft-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; }
.draft-head h2 { margin: 0; font-size: 18px; }
.sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.sources li { display: flex; flex-direction: column; }
.sources span { font-size: 13px; color: var(--muted); }
.phases { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; font-size: 12px; color: var(--muted); }
.phases li { border-top: 8px solid #E6EAF0; padding-top: 6px; }
.phases li.done { border-color: #9DB2F2; }
.phases li.now { border-color: #E0661B; color: var(--warm-ink); font-weight: 600; }
.why { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.why li > div { display: flex; justify-content: space-between; gap: 10px; }
.why p { color: var(--ink-2); }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.label, .field > label, legend { font-size: 13px; font-weight: 600; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid #CBD2DC; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; background: var(--ground); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1 1 120px; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 2px rgba(18, 22, 28, .12); }
textarea, input, select { font: inherit; font-size: 15px; color: var(--ink); border: 1px solid #CBD2DC; border-radius: 10px; padding: 10px 12px; background: var(--surface); width: 100%; }
input, select { min-height: 44px; }
#texte { line-height: 1.65; min-height: 300px; resize: vertical; }
.plan { background: #F6F8FB; border-radius: 12px; padding: 14px 16px; font-size: 14px; }
.plan ol { margin: 8px 0 0; }
.raisons { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.raisons legend { padding: 0 4px; }

/* ---------- Profil ---------- */
.form { flex: 1.5 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid #CBD2DC; border-radius: 10px; font-size: 14px; background: var(--surface); cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }

/* ---------- Historique ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.stat span, .stat small { color: var(--muted); font-size: 13px; }
.stat strong { font-family: var(--display); font-size: 28px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #EEF1F4; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
td.ok { color: var(--ok-ink); font-weight: 600; }
td.ko { color: var(--warm-ink); font-weight: 600; }

/* ---------- Ajouts : appel à l'action, traduction ---------- */
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 13px; }
.tag { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600; background: var(--mid-soft); color: var(--mid-ink); border-radius: 999px; padding: 1px 7px; }
.hint { background: #F6F8FB; border-radius: 10px; padding: 8px 12px; color: var(--ink-2); }
.draft-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.cta-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 8px; align-items: center; }
@media (max-width: 520px) { .cta-row { grid-template-columns: 1fr; } }

/* ---------- Mobile : pile de cartes à swiper ---------- */
.deck { position: relative; display: block; transition: height .2s ease; }
.deck .card { position: absolute; inset: 0 0 auto 0; touch-action: pan-y; user-select: none; box-shadow: 0 6px 18px rgba(18, 22, 28, .10); background: var(--surface); }
.deck .card:not(.is-top):not(.is-next) { visibility: hidden; }
.deck .card.is-next { transform: translateY(10px) scale(.97); }
.deck .bars, .deck .card .actions { display: none; }
.stamp { display: none; }
.deck .stamp { display: block; position: absolute; top: 18px; padding: 4px 12px; border: 3px solid; border-radius: 8px; font-family: var(--display); font-size: 22px; font-weight: 700; opacity: 0; pointer-events: none; background: var(--surface); }
.deck .stamp-open { left: 18px; color: var(--ok-ink); transform: rotate(-10deg); }
.deck .stamp-pass { right: 18px; color: var(--warm-ink); transform: rotate(10deg); }
.deck-bar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 18px; }
.deck-count { font-size: 14px; color: var(--muted); text-align: center; }
.deck-help { font-size: 13px; color: var(--muted); }

@media (max-width: 700px) {
  .main { padding-top: 20px; }
  .head { align-items: flex-start; }
  .card-top { gap: 12px; }
  .ring { width: 54px; height: 54px; }
  .side { padding: 12px 14px; gap: 10px; }
  .brand { font-size: 14px; }
  .brand br { display: none; }
  .brand-mark { width: 30px; height: 30px; font-size: 11px; }
  .nav { gap: 2px; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { min-height: 40px; padding: 0 10px; font-size: 13px; white-space: nowrap; }
  h1 { font-size: 23px; }
  .meta { font-size: 13px; }
  .weights { display: none; }
  .timer { flex-direction: row; align-items: center; gap: 8px; padding: 6px 10px; }
  .timer strong { font-size: 16px; }
  .wrap { gap: 16px; }
  .jump { display: inline-flex !important; }
  .side { flex-basis: 100%; padding: 16px; gap: 14px; }
  .nav { flex-direction: row; }
  .who, .demo-note { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
