/* Pilote : sobre, système, clair ou sombre comme le téléphone.
   Cibles tactiles de 44 pt au moins, bouton +1 de 60 pt, texte à 17 pt. */
:root {
  --bg: #f6f6f3; --card: #ffffff; --text: #15171a; --muted: #5d646d; --line: #e3e3de;
  --accent: #1d6b45; --accent-ink: #ffffff; --accent-soft: #e2eee7; --accent-mid: #8fbfa5;
  --err: #a8321c; --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  --l0: #ebece8; --l1: #cfe3d6; --l2: #9cc8ad; --l3: #5a9e78; --l4: #1d6b45;
  --tab-h: 56px; --r: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1110; --card: #191c1a; --text: #eef0ee; --muted: #a2a9a4; --line: #2b302d;
    --accent: #5cc98f; --accent-ink: #08170e; --accent-soft: #1c3226; --accent-mid: #2f6a4a;
    --err: #ff9a85; --shadow: none;
    --l0: #222624; --l1: #1f4330; --l2: #2b6646; --l3: #3f9a68; --l4: #5cc98f;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  padding: 0 0 calc(var(--tab-h) + env(safe-area-inset-bottom) + 72px);
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 17px; } /* 16 px au moins, sinon iOS zoome */
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 80vh; color: var(--muted); }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.tiny { font-size: 13px; }
h1 { font-size: 28px; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }
h3 { font-size: 17px; margin: 0 0 8px; }

/* En-tête */
.top { padding: 14px 0 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .back { min-height: 44px; min-width: 44px; padding: 0 8px 0 0; border: 0; background: none; color: var(--accent); font-size: 17px; }
.headline { font-size: 24px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.date { color: var(--muted); font-size: 15px; }
.date::first-letter { text-transform: uppercase; }
.seg { display: inline-flex; background: var(--line); border-radius: 10px; padding: 2px; }
.seg button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: none; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: var(--shadow); font-weight: 600; }

/* Bandeaux */
.banner { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.banner button { flex: none; white-space: nowrap; min-height: 44px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); padding: 0 12px; font-size: 15px; font-weight: 600; }
.banner.neutral { background: var(--card); border: 1px solid var(--line); }

/* Lignes d'habitudes */
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 4px 6px 4px 12px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.row .ico { font-size: 26px; width: 34px; text-align: center; flex: none; }
.row .mid { flex: 1; min-width: 0; min-height: 56px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; border: 0; background: none; padding: 0; text-align: left; }
.row .name { font-size: 17px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.row .sub { font-size: 14px; color: var(--muted); margin-top: 1px; }
.row .bar { display: block; height: 4px; width: 100%; max-width: 160px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .2s ease-out; }
.row.dim { opacity: .62; }
.more { flex: none; width: 44px; height: 44px; border: 0; border-radius: 22px; background: none; color: var(--muted); font-size: 22px; line-height: 1; }

.plus {
  --p: 0%;
  flex: none; position: relative; width: 60px; height: 60px; border-radius: 30px; border: 0; padding: 0;
  display: grid; place-items: center; font-weight: 650; font-size: 16px; color: var(--accent);
  background: conic-gradient(var(--accent) var(--p), var(--line) 0);
  transition: transform .12s ease-out;
}
.plus::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--card); }
.plus span { position: relative; }
.plus.wide { font-size: 14px; }
.plus.full { background: var(--accent); color: var(--accent-ink); }
.plus.full::before { display: none; }
.plus:active { transform: scale(.94); }
.plus svg { width: 28px; height: 28px; position: relative; }

/* Toast d'annulation */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 10px);
  max-width: 616px; margin: 0 auto; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: #222724; color: #fff; padding: 8px 8px 8px 16px; border-radius: 14px; min-height: 52px; z-index: 30;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); font-size: 16px; animation: up .18s ease-out;
}
.toast button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: #3a423d; color: #9fe2bb; font-weight: 650; }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }

/* Barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; max-width: 200px; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 550; }
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs svg { width: 25px; height: 25px; }

/* Cartes, formulaires */
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.cards { display: flex; flex-direction: column; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--card); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 26px; line-height: 1.1; }
.tile span { font-size: 13px; color: var(--muted); }
.btn { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 17px; }
.btn.ghost { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: var(--card); color: var(--err); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field > span { font-size: 15px; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); width: 100%; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.link-row { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 14px; background: var(--card); border: 0; width: 100%; text-align: left; border-radius: 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.group { border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.group > :last-child { border-bottom: 0; }
.link-row .chev { color: var(--muted); }
.mini-btn { min-height: 40px; min-width: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.copy { display: flex; gap: 8px; align-items: center; margin: 6px 0 10px; }
.copy code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.steps { padding-left: 22px; margin: 6px 0; }
.steps li { margin: 0 0 10px; }
.err { color: var(--err); }

/* Statistiques */
.week { display: flex; justify-content: space-between; gap: 4px; }
.dot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); border: 0; background: none; padding: 0; min-height: 44px; }
.dot i { width: 26px; height: 26px; border-radius: 13px; border: 2px solid var(--line); display: grid; place-items: center; font-style: normal; font-size: 13px; color: var(--accent-ink); }
.dot.done i, .dot.logged i { background: var(--accent); border-color: var(--accent); }
.dot.partial i { border-color: var(--accent); background: conic-gradient(var(--accent-mid) var(--p, 50%), transparent 0); }
.dot.missed i { border-color: var(--muted); }
.dot.skipped i, .dot.paused i { border-style: dashed; }
.dot.none i, .dot.not_due i { border-color: transparent; background: none; }
.dot.today { color: var(--text); font-weight: 650; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; position: relative; padding-top: 4px; }
.bars .b { flex: 1; position: relative; height: 100%; display: flex; align-items: flex-end; }
.bars .b i { display: block; width: 100%; background: var(--accent-mid); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b.done i { background: var(--accent); }
.bars .b u { position: absolute; left: -2px; right: -2px; border-top: 2px dotted var(--muted); text-decoration: none; }
.bars-labels { display: flex; gap: 4px; margin-top: 4px; }
.bars-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); overflow: hidden; white-space: nowrap; }
.grid-scroll { overflow-x: auto; padding-bottom: 4px; }
.year { display: grid; grid-template-rows: repeat(7, 13px); grid-auto-flow: column; grid-auto-columns: 13px; gap: 3px; width: max-content; }
.year button { width: 13px; height: 13px; border-radius: 3px; border: 0; padding: 0; background: var(--l0); }
.year .l1 { background: var(--l1); } .year .l2 { background: var(--l2); } .year .l3 { background: var(--l3); } .year .l4 { background: var(--l4); }
.year .ln1 { background: transparent; } .year .ln2 { background: transparent; outline: 1px dashed var(--line); outline-offset: -1px; }
.stat-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 0; width: 100%; text-align: left; border-bottom: 1px solid var(--line); min-height: 64px; }
.stat-row .ico { font-size: 24px; width: 30px; text-align: center; }
.stat-row .grow { flex: 1; min-width: 0; }
.mini-week { display: flex; gap: 3px; margin-top: 5px; }
.mini-week i { width: 10px; height: 10px; border-radius: 5px; background: var(--l0); }
.mini-week i.on { background: var(--accent); }

/* Feuille du bas */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; animation: up .18s ease-out;
  max-width: 640px; margin: 0 auto;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.sheet-head button { min-height: 44px; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 17px; }

/* Écran d'un rappel : un grand +1 */
.focus { text-align: center; padding-top: 40px; }
.focus .big { width: 160px; height: 160px; border-radius: 80px; font-size: 30px; margin: 28px auto; }
.focus .big::before { inset: 8px; }
.focus .emoji { font-size: 56px; }

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