:root {
  --fond: #fafaf9;
  --surface: #ffffff;
  --texte: #1c1b1a;
  --discret: #6b6762;
  --bordure: #e7e5e2;
  --accent: #2f5bd3;
  --accent-texte: #ffffff;
  --accent-doux: #eef2fd;
  --alerte: #8a5300;
  --alerte-fond: #fdf4e3;
  --rayon: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --fond: #161615;
    --surface: #1f1f1d;
    --texte: #ecebe8;
    --discret: #a29e98;
    --bordure: #34322f;
    --accent: #8aa8ff;
    --accent-texte: #10131c;
    --accent-doux: #222a40;
    --alerte: #f3c375;
    --alerte-fond: #33291a;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --fond: #161615;
  --surface: #1f1f1d;
  --texte: #ecebe8;
  --discret: #a29e98;
  --bordure: #34322f;
  --accent: #8aa8ff;
  --accent-texte: #10131c;
  --accent-doux: #222a40;
  --alerte: #f3c375;
  --alerte-fond: #33291a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font:
    16px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}
main,
.entete,
.pied {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}
a {
  color: var(--accent);
}
h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 1.5rem 0 0.5rem;
  letter-spacing: -0.01em;
}
h1 span,
h3 span {
  color: var(--discret);
  font-weight: 500;
}
h2 {
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
}
code {
  font-size: 0.85rem;
  word-break: break-all;
}
.visuellement-cache {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.discret,
.aide,
.facultatif {
  color: var(--discret);
  font-size: 0.875rem;
}
svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* En-tête et pied */
.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--texte);
  text-decoration: none;
}
.logo svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
}
.bouton-theme {
  background: none;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  color: var(--texte);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.bouton-theme svg {
  width: 18px;
  height: 18px;
}
.pied {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 32px;
  padding-bottom: 32px;
  font-size: 0.875rem;
}
.pied a {
  color: var(--discret);
}

/* Accueil */
.intro h1 {
  font-size: 1.9rem;
  margin-top: 1rem;
}
.intro > p {
  color: var(--discret);
  margin: 0 0 1.25rem;
}
.recherche input {
  width: 100%;
  font: inherit;
  padding: 14px 16px;
  border-radius: var(--rayon);
  border: 1px solid var(--bordure);
  background: var(--surface);
  color: var(--texte);
}
.recherche input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 4px;
  scrollbar-width: none;
}
.chip {
  flex: none;
  font: inherit;
  font-size: 0.875rem;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--bordure);
  background: var(--surface);
  color: var(--texte);
}
.chip[aria-pressed='true'] {
  background: var(--texte);
  color: var(--fond);
  border-color: var(--texte);
}
.categorie {
  margin-top: 1.75rem;
}
.categorie h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--discret);
}
.cartes {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}
@media (min-width: 640px) {
  .cartes {
    grid-template-columns: 1fr 1fr;
  }
}
.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.carte > p {
  margin: 0;
  color: var(--discret);
  font-size: 0.925rem;
}
.carte-generateur {
  border-color: var(--accent);
  background: var(--accent-doux);
}
.carte-tete {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.carte h3 {
  font-size: 1rem;
  margin: 0;
}
.carte h3 a {
  color: var(--texte);
  text-decoration: none;
}
.etiquette {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--discret);
}
.icone {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 7px;
  border-radius: 10px;
  background: var(--accent-doux);
  color: var(--accent);
}
.carte-generateur .icone {
  background: var(--surface);
}
.aucun-resultat {
  text-align: center;
  color: var(--discret);
  padding: 32px 0;
}

/* Boutons */
.bouton {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-top: auto;
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-texte);
  text-decoration: none;
}
.bouton:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Options d'ajout */
.options {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.option {
  width: 100%;
  display: flex;
  flex-direction: column;
  text-align: left;
  font: inherit;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--bordure);
  background: var(--surface);
  color: var(--texte);
  text-decoration: none;
}
.option:hover {
  border-color: var(--accent);
}
.option span {
  font-size: 0.8rem;
  color: var(--discret);
}
.options li:first-child .option {
  border-color: var(--accent);
  background: var(--accent-doux);
}
.option-secondaire strong {
  font-weight: 500;
}
.explication {
  margin-top: 12px;
  font-size: 0.9rem;
}
.explication summary {
  cursor: pointer;
  color: var(--discret);
}
.explication p {
  margin: 8px 0;
}

/* Feuille (dialog) */
.feuille {
  width: min(480px, 100%);
  max-height: 90vh;
  margin: auto auto 0;
  padding: 16px 16px 24px;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--fond);
  color: var(--texte);
}
@media (min-width: 640px) {
  .feuille {
    margin: auto;
    border-radius: 20px;
  }
}
.feuille::backdrop {
  background: rgb(0 0 0 / 0.45);
}
.feuille-tete {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.feuille-tete h2 {
  margin: 0;
}
.feuille-nom {
  margin: 0 0 12px;
  color: var(--discret);
}
.fermer {
  font-size: 1.5rem;
  line-height: 1;
  background: none;
  border: 0;
  color: var(--discret);
  cursor: pointer;
  padding: 4px 8px;
}

/* Pages de détail */
.retour {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}
.retour a {
  color: var(--discret);
  text-decoration: none;
}
.chapo {
  color: var(--discret);
  margin: 0 0 1.25rem;
}
.bloc {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 16px;
  margin-bottom: 16px;
}
.texte p,
.texte li {
  font-size: 0.95rem;
}
.evenements {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.evenements li {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bordure);
}
.evenements li:last-child {
  border-bottom: 0;
}
.evenements time {
  flex: none;
  width: 8.5em;
  color: var(--discret);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.infos {
  margin: 0;
  padding-left: 1.1em;
  font-size: 0.875rem;
  color: var(--discret);
}
.lien-brut p {
  margin: 0 0 4px;
}

/* Formulaire */
.formulaire {
  display: grid;
  gap: 16px;
}
.champ {
  display: grid;
  gap: 4px;
}
.champ label {
  font-weight: 600;
  font-size: 0.95rem;
}
.champ input,
.champ select {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--bordure);
  background: var(--fond);
  color: var(--texte);
  width: 100%;
  min-height: 44px;
}
.champ .aide {
  margin: 0;
}
.champ-groupe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.facultatif {
  font-weight: 400;
}
.case {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.95rem;
}
.case input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex: none;
}
.avertissements {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}
.avertissements li {
  background: var(--alerte-fond);
  color: var(--alerte);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
}
#resultat .bouton {
  width: 100%;
}

/* Générateur papiers : liste de documents */
.documents {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}
.document {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--bordure);
  border-radius: 12px;
}
.retirer {
  justify-self: start;
  font: inherit;
  font-size: 0.875rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--discret);
  text-decoration: underline;
  cursor: pointer;
}
.bouton-secondaire {
  justify-self: start;
  background: var(--accent-doux);
  color: var(--accent);
}
