:root {
  --papier: #f6f1e7;
  --carte: #fffdf8;
  --encre: #1d2b2a;
  --encre-douce: #5b6563;
  --trait: #e2d9c8;
  --trait-fort: #cfc5b2;
  --accent: #1f5f5b;
  --accent-fort: #164845;
  --accent-pale: #eef5f4;
  --ocre: #a8701a;
  --ok: #2f7d4f;
  --ok-fond: #e6f2ea;
  --ko: #b3261e;
  --ko-fond: #fbe9e7;
  --sable: #fdf3df;
  --rayon: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--papier); color: var(--encre); font: 16px/1.55 var(--sans); min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 0; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.aide { color: var(--encre-douce); font-size: .85rem; font-weight: 400; }
:focus-visible { outline: 3px solid rgba(31, 95, 91, .35); outline-offset: 2px; }

/* Boutons */
button[type="submit"], .secondaire { border-radius: 9px; padding: .55rem 1.2rem; border: 1px solid var(--accent); }
button[type="submit"] { background: var(--accent); color: #fff; font-weight: 600; }
button[type="submit"]:hover { background: var(--accent-fort); }
button[disabled] { opacity: .55; cursor: progress; }
.secondaire { background: transparent; color: var(--accent); padding: .4rem .9rem; font-size: .92rem; }
.secondaire:hover { background: var(--accent-pale); }
.lien { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0; }
.lien.discret { color: var(--encre-douce); text-decoration: none; font-size: .9rem; }
.lien.discret:hover { color: var(--accent); text-decoration: underline; }
.croix { background: none; border: 0; color: var(--encre-douce); padding: 0 .2rem; font-size: .85rem; line-height: 1; }
.croix:hover { color: var(--ko); }

/* En-tête */
.entete { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.25rem; }
.marque { display: flex; align-items: center; gap: .55rem; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.compte { display: flex; align-items: center; gap: .8rem; }
.menu-compte { position: relative; }
.menu-compte summary { list-style: none; cursor: pointer; color: var(--encre-douce); font-size: .9rem; padding: .3rem .5rem; border-radius: 8px; }
.menu-compte summary::-webkit-details-marker { display: none; }
.menu-compte summary::after { content: " ▾"; }
.menu-compte[open] summary { background: var(--carte); }
.menu-compte form { position: absolute; right: 0; top: 2.1rem; margin: 0; background: var(--carte); border: 1px solid var(--trait); border-radius: 10px; padding: .6rem .9rem; white-space: nowrap; z-index: 2; box-shadow: 0 4px 16px rgba(0,0,0,.06); }

/* Page */
.page { width: 100%; max-width: 820px; margin: 0 auto; padding: .5rem 1.25rem 2rem; display: flex; flex-direction: column; gap: 1rem; flex: 1; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1.1rem 1.25rem; }

/* Zone de saisie */
.saisie { background: var(--carte); border: 1px solid var(--trait-fort); border-radius: 16px; padding: .9rem 1rem .7rem; box-shadow: 0 2px 10px rgba(29, 43, 42, .05); transition: border-color .15s, box-shadow .15s; }
.saisie:focus-within { border-color: var(--accent); box-shadow: 0 2px 14px rgba(31, 95, 91, .12); }
.depot .saisie:not([hidden]) { border: 2px dashed var(--accent); background: var(--accent-pale); }
.saisie textarea { width: 100%; border: 0; background: transparent; font: inherit; color: inherit; resize: vertical; min-height: 4.5rem; padding: 0; outline: none; }
.suite textarea { min-height: 2.2rem; }
.barre-saisie { display: flex; align-items: center; gap: .9rem; margin-top: .5rem; flex-wrap: wrap; }
.barre-saisie button[type="submit"] { margin-left: auto; }
.bouton-icone { display: inline-flex; align-items: center; gap: .3rem; color: var(--encre-douce); font-size: .92rem; cursor: pointer; padding: .3rem .55rem; border-radius: 8px; border: 1px solid var(--trait); }
.bouton-icone:hover, .bouton-icone:focus-within { color: var(--accent); border-color: var(--accent); }
.bouton-icone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.puce-date { display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-pale); color: var(--accent); border-radius: 999px; padding: .15rem .3rem .15rem .7rem; font-size: .88rem; }
.puce-date input { border: 0; background: transparent; color: inherit; font: inherit; padding: 0; }
.puces-pieces { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.puces-pieces:empty { display: none; }
.puce-piece { display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; background: #f1ece1; border-radius: 999px; padding: .15rem .35rem .15rem .7rem; font-size: .86rem; }
.puce-piece span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.puce-piece.en-cours { opacity: .7; }
.puce-piece.erreur-piece { background: var(--ko-fond); color: var(--ko); }
.puce-piece.erreur-piece span { white-space: normal; }

.suggestions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: -.4rem; }
.suggestion { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: .45rem 1rem; font-weight: 600; font-size: .93rem; }
.suggestion:hover { background: var(--accent-fort); }
.exemples { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: -.3rem; }
.puce { background: transparent; border: 1px solid var(--trait-fort); color: var(--encre-douce); border-radius: 999px; padding: .25rem .8rem; font-size: .85rem; }
.puce:hover { border-color: var(--accent); color: var(--accent); }

/* Recherches (cartes) et attente */
.conversations { display: flex; flex-direction: column; gap: 1rem; }
.tete-conv { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; }
.tete-conv .rappel-question { margin: 0 0 .6rem; font-weight: 600; color: var(--encre); font-size: .95rem; }
.fil-conv { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .6rem; }
.fil-conv:empty { display: none; }
.attente { margin: .2rem 0 .4rem; }
.ligne-attente { display: flex; align-items: center; gap: .6rem; }
.ligne-attente .phrase { font-weight: 600; flex: 1; }
.chrono { font-variant-numeric: tabular-nums; color: var(--encre-douce); font-size: .92rem; }
.ligne-attente.bas { margin-top: .4rem; font-size: .83rem; color: var(--encre-douce); flex-wrap: wrap; gap: .3rem .9rem; }
.compteurs { color: var(--accent); font-weight: 600; }
.compteurs:empty { display: none; }
.actions-attente { margin-left: auto; display: inline-flex; gap: .9rem; }
.barre { height: 6px; background: #ece5d6; border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.barre .remplie { height: 100%; width: 3%; background: var(--accent); border-radius: 999px; transition: width 1s linear; }
.detail-etapes { margin-top: .4rem; font-size: .83rem; color: var(--encre-douce); }
.detail-etapes summary { cursor: pointer; width: max-content; }
.detail-etapes ol { margin: .3rem 0 0; padding-left: 1.2rem; }
.conversation > .erreur { margin: .4rem 0; }
.suite-conv { display: flex; gap: .6rem; align-items: flex-end; margin-top: 1rem; border: 1px solid var(--trait-fort); border-radius: 12px; padding: .5rem .5rem .5rem .8rem; background: #fff; }
.suite-conv:focus-within { border-color: var(--accent); }
.suite-conv textarea { flex: 1; border: 0; outline: none; resize: none; font: inherit; color: inherit; background: transparent; min-height: 1.6rem; padding: .25rem 0; }
.suite-conv button { flex: none; padding: .4rem 1rem; }
.sablier { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: tourne .9s linear infinite; vertical-align: -2px; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sablier { animation: none; } .barre .remplie { transition: none; } }

.erreur { margin: 0; padding: .7rem 1rem; background: var(--ko-fond); color: var(--ko); border: 1px solid #f0c4bf; border-radius: 10px; }
.alerte { margin: 0 0 .6rem; padding: .5rem .8rem; background: var(--ko-fond); color: var(--ko); border-radius: 8px; font-size: .9rem; }

/* Réponse */
.rappel-question { margin: 0 0 .7rem; color: var(--encre-douce); font-size: .92rem; }
.markdown h3 { font-size: 1.05rem; margin: 1.1rem 0 .35rem; }
.markdown p { margin: .45rem 0; }
.markdown ul, .markdown ol { padding-left: 1.35rem; margin: .35rem 0; }
.markdown li { margin: .2rem 0; }
.markdown hr { border: 0; border-top: 1px solid var(--trait); margin: 1rem 0; }
.markdown code { background: #f1ece1; padding: 0 .25rem; border-radius: 4px; }
.markdown blockquote { margin: .5rem 0; padding: .2rem .9rem; border-left: 3px solid var(--trait); color: var(--encre-douce); }
.en-bref { background: var(--accent-pale); border-left: 4px solid var(--accent); border-radius: 8px; padding: .2rem 1rem .5rem; margin: 0 0 .8rem; font-size: 1.05rem; }
.en-bref h3 { margin-top: .6rem !important; color: var(--accent); font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; font-family: var(--sans); }
.ref { border-bottom: 2px solid; padding-bottom: 1px; }
.ref.ok { border-color: rgba(47, 125, 79, .55); }
.ref.ko { border-color: var(--ko); background: var(--ko-fond); }
.ref.ko::after { content: " ⚠️"; font-size: .75em; }
.actions-reponse { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

.bloc-sources { margin-top: 1rem; border-top: 1px solid var(--trait); padding-top: .7rem; }
.bloc-sources > summary { cursor: pointer; font-weight: 600; width: max-content; }
.ok-texte { color: var(--ok); }
.ko-texte { color: var(--ko); }
.sources { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.source { display: flex; gap: .5rem; align-items: flex-start; padding: .35rem .55rem; border-radius: 8px; font-size: .9rem; }
.source.ko { background: var(--ko-fond); }
.source .icone { flex: none; }
.corps-source { min-width: 0; overflow-wrap: anywhere; }
.ligne-source a { text-decoration: none; font-weight: 600; }
.source .motif { color: var(--ko); font-size: .85rem; }
.source .citation { color: var(--encre-douce); font-style: italic; font-size: .85rem; }
.copier-ref { font-size: .8rem !important; }

.tour-precedent { background: var(--carte); border: 1px solid var(--trait); border-radius: 10px; padding: .55rem .9rem; }
.tour-precedent summary { cursor: pointer; color: var(--encre-douce); }
.tour-precedent .markdown { margin-top: .5rem; font-size: .94rem; }

/* Indemnités de licenciement */
.barre-reponse { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.attente { color: var(--encre-douce); margin: .4rem 0; }
.a-verifier { margin: 0 0 .8rem; padding: .55rem .8rem; background: var(--sable); border-radius: 8px; font-size: .92rem; }
.a-verifier .contradiction { display: block; margin-top: .3rem; color: #6b4a10; font-size: .88rem; }
.a-verifier .relancer { margin-right: .6rem; }
.fiche-grille { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem 1rem; }
.champ { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.champ.large { grid-column: span 3; }
.champ.lecture { grid-column: 1 / -1; flex-direction: row; gap: .6rem; align-items: baseline; flex-wrap: wrap; font-size: .93rem; }
.champ label, .champ .libelle { font-size: .82rem; font-weight: 600; color: var(--encre-douce); display: flex; align-items: center; gap: .25rem; }
.champ input { width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid var(--trait-fort); border-radius: 8px; padding: .45rem .6rem; }
.champ.a-voir input { border-color: #e2b65c; background: #fffaf0; }
.icone-source { border: 0; border-radius: 999px; width: 1.25rem; height: 1.25rem; font-size: .75rem; line-height: 1.25rem; padding: 0; font-weight: 700; }
.icone-source.ok { background: var(--ok-fond); color: var(--ok); }
.icone-source.ko { background: #fbe7c4; color: #8a5a00; }
.champ .extrait { margin: .15rem 0 0; font-size: .8rem; color: var(--encre-douce); font-style: italic; overflow-wrap: anywhere; }
.ligne-calcul { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.segments { display: inline-flex; border: 1px solid var(--trait-fort); border-radius: 9px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.segments label { cursor: pointer; margin: 0; }
.segments input { position: absolute; opacity: 0; pointer-events: none; }
.segments span { display: block; padding: .45rem .8rem; font-size: .88rem; color: var(--encre-douce); }
.segments label + label span { border-left: 1px solid var(--trait-fort); }
.segments input:checked + span { background: var(--accent); color: #fff; }
.segments input:focus-visible + span { outline: 3px solid rgba(31, 95, 91, .35); outline-offset: -3px; }
#ph-resultats { margin-top: 1.2rem; border-top: 1px solid var(--trait); padding-top: 1rem; }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem; }
.tuile { background: var(--accent-pale); border-radius: 10px; padding: .7rem .9rem; display: flex; flex-direction: column; gap: .1rem; }
.tuile.ko { background: var(--ko-fond); }
.titre-tuile { font-size: .8rem; font-weight: 600; color: var(--encre-douce); text-transform: uppercase; letter-spacing: .03em; }
.chiffre { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.tuile:nth-child(3) .chiffre { white-space: normal; }
.tuile.ko .chiffre { color: var(--ko); }
.sous { font-size: .8rem; color: var(--encre-douce); }
.detail-calculs { margin-top: 1rem; }
.detail-calculs > summary { cursor: pointer; color: var(--accent); width: max-content; }
.cartes-calcul { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .7rem; margin-top: .6rem; }
.carte-calcul { border: 1px solid var(--trait); border-radius: 10px; padding: .7rem .9rem; background: #fff; font-size: .88rem; }
.carte-calcul h3 { font-size: .95rem; margin: 0 0 .3rem; }
.carte-calcul ol { margin: 0; padding-left: 1.15rem; }
.alerte-douce { margin: .45rem 0 0; padding: .35rem .55rem; background: var(--sable); border-radius: 6px; font-size: .82rem; color: #6b4a10; }
.sources-calcul { margin: .5rem 0 0; font-size: .8rem; }

.pied-page { text-align: center; color: var(--encre-douce); font-size: .78rem; padding: 1rem 1.25rem 1.5rem; }

/* Connexion */
.page-connexion { align-items: center; justify-content: center; padding: 1rem; }
.carte-connexion { width: 100%; max-width: 380px; background: var(--carte); border: 1px solid var(--trait); border-radius: 16px; padding: 1.75rem; }
.carte-connexion .marque { margin-bottom: 1.2rem; }
.carte-connexion form { display: flex; flex-direction: column; }
.carte-connexion label { font-weight: 600; margin-bottom: .3rem; font-size: .92rem; }
.carte-connexion input { width: 100%; font: inherit; border: 1px solid var(--trait-fort); border-radius: 9px; padding: .6rem .75rem; margin-bottom: 1rem; background: #fff; }
.carte-connexion .erreur { margin-bottom: 1rem; }
.carte-connexion .pied { margin: 1.2rem 0 0; color: var(--encre-douce); font-size: .8rem; text-align: center; }
.etiquette { font-family: var(--sans); font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ocre); border: 1px solid var(--ocre); border-radius: 999px; padding: .02rem .45rem; }
.bandeau-pilote { margin: 0 0 1rem; padding: .5rem .7rem; background: var(--sable); border-radius: 8px; color: #6b4a10; font-size: .86rem; }

@media (max-width: 640px) {
  .entete { padding: .6rem 16px; }
  .page { padding: .3rem 16px 1.5rem; }
  .fiche-grille { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .champ.large { grid-column: 1 / -1; }
  .barre-saisie { gap: .6rem; }
  .ligne-calcul button[type="submit"] { width: 100%; }
  .actions-attente { margin-left: 0; }
}
@media print {
  .entete, .saisie, .suggestions, .exemples, .attente, .actions-reponse, .pied-page, .fermer-conv, .suite-conv, #ph-fermer, .ligne-calcul, .copier-ref { display: none !important; }
  body { background: #fff; }
  .carte { border: 0; padding: 0; }
  .bloc-sources { display: block; }
}
