/* =====================================================================
   THÈMES — chaque thème n'est qu'un bloc de variables.
   Pour en créer un : copie un bloc, change le nom entre guillemets,
   les couleurs, puis ajoute-le dans THEMES (script.js).
   ===================================================================== */

[data-theme="rose"], [data-theme="perso"] {
  --bg: #ffd6e8;  --bg2: #ffe9d6;  --card: #fffafc;
  --ink: #5a2a47; --muted: #c08aa8; --line: #ffe3ef;
  --accent: #ff6fae; --accent2: #ffb199; --danger: #ff4d8d;
  --on-accent: #fff;
  --shadow: 0 30px 60px -25px rgba(255, 90, 160, .45);
}
[data-theme="lavande"] {
  --bg: #e6dcff;  --bg2: #fbe3ff;  --card: #fcfaff;
  --ink: #3a2a5e; --muted: #9a8ac4; --line: #efe8ff;
  --accent: #9b6bff; --accent2: #ff8fe0; --danger: #ff5c93;
  --on-accent: #fff;
  --shadow: 0 30px 60px -25px rgba(120, 80, 255, .4);
}
[data-theme="menthe"] {
  --bg: #d4f5e4;  --bg2: #fff6d6;  --card: #fbfffd;
  --ink: #1f4a3a; --muted: #7fb59d; --line: #e2f8ec;
  --accent: #1fbf84; --accent2: #6fd0ff; --danger: #ff6b6b;
  --on-accent: #fff;
  --shadow: 0 30px 60px -25px rgba(30, 160, 110, .4);
}
[data-theme="ocean"] {
  --bg: #cfe8ff;  --bg2: #d8fff6;  --card: #fbfdff;
  --ink: #153a5c; --muted: #78a3c9; --line: #e3f1ff;
  --accent: #2f8cff; --accent2: #2fd1c9; --danger: #ff5c7a;
  --on-accent: #fff;
  --shadow: 0 30px 60px -25px rgba(40, 110, 220, .4);
}
[data-theme="soleil"] {
  --bg: #fff0b8;  --bg2: #ffd9c2;  --card: #fffdf6;
  --ink: #4a3200; --muted: #b59a5a; --line: #fff3cf;
  --accent: #ffb300; --accent2: #ff7a59; --danger: #e8454f;
  --on-accent: #3a2600;
  --shadow: 0 30px 60px -25px rgba(230, 150, 0, .4);
}
[data-theme="nuit"] {
  --bg: #0e1020;  --bg2: #1a1740;  --card: #181a33;
  --ink: #eceaff; --muted: #8c8fb8; --line: #272a4d;
  --accent: #7c7bff; --accent2: #35e0c0; --danger: #ff6b8a;
  --on-accent: #0e1020;
  --shadow: 0 30px 60px -25px rgba(0, 0, 0, .7);
}
[data-theme="halloween"] {
  --bg: #150a26;  --bg2: #2e1204;  --card: #231335;
  --ink: #ffeedd; --muted: #a98fc4; --line: #36204f;
  --accent: #ff7a1a; --accent2: #a35cff; --danger: #ff4a4a;
  --on-accent: #1a0b2e;
  --shadow: 0 30px 70px -25px rgba(255, 122, 26, .35);
}
[data-theme="noel"] {
  --bg: #0f4a35;  --bg2: #9c1c2c;  --card: #fffdf7;
  --ink: #3b1b1b; --muted: #a08a82; --line: #f6e9e2;
  --accent: #d62839; --accent2: #1f9d55; --danger: #b0102a;
  --on-accent: #fff;
  --shadow: 0 30px 60px -25px rgba(0, 0, 0, .5);
}

/* Fond uni : on aplatit tous les dégradés d'un coup */
html[data-solid="1"][data-theme] {
  --bg2: var(--bg);
  --accent2: var(--accent);
}

/* ===================================================================== */

* { box-sizing: border-box; }
:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html, body { height: 100%; margin: 0; }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg), var(--bg2)) fixed;
  display: flex; justify-content: center; align-items: flex-start;
  padding: clamp(16px, 6vh, 64px) 16px;
}
button:focus-visible, input:focus-visible, label.check:focus-within {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* transition douce au changement de thème */
html.switching .app, html.switching .add input, html.switching .item,
html.switching .panel, html.switching .progress, html.switching .theme-btn {
  transition: background-color .45s, border-color .45s, color .45s;
}

.app {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px;
  background: var(--card);
  border-radius: 36px;
  box-shadow: var(--shadow);
  padding: 28px 24px 20px;
}

header h1 { margin: 0; padding-right: 48px; font-size: 1.9rem; letter-spacing: -.02em; }
header h1 .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
header p { margin: 4px 0 18px; color: var(--muted); font-size: .95rem; }

/* --------- bouton + panneau de thèmes --------- */
.theme-btn {
  position: absolute; top: 22px; right: 20px;
  width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: var(--line); font-size: 1.2rem; cursor: pointer;
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.theme-btn:hover { transform: rotate(-14deg) scale(1.08); }
.theme-btn[aria-expanded="true"] { transform: rotate(20deg) scale(1.05); }

.panel {
  position: absolute; z-index: 5; top: 72px; right: 14px;
  width: min(340px, calc(100% - 28px));
  background: var(--card); border: 1px solid var(--line);
  border-radius: 24px; padding: 16px;
  box-shadow: var(--shadow), 0 0 0 1px var(--line);
  transform-origin: top right;
  animation: panelIn .28s cubic-bezier(.2, .9, .3, 1.2);
}
.panel[hidden] { display: none; }
@keyframes panelIn { from { opacity: 0; transform: scale(.88) translateY(-8px); } to { opacity: 1; transform: none; } }
.panel-title { margin: 0 0 10px; font-weight: 700; }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 2px 8px; border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--bg), var(--bg2));
  color: var(--ink); font: inherit; font-size: .72rem; font-weight: 600;
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.chip:hover { transform: translateY(-3px) scale(1.05); }
.chip .ico { font-size: 1.35rem; line-height: 1.2; }
.chip[aria-pressed="true"] { outline: 3px solid var(--accent); outline-offset: 2px; }

.row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: .92rem; }
.row input[type="color"] {
  width: 52px; height: 34px; padding: 0; border: 2px solid var(--line);
  border-radius: 12px; background: none; cursor: pointer;
}
.row input[type="color"].on { border-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: .92rem; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* --------- progression --------- */
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  box-shadow: 0 0 12px var(--accent);
  transition: width .6s cubic-bezier(.2, .9, .2, 1);
}

/* --------- ajout --------- */
.add { display: flex; gap: 10px; margin: 20px 0 14px; }
.add input {
  flex: 1; min-width: 0;
  font: inherit; color: inherit;
  background: var(--line); border: 2px solid transparent;
  border-radius: 16px; padding: 14px 16px; outline: none;
  transition: border-color .2s, background .2s;
}
.add input::placeholder { color: var(--muted); }
.add input:focus { border-color: var(--accent); background: transparent; }
.add button {
  width: 52px; border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: var(--on-accent); font-size: 1.6rem; line-height: 1;
  transition: transform .15s;
  box-shadow: 0 10px 20px -8px var(--accent);
}
.add button:hover  { transform: translateY(-2px) scale(1.08) rotate(90deg); }
.add button:active { transform: scale(.92); }

/* --------- filtres --------- */
.filters { display: flex; gap: 6px; margin-bottom: 8px; }
.filters button {
  font: inherit; font-size: .85rem; color: var(--muted);
  background: none; border: 0; border-radius: 99px; padding: 6px 14px; cursor: pointer;
  transition: background .2s, color .2s;
}
.filters button.on { background: var(--line); color: var(--ink); font-weight: 600; }

/* --------- liste --------- */
ul { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 6px; border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.item.enter { animation: enter .45s cubic-bezier(.2, .9, .3, 1.2) both; }
.item.leave { animation: leave .35s ease-in forwards; }
.item.hide  { display: none; }
@keyframes enter { from { opacity: 0; transform: translateX(-24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateX(40px); height: 0; padding: 0; border-width: 0; } }

.check { position: relative; flex: none; width: 28px; height: 28px; cursor: pointer; }
.check input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.box {
  position: absolute; inset: 0; border-radius: 10px;
  border: 2.5px solid var(--muted);
  display: grid; place-items: center;
  transition: background .25s, border-color .25s, transform .25s;
}
.box svg {
  width: 18px; height: 18px; fill: none; stroke: var(--on-accent); stroke-width: 3.2;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .35s .1s ease-out;
}
.check input:focus-visible + .box { outline: 3px solid var(--accent); outline-offset: 3px; }
.check:hover .box { border-color: var(--accent); }
.check input:checked + .box {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  animation: pop .4s cubic-bezier(.3, 1.6, .5, 1);
}
.check input:checked + .box svg { stroke-dashoffset: 0; }
@keyframes pop { 0% { transform: scale(.8); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

.text {
  flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; width: fit-content;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 55% / 0% 2px;
  transition: background-size .4s ease, color .3s;
}
.item.done .text { color: var(--muted); background-size: 100% 2px; }
.spacer { flex: 1; }

.del {
  border: 0; background: none; color: var(--muted); font-size: 1.4rem; line-height: 1;
  cursor: pointer; border-radius: 10px; width: 32px; height: 32px;
  opacity: 0; transition: opacity .2s, color .2s, background .2s;
}
.item:hover .del, .del:focus-visible { opacity: 1; }
.del:hover { color: var(--danger); background: var(--line); }
@media (hover: none) { .del { opacity: .6; } }

.empty { text-align: center; color: var(--muted); padding: 34px 0 20px; display: none; }
.empty.show { display: block; animation: enter .5s both; }
.empty b { display: block; font-size: 2rem; margin-bottom: 6px; }

footer { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); font-size: .85rem; }
footer button { font: inherit; font-size: .85rem; color: var(--muted); background: none; border: 0; cursor: pointer; border-radius: 8px; padding: 4px 8px; }
footer button:hover { color: var(--danger); }

/* --------- confettis --------- */
.dot { position: fixed; font-size: 18px; line-height: 1; pointer-events: none; z-index: 10; animation: fly 1s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }

/* --------- ambiance (neige, cœurs, bulles, chauves-souris…) --------- */
#ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.p {
  position: absolute; top: 0; left: var(--x);
  font-size: var(--size); color: var(--accent);
  opacity: 0; will-change: transform;
  animation-duration: var(--dur); animation-delay: var(--delay);
  animation-timing-function: linear; animation-iteration-count: infinite;
}
.p.fall { animation-name: fall; }
.p.rise { animation-name: rise; }
@keyframes fall {
  0%   { transform: translate3d(0, -10vh, 0) rotate(0); opacity: 0; }
  10%  { opacity: .7; }
  50%  { transform: translate3d(var(--sway), 50vh, 0) rotate(180deg); }
  90%  { opacity: .7; }
  100% { transform: translate3d(0, 110vh, 0) rotate(360deg); opacity: 0; }
}
@keyframes rise {
  0%   { transform: translate3d(0, 110vh, 0) rotate(0); opacity: 0; }
  10%  { opacity: .7; }
  50%  { transform: translate3d(var(--sway), 50vh, 0) rotate(-180deg); }
  90%  { opacity: .7; }
  100% { transform: translate3d(0, -10vh, 0) rotate(-360deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}