/* --- Bureau de widgets --- */

.desk { max-width: 1120px; margin: 0 auto; }

.desk-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 16px; margin: 10px 4px 22px; }
.desk-head__titles { min-width: 0; }
.desk-greeting { font-size: 15px; font-weight: 600; color: var(--text-2); }
.desk-summary { font-size: 17px; color: var(--text-2); }
.desk-summary a { font-weight: 600; }
.desk-summary a.is-danger, .is-danger { color: var(--danger); }
.desk-head__actions { display: flex; align-items: center; gap: 8px; }
.desk-head__actions .btn:not(.btn--primary) { background: var(--glass-strong); -webkit-backdrop-filter: var(--glass-filter); backdrop-filter: var(--glass-filter); box-shadow: var(--shadow-sm), 0 0 0 0.5px color-mix(in srgb, var(--text) 12%, transparent); }
.desk-settings { display: none; }

.desk-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: var(--tile-row);
  grid-auto-flow: dense;
  gap: var(--tile-gap);
}
.desk-empty { grid-column: 1 / -1; padding: 48px 16px; text-align: center; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* --- Tuile --- */

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 16px 14px;
  border-radius: var(--r-tile);
  background: var(--surface);
  box-shadow: var(--shadow-md), 0 0 0 1px color-mix(in srgb, var(--text) 4%, transparent);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease-spring);
}
.tile--s { grid-column: span 1; }
.tile--m { grid-column: span 2; }
.tile--l { grid-column: span 2; grid-row: span 2; }

.tile__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; min-width: 0; }
.tile__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 28px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .01em;
  text-transform: uppercase;
  text-decoration: none;
}
.tile__title:hover { text-decoration: none; color: var(--accent); }
.tile__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--chip);
  color: var(--chip-ink, #fff);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25);
}
.tile__icon--lg { width: 44px; height: 44px; border-radius: 12px; }
.tile__meta { flex: none; font-size: 13px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tile__body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* Aujourd'hui : la tuile prend la couleur du moment de la journée (élément signature). */
.tile--today {
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--wp-1) calc(var(--wp-strength) * 0.9), transparent), transparent 70%),
    radial-gradient(90% 80% at 100% 0%, color-mix(in srgb, var(--wp-2) calc(var(--wp-strength) * 0.7), transparent), transparent 70%),
    var(--surface);
}
.tile--l.tile--today .tile__body { overflow-y: auto; }

/* --- Mode Modifier --- */

/* État d'édition fixe (pas de tremblement permanent : les cibles restent immobiles). */
.desk.is-editing .tile {
  cursor: grab;
  transform: scale(0.975);
  box-shadow: var(--shadow-sm), 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
  animation: edit-in var(--dur-slow) var(--ease-spring);
}
.desk.is-editing .tile__body { opacity: .5; }
@keyframes edit-in { from { transform: scale(1); } }
.tile.is-lifted { z-index: 30; animation: none !important; box-shadow: var(--shadow-lg); cursor: grabbing; transition: none; }

.tile__remove {
  position: absolute;
  top: -9px;
  left: -9px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 75%, transparent);
  color: var(--bg);
}
.tile__remove::after { content: ""; position: absolute; inset: -8px; } /* zone de toucher 44 px */
.tile__edit {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 2;
  display: flex;
  gap: 6px;
  transform: translateX(-50%);
}
.tile__sizes, .tile__move {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-md), 0 0 0 0.5px color-mix(in srgb, var(--text) 14%, transparent);
}
.tile__size {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.tile__size.is-active { background: var(--accent-fill); color: var(--accent-on); }
.tile__size:disabled { opacity: .3; cursor: default; }
.tile--s .tile__move { display: none; }

/* --- Galerie --- */

.gallery { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.gallery__item { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; }
.gallery__item + .gallery__item { border-top: 1px solid var(--border); }
.gallery__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.gallery__name { font-weight: 650; font-size: 16px; }
.gallery__desc { font-size: 14px; color: var(--text-2); }
.gallery__sizes { margin-top: 6px; }
.gallery__item .btn { align-self: center; }

/* --- Contenu des widgets --- */

.w-empty { margin: auto; text-align: center; color: var(--text-3); font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.w-empty__title { color: var(--text); font-weight: 650; font-size: 15px; }
.w-more { margin-top: auto; padding-top: 6px; font-size: 13px; font-weight: 600; }

/* Tâches */
.w-tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.w-task { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.w-task + .w-task { border-top: 1px solid var(--border); }
.w-task__title {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 14.5px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.w-task.is-done .w-task__title { color: var(--text-3); text-decoration: line-through; }
.w-task__date { flex: none; font-size: 12px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.w-quick { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 0 10px; min-height: 38px; border-radius: 12px; background: var(--fill); color: var(--accent); }
.w-quick__input { flex: 1; min-width: 0; min-height: 36px; border: 0; background: none; color: var(--text); font-size: 15px; }
.w-quick__input:focus { outline: none; }
.w-quick:focus-within { box-shadow: 0 0 0 2px var(--accent); }

/* Aujourd'hui */
.w-next {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
}
.w-next__label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.w-next__time { font-size: 24px; font-weight: 700; letter-spacing: var(--tracking-title); font-variant-numeric: tabular-nums; }
.w-next__title { font-size: 15px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; border-left: 3px solid var(--event-color, var(--text-3)); padding-left: 8px; }
.w-next__more { margin-top: auto; font-size: 12px; color: var(--text-3); }
.w-allday { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-agenda-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.w-agenda { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 8px; }
.w-agenda__time { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); text-align: right; }
.w-agenda__title {
  min-width: 0;
  min-height: 32px;
  padding: 4px 10px;
  border: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--event-color, var(--text)) 12%, var(--surface));
  box-shadow: inset 3px 0 0 var(--event-color, transparent);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.w-agenda--task .w-agenda__title { background: color-mix(in srgb, var(--text) 5%, var(--surface)); box-shadow: inset 3px 0 0 var(--border-strong); }
.w-agenda.is-past { opacity: .55; }
.w-agenda-list--thread { gap: 6px; }
.w-now { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 8px; }
.w-now .w-agenda__time { color: var(--danger); }
.w-now__line { position: relative; height: 2px; border-radius: 1px; background: var(--danger); }
.w-now__line::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.w-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.w-pill {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--event-color) 20%, var(--surface));
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

/* Calendrier */
.w-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px 2px; text-align: center; align-content: start; }
.w-month__wd { font-size: 10.5px; font-weight: 650; color: var(--text-3); padding-bottom: 2px; }
.w-month__day {
  position: relative;
  display: grid;
  place-items: center;
  height: 17px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  font-size: 11px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.w-month__day.is-outside { color: color-mix(in srgb, var(--text-3) 60%, transparent); }
.w-month__day.is-busy::after { content: ""; position: absolute; bottom: -1px; width: 3px; height: 3px; border-radius: 50%; background: var(--c-cal); }
.w-month__day.is-today { background: var(--danger); color: #fff; font-weight: 700; }
.w-month__day.is-today::after { display: none; }
.w-month--l { gap: 4px; }
.w-month--l .w-month__wd { font-size: 12px; }
.w-month--l .w-month__day { height: 34px; font-size: 14px; border-radius: 10px; cursor: pointer; }
.w-month--l .w-month__day:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.w-month--l .w-month__day.is-today { background: var(--danger); }
.w-month--l .w-month__day.is-busy::after { bottom: 3px; width: 4px; height: 4px; }
.w-month-wrap--m { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; }
.w-month-wrap--l { display: flex; flex-direction: column; gap: 12px; }
.w-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.w-event {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 3px 0 3px 10px;
  border: 0;
  border-left: 3px solid var(--event-color);
  background: none;
  color: var(--text);
  text-align: left;
}
.w-event__when { font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.w-event__title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-events__empty { font-size: 13px; color: var(--text-3); }

/* Prochains jours */
.w-upcoming { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.w-upcoming li { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 30px; }
.w-upcoming li + li { border-top: 1px solid var(--border); }
.w-upcoming__day { font-size: 12.5px; font-weight: 650; color: var(--text-3); }
.w-upcoming__title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.w-upcoming__title .icon { color: var(--text-3); }
.w-upcoming__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--event-color); }

/* Notes */
.w-note { display: flex; flex-direction: column; gap: 4px; min-height: 0; flex: 1; padding: 0; border: 0; background: none; color: var(--text); text-align: left; }
.w-note__title { font-size: 16px; font-weight: 700; letter-spacing: var(--tracking-tight); padding: 0; border: 0; background: none; color: var(--text); text-align: left; }
.w-note__excerpt { font-size: 14px; line-height: 1.45; color: var(--text-2); display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; -webkit-line-clamp: 4; }
.w-note--s .w-note__excerpt { -webkit-line-clamp: 3; font-size: 13px; }
.w-note--l { overflow-y: auto; }
.w-note__md { font-size: 14px; }
.tile--note, .tile--notes { background: color-mix(in srgb, #ffd60a 7%, var(--surface)); }
.w-notes { list-style: none; margin: 0; padding: 0; }
.w-notes li + li { border-top: 1px solid var(--border); }
.w-notes__row { display: flex; align-items: center; gap: 6px; min-height: 34px; color: var(--text); text-decoration: none; }
.w-notes__row:hover { text-decoration: none; color: var(--accent); }
.w-notes__row .icon { color: var(--text-3); }
.w-notes__title { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-notes__date { font-size: 12px; color: var(--text-3); }

/* Créer */
.w-create { flex: 1; display: flex; align-items: center; justify-content: space-around; gap: 6px; }
.w-create__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 44px;
  padding: 4px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.w-create__btn:hover .w-create__icon { transform: scale(1.06); }
.w-create__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--chip);
  color: #fff;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25), var(--shadow-sm);
  transition: transform var(--dur) var(--ease-spring);
}
.w-create--s { gap: 2px; }
.w-create--s .w-create__icon { width: 40px; height: 40px; }
.w-create--s .w-create__label { font-size: 11px; }
.w-create--m .w-create__icon { width: 56px; height: 56px; }

/* Progression */
.w-progress { flex: 1; display: flex; align-items: center; gap: 14px; min-height: 0; }
.w-progress--s { flex-direction: column; justify-content: center; gap: 6px; text-align: center; }
.w-ring { position: relative; flex: none; width: 76px; height: 76px; }
.w-progress--s .w-ring { width: 68px; height: 68px; }
.w-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.w-ring__track, .w-ring__value { fill: none; stroke-width: 9; }
.w-ring__track { stroke: color-mix(in srgb, var(--ok) 18%, var(--surface)); }
.w-ring__value { stroke: var(--ok); stroke-linecap: round; transition: stroke-dashoffset var(--dur-slow) var(--ease-spring); }
.w-ring__label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.w-progress__text { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.w-progress__last { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Largeurs --- */

@media (max-width: 1000px) {
  .desk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .desk-head { margin: 0 0 18px; }
  .desk-settings { display: inline-flex; background: var(--glass-strong); }
  .desk-summary { font-size: 16px; }
  /* Grille iOS : 2 colonnes, petites tuiles carrées. */
  .desk-grid { --tile-gap: 14px; grid-auto-rows: calc((100vw - 32px - var(--tile-gap)) / 2); gap: var(--tile-gap); }
  .tile { padding: 12px 14px; border-radius: 22px; }
  .w-month__day { height: 16px; font-size: 10.5px; }
  .w-month-wrap--m { gap: 12px; }
}

/* --- Carte du jour --- */

.tile--map .tile__body { padding-bottom: 12px; }
.w-map { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 0; }
.w-map__head { display: flex; align-items: center; gap: 4px; }
.w-map__nav {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text);
}
.w-map__nav:hover { background: color-mix(in srgb, var(--text) 12%, transparent); }
.w-map__day {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
}
.w-map__day:not(:disabled):hover { background: var(--fill); }
.w-map__day:disabled { cursor: default; }
.w-map__day-name { font-weight: 650; }
.w-map__count { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.w-map__route {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.w-map__route:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.w-map__frame { position: relative; flex: 1; min-height: 150px; border-radius: 14px; overflow: hidden; background: var(--fill); }
.w-map__map { position: absolute; inset: 0; }
.w-map__map .leaflet-control-attribution { font-size: 10px; }
.w-map__overlay {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 500;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
  text-align: center;
}
.w-map__list { display: none; list-style: none; margin: 0; padding: 0; flex-direction: column; gap: 2px; flex: none; max-height: 86px; overflow-y: auto; }
.w-map--l .w-map__list { display: flex; }
.w-map__list:empty { display: none; }
.w-map__stop {
  display: grid;
  grid-template-columns: 24px 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 4px 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  text-align: left;
  font: inherit;
}
.w-map__stop:hover, .w-map__stop:focus-visible { background: var(--fill); }
.w-map__num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--event-color);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.w-map__time { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.w-map__text { display: flex; flex-direction: column; min-width: 0; }
.w-map__title, .w-map__place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-map__title { font-size: 14px; font-weight: 600; }
.w-map__place { font-size: 12.5px; color: var(--text-2); }
.w-map__line { stroke: var(--accent-fill); }
.w-map__popup { display: flex; flex-direction: column; gap: 2px; min-width: 160px; font: 14px/1.35 var(--font); }
.w-map__popup p { margin: 0; }
.w-map__popup-time { font-size: 12.5px; font-weight: 650; color: #555; }
.w-map__popup-title { font-weight: 650; color: #111; }
.w-map__popup-place { font-size: 12.5px; color: #555; margin-bottom: 6px !important; }

/* Repère numéroté (couleur de la catégorie de l'événement). */
.map-pin.map-pin--num span { background: var(--pin, var(--danger)); display: grid; place-items: center; }
.map-pin.map-pin--num b { transform: rotate(45deg); color: #fff; font: 700 13px/1 var(--font); }
.map-pin.map-pin--num.is-active span { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--pin), 0 2px 6px rgb(0 0 0 / 0.3); }
:root[data-theme="dark"] .w-map__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"]) .w-map__map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
}
@media (pointer: coarse) {
  .w-map__nav { width: 44px; height: 44px; }
  .w-map__day, .w-map__route { min-height: 44px; }
}
