/* ===== Charte du portail : palette des maquettes, typographie système, thèmes clair et sombre ===== */
/* Thème : celui du système, forçable par le bouton de l'en-tête (data-theme sur <html>, posé par site.js). */
:root {
  color-scheme: light;
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f8f9fb; --hover: #eef1f5;
  --text: #121826; --text-2: #364152; --muted: #5b6676; --border: #dfe3ea; --border-strong: #c4cbd6;
  --accent: #1f4fbf; --accent-hover: #183f9a; --accent-ink: #ffffff; --accent-soft: #edf2fd; --accent-line: #c5d3f5;
  --ok: #1d7a3e; --ok-bg: #e8f5ec;
  --warn: #8a4b00; --warn-bg: #fff4e0; --warn-line: #f1c98a;
  --danger: #b42318; --danger-bg: #fdecea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
  --width: 960px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1018; --surface: #121824; --surface-2: #161d2b; --hover: #1c2433;
  --text: #e8ebf1; --text-2: #c5ccd8; --muted: #9aa4b5; --border: #263042; --border-strong: #36435a;
  --accent: #7d9cff; --accent-hover: #9cb4ff; --accent-ink: #0c1018; --accent-soft: #18213a; --accent-line: #2d3e70;
  --ok: #5fd08a; --ok-bg: #10291a;
  --warn: #f5c16c; --warn-bg: #2d2210; --warn-line: #6b4f1d;
  --danger: #f47c72; --danger-bg: #331614;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1018; --surface: #121824; --surface-2: #161d2b; --hover: #1c2433;
    --text: #e8ebf1; --text-2: #c5ccd8; --muted: #9aa4b5; --border: #263042; --border-strong: #36435a;
    --accent: #7d9cff; --accent-hover: #9cb4ff; --accent-ink: #0c1018; --accent-soft: #18213a; --accent-line: #2d3e70;
    --ok: #5fd08a; --ok-bg: #10291a;
    --warn: #f5c16c; --warn-bg: #2d2210; --warn-line: #6b4f1d;
    --danger: #f47c72; --danger-bg: #331614;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

/* ----- Base ----- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 16px/1.6 var(--font); color: var(--text); background: var(--bg); font-feature-settings: "kern";
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 680; letter-spacing: -.01em; }
h1 { font-size: 28px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
p { margin: 0 0 .9em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
.muted, small { color: var(--muted); }
.lead { font-size: 17px; color: var(--text-2); }
code, pre { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 6px; font-weight: 600; }
.skip:focus { top: 10px; color: var(--accent-ink); }

/* ----- Ossature : en-tête, contenu, pied ----- */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-inner, .page, .foot { width: 100%; max-width: var(--width); margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions form { margin: 0; }
.page { flex: 1; padding-top: 32px; padding-bottom: 40px; }
.foot { padding-top: 16px; padding-bottom: 24px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.foot p { margin: 0; }
.narrow { max-width: 440px; margin: 0 auto; }

/* ----- Composants ----- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin: 0 0 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-ink); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--hover); color: var(--text); border-color: var(--border-strong); }
label { display: block; font-weight: 600; margin: 0 0 4px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 9px 12px; min-height: 42px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; }
.field { margin: 0 0 16px; }
.alert { border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; border: 1px solid var(--border); background: var(--surface-2); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--text); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--text); }
.alert-ok { background: var(--ok-bg); border-color: var(--ok); color: var(--text); }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; line-height: 1.6;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); white-space: nowrap;
}

/* ----- Documents : cartes de l'accueil, page d'un document ----- */
/* Une colonne sur téléphone, deux dès la tablette. */
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.doc-card { margin: 0; display: flex; flex-direction: column; }
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 0 0 8px; }
.doc-title { margin: 0; overflow-wrap: anywhere; }
.doc-title a { color: var(--text); text-decoration: none; }
.doc-title a:hover { color: var(--accent); text-decoration: underline; }
.doc-desc { white-space: pre-line; color: var(--text-2); overflow-wrap: anywhere; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.doc-meta div { display: flex; gap: 6px; }
.doc-meta dt { font-weight: 600; }
.doc-meta dd { margin: 0; color: var(--text-2); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.doc-page .doc-title { font-size: 26px; }
.crumbs { margin: 0 0 12px; font-size: 15px; }

/* ----- Back office : tableaux, formulaires, compteurs ----- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0 0 16px; }
.page-head h1 { margin: 0; }
.btn-small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: var(--surface); filter: brightness(.92); }
.badge-muted { color: var(--text-2); background: var(--surface-2); border-color: var(--border-strong); }
/* position: relative : les textes .sr-only (absolus) du tableau restent dans la zone défilante, sans élargir la page. */
.table-wrap { position: relative; padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th { font-size: 13px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.table tbody tr:last-child th, .table tbody tr:last-child td { border-bottom: none; }
.table .cell-title { font-weight: 600; min-width: 12em; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; flex-wrap: nowrap; gap: 6px; }
.row-actions form, .form-actions form { margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; min-height: 0; }
.check label { margin: 0; }
textarea { min-height: 6em; resize: vertical; }
input[type="file"] { padding: 7px 10px; }
.card h3 { margin-top: 18px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0 0 16px; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { color: var(--muted); font-size: 14px; }
.stats dd { margin: 0; font-size: 28px; font-weight: 700; }
.danger-zone { border-color: var(--danger); }
.badge-warn { color: var(--text); background: var(--warn-bg); border-color: var(--warn-line); }
.cell-detail { overflow-wrap: anywhere; }
.secret { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); overflow-wrap: anywhere; }
.secret code { font-size: 20px; letter-spacing: .04em; }
.secret-uri code { font-size: 14px; letter-spacing: 0; }
.notice-list { margin: 0 0 16px; padding-left: 20px; font-size: 15px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 16px; }

/* ----- Commentaires : fil d'un document, compteur des cartes ----- */
.doc-comments { margin: 0 0 12px; font-size: 14px; }
.comment-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 12px; }
.comment { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface); }
.comment-anonda { background: var(--accent-soft); border-color: var(--accent-line); }
.comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 6px; font-size: 14px; }
.comment-author { font-weight: 650; }
.comment-text { white-space: pre-line; overflow-wrap: anywhere; margin: 0 0 8px; }
.comment .row-actions { flex-wrap: wrap; }
.comment-form { margin-top: 8px; }

/* ----- Petits écrans ----- */
@media (max-width: 600px) {
  h1 { font-size: 24px; }
  .page { padding-top: 22px; }
  .top-inner { min-height: 54px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-left: auto; }
  .top-actions .btn { min-height: 36px; padding: 4px 10px; font-size: 14px; }
  .btn { padding: 8px 12px; }
  .doc-page .doc-title { font-size: 22px; }
  .doc-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .top-actions, .skip { display: none; }
  body { background: #fff; color: #000; }
}
