.cal { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* --- Barre d'outils --- */

.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.cal-toolbar__nav { display: flex; gap: 6px; }
.cal-title { flex: 1; min-width: 180px; font-size: 28px; font-weight: 700; letter-spacing: var(--tracking-title); }

.seg-links { display: inline-flex; padding: 2px; gap: 2px; background: var(--fill); border-radius: 9px; }
.seg-links__item {
  padding: 5px 14px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 560;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease-spring), color var(--dur-fast);
}
.seg-links__item:hover { color: var(--text); text-decoration: none; }
.seg-links__item.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 1px rgb(0 0 0 / 0.04), 0 2px 6px rgb(0 0 0 / 0.1); }
:root[data-theme="dark"] .seg-links__item.is-active { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg-links__item.is-active { background: #636366; } }

@media (max-width: 640px) {
  .cal-title { order: -1; flex-basis: 100%; font-size: 19px; }
  .cal-toolbar .btn--primary { margin-left: auto; }
}

/* --- Pastilles (mois, bandeau journée) --- */

.cal-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
  min-height: 22px;
  padding: 1px 6px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.35;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.cal-chip:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.cal-chip__title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip__time { color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; margin-right: 4px; }
.cal-chip__icon { color: var(--text-3); }

.cal-chip--timed::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--event-color);
}
.cal-chip--allday {
  background: color-mix(in srgb, var(--event-color) 22%, var(--surface));
  box-shadow: inset 3px 0 0 var(--event-color);
  font-weight: 550;
}
.cal-chip--allday:hover { background: color-mix(in srgb, var(--event-color) 32%, var(--surface)); }

.cal-chip--task { padding-left: 4px; cursor: grab; }
.cal-chip--task .cal-chip__title { padding: 0; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.cal-chip--task.is-done .cal-chip__title { color: var(--text-3); text-decoration: line-through; }
.cal-chip--task .check--sm { width: 14px; height: 14px; border-width: 1.5px; }
.cal-chip--task .check--sm::after { width: 6px; height: 3px; }
.cal-chip--high .check:not(:checked) { border-color: var(--prio-high); }
.cal-chip--low .check:not(:checked) { border-color: var(--prio-low); }

.is-drag-source { opacity: .35; }
.is-armed { outline: 2px solid var(--accent); outline-offset: 1px; }
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  pointer-events: none;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: .95;
}
.is-drop-target { background: var(--accent-weak) !important; box-shadow: inset 0 0 0 2px var(--accent); }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

/* --- Vue mois --- */

.month { border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--text) 5%, transparent); overflow: hidden; }
.month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.month-head__day { padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(112px, 1fr); }

.month-cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 4px 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color .1s;
}
.month-cell:nth-child(7n) { border-right: 0; }
.month-cell:nth-last-child(-n + 7) { border-bottom: 0; }
.month-cell:hover { background: color-mix(in srgb, var(--surface-hover) 50%, transparent); }
.month-cell.is-outside { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.month-cell.is-outside .month-cell__num { color: var(--text-3); }

.month-cell__num {
  align-self: flex-start;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: 0;
  border-radius: 13px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.month-cell__num:hover { background: var(--surface-hover); color: var(--text); }
.month-cell.is-today .month-cell__num { background: var(--accent-fill); color: var(--accent-on); }
.month-cell__items { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.month-more {
  align-self: flex-start;
  padding: 1px 6px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.month-more:hover { background: var(--surface-hover); color: var(--text); }

@media (max-width: 640px) {
  .month { margin: 0 -8px; }
  .month-head__day { padding: 6px 2px; text-align: center; font-size: 11px; }
  .month-grid { grid-auto-rows: minmax(74px, 1fr); }
  .month-cell { padding: 3px 2px; align-items: center; }
  .month-cell__num { align-self: center; font-size: 12px; min-width: 24px; height: 24px; }
  .month-cell__mon { display: none; }
  .month-cell__items { width: 100%; }
  /* Sur mobile, les pastilles deviennent de simples barres colorées. */
  .month-cell .cal-chip { min-height: 5px; height: 5px; padding: 0; border-radius: 3px; pointer-events: none; }
  .month-cell .cal-chip > * { display: none; }
  .month-cell .cal-chip--timed, .month-cell .cal-chip--allday { background: var(--event-color); box-shadow: none; }
  .month-cell .cal-chip--timed::before { display: none; }
  .month-cell .cal-chip--task { background: var(--border-strong); }
  .month-more { font-size: 10.5px; padding: 0 2px; align-self: center; pointer-events: none; }
}

/* --- Grille horaire --- */

.tg {
  --gutter: 56px;
  --hour: 48px;
  box-shadow: var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--text) 5%, transparent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.tg-head, .tg-allday, .tg-inner {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols), minmax(0, 1fr));
}
.tg-head, .tg-allday { scrollbar-gutter: stable; overflow-y: hidden; }
.tg-head { border-bottom: 1px solid var(--border); }

.tg-dayhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  border-left: 1px solid var(--border);
  background: none;
  color: var(--text-2);
}
.tg-dayhead:not(:disabled):hover { background: var(--surface-hover); }
.tg-dayhead:disabled { cursor: default; color: var(--text-2); opacity: 1; }
.tg-dayhead__wd { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tg--day .tg-dayhead__wd { text-transform: none; letter-spacing: 0; font-size: 13px; }
.tg-dayhead__num {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tg-dayhead.is-today { color: var(--accent); }
.tg-dayhead.is-today .tg-dayhead__num { background: var(--accent-fill); color: var(--accent-on); }

.tg-allday { border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.tg-allday__label { display: flex; align-items: flex-start; justify-content: flex-end; padding: 6px 8px; font-size: 11px; color: var(--text-3); }
.tg-allday__cell {
  min-width: 0;
  min-height: 32px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border-left: 1px solid var(--border);
}

.tg-body { position: relative; max-height: max(380px, calc(100dvh - 290px)); overflow-y: auto; scrollbar-gutter: stable; overscroll-behavior: contain; }
.tg-times { position: relative; height: calc(24 * var(--hour)); }
.tg-times__label {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.tg-cols { display: contents; }
.tg-col {
  position: relative;
  height: calc(24 * var(--hour));
  border-left: 1px solid var(--border);
  background-image:
    repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px var(--hour)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour) / 2), color-mix(in srgb, var(--border) 45%, transparent) calc(var(--hour) / 2) calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px) var(--hour));
  cursor: cell;
}
.tg-col.is-today { background-color: color-mix(in srgb, var(--accent-weak) 35%, transparent); }

.tg-event {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  padding: 3px 6px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--event-color) 18%, var(--surface));
  transition: background-color var(--dur-fast) var(--ease);
  box-shadow: inset 3px 0 0 var(--event-color), 0 0 0 1px var(--surface);
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.tg-event:hover { background: color-mix(in srgb, var(--event-color) 30%, var(--surface)); z-index: 2; }
.tg-event__title { display: flex; align-items: center; gap: 4px; min-width: 0; font-weight: 600; }
.tg-event__title > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-event__time, .tg-event__loc { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-event--short { flex-direction: row; align-items: baseline; gap: 6px; padding-block: 1px; }
.tg-event--short .tg-event__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tg-event--short .tg-event__loc { display: none; }
.tg-event--cont { border-top-left-radius: 0; border-top-right-radius: 0; }
.tg-event.is-dragging { z-index: 5; box-shadow: inset 3px 0 0 var(--event-color), var(--shadow-lg); opacity: .95; transform: scale(1.02); }
.tg-event__resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; touch-action: none; }
.tg-event__resize::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 18px;
  height: 3px;
  margin-left: -9px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--event-color) 70%, transparent);
  opacity: 0;
}
.tg-event:hover .tg-event__resize::after { opacity: 1; }

.tg-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 3;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-weak);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.tg-now { position: absolute; left: 0; right: 0; z-index: 4; height: 2px; background: var(--danger); pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

@media (max-width: 640px) {
  .tg { --gutter: 44px; }
  .tg-allday__label { padding: 6px 2px; font-size: 9.5px; }
  .tg--week { margin: 0 -8px; }
  .tg--week .tg-dayhead__wd { font-size: 10.5px; }
  .tg--week .tg-dayhead__num { min-width: 26px; height: 26px; font-size: 14px; }
  .tg--week .tg-event { padding: 2px 3px; font-size: 10.5px; }
  .tg--week .tg-event__time, .tg--week .tg-event__loc { display: none; }
  .tg--week .tg-allday__cell { padding: 2px 1px; }
  .tg-body { max-height: calc(100dvh - 290px - env(safe-area-inset-bottom)); }
}

/* --- Formulaire d'événement --- */

.switch-row { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 550; cursor: pointer; align-self: flex-start; }
.switch {
  appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color .15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.2), 0 0 1px rgb(0 0 0 / 0.1);
  transition: transform var(--dur) var(--ease-spring);
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(18px); }

.field__label .icon { vertical-align: -2px; }
.field__hint { font-size: 14px; color: var(--text-2); }
.input--num { width: 72px !important; flex: none !important; }
.repeat-details { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 8px; background: var(--surface-2); }

.day-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.day-toggle { position: relative; }
.day-toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.day-toggle span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
}
.day-toggle input:checked + span { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-on); }
.day-toggle input:focus-visible + span { box-shadow: var(--focus); }

.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-chip { position: relative; }
.cat-chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.cat-chip > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
}
.cat-chip input:checked + span { border-color: var(--accent); background: var(--accent-weak); color: var(--text); }
.cat-chip input:focus-visible + span { box-shadow: var(--focus); }
.dot--none { background: none; box-shadow: inset 0 0 0 1.5px var(--border-strong); }

.form-error { padding: 8px 12px; border-radius: 8px; background: var(--danger-weak); color: var(--danger); font-size: 14px; font-weight: 550; }

/* --- Lieu : suggestions, carte, itinéraire --- */

.combo { position: relative; }
.combo__list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 1000;
  list-style: none;
  margin: 0;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent);
  max-height: 260px;
  overflow-y: auto;
}
.combo__option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14.5px;
  line-height: 1.35;
  cursor: pointer;
}
.combo__option .icon { margin-top: 2px; color: var(--text-3); }
.combo__option:hover, .combo__option.is-active { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.place-status:empty { display: none; }
.place-status { font-size: 13px; color: var(--text-3); }
.place-hint { font-size: 12px; color: var(--text-3); }

.place-card {
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.place-map { height: 190px; background: var(--fill); }
.place-card__body { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 14px; }
.place-address { font-size: 14.5px; font-weight: 600; }
.place-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.place-actions__label { margin-left: 4px; font-size: 13px; color: var(--text-3); }
.place-app .icon { color: var(--text-3); }

.place-route { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.place-route__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.place-route__row .input { flex: 1 1 180px; width: auto; min-height: 36px; }
.place-route__or { font-size: 13px; color: var(--text-3); }
.btn.is-selected { background: var(--accent-weak); color: var(--accent); }
.place-modes { align-self: flex-start; }
.place-result__main { display: flex; align-items: center; gap: 6px; font-size: 17px; }
.place-result__main strong { font-weight: 700; letter-spacing: var(--tracking-tight); }
.place-result__advice { font-size: 15px; font-weight: 600; color: var(--text); }
.place-muted { font-size: 13px; color: var(--text-3); }

/* Repères de carte aux couleurs de l'app. */
.map-pin { background: none; border: 0; }
.map-pin span {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--danger);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.3), inset 0 0 0 3px rgb(255 255 255 / 0.9);
}
.map-pin--start span { border-radius: 50%; transform: scale(0.6); background: var(--accent-fill); box-shadow: 0 0 0 4px #fff, 0 2px 6px rgb(0 0 0 / 0.3); }
.place-map .leaflet-control-attribution { font-size: 10.5px; }
.place-map .leaflet-bar a { width: 32px; height: 32px; line-height: 32px; }

/* Carte en mode sombre : tuiles assombries (les repères et le tracé gardent leurs couleurs). */
:root[data-theme="dark"] .place-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .place-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
}
@media (pointer: coarse) {
  .place-actions .btn, .place-route .btn { min-height: 44px; }
}

/* --- Agendas partagés --- */
fieldset.form-stack { border: 0; margin: 0; padding: 0; min-width: 0; }
.event-calendar { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-2); font-size: 13px; }
.event-calendar .dot { background: var(--event-color); }
.cal-agendas__dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.cal-agendas__dots .dot { width: 8px; height: 8px; }
.agenda-own { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.agenda-own__name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.agendas__empty { color: var(--text-2); font-size: 14px; padding: 8px 0; }
.agenda-row__toggle { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.agenda-row__toggle input { position: absolute; opacity: 0; pointer-events: none; }
.agenda-row__swatch {
  width: 20px; height: 20px; flex: none; border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--event-color); transition: background var(--dur-fast, .15s);
}
.agenda-row__toggle input:checked + .agenda-row__swatch { background: var(--event-color); }
.agenda-row__toggle input:focus-visible + .agenda-row__swatch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Rappels (pastilles larges) --- */
.day-toggle--wide span { width: auto; min-width: 34px; padding: 0 12px; border-radius: 17px; font-weight: 600; white-space: nowrap; }
