/* Traitement de texte de ressources.online : page d'accueil de l'outil, puis éditeur en plein écran.
   Les couleurs de l'habillage suivent la palette du site ; la feuille, elle, reste noire sur blanc comme le document exporté. */

/* ---------- accueil de l'outil ---------- */
.bloc {
  margin: 28px auto 0; max-width: 1100px; background: var(--surface); border: 1px solid var(--ligne); border-radius: 22px;
  box-shadow: var(--ombre); padding: 22px 20px;
}
.depart { border: 2px dashed var(--ligne); border-radius: 18px; padding: 30px 18px 26px; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; }
.depart.survol { border-color: var(--orange); background: color-mix(in srgb, var(--orange) 8%, var(--surface-2)); }
.depart svg.grand { color: var(--orange); margin-bottom: 10px; }
.depart .choix { display: flex; flex-wrap: wrap; gap: 10px 12px; justify-content: center; align-items: center; }
.depart p { margin: 14px 0 0; color: var(--doux); font-size: .92rem; }
.reprise {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 16px; margin-bottom: 16px; border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--orange) 45%, var(--ligne)); background: color-mix(in srgb, var(--orange) 7%, var(--surface));
}
.reprise svg { color: var(--orange); flex: none; }
.reprise div { flex: 1 1 220px; min-width: 0; }
.reprise strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reprise small { color: var(--doux); }
.reprise .btn { min-height: 42px; padding: 0 20px; }
.btn-lien { font: inherit; font-size: .9rem; background: none; border: 0; color: var(--doux); text-decoration: underline; cursor: pointer; padding: 8px 4px; }
.prive { display: flex; gap: 10px; align-items: flex-start; margin: 18px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: .9rem; color: var(--doux); }
.prive svg { flex: none; color: var(--vert); margin-top: 2px; }
.atouts { list-style: none; max-width: 1100px; margin: 34px auto 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.atouts li { background: var(--surface); border: 1px solid var(--ligne); border-radius: 18px; padding: 18px; }
.atouts svg { color: var(--orange); }
.atouts strong { display: block; margin: 8px 0 4px; }
.atouts span { color: var(--doux); font-size: .92rem; line-height: 1.5; display: block; }
/* modèles : la première page de chacun, en petit */
.modeles { max-width: 1100px; margin: 34px auto 0; }
.modeles h2 { margin: 0 0 6px; }
.modeles > p { margin: 0 0 16px; color: var(--doux); }
.modeles-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.modele { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; overflow-wrap: anywhere; hyphens: auto; gap: 8px; align-content: start; text-align: left; padding: 10px; border-radius: 16px; border: 1px solid var(--ligne); background: var(--surface); color: var(--texte); cursor: pointer; font: inherit; transition: border-color .15s, transform .2s, box-shadow .2s; }
.modele:hover, .modele:focus-visible { border-color: var(--orange); transform: translateY(-3px); box-shadow: var(--ombre); }
.modele-vue { position: relative; width: 100%; aspect-ratio: 210 / 297; overflow: hidden; border-radius: 8px; border: 1px solid var(--ligne); background: #fff; pointer-events: none; }
.modele-vue .tx-feuille { position: absolute; left: 0; top: 0; width: 595.28pt; height: 841.89pt; min-height: 0; max-width: none; margin: 0; transform-origin: 0 0; box-shadow: none; overflow: hidden; -webkit-user-select: none; user-select: none; }
.modele strong { font-size: .95rem; line-height: 1.25; }
.modele small { color: var(--doux); font-size: .8rem; line-height: 1.35; }
.modele em { font-style: normal; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--orange); }
.modele-oter { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--ligne); background: var(--surface); color: var(--doux); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.modele-oter:hover { border-color: var(--rouge); color: var(--rouge); }
.touches { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; list-style: none; padding: 0; margin: 0 0 14px; font-size: .92rem; }
.touches kbd { font: inherit; font-size: .82em; padding: 1px 6px; border: 1px solid var(--ligne); border-radius: 6px; background: var(--surface-2); white-space: nowrap; }

/* ---------- éditeur ---------- */
html.tx-ouvert, html.tx-ouvert body { overflow: hidden; }
html.tx-ouvert .toast { z-index: 7100; }
.tx {
  --bleu: #2563eb;
  position: fixed; inset: 0; z-index: 6000; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--primary) 8%, #e8eaee); color: var(--texte); font-size: 14px; line-height: 1.4; -webkit-tap-highlight-color: transparent;
}
.tx button, .tx select, .tx input { font-family: inherit; }
.tx :focus-visible { outline: 2px solid var(--bleu); outline-offset: 1px; }
.tx-barre { display: flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 52px; background: var(--surface); border-bottom: 1px solid var(--ligne); }
.tx-bt {
  width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--texte); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0;
}
.tx-bt:hover { background: var(--surface-2); }
.tx-bt[aria-pressed="true"] { background: color-mix(in srgb, var(--orange) 22%, transparent); }
#tx-nom {
  font: inherit; font-weight: 700; font-size: 15px; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; background: transparent;
  color: var(--texte); flex: 0 1 30ch; width: 30ch; min-width: 70px; text-overflow: ellipsis;
}
#tx-nom:hover { border-color: var(--ligne); }
#tx-nom:focus { border-color: var(--orange); outline: none; }
.tx-etat { display: inline-flex; align-items: center; gap: 5px; color: var(--doux); font-size: 12px; white-space: nowrap; }
.tx-etat[data-etat="ok"] svg { color: var(--vert); }
.tx-etat[data-etat="ko"] { color: var(--rouge); }
.tx-souple { flex: 1; min-width: 4px; }
.tx .tx-action { min-height: 40px; padding: 0 16px; font-size: 14px; flex: none; }
.tx .btn-secondaire.tx-action { background: var(--surface); }
/* « Enregistrer » dans le fichier du disque (Chrome, Edge) ; la pastille : des changements pas encore écrits dans le fichier */
.tx .tx-action[hidden] { display: none; }
.tx .tx-disque { position: relative; }
.tx .tx-disque.a-faire::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.tx-outils {
  display: flex; align-items: center; gap: 2px; padding: 5px 10px; background: var(--surface); border-bottom: 1px solid var(--ligne);
  overflow-x: auto; scrollbar-width: thin; flex: none;
}
.tx-sep { width: 1px; height: 22px; background: var(--ligne); margin: 0 5px; flex: none; }
.tx-outils select {
  height: 34px; border: 1px solid var(--ligne); border-radius: 9px; background: var(--surface); color: var(--texte); font-size: 13px; padding: 0 6px; flex: none; cursor: pointer; max-width: 150px;
}
.tx-zone { flex: 1; min-height: 0; overflow: auto; padding: 22px 12px 90px; overscroll-behavior: contain; }
.tx-pied { display: flex; gap: 18px; padding: 5px 14px; border-top: 1px solid var(--ligne); background: var(--surface); color: var(--doux); font-size: 11.5px; white-space: nowrap; overflow: hidden; }

/* la feuille : format, marges et police du document (A4, 2,5 cm, Arial 11 par défaut ; ceux du fichier ouvert sinon) */
.tx-feuille {
  position: relative; box-sizing: border-box; width: var(--pl, 21cm); max-width: 100%; min-height: var(--ph, 29.7cm); margin: 0 auto;
  padding: var(--mhe, var(--mh, 2.5cm)) var(--md, 2.5cm) var(--mbe, var(--mb, 2.5cm)) var(--mg, 2.5cm);
  background: #fff; color: #111827; box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 8px 24px rgba(0, 0, 0, .10); outline: none;
  font: 11pt/1.32 Arial, Helvetica, sans-serif; overflow-wrap: break-word; -webkit-user-select: text; user-select: text; cursor: text;
  tab-size: 35.4pt; -moz-tab-size: 35.4pt;
}
.tx-feuille.vide::before { content: var(--vide, ""); position: absolute; left: var(--mg, 2.5cm); top: var(--mhe, var(--mh, 2.5cm)); color: #9ca3af; pointer-events: none; }
/* en-tête et pied de page : dans les marges, comme sur la page imprimée */
.tx-entete, .tx-piedp { position: absolute; left: var(--mg, 2.5cm); right: var(--md, 2.5cm); outline: 1px dashed transparent; outline-offset: 3px; transition: outline-color .15s; }
.tx-entete { top: var(--eh, 1.25cm); }
.tx-piedp { bottom: var(--ep, 1.25cm); }
.tx-entete:hover, .tx-piedp:hover, .tx-entete:focus-within, .tx-piedp:focus-within { outline-color: #cbd5e1; }
.tx-feuille.mesure { max-width: none; }
.tx-tab { white-space: pre; text-indent: 0; }
.tx-tab.points { border-bottom: 1px dotted currentColor; }
.tx-num { display: inline-block; text-indent: 0; white-space: pre; }
.tx-var { background: rgba(100, 116, 139, .16); border-radius: 2px; }
.tx-cadre { margin: 0 0 .5em; }
.tx-feuille p { margin: 0 0 .5em; }
.tx-feuille h1 { font-size: 20pt; line-height: 1.25; margin: .7em 0 .35em; font-family: inherit; }
.tx-feuille h2 { font-size: 15pt; line-height: 1.3; margin: .8em 0 .35em; font-family: inherit; }
.tx-feuille h3 { font-size: 12.5pt; line-height: 1.3; margin: .8em 0 .3em; font-family: inherit; }
.tx-feuille > :first-child { margin-top: 0; }
.tx-feuille ul, .tx-feuille ol { margin: 0 0 .5em; padding-left: 1.7em; }
.tx-feuille li { margin: 0 0 .2em; }
.tx-feuille a { color: #1d4ed8; text-decoration: underline; cursor: text; }
.tx-feuille blockquote { margin: 0 0 0 40px; padding: 0; border: 0; }
.tx-feuille table { border-collapse: collapse; width: 100%; margin: 0 0 .6em; table-layout: fixed; }
.tx-feuille td { border: 1px solid #94a3b8; padding: .3em .5em; vertical-align: top; min-width: 30px; }
.tx-feuille img { max-width: 100%; height: auto; cursor: pointer; }
.tx-feuille img.choisie { outline: 2px solid var(--bleu); outline-offset: 2px; }
.tx-feuille hr { border: 0; border-top: 1px solid #94a3b8; margin: 1em 0; }
.tx-feuille hr.tx-saut { border-top: 2px dashed #9ca3af; margin: 1.4em calc(-1 * var(--md, 2.5cm)) 1.4em calc(-1 * var(--mg, 2.5cm)); position: relative; overflow: visible; height: 0; clear: both; }
.tx-feuille hr.tx-saut::after { content: var(--saut, ""); position: absolute; left: 50%; top: -9px; transform: translateX(-50%); background: #fff; padding: 0 10px; font: 600 10px/16px Arial, sans-serif; color: #6b7280; letter-spacing: .06em; text-transform: uppercase; }

/* volets (couleurs, lien, tableau, téléchargement, envoi) */
.tx-volet {
  position: fixed; z-index: 6100; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--ligne); box-shadow: 0 18px 44px rgba(0, 0, 0, .2);
  display: grid; gap: 8px; width: max-content; max-width: min(360px, calc(100vw - 16px));
}
.tx-volet h2 { font: 700 11.5px/1.2 var(--font-body, inherit); text-transform: uppercase; letter-spacing: .06em; color: var(--doux); margin: 0 0 2px; }
.tx-volet p { margin: 0; font-size: 12.5px; color: var(--doux); }
.tx-palette { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; }
.tx-pastille { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); cursor: pointer; padding: 0; box-shadow: 0 0 0 1px var(--ligne); }
.tx-pastille.aucun { background: linear-gradient(135deg, #fff 45%, #dc2626 45%, #dc2626 55%, #fff 55%); }
.tx-champ { display: grid; gap: 4px; font-size: 12px; color: var(--doux); font-weight: 600; }
.tx-champ input[type="text"], .tx-champ input[type="url"], .tx-champ input[type="email"], .tx-champ input[type="number"] {
  font-size: 14px; font-weight: 400; color: var(--texte); background: var(--surface); border: 1px solid var(--ligne); border-radius: 9px; height: 36px; padding: 0 9px; min-width: 0; width: 100%;
}
.tx-champ input:focus { outline: none; border-color: var(--orange); }
.tx-deux { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tx-rang { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.tx-volet .btn { min-height: 38px; padding: 0 16px; font-size: 13.5px; }
.tx-choix {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--ligne);
  background: var(--surface); color: var(--texte); cursor: pointer; font-size: 13.5px;
}
.tx-choix:hover { border-color: var(--orange); }
.tx-choix svg { flex: none; color: var(--orange); }
.tx-choix small { display: block; color: var(--doux); font-size: 12px; }
.tx-choix strong { display: block; }
.tx-choix.modele-garder { margin-top: 6px; border-style: dashed; }
.tx-formats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tx-formats label { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border: 1px solid var(--ligne); border-radius: 10px; font-size: 13px; color: var(--texte); cursor: pointer; }
.tx-formats label:has(input:checked) { border-color: var(--orange); background: color-mix(in srgb, var(--orange) 9%, transparent); }
.tx-formats input { accent-color: var(--orange); }
.tx-contexte {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 6050; display: flex; gap: 4px; align-items: center; padding: 6px 8px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--ligne); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: calc(100vw - 16px); overflow-x: auto;
}
.tx-contexte > div { display: flex; gap: 4px; align-items: center; }
.tx-petit { font-size: 12.5px; font-weight: 600; border: 1px solid var(--ligne); background: var(--surface); color: var(--texte); border-radius: 9px; padding: 6px 9px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 5px; align-items: center; }
.tx-petit:hover { border-color: var(--orange); }
.tx-petit.danger:hover { border-color: var(--rouge); color: var(--rouge); }

@media (min-width: 861px) {
  .tx-outils { flex-wrap: wrap; row-gap: 4px; overflow-x: visible; }
}
@media (max-width: 860px) {
  .tx-zone { padding: 10px 6px 90px; }
  /* sur petit écran la feuille prend la largeur disponible ; « mesure » lui rend sa vraie mise en page le temps d'un export */
  .tx-zone .tx-feuille:not(.mesure) { --zones: libres; padding: 22px 18px; min-height: 70vh; }
  .tx-zone .tx-feuille:not(.mesure).vide::before { left: 18px; top: 22px; }
  .tx-zone .tx-feuille:not(.mesure) hr.tx-saut { margin: 1.4em -18px; }
  .tx-zone .tx-feuille:not(.mesure) > .tx-entete, .tx-zone .tx-feuille:not(.mesure) > .tx-piedp { position: static; margin: 0 0 14px; }
  .tx-zone .tx-feuille:not(.mesure) > .tx-piedp { margin: 14px 0 0; }
  .tx-etat span, .tx-pied span:last-child { display: none; }
  .tx .tx-action { padding: 0 12px; }
  .tx .tx-action span { display: none; }
  #tx-nom { font-size: 14px; }
}
@media print { .tx { display: none !important; } }
