/* =====================================================================
   The World's Guestbook — feuille de style unique
   Utilisée par : index.html et legal.html (site des backers, classe « site » sur <body>),
   admin.html et book.html (outils de Thomas, style clair par défaut).
   Direction : « le livre ouvert ». Le fond est la reliure toilée bleu nuit,
   chaque écran est une page de papier crème, le texte est à l'encre bleu-noir,
   et tout est en Literata, la police du livre.
   ⚠ La section « PAGES DU LIVRE » en bas sert au calcul des pages (layout.js) :
     ne pas modifier les tailles, marges ou polices, sinon l'aperçu et le PDF ne correspondent plus.
   ===================================================================== */

/* ---------- 1. Couleurs, polices, tailles ---------- */
/* Police du livre : Literata « figée » (fichiers LiterataBook-*.woff2 à côté de cette page, licence Literata-OFL.txt).
   Avec la Literata « variable » de Google Fonts, Chrome intégrait la police au PDF en « Type 3 », un format
   que les imprimeurs refusent ou impriment mal. Ces versions figées reprennent exactement les réglages
   de Literata à 10 pt (texte) et 17 pt (titres) : les pages se coupent au même endroit qu'avant. */
@font-face { font-family: "Literata Book"; src: url("LiterataBook-Regular.woff2?v=1") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Literata Book"; src: url("LiterataBook-Italic.woff2?v=1") format("woff2"); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: "Literata Book"; src: url("LiterataBook-SemiBold.woff2?v=1") format("woff2"); font-weight: 600 700; font-style: normal; font-display: block; }

:root {
  /* La reliure (fond du site) */
  --cloth: #1F3A2E;           /* vert bouteille (choisi le 29 octobre 2026) */
  --cloth-2: #183025;          /* en-tête, barres */
  --on-cloth: #EFE8D8;         /* texte crème sur la reliure */
  --on-cloth-soft: #A7B9AE;
  --gold: #C9A24A;             /* or : seulement le nom dans l'en-tête */
  --proof-on-cloth: #F2A79E;   /* rouge de correcteur, lisible sur la reliure */

  /* Le papier et l'encre */
  --paper: #F6F0E3;            /* papier crème, comme l'intérieur du livre Lulu */
  --paper-hi: #FBF8F0;         /* champs de saisie */
  --paper-edge: #E2D8C3;       /* filets sur le papier */
  --ink: #18202E;              /* encre bleu-noir */
  --graphite: #615D54;         /* texte secondaire */
  --accent: #2F6A4F;           /* vert d'action : la seule couleur des boutons et liens */
  --accent-hover: #265A42;
  --proof: #A3262B;            /* rouge de correcteur : erreurs, texte trop long */

  /* Noms utilisés par admin.html et book.html (ne pas supprimer) */
  --bg: #F6F0E3;
  --surface: #FFFDF8;
  --soft: #EFE8D8;
  --ink-2: #2E3440;
  --ink-soft: #615D54;
  --line: #E2D8C3;
  --line-strong: #C9BDA4;
  --accent-ink: #FBF8F0;
  --accent-soft: #E2EEE6;
  --accent-text: #2F6A4F;
  --ok: #2F6A4F;
  --ok-soft: #E2EEE6;
  --warn: #8A4B0F;
  --warn-soft: #F7E9D2;
  --danger: #A3262B;
  --radius: 4px;

  --header-h: 56px;
  --bar-h: 76px;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;   /* outils de Thomas seulement */
  --book: "Literata", Georgia, "Times New Roman", serif;
  --print: "Literata Book", "Literata", Georgia, serif; /* texte du livre (aperçu + PDF) */
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; } /* l'iPhone en paysage ne grossit pas le texte du livre */
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--ui); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1 { font-weight: 700; font-size: 2rem; line-height: 1.15; margin: 0 0 .5rem; }
h2 { font-weight: 700; font-size: 1.35rem; margin: 0 0 1rem; }
.lead { color: var(--ink-2); font-size: 1.05rem; margin: 0 0 1.5rem; }
.hint { color: var(--graphite); font-size: .9rem; margin: 1rem 0 .5rem; }
.muted { color: var(--graphite); }
.center { text-align: center; }
.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; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Le site des backers : la reliure et la police du livre */
body.site {
  background: var(--cloth); color: var(--ink);
  font-family: var(--book); font-size: 17px; line-height: 1.55;
  font-optical-sizing: auto;
  padding-top: var(--header-h);
}
.site h1, .site h2, .site h3 { font-family: var(--book); font-weight: 600; letter-spacing: -.005em; }
.site .lead { color: var(--ink); font-size: 1.12rem; line-height: 1.55; }
.site p, .site li { font-variant-numeric: oldstyle-nums; }

/* ---------- 3. En-tête : le dos du livre ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: var(--header-h);
  background: var(--cloth-2); color: var(--on-cloth);
  border-bottom: 1px solid rgba(0,0,0,.25);
}
.topbar-row {
  height: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { margin-right: auto; font-weight: 600; font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--gold); }
.head-right { display: flex; align-items: center; gap: 18px; }
.closes { font-size: .95rem; color: var(--on-cloth-soft); white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.closes.soon { color: var(--on-cloth); }
.closes .when-short { display: none; }
.how-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 4px;
  border: 0; background: none; color: var(--on-cloth);
  font: inherit; font-size: .95rem; cursor: pointer;
  border-bottom: 1px solid transparent;
}
.how-btn:hover .how-btn-label { text-decoration: underline; text-underline-offset: 4px; }
.how-icon { display: none; }
.topbar :focus-visible, .bottombar :focus-visible, .actionbar :focus-visible { outline-color: var(--on-cloth); }

.demo-banner {
  max-width: 1040px; margin: 16px auto 0; padding: 8px 14px; text-align: center;
  color: var(--on-cloth-soft); font-size: .88rem; font-style: italic;
  border: 1px dashed rgba(239,232,216,.3); border-radius: var(--radius);
}
.demo-banner b { color: var(--on-cloth); font-style: normal; letter-spacing: .08em; }

/* ---------- 4. Pied de page ---------- */
.bottombar {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px 6px;
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
}
body:not(.site) .bottombar { display: none; }
.foot-link {
  background: none; border: 0; font: inherit; font-size: .9rem;
  color: var(--on-cloth-soft); padding: 8px 10px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.foot-link:hover { color: var(--on-cloth); text-decoration: underline; text-underline-offset: 4px; }

/* ---------- 5. Écrans et feuilles de papier ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 36px 16px 8px; }
.center-box { display: flex; justify-content: center; padding: 120px 0; }
.loading-sheet { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
.loading-sheet .spinner { border-color: var(--paper-edge); border-top-color: var(--graphite); }
.spinner { width: 28px; height: 28px; border: 2px solid rgba(239,232,216,.25); border-top-color: var(--on-cloth); border-radius: 50%; animation: spin .9s linear infinite; }
body:not(.site) .spinner { border-color: var(--line); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Une feuille posée sur la reliure */
.sheet, .spread, .slip {
  background: var(--paper); color: var(--ink); border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0,0,0,.25), 0 24px 48px -18px rgba(5,10,25,.55);
}
.sheet { max-width: 760px; margin: 0 auto; padding: 52px 60px 44px; }

.first-note { margin: 0 0 28px; padding: 0 0 22px; border-bottom: 1px solid var(--paper-edge); font-style: italic; color: var(--graphite); font-size: 1.02rem; }
.notice {
  margin: 0 0 20px; padding: 10px 14px; border-left: 3px solid var(--accent);
  background: rgba(47,106,79,.07); font-size: .95rem;
}

/* ---------- 6. Formulaires ---------- */
label { display: block; font-size: .9rem; font-weight: 600; margin: 0 0 6px; }
input[type=email], input[type=text] {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
  padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-hi);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #9C9585; }
/* Menu des pays : même allure que les champs, flèche dessinée */
select {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); cursor: pointer;
  padding: 12px 40px 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background-color: var(--paper-hi); outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23615D54' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,106,79,.16); }
select.is-blank { color: #9C9585; }
/* « Choose a country » : texte posé sur le menu tant que rien n'est choisi (pas une option de la liste) */
.select-wrap { position: relative; }
.select-ph { display: none; position: absolute; left: 15px; top: 0; bottom: 0; align-items: center; pointer-events: none; color: #9C9585; font-size: 1rem; }
select.is-unset + .select-ph { display: flex; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,106,79,.16); }
.code-input { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; font-variant-numeric: lining-nums tabular-nums; }
.form-error { color: var(--proof); font-size: .92rem; margin: 8px 0 0; }
form .btn { margin-top: 16px; }
.row-links { display: flex; justify-content: space-between; gap: 12px; }
.link {
  background: none; border: 0; font: inherit; font-size: .95rem; color: var(--accent); cursor: pointer; padding: 4px 0;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: rgba(47,106,79,.35);
}
.link:hover { text-decoration-color: currentColor; }
.link:disabled { color: var(--graphite); cursor: default; text-decoration: none; }

/* ---------- 7. Boutons ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 1rem; border-radius: var(--radius);
  padding: 13px 22px; cursor: pointer; border: 1px solid transparent; line-height: 1.2;
  transition: background .15s, border-color .15s, opacity .15s; text-decoration: none; text-align: center;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: rgba(24,32,46,.05); }
.btn-block { width: 100%; display: block; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.card-title { font-weight: 700; font-size: 1rem; margin-bottom: 12px; }

/* ---------- 8. Connexion : le livre ouvert ---------- */
.spread {
  position: relative; max-width: 1060px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr;
  min-height: min(680px, calc(100vh - var(--header-h) - 150px));
}
/* le creux entre les deux pages */
.spread::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 90px; transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(70,52,20,0) 0%, rgba(70,52,20,.07) 38%, rgba(70,52,20,.2) 50%, rgba(70,52,20,.07) 62%, rgba(70,52,20,0) 100%);
  pointer-events: none;
}
.leaf { position: relative; padding: 64px 64px 80px; display: flex; flex-direction: column; }
.leaf-r { justify-content: center; }
.folio { position: absolute; left: 0; right: 0; bottom: 30px; text-align: center; font-size: .85rem; color: var(--graphite); }

.hero-title { font-size: 3rem; line-height: 1.06; letter-spacing: -.02em; margin: 0 0 22px; font-weight: 600; text-wrap: balance; }
.hero-head .lead { max-width: 30em; margin: 0; }

/* Le sommaire, avec une ligne pour vous */
.toc { margin-top: auto; padding-top: 44px; }
.toc-title { font-size: 1.15rem; margin: 0 0 14px; font-weight: 600; }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; color: var(--graphite); font-style: italic; font-size: 1.02rem; }
.toc-list .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.toc-list .dots { flex: 1; min-width: 24px; border-bottom: 2px dotted rgba(97,93,84,.4); transform: translateY(-5px); }
.toc-list .n { flex: none; font-style: normal; font-variant-numeric: oldstyle-nums tabular-nums; min-width: 2ch; text-align: right; }
.toc-list li.you { color: var(--ink); font-style: normal; font-weight: 600; }
.toc-list li.you .dots { border-bottom-color: rgba(24,32,46,.45); }
.caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 3px; vertical-align: -.16em;
  background: var(--accent); animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.toc-note { margin: 14px 0 0; font-size: .92rem; color: var(--graphite); }

.auth-card { max-width: 380px; width: 100%; margin: 0 auto; }
.card-heading { font-size: 1.75rem; margin: 0 0 6px; }
.card-sub { color: var(--graphite); margin: 0 0 26px; }
.auth-card input[type=email], .auth-card input[type=text] { height: 52px; font-size: 1.05rem; }
.auth-card .btn { height: 52px; padding-top: 0; padding-bottom: 0; }
.auth-card .hint { margin-top: 18px; }
.mini-steps { list-style: none; margin: 34px 0 18px; padding: 22px 0 0; border-top: 1px solid var(--paper-edge); display: flex; flex-direction: column; gap: 10px; }
.mini-steps li { display: flex; align-items: baseline; gap: 14px; font-size: .97rem; color: var(--ink); }
.step-num { flex: none; width: 1.2em; font-weight: 600; color: var(--accent); font-variant-numeric: oldstyle-nums; text-align: right; }

/* ---------- 9. Écriture : une page du livre ---------- */
#screen-write { padding-bottom: calc(var(--bar-h) + 24px); }
.title-input {
  display: block; width: 100%; resize: none; overflow: hidden;
  font-family: var(--book); font-size: 2.1rem; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; color: var(--ink);
  border: 0; background: transparent; padding: 0; margin: 0; box-shadow: none; border-radius: 0;
}
.title-input:focus { box-shadow: none; }
.title-input::placeholder { color: #A39C8B; }
.rules-line { margin: 10px 0 0; font-size: .95rem; color: var(--graphite); }
.rules-line .link { font-size: inherit; }
.rules-line.come-back { margin-top: 2px; }

.editor-wrap { margin-top: 26px; border-top: 1px solid var(--paper-edge); }
.toolbar {
  display: flex; align-items: center; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--paper-edge);
  position: sticky; top: var(--header-h); z-index: 3; background: var(--paper);
}
.mini-gauge { display: none; margin-left: auto; font-size: .88rem; color: var(--graphite); font-variant-numeric: lining-nums; }
.mini-gauge.over { color: var(--proof); font-weight: 600; }
body.typing .mini-gauge + .save-state { margin-left: 12px; }
.tool { width: 36px; height: 34px; border-radius: var(--radius); border: 0; background: none; cursor: pointer; font-family: var(--book); font-size: 1.05rem; color: var(--ink); }
.tool:hover, .tool.active { background: rgba(47,106,79,.1); color: var(--accent); }
.idea-btn {
  background: none; border: 0; padding: 6px 4px; cursor: pointer;
  font: inherit; font-size: .92rem; color: var(--accent);
  text-decoration: underline; text-decoration-color: rgba(47,106,79,.35); text-underline-offset: 3px;
}
.idea-btn:hover { text-decoration-color: currentColor; }
.save-state { margin-left: auto; font-size: .88rem; color: var(--graphite); font-style: italic; }
.save-state.ok { color: var(--graphite); }
.save-state.err { color: var(--proof); font-style: normal; }
/* « Done » : sur téléphone, ferme le clavier pour faire revenir la barre « See my pages » */
.tool-done { display: none; margin-left: 12px; height: 34px; padding: 0 14px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--paper-hi); color: var(--accent); font-family: var(--book); font-size: .95rem; font-weight: 600; cursor: pointer; }
.editor {
  position: relative; min-height: 46vh; padding: 22px 0 26px; outline: none;
  font-family: var(--book); font-size: 1.17rem; line-height: 1.75; overflow-wrap: break-word;
  font-variant-numeric: oldstyle-nums;
}
.editor p { margin: 0 0 .85em; }
/* L'amorce contre la page blanche : visible tant que la page est vide.
   Le texte laisse passer les clics vers la page ; seul le bouton « Another idea » est cliquable. */
.editor-area { position: relative; }
.idea-box { position: absolute; top: 22px; left: 0; right: 0; pointer-events: none; }
.idea-text { margin: 0; font-size: 1.17rem; line-height: 1.75; color: #9C9585; font-style: italic; }
.idea-box .idea-btn { pointer-events: auto; margin: 10px 0 0; padding: 4px 0; }

/* La vérification, comme une note dans la marge */
.ai-box { margin-top: 8px; padding: 2px 0 2px 16px; border-left: 2px solid var(--paper-edge); font-size: .93rem; color: var(--graphite); }
.ai-box[data-state=idle] { display: none; }
.ai-head { display: flex; align-items: baseline; gap: 10px; }
.ai-dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; transform: translateY(-1px); }
.ai-box[data-state=checking] .ai-dot { display: block; animation: pulse 1s infinite; }
.ai-box[data-state=ok] { border-left-color: var(--accent); }
.ai-box[data-state=ok] .ai-dot { display: block; }
.ai-box[data-state=warn] { border-left-color: var(--proof); color: var(--ink); }
.ai-box[data-state=warn] #ai-status { font-weight: 600; }
@keyframes pulse { 50% { opacity: .3; } }
.ai-list { margin: 8px 0 0; padding-left: 18px; }
.ai-list:empty { display: none; }
.ai-list li { margin-top: 6px; }
.ai-list .quote { font-style: italic; color: var(--graphite); }

/* La barre du bas : trois petites pages qui se remplissent, et l'action */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--cloth-2); color: var(--on-cloth);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(0,0,0,.3);
  box-shadow: 0 -12px 30px -10px rgba(0,0,0,.35);
}
.actionbar-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 16px; min-height: 52px; }
.actionbar .btn-primary { background: var(--paper); color: var(--ink); }
.actionbar .btn-primary:hover:not(:disabled) { background: #FFFFFF; }
.actionbar .btn-ghost { color: var(--on-cloth); border-color: rgba(239,232,216,.55); }
.actionbar .btn-ghost:hover:not(:disabled) { background: rgba(239,232,216,.08); }
.actionbar .btn { height: 48px; padding-top: 0; padding-bottom: 0; }
#btn-preview { flex: none; min-width: 180px; }

.gauge { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.pgs { display: flex; gap: 5px; flex: none; }
.pg { display: block; width: 15px; height: 22px; border: 1.5px solid var(--on-cloth-soft); border-radius: 1px; position: relative; overflow: hidden; }
.pg::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--fill, 0%); background: var(--on-cloth); transition: height .3s ease; }
.gauge-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
#gauge-label { font-weight: 600; font-variant-numeric: lining-nums; }
.gauge-sub { font-size: .86rem; color: var(--on-cloth-soft); }
.gauge-sub:empty { display: none; }
.gauge-fix {
  align-self: flex-start; background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: .86rem; color: var(--proof-on-cloth);
  text-decoration: underline; text-underline-offset: 3px;
}
.gauge.over .pg { border-color: var(--proof-on-cloth); }
.gauge.over .pg::after { background: var(--proof-on-cloth); }
.gauge.over #gauge-label, .gauge.over .gauge-sub { color: var(--proof-on-cloth); }

/* ---------- 10. Aperçu : les épreuves posées sur la table ---------- */
#screen-preview { padding-bottom: calc(var(--bar-h) + 110px); }
.preview-col { max-width: 560px; margin: 0 auto; }
.screen-head { color: var(--on-cloth); margin: 4px 0 24px; }
.screen-head h1 { font-size: 2.3rem; margin-bottom: 8px; }
.screen-head .lead { color: var(--on-cloth-soft); margin: 0; }
.slip { padding: 22px 24px; }
.slip-title { font-size: 1.12rem; margin: 0 0 14px; }
.signature { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sig-title { grid-column: 1 / -1; }
.two-up .preview-col { max-width: 1040px; }
.two-up .signature { grid-template-columns: 2fr 1fr 1fr; }
.two-up .sig-title { grid-column: auto; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 26px; margin: 28px 0; }
/* Sur grand écran, les pages s'ouvrent deux par deux, comme le livre */
.pages.two-up { display: grid; grid-template-columns: repeat(2, auto); justify-content: center; column-gap: 0; row-gap: 30px; }
.pages.two-up .page-frame:nth-child(odd)::after, .pages.two-up .page-frame:nth-child(even)::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 46px; pointer-events: none;
}
.pages.two-up .page-frame:nth-child(odd)::after { right: 0; background: linear-gradient(90deg, rgba(70,52,20,0), rgba(70,52,20,.16)); }
.pages.two-up .page-frame:nth-child(even)::after { left: 0; background: linear-gradient(270deg, rgba(70,52,20,0), rgba(70,52,20,.16)); }
.consent { display: flex; gap: 12px; align-items: flex-start; font-size: .95rem; line-height: 1.4; cursor: pointer; margin: 0; font-weight: 400; color: var(--on-cloth); }
/* Le lien « terms » : sans cette règle, il sortait en bleu par défaut, presque illisible sur la barre verte */
.consent a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.consent input {
  /* Case dessinée à la main : Safari rendait la case cochée en gris. Vide = contour crème ; cochée = crème avec coche bleu nuit, comme le bouton « Send my story ». */
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; margin: 1px 0 0; flex: none; cursor: pointer;
  border: 1.5px solid var(--on-cloth); border-radius: 4px; background: transparent;
  transition: background-color .15s, border-color .15s;
}
.consent input:checked {
  border-color: var(--paper);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3.2L15 7' fill='none' stroke='%231F3A2E' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.consent input:focus-visible { outline: 2px solid var(--on-cloth); outline-offset: 2px; }
.consent.attention input { border-color: var(--proof-on-cloth); }
.consent.attention { color: var(--proof-on-cloth); animation: nudge .4s ease; }
@keyframes nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.btn-primary.needs-consent { opacity: .8; }
.actionbar-preview { flex-direction: column; align-items: stretch; gap: 10px; max-width: 560px; padding-top: 2px; }
.bar-error { margin: 0; color: var(--proof-on-cloth); font-size: .92rem; text-align: center; }
.actions-row { display: flex; gap: 12px; }
.actions-row .btn { flex: 1; }
.actions-row #btn-validate { flex: 2; }

/* ---------- 11. Confirmation et fin ---------- */
.done-sheet { max-width: 640px; padding-top: 60px; }
.done-title { font-size: 2.6rem; line-height: 1.08; letter-spacing: -.02em; margin: 0 0 16px; }
.toc-done { margin: 34px 0 34px; padding: 24px 0 0; border-top: 1px solid var(--paper-edge); }
.toc-done .toc-note { font-style: italic; }
.toc-done li.you .t { white-space: normal; }
.next { margin: 0 0 32px; }
.next-title { font-size: 1.15rem; margin: 0 0 4px; }
.next-steps { margin: 0; padding: 12px 0 0; border-top: 0; }
.done-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.done-actions .btn { flex: 1 1 160px; height: 52px; padding-top: 0; padding-bottom: 0; white-space: nowrap; }
.done-actions .btn-share { flex: 1.6 1 290px; }
.btn-share { display: flex; align-items: center; justify-content: center; gap: 10px; }
.share-preview { margin-top: 26px; padding: 4px 0 4px 16px; border-left: 2px solid var(--paper-edge); }
.share-label { font-size: .9rem; color: var(--graphite); margin: 0; }
.share-card { display: block; width: 100%; max-width: 280px; height: auto; margin: 10px 0 12px; border-radius: 3px; box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.share-save { white-space: nowrap; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.share-text { font-size: 1.05rem; line-height: 1.5; margin: 6px 0 4px; font-style: italic; }
.share-preview .hint { margin: 0; font-size: .88rem; }
.follow { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--paper-edge); display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.follow p { margin: 0; }
.closed-sheet { max-width: 560px; text-align: center; }

/* ---------- 12. Fenêtres ---------- */
.dialog {
  border: 0; border-radius: 3px; padding: 32px; color: var(--ink); background: var(--paper);
  width: min(540px, calc(100vw - 24px)); max-height: 86vh;
  box-shadow: 0 30px 70px rgba(5,10,25,.45);
}
.site .dialog { font-family: var(--book); }
.dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.dialog::backdrop { background: rgba(15,22,36,.6); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dlg-head h2 { margin: 0; font-size: 1.6rem; }
.dlg-x { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.dlg-x:hover { background: rgba(24,32,46,.07); }
.steps { list-style: none; padding: 0; margin: 0 0 18px; }
.steps li { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--paper-edge); }
.steps li:last-child { border-bottom: 0; }
.steps .step-num { font-size: 1.15rem; line-height: 1.4; }
.steps b { font-size: 1.05rem; font-weight: 600; }
.steps p { margin: 4px 0 0; color: var(--graphite); font-size: .95rem; }
.rules { border-top: 1px solid var(--ink); padding: 14px 0 0; font-size: .95rem; }
.rules h3 { font-size: 1.05rem; margin: 0; }
.rules ul { margin: 6px 0 0; padding-left: 18px; }
.rules li { margin: 4px 0; }
.dialog details { border-bottom: 1px solid var(--paper-edge); }
.dialog summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 0; font-weight: 600; cursor: pointer; }
.dialog summary::-webkit-details-marker { display: none; }
.dialog summary::after { content: "+"; flex: none; width: 24px; text-align: center; font-weight: 400; font-size: 1.3rem; color: var(--accent); transition: transform .2s; }
.dialog details[open] summary::after { transform: rotate(45deg); }
.dialog details p { color: var(--graphite); margin: 0 0 16px; font-size: .97rem; }
.dialog .btn { margin-top: 20px; }
.dialog form + .btn-ghost { margin-top: 10px; }

/* ---------- 13. Notification ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--bar-h) + 24px + env(safe-area-inset-bottom));
  background: var(--paper); color: var(--ink); padding: 12px 20px; border-radius: var(--radius); text-align: center;
  font-size: .95rem; box-shadow: 0 12px 30px rgba(5,10,25,.4);
  max-width: calc(100vw - 32px);
}
body:not(.site) .toast { background: var(--ink); color: #fff; }

/* ---------- 14. Adaptation aux écrans ---------- */
@media (max-width: 900px) {
  /* Le livre se referme : une seule page, le formulaire juste après le titre */
  .spread { display: flex; flex-direction: column; min-height: 0; }
  .spread::before, .folio { display: none; }
  .leaf { display: contents; }
  .hero-head { order: 1; padding: 36px 28px 0; }
  .leaf-r .auth-card { order: 2; padding: 28px 28px 8px; max-width: none; }
  .spread .toc { order: 3; padding: 26px 28px 34px; margin: 0; }
  .hero-title { font-size: 2.3rem; margin-bottom: 14px; }
  #screen-code .hero-head, #screen-code .toc { display: none; }
  #screen-code .auth-card { padding-top: 34px; padding-bottom: 34px; }
}
@media (max-width: 640px) {
  :root { --header-h: 52px; --bar-h: 72px; }
  body.site { font-size: 16px; }
  main { padding: 16px 10px 4px; }
  .topbar-row { padding: 0 14px; gap: 10px; }
  .brand { font-size: .82rem; letter-spacing: .1em; }
  .head-right { gap: 10px; }
  .closes .when-long { display: none; }
  .closes .when-short { display: inline; }
  .how-btn-label { display: none; }
  .how-icon { display: block; }
  .how-btn { width: 36px; justify-content: center; padding: 0; }
  .demo-banner { margin: 10px 10px 0; font-size: .8rem; }
  .sheet { padding: 30px 22px 28px; }
  .hero-head { padding: 30px 22px 0; }
  .leaf-r .auth-card { padding: 24px 22px 6px; }
  .spread .toc { padding: 24px 22px 28px; }
  .hero-title { font-size: 2rem; }
  .card-heading { font-size: 1.45rem; }
  .title-input { font-size: 1.65rem; }
  .editor { font-size: 1.08rem; min-height: 50vh; }
  .actionbar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .actionbar-inner { gap: 12px; }
  #btn-preview { min-width: 0; padding: 0 18px; }
  .pg { width: 12px; height: 18px; }
  .gauge { gap: 9px; }
  .signature { grid-template-columns: 1fr; }
  .screen-head h1 { font-size: 1.8rem; }
  .done-title { font-size: 2rem; }
  .done-sheet { padding-top: 34px; }
  .dialog { padding: 24px 22px; }
  .toc-list li { font-size: .98rem; }
}
@media (max-width: 640px) {
  .tool { width: 44px; height: 42px; }
  body.typing #screen-write .actionbar { display: none; }
  body.typing .mini-gauge { display: inline; }
  body.typing .tool-done { display: inline-flex; align-items: center; }
}
@media (max-width: 380px) {
  .gauge-sub { display: none; }
}

/* =====================================================================
   15. PAGES DU LIVRE — ne pas modifier (sert au calcul des pages)
   Format Royal 156 × 234 mm (Lulu « Royal »). Marge intérieure 1" (25,4 mm), extérieure 15,6 mm.
   Largeur du texte : 156 - 25,4 - 15,6 = 115 mm. Hauteur du texte : 234 - 18 - 20 = 196 mm.
   (Seule la couleur du papier de l'aperçu a changé : crème, comme le papier du livre.)
   ===================================================================== */
.page-frame { position: relative; box-shadow: 0 1px 0 rgba(0,0,0,.25), 0 22px 44px -16px rgba(5,10,25,.55); border-radius: 2px; overflow: hidden; background: #F6F0E3; }
.page-frame .page { transform-origin: top left; position: absolute; top: 0; left: 0; }
.page { width: 156mm; height: 234mm; background: #F6F0E3; color: #000; }
.page-body { position: absolute; top: 18mm; left: 20.5mm; right: 20.5mm; height: 196mm; overflow: hidden; }
.page-num { position: absolute; bottom: 13.5mm; left: 0; right: 0; text-align: center; font-family: var(--print); font-size: 8pt; color: #777; }
/* Interlignes en points, pas en multiples : Safari (et tous les navigateurs d'iPhone) arrondit « 1.5 » au pixel
   et mettait 38 lignes par page au lieu de 37, donc l'aperçu ne coupait pas les pages comme le PDF (30 octobre).
   overflow-wrap : une adresse web ou un mot très long passe à la ligne au lieu de sortir de la page. */
.book-text { font-family: var(--print); font-size: 10pt; line-height: 15pt; text-align: justify; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.book-text p { margin: 0; text-indent: 1.3em; }
.book-text p.first, .book-text p.cont { text-indent: 0; }
.book-text p.split { text-align-last: justify; }
/* La première ligne de chaque histoire en petites capitales */
.book-text p.first .incipit { font-variant-caps: small-caps; letter-spacing: .03em; hyphens: manual; }
/* Ouverture de chaque histoire : un blanc d'environ un neuvième de page au-dessus du titre, comme dans un recueil.
   C'est un « padding » et non une marge : une marge en tête s'échappait du calcul des pages, et la dernière ligne
   de la première page débordait (corrigé le 28 octobre). */
.book-title { font-family: var(--print); font-size: 17pt; font-weight: 600; line-height: 20.4pt; margin: 0 0 2.5mm; padding-top: 22mm; text-align: left; hyphens: manual; overflow-wrap: anywhere; }
.book-byline { font-family: var(--print); font-size: 8.5pt; letter-spacing: .08em; text-transform: uppercase; color: #666; margin: 0 0 8mm; overflow-wrap: anywhere; }
#measure { position: absolute; left: -9999px; top: 0; width: 115mm; visibility: hidden; }
/* Garde-fou : le style du site ne doit jamais changer le texte du livre (chiffres, interlignage) */
.book-text, .site .book-text p, .book-text p { font-variant-numeric: normal; }
.book-byline { line-height: 12.75pt; }

/* Petits téléphones (375 px et moins) : le nom du site tient en entier dans l'en-tête */
@media (max-width: 420px) {
  .brand { font-size: .7rem; letter-spacing: .04em; }
  .topbar-row { gap: 8px; }
  .head-right { gap: 6px; }
  .closes { font-size: .88rem; }
}
@media (max-width: 350px) {
  .brand { font-size: .62rem; letter-spacing: .03em; }
  .topbar-row { padding: 0 10px; }
  .closes { font-size: .8rem; }
}

/* Histoire impossible à charger : on le dit, avec un bouton pour réessayer (rien n'est enregistré entre-temps) */
.load-error { text-align: center; }
.load-error h1 { font-size: 1.8rem; }
.load-error:not([hidden]) + .loading-sheet { display: none; }
#dlg-conflict .btn + .btn { margin-top: 10px; }
