/* ==========================================================================
   Calendrier – styles propres à la page (calendrier.php).
   Tout est scopé sous .cal. Les variables et classes partagées du site
   (--white, --line, --shadow, --brand, --font-head, .container, .sr-only…)
   restent dans assets/css/style.css.
   ========================================================================== */

/* ---------- Variables locales ---------- */
.cal *, .cal *::before, .cal *::after { box-sizing: border-box; }
.cal {
  --bg: #ffffff;
  --surface: #f5f7fb;
  --border: #e2e7ef;
  --border2: #c3d0ea;
  --text: #0f1b33;
  --muted: #596378;
  --accent: #1d4ed8;
  --accent2: #173ea8;
  --tint: #eaf0ff;
  --danger: #b42318;
  --now: #dc2626;
  --radius: 10px;
  --side: 272px;
  --hh: 48px;
  --hover: #fafbfe;
  --todaycol: #f7faff;
  --errbg: #fef3f2;
  --errbd: #f0c4bf;
  --holtext: #7f1d1d;
  font-family: var(--font-body, 'Instrument Sans', system-ui, sans-serif);
  color: var(--text);
}
.cal :is(h1, h2, h3, p, ul, ol) { margin: 0; padding: 0; }
.cal :is(ul, ol) { list-style: none; }
.cal button { font: inherit; color: inherit; cursor: pointer; }
.cal button:disabled { cursor: default; opacity: .45; }
.cal :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Carte de l'application ---------- */
.cal-wrap { padding: var(--app-gutter, 24px) 0; }
.cal-app {
  display: flex; flex-direction: column;
  height: calc(100vh - 2 * var(--app-gutter, 24px));
  height: calc(100dvh - 2 * var(--app-gutter, 24px));
  min-height: 480px;
  background: var(--white, #fff); border: 1px solid var(--line, var(--border)); border-radius: 20px;
  box-shadow: var(--shadow); overflow: hidden;
}

/* L'attribut hidden doit toujours gagner (sinon .cal-btn { display:inline-flex } l'écrase :
   Supprimer, Dupliquer, Rejoindre et Écrire aux invités restaient visibles en permanence). */
.cal [hidden] { display: none !important; }

/* ---------- Boutons ---------- */
.cal .cal-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border: 1px solid var(--border2); border-radius: 9px;
  background: var(--bg); font-size: .875rem; font-weight: 500; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.cal .cal-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.cal .cal-btn-sm { height: 32px; padding: 0 12px; font-size: .82rem; }
.cal .cal-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cal .cal-btn-primary:hover:not(:disabled) { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.cal .cal-btn-danger { color: var(--danger); border-color: var(--errbd); }
.cal .cal-btn-danger:hover:not(:disabled) { background: var(--errbg); border-color: var(--danger); color: var(--danger); }
.cal .cal-ico {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  transition: background-color .15s, color .15s;
}
.cal .cal-ico:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.cal .cal-ico-sm { width: 28px; height: 28px; border-radius: 7px; }

/* ---------- Barre d'outils ---------- */
.cal-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.cal-nav { display: flex; gap: 2px; }
.cal .cal-title {
  font-family: var(--font-head, 'Bricolage Grotesque', sans-serif); font-size: 1.3rem; font-weight: 700;
  letter-spacing: -.01em; margin-left: 6px; white-space: nowrap;
}
.cal-bar-end { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-left: auto; }
.cal .cal-search {
  width: 210px; height: 36px; padding: 0 12px; border: 1px solid var(--border2); border-radius: 9px;
  font: inherit; font-size: .875rem; background: var(--bg); color: var(--text);
}
.cal .cal-search::placeholder { color: var(--muted); }
.cal-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.cal-seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; font-size: .84rem; font-weight: 500; color: var(--muted); }
.cal-seg button:hover { color: var(--text); }
.cal-seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 27, 51, .12); }

/* ---------- Corps : barre latérale + zone principale ---------- */
.cal-body { flex: 1; min-height: 0; display: flex; position: relative; overflow: hidden; }
.cal-side {
  width: var(--side); flex: none; display: flex; flex-direction: column; gap: 18px;
  padding: 16px 14px; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border);
  transition: width .25s ease, padding .25s ease, visibility 0s linear 0s;
}
.cal-body.is-collapsed .cal-side {
  width: 0; padding-inline: 0; overflow: hidden; border-right-color: transparent;
  visibility: hidden; transition: width .25s ease, padding .25s ease, visibility 0s linear .25s;
}
.cal-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.cal .noscript-msg { margin: 16px 24px; padding: 12px 16px; text-align: center; border: 1px solid var(--accent2); border-radius: var(--radius); background: var(--surface); font-size: .85rem; line-height: 1.55; }

.side-block h3 { font-size: .85rem; font-weight: 600; font-family: var(--font-body, inherit); letter-spacing: 0; color: var(--text); }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.side-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.side-privacy { margin-top: auto; font-size: .74rem; line-height: 1.5; color: var(--muted); }
.side-privacy strong { color: var(--text); }

/* mini-calendrier */
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: .88rem; }
.mini-head > span { display: flex; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px 0; text-align: center; }
.mini-grid i { font-style: normal; font-size: .68rem; color: var(--muted); padding: 2px 0 4px; }
.cal .mini-d {
  position: relative; height: 30px; border: 0; background: transparent; border-radius: 8px;
  font-size: .78rem; font-variant-numeric: tabular-nums;
}
.cal .mini-d:hover { background: var(--border); }
.cal .mini-d.is-other { color: var(--muted); opacity: .65; }
.cal .mini-d.is-sel { background: var(--tint); font-weight: 600; }
.cal .mini-d.is-today { background: var(--accent); color: #fff; font-weight: 600; opacity: 1; }
.cal .mini-d.has-ev::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.cal .mini-d.is-today.has-ev::after { background: #fff; }

/* liste des calendriers */
.cal-list { display: grid; gap: 2px; }
.cl { display: flex; align-items: center; gap: 4px; }
.cl-chk { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-size: .86rem; }
.cl-chk:hover { background: var(--border); }
.cl-chk input { position: absolute; opacity: 0; pointer-events: none; }
.cl-sw { flex: none; width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--c); background: transparent; transition: background-color .12s; }
.cl-chk input:checked + .cl-sw { background: var(--c); }
.cl-chk input:focus-visible + .cl-sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.cl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Vue mois ---------- */
.m { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.m-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.m-head > div { padding: 8px 0; text-align: center; font-size: .8rem; color: var(--muted); font-weight: 500; }
.m-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); }
.m-cell {
  min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 3px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); overflow: hidden; cursor: pointer;
}
.m-cell:nth-child(7n) { border-right: 0; }
.m-cell:hover { background: var(--hover); }
.m-cell.is-other { background: var(--surface); }
.m-cell.is-drop { background: var(--tint); box-shadow: inset 0 0 0 2px var(--accent); }
.cal .m-num {
  align-self: flex-start; display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 4px;
  border: 0; border-radius: 13px; background: transparent; font-size: .85rem; font-variant-numeric: tabular-nums;
}
.cal .m-num:hover { background: var(--border); }
.m-cell.is-other .m-num { color: var(--muted); }
.cal .m-cell.is-today .m-num { background: var(--accent); color: #fff; font-weight: 600; }
.m-evs { display: grid; gap: 2px; min-height: 0; }
.cal .m-more { align-self: flex-start; padding: 0 6px; border: 0; background: none; font-size: .74rem; font-weight: 600; color: var(--muted); }
.cal .m-more:hover { color: var(--accent); }

/* pastilles (mois, jours entiers, agenda) */
.cal .chip {
  display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; padding: 1px 6px;
  border: 0; border-left: 3px solid var(--c); border-radius: 4px;
  background: var(--tint); background: color-mix(in srgb, var(--c) 12%, var(--bg));
  font-size: .76rem; line-height: 1.55; text-align: left; color: var(--text);
}
.cal .chip:hover { background: color-mix(in srgb, var(--c) 22%, var(--bg)); }
.cal .chip-band, .cal .chip-band:hover { background: var(--c); color: #fff; }
.cal .chip-hol, .cal .chip-hol:hover { background: color-mix(in srgb, var(--c) 8%, var(--bg)); color: var(--holtext); font-style: italic; cursor: default; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-t { flex: none; font-style: normal; font-variant-numeric: tabular-nums; color: var(--muted); }
.chip-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cal .chip.is-drag { opacity: .45; }

/* ---------- Vues semaine / jour ---------- */
.g-scroll { flex: 1; min-height: 0; overflow: auto; position: relative; scrollbar-gutter: stable; overscroll-behavior: contain; }
.g-inner { min-width: calc(56px + var(--cols) * 104px); }
.g-top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--border); }
.g-row { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); }
.cal .g-dh {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0 8px; border: 0; border-left: 1px solid var(--border);
  background: transparent; font-size: .8rem; color: var(--muted);
}
.cal .g-dh:hover:not(:disabled) { background: var(--surface); }
.cal .g-dh:disabled { opacity: 1; }
.g-dh b { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; border-radius: 17px; font-family: var(--font-head, inherit); font-size: 1.25rem; font-weight: 600; color: var(--text); }
.cal .g-dh.is-today b { background: var(--accent); color: #fff; }
.cal .g-dh.is-today { color: var(--accent); font-weight: 600; }
.g-lab { align-self: end; padding: 0 8px 4px 0; text-align: right; font-size: .68rem; color: var(--muted); }
.g-ad { display: grid; align-content: start; gap: 2px; min-height: 30px; padding: 2px; border-left: 1px solid var(--border); cursor: pointer; }
.g-alldays { border-top: 1px solid var(--border); }
.g-body { position: relative; }
.g-h { position: relative; height: var(--hh); }
.g-h span { position: absolute; top: -.62em; right: 8px; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-col {
  position: relative; height: calc(var(--hh) * 24); border-left: 1px solid var(--border); cursor: pointer;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hh) - 1px), var(--border) calc(var(--hh) - 1px), var(--border) var(--hh));
}
.g-col.is-today { background-color: var(--todaycol); }
.cal .ev {
  position: absolute; display: flex; flex-direction: column; gap: 0; overflow: hidden; padding: 2px 6px;
  border: 0; border-left: 3px solid var(--c); border-radius: 6px; text-align: left; font-size: .76rem; line-height: 1.3;
  background: var(--tint); background: color-mix(in srgb, var(--c) 14%, var(--bg)); color: var(--text);
}
.cal .ev:hover { background: color-mix(in srgb, var(--c) 24%, var(--bg)); z-index: 2; }
.ev b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev-short { flex-direction: row; align-items: baseline; gap: 6px; padding-block: 0; }
.g-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--now); z-index: 3; pointer-events: none; }
.g-now::before { content: ''; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }

/* ---------- Agenda et recherche ---------- */
.a { flex: 1; overflow-y: auto; padding: 4px 24px 32px; }
.a-day { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.a-date { display: flex; align-items: center; gap: 12px; font: 500 .85rem/1.3 var(--font-body, inherit); letter-spacing: 0; color: var(--muted); }
.a-num { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px; border-radius: 12px; font: 700 1.4rem/1 var(--font-head, inherit); color: var(--text); background: var(--surface); }
.a-day.is-today .a-num { background: var(--accent); color: #fff; }
.a-list { display: grid; gap: 2px; align-content: start; }
.cal .a-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.cal button.a-row:hover { background: var(--surface); }
.a-row.is-hol { color: var(--holtext); font-style: italic; }
.a-time { flex: none; min-width: 92px; white-space: nowrap; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.a-dot { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.a-body { min-width: 0; display: grid; }
.a-body b { font-weight: 600; font-size: .92rem; }
.a-body small { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; color: var(--muted); }

/* ---------- Fenêtres ---------- */
.cal .cal-dlg {
  width: min(580px, calc(100% - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 16px;
  background: var(--bg); color: var(--text); box-shadow: 0 24px 64px -16px rgba(15, 27, 51, .45); overflow: auto;
}
.cal .cal-dlg-sm { width: min(420px, calc(100% - 24px)); }
.cal-dlg::backdrop { background: rgba(15, 27, 51, .45); }
.cal-dlg form { display: grid; gap: 14px; padding: 20px 22px 22px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { font: 700 1.2rem/1.3 var(--font-head, inherit); letter-spacing: -.01em; }
.fld { display: grid; gap: 5px; align-content: start; min-width: 0; border: 0; padding: 0; margin: 0; }
.fld[hidden] { display: none; }
.fld > label, .fld > legend { font-size: .82rem; font-weight: 600; padding: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dt { display: grid; grid-template-columns: minmax(0, 1fr) minmax(112px, 132px); gap: 8px; }
.row-dates { grid-template-columns: minmax(0, 1fr); }
.cal-dlg .is-allday .t-only { display: none; }
.cal-dlg .is-allday .dt { grid-template-columns: 1fr; }
.cal-dlg :is(input[type="text"], input[type="date"], input[type="time"], select, textarea) {
  width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--border2); border-radius: 8px;
  font: inherit; font-size: .9rem; background: var(--bg); color: var(--text);
}
.cal-dlg textarea { resize: vertical; min-height: 64px; }
/* Safari / iPad : les champs date et heure ignorent la largeur de leur colonne et débordent (ils se chevauchent) : on force leur taille. */
.dt > * { min-width: 0; max-width: 100%; }
.cal-dlg :is(input[type="date"], input[type="time"]) { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; min-height: 40px; text-align: left; }
.cal-dlg :is(input[type="date"], input[type="time"])::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.3em; }
.cal-dlg :is(input[type="date"], input[type="time"])::-webkit-datetime-edit { padding: 0; }
.cal-dlg select { min-height: 40px; }
.fld-check { align-content: end; padding-bottom: 8px; }
.cal .check { color: var(--text); }
.cal .rem-add, .cal .fld > .cal-btn { margin-top: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-err { padding: 8px 12px; border-radius: 8px; background: var(--errbg); color: var(--danger); font-size: .86rem; }
.form-err[hidden] { display: none; }
.form-hint { font-size: .8rem; color: var(--muted); }
.dlg-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--border); }
.dlg-foot .grow { flex: 1; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { position: relative; cursor: pointer; }
.sw input { position: absolute; opacity: 0; }
.sw span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--border2); }
.sw input:checked + span { box-shadow: 0 0 0 3px var(--c); }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- Notifications ---------- */
.cal-toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1000; display: grid; gap: 8px; width: max-content; max-width: calc(100% - 24px); }
.toast {
  display: flex; align-items: center; gap: 16px; padding: 11px 16px; border-radius: 11px;
  background: var(--text); color: #fff; font-size: .88rem; box-shadow: 0 12px 32px -8px rgba(15, 27, 51, .5);
}
.toast button { padding: 0; border: 0; background: none; color: #bcd0ff; font-weight: 600; text-decoration: underline; }

/* ---------- Déplacement / redimensionnement (vues semaine et jour) ---------- */
.cal .ev { user-select: none; -webkit-user-select: none; }
.cal .ev .ev-rz { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; }
@media (pointer: fine) {
  .cal .ev { cursor: grab; }
  .cal .ev .ev-rz { cursor: ns-resize; }
}
.cal .ev.is-moving { z-index: 6; opacity: .9; cursor: grabbing; box-shadow: 0 8px 20px -6px rgba(15, 27, 51, .45); }

/* ---------- Fenêtre : portée d'une modification de série ---------- */
.scope-box { display: grid; gap: 14px; padding: 20px 22px 22px; }
.scope-opts { display: grid; gap: 8px; }
.cal .scope-opts .cal-btn { justify-content: flex-start; height: 42px; }

/* ---------- Réglages : numéros de semaine, titres de fenêtre ---------- */
.set-h { margin-top: 4px; font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.m-cell { position: relative; }
.m-wk { position: absolute; top: 7px; right: 6px; font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
.mini-grid.has-wk { grid-template-columns: 24px repeat(7, 1fr); }
.mini-grid .mini-wk { display: flex; align-items: center; justify-content: center; height: 30px; padding: 0; font-size: .66rem; }

/* ---------- Thème sombre (réglage « Thème ») ---------- */
.cal[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121a2b;
  --surface: #182238;
  --border: #28344d;
  --border2: #3a4968;
  --text: #e6ecf8;
  --muted: #9aa7c0;
  --accent: #4a78ec;
  --accent2: #3a66d6;
  --tint: #1c2b50;
  --danger: #f2877d;
  --now: #f87171;
  --hover: #161f33;
  --todaycol: #14203a;
  --errbg: #3a1c1c;
  --errbd: #6b2b27;
  --holtext: #fca5a5;
}
.cal[data-theme="dark"] .cal-app { background: var(--bg); border-color: var(--border); }
.cal[data-theme="dark"] .cal-dlg { border: 1px solid var(--border); }
.cal[data-theme="dark"] .toast { color: var(--bg); }
.cal[data-theme="dark"] .toast button { color: #1d4ed8; }
/* L'introduction reste sur le fond clair du site */

/* ---------- Adaptation ---------- */
@media (max-width: 1100px) {
  .cal .cal-search { width: 160px; }
}
@media (max-width: 860px) {
  .cal-side { position: absolute; inset: 0 auto 0 0; z-index: 20; width: min(var(--side), 88vw); box-shadow: 8px 0 32px -12px rgba(15, 27, 51, .35); }
  .cal-bar-end { margin-left: 0; width: 100%; }
  .cal .cal-search { flex: 1; width: auto; min-width: 120px; }
  .cal .cal-title { font-size: 1.1rem; }
  .a-day { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 640px) {
  .cal-app { height: calc(100vh - 2 * var(--app-gutter, 24px)); height: calc(100dvh - 2 * var(--app-gutter, 24px)); min-height: 480px; border-radius: 14px; }
  .cal-bar { padding: 10px 12px; }
  .cal-seg { flex: 1; }
  .cal-seg button { flex: 1; padding: 0 6px; }
  .cal .cal-btn-primary { flex: none; }
  .m-cell { padding: 2px; }
  .cal .chip { font-size: .7rem; padding: 0 4px; }
  .chip-t { display: none; }
  .row2 { grid-template-columns: 1fr; }
  .cal-dlg form, .scope-box { padding: 16px 16px 18px; }
  .dlg-foot .grow { display: none; }
  .dlg-foot .cal-btn { flex: 1 1 calc(50% - 4px); }
  .dlg-foot .cal-btn-primary { order: -1; flex-basis: 100%; }
  .a { padding-inline: 14px; }
  .a-time { min-width: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  .cal *, .cal *::before, .cal *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Récurrence avancée, rappels multiples, couleur d'événement ---------- */
.rec { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.rec[hidden], .rec [hidden], .ex[hidden] { display: none !important; }
.rec-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: .9rem; }
.rec-row > label { font-size: .82rem; font-weight: 600; }
.cal-dlg .rec-row input[type="number"] {
  width: 76px; padding: 7px 8px; border: 1px solid var(--border2); border-radius: 8px;
  font: inherit; font-size: .9rem; background: var(--bg); color: var(--text);
}
.cal-dlg .rec-row :is(select, input[type="date"]) { width: auto; max-width: 100%; }
.rec-days { min-width: 0; margin: 0; padding: 0; border: 0; }
.rec-days legend { margin-bottom: 6px; padding: 0; font-size: .82rem; font-weight: 600; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.day { position: relative; cursor: pointer; }
.day input { position: absolute; opacity: 0; }
.day span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 42px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border2); border-radius: 16px; background: var(--bg); color: var(--muted); font-size: .8rem; font-weight: 500;
}
.day input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ex { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.cal .ex-chip { height: 26px; padding: 0 10px; border: 1px solid var(--border2); border-radius: 13px; background: var(--bg); font-size: .78rem; }
.cal .ex-chip:hover { border-color: var(--accent); color: var(--accent); }
.rems { display: grid; gap: 6px; }
.rems:empty { display: none; }
.rem { display: flex; align-items: center; gap: 8px; }
.rem .cal-ico { flex: none; }
.rem select { flex: 1; }
.cal .rem-add { justify-self: start; }
.cal .sw-auto span { background: var(--bg); border: 3px dashed var(--c); }

/* ---------- Fuseaux horaires, visioconférence, invités, pièces jointes ---------- */
.cal-dlg :is(input[type="url"], input[type="email"]) {
  width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--border2); border-radius: 8px;
  font: inherit; font-size: .9rem; background: var(--bg); color: var(--text);
}
.g-tzl { align-self: end; padding: 0 8px 8px 0; text-align: right; font-size: .68rem; color: var(--muted); }
.more { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.more > summary { padding: 10px 12px; font-size: .86rem; font-weight: 600; cursor: pointer; list-style-position: inside; }
.more[open] > summary { border-bottom: 1px solid var(--border); }
.more-body { display: grid; gap: 14px; padding: 12px; }
.vid { display: flex; align-items: center; gap: 8px; }
.vid input { flex: 1; }
.cal .vid a.cal-btn { text-decoration: none; color: var(--accent); border-color: var(--accent); }
.guests { display: flex; flex-wrap: wrap; gap: 6px; }
.guests:not(:empty) { margin-bottom: 2px; }
.guests[hidden] { display: none; }
.gchip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 28px; padding: 0 4px 0 10px; border: 1px solid var(--border2); border-radius: 14px; background: var(--bg); font-size: .8rem; }
.gchip button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 1rem; line-height: 1; color: var(--muted); }
.gchip button:hover { background: var(--border); color: var(--text); }
.atts { display: grid; gap: 6px; }
.atts:empty { display: none; }
.att { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; align-items: center; gap: 6px; }
@media (max-width: 640px) { .att { grid-template-columns: 1fr auto; } .att .att-n { grid-column: 1; } .att .att-u { grid-column: 1; } .att button { grid-row: 1 / span 2; grid-column: 2; } }

/* ---------- Modèles d'événements ---------- */
.vid select { flex: 1; }

/* ---------- Tâches ---------- */
.tk-count { margin-left: 4px; padding: 1px 7px; border-radius: 9px; background: var(--tint); color: var(--accent); font-size: .7rem; font-weight: 600; }
.tk-count:empty { display: none; }
.cal .tk-add input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border2); border-radius: 8px; font: inherit; font-size: .85rem; background: var(--bg); color: var(--text); }
.tk-list { display: grid; gap: 1px; margin-top: 8px; max-height: 240px; overflow-y: auto; }
.tk { display: flex; align-items: flex-start; gap: 2px; }
.tk-chk { position: relative; display: flex; padding: 8px 4px 6px 6px; cursor: pointer; }
.tk-chk input { position: absolute; opacity: 0; }
.tk-box { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--c); transition: background-color .12s; }
.tk-chk input:checked + .tk-box { background: var(--c); }
.tk-chk input:focus-visible + .tk-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.cal .tk-body { flex: 1; min-width: 0; display: grid; padding: 5px 6px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: .85rem; }
.cal .tk-body:hover { background: var(--border); }
.tk-t { overflow-wrap: anywhere; }
.tk-body small { font-size: .74rem; color: var(--muted); }
.tk-body small.is-late { color: var(--danger); font-weight: 600; }
.tk.is-done .tk-t { text-decoration: line-through; color: var(--muted); }
.cal .tk-more { padding: 4px 6px; border: 0; background: none; font-size: .76rem; color: var(--muted); text-decoration: underline; }
.tk-empty { padding: 4px 6px; font-size: .8rem; color: var(--muted); }

/* ---------- Sous-tâches et catégories ---------- */
.subs { display: grid; gap: 4px; }
.subs:empty { display: none; }
.sub { display: flex; align-items: center; gap: 6px; }
.sub .check { flex: 1; min-width: 0; }
.sub .check span { overflow-wrap: anywhere; }
.cal .tk-filter { width: 100%; height: 32px; margin-top: 8px; padding: 0 8px; border: 1px solid var(--border2); border-radius: 8px; font: inherit; font-size: .8rem; background: var(--bg); color: var(--text); }

/* ---------- Partage de calendrier ---------- */
.members { display: grid; gap: 6px; }
.members:empty { display: none; }
.mb { display: flex; align-items: center; gap: 8px; }
.mb-n { flex: 1; min-width: 0; display: grid; font-size: .86rem; overflow-wrap: anywhere; }
.mb-n small { color: var(--muted); font-size: .76rem; }
.cal-dlg .mb select { width: auto; flex: none; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cal-dlg .share-row input { flex: 1 1 170px; width: auto; }
.cal-dlg .share-row select { width: auto; flex: none; }
.side-privacy#syncState { margin-top: 0; color: var(--accent); font-weight: 500; }

/* ---------- Disponibilités ---------- */
.slots { display: grid; gap: 6px; max-height: 280px; overflow-y: auto; }
.cal .slot { width: 100%; justify-content: space-between; gap: 12px; }
.slot small { color: var(--muted); }

/* ---------- Impression / PDF : seule la vue affichée est imprimée ---------- */
/* ---------- Heures visibles : la grille reste calée sur 24 h (clics et glisser-déposer inchangés), on masque ce qui est hors plage ---------- */
.g-body { height: calc(var(--hh) * (var(--h1, 24) - var(--h0, 0))); overflow: hidden; }
.g-body > .g-hours, .g-body > .g-col { position: relative; top: calc(var(--hh) * var(--h0, 0) * -1); }
.g-h.g-first span { top: 2px; }

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .site-header, footer, .skip-link, .cal-side, .cal-bar-end, .cal-nav button, .cal-toasts, dialog { display: none !important; }
  .cal-wrap, .container { padding: 0 !important; max-width: none !important; }
  .cal-app, .cal-body, .cal-main, .cal-main * { overflow: visible !important; max-height: none !important; }
  .cal-app { height: auto !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
  .cal-body { display: block !important; }
  .cal-main .g-body { overflow: hidden !important; }
  .cal-app * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
