/* Escale : une colonne façon iPhone, sombre d'abord, clair si l'iPhone l'est.
   Jetons repris de Fonte (docs/phase-0/06-design.md) et de la maquette validée. */

:root {
  color-scheme: light dark;
  --bg: light-dark(#f2f2f7, #000000);
  --card: light-dark(#ffffff, #1c1c1e);
  --card2: light-dark(#efeff4, #2c2c2e);
  --pressed: light-dark(#e5e5ea, #3a3a3c);
  --sep: light-dark(rgb(60 60 67 / 0.29), rgb(84 84 88 / 0.65));
  --fg: light-dark(#000000, #ffffff);
  --fg2: light-dark(rgb(60 60 67 / 0.76), rgb(235 235 245 / 0.6));
  --fg3: light-dark(rgb(60 60 67 / 0.3), rgb(235 235 245 / 0.3));
  --blue: light-dark(#007aff, #0a84ff);
  --green: light-dark(#248a3d, #30d158);
  --orange: light-dark(#c75000, #ff9f0a);
  --red: light-dark(#e0281e, #ff453a);
  --pink: light-dark(#d30f45, #ff375f);
  --purple: light-dark(#9a45c7, #bf5af2);
  --teal: light-dark(#00829b, #40c8e0);
  --indigo: light-dark(#5856d6, #5e5ce6);
  --yellow: light-dark(#a26b00, #ffd60a);
  --green-tint: light-dark(rgb(36 138 61 / 0.2), rgb(48 209 88 / 0.18));
  --glass: light-dark(rgb(255 255 255 / 0.78), rgb(30 30 32 / 0.72));
  --shadow-glass: inset 0 0 0 0.5px light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.14)), 0 8px 24px light-dark(rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.45));
  --shadow-edge: -10px 0 24px -12px light-dark(rgb(0 0 0 / 0.28), rgb(0 0 0 / 0.75));
  --scrim: light-dark(rgb(0 0 0 / 0.25), rgb(0 0 0 / 0.5));
  --seg-on: light-dark(#ffffff, #636366);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  /* Ressorts d'Apple pour ce qui se joue en CSS (guide de Fonte) : sans dépassement. */
  --ease-spring: cubic-bezier(0.18, 0.65, 0.08, 0.99);
  --ease-sheet: cubic-bezier(0.28, 0.42, 0.06, 1);
  --tabbar: 62px;
  --bas: max(12px, calc(env(safe-area-inset-bottom, 0px) - 12px));
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--bg); overflow: clip; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--fg); font: 17px/22px var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; overflow: clip; overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button, a, [role="checkbox"], [role="radio"] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
a { color: var(--blue); text-decoration: none; }

/* ---------- pages ---------- */
.ecran { position: fixed; inset: 0; background: var(--bg); will-change: transform; }
#ecran-voyage { z-index: 2; box-shadow: var(--shadow-edge); }
.defile { height: 100%; overflow-y: auto; overflow-x: clip; overscroll-behavior-y: contain; }
/* Un pixel de plus que l'écran : la zone garde son rebond même quand tout tient (piège de Fonte). */
.defile > .app { min-height: calc(100% + 1px); }
.voile { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 3; }
.app {
  max-width: 480px; margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabbar) + var(--bas) + 32px) max(16px, env(safe-area-inset-left, 0px));
}
.apparait > * { animation: appear 260ms var(--ease-sheet) both; }
@keyframes appear { from { opacity: 0; transform: translate3d(0, 8px, 0); } }

/* ---------- en-tête ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.retour { display: inline-flex; align-items: center; gap: 6px; color: var(--blue); font-size: 17px; min-height: 44px; margin-left: -4px; padding-right: 8px; }
.boutons-haut { display: flex; gap: 10px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 46px; text-align: left; }
#erreurNouveau:empty { display: none; }
.rond { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--fg); background: var(--card); margin-right: -4px; }
.rond svg { width: 24px; height: 24px; }
.rond.petit { width: 36px; height: 36px; background: var(--blue); color: #fff; margin-right: 0; }
.rond.petit svg { width: 20px; height: 20px; }
.boutons-haut { align-items: center; }
.rond:active { transform: scale(0.94); }
.statut { font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--card); color: var(--fg2); white-space: nowrap; }
.s-vert { color: var(--green); }
.s-orange { color: var(--orange); }
.s-rouge { color: #fff; background: var(--red); }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--fg2); }
h1 { font: 700 34px/41px var(--display); letter-spacing: -0.02em; margin: 2px 0 4px; text-wrap: balance; }
.sub { color: var(--fg2); font-size: 15px; line-height: 20px; margin: 0 0 14px; }
.simule { margin: -6px 0 12px; }
h2 { font: 700 22px/28px var(--display); letter-spacing: -0.01em; margin: 28px 2px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
h2 small { font: 400 15px var(--font); color: var(--fg2); letter-spacing: 0; }

/* ---------- groupes façon Réglages ---------- */
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; position: relative; width: 100%; text-align: left; min-height: 48px; cursor: pointer; }
div.row:not([data-act]) { cursor: default; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 56px; border-top: 0.5px solid var(--sep); }
.group.plain .row + .row::before { left: 16px; }
.row-main { flex: 1; min-width: 0; display: block; text-align: left; }
.row-title { display: block; font-size: 17px; line-height: 22px; }
.row-title.small { font-size: 15px; line-height: 20px; }
.row-title.fort { font-weight: 600; display: inline; }
.row-title.lien { color: var(--blue); }
.row-detail { display: block; font-size: 15px; line-height: 20px; color: var(--fg2); margin-top: 1px; }
.row-detail.grand { font-size: 17px; line-height: 22px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-right { color: var(--fg2); font-size: 15px; display: flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; max-width: 55%; font-variant-numeric: tabular-nums; }
.row-right .pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row-right .chev { flex: none; }
.chev { width: 8px; height: 13px; flex: none; opacity: 0.55; }
.done .row-title { color: var(--fg2); text-decoration: line-through; text-decoration-color: var(--fg3); }
.who { display: block; font-size: 13px; color: var(--fg2); margin-top: 4px; }
.links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; font-size: 15px; font-weight: 600; }
.min0 { min-width: 0; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 8px; }
.red { color: var(--red) !important; }
.green { color: var(--green) !important; }
.orange { color: var(--orange) !important; }
.bleu { color: var(--blue) !important; margin-left: 0 !important; }

/* Appui : réduction à 97 % en 120 ms, seul retour tactile possible sur le web (Fonte). */
.row[data-act], .btn, .opt, .chip, .tab, .retour { transition: transform 120ms ease-out, background-color 120ms ease-out; }
.row[data-act]:active, .opt:active { background-color: var(--pressed); }
.btn:active, .chip:active { transform: scale(0.97); }

/* ---------- coche ronde ---------- */
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--fg3); flex: none; display: grid; place-items: center; }
.check.on { background: var(--green); border-color: var(--green); }
.check svg { opacity: 0; }
.check.on svg { opacity: 1; }
.check.vient.on { animation: coche 410ms var(--ease-spring); }
.check.vient:not(.on) { animation: decoche 260ms var(--ease-sheet); }
@keyframes coche { 0% { transform: scale(0.6); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes decoche { from { transform: scale(0.85); } }
.pill.vient, .vient-ligne { animation: appear 260ms var(--ease-sheet) both; }
.icon { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; color: #fff; }
.icon svg { width: 17px; height: 17px; }
.icon.grand { width: 44px; height: 44px; border-radius: 10px; }
.icon.grand svg { width: 24px; height: 24px; }

/* ---------- pastilles ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; vertical-align: 1px; }
.p-orange { background: color-mix(in srgb, var(--orange) 20%, transparent); color: var(--orange); }
.p-green { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.p-blue { background: color-mix(in srgb, var(--blue) 20%, transparent); color: var(--blue); }
.p-purple { background: color-mix(in srgb, var(--purple) 22%, transparent); color: var(--purple); }
.p-red { background: color-mix(in srgb, var(--red) 20%, transparent); color: var(--red); }
.p-gray { background: var(--card2); color: var(--fg2); }

/* ---------- cartes ---------- */
.deadline, .ready, .now, .budget-head { background: var(--card); border-radius: 22px; padding: 16px; }
.deadline { display: grid; gap: 14px; }
.deadline-head { display: flex; gap: 12px; align-items: flex-start; }
.deadline-t { font-size: 17px; font-weight: 600; margin-top: 2px; }
.count { font: 700 28px/34px var(--rounded); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--orange); }
.count.late { color: var(--red); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { flex: 1; min-width: 120px; min-height: 50px; padding: 13px 16px; border-radius: 999px; font-size: 17px; font-weight: 600; text-align: center; background: var(--card2); color: var(--blue); display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.rouge { color: var(--red); }
.btn.small { flex: none; min-width: 0; min-height: 36px; padding: 7px 14px; font-size: 15px; }
.ready { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.ready svg { display: block; }
.big { font: 700 34px/38px var(--rounded); font-variant-numeric: tabular-nums; }
.legend { display: grid; gap: 4px; margin-top: 4px; font-size: 13px; color: var(--fg2); }
.legend.row { display: flex; gap: 16px; padding: 0; min-height: 0; cursor: default; }
.legend.row::before { display: none; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--c); vertical-align: 1px; }
.anneau-vient { animation: anneau 900ms var(--ease-sheet) both; }
@keyframes anneau { from { stroke-dasharray: 0.001 var(--tour); } }
.propo { cursor: default; }
.propo .btn { margin-left: 4px; }

.now { display: grid; gap: 10px; }
.now .k { font-size: 13px; font-weight: 600; color: var(--green); text-transform: uppercase; letter-spacing: 0.04em; }
.now.next { margin-top: 10px; }
.now.next .k { color: var(--blue); }
.now .t { font: 700 28px/34px var(--display); letter-spacing: -0.015em; }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--fg2); font-size: 15px; align-items: center; }

/* ---------- programme ---------- */
.zone { margin-top: 18px; }
.zone-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg2); margin: 0 4px 6px; display: flex; align-items: center; gap: 6px; }
.zone-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.step .time { width: 48px; flex: none; font: 600 15px var(--rounded); font-variant-numeric: tabular-nums; }
.step .time.est { color: var(--fg3); }
.step .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c); }
.group.steps .row + .row::before { left: 86px; }
.step.dim { opacity: 0.38; }
.step.is-now { background: color-mix(in srgb, var(--green) 12%, transparent); }
.filters { display: flex; gap: 8px; margin: 12px 0 0; flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--card); font-size: 15px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--purple); color: #fff; }
.day-cap { color: var(--fg2); font-size: 15px; margin: 10px 4px 0; }

/* ---------- contrôle segmenté ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--card2); border-radius: 9px; padding: 2px; min-width: 0; }
.seg button { font-size: 13px; font-weight: 500; padding: 6px; border-radius: 7px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background-color 410ms var(--ease-spring); }
.seg button[aria-pressed="true"] { background: var(--seg-on); box-shadow: 0 1px 3px light-dark(rgb(0 0 0 / 0.12), transparent); font-weight: 600; }
.seg.big button { font-size: 15px; padding: 8px; min-height: 36px; }
.seg.big.serre button { font-size: 12px; padding: 8px 2px; }
.seg.petit { flex: none; width: 160px; }

/* ---------- budget ---------- */
.budget-head { display: grid; gap: 12px; }
.money { font: 700 34px/38px var(--rounded); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.track { height: 10px; border-radius: 6px; background: var(--card2); position: relative; overflow: hidden; }
.track i { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.track i.reel { left: 0; background: var(--blue); opacity: 0.9; }
.track b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg); border-radius: 1px; }
.scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg2); font-variant-numeric: tabular-nums; }
.note { font-size: 13px; line-height: 18px; color: var(--fg2); margin: 8px 4px 0; }
.empty { padding: 22px 16px; text-align: center; color: var(--fg2); font-size: 15px; }
.foot { text-align: center; color: var(--fg2); font-size: 12px; line-height: 16px; margin-top: 28px; }

/* ---------- barre d'onglets flottante, façon iOS 26 ---------- */
.tabbar {
  position: absolute; left: 20px; right: 20px; bottom: var(--bas); height: var(--tabbar); z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 999px;
  background: var(--glass); box-shadow: var(--shadow-glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  max-width: 440px; margin: 0 auto;
}
.tab-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 999px; background: var(--fg3); opacity: 0.45; transform: translate3d(calc(var(--i) * 100%), 0, 0); transition: transform 410ms var(--ease-spring); }
.tab { position: relative; display: grid; justify-items: center; align-content: center; gap: 1px; font-size: 10px; line-height: 12px; font-weight: 600; color: var(--fg); border-radius: 999px; }
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--blue); }

/* ---------- feuilles ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; opacity: 0; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; will-change: transform; }
.sheet-in {
  max-width: 480px; margin: 0 auto; background: var(--bg); border-radius: 28px 28px 0 0; max-height: calc(var(--visible, 100vh) - 48px - env(safe-area-inset-top, 0px));
  overflow-y: auto; overflow-x: clip; overscroll-behavior: contain;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.sheet.clavier .sheet-in { padding-bottom: 16px; border-radius: 28px; }
#erreurDepense:empty { display: none; }
.grab { width: 36px; height: 5px; border-radius: 3px; background: var(--fg3); margin: 0 auto 8px; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-top.saisie { min-height: 44px; margin-bottom: 4px; }
.lien-barre { color: var(--blue); font-size: 17px; min-height: 44px; padding: 0 4px; }
.lien-barre.fort { font-weight: 600; }
.barre-titre { font-size: 17px; font-weight: 600; text-align: center; flex: 1; }
.sheet h3 { font: 700 22px/28px var(--display); letter-spacing: -0.01em; margin: 6px 0 4px; text-wrap: balance; }
.opt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 14px 16px; text-align: left; width: 100%; border-radius: 16px; background: var(--card); border: 2px solid transparent; margin-top: 8px; cursor: pointer; transition: border-color 260ms var(--ease-sheet), background-color 120ms; }
.opt[aria-checked="true"] { border-color: var(--green); }
.opt .check { margin-top: 1px; }
.opt .price { font-size: 15px; color: var(--fg2); font-variant-numeric: tabular-nums; white-space: nowrap; max-width: 9em; white-space: normal; text-align: right; }
.field-label { font-size: 13px; color: var(--fg2); margin: 16px 4px 6px; text-transform: uppercase; letter-spacing: 0.03em; }
input[type="text"], input[type="password"], input[type="date"], textarea { width: 100%; font: 17px/22px var(--font); color: var(--fg); background: var(--card); border: 0; border-radius: 12px; padding: 12px 14px; }
textarea { min-height: 140px; resize: vertical; }
.amount { font: 700 48px/1 var(--rounded) !important; text-align: center; font-variant-numeric: tabular-nums; background: transparent !important; padding: 12px 8px !important; }

/* ---------- accueil ---------- */
.accueil { padding-top: 32px; }
.logo { width: 72px; height: 72px; border-radius: 18px; background: linear-gradient(180deg, #40c8e0, #0a84ff); display: grid; place-items: center; margin-bottom: 12px; }
.logo svg { width: 38px; height: 38px; }

/* ---------- bandeau de mise à jour ---------- */
.bandeau {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar) + var(--bas) + 12px); z-index: 25; max-width: 440px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--glass); box-shadow: var(--shadow-glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  font-size: 15px; font-weight: 600; animation: appear 260ms var(--ease-sheet) both;
}
.bandeau button { background: var(--blue); color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 600; white-space: nowrap; }

/* ---------- message ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--bas) + 16px); transform: translate3d(-50%, 12px, 0); z-index: 30;
  background: var(--card2); color: var(--fg); font-size: 15px; font-weight: 500; padding: 10px 16px; border-radius: 999px;
  opacity: 0; transition: opacity 260ms var(--ease-sheet), transform 410ms var(--ease-spring);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.3); max-width: calc(100% - 32px); text-align: center; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate3d(-50%, 0, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
