/* ============================================================
   Agenda — couverture cuir marron, StPageFlip
   ============================================================ */

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

body {
  font-family: 'Georgia', 'Garamond', serif;
  color: #2a1f15;
  background: radial-gradient(ellipse at center, #3a2a1a 0%, #1a0f08 80%), #1a0f08;
  min-height: 100vh;
  overflow: hidden;
}

/* ---------- LOGIN ---------- */
body.login-page { display: flex; align-items: center; justify-content: center; }
.login-box {
  background: #fbf6ea;
  border-radius: 8px;
  padding: 2rem 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  width: 340px;
  max-width: 90%;
  border: 1px solid #c9b88c;
}
.login-box h1 { margin: 0 0 .2rem; text-align: center; font-size: 1.8rem; color: #4a2e1a; letter-spacing: .08em; }
.login-box .sub { text-align: center; color: #7b6242; margin: 0 0 1.3rem; font-size: .88rem; }
.login-box label { display: block; margin-bottom: .8rem; font-size: .85rem; color: #5a4730; }
.login-box input {
  display: block; width: 100%; margin-top: .25rem;
  padding: .5rem .7rem; border: 1px solid #c9b88c;
  border-radius: 4px; background: #fffdf5;
  font-size: .95rem; font-family: inherit;
}
.login-box button {
  width: 100%; padding: .6rem;
  background: #4a2e1a; color: #fbf6ea;
  border: none; border-radius: 4px;
  font-size: 1rem; font-family: inherit;
  cursor: pointer; letter-spacing: .05em; margin-top: .5rem;
}
.login-box button:hover { background: #5a3a22; }
.login-box .error {
  background: #f8d7d7; color: #7b2b2b;
  padding: .5rem .7rem; border-radius: 4px;
  font-size: .85rem; margin-bottom: 1rem;
  border-left: 3px solid #c04040;
}

/* ---------- DESK ---------- */
body.desk {
  background: radial-gradient(ellipse at 50% 40%, #5a3a22 0%, #2a1a0c 70%, #0f0805 100%);
}

.desk-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: .6rem 1.2rem;
  display: flex; justify-content: space-between; align-items: center;
  color: #c9b88c;
  font-size: .85rem;
  z-index: 100;
  pointer-events: none;
}
.desk-topbar .welcome { font-style: italic; }
.desk-topbar .logout {
  color: #c9b88c; text-decoration: none;
  border: 1px solid #6a4a2a;
  padding: .25rem .7rem;
  border-radius: 3px;
  font-size: .78rem;
  pointer-events: auto;
  transition: background .2s;
}
.desk-topbar .logout:hover { background: rgba(201,184,140,.15); }

#book-stage {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 2rem;
}

#book {
  position: relative;
  margin: 0 auto;
}

/* Une .page = un div que StPageFlip prendra en charge */
.page {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0 6px 6px 0;
}

/* ---------- COUVERTURE CUIR ---------- */
.page-cover { padding: 0; }
.leather {
  width: 100%;
  height: 100%;
  position: relative;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(255,220,180,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(0,0,0,.25) 0%, transparent 50%),
    linear-gradient(135deg, #4a2818 0%, #3a1e10 50%, #2a1408 100%);
  box-shadow:
    inset 0 0 80px rgba(0,0,0,.5),
    inset 0 0 20px rgba(100,60,30,.3);
  overflow: hidden;
}
.leather::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.05  0 0 0 0 0.02  0 0 0 .35 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: .5;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.stitch {
  position: absolute;
  inset: 18px;
  border: 1.5px dashed #c9a76a;
  border-radius: 4px;
  opacity: .65;
  pointer-events: none;
}

.emboss {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #d4a85c;
  text-shadow: 0 1px 0 rgba(255,220,150,.4), 0 -1px 0 rgba(0,0,0,.6), 0 0 20px rgba(212,168,92,.25);
  letter-spacing: .25em;
  user-select: none;
  pointer-events: none;
}
.emboss-title {
  display: block;
  font-size: 3rem;
  font-family: 'Georgia', serif;
  font-weight: bold;
  font-variant: small-caps;
  margin-bottom: .4rem;
}
.emboss-year {
  display: block;
  font-size: 1.2rem;
  letter-spacing: .5em;
  opacity: .85;
}

.corner {
  position: absolute;
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #c9a76a 0%, #8a6a3a 100%);
  opacity: .55;
  pointer-events: none;
}
.corner.tl { top: 6px; left: 6px; border-radius: 4px 0 40% 0; }
.corner.tr { top: 6px; right: 6px; border-radius: 0 10px 0 40%; }
.corner.bl { bottom: 6px; left: 6px; border-radius: 0 40% 0 4px; }
.corner.br { bottom: 6px; right: 6px; border-radius: 40% 0 10px 0; }

.ribbon {
  position: absolute;
  top: 0;
  right: 48px;
  width: 18px;
  height: 108%;
  background: linear-gradient(to bottom, #a01818 0%, #7a1010 50%, #5a0808 100%);
  box-shadow: 2px 0 6px rgba(0,0,0,.5);
  z-index: 3;
}
.ribbon::after {
  content: "";
  position: absolute;
  bottom: -12px; left: 0; right: 0;
  height: 18px;
  background:
    linear-gradient(135deg, transparent 50%, #7a1010 50%),
    linear-gradient(-135deg, transparent 50%, #7a1010 50%);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  background-position: left, right;
}

.leather-back .emboss,
.leather-back .ribbon { display: none; }

/* ---------- PAGES INTÉRIEURES ---------- */
.page-day,
.page-title,
.page-liner,
.page-month {
  background:
    linear-gradient(to right, rgba(0,0,0,.12) 0%, transparent 3%),
    repeating-linear-gradient(to bottom, #fbf6ea 0, #fbf6ea 38px, #f6eed8 38px, #f6eed8 39px),
    #fbf6ea;
}

.page-liner {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(200,160,100,.18) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(150,100,60,.12) 0%, transparent 50%),
    linear-gradient(135deg, #f0e4c6 0%, #e8d9b4 100%);
}
.liner-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.liner-note {
  text-align: center;
  font-style: italic;
  color: #6a4a2a;
  font-size: 1rem;
  line-height: 1.6;
}
.liner-note strong {
  display: inline-block;
  margin-top: .4rem;
  font-size: 1.2rem;
  color: #4a2818;
  font-style: normal;
  font-variant: small-caps;
  letter-spacing: .1em;
}

.sheet-inner { padding: 2.2rem 2rem 1.5rem 2.4rem; height: 100%; position: relative; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }

.sheet-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.title-year {
  font-size: 5rem;
  font-weight: bold;
  color: #7a1010;
  margin: 0;
  letter-spacing: .15em;
  text-shadow: 1px 1px 0 rgba(0,0,0,.1);
}
.title-sub {
  font-size: 1.3rem;
  color: #6a5232;
  font-variant: small-caps;
  letter-spacing: .3em;
  margin: .5rem 0 0;
}

.sheet-head {
  border-bottom: 2px double #b8a370;
  padding-bottom: .7rem;
  margin-bottom: 1rem;
}
.date-block { display: flex; align-items: baseline; gap: .9rem; }
.date-block .weekday {
  font-size: 1.2rem;
  color: #4a2e1a;
  font-variant: small-caps;
  letter-spacing: .1em;
}
.date-block .day-num {
  font-size: 2.6rem;
  font-weight: bold;
  color: #7a1010;
}
.date-block .month-year {
  font-size: .95rem;
  color: #6a5232;
  font-style: italic;
}

.hour-grid { display: flex; flex-direction: column; gap: 0; }
.hour-row {
  display: flex;
  align-items: center;
  height: 32px;
  gap: .6rem;
}
.hour-label {
  width: 36px;
  font-size: .78rem;
  color: #9a7a4a;
  text-align: right;
  font-variant: tabular-nums;
  font-weight: bold;
}
.hour-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, #b8a370 0%, #d4c590 40%, transparent 100%);
}

/* ---------- NAVIGATION ---------- */
#book-controls {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.2rem;
  z-index: 50;
}
.nav-btn {
  background: rgba(30,18,10,.85);
  color: #d4a85c;
  border: 1px solid #6a4a2a;
  font-size: 1.3rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  transition: background .2s, transform .1s;
  font-family: inherit;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:hover { background: rgba(74,46,26,.95); transform: scale(1.05); }
.nav-btn:active { transform: scale(.95); }

#page-indicator {
  color: #c9b88c;
  font-size: .85rem;
  font-variant: tabular-nums;
  letter-spacing: .1em;
  min-width: 60px;
  text-align: center;
}

/* StPageFlip */
.stf__parent { margin: 0 auto; }

/* ============================================================
   Événements
   ============================================================ */

/* Zone événements "toute la journée" */
.allday-zone {
  min-height: 10px;
  margin-bottom: .4rem;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  cursor: pointer;
}
.allday-zone:empty::before {
  content: "+ journée";
  color: #b8a370;
  font-size: .7rem;
  font-style: italic;
  opacity: .4;
  padding: 2px 6px;
}
.evt-chip {
  padding: 2px 8px;
  border-radius: 10px;
  color: #fffdf5;
  font-size: .75rem;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.evt-chip:hover { filter: brightness(1.12); }

/* Grille heures : conteneur relatif pour layer événements */
.hour-grid {
  position: relative;
}
.events-layer {
  position: absolute;
  top: 0;
  left: 46px;           /* après le label d'heure */
  right: 4px;
  bottom: 0;
  pointer-events: none; /* les rows sont cliquables ; les brackets réactivent pointer-events */
}

.hour-row { cursor: pointer; }
.hour-row:hover .hour-line {
  background: linear-gradient(to right, #d4a85c 0%, #d4c590 40%, transparent 100%);
}

/* Accolade / bracket événement */
.evt-bracket {
  position: absolute;
  left: 0;
  right: 0;
  padding-left: 14px;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: stretch;
}
.evt-bracket .evt-bar {
  position: absolute;
  left: 2px;
  top: 2px;
  bottom: 2px;
  width: 8px;
  background: var(--evt-color);
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.15),
    0 1px 2px rgba(0,0,0,.2);
}
/* Accolade : pattes en haut et bas qui dépassent, façon crochet */
.evt-bracket .evt-bar::before,
.evt-bracket .evt-bar::after {
  content: "";
  position: absolute;
  left: -2px;
  width: 12px;
  height: 3px;
  background: var(--evt-color);
  border-radius: 2px;
}
.evt-bracket .evt-bar::before { top: 0; }
.evt-bracket .evt-bar::after  { bottom: 0; }

.evt-bracket .evt-body {
  margin-left: 14px;
  background: rgba(255,255,255,.55);
  border-left: 2px solid var(--evt-color);
  border-radius: 0 3px 3px 0;
  padding: 2px 6px;
  font-size: .78rem;
  line-height: 1.2;
  overflow: hidden;
  width: calc(100% - 14px);
}
.evt-bracket .evt-title {
  display: block;
  color: #2a1f15;
  font-weight: bold;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.evt-bracket .evt-time {
  display: block;
  font-size: .68rem;
  color: #6a5232;
  font-variant: tabular-nums;
}
.evt-bracket:hover .evt-body {
  background: rgba(255,255,255,.8);
}

/* ---------- MODAL ---------- */
.evt-modal {
  position: fixed;
  inset: 0;
  background: rgba(10,6,3,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.evt-modal[hidden] { display: none; }
.evt-modal-inner {
  background: #fbf6ea;
  border-radius: 8px;
  padding: 1.5rem 1.8rem;
  width: 420px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid #c9b88c;
  box-shadow: 0 25px 70px rgba(0,0,0,.6);
  position: relative;
}
.evt-modal-inner h2 {
  margin: 0 0 1rem;
  color: #4a2818;
  font-size: 1.2rem;
  font-variant: small-caps;
  letter-spacing: .08em;
  border-bottom: 1px solid #c9b88c;
  padding-bottom: .5rem;
}
.evt-close {
  position: absolute;
  top: .6rem;
  right: .8rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #8a6a3a;
  line-height: 1;
}
.evt-close:hover { color: #4a2818; }

.evt-modal-inner label {
  display: block;
  font-size: .82rem;
  color: #5a4730;
  margin-bottom: .7rem;
  font-variant: small-caps;
  letter-spacing: .05em;
}
.evt-modal-inner label.inline {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-variant: normal;
  letter-spacing: 0;
}
.evt-modal-inner input[type="text"],
.evt-modal-inner input[type="date"],
.evt-modal-inner input[type="time"],
.evt-modal-inner textarea {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .45rem .6rem;
  border: 1px solid #c9b88c;
  border-radius: 4px;
  background: #fffdf5;
  font-size: .9rem;
  font-family: inherit;
  color: #2a1f15;
}
.evt-modal-inner textarea { resize: vertical; font-family: inherit; }

.evt-times {
  display: flex;
  gap: .6rem;
}
.evt-times[hidden] { display: none; }
.evt-times label { flex: 1; margin-bottom: .7rem; }

.color-picker {
  display: flex;
  gap: .35rem;
  margin-top: .25rem;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform .15s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected {
  border-color: #2a1f15;
  box-shadow: 0 0 0 2px #fbf6ea, 0 0 0 3px #2a1f15;
}

.evt-actions {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  margin-top: 1rem;
}
.btn-primary, .btn-danger {
  padding: .55rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: .05em;
}
.btn-primary {
  background: #4a2818;
  color: #fbf6ea;
}
.btn-primary:hover { background: #5a3622; }
.btn-danger {
  background: transparent;
  color: #7a1010;
  border: 1px solid #7a1010;
}
.btn-danger:hover { background: #7a1010; color: #fbf6ea; }

.evt-error {
  background: #f8d7d7;
  color: #7b2b2b;
  padding: .4rem .6rem;
  border-radius: 4px;
  font-size: .82rem;
  margin-top: .6rem;
  border-left: 3px solid #c04040;
}

/* ============================================================
   Topbar : navigation semaine
   ============================================================ */
.desk-topbar .topbar-left {
  display: flex;
  gap: .5rem;
  align-items: center;
  pointer-events: auto;
}
.nav-week {
  color: #c9b88c;
  text-decoration: none;
  border: 1px solid #6a4a2a;
  padding: .2rem .6rem;
  border-radius: 3px;
  font-size: .75rem;
  letter-spacing: .05em;
  transition: background .2s;
}
.nav-week:hover { background: rgba(201,184,140,.15); }
.nav-week.today-link {
  color: #fbf6ea;
  background: rgba(122, 16, 16, .5);
  border-color: #7a1010;
}
.nav-week.today-link:hover { background: rgba(122, 16, 16, .75); }

/* ============================================================
   Page vue mois
   ============================================================ */
.page-month { }

.sheet-month .month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-top: .8rem;
}
.sheet-month .dow {
  text-align: center;
  font-size: .72rem;
  font-variant: small-caps;
  color: #7a1010;
  font-weight: bold;
  padding: 3px 0;
  border-bottom: 1px solid #b8a370;
  letter-spacing: .1em;
}
.sheet-month .mday {
  min-height: 56px;
  padding: 3px 4px;
  border: 1px solid rgba(184, 163, 112, .3);
  border-radius: 3px;
  background: rgba(255, 253, 245, .4);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  transition: background .15s, transform .1s;
}
.sheet-month .mday:hover {
  background: rgba(255, 253, 245, .85);
  transform: scale(1.03);
  z-index: 2;
}
.sheet-month .mday.empty {
  cursor: default;
  background: transparent;
  border-color: transparent;
}
.sheet-month .mday.empty:hover { background: transparent; transform: none; }
.sheet-month .mday.today {
  background: rgba(122, 16, 16, .08);
  border-color: #7a1010;
}
.sheet-month .mday.today .mday-num {
  color: #7a1010;
  font-weight: bold;
}
.sheet-month .mday.in-range {
  box-shadow: inset 0 0 0 2px #c9a76a;
  background: rgba(201, 167, 106, .12);
}
.sheet-month .mday-num {
  font-size: .85rem;
  color: #4a2e1a;
  font-variant: tabular-nums;
  line-height: 1;
  padding: 1px 0;
}
.sheet-month .mday-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: auto;
  padding: 2px 0 1px;
}
.mdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.mdot-more {
  font-size: .6rem;
  color: #7b6242;
  font-weight: bold;
}

/* ============================================================
   Partage + badges
   ============================================================ */
.share-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .3rem;
}
.share-chk {
  display: inline-flex !important;
  align-items: center;
  gap: .25rem;
  font-size: .82rem;
  font-variant: normal !important;
  letter-spacing: 0 !important;
  padding: 3px 8px;
  background: #fffdf5;
  border: 1px solid #c9b88c;
  border-radius: 12px;
  cursor: pointer;
  color: #4a2e1a;
  margin: 0 !important;
}
.share-chk:has(input:checked) {
  background: #f0e4c6;
  border-color: #8a6a3a;
}
.share-chk input { cursor: pointer; }
.share-list .muted {
  color: #9a7a4a;
  font-size: .8rem;
  padding: 3px 0;
}

/* Événement partagé (pas propriétaire) */
.evt-bracket.shared .evt-body {
  background: repeating-linear-gradient(135deg,
    rgba(255,255,255,.55) 0,
    rgba(255,255,255,.55) 6px,
    rgba(255,255,255,.4) 6px,
    rgba(255,255,255,.4) 12px);
  font-style: italic;
}
.evt-bracket.shared .evt-owner {
  display: block;
  font-size: .62rem;
  color: #7a1010;
  font-style: normal;
}
.evt-chip.shared {
  outline: 1px dashed rgba(255,255,255,.8);
  outline-offset: -3px;
}

/* ============================================================
   Admin page
   ============================================================ */
body.admin-page {
  background: radial-gradient(ellipse at 50% 40%, #5a3a22 0%, #2a1a0c 70%, #0f0805 100%);
  color: #2a1f15;
  overflow: auto;
  min-height: 100vh;
}
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: #1a0f08;
  color: #c9b88c;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.admin-head h1 {
  margin: 0;
  font-size: 1.3rem;
  font-variant: small-caps;
  letter-spacing: .1em;
}
.admin-head nav { display: flex; gap: 1rem; }
.admin-head nav a {
  color: #c9b88c;
  text-decoration: none;
  font-size: .85rem;
  border: 1px solid #6a4a2a;
  padding: .3rem .8rem;
  border-radius: 3px;
}
.admin-head nav a:hover { background: rgba(201,184,140,.15); }

.admin-main {
  max-width: 900px;
  margin: 2rem auto;
  background: #fbf6ea;
  border-radius: 8px;
  padding: 1.5rem 2rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.admin-intro {
  color: #7b6242;
  font-size: .88rem;
  margin: 0 0 1rem;
  font-style: italic;
}
.admin-msg {
  background: #d8efd8;
  color: #2a5a2a;
  padding: .6rem 1rem;
  border-radius: 4px;
  border-left: 3px solid #4a7a2a;
  margin-bottom: 1rem;
  font-size: .9rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.admin-table th, .admin-table td {
  padding: .6rem .7rem;
  text-align: left;
  border-bottom: 1px solid #e4d8b4;
}
.admin-table th {
  background: #f0e4c6;
  color: #4a2818;
  font-variant: small-caps;
  font-size: .8rem;
  letter-spacing: .05em;
}
.admin-table tr.row-invited { background: rgba(201, 167, 106, .1); }
.admin-table tr.row-inactive { opacity: .5; }
.admin-table .ok { color: #4a7a2a; font-weight: bold; }
.admin-table .ko { color: #b8a370; }

.btn-sm {
  padding: .3rem .7rem !important;
  font-size: .78rem !important;
}

/* ============================================================
   Récurrence
   ============================================================ */
.evt-recurrence {
  display: flex;
  gap: .6rem;
  margin-bottom: .7rem;
}
.evt-recurrence label { flex: 1; margin-bottom: 0; }
.evt-recurrence select {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .45rem .6rem;
  border: 1px solid #c9b88c;
  border-radius: 4px;
  background: #fffdf5;
  font-size: .9rem;
  font-family: inherit;
  color: #2a1f15;
}
#evt-rec-end-lbl[hidden] { display: none; }

.evt-rec-icon {
  display: inline-block;
  margin-right: 3px;
  font-size: .72rem;
  vertical-align: baseline;
}

.evt-chip.recurring {
  box-shadow:
    0 1px 2px rgba(0,0,0,.2),
    inset 0 0 0 1px rgba(255,255,255,.4);
}

/* ============================================================
   Modal iCal
   ============================================================ */
.ical-intro {
  color: #7b6242;
  font-size: .85rem;
  margin: 0 0 1rem;
}
#ical-url {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .5rem .7rem;
  border: 1px solid #c9b88c;
  border-radius: 4px;
  background: #fffdf5;
  font-family: 'Courier New', monospace;
  font-size: .78rem;
  color: #2a1f15;
}
.ical-actions {
  display: flex;
  gap: .6rem;
  margin-top: .7rem;
  margin-bottom: 1rem;
}
.ical-help {
  font-size: .78rem;
  color: #7b6242;
  line-height: 1.7;
  background: #f0e4c6;
  padding: .7rem .9rem;
  border-radius: 4px;
  border-left: 3px solid #b8a370;
  margin: 0;
}
.ical-help strong { color: #4a2818; }

#ical-btn {
  background: none;
  cursor: pointer;
}

/* ============================================================
   Phase 6c — Bureau multi-carnets
   ============================================================ */

body.bureau {
  overflow: auto;
  display: block;
}
.bureau-stage {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
  color: #f0e4c6;
}
.bureau-title {
  text-align: center;
  font-size: 2.4rem;
  letter-spacing: .15em;
  margin: 0 0 .3rem;
  font-variant: small-caps;
  color: #d4a85c;
  text-shadow: 0 1px 0 rgba(255,220,150,.3), 0 -1px 0 rgba(0,0,0,.6);
}
.bureau-sub {
  text-align: center;
  margin: 0 0 2.5rem;
  color: #c9b88c;
  letter-spacing: .08em;
}
.bureau-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
  justify-items: center;
}
.bureau-book {
  position: relative;
  width: 200px;
  height: 280px;
  transition: transform .18s;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.bureau-book:hover { transform: translateY(-4px) rotate(-1deg); }
.book-cover-link { text-decoration: none; color: inherit; display: block; height: 100%; }
.book-cover {
  --cover-color: #4a2818;
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px 6px 6px 4px;
  background:
    radial-gradient(ellipse at 30% 25%, rgba(255,220,180,.1) 0%, transparent 60%),
    radial-gradient(ellipse at 75% 80%, rgba(0,0,0,.3) 0%, transparent 50%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--cover-color), #fff 8%) 0%,
      var(--cover-color) 45%,
      color-mix(in srgb, var(--cover-color), #000 35%) 100%);
  box-shadow:
    4px 6px 14px rgba(0,0,0,.55),
    inset 0 0 40px rgba(0,0,0,.35),
    inset -4px 0 10px rgba(0,0,0,.4);
  border-left: 6px solid color-mix(in srgb, var(--cover-color), #000 55%);
  overflow: hidden;
}
.book-cover::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.05  0 0 0 0 0.02  0 0 0 .35 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: .45;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.book-stitch {
  position: absolute; inset: 14px;
  border: 1.2px dashed rgba(201,167,106,.55);
  border-radius: 3px;
  pointer-events: none;
}
.book-emboss {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  color: #d4a85c;
  text-shadow: 0 1px 0 rgba(255,220,150,.35), 0 -1px 0 rgba(0,0,0,.55);
  padding: 0 1rem;
  pointer-events: none;
}
.book-name {
  font-size: 1.2rem;
  font-weight: bold;
  font-variant: small-caps;
  letter-spacing: .12em;
  margin-bottom: .4rem;
  word-break: break-word;
  line-height: 1.2;
}
.book-badge {
  font-size: .7rem;
  letter-spacing: .18em;
  opacity: .75;
}
.book-count {
  position: absolute;
  bottom: 14px; left: 0; right: 0;
  text-align: center;
  font-size: .72rem;
  color: #c9a76a;
  letter-spacing: .08em;
  opacity: .85;
  pointer-events: none;
}
.book-corner {
  position: absolute;
  width: 22px; height: 22px;
  background: linear-gradient(135deg, #c9a76a 0%, #8a6a3a 100%);
  opacity: .5;
  pointer-events: none;
}
.book-corner.tl { top: 5px; left: 5px; border-radius: 3px 0 30% 0; }
.book-corner.tr { top: 5px; right: 5px; border-radius: 0 6px 0 30%; }
.book-corner.bl { bottom: 5px; left: 5px; border-radius: 0 30% 0 3px; }
.book-corner.br { bottom: 5px; right: 5px; border-radius: 30% 0 6px 0; }

.book-settings {
  position: absolute;
  top: 6px; right: 6px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(201,167,106,.4);
  background: rgba(30,18,10,.8);
  color: #c9a76a;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  z-index: 3;
}
.bureau-book:hover .book-settings { opacity: 1; }
.book-settings:hover { background: #c9a76a; color: #2a1408; transform: rotate(45deg); }

.bureau-add {
  border: 2px dashed rgba(201,167,106,.4);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #c9a76a;
  background: rgba(30,18,10,.3);
  cursor: pointer;
  font-family: inherit;
}
.bureau-add:hover {
  background: rgba(50,30,18,.5);
  border-color: #c9a76a;
  color: #d4a85c;
  transform: translateY(-4px);
}
.bureau-add .add-plus { font-size: 3rem; line-height: 1; margin-bottom: .5rem; }
.bureau-add .add-label { letter-spacing: .1em; font-variant: small-caps; }

/* Leather intérieur : support --cover-color comme override */
.leather {
  --cover-color: #4a2818;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(255,220,180,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(0,0,0,.25) 0%, transparent 50%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--cover-color), #fff 6%) 0%,
      var(--cover-color) 50%,
      color-mix(in srgb, var(--cover-color), #000 35%) 100%);
}

/* Header : label du carnet */
.notebook-label {
  --cover-color: #4a2818;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: #f0e4c6;
  font-size: .95rem;
  letter-spacing: .05em;
  padding: .3rem .7rem;
  background: rgba(30,18,10,.5);
  border-radius: 4px;
  border: 1px solid rgba(201,167,106,.3);
}
.notebook-chip {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  background: var(--cover-color);
  box-shadow: 0 0 0 1px rgba(201,167,106,.4), inset 0 1px 2px rgba(0,0,0,.4);
}
.notebook-role-badge {
  font-size: .72rem;
  opacity: .75;
  letter-spacing: .05em;
  padding-left: .5rem;
  border-left: 1px solid rgba(201,167,106,.3);
  margin-left: .3rem;
}
.back-bureau {
  background: rgba(74,46,26,.6) !important;
  border: 1px solid #c9a76a !important;
  color: #d4a85c !important;
}
.back-bureau:hover { background: #4a2e1a !important; }

/* Modal carnet : lignes de partage */
.nb-share-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 280px;
  overflow-y: auto;
  padding: .5rem;
  background: #fffdf5;
  border: 1px solid #c9b88c;
  border-radius: 4px;
}
.nb-share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .3rem .4rem;
  border-bottom: 1px dashed rgba(201,167,106,.3);
}
.nb-share-row:last-child { border-bottom: none; }
.nb-share-row label {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  font-size: .9rem;
}
.nb-share-edit-lbl {
  font-size: .8rem;
  color: #7b6242;
}
#nb-color {
  width: 60px;
  height: 34px;
  border: 1px solid #c9b88c;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
}

/* Onglet-ruban latéral pour la page mois */
.book-bookmark {
  position: absolute;
  right: 8px;
  top: 110px;
  background: linear-gradient(90deg, #5a0808 0%, #7a1010 50%, #5a0808 100%);
  color: #f0e4c6;
  border: 1px solid #3a0505;
  border-radius: 0 0 8px 8px;
  padding: 10px 6px 12px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  box-shadow: 2px 3px 8px rgba(0,0,0,.35);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1;
}
.book-bookmark:hover {
  background: linear-gradient(90deg, #6a1414 0%, #8a1a1a 50%, #6a1414 100%);
  transform: translateY(2px);
}
.book-bookmark span {
  font-size: .62rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: .85;
}
@media (max-width: 640px) {
  .book-bookmark { right: 2px; top: 70px; padding: 6px 4px 8px; font-size: .95rem; }
  .book-bookmark span { font-size: .55rem; }
}

/* ===================== MODE MOBILE ===================== */
@media (max-width: 900px) {
  body.mobile-mode { overflow: hidden; }

  body.mobile-mode .desk-topbar {
    padding: .4rem .6rem;
    gap: .4rem;
    flex-wrap: wrap;
    min-height: 44px;
  }
  body.mobile-mode .desk-topbar .notebook-label { font-size: .85rem; }
  body.mobile-mode .desk-topbar .notebook-role-badge { display: none; }
  body.mobile-mode .desk-topbar .nav-week,
  body.mobile-mode .desk-topbar .logout { padding: .2rem .5rem; font-size: .72rem; }

  body.mobile-mode {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }
  body.mobile-mode .desk-topbar {
    flex: 0 0 auto;
    position: relative;
    z-index: 50;
  }
  body.mobile-mode #book-stage {
    padding: 0;
    width: 100vw;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: block;
  }

  body.mobile-mode #book {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    width: 100vw;
    height: 100%;
    background: #2a1f15;
    margin: 0;
  }

  body.mobile-mode #book .page {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 0;
    box-shadow: none;
    position: relative;
    background-attachment: local;
  }

  body.mobile-mode #book .sheet-inner {
    padding: 1rem .9rem 2rem;
    min-height: 100%;
    height: auto;
    position: relative;
  }

  /* Grille des heures : laisse le scroll vertical libre */
  body.mobile-mode .hour-grid { height: auto; }
  body.mobile-mode .events-layer { pointer-events: auto; }

  body.mobile-mode .book-bookmark {
    position: fixed;
    right: 0;
    top: 50px;
    z-index: 40;
    padding: 8px 5px 10px;
    font-size: 1rem;
  }
  body.mobile-mode .book-bookmark span { font-size: .55rem; }

  /* Vue mois adaptée */
  body.mobile-mode .sheet-month .month-grid { gap: 2px; }
  body.mobile-mode .sheet-month .mday { padding: .2rem; font-size: .78rem; }
  body.mobile-mode .sheet-month .mday-num { font-size: .85rem; }
}

/* ===== Abonnements ICS dans modal carnet ===== */
.nb-ical-hr   { border: none; border-top: 1px solid #c9b88c; margin: 1.5rem 0 1rem; }
.nb-ical-title { font-family: Georgia, serif; color: #4a2818; font-size: 1rem; margin: 0 0 .4rem; }
.nb-ical-add  { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }
.nb-ical-add input[type="text"]  { flex: 0 0 140px; }
.nb-ical-add input[type="url"]   { flex: 1 1 220px; min-width: 0; }
.nb-ical-row  { display: flex; align-items: center; gap: .5rem; padding: .5rem 0;
                border-bottom: 1px solid #e8dcc8; }
.nb-ical-info { flex: 1; font-size: .85rem; display: flex; flex-direction: column; gap: 2px; }
.nb-ical-meta { color: #7b6242; font-size: .75rem; }
.nb-ical-err  { color: #b00; font-size: .75rem; }

/* ═══════════════════════════════════════════════════════════
   NOTES — pages libres
   ═══════════════════════════════════════════════════════════ */

.notes-desk { background: var(--desk-bg, #3a2010); }

.notes-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 52px);
  padding: 24px 0;
  box-sizing: border-box;
}

/* Scroll horizontal snap */
.notes-scroll {
  display: flex;
  gap: 32px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  height: 100%;
  padding: 0 48px;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.notes-scroll::-webkit-scrollbar { height: 6px; }
.notes-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }

/* Page note */
.note-page {
  flex: 0 0 auto;
  scroll-snap-align: center;
  width: min(520px, 88vw);
  height: min(680px, 78vh);
  background: #fdf8ef;
  border-radius: 2px 6px 6px 2px;
  box-shadow: -4px 4px 18px rgba(0,0,0,.45), 2px 2px 6px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s;
  position: relative;
  /* Reliure à gauche */
  border-left: 6px solid #c8a870;
}
.note-page::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(0,0,0,.15);
}
.note-page:hover {
  box-shadow: -6px 6px 24px rgba(0,0,0,.55), 3px 3px 10px rgba(0,0,0,.25);
}

.note-page-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 24px 16px 24px;
  box-sizing: border-box;
}

/* En-tête de la page */
.note-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 1px solid #d4b896;
  padding-bottom: 10px;
}
.note-page-num {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .8rem;
  color: #b09070;
  letter-spacing: .05em;
}
.note-delete-btn {
  background: none;
  border: 1px solid #d4a0a0;
  color: #c07070;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background .15s, color .15s;
}
.note-delete-btn:hover { background: #c07070; color: #fff; border-color: #c07070; }

/* Titre éditable */
.note-title-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.15rem;
  font-weight: bold;
  color: #3a2010;
  padding: 0 0 8px 0;
  border-bottom: 1px dashed #d4b896;
  margin-bottom: 14px;
  box-sizing: border-box;
}
.note-title-input::placeholder { color: #c4a888; font-style: italic; }

/* Contenu éditable — papier ligné */
.note-content-input {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .97rem;
  line-height: 2;
  color: #2a1a08;
  padding: 0;
  box-sizing: border-box;
  /* Lignes de papier */
  background-image: repeating-linear-gradient(
    transparent,
    transparent calc(2em - 1px),
    #e8d8c0 calc(2em - 1px),
    #e8d8c0 2em
  );
  background-attachment: local;
}
.note-content-input::placeholder { color: #c4a888; font-style: italic; }

/* Lecture seule */
.note-title-ro {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.15rem;
  font-weight: bold;
  color: #3a2010;
  padding-bottom: 8px;
  border-bottom: 1px dashed #d4b896;
  margin-bottom: 14px;
}
.note-content-ro {
  flex: 1;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .97rem;
  line-height: 2;
  color: #2a1a08;
  overflow-y: auto;
  background-image: repeating-linear-gradient(transparent, transparent calc(2em - 1px), #e8d8c0 calc(2em - 1px), #e8d8c0 2em);
}

/* Statut sauvegarde */
.note-save-status {
  font-size: .78rem;
  font-family: sans-serif;
  min-height: 1em;
  text-align: right;
  margin-top: 6px;
  color: #7a9c6a;
  transition: opacity .3s;
}

/* Page "+ Nouvelle note" */
.note-add-page {
  background: rgba(255,255,255,.07);
  border: 2px dashed rgba(255,255,255,.25);
  border-left: 6px solid rgba(200,168,112,.4);
  cursor: pointer;
  transition: background .2s, border-color .2s;
  box-shadow: none;
}
.note-add-page:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.45);
  box-shadow: none;
}
.note-add-inner {
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.5);
  gap: 10px;
}

/* État vide */
.notes-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
}
.notes-empty-inner {
  text-align: center;
  color: rgba(255,255,255,.55);
  font-family: Georgia, serif;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.notes-empty-inner .btn-primary {
  margin-top: 8px;
  font-family: sans-serif;
}

/* Bouton dans la topbar */
.topbar-right { margin-left: auto; }

/* Mobile */
@media (max-width: 600px) {
  .notes-scroll { padding: 0 20px; gap: 20px; }
  .note-page { width: 92vw; height: 72vh; border-left-width: 4px; }
  .note-page-inner { padding: 14px 16px 12px; }
}

/* ── Notes link on bureau cards ──────────────────────────── */
.book-notes-link {
  display: block;
  text-align: center;
  margin-top: 4px;
  font-size: .8rem;
  color: var(--text-muted, #888);
  text-decoration: none;
  opacity: 0;
  transition: opacity .2s;
}
.bureau-book:hover .book-notes-link { opacity: 1; }
.notes-badge {
  display: inline-block;
  background: var(--primary, #5c6bc0);
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  font-size: .75rem;
  vertical-align: middle;
}
