/* Ma semaine — visuel « 25H qui courent » */
:root {
  --rose: #ff0089;
  --rose-clair: #ffacd8;
  --violet: #7700ff;
  --jaune: #fff900;
  --vert: #47ffc0;
  --noir: #000;
  --blanc: #fff;
  --hand: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --display: 'Bungee', 'Arial Black', sans-serif;
  --body: 'Jost', 'Futura PT', Futura, system-ui, sans-serif;
  --script: 'Caveat', 'Comic Sans MS', cursive;
  --tilt: 0.6;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--rose);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--rose);
  color: var(--noir);
  font-family: var(--body);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.4;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--noir); outline-offset: 3px; }

.i {
  width: 15px; height: 15px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2.6;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Mise en page ---------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 22px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 24px)
    calc(env(safe-area-inset-left) + 16px);
}

@media (min-width: 640px) {
  .app {
    --tilt: 0.8;
    padding:
      calc(env(safe-area-inset-top) + 30px)
      calc(env(safe-area-inset-right) + 32px)
      calc(env(safe-area-inset-bottom) + 28px)
      calc(env(safe-area-inset-left) + 32px);
  }
}
@media (min-width: 1024px) {
  .app { --tilt: 1; padding: 34px 44px 30px; }
}

/* ---------- En-tête ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px 24px;
  padding-bottom: 26px;
}

.titles { display: flex; flex-direction: column; gap: 4px; }

.tagline {
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(22px, 6vw, 28px);
  line-height: 1;
  transform: rotate(-3deg);
  transform-origin: left;
  margin-left: 4px;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 10.5vw, 66px);
  line-height: 0.92;
  letter-spacing: -0.01em;
  color: var(--blanc);
  text-transform: uppercase;
}

.outline {
  position: relative;
  display: inline-block;
  color: transparent;
  -webkit-text-stroke: 2px var(--blanc);
}
@media (min-width: 640px) { .outline { -webkit-text-stroke-width: 2.5px; } }

.squiggle {
  position: absolute;
  left: -4px;
  bottom: -16px;
  width: calc(100% + 8px);
  height: 16px;
  filter: url(#boil-strong);
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.chip {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--c, var(--blanc));
  color: var(--on, var(--noir));
  border: 2.5px solid var(--noir);
  border-radius: var(--hand);
  box-shadow: 3px 4px 0 var(--noir);
  transform: rotate(var(--r, 0deg));
}
button.chip { min-height: 44px; }
.chip--new { background: transparent; color: #444; border-style: dashed; box-shadow: none; }
@media (hover: hover) { .chip--new:hover { color: var(--noir); background: var(--blanc); } }
@media (max-width: 400px) {
  .chip { font-size: 11px; padding: 7px 10px; gap: 5px; }
  .chip .i { width: 13px; height: 13px; }
  .legend { gap: 10px; width: 100%; }
}

/* ---------- Boutons ---------- */
.btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--blanc);
  color: var(--noir);
  border: 2.5px solid var(--noir);
  border-radius: var(--hand);
  box-shadow: 3px 4px 0 var(--noir);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--noir); }
.btn--icon { padding: 0; width: 48px; height: 48px; }
.btn--icon .i { width: 20px; height: 20px; stroke-width: 2.8; }
.btn--primary { background: var(--noir); color: var(--blanc); box-shadow: 3px 4px 0 var(--rose); }
.btn--primary:active { box-shadow: 1px 1px 0 var(--rose); }
.btn--danger { background: var(--rose-clair); }
.btn--sm { width: 44px; height: 44px; box-shadow: 2px 3px 0 var(--noir); }
.btn:disabled { opacity: 0.3; cursor: default; box-shadow: none; }
.btn--dashed { border-style: dashed; box-shadow: none; justify-content: center; margin-top: 16px; }
.btn--wide { width: 100%; justify-content: flex-start; text-align: left; padding: 10px 16px; font-size: 13px; line-height: 1.3; }

@media (hover: hover) {
  .btn:hover { background: var(--jaune); }
  .btn--primary:hover { background: var(--violet); }
}

/* ---------- Navigation semaine ---------- */
.weekbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.wk {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}
.wk-range {
  font-family: var(--display);
  font-size: clamp(17px, 4.8vw, 24px);
  line-height: 1.05;
  color: var(--blanc);
}
.wk-rel {
  font-family: var(--script);
  font-weight: 700;
  font-size: 21px;
  line-height: 1;
  transform: rotate(-2deg);
}
.wk-today {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 32px;
  padding: 4px 12px;
  margin-top: 2px;
  background: var(--jaune);
  border: 2px solid var(--noir);
  border-radius: var(--hand);
  box-shadow: 2px 3px 0 var(--noir);
  transform: rotate(-1.5deg);
  position: relative;
}
.wk-today::after { content: ""; position: absolute; inset: -8px -4px; } /* zone tactile ≥ 44px */
.wk-today[hidden] { display: none; }

@media (min-width: 1024px) {
  .weekbar { justify-content: flex-start; }
  .wk { flex: 0 1 auto; min-width: 260px; }
}

/* ---------- Grille ---------- */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 22px; }
}
@media (min-width: 1024px) {
  .grid {
    flex: 1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(240px, 1fr));
    gap: 22px;
  }
}

.grid.slide-next { animation: slide-next 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
.grid.slide-prev { animation: slide-prev 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes slide-next { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-prev { from { opacity: 0; transform: translateX(-28px); } }

/* ---------- Carte jour ---------- */
.day {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 18px;
  background: var(--blanc);
  border: 2.5px solid var(--noir);
  border-radius: var(--card-r, 22px 16px 26px 14px / 14px 26px 16px 22px);
  box-shadow: 5px 6px 0 #000000e0;
  transform: rotate(calc(var(--rot, 0deg) * var(--tilt)));
  --line: rgba(0, 0, 0, 0.12);
}
.day--weekend { background: var(--rose-clair); --line: rgba(0, 0, 0, 0.14); }

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.day-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 24px;
  line-height: 1;
}
.day-num {
  font-family: var(--display);
  font-size: 24px;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--noir);
}
.is-today .day-num { color: var(--jaune); }

.today-badge {
  position: absolute;
  top: -15px;
  right: 64px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  background: var(--jaune);
  border: 2px solid var(--noir);
  border-radius: var(--hand);
  box-shadow: 2px 3px 0 var(--noir);
  transform: rotate(4deg);
  pointer-events: none;
}

.acts {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.acts:empty { display: none; }

.act {
  width: 100%;
  min-height: 50px;
  padding: 7px 12px 7px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: var(--c, var(--blanc));
  color: var(--on, var(--noir));
  border: 2px solid var(--noir);
  border-radius: var(--hand);
  box-shadow: 3px 4px 0 var(--noir);
  transform: rotate(calc(var(--rot, 0deg) * var(--tilt)));
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.act:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--noir); }
@media (hover: hover) {
  .act:hover { transform: rotate(calc(var(--rot, 0deg) * var(--tilt))) translate(-1px, -1px); box-shadow: 4px 5px 0 var(--noir); }
}

.act-ico {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blanc);
  color: var(--noir);
  border: 2px solid var(--noir);
  display: flex;
  align-items: center;
  justify-content: center;
}
.act-ico .i { width: 18px; height: 18px; stroke-width: 2.4; }
.act-txt { min-width: 0; }
.act-t {
  display: block;
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.15;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.act-d { display: block; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }

.lines {
  flex: 1;
  margin-top: 14px;
}

.add {
  min-height: 44px;
  padding: 0 14px 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  color: #555;
  border: 2px dashed currentColor;
  border-radius: var(--hand);
}
.add .i { width: 16px; height: 16px; stroke-width: 3; }
@media (hover: hover) { .add:hover { color: var(--noir); background: var(--blanc); border-style: solid; } }
.day--weekend .add { color: #222; }

/* ---------- Carte notes ---------- */
.day--notes { background: var(--noir); color: var(--blanc); --line: rgba(255, 255, 255, 0.35); }
.notes-tag {
  font-family: var(--script);
  font-weight: 700;
  font-size: 21px;
  line-height: 1;
  color: var(--jaune);
  transform: rotate(-5deg);
}
.notes {
  flex: 1;
  width: 100%;
  min-height: 140px;
  margin-top: 10px;
  padding: 0 2px;
  border: 0;
  resize: none;
  background: transparent;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 26.5px, var(--line) 26.5px, var(--line) 28px);
  background-attachment: local;
  color: var(--blanc);
  font-size: 17px;
  line-height: 28px;
}
.notes::placeholder { color: rgba(255, 255, 255, 0.6); }
.notes:focus-visible { outline: 2px dashed var(--jaune); outline-offset: 4px; }

/* ---------- Pied ---------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  padding-top: 26px;
}
.foot-count { font-family: var(--display); font-size: 13px; letter-spacing: 0.08em; }
.foot-date { font-size: 15px; }

/* ---------- Feuilles (dialogues) ---------- */
.sheet {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 22px 22px 20px;
  background: var(--blanc);
  color: var(--noir);
  border: 2.5px solid var(--noir);
  border-radius: 26px 18px 24px 20px / 20px 24px 18px 26px;
  box-shadow: 6px 8px 0 var(--noir);
  overflow: auto;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.5); }
.sheet[open] { animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes pop { from { opacity: 0; transform: scale(0.94) rotate(-1deg); } }

@media (max-width: 639px) {
  .sheet {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 26px 22px 0 0 / 22px 26px 0 0;
    border-bottom: 0;
    box-shadow: none;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .sheet[open] { animation: rise 0.26s cubic-bezier(0.2, 0.9, 0.3, 1); }
  @keyframes rise { from { transform: translateY(100%); } }
}

.sheet-title {
  margin: 0 0 16px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.1;
  text-transform: uppercase;
}
.sheet-help { margin: -6px 0 16px; font-size: 15px; }

.lbl {
  display: block;
  margin-bottom: 6px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.opt { font-family: var(--body); font-size: 13px; letter-spacing: 0; text-transform: none; color: #555; }

.types, .picker { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.types legend, .picker legend { padding: 0; }
.types-list { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.type { position: relative; cursor: pointer; }
.type input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.type .chip { min-height: 44px; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.type input:not(:checked) + .chip { background: var(--blanc); color: var(--noir); box-shadow: 0 0 0 var(--noir); transform: none; }
.type input:focus-visible + .chip { outline: 3px solid var(--noir); outline-offset: 3px; }

.field { display: block; margin-bottom: 14px; }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 17px;
  background: var(--blanc);
  border: 2px solid var(--noir);
  border-radius: 14px 18px 12px 16px / 16px 12px 18px 14px;
}
.field input:focus-visible, .field select:focus-visible { outline: 3px solid var(--violet); outline-offset: 1px; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 42px;
}

.sheet-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.spacer { flex: 1; }
.menu-list { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--jaune);
  border: 2.5px solid var(--noir);
  border-radius: var(--hand);
  box-shadow: 3px 4px 0 var(--noir);
  transform: translate(-50%, 150%) rotate(-1deg);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s ease;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0) rotate(-1deg); opacity: 1; }

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Impression : A4 paysage comme le poster ---------- */
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: var(--rose); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .app { --tilt: 1; width: 297mm; height: 210mm; padding: 9mm 11mm 8mm; }
  .weekbar, .add, .sheet, .toast { display: none !important; }
  .grid { flex: 1; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 22px; }
  .today-badge { display: none; }
}

/* ---------- Gestion des catégories ---------- */
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cat-main { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.cat-row .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-uses { font-size: 14px; color: #555; white-space: nowrap; padding-left: 4px; }
.cat-tools { flex-shrink: 0; display: flex; gap: 8px; }

.ce-preview { display: flex; justify-content: center; padding: 6px 0 18px; }
.ce-preview .chip { font-size: 15px; padding: 10px 18px; }

.swatch-list { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch, .icon-pick { position: relative; cursor: pointer; }
.swatch input, .icon-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch span {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--c);
  border: 2.5px solid var(--noir);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--blanc), 0 0 0 6px var(--noir); transform: scale(0.9); }

.icon-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.icon-pick span {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--noir);
  border-radius: 12px 16px 10px 14px / 14px 10px 16px 12px;
  background: var(--blanc);
}
.icon-pick .i { width: 20px; height: 20px; stroke-width: 2.4; }
.icon-pick input:checked + span { background: var(--jaune); box-shadow: 2px 3px 0 var(--noir); }

.swatch input:focus-visible + span, .icon-pick input:focus-visible + span { outline: 3px solid var(--violet); outline-offset: 3px; }

/* ---------- Confirmation ---------- */
.sheet--small { width: min(400px, calc(100vw - 32px)); }
.cf-text { font-size: 16px; line-height: 1.45; }
.btn--delete { background: var(--rose); color: var(--noir); box-shadow: 3px 4px 0 var(--noir); }
.btn--delete:active { box-shadow: 1px 1px 0 var(--noir); }
@media (hover: hover) { .btn--delete:hover { background: var(--rose-clair); } }

/* ---------- Tri des activités ---------- */
.act { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.acts > li { transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1); }
.acts > li.dragging { position: relative; z-index: 5; transition: none; }
.acts > li.dragging .act {
  cursor: grabbing;
  box-shadow: 7px 10px 0 var(--noir);
  transform: rotate(calc(var(--rot, 0deg) * var(--tilt) - 1.5deg)) scale(1.04);
}
body.is-sorting, body.is-sorting * { cursor: grabbing !important; }
.sheet-hint { margin: -4px 0 0; font-size: 14px; color: #555; }

/* ---------- Déplacement vers un autre jour ---------- */
.day.drag-source { z-index: 10; }
.day.drop-target { outline: 3px dashed var(--noir); outline-offset: 7px; }
.drop-line {
  position: fixed;
  z-index: 20;
  height: 8px;
  background: var(--jaune);
  border: 2px solid var(--noir);
  border-radius: 8px;
  box-shadow: 2px 3px 0 var(--noir);
  pointer-events: none;
}

/* ---------- Activité ajoutée ou modifiée ---------- */
.act.just-added { animation: just-added 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes just-added {
  0% { transform: rotate(calc(var(--rot, 0deg) * var(--tilt))) scale(0.6); opacity: 0; }
  45% { transform: rotate(calc(var(--rot, 0deg) * var(--tilt) - 3deg)) scale(1.08); opacity: 1; box-shadow: 6px 8px 0 var(--noir), 0 0 0 6px var(--jaune); }
  100% { transform: rotate(calc(var(--rot, 0deg) * var(--tilt))) scale(1); box-shadow: 3px 4px 0 var(--noir), 0 0 0 0 var(--jaune); }
}
