* { box-sizing: border-box; }

body {
  --py: 28px;
  --px: 40px;
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  margin: 0;
  padding: calc(var(--py) + var(--sa-t)) calc(var(--px) + var(--sa-r))
           calc(var(--py) + var(--sa-b)) calc(var(--px) + var(--sa-l));
  background: #fbf8f2;
  color: #2e2e34;
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1, h2, .principal, .badge {
  font-family: "Caveat", cursive;
}
h1, h2 { font-weight: 600; }

h1 {
  font-size: 48px;
  margin: 8px 0 4px;
  display: inline-block;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 12' preserveAspectRatio='none'%3E%3Cpath d='M3 8 Q50 3 100 7 T197 5' fill='none' stroke='%23d48822' stroke-width='3.2' stroke-linecap='round'/%3E%3Cpath d='M12 10 Q70 7 130 9 T190 8' fill='none' stroke='%23d48822' stroke-width='1.4' stroke-linecap='round' opacity='.6'/%3E%3C/svg%3E") no-repeat 0 100% / 100% 14px;
  padding-bottom: 10px;
}

h2 { font-size: 34px; margin: 0 0 12px; color: #2e2e34; }

.marque {
  display: flex;
  align-items: center;
  gap: 18px;
  /* full-bleed : annule exactement le padding du body, safe-area comprise */
  margin: calc(-1 * (var(--py) + var(--sa-t))) calc(-1 * (var(--px) + var(--sa-r)))
          18px calc(-1 * (var(--px) + var(--sa-l)));
  padding: calc(16px + var(--sa-t)) calc(var(--px) + var(--sa-r))
           16px calc(var(--px) + var(--sa-l));
  background: #0b1220;
}

.logo { height: 64px; width: auto; }
.logo-eutomation {
  height: 58px;
  width: auto;
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
}

.menu {
  display: flex;
  gap: 14px;
  margin: 0 0 8px;
}
.menu a {
  font-family: "Caveat", cursive;
  font-size: 28px;
  font-weight: 600;
  color: #2e2e34;
  text-decoration: none;
  border: 2px solid #2e2e34;
  border-radius: 14px 8px 12px 10px / 10px 14px 8px 12px;
  padding: 2px 16px;
  background: #fffdf8;
}
.menu a[aria-current="page"] {
  background: #ff6b2b;
  border-color: #ff6b2b;
  color: #2a1204;
  transform: rotate(-2deg);
}
.bandeau {
  margin: 8px 0 24px;
  padding: 0;
  background: transparent;
  border: 0;
  font-weight: 500;
  font-size: 19px;
  color: #2e2e34;
}
.agents { display: flex; align-items: center; gap: 14px; }
.agents-icones { display: flex; gap: 6px; flex: none; }
.crayon-bot { width: 42px; height: 42px; overflow: visible; }
.crayon-bot path, .crayon-bot circle {
  fill: none;
  stroke: #ece6da;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.crayon-bot circle { stroke: #f0a73a; fill: #f0a73a; }

.col, .brouillon, .pin-carte {
  background: #fffdf8;
  border: 2.4px solid #2e2e34;
  border-radius: 22px 14px 18px 12px / 14px 20px 12px 18px;
  padding: 22px;
  box-shadow: 4px 5px 0 rgba(46, 46, 52, 0.08);
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.attendu { margin: 0 0 20px; padding-left: 34px; }
.attendu li { margin: 10px 0; }
.attendu li span:first-child { margin-right: 12px; }
.pas-recu {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  border: 2px solid #e8b04a;
  color: #e8b04a;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}

.zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 34px 20px;
  border: 3px dashed #e8b04a;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
}
.zone strong { font-size: 24px; font-weight: 600; }
.zone span, .vide, .reply, .note, .nonlu { color: #5c564c; }
.zone.survol { background: #fff4e4; }
.carte, .draft, .rappro tbody tr {
  background: #fffdf8;
  color: #2e2e34;
  border-color: #2e2e34;
}
.texte, .draft { color: #2e2e34; }
button, input[type="text"], input[type="password"], #code {
  background: #fffdf8;
  color: #2e2e34;
  border: 2px solid #2e2e34;
  border-radius: 12px 8px 14px 9px / 9px 13px 8px 12px;
}
.principal { background: #ff6b2b; border-color: #ff6b2b; color: #2a1204; font-size: 25px; }
.brouillon-badge { background: transparent; color: #d48822; border: 2px solid #d48822; transform: rotate(-3deg); }
.pin-carte { max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.pin-carte input { font-size: 32px; letter-spacing: 0.3em; padding: 12px 16px; }
.erreur { color: #ff6b2b; min-height: 1.2em; margin: 0; }
.zone.ferme { opacity: .55; cursor: not-allowed; pointer-events: none; }
button:disabled, .principal:disabled {
  opacity: .45;
  cursor: not-allowed;
  background: #1a2231;
  color: #c5d0de;
  border-color: rgba(245, 193, 74, .35);
}

.lu { max-height: 620px; overflow-y: auto; }
.vide { color: #b7c0d0; }

.carte {
  border: 1px solid #2c3854;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
  background: #0f1728;
}
.tete { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.nom { word-break: break-all; }
.etat { font-size: 17px; white-space: nowrap; }
.etat.ok { color: #7fd6a0; }
.etat.non { color: #e8b04a; }
.texte {
  white-space: pre-wrap;
  word-break: break-word;
  font: 17px/1.5 ui-monospace, Menlo, monospace;
  max-height: 280px;
  overflow-y: auto;
  margin: 10px 0 0;
  color: #dfe4ee;
}

button {
  font: inherit;
  padding: 10px 20px;
  border: 2px solid #3a4766;
  border-radius: 10px;
  background: #1d2740;
  color: #eef1f6;
  cursor: pointer;
}
button:hover { border-color: #e8b04a; }

.principal {
  margin-left: auto;
  background: #ff6b2b;
  border-color: #ff6b2b;
  color: #0b1220;
  font-weight: 700;
}
.principal:hover { background: #ff8550; border-color: #ff8550; }

.brouillon { margin-top: 28px; }
.brouillon-tete { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brouillon-tete h2 { margin: 0; }

.badge {
  padding: 4px 16px;
  border-radius: 999px;
  font-weight: 700;
}
.brouillon-badge { background: #2a3350; color: #e8b04a; }
.pret-badge { background: #2f8a52; color: #fff; }

.reply { min-height: 1.4em; color: #b7c0d0; margin: 14px 0 8px; }
.reflexion[hidden], .reply[hidden] { display: none; }
.reflexion {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 100%;
  margin: 14px 0 8px;
  color: #f5c14a;
}
.reflexion span { overflow-wrap: anywhere; }
.engrenage { width: 30px; height: 30px; flex: none; animation: spin 1.6s linear infinite; }
.engrenage path, .engrenage circle {
  fill: none;
  stroke: #f0a73a;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
@keyframes spin { to { transform: rotate(360deg); } }

.draft {
  white-space: pre-wrap;
  word-break: break-word;
  font: 17px/1.55 ui-monospace, Menlo, monospace;
  background: #0f1728;
  border: 1px dashed #3a4766;
  padding: 16px;
  border-radius: 10px;
  color: #eef1f6;
}

.signer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; }
.signer label { font-weight: 600; }
input[type="text"] {
  font: inherit;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #3a4766;
  background: #0b1220;
  color: #eef1f6;
}
.signe { color: #7fd6a0; font-weight: 600; }
.note { color: #b7c0d0; font-size: 17px; margin: 12px 0 0; }

footer { margin-top: 24px; }

/* Rapprochement */
.sous-titre { margin-top: 24px; }
.tableau { overflow-x: auto; }
.rappro { width: 100%; border-collapse: collapse; font-size: 18px; }
.rappro th, .rappro td { padding: 10px 12px; border-bottom: 1px solid #26314a; text-align: left; vertical-align: top; }
.rappro th { color: #e8b04a; font-size: 16px; font-weight: 600; }
.rappro tbody tr { background: #0f1728; }
.nonlu { color: #b7c0d0; font-style: italic; }
.statut { font-weight: 700; padding: 2px 12px; border-radius: 999px; white-space: nowrap; }
.s-ok { background: #2f8a52; color: #fff; }
.s-ecart { background: #ff6b2b; color: #0b1220; }

@media (max-width: 1000px) {
  .cols { grid-template-columns: 1fr; }
}

/* Mobile (iPhone 390 px) */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  body { --py: 20px; --px: 20px; font-size: 16px; font-weight: 400; line-height: 1.55; }
  img, svg, pre, table { max-width: 100%; }

  .marque { flex-wrap: wrap; gap: 10px 12px; margin-bottom: 22px; padding-top: calc(12px + var(--sa-t)); padding-bottom: 12px; }
  .logo { height: 40px; }
  .logo-eutomation { height: 36px; padding: 4px 8px; }

  h1 { font-size: 30px; font-weight: 600; margin: 4px 0 6px; padding-bottom: 8px; max-width: 100%; overflow-wrap: anywhere; }
  h2 { font-size: 24px; font-weight: 600; margin-bottom: 14px; overflow-wrap: anywhere; }
  .bandeau { font-size: 16px; font-weight: 500; margin: 6px 0 24px; }
  .agents { align-items: flex-start; }
  .crayon-bot { width: 32px; height: 32px; }
  .reflexion { gap: 8px; font-size: 16px; margin: 16px 0 10px; }
  .engrenage { width: 26px; height: 26px; }

  .menu { flex-wrap: wrap; gap: 10px 12px; margin-bottom: 14px; }
  .menu a { display: inline-flex; align-items: center; min-height: 44px; font-size: 22px; font-weight: 500; padding: 2px 16px; }

  .col, .brouillon, .pin-carte { padding: 20px; min-width: 0; }
  .cols { gap: 24px; }
  .brouillon { margin-top: 24px; }

  .attendu { padding-left: 22px; margin-bottom: 22px; }
  .attendu li { margin: 14px 0; overflow-wrap: anywhere; }
  .attendu li span:first-child { display: block; margin-right: 0; }
  .pas-recu { font-size: 14px; font-weight: 600; margin-top: 6px; }

  .zone { padding: 26px 16px; gap: 6px; }
  .zone strong { font-size: 19px; }

  .carte { padding: 16px; margin-bottom: 16px; }
  .tete { flex-wrap: wrap; }
  .etat { font-size: 14px; }
  .texte, .draft { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
  .note { font-size: 14px; margin-top: 16px; }
  .reply { margin: 16px 0 10px; }

  button { min-height: 44px; font-weight: 600; }
  .brouillon-tete, .signer { flex-direction: column; align-items: stretch; gap: 14px; }
  .signer { margin-top: 20px; }
  .brouillon-tete .badge { align-self: flex-start; font-weight: 600; }
  .brouillon-tete button, .signer input, .signer button, footer button { width: 100%; }
  .principal { margin-left: 0; font-size: 22px; font-weight: 600; }
  input, input[type="text"] { font-size: max(16px, 1em); min-width: 0; max-width: 100%; }
  input[type="text"], #code { min-height: 44px; }
  footer { margin-top: 28px; }

  .pin-carte { max-width: 100%; gap: 14px; }
  .pin-carte input { width: 100%; font-size: 24px; letter-spacing: 0.15em; padding: 10px 14px; }

  /* Tableau rapprochement : une carte par ligne */
  .sous-titre { margin-top: 28px; }
  .tableau { overflow-x: visible; }
  .rappro, .rappro tbody, .rappro tr, .rappro td { display: block; width: 100%; }
  .rappro thead { display: none; }
  .rappro { font-size: 16px; }
  .rappro tbody tr {
    margin-bottom: 18px;
    padding: 8px 16px;
    border: 2px solid #2e2e34;
    border-radius: 14px 10px 12px 9px / 10px 13px 9px 12px;
  }
  .rappro td { padding: 11px 0; overflow-wrap: anywhere; }
  .rappro td:last-child { border-bottom: 0; }
  .rappro td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 600;
    font-style: normal;
    color: #e8b04a;
  }
  .statut { font-weight: 600; }
  body.night .rappro tbody tr { border-color: rgba(245, 193, 74, .28); }
  body.night .rappro td::before { color: #f5c14a; }
}

/* Nuit — mêmes tokens que pianzo.tech body.night */
body.night {
  --crayon-ink: #ece6da;
  --crayon-amber: #f0a73a;
  background:
    radial-gradient(ellipse 90% 48% at 50% -8%, rgba(37,99,235,.22), transparent 58%),
    radial-gradient(ellipse 70% 42% at 78% 108%, rgba(46,191,140,.16), transparent 52%),
    #050814;
  color: rgba(255, 255, 255, .88);
  color-scheme: dark;
}
body.night h1 {
  color: rgba(255, 255, 255, .94);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 12' preserveAspectRatio='none'%3E%3Cpath d='M3 8 Q50 3 100 7 T197 5' fill='none' stroke='%23f0a73a' stroke-width='3.2' stroke-linecap='round'/%3E%3Cpath d='M12 10 Q70 7 130 9 T190 8' fill='none' stroke='%23f0a73a' stroke-width='1.4' stroke-linecap='round' opacity='.6'/%3E%3C/svg%3E");
}
body.night h2,
body.night .bandeau { color: rgba(236, 230, 218, .86); }
body.night button,
body.night input[type="text"],
body.night #code {
  background: #111827;
  color: rgba(255, 255, 255, .88);
  border-color: rgba(245, 193, 74, .45);
  box-shadow: none;
}
/* Cartes translucides : le dégradé de la page passe derrière */
body.night .col,
body.night .brouillon,
body.night .pin-carte,
body.night .carte,
body.night .draft,
body.night .menu a,
body.night .rappro tbody tr {
  background: rgba(17, 24, 39, .72);
  color: rgba(255, 255, 255, .88);
  border-color: rgba(245, 193, 74, .28);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 8px 24px rgba(0, 0, 0, .18);
}
body.night .menu a[aria-current="page"],
body.night .principal {
  background: rgba(255, 107, 43, .92);
  border-color: rgba(255, 107, 43, .92);
  color: #2a1204;
  box-shadow: 0 6px 22px rgba(255, 107, 43, .28), 0 2px 6px rgba(0, 0, 0, .25);
}
body.night .principal:hover { background: rgba(255, 133, 80, .94); border-color: rgba(255, 133, 80, .94); }
body.night .zone {
  border-color: rgba(240, 167, 58, .55);
  background: rgba(255, 255, 255, .03);
}
body.night .zone.survol { background: rgba(255, 255, 255, .07); }
body.night .zone span,
body.night .vide,
body.night .reply,
body.night .texte { color: rgba(197, 208, 222, .9); }
body.night .note,
body.night .nonlu { color: rgba(197, 208, 222, .68); }
body.night .pas-recu,
body.night .brouillon-badge,
body.night .rappro th,
body.night .etat.non { color: #f5c14a; border-color: rgba(245, 193, 74, .7); }
body.night .rappro th,
body.night .rappro td { border-bottom-color: rgba(255,255,255,.08); }
body.night .s-ok,
body.night .pret-badge {
  background: rgba(47, 138, 82, .32);
  color: #a6e6bf;
  box-shadow: inset 0 0 0 1px rgba(127, 214, 160, .4);
}
body.night .s-ecart {
  background: rgba(255, 107, 43, .22);
  color: #ffb48f;
  box-shadow: inset 0 0 0 1px rgba(255, 107, 43, .5);
}
body.night .logo-eutomation { background: transparent; padding: 0; }


/* Resserré — moins gros, un peu plus tenu */
body { --py: 18px; --px: 22px; font-size: 15px; line-height: 1.5; }
.cols, .brouillon, footer, .pin-carte { max-width: 920px; }
.brouillon, footer { margin-left: auto; margin-right: auto; }
.pin-carte { margin-left: 0; }
h1, h2, .badge { font-family: "Caveat", cursive; }
button, .principal, .menu a { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
h1 { font-size: 36px; padding-bottom: 6px; }
h2 { font-size: 26px; margin-bottom: 8px; }
.logo { height: 42px; }
.logo-eutomation { height: 36px; padding: 4px 8px; }
.menu a { font-size: 14px; font-weight: 600; letter-spacing: .01em; padding: 6px 12px; border-width: 1px; border-radius: 999px; min-height: 36px; }
.bandeau { font-size: 15px; margin-bottom: 16px; }
.col, .brouillon, .pin-carte { padding: 16px; border-width: 1px; border-radius: 16px; box-shadow: none; }
.cols { gap: 16px; }
.zone { padding: 18px 14px; border-width: 1.5px; }
.zone strong { font-size: 16px; }
.principal { font-size: 15px; font-weight: 650; padding: 8px 14px; }
button { padding: 8px 14px; }
.draft, .texte { font-size: 13px; }
.note { font-size: 13px; }
.rappro { font-size: 14px; }
.crayon-bot { width: 28px; height: 28px; }
.pin-carte input { font-size: 22px; }
@media (max-width: 720px) {
  h1 { font-size: 28px; }
  h2 { font-size: 22px; }
  .menu a { min-height: 44px; font-size: 15px; }
  button, .principal { min-height: 44px; font-size: 15px; }
  .zone { padding: 16px 12px; }
  .col, .brouillon, .pin-carte { padding: 14px; }
}
