/* =========================================================
   Thème pastel
   ========================================================= */

:root {
  --bg: #f6f3fb;
  --blob-1: #ffd9ea;
  --blob-2: #dbe4ff;
  --blob-3: #d9f4e8;
  --blob-4: #ffe5d2;
  --card: rgb(255 255 255 / 0.8);
  --card-solid: #ffffff;
  --card-2: #f4f1fa;
  --field: #f3f0fa;
  --sheet: #faf8fe;
  --text: #2a2640;
  --muted: #8b87a3;
  --line: #ece8f5;
  --accent: #6c5ce7;
  --accent-soft: #eeebff;
  --grad: linear-gradient(135deg, #c6b8ff 0%, #f6b9d7 55%, #ffd3b5 100%);
  --hero: linear-gradient(140deg, #e9e3ff 0%, #ffe3ef 58%, #ffecdd 100%);
  --hero-done: linear-gradient(140deg, #d9f6ea 0%, #e2f0ff 100%);
  --ink: #2a2640;
  --ring-a: #8b7bff;
  --ring-b: #f28cb8;
  --ring-track: rgb(255 255 255 / 0.75);
  --ok: #2b9b75;
  --ok-soft: #dcf5ea;
  --warn: #bd7428;
  --warn-soft: #fff0de;
  --danger: #d4506c;
  --danger-soft: #ffe5eb;
  --shadow: 0 1px 2px rgb(108 92 231 / 0.04), 0 10px 30px rgb(108 92 231 / 0.08);
  --shadow-btn: 0 8px 22px rgb(214 160 220 / 0.45);
  --radius: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Plus Jakarta Sans Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14121f;
    --blob-1: #3a2241;
    --blob-2: #1f2847;
    --blob-3: #15322a;
    --blob-4: #3b2a20;
    --card: rgb(31 28 47 / 0.82);
    --card-solid: #1f1c2f;
    --card-2: #272339;
    --field: #29253c;
    --sheet: #1a1728;
    --text: #efecf9;
    --muted: #a39fba;
    --line: #302b46;
    --accent: #b6a9ff;
    --accent-soft: #2d2752;
    --grad: linear-gradient(135deg, #ab9cff 0%, #f0a6c9 55%, #ffc7a6 100%);
    --hero: linear-gradient(140deg, #2d2752 0%, #3a2541 58%, #3a2b25 100%);
    --hero-done: linear-gradient(140deg, #173a2f 0%, #1d2b45 100%);
    --ink: #1b1830;
    --ring-a: #a99bff;
    --ring-b: #f5a3c7;
    --ring-track: rgb(255 255 255 / 0.1);
    --ok: #82dcb8;
    --ok-soft: #183a2f;
    --warn: #f2c07c;
    --warn-soft: #3d2f1a;
    --danger: #ffa0b4;
    --danger-soft: #45212d;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.28);
    --shadow-btn: 0 8px 22px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Taches de couleur pastel floues en fond */
body::before {
  content: '';
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38vmax 38vmax at 12% 8%, var(--blob-1), transparent 70%),
    radial-gradient(34vmax 34vmax at 92% 22%, var(--blob-2), transparent 70%),
    radial-gradient(40vmax 40vmax at 85% 92%, var(--blob-3), transparent 70%),
    radial-gradient(30vmax 30vmax at 8% 78%, var(--blob-4), transparent 70%);
  opacity: 0.85;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash img { border-radius: 20px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; transform: scale(0.96); } }

/* ---------- mise en page ---------- */

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 118px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 18px;
}
.topbar h1 { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: -0.035em; line-height: 1.15; }
.topbar h1.month-title { font-size: 26px; text-transform: capitalize; }
.eyebrow { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0.01em; }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  display: inline-grid;
  place-items: center;
  flex: none;
  color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.card {
  background: var(--card);
  border: 1px solid rgb(255 255 255 / 0.6);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .card { border-color: rgb(255 255 255 / 0.05); } }
.card + .card, .card + .section-title, .section-title + .card, .btn-row + .card, .card + .btn-row { margin-top: 14px; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 28px 4px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- barre d'onglets flottante ---------- */

.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 12px);
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  background: color-mix(in srgb, var(--card-solid) 78%, transparent);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgb(255 255 255 / 0.65);
  border-radius: 26px;
  box-shadow: 0 12px 36px rgb(108 92 231 / 0.16);
  padding: 6px;
}
@media (prefers-color-scheme: dark) {
  .tabbar { border-color: rgb(255 255 255 / 0.07); box-shadow: 0 12px 36px rgb(0 0 0 / 0.45); }
}
.tabbar nav { display: flex; position: relative; }
.tabbar a {
  flex: 1;
  position: relative;
  z-index: 1;
  text-decoration: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 0 6px;
  font-size: 11px;
  font-weight: 700;
  transition: color 0.25s;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.active { color: var(--accent); }
.tab-indicator {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(100% / var(--n, 4));
  pointer-events: none;
  padding: 0 4px;
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.45s var(--ease-spring);
}
.tab-indicator::before {
  content: '';
  display: block;
  height: 100%;
  border-radius: 20px;
  background: var(--accent-soft);
}

/* ---------- boutons ---------- */

.btn {
  border: 0;
  border-radius: 18px;
  padding: 15px 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: var(--grad);
  color: var(--ink);
  box-shadow: var(--shadow-btn);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; box-shadow: none; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn.small { padding: 10px 14px; border-radius: 14px; font-size: 14px; width: auto; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 4px 0; font-size: 14px; }

/* ---------- carte principale ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--hero);
  border-color: rgb(255 255 255 / 0.7);
  padding: 20px;
}
.hero.done { background: var(--hero-done); }
.hero-text h2 { margin: 0 0 4px; font-size: 21px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.2; }
.hero-text p { margin: 0; color: var(--muted); font-size: 14px; }
.ring { position: relative; flex: none; }
.ring svg { display: block; transform: rotate(-90deg); }
.ring .ring-track { stroke: var(--ring-track); }
.ring .ring-value { stroke: url(#ring-grad); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label strong { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.ring-label .tick { color: var(--ok); font-size: 34px; line-height: 1; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--card-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- personnes ---------- */

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #2a2640;
  flex: none;
  font-size: 16px;
}
.avatar.sm { width: 30px; height: 30px; border-radius: 11px; font-size: 12px; }
.avatars { display: flex; flex: none; }
.avatars .avatar + .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--card-solid); }

.member + .member { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.member-name { font-weight: 700; }
.member-amount { text-align: right; }
.member-amount strong { display: block; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.bar { height: 10px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 12px; }
.bar > div { height: 100%; border-radius: inherit; }
.carry { font-size: 12.5px; margin-top: 7px; color: var(--muted); }

/* ---------- listes ---------- */

.list { margin: 0; padding: 0; list-style: none; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list > li.clickable { cursor: pointer; }
.list .emoji {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--tile, var(--card-2)) 55%, var(--card-solid));
  display: grid;
  place-items: center;
  font-size: 19px;
  flex: none;
}
@media (prefers-color-scheme: dark) {
  .list .emoji { background: color-mix(in srgb, var(--tile, var(--card-2)) 22%, var(--card-solid)); }
}
.list .title { font-weight: 600; }
.list .sub { font-size: 13px; color: var(--muted); }
.list .amount { font-weight: 700; white-space: nowrap; }
.list .amount.neg::before { content: '−'; }
.list li.done .title, .list li.done .amount { color: var(--muted); }
.list li.done .title { text-decoration: line-through; text-decoration-color: var(--line); }

.check {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--card-solid);
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  color: var(--ink);
}
.check.on { background: var(--grad); border-color: transparent; }
.check svg { width: 15px; height: 15px; }

.del {
  border: 0;
  background: var(--card-2);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 17px;
  flex: none;
}

.totals { display: grid; gap: 9px; }
.totals .row { justify-content: space-between; }
.totals .sum { border-top: 1px solid var(--line); padding-top: 11px; font-weight: 800; font-size: 17px; }

.empty { text-align: center; color: var(--muted); padding: 20px 8px; font-size: 14px; }

/* ---------- sélecteur à pastille ---------- */

.segmented {
  position: relative;
  display: flex;
  background: var(--field);
  border-radius: 16px;
  padding: 4px;
  gap: 4px;
}
.seg-pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px - (var(--n) - 1) * 4px) / var(--n));
  border-radius: 12px;
  background: var(--card-solid);
  box-shadow: 0 2px 8px rgb(108 92 231 / 0.12);
  transform: translateX(calc(var(--i) * (100% + 4px)));
  transition: transform 0.4s var(--ease-spring);
}
.segmented button {
  position: relative;
  z-index: 1;
  flex: 1;
  border: 0;
  background: none;
  padding: 9px 6px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.25s;
}
.segmented button.on { color: var(--text); }

/* ---------- formulaires ---------- */

.field { display: block; }
.field + .field, .field + .row, .row + .field { margin-top: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.input {
  width: 100%;
  border: 1.5px solid transparent;
  background: var(--field);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  font-size: 16px; /* évite le zoom auto sur iOS */
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--accent); background: var(--card-solid); box-shadow: 0 0 0 4px var(--accent-soft); }
.money-input { position: relative; }
.money-input .input { padding-right: 38px; }
.money-input.big .input {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  padding: 16px 44px;
  border-radius: 20px;
}
.money-input::after {
  content: '€';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 700;
}
.money-input.big::after { font-size: 24px; right: 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid transparent;
  background: var(--field);
  border-radius: 99px;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.switch-row + .switch-row, .switch-row + .field, .field + .switch-row { margin-top: 16px; }
.switch {
  position: relative;
  width: 52px;
  height: 32px;
  flex: none;
  border-radius: 99px;
  border: 0;
  background: var(--line);
  padding: 0;
  transition: background 0.25s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.18);
}
.switch.on { background: var(--grad); }
.switch.on::after { transform: translateX(20px); }

.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot { width: 36px; height: 36px; border-radius: 13px; border: 3px solid transparent; outline: 2px solid transparent; padding: 0; }
.color-dot.on { outline-color: var(--accent); border-color: var(--card-solid); }

.error-msg { color: var(--danger); font-size: 14px; font-weight: 600; margin-top: 10px; }

.both-parts { margin: 4px 0 14px; padding: 6px 14px; }
.both-parts .row { padding: 8px 0; }
.both-parts .row + .row { border-top: 1px solid var(--line); }
.both-parts .input { padding-top: 10px; padding-bottom: 10px; text-align: right; }

/* ---------- panneau du bas ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(42 38 64 / 0.32);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--sheet);
  border-radius: 30px 30px 0 0;
  padding: 10px 18px calc(var(--safe-bottom) + 20px);
  box-shadow: 0 -10px 40px rgb(42 38 64 / 0.15);
}
.sheet-handle { touch-action: none; cursor: grab; padding-top: 2px; }
.sheet-grip { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 18px; font-size: 22px; font-weight: 800; letter-spacing: -0.025em; }
.sheet .card { background: var(--card-solid); }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 30px; }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 98px);
  transform: translateX(-50%);
  z-index: 100;
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 600;
  width: max-content;
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 10px 30px rgb(42 38 64 / 0.25);
}
.toast.error { background: var(--danger); color: #fff; }

.offline-banner {
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 7px;
  border-radius: 12px;
  margin-bottom: 12px;
}

/* ---------- connexion ---------- */

.auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
}
.auth-logo { width: 78px; height: 78px; border-radius: 24px; display: block; margin: 0 auto 20px; box-shadow: var(--shadow-btn); }
.auth h1 { text-align: center; margin: 0 0 8px; font-size: 30px; font-weight: 800; letter-spacing: -0.035em; }
.auth > p { text-align: center; color: var(--muted); margin: 0 0 26px; }

/* ---------- historique ---------- */

.month-row { cursor: pointer; }
.month-row .label { font-weight: 800; letter-spacing: -0.01em; text-transform: capitalize; }
.mini-members { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.mini-members span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- squelettes ---------- */

.skeleton + .skeleton { margin-top: 14px; }
.sk {
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--card-2) 0%, var(--line) 50%, var(--card-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.sk-circle { width: 42px; height: 42px; border-radius: 15px; flex: none; }

/* ---------- confettis ---------- */

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); } }

/* =========================================================
   Mouvement
   ========================================================= */

:root {
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-out-strong: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.45, .64, 1);
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes in-right { from { opacity: 0; transform: translateX(32px); } }
@keyframes in-left { from { opacity: 0; transform: translateX(-32px); } }
@keyframes item-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop {
  0% { opacity: 0; transform: scale(.4); }
  60% { opacity: 1; transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes title-in { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px) scale(.94); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 8px) scale(.96); } }

/* Entrée des écrans : chaque bloc monte en douceur, légèrement décalé */
.view > *, .month-body > * { animation: rise .5s var(--ease-out-strong) backwards; }
.view > .month-body { animation: none; }
.month-body.from-right > * { animation-name: in-right; }
.month-body.from-left > * { animation-name: in-left; }
.view > :nth-child(2), .month-body > :nth-child(2) { animation-delay: 40ms; }
.view > :nth-child(3), .month-body > :nth-child(3) { animation-delay: 80ms; }
.view > :nth-child(4), .month-body > :nth-child(4) { animation-delay: 120ms; }
.view > :nth-child(5), .month-body > :nth-child(5) { animation-delay: 160ms; }
.view > :nth-child(6), .month-body > :nth-child(6) { animation-delay: 200ms; }
.view > :nth-child(7), .month-body > :nth-child(7) { animation-delay: 240ms; }
.view > :nth-child(n+8), .month-body > :nth-child(n+8) { animation-delay: 280ms; }

.month-title { animation: title-in .35s var(--ease-out) backwards; }

.auth > * { animation: rise .6s var(--ease-out-strong) backwards; }
.auth > :nth-child(2) { animation-delay: 60ms; }
.auth > :nth-child(3) { animation-delay: 120ms; }
.auth > :nth-child(4) { animation-delay: 180ms; }
.auth > :nth-child(n+5) { animation-delay: 240ms; }
.auth-logo { animation: pop .7s var(--ease-spring) backwards !important; }

.list > li { animation: item-in .35s var(--ease-out) backwards; }

.ring .ring-value { transition: stroke-dashoffset 1.1s var(--ease-out-strong), opacity .2s; }
.bar > div { transition: width 1s var(--ease-out-strong) .1s; }
.ring-label .tick { animation: pop .6s var(--ease-spring) .45s backwards; }
.badge.pop { animation: pop .45s var(--ease-spring) backwards; }

/* Retour tactile */
.btn, .icon-btn, .chip, .check, .color-dot, .link-btn, .del {
  transition: transform .18s var(--ease-out), background-color .2s, color .2s, border-color .2s, opacity .2s, box-shadow .2s, outline-color .2s;
}
.btn:active { transform: scale(.97); }
.icon-btn:not(:disabled):active, .chip:active, .del:active { transform: scale(.9); }
.check:active { transform: scale(.82); }
.check.on svg { animation: pop .35s var(--ease-spring); }
.color-dot.on { transform: scale(1.1); }
.list > li.clickable { transition: opacity .15s; }
.list > li.clickable:active { opacity: .6; }
.list li .title, .list li .amount { transition: color .25s; }
.month-row { transition: transform .18s var(--ease-out); }
.month-row:active { transform: scale(.98); }
.input { transition: border-color .2s, box-shadow .2s, background-color .2s; }
.switch::after { transition: transform .32s var(--ease-spring); }
.tabbar a.active svg { animation: pop .45s var(--ease-spring); }

/* Panneaux du bas : entrée élastique, sortie qui glisse */
.sheet-backdrop { animation: fade .3s ease; transition: opacity .24s ease; }
.sheet-backdrop.closing { opacity: 0; }
.sheet {
  animation: slide-up .45s var(--ease-out-strong);
  transition: transform .24s cubic-bezier(.4, 0, 1, 1);
  will-change: transform;
}
.sheet-backdrop.closing .sheet { transform: translateY(100%); }
.sheet form > * { animation: rise .45s var(--ease-out-strong) backwards; }
.sheet form > :nth-child(2) { animation-delay: 40ms; }
.sheet form > :nth-child(3) { animation-delay: 80ms; }
.sheet form > :nth-child(n+4) { animation-delay: 120ms; }
@media (min-width: 700px) {
  .sheet { animation-name: sheet-in; }
  .sheet-backdrop.closing .sheet { transform: translateY(24px) scale(.97); }
}

.toast { animation: toast-in .4s var(--ease-spring) backwards; }
.toast.leaving { animation: toast-out .22s ease forwards; }

/* Mouvement réduit (réglage d'accessibilité du téléphone) : on garde des fondus, sans déplacement. */
@media (prefers-reduced-motion: reduce) {
  @keyframes rise { from { opacity: 0; } }
  @keyframes in-right { from { opacity: 0; } }
  @keyframes in-left { from { opacity: 0; } }
  @keyframes item-in { from { opacity: 0; } }
  @keyframes slide-up { from { opacity: 0; } }
  @keyframes sheet-in { from { opacity: 0; } }
  @keyframes pop { from { opacity: 0; } }
  @keyframes title-in { from { opacity: 0; } }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 0); } }
  @keyframes toast-out { to { opacity: 0; transform: translate(-50%, 0); } }
  .sheet-backdrop.closing .sheet { transform: none; opacity: 0; transition: opacity .2s; }
  .btn:active, .icon-btn:not(:disabled):active, .chip:active, .del:active, .check:active, .month-row:active { transform: none; }
  .confetti { display: none; }
}

/* ---------- historique détaillé ---------- */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
.stat { background: var(--card-2); border-radius: 16px; padding: 12px 14px; display: grid; gap: 2px; }
.stat span { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat strong { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }

.chevron { color: var(--muted); font-size: 22px; line-height: 1; transition: transform .3s var(--ease-out); }
.month-row.open .chevron { transform: rotate(90deg); }
.month-row.open:active { transform: none; }
.month-details {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  cursor: default;
  animation: rise .35s var(--ease-out-strong) backwards;
}
.detail-people { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.detail-person { background: var(--card-2); border-radius: 16px; padding: 12px; font-size: 13px; display: grid; gap: 3px; }

.stat.aid { grid-column: span 2; background: var(--ok-soft); }
.stat.aid strong { color: var(--ok); }

/* ---------- budget synchronisé ---------- */

.budget-amount { font-size: 34px; font-weight: 800; letter-spacing: -0.035em; margin-top: 2px; }
.budget-people { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.budget-person { display: flex; align-items: center; gap: 9px; background: var(--card-2); border-radius: 14px; padding: 9px 10px; }
.tick-sm { color: var(--ok); font-weight: 800; }
.mini-bar { height: 5px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 7px; max-width: 160px; }
.mini-bar > div { height: 100%; border-radius: inherit; background: var(--grad); transition: width 1s var(--ease-out-strong); }
.mini-bar > div.full { background: var(--ok); opacity: .6; }
.cov-ok { color: var(--ok); font-weight: 700; }

/* Compte actif + choix du compte */
.space-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  max-width: 100%;
  transition: transform .2s var(--ease-spring);
}
.space-chip:active { transform: scale(.96); }
.space-chip .avatar.sm { width: 28px; height: 28px; border-radius: 50%; font-size: 11px; }
.space-chip svg { color: var(--muted); flex: none; }
.space-chip .avatars .avatar + .avatar, .account-list .avatars .avatar + .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--card-solid); }
.account-list .avatar { border-radius: 50%; }
.account-list .avatars { min-width: 52px; }
.account-list li.on .title { color: var(--accent); }

/* Tirer pour recharger */
.ptr {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 50%;
  z-index: 50;
  width: 48px; height: 48px;
  padding: 4px;
  border-radius: 50%;
  background: var(--card-solid);
  box-shadow: var(--shadow-btn);
  pointer-events: none;
}
.ptr.settle { transition: transform .45s var(--ease-spring), opacity .3s; }
.ptr img { display: block; width: 100%; height: 100%; border-radius: 50%; transition: transform .1s; }
.ptr.ready img { box-shadow: 0 0 0 3px var(--accent); }
.ptr.loading { animation: ptr-bounce .5s var(--ease-spring); }
.ptr.loading img { animation: ptr-spin .7s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
@keyframes ptr-bounce { 0% { scale: .7; } 60% { scale: 1.15; } 100% { scale: 1; } }
@media (prefers-reduced-motion: reduce) { .ptr.loading, .ptr.loading img { animation: none; } }
