/* ================================================================
   Aurea — feuille de style
   Papier crème, dorure, motif de paon
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;1,9..144,500&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --papier:        #FDFAF2;
  --papier-creme:  #F7F1E1;

  --or:            #C2A24A;
  --or-fonce:      #96774A;
  --or-pale:       #E5D8B6;
  --or-clair:      #E8D6A8;

  --paon:          #0F4A4C;
  --paon-clair:    #1E7A78;
  --paon-voile:    rgba(15, 74, 76, 0.08);

  --encre:         #2E2A22;
  --encre-douce:   #6B6152;
  --encre-pale:    #A2977F;

  --serif:  'Cormorant Garamond', Georgia, serif;
  --sans:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --titre-ev: 'Fraunces', 'Cormorant Garamond', Georgia, serif;

  --reliure: 46px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--sans);
  color: var(--encre);
  background: radial-gradient(ellipse at 50% 0%, #4A3B22 0%, #2A2117 55%, #191309 100%);
  -webkit-font-smoothing: antialiased;
}

.grain::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(140,106,46,0.035) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(140,106,46,0.03) 0 1px, transparent 1px),
    radial-gradient(circle at 45% 85%, rgba(140,106,46,0.025) 0 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px, 13px 13px;
}

/* ================================================================
   COUVERTURE
   ================================================================ */

#couverture {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  perspective: 2400px;
}

.couverture-carte {
  position: relative;
  width: min(430px, 90vw);
  height: min(660px, 92vh);
  border-radius: 3px 12px 12px 3px;
  background: radial-gradient(ellipse at 50% 32%, #FDF8EA 0%, #F6EEDA 52%, #EBE0C4 100%);
  box-shadow:
    0 44px 100px rgba(0,0,0,0.6),
    0 0 0 1px var(--or-fonce),
    inset 0 0 0 1px rgba(255,255,255,0.7);
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.05s cubic-bezier(.6,.02,.25,1), opacity .45s ease .5s;
  overflow: hidden;
}
.couverture-carte.ouvre { transform: rotateY(-120deg); opacity: 0; }

/* Tranche dorée sculptée */
.couverture-carte::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 16px;
  z-index: 3;
  background: linear-gradient(90deg,
    #7E6640 0%, #96774A 14%, var(--or) 38%,
    var(--or-clair) 55%, var(--or) 72%, #B89A62 88%, #846A44 100%);
  box-shadow: inset -2px 0 5px rgba(0,0,0,0.25), 2px 0 8px rgba(140,106,46,0.3);
}
.couverture-carte::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 16px;
  z-index: 4;
  pointer-events: none;
  background: repeating-linear-gradient(180deg,
    rgba(255,248,225,0.35) 0 1px,
    transparent 1px 4px,
    rgba(110,83,32,0.22) 4px 5px,
    transparent 5px 9px);
}

/* Encadrement à triple filet */
.couv-cadre {
  position: absolute;
  left: 30px; right: 18px; top: 18px; bottom: 18px;
  border: 1.5px solid var(--or-fonce);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}
.couv-cadre::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 0.75px solid rgba(201,162,39,0.55);
}
.couv-cadre::after {
  content: '';
  position: absolute;
  inset: -6px;
  border: 0.75px solid rgba(201,162,39,0.3);
}

/* Écoinçons ornés */
.ecoincon {
  position: absolute;
  width: 42px; height: 42px;
  z-index: 2;
  pointer-events: none;
  opacity: .85;
}
.ecoincon svg { width: 100%; height: 100%; display: block; }
.ec-hg { left: 33px;  top: 21px; }
.ec-hd { right: 21px; top: 21px;    transform: scaleX(-1); }
.ec-bg { left: 33px;  bottom: 21px; transform: scaleY(-1); }
.ec-bd { right: 21px; bottom: 21px; transform: scale(-1); }

/* Contenu — colonne centrée */
.couv-inner {
  position: absolute;
  left: 42px; right: 30px; top: 34px; bottom: 30px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.couv-eyebrow {
  flex-shrink: 0;
  font-family: var(--serif);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  text-transform: uppercase;
  color: var(--or-fonce);
}

.couv-paon {
  flex-shrink: 0;
  display: block;
  width: 86%;
  max-width: 290px;
  margin: 12px auto 0;
  filter: drop-shadow(0 3px 10px rgba(140,106,46,0.3));
  animation: eclore 1.3s cubic-bezier(.2,.8,.25,1) both .15s;
}
@keyframes eclore {
  from { opacity: 0; transform: scale(.88) translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.couv-titre-zone { flex-shrink: 0; margin-top: 2px; }
.couv-titre {
  font-family: var(--serif);
  font-size: 2.85rem;
  font-weight: 600;
  color: var(--paon);
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  line-height: 1;
}
.couv-filet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 5px;
}
.couv-filet i {
  display: block;
  width: 54px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--or-fonce));
}
.couv-filet i:last-child { background: linear-gradient(90deg, var(--or-fonce), transparent); }
.couv-filet b {
  width: 5px; height: 5px;
  background: var(--or);
  transform: rotate(45deg);
}
.couv-sous {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.98rem;
  color: var(--or-fonce);
  letter-spacing: 0.06em;
}

/* Cartouche du formulaire — poussé en bas, centré */
.couv-zone {
  margin-top: auto;
  width: 100%;
  max-width: 270px;
  flex-shrink: 0;
}

.couv-form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.2rem 1.1rem 1.05rem;
  background: rgba(255,252,244,0.6);
  border: 1px solid var(--or-pale);
  border-radius: 3px;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.55);
}
.couv-form::before {
  content: '';
  position: absolute;
  top: -5px; left: 50%;
  width: 9px; height: 9px;
  margin-left: -4.5px;
  background: #F6EEDA;
  border: 1px solid var(--or-fonce);
  border-radius: 50%;
  box-shadow: 0 0 0 2.5px #F6EEDA;
}

.couv-note {
  font-family: var(--serif);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--encre-douce);
  line-height: 1.45;
}

.couv-form input {
  display: block;
  width: 100%;
  padding: 0.58rem 0.8rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  text-align: center;
  letter-spacing: 0.1em;
  color: var(--encre);
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--or-pale);
  border-radius: 2px;
  outline: none;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.couv-form input::placeholder { letter-spacing: 0.04em; color: var(--encre-pale); }
.couv-form input:focus {
  border-color: var(--paon-clair);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(30,122,120,0.1);
}

.couv-form button {
  display: block;
  width: 100%;
  padding: 0.62rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  color: var(--papier);
  background: linear-gradient(180deg, var(--paon-clair), var(--paon));
  border: 1px solid var(--paon);
  border-radius: 2px;
  cursor: pointer;
  transition: filter .18s, transform .08s;
}
.couv-form button:hover  { filter: brightness(1.12); }
.couv-form button:active { transform: translateY(1px); }

.couv-erreur {
  min-height: 0.9rem;
  font-size: 0.74rem;
  color: #A8412C;
}

.couv-action {
  flex-shrink: 0;
  margin-top: 0.75rem;
  font-family: var(--sans);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--encre-pale);
}

/* ================================================================
   CARNET
   ================================================================ */

#carnet {
  position: fixed;
  inset: 0;
  display: none;
  padding: clamp(10px, 2vh, 26px);
}
#carnet.visible { display: block; animation: entree .7s ease both; }
@keyframes entree {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}

.page {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--papier) 0%, #FCF8EE 60%, var(--papier-creme) 100%);
  border-radius: 3px 10px 10px 3px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.7);
  overflow: hidden;
}

/* Filigrane de paon */
.filigrane {
  position: absolute;
  right: 2%;
  bottom: -9%;
  width: min(560px, 46%);
  z-index: 0;
  opacity: .42;
  pointer-events: none;
  user-select: none;
}

/* --- Reliure --- */

.reliure {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--reliure);
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(90deg,
    #7E6640 0%,
    #96774A 8%,
    var(--or) 26%,
    var(--or-clair) 38%,
    var(--or) 50%,
    #B89A62 62%,
    #CDB582 74%,
    rgba(227,210,160,0.75) 88%,
    rgba(232,222,196,0.25) 96%,
    transparent 100%);
}
.reliure::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 74%;
  background: repeating-linear-gradient(180deg,
    rgba(255,248,225,0.30) 0 1px,
    transparent 1px 5px,
    rgba(110,83,32,0.16) 5px 6px,
    transparent 6px 11px);
}
.reliure::after {
  content: '';
  position: absolute;
  right: -18px; top: 0; bottom: 0;
  width: 18px;
  background: linear-gradient(90deg, rgba(140,106,46,0.16), transparent);
}

/* Fil de couture */
.couture {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--reliure);
  z-index: 7;
  pointer-events: none;
}
.couture svg { width: 100%; height: 100%; display: block; }

/* Ferrets */
.ferret {
  position: absolute;
  left: 4px;
  width: calc(var(--reliure) - 10px);
  height: 26px;
  z-index: 8;
  pointer-events: none;
  background: linear-gradient(180deg, var(--or-clair), var(--or-fonce));
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,250,230,0.55);
}
.ferret::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;
  background: radial-gradient(circle at 35% 30%, #2AA9A4, var(--paon) 70%);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(110,83,32,0.6), inset 0 1px 1px rgba(255,255,255,0.4);
}
.ferret-h { top: 12px; }
.ferret-b { bottom: 12px; }

/* --- En-tête --- */

.entete {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem 0.75rem calc(var(--reliure) + 1.1rem);
  border-bottom: 1.5px solid var(--or-fonce);
  flex-shrink: 0;
}
.entete::before {
  content: '';
  position: absolute;
  left: calc(var(--reliure) + 1.1rem); right: 1.1rem; bottom: -4.5px;
  height: 1px;
  background: rgba(201,162,39,0.5);
}

.marque { display: flex; align-items: center; gap: 0.7rem; flex-shrink: 0; }
.marque img {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--or-fonce), 0 2px 9px rgba(140,106,46,0.35);
}
.marque h1 {
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--paon);
  letter-spacing: 0.14em;
  line-height: 1;
}

.nav-semaine { display: flex; align-items: center; gap: 0.35rem; margin-left: 0.4rem; }
.periode {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-style: italic;
  color: var(--or-fonce);
  white-space: nowrap;
  min-width: 215px;
  text-align: center;
}

.entete-actions { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }

/* --- Boutons --- */

.btn {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.42rem 0.85rem;
  color: var(--encre-douce);
  background: rgba(255,255,255,0.35);
  border: 1px solid var(--or-pale);
  border-radius: 3px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover {
  color: var(--paon);
  border-color: var(--paon-clair);
  background: var(--paon-voile);
}
.btn-rond {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; font-size: 1rem; line-height: 1;
}
.btn-plein {
  color: var(--papier);
  background: linear-gradient(180deg, var(--paon-clair), var(--paon));
  border-color: var(--paon);
}
.btn-plein:hover {
  color: var(--papier);
  filter: brightness(1.12);
  background: linear-gradient(180deg, var(--paon-clair), var(--paon));
  border-color: var(--paon);
}
.btn-danger:hover {
  color: #A8412C;
  border-color: #C87A63;
  background: rgba(168,65,44,0.06);
}

/* Boutons segmentés (vue / zoom) */
.groupe-btn {
  display: flex;
  border: 1px solid var(--or-pale);
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255,255,255,0.35);
  flex-shrink: 0;
}
.btn-seg {
  border: none;
  border-radius: 0;
  background: transparent;
  border-left: 1px solid var(--or-pale);
}
.btn-seg:first-child { border-left: none; }
.btn-seg:hover { background: var(--paon-voile); }
.btn-seg.actif {
  color: #FFF8E6;
  background: linear-gradient(180deg, var(--paon-clair), var(--paon));
}
.btn-seg.actif:hover {
  color: #FFF8E6;
  background: linear-gradient(180deg, var(--paon-clair), var(--paon));
}
.btn-seg:disabled { opacity: .35; cursor: not-allowed; }
.btn-seg:disabled:hover { background: transparent; }

.ruban {
  position: relative;
  padding: 0.44rem 0.9rem 0.44rem 0.85rem;
  font-family: var(--serif);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #FFF8E6;
  background: linear-gradient(180deg, var(--or), var(--or-fonce));
  border: none;
  cursor: pointer;
  transition: filter .15s;
  box-shadow: inset 0 1px 0 rgba(255,250,230,0.4);
}
.ruban:hover { filter: brightness(1.1); }
.ruban::after {
  content: '';
  position: absolute;
  right: -9px; top: 0; bottom: 0;
  width: 9px;
  background: inherit;
  clip-path: polygon(0 0, 100% 0, 0 50%, 100% 100%, 0 100%);
}

/* --- Légende --- */

.legende {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.1rem;
  padding: 0.5rem 1.1rem 0.5rem calc(var(--reliure) + 1.1rem);
  border-bottom: 1px solid rgba(227,210,160,0.65);
  flex-shrink: 0;
}
.legende-item {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.7rem;
  color: var(--encre-douce);
}
/* Pastille = ocelle de plume */
.legende-pastille {
  position: relative;
  width: 10px; height: 12px;
  border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
  flex-shrink: 0;
}
.legende-pastille::after {
  content: '';
  position: absolute;
  left: 50%; top: 44%;
  width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: rgba(255,250,235,0.85);
}

/* --- Grille --- */

.grille-zone {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 1.1rem 1.4rem calc(var(--reliure) + 0.5rem);
  position: relative;
  z-index: 2;
}
.grille-zone::-webkit-scrollbar { width: 8px; }
.grille-zone::-webkit-scrollbar-track { background: transparent; }
.grille-zone::-webkit-scrollbar-thumb { background: var(--or-pale); border-radius: 4px; }

.jours-entete {
  display: grid;
  grid-template-columns: 50px repeat(var(--nb-jours, 6), minmax(0, 1fr));
  gap: 0 3px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--papier) 74%, rgba(253,250,242,0.9));
  padding: 0.55rem 0 0.4rem;
}

.jour-titre {
  text-align: center;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--or-pale);
  cursor: pointer;
  transition: background .15s;
}
#carnet:not(.mode-jour) .jour-titre:hover {
  background: rgba(201,162,39,0.06);
}
#carnet.mode-jour .jour-titre { cursor: default; }
.jour-nom {
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: var(--encre-pale);
}
.jour-num {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--encre-douce);
  line-height: 1.15;
}
.jour-titre.aujourdhui {
  border-bottom: 2px solid var(--or);
  background: linear-gradient(180deg, transparent, rgba(201,162,39,0.07));
}
.jour-titre.aujourdhui .jour-nom { color: var(--or-fonce); }
.jour-titre.aujourdhui .jour-num { color: var(--paon); font-weight: 700; }

.grille {
  display: grid;
  grid-template-columns: 50px repeat(var(--nb-jours, 6), minmax(0, 1fr));
  gap: 0 3px;
  position: relative;
}

.heure {
  font-family: var(--serif);
  font-size: 0.92rem;
  color: var(--encre-pale);
  text-align: right;
  padding-right: 0.55rem;
  transform: translateY(-0.5em);
}
.heure.demi {
  font-size: 0.72rem;
  font-style: italic;
  opacity: .6;
}

.ligne-h { border-top: 1px solid rgba(227,210,160,0.6); }
.ligne-h.demi  { border-top: 1px dotted rgba(227,210,160,0.42); }
.ligne-h.quart { border-top: 1px dotted rgba(227,210,160,0.22); }

/* --- Vue jour : colonne large, en-tête étoffé --- */
#carnet.mode-jour .jours-entete,
#carnet.mode-jour .grille {
  grid-template-columns: 66px minmax(0, 1fr);
  max-width: 880px;
  margin: 0 auto;
}
#carnet.mode-jour .jour-titre {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.6rem;
  padding-bottom: 0.5rem;
}
#carnet.mode-jour .jour-nom {
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
}
#carnet.mode-jour .jour-num { font-size: 2.3rem; }
#carnet.mode-jour .bloc { padding: 5px 10px 5px 12px; }
#carnet.mode-jour .bloc-titre { font-size: 0.94rem; }
#carnet.mode-jour .bloc-heure { font-size: 0.66rem; }
#carnet.mode-jour .bloc-note  { font-size: 0.72rem; white-space: normal; }

.colonne { position: relative; border-left: 1px solid rgba(227,210,160,0.4); }
.colonne:hover { background: rgba(201,162,39,0.022); }

/* --- Blocs --- */

.bloc {
  position: absolute;
  padding: 3px 6px 3px 8px;
  border-radius: 3px;
  border-left: 3px solid var(--c, var(--paon));
  background: var(--bg, rgba(15,74,76,0.07));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.45);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow .15s, transform .1s;
  z-index: 2;
}
.bloc:hover {
  box-shadow: 0 3px 12px rgba(140,106,46,0.26), inset 0 0 0 1px rgba(255,255,255,0.6);
  transform: translateY(-1px);
  z-index: 3;
}
.bloc-heure {
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--c);
  opacity: .82;
}
.bloc-titre {
  font-family: var(--titre-ev);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--encre);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bloc.compact {
  padding: 1px 5px;
  display: flex;
  align-items: center;
}
.bloc.compact .bloc-titre {
  font-size: 0.74rem;
  font-weight: 600;
}
.bloc.compact .bloc-heure { display: none; }
.bloc-note {
  font-size: 0.66rem;
  color: var(--encre-douce);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bloc.annule { opacity: .5; }
.bloc.annule .bloc-titre { text-decoration: line-through; }

.sceau {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
  padding: 1px 7px;
  font-family: var(--serif);
  font-size: 0.68rem;
  font-weight: 600;
  font-style: italic;
  color: #FBF6E9;
  background: var(--paon);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(201,162,39,0.45);
}
.sceau.retard { background: #A8412C; }

.blocage {
  position: absolute;
  left: 1px; right: 1px;
  z-index: 1;
  border-radius: 2px;
  background: repeating-linear-gradient(45deg,
    rgba(154,147,132,0.11) 0 5px,
    rgba(154,147,132,0.04) 5px 10px);
  border-left: 2px solid rgba(154,147,132,0.42);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.blocage span {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.74rem;
  color: rgba(107,97,82,0.62);
  letter-spacing: 0.06em;
}

.maintenant {
  position: absolute;
  left: 0; right: 0;
  height: 0;
  border-top: 1.5px solid #A8412C;
  z-index: 6;
  pointer-events: none;
}
.maintenant::before {
  content: '';
  position: absolute;
  left: -4px; top: -4px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #A8412C;
}

/* ================================================================
   VOLET
   ================================================================ */

#voile {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(25,19,9,0.55);
  backdrop-filter: blur(2px);
  display: none;
}
#voile.visible { display: block; animation: fondu .25s ease both; }
@keyframes fondu { from { opacity: 0 } to { opacity: 1 } }

.volet {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(430px, 100%);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--papier) 0%, var(--papier-creme) 100%);
  box-shadow: -20px 0 50px rgba(0,0,0,0.4);
  animation: glisse .3s cubic-bezier(.2,.8,.3,1) both;
  overflow: hidden;
}
@keyframes glisse { from { transform: translateX(100%) } to { transform: none } }
.volet::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--or-clair), var(--or), var(--or-fonce));
}

.volet-entete {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.2rem 1.3rem 0.9rem;
  border-bottom: 1.5px solid var(--or-fonce);
  flex-shrink: 0;
}
.volet-entete h2 {
  font-family: var(--serif);
  font-size: 1.62rem;
  font-weight: 600;
  color: var(--paon);
}
.volet-fermer {
  margin-left: auto;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  color: var(--encre-pale);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 3px;
  transition: all .15s;
}
.volet-fermer:hover { color: var(--encre); background: rgba(140,106,46,0.08); }

.volet-corps { flex: 1; overflow-y: auto; padding: 1.2rem 1.3rem 2rem; }
.volet-corps::-webkit-scrollbar { width: 8px; }
.volet-corps::-webkit-scrollbar-thumb { background: var(--or-pale); border-radius: 4px; }

/* --- Formulaires --- */

.champ { margin-bottom: 1rem; }
.champ label {
  display: block;
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--encre-pale);
  margin-bottom: 0.35rem;
}
.champ input,
.champ select,
.champ textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--encre);
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--or-pale);
  border-radius: 3px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.champ textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.champ input:focus,
.champ select:focus,
.champ textarea:focus { border-color: var(--paon-clair); background: #fff; }
.champ-duo  { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.champ-trio { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; }

.groupe {
  margin: 1.4rem 0 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(227,210,160,0.7);
}
.groupe:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.groupe-titre {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 600;
  font-style: italic;
  color: var(--or-fonce);
  margin-bottom: 0.8rem;
}

.case { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.8rem; }
.case input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--paon);
  cursor: pointer;
  flex-shrink: 0;
}
.case label {
  font-size: 0.83rem;
  color: var(--encre-douce);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin: 0;
  cursor: pointer;
}

.actions-volet {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--or-pale);
}
.actions-volet .btn { flex: 1; padding: 0.6rem; }

/* --- Listes --- */

.recherche {
  width: 100%;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--or-pale);
  border-radius: 3px;
  outline: none;
}
.recherche:focus { border-color: var(--paon-clair); background: #fff; }

.carte {
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.55rem;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(227,210,160,0.75);
  border-left: 3px solid var(--or-pale);
  border-radius: 3px;
  cursor: pointer;
  transition: all .15s;
}
.carte:hover {
  border-left-color: var(--paon);
  background: #fff;
  transform: translateX(2px);
}
.carte-nom {
  font-family: var(--titre-ev);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--paon);
  line-height: 1.2;
}
.carte-info { font-size: 0.75rem; color: var(--encre-douce); margin-top: 2px; }
.carte-meta { font-size: 0.7rem; color: var(--encre-pale); margin-top: 3px; font-style: italic; }

.vide {
  padding: 2.5rem 1rem;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.08rem;
  font-style: italic;
  color: var(--encre-pale);
  line-height: 1.6;
}

.seance {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.8rem;
  color: var(--encre-douce);
  border-bottom: 1px dotted rgba(227,210,160,0.85);
}
.seance:last-child { border-bottom: none; }
.seance-type { font-size: 0.72rem; color: var(--encre-pale); }

.compteur {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  font-family: var(--serif);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--paon);
  background: var(--paon-voile);
  border: 1px solid rgba(15,74,76,0.15);
  border-radius: 10px;
}

.type-ligne {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0;
  border-bottom: 1px dotted rgba(227,210,160,0.75);
}
.type-ligne input[type="color"] {
  width: 30px; height: 26px;
  padding: 0;
  border: 1px solid var(--or-pale);
  border-radius: 3px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}
.type-ligne input[type="text"] {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.83rem;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  outline: none;
}
.type-ligne input[type="text"]:focus { border-color: var(--or-pale); background: #fff; }
.type-suppr {
  width: 24px; height: 24px;
  font-size: 0.95rem;
  color: var(--encre-pale);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 3px;
  flex-shrink: 0;
}
.type-suppr:hover { color: #A8412C; background: rgba(168,65,44,0.08); }
.type-suppr:disabled { opacity: .25; cursor: not-allowed; }

#toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 500;
  padding: 0.7rem 1.5rem;
  font-family: var(--serif);
  font-size: 1.02rem;
  color: var(--papier);
  background: var(--paon);
  border: 1px solid var(--or-fonce);
  border-radius: 3px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
#toast.visible { opacity: 1; transform: translateX(-50%); }

/* --- Bandeau hors-ligne --- */
#bandeau-offline {
  display: none;
  position: relative;
  z-index: 4;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  padding-left: calc(var(--reliure) + 1rem);
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #6B4A1E;
  background: linear-gradient(180deg, #F0E2BC, #E9D8AC);
  border-bottom: 1px solid var(--or-fonce);
  flex-shrink: 0;
}
#bandeau-offline.visible { display: flex; }
.pastille-offline {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #B8934A;
  box-shadow: 0 0 0 2px rgba(184,147,74,0.25);
}

/* En lecture seule : on grise le bouton d'ajout */
#carnet.lecture-seule #btnNouveau {
  opacity: .4;
  pointer-events: none;
}

/* Avis dans un formulaire consulté hors-ligne */
.avis-offline {
  padding: 0.7rem 0.9rem;
  margin-top: 1rem;
  font-size: 0.8rem;
  font-style: italic;
  color: #6B4A1E;
  background: rgba(184,147,74,0.12);
  border: 1px solid rgba(184,147,74,0.3);
  border-radius: 3px;
  text-align: center;
}

/* ================================================================
   MOBILE
   ================================================================ */

@media (max-width: 780px) {
  :root { --reliure: 24px; }

  #carnet { padding: 0; }
  .page { border-radius: 0; }
  .filigrane { width: 72%; opacity: .38; }
  .ferret { height: 18px; left: 2px; width: calc(var(--reliure) - 5px); }
  .ferret::after { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; }

  .entete { flex-wrap: wrap; gap: 0.5rem; padding: 0.7rem 0.7rem 0.6rem calc(var(--reliure) + 0.7rem); }
  .marque h1 { font-size: 1.45rem; }
  .marque img { width: 32px; height: 32px; }
  .periode { min-width: 0; font-size: 1rem; }
  .nav-semaine { order: 3; width: 100%; justify-content: center; }
  .entete-actions { gap: 0.3rem; flex-wrap: wrap; }
  .entete-actions .btn { padding: 0.4rem 0.55rem; font-size: 0.72rem; }
  .btn-seg.btn-rond { width: 26px; height: 26px; }

  #carnet.mode-jour .jours-entete,
  #carnet.mode-jour .grille { grid-template-columns: 44px minmax(0, 1fr); }
  #carnet.mode-jour .jour-num { font-size: 1.7rem; }

  .legende { padding-left: calc(var(--reliure) + 0.7rem); gap: 0.1rem 0.7rem; }
  .legende-item { font-size: 0.65rem; }

  .grille-zone { padding: 0 0.5rem 1rem calc(var(--reliure) + 0.2rem); overflow-x: auto; }
  .grille, .jours-entete { grid-template-columns: 34px repeat(var(--nb-jours, 6), minmax(58px, 1fr)); }
  .jour-num { font-size: 1.3rem; }
  .jour-nom { font-size: 0.54rem; letter-spacing: 0.1em; }
  .heure { font-size: 0.76rem; padding-right: 0.3rem; }
  .bloc-titre { font-size: 0.68rem; }
  .bloc-heure { font-size: 0.55rem; }
  .bloc-note { display: none; }

  /* En vue jour (défaut mobile) : pleine largeur, blocs confortables */
  #carnet.mode-jour .grille-zone { overflow-x: hidden; }
  #carnet.mode-jour .grille,
  #carnet.mode-jour .jours-entete { grid-template-columns: 46px minmax(0, 1fr); }
  #carnet.mode-jour .bloc-note { display: block; }
  #carnet.mode-jour .bloc { padding: 6px 10px; }
  #carnet.mode-jour .bloc-titre { font-size: 0.9rem; }
  #carnet.mode-jour .bloc-heure { font-size: 0.62rem; }

  /* Cible tactile plus grande pour les boutons */
  .entete-actions .btn { padding: 0.5rem 0.6rem; }
  .btn-rond { width: 34px; height: 34px; }
  .ruban { padding: 0.5rem 0.9rem; }

  /* Priorité aux actions utiles ; on garde vue + ajout, on cache le zoom fin */
  #grpZoom { display: none; }

  .volet { width: 100%; }

  .couverture-carte { height: min(620px, 90vh); }
  .couv-inner { left: 36px; right: 24px; top: 28px; bottom: 24px; }
  .couv-titre { font-size: 2.3rem; }
  .couv-paon { width: 92%; margin-top: 8px; }
  .couv-eyebrow { font-size: 0.6rem; letter-spacing: 0.3em; }
  .ecoincon { width: 30px; height: 30px; }
  .ec-hg { left: 26px; top: 16px; }
  .ec-hd { right: 16px; top: 16px; }
  .ec-bg { left: 26px; bottom: 16px; }
  .ec-bd { right: 16px; bottom: 16px; }
  .couv-cadre { left: 24px; right: 14px; top: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
