/* ==========================================================================
   MyLife — thème sombre premium
   Un seul thème, assumé : la palette est calibrée pour l'OLED de l'iPhone.
   Contrastes vérifiés sur fond #0B0B0E (tous > 4.5:1).
   ========================================================================== */

:root {
  /* Fonds — dégradé de profondeur, jamais de noir pur (trop dur en OLED) */
  --bg:        #0B0B0E;
  --bg-2:      #101014;
  --surface:   rgba(255, 255, 255, .038);
  --surface-2: rgba(255, 255, 255, .065);
  --line:      rgba(255, 255, 255, .085);
  --line-warm: rgba(212, 175, 98, .28);

  /* Or — éclairci pour rester lisible sur fond sombre */
  --gold:      #D4AF62;
  --gold-soft: #EBD9A8;
  --gold-deep: #8A6D2F;

  /* Texte */
  --ink:       #F4F1EA;   /* 17.2:1 */
  --ink-2:     #C9C4B8;   /* 11.1:1 */
  --muted:     #918B7E;   /*  5.4:1 */

  --ok:   #6FD39B;
  --warn: #E5B85C;
  --err:  #F0796B;

  --r:    20px;
  --r-sm: 14px;
  --r-xs: 10px;

  /* Space Grotesk n'a pas de vraie italique : ne jamais utiliser font-style
     italic dessus, le navigateur fabriquerait une oblique bancale. */
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --body:    "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  font-family: var(--body);
  font-size: 16px;                 /* jamais moins : lisibilité mobile */
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 50% -14%, rgba(212,175,98,.10), transparent 62%),
    radial-gradient(760px 460px at 92% 8%,   rgba(120,140,255,.055), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 34%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;   /* chiffres alignés, essentiel ici */
}

/* ---------- Structure ---------- */

.page {
  display: none;
  padding: calc(30px + var(--safe-t)) 18px calc(112px + var(--safe-b));
  max-width: 680px; margin: 0 auto;
}
.page.active { display: block; }
.page.active > * { animation: rise .5s var(--ease) both; }
.page.active > *:nth-child(2) { animation-delay: .04s; }
.page.active > *:nth-child(3) { animation-delay: .08s; }
.page.active > *:nth-child(4) { animation-delay: .12s; }
.page.active > *:nth-child(n+5) { animation-delay: .16s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.head { margin-bottom: 22px; }
.title {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.95rem, 7.6vw, 2.5rem); line-height: 1.1;
  letter-spacing: -.035em;          /* une grotesque en gros corps a besoin d'être resserrée */
}
.title em {
  font-style: normal; font-weight: 400; color: var(--gold-soft);
}
.subtitle { color: var(--muted); font-size: .88rem; margin-top: 6px; letter-spacing: .01em; }

.eyebrow {
  font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .16em; color: var(--gold);
}

/* ---------- Carte de tête ---------- */

.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r); padding: 26px 24px 24px;
  background:
    linear-gradient(158deg, rgba(212,175,98,.14), rgba(212,175,98,.02) 46%),
    var(--surface-2);
  border: 1px solid var(--line-warm);
  margin-bottom: 12px;
}
/* Halo diffus : donne de la profondeur sans image */
.hero::before {
  content: ''; position: absolute; inset: -55% 32% auto -22%; height: 190%;
  background: radial-gradient(closest-side, rgba(212,175,98,.16), transparent 72%);
  pointer-events: none;
}
.hero > * { position: relative; }

.figure {
  font-family: var(--display); font-weight: 500;
  font-size: clamp(2.9rem, 14vw, 4.2rem); line-height: 1;
  letter-spacing: -.05em; margin: 10px 0 4px;
  background: linear-gradient(178deg, #FFFDF7, var(--gold-soft) 88%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.figure.alert { background: none; color: var(--err); -webkit-text-fill-color: var(--err); }
.hero-note { color: var(--ink-2); font-size: .87rem; }

.bar { height: 5px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 18px; }
.bar > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-soft));
  transition: width .7s var(--ease);
}
.bar.over > i { background: linear-gradient(90deg, #8A3428, var(--err)); }

/* ---------- Grille ---------- */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 16px 17px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card-label {
  font-size: .67rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .13em; color: var(--muted);
}
.card-figure {
  font-family: var(--display); font-weight: 500; font-size: 1.65rem;
  line-height: 1.15; letter-spacing: -.03em; margin-top: 5px; color: var(--ink);
}
.card-sub { font-size: .76rem; color: var(--muted); margin-top: 1px; }

/* ---------- Lignes ---------- */

.section {
  font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .16em; color: var(--gold);
  margin: 30px 0 12px; display: flex; align-items: center; gap: 12px;
}
.section::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.row {
  display: flex; align-items: center; gap: 14px;
  min-height: 44px;                       /* cible tactile */
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 14px 16px; margin-bottom: 8px;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.row.tappable { cursor: pointer; }
.row.tappable:hover { background: var(--surface-2); border-color: var(--line-warm); }
.row.done { opacity: .45; }
.row.done .row-name { text-decoration: line-through; }

.row-ico {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, rgba(212,175,98,.18), rgba(212,175,98,.05));
  border: 1px solid rgba(212,175,98,.16);
  color: var(--gold-soft);
}
.row-ico svg { width: 19px; height: 19px; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 500; font-size: .95rem; letter-spacing: -.005em; }
.row-sub { font-size: .79rem; color: var(--muted); margin-top: 2px; }
.row-val { font-family: var(--display); font-weight: 500; font-size: 1.12rem;
           letter-spacing: -.025em; white-space: nowrap; color: var(--ink); }
.row-val.small { font-family: var(--body); font-size: .84rem; color: var(--ink-2); }

.tag {
  font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  padding: 5px 10px; border-radius: 99px; white-space: nowrap;
  background: rgba(212,175,98,.13); color: var(--gold-soft);
  border: 1px solid rgba(212,175,98,.2);
}
.tag.urgent { background: rgba(240,121,107,.13); color: var(--err); border-color: rgba(240,121,107,.26); }
.tag.ok     { background: rgba(111,211,155,.12); color: var(--ok);  border-color: rgba(111,211,155,.24); }

.empty {
  color: var(--muted); font-size: .87rem; padding: 24px 18px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r-sm); line-height: 1.6;
}

.note {
  border-left: 2px solid var(--gold); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: linear-gradient(90deg, rgba(212,175,98,.09), rgba(212,175,98,.015));
  padding: 15px 17px; font-size: .87rem; color: var(--ink-2); margin: 14px 0;
}
.note b { color: var(--ink); font-weight: 600; }

/* ---------- Bascule de période ---------- */

.switch {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 15px; padding: 4px; margin-bottom: 20px;
}
.switch .glider {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  border-radius: 11px;
  background: linear-gradient(150deg, rgba(212,175,98,.24), rgba(212,175,98,.11));
  border: 1px solid rgba(212,175,98,.26);
  transition: transform .38s var(--ease);
}
.switch[data-on="vacances"] .glider { transform: translateX(100%); }
.switch button {
  position: relative; z-index: 1; min-height: 44px; border: 0; background: none;
  font-family: inherit; font-size: .86rem; font-weight: 500; color: var(--muted);
  cursor: pointer; transition: color .25s var(--ease);
}
.switch button.on { color: var(--gold-soft); }

/* ---------- Curseur ---------- */

.slider-card { background: var(--surface); border: 1px solid var(--line);
               border-radius: var(--r); padding: 20px; margin-bottom: 12px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.slider-val { font-family: var(--display); font-weight: 500; font-size: 1.5rem;
              letter-spacing: -.03em; color: var(--gold-soft); }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 44px; background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold) var(--pct, 0%), rgba(255,255,255,.09) var(--pct, 0%));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(160deg, #FFF8E6, var(--gold));
  border: 2px solid rgba(0,0,0,.35); box-shadow: 0 3px 14px rgba(212,175,98,.42);
  margin-top: -10.5px;
}
input[type=range]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(0,0,0,.35);
  background: var(--gold);
}

/* ---------- Champs ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: .74rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
.field input {
  width: 100%; min-height: 48px; padding: 12px 15px;
  font-family: var(--body); font-size: 16px;   /* < 16px : iOS zoome au focus */
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-xs);
}
.field input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }

.btn {
  width: 100%; min-height: 50px; border: 0; border-radius: var(--r-xs);
  font-family: var(--body); font-size: .95rem; font-weight: 600; cursor: pointer;
  background: linear-gradient(150deg, var(--gold-soft), var(--gold));
  color: #221B08; transition: filter .2s var(--ease);
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost {
  background: transparent; color: var(--gold-soft); border: 1px solid var(--line-warm);
}

/* ---------- Navigation ---------- */

.nav {
  position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b));
  display: flex; justify-content: space-around; gap: 2px;
  background: rgba(18, 18, 22, .82);
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--line); border-radius: 19px; padding: 7px 6px;
  box-shadow: 0 16px 44px rgba(0,0,0,.55);
  max-width: 660px; margin: 0 auto;
}
.nav button {
  flex: 1; min-width: 0; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; cursor: pointer; font-family: inherit;
  font-size: .63rem; font-weight: 500; letter-spacing: .02em;
  color: var(--muted); border-radius: 13px;
  transition: color .22s var(--ease), background .22s var(--ease);
}
.nav button svg { width: 20px; height: 20px; }
.nav button.on { color: var(--gold-soft); background: rgba(212,175,98,.1); }
.nav button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

/* ---------- Réglages : bouton d'en-tête ---------- */

.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.icon-btn {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.icon-btn:hover { color: var(--gold-soft); border-color: var(--line-warm); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- Habitudes ---------- */

.semaine { display: flex; gap: 5px; margin-top: 7px; }
.pastille {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,.13); transition: background .25s var(--ease);
}
.pastille.on { background: var(--gold); box-shadow: 0 0 7px rgba(212,175,98,.55); }

.mini {
  flex: 0 0 32px; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.mini:hover { color: var(--err); border-color: rgba(240,121,107,.4); }

/* ---------- Boîte de dialogue ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.66);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  opacity: 0; transition: opacity .24s var(--ease);
}
.overlay.on { opacity: 1; }

.sheet {
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  padding: 12px 20px calc(26px + var(--safe-b));
  background: linear-gradient(180deg, #16161B, #101014);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -18px 60px rgba(0,0,0,.7);
  transform: translateY(100%); transition: transform .34s var(--ease);
}
.overlay.on .sheet { transform: none; }

.sheet-poignee {
  width: 38px; height: 4px; border-radius: 99px;
  background: rgba(255,255,255,.18); margin: 4px auto 18px;
}
.sheet-titre {
  font-family: var(--display); font-weight: 600; font-size: 1.35rem;
  margin-bottom: 20px; letter-spacing: -.03em;
}

@media (min-width: 720px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 26px; border-bottom: 1px solid var(--line); transform: translateY(18px) scale(.98); }
  .overlay.on .sheet { transform: none; }
}

/* ---------- Notification ---------- */

#toast {
  position: fixed; z-index: 60;
  left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translate(-50%, 14px);
  padding: 12px 20px; border-radius: 13px;
  background: rgba(28,28,34,.96); border: 1px solid var(--line-warm);
  color: var(--ink); font-size: .87rem; font-weight: 500;
  box-shadow: 0 12px 34px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none;
  transition: opacity .26s var(--ease), transform .26s var(--ease);
  max-width: calc(100vw - 40px); text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Accessibilité ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .page { padding-top: 52px; }
}
