/* Style repris de mon-cahier.fr : papier crème, bleu nuit, bleu #576BE1, orange, police Geologica (OFL, dans fonts/) */
@font-face { font-family: "Geologica"; src: url("fonts/Geologica-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geologica"; src: url("fonts/Geologica-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Geologica"; src: url("fonts/Geologica-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Geologica"; src: url("fonts/Geologica-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Geologica"; src: url("fonts/Geologica-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --fond: #F6F4EF;          /* papier */
  --bureau: #EAE7E0;
  --carte: #ffffff;
  --texte: #000F44;         /* encre */
  --doux: rgba(0, 15, 68, 0.6);
  --bord: rgba(0, 15, 68, 0.08);
  --accent: #576BE1;
  --accent-fonce: #4558c9;
  --accent-doux: rgba(87, 107, 225, 0.12);
  --orange: #FF8A54;
  --ok: #1e7a46;
  --erreur: #c0352b;
  --ombre: 0 6px 24px rgba(0, 15, 68, 0.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Geologica", -apple-system, "Segoe UI", sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.45;
}
h1, h2, h3 { color: var(--texte); font-weight: 800; letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
.ti { font-size: 1.15em; vertical-align: -0.12em; }
.bandeau-test { background: var(--orange); color: #fff; text-align: center; font-weight: 600; padding: 4px; }

.carte { background: var(--carte); border: 0; border-radius: 20px; padding: 20px; box-shadow: var(--ombre); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--bord); background: #fff; color: var(--texte);
  border-radius: 999px; padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-principal:hover { background: var(--accent-fonce); color: #fff; }
.btn:disabled { opacity: .6; cursor: wait; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  font: inherit; font-weight: 400; padding: 11px 14px; border: 1px solid transparent;
  border-radius: 14px; background: var(--fond); color: var(--texte); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.erreur { color: var(--erreur); }

/* Logo : carré orange arrondi, comme Mon Cahier */
.logo {
  width: 64px; height: 64px; border-radius: 20px; background: var(--orange); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 34px;
}
.logo .ti { font-size: inherit; vertical-align: 0; }
.logo.petit { width: 34px; height: 34px; border-radius: 11px; font-size: 19px; }

/* Connexion */
.connexion { max-width: 440px; margin: 0 auto; min-height: 100vh; padding: 24px 16px; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.connexion .logo { align-self: center; margin-bottom: 12px; }
.connexion h1 { margin: 0; font-size: 2.4rem; }
.sous-titre { color: var(--doux); margin: 6px 0 26px; font-size: 1.05rem; }
.connexion form { display: flex; flex-direction: column; gap: 16px; text-align: left; border-radius: 28px; padding: 28px; box-shadow: 0 10px 40px rgba(0, 15, 68, 0.07); }
.connexion .btn-principal { padding: 12px; }

/* Page */
.entete {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--fond); border-bottom: 1px solid var(--bord);
}
.entete .titre { font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; gap: 10px; }
.entete .titre-doux { color: var(--doux); font-weight: 600; }
.entete .qui { display: flex; gap: 18px; align-items: center; color: var(--doux); flex-wrap: wrap; font-size: .95rem; }
.page { max-width: 900px; margin: 0 auto; padding: 22px 16px 60px; }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
.semaine { display: flex; align-items: center; gap: 10px; }
.semaine > div { flex: 1; text-align: center; display: flex; flex-direction: column; }
.semaine small { color: var(--doux); min-height: 1em; }
.semaine .btn { width: 40px; height: 40px; padding: 0; font-size: 1.2rem; }
#apercu { align-self: stretch; }
.aide { color: var(--doux); font-size: .9rem; margin: 16px 6px; }

.jour { margin-top: 16px; padding: 0; overflow: hidden; }
.jour-entete { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 16px 20px 10px; flex-wrap: wrap; }
.jour h2 { margin: 0; font-size: 1.15rem; display: flex; align-items: baseline; gap: 8px; }
.jour h2::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); align-self: center; }
.jour h2 span { font-weight: 500; color: var(--doux); font-size: .95rem; }
.statut { font-size: .82rem; color: var(--doux); }
.statut.ok { color: var(--ok); }
.statut.erreur { color: var(--erreur); }
.jour .ql-toolbar.ql-snow { border: 0; border-top: 1px solid var(--bord); border-bottom: 1px solid var(--bord); background: #fbfaf7; padding: 8px 14px; font-family: inherit; }
.jour .ql-container.ql-snow { border: 0; font-size: 1rem; font-family: inherit; }
.jour .ql-editor { min-height: 110px; padding: 14px 20px; }
.jour .ql-editor.ql-blank::before { color: rgba(0, 15, 68, 0.35); font-style: normal; left: 20px; }
.jour .ql-editor img { max-width: 100%; max-height: 320px; border: 1px solid var(--bord); border-radius: 6px; }
.ql-snow .ql-stroke { stroke: var(--texte); }
.ql-snow .ql-fill { fill: var(--texte); }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }
.ql-toolbar.ql-snow button.ql-photo, .ql-toolbar.ql-snow button.ql-pdf,
.ql-toolbar.ql-snow button.ql-zone, .ql-toolbar.ql-snow button.ql-dessin { width: 30px; color: var(--texte); }
.ql-toolbar.ql-snow button.ql-photo:hover, .ql-toolbar.ql-snow button.ql-pdf:hover,
.ql-toolbar.ql-snow button.ql-zone:hover, .ql-toolbar.ql-snow button.ql-dessin:hover { color: var(--accent); }
.autres { font-size: .82rem; color: var(--doux); padding: 0 20px 14px; }
.autres:empty { display: none; }

/* Fenêtre photo / PDF */
dialog#fenetre {
  width: min(900px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  border: 0; border-radius: 24px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 15, 68, .25); color: var(--texte);
}
dialog::backdrop { background: rgba(0, 15, 68, .45); }
.fenetre-entete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; max-height: 60vh; overflow: auto; }
.vignette { border: 2px solid var(--bord); border-radius: 14px; background: var(--fond); color: var(--texte); padding: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font: inherit; }
.vignette:hover { border-color: var(--accent); }
.vignette canvas { max-width: 100%; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.zone-rognage { height: min(60vh, 560px); background: var(--bureau); border-radius: 12px; overflow: hidden; }
.zone-rognage img { display: block; max-width: 100%; }
.outils-rognage { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.outils-rognage .espace { flex: 1; }
#fenetre-statut { margin: 10px 0 0; }

/* Réglages */
.reglages { display: flex; flex-direction: column; gap: 16px; }
.reglages h2 { margin: 0 0 10px; font-size: 1.1rem; }
.reglages .grille { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.reglages textarea { min-height: 150px; }
.reglages .note { color: var(--doux); font-size: .85rem; font-weight: 400; }
.message { padding: 12px 16px; border-radius: 14px; background: #e7f6ec; color: var(--ok); }
.message.erreur { background: #fdecea; color: var(--erreur); }
table.envois { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.envois td, table.envois th { text-align: left; padding: 6px; border-bottom: 1px solid var(--bord); }

@media (max-width: 640px) {
  .choix, .reglages .grille { grid-template-columns: 1fr; }
  .entete { padding: 10px 16px; }
}

/* Zones d'écriture : mêmes motifs que dans le PDF (lignes tous les 8 mm, carreaux de 5 mm, Seyès 8 mm / 2 mm) */
.zone-ecriture {
  display: block; margin: 6px 0; border: 1px solid #c9d1e3; background-color: #fff;
  cursor: default; user-select: none;
}
.zone-ecriture[data-zone^="lignes"] {
  background-image: linear-gradient(to bottom, transparent calc(8mm - 1px), #9aa3b5 calc(8mm - 1px));
  background-size: 100% 8mm;
}
.zone-ecriture[data-zone^="quadrillage"] {
  background-image: linear-gradient(to right, #c3cbdc 1px, transparent 1px),
                    linear-gradient(to bottom, #c3cbdc 1px, transparent 1px);
  background-size: 5mm 5mm;
}
.zone-ecriture[data-zone^="seyes"] {
  background-image: linear-gradient(to right, #b4a9de 1px, transparent 1px),
                    linear-gradient(to bottom, transparent calc(8mm - 1px), #8a7fc0 calc(8mm - 1px)),
                    linear-gradient(to bottom, transparent calc(2mm - 1px), #b9d0ee calc(2mm - 1px));
  background-size: 8mm 8mm, 100% 8mm, 100% 2mm;
}
.ql-editor .zone-ecriture.ql-selected, .ql-editor .zone-ecriture:focus { outline: 2px solid var(--accent); }
dialog#fenetre-zone {
  width: min(560px, calc(100vw - 24px)); border: 0; border-radius: 24px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 15, 68, .25); color: var(--texte);
}
.choix-zone { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choix-zone label {
  border: 2px solid var(--bord); border-radius: 16px; padding: 8px; cursor: pointer; text-align: center; font-weight: 600;
}
.choix-zone label:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); }
.choix-zone input { position: absolute; opacity: 0; pointer-events: none; }
.choix-zone .zone-ecriture { height: 2cm; margin: 0 0 6px; }

/* Écriture à la main */
dialog#fenetre-dessin {
  width: min(1000px, calc(100vw - 16px)); max-height: calc(100vh - 16px); border: 0; border-radius: 24px;
  padding: 18px; box-shadow: 0 20px 60px rgba(0, 15, 68, .25); color: var(--texte);
}
.outils-dessin { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.outils-dessin select { width: auto; }
.outils-dessin .groupe { display: inline-flex; gap: 4px; align-items: center; }
.outils-dessin .btn { padding: 6px 10px; }
.outils-dessin .btn.actif { border-color: var(--orange); background: var(--orange); color: #fff; }
.pastille { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--bord); cursor: pointer; padding: 0; }
.pastille.actif { box-shadow: 0 0 0 2px var(--texte); }
.zone-dessin { position: relative; margin: 0 auto; border-radius: 6px; background: var(--bureau); }
.zone-dessin canvas { display: block; width: 100%; height: auto; }
#dessin-canvas { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.note-dessin { color: var(--doux); font-size: .85rem; }
#fenetre-dessin, #fenetre-dessin * {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
