:root {
  --fond: #f3f0e8;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --bord: #e2ddd0;
  --bord-fort: #cfc8b6;
  --texte: #1f2328;
  --texte-2: #5f6670;
  --accent: #3d5a80;
  --accent-fort: #2c4462;
  --accent-doux: #e6ecf4;
  --danger: #b3261e;
  --ok: #2e7d4f;
  --alerte: #b45309;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(31, 35, 40, .06), 0 4px 16px rgba(31, 35, 40, .06);
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--police); font-size: 15px; line-height: 1.45; color: var(--texte); background: var(--fond); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0 0 .6em; }
a { color: var(--accent); }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.discret { color: var(--texte-2); }
.nowrap { white-space: nowrap; }
.icone { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 14px; border: 1px solid var(--bord-fort); border-radius: 8px; background: var(--surface); color: var(--texte); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--texte-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primaire:hover { background: var(--accent-fort); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--bord)); }
.btn.danger:hover { background: #fdecea; }
.btn.discret { border-color: transparent; background: transparent; color: var(--accent); }
.btn.discret:hover { background: var(--accent-doux); }
.btn.petit { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.gauche { margin-right: auto; }
.btn-icone { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--texte-2); cursor: pointer; }
.btn-icone:hover { background: var(--surface-2); color: var(--texte); border-color: var(--bord); }
.btn-icone.mini { width: 26px; height: 26px; }
.lien { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* ---------- Accueil ---------- */
.accueil { min-height: 100vh; padding: 48px 16px; }
.accueil-cadre { max-width: 880px; margin: 0 auto; }
.accueil-entete { display: flex; align-items: center; gap: 16px; margin-bottom: 32px; }
.accueil-entete h1 { font-size: 30px; letter-spacing: -.01em; }
.accroche { color: var(--texte-2); margin: 4px 0 0; }
.accueil-entete .compte { margin-left: auto; }
.carte-accueil { background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 28px; box-shadow: var(--ombre); max-width: 560px; }
.carte-accueil h2 { font-size: 22px; margin-bottom: 10px; }
.puces-info { padding-left: 20px; color: var(--texte-2); margin: 12px 0 22px; }
.puces-info li { margin: 4px 0; }
.btn-google { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 18px 0 12px; border: 1px solid #747775; border-radius: 22px; background: #fff; color: #1f1f1f; font: 500 15px var(--police); cursor: pointer; }
.btn-google:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.btn-google .g { display: inline-grid; place-items: center; }
.ou { margin-top: 18px; font-size: 14px; }
.titre-section { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; }
.titre-section h2 { font-size: 22px; }
.groupe { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fichiers { display: grid; gap: 10px; }
.fichier { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 6px 8px 6px 6px; }
.fichier:hover { border-color: var(--bord-fort); box-shadow: var(--ombre); }
.fichier-ouvrir { flex: 1; display: grid; gap: 2px; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; cursor: pointer; font: inherit; color: inherit; min-width: 0; }
.fichier-nom { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fichier-info { color: var(--texte-2); font-size: 13px; }
.bandeau { background: var(--accent-doux); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent-fort); border-radius: var(--rayon); padding: 10px 14px; margin-bottom: 20px; font-size: 14px; }
.accueil-pied { margin-top: 48px; font-size: 13px; color: var(--texte-2); display: flex; gap: 8px; flex-wrap: wrap; }
.vide { background: var(--surface); border: 1px dashed var(--bord-fort); border-radius: var(--rayon); padding: 28px; text-align: center; color: var(--texte-2); }

/* ---------- Compte ---------- */
.compte { display: flex; align-items: center; gap: 4px; min-width: 0; }
.compte-nom { font-size: 13px; color: var(--texte-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Éditeur ---------- */
.editeur { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.barre { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--bord); min-height: 58px; }
.barre input.titre-fresque { font: 650 18px var(--police); border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; background: transparent; color: var(--texte); min-width: 120px; width: min(380px, 35vw); min-height: 0; text-overflow: ellipsis; box-shadow: none; }
.barre input.titre-fresque:hover { border-color: var(--bord); }
.barre input.titre-fresque:focus { border-color: var(--accent); outline: none; background: #fff; }
.espaceur { flex: 1; }
.etat { border: 0; background: none; font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 99px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.etat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.etat.ok { color: var(--ok); }
.etat.attente { color: var(--texte-2); }
.etat.attente::before { animation: pulse 1.2s ease-in-out infinite; }
.etat.neutre { color: var(--texte-2); }
.etat.alerte { color: var(--alerte); background: #fff4e5; cursor: pointer; }
.etat:not(:disabled) { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@keyframes pulse { 50% { opacity: .3; } }

.espace { flex: 1; display: flex; min-height: 0; }
.principal { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 18px 40px; }
.outils { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.recherche { flex: 1; min-width: 200px; }
.recherche input { width: 100%; }
.zoom { gap: 2px; background: var(--surface); border: 1px solid var(--bord); border-radius: 10px; padding: 2px; }
.fresque { position: relative; height: clamp(360px, 60vh, 820px); border: 1px solid var(--bord); border-radius: 12px; overflow: hidden; background: #fbfaf6; box-shadow: var(--ombre); }
.fresque-canvas { display: block; touch-action: none; cursor: grab; outline: none; }
.fresque-canvas.glisse { cursor: grabbing; }
.fresque-canvas:focus-visible { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.aide-fresque { font-size: 12.5px; color: var(--texte-2); margin: 8px 2px 18px; }
.infobulle { position: absolute; top: 0; left: 0; pointer-events: none; background: #1f2328; color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; max-width: 300px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 2; }
.ib-titre { font-weight: 650; font-size: 13.5px; }
.ib-note { color: #c9ced6; font-style: italic; }

.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--bord); margin-bottom: 16px; overflow-x: auto; }
.onglet { border: 0; background: none; font: 600 14px var(--police); color: var(--texte-2); padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.onglet[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.compteur { font-size: 12px; font-weight: 600; background: var(--surface); border: 1px solid var(--bord); border-radius: 99px; padding: 0 8px; color: var(--texte-2); }

.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.carte { display: flex; flex-direction: column; gap: 4px; text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--bord); border-left: 4px solid var(--c, var(--accent)); border-radius: var(--rayon); padding: 12px 14px; cursor: pointer; min-height: 96px; }
.carte:hover { border-color: var(--bord-fort); border-left-color: var(--c); box-shadow: var(--ombre); }
.carte-nom { font-weight: 650; font-size: 15.5px; }
.carte-dates { font-size: 13px; color: var(--texte-2); }
.carte-extrait { font-size: 13px; color: var(--texte-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.carte-meta { margin-top: auto; padding-top: 4px; font-size: 12px; color: var(--accent); font-weight: 600; }
.note-limite { font-size: 13px; color: var(--texte-2); margin-top: 12px; }

.bloc-territoire { margin-bottom: 22px; }
.bloc-territoire h3 { display: flex; align-items: center; justify-content: space-between; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-2); margin-bottom: 8px; }
.tableau { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden; font-size: 14px; }
.tableau th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-2); background: var(--surface-2); padding: 8px 12px; border-bottom: 1px solid var(--bord); }
.tableau td { padding: 9px 12px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cliquable { cursor: pointer; }
.cliquable:hover td { background: var(--surface-2); }
.pastille-ligne { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 8px; vertical-align: 0; }
.lien-fiche { margin-left: 8px; border: 1px solid var(--bord); background: var(--surface-2); color: var(--accent); border-radius: 99px; font: 600 11.5px var(--police); padding: 1px 8px; cursor: pointer; }
.imp { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--bord); white-space: nowrap; }
.imp-3 { color: #8a2c0f; background: #fdf0e9; border-color: #f2cdb9; }
.imp-1 { color: var(--texte-2); }

/* ---------- Fiche ---------- */
.fiche { width: 420px; flex: none; border-left: 1px solid var(--bord); background: var(--surface); overflow-y: auto; }
.fiche-entete { padding: 16px 20px 16px; border-top: 6px solid var(--c); background: linear-gradient(color-mix(in srgb, var(--c) 9%, #fff), #fff); border-bottom: 1px solid var(--bord); }
.fiche-boutons { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 4px; }
.fiche-nom { font-size: 25px; letter-spacing: -.01em; }
.fiche-autres { color: var(--texte-2); font-style: italic; margin: 4px 0 0; }
.fiche-dates { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 12px 0 0; font-size: 14px; }
.fiche-dates dt { color: var(--texte-2); }
.fiche-dates dd { margin: 0; font-weight: 500; }
.fiche-corps { padding: 16px 20px 32px; }
.fiche-description { font-size: 14.5px; }
.fiche-section { margin-top: 22px; }
.fiche-section-titre { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--bord); padding-bottom: 6px; margin-bottom: 10px; }
.fiche-section-titre h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-2); }
.chrono { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--bord); }
.chrono-item { position: relative; margin-bottom: 6px; }
.chrono-item::before { content: ""; position: absolute; left: -22px; top: 12px; width: 10px; height: 10px; background: var(--accent); transform: rotate(45deg); border: 2px solid #fff; }
.chrono-item.niv-1::before { width: 8px; height: 8px; left: -21px; opacity: .7; }
.chrono-item.niv-3::before { width: 12px; height: 12px; left: -23px; top: 11px; }
.chrono-bouton { display: grid; gap: 1px; width: 100%; text-align: left; border: 0; background: none; font: inherit; color: inherit; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.chrono-bouton:hover { background: var(--surface-2); }
.chrono-date { font-size: 12.5px; color: var(--texte-2); font-weight: 600; }
.chrono-titre { font-weight: 600; }
.niv-3 > .chrono-bouton .chrono-titre { font-weight: 700; }
.chrono-desc { font-size: 13.5px; color: var(--texte-2); }
.chrono-avec { font-size: 12.5px; color: var(--texte-2); padding: 0 8px 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.liens, .regnes-fiche { list-style: none; margin: 0; padding: 0; }
.liens li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 0; border-bottom: 1px dashed var(--bord); font-size: 14px; }
.liens li:last-child { border-bottom: 0; }
.liens .btn-icone { margin-left: auto; }
.lien-type { color: var(--texte-2); }
.lien-personne { border: 1px solid var(--bord); border-left: 3px solid var(--c); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font: 600 13px var(--police); color: var(--texte); cursor: pointer; }
.lien-personne:hover { border-color: var(--c); }

/* ---------- Modales et formulaires ---------- */
.modale { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--texte); display: flex; flex-direction: column; }
.modale:not([open]) { display: none; }
.modale.large { width: min(720px, calc(100vw - 32px)); }
.modale::backdrop { background: rgba(31, 35, 40, .45); }
.modale-entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 22px; }
.modale-entete h2 { font-size: 19px; }
.modale-corps { padding: 6px 22px 16px; overflow-y: auto; }
.modale-pied { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 22px 18px; border-top: 1px solid var(--bord); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.formulaire { display: grid; gap: 14px; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.champ { display: grid; gap: 5px; align-content: start; }
.libelle { font-size: 13px; font-weight: 600; color: var(--texte); }
.aide { font-size: 12.5px; color: var(--texte-2); }
input[type=text], input[type=search], select, textarea { font: inherit; font-size: 14.5px; color: var(--texte); background: #fff; border: 1px solid var(--bord-fort); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.apercu-date { font-size: 12.5px; min-height: 18px; color: var(--texte-2); }
.apercu-date.ok { color: var(--ok); }
.apercu-date.erreur { color: var(--danger); }
.erreur-formulaire { background: #fdecea; color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.couleurs { display: flex; flex-wrap: wrap; gap: 8px; }
.pastille { position: relative; cursor: pointer; }
.pastille input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pastille span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--bord-fort); font-size: 10px; font-weight: 700; color: var(--texte-2); }
.pastille.auto span { width: auto; padding: 0 10px; border-radius: 99px; background: var(--surface-2); }
.pastille input:checked + span { box-shadow: 0 0 0 2px var(--texte); }
.pastille input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.segments { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--bord-fort); border-radius: 9px; padding: 2px; background: var(--surface-2); gap: 2px; justify-self: start; }
.segments label { position: relative; }
.segments input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segments span { display: block; padding: 6px 14px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--texte-2); }
.segments input:checked + span { background: #fff; color: var(--texte); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.segments input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.case { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.case input { width: 17px; height: 17px; accent-color: var(--accent); }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--bord); border-left: 3px solid var(--c); border-radius: 6px; padding: 3px 4px 3px 9px; font-size: 13.5px; font-weight: 600; }
.puce button { border: 0; background: none; font-size: 16px; line-height: 1; color: var(--texte-2); cursor: pointer; padding: 0 4px; border-radius: 4px; }
.puce button:hover { background: var(--bord); color: var(--texte); }
.phrase-lien { font-weight: 600; margin: 0; }
.export-ligne { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--bord); }
.export-ligne p { margin: 2px 0 6px; font-size: 13.5px; }
.export-ligne select { width: auto; margin-top: 8px; }
.etat-export { font-size: 13.5px; color: var(--texte-2); min-height: 20px; margin: 4px 0 0; }

/* ---------- Notifications et chargement ---------- */
.notifs { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(460px, calc(100vw - 32px)); }
.notif { background: #1f2328; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: opacity .3s, transform .3s; }
.notif.erreur { background: var(--danger); }
.notif.ok { background: var(--ok); }
.notif.sortie { opacity: 0; transform: translateY(8px); }
.chargement { position: fixed; inset: 0; background: rgba(243, 240, 232, .82); display: grid; place-content: center; justify-items: center; gap: 12px; z-index: 90; font-weight: 600; color: var(--texte-2); }
.roue { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--bord-fort); border-top-color: var(--accent); animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.noscript { padding: 40px; text-align: center; }

/* ---------- Petits écrans ---------- */
@media (max-width: 900px) {
  .fiche { position: fixed; inset: 0; width: auto; z-index: 50; border-left: 0; }
  .barre { flex-wrap: wrap; padding: 8px 10px; gap: 6px; }
  .barre input.titre-fresque { width: auto; flex: 1; font-size: 16px; }
  .espaceur { display: none; }
  .barre .compte-nom { display: none; }
  .principal { padding: 10px 12px 32px; }
  .fresque { height: clamp(320px, 62vh, 620px); }
  .outils .groupe:first-child { width: 100%; }
  .outils .groupe:first-child .btn { flex: 1; padding: 7px 8px; }
}
@media (max-width: 560px) {
  .grille-2 { grid-template-columns: 1fr; }
  .accueil { padding: 24px 16px; }
  .accueil-entete { flex-wrap: wrap; }
  .accueil-entete h1 { font-size: 26px; }
  .carte-accueil { padding: 20px; }
  .export-ligne { flex-direction: column; align-items: stretch; }
  .aide-fresque { display: none; }
  .modale-pied .btn { flex: 1; }
  .barre .texte-btn { display: none; }
  .barre .btn { padding: 7px 10px; }
  .barre .etat { order: 10; width: 100%; justify-content: flex-start; padding-left: 4px; }
}

/* ---------- Page de confidentialité ---------- */
.texte-legal { line-height: 1.6; max-width: 720px; }
.texte-legal h1 { font-size: 28px; margin: 16px 0 4px; }
.texte-legal h2 { font-size: 18px; margin: 28px 0 8px; }
.texte-legal code { background: var(--surface); border: 1px solid var(--bord); border-radius: 4px; padding: 0 4px; }
