:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #23302c;
  --muted: #6b7670;
  --line: #e4ddd2;
  --brand: #2f5d50;
  --brand-soft: #e3ece8;
  --accent: #c2703d;
  --danger: #b3412e;
  --radius: 16px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-size: 17px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b19; --card: #212826; --ink: #eef2ef; --muted: #9aa6a0;
    --line: #313b37; --brand: #7fb7a4; --brand-soft: #24342f; --accent: #e09a68;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4; overscroll-behavior-y: contain;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.splash { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* --- écrans de connexion --- */
.auth { max-width: 420px; margin: 0 auto; padding: calc(48px + var(--safe-t)) 24px 32px; }
.auth h1 { font-size: 1.9rem; margin: 0 0 4px; color: var(--brand); }
.auth p.lead { color: var(--muted); margin: 0 0 28px; }
.field { display: block; margin-bottom: 18px; }
.field span { display: block; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 6px; font-size: .85rem; }
.field input {
  width: 100%; min-height: 54px; padding: 12px 16px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card); font-size: 1.05rem;
}
.field input:focus { outline: none; border-color: var(--brand); }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; border: 0; border-radius: 14px;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 1.05rem;
}
.btn:disabled { opacity: .55; }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.error { color: var(--danger); font-weight: 600; min-height: 1.4em; margin: 4px 0 14px; }

/* --- en-tête --- */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(12px + var(--safe-t)) 16px 8px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 1.35rem; margin: 0; flex: 1; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--card); display: grid; place-items: center; box-shadow: 0 1px 0 var(--line);
}
.icon-btn svg { width: 24px; height: 24px; stroke: var(--ink); }
.pill-btn {
  min-height: 46px; padding: 0 16px; border-radius: 23px; border: 0;
  background: var(--brand-soft); color: var(--brand); font-weight: 700;
}
.pill-btn[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* --- onglets de l'Accueil --- */
.tabs {
  position: sticky; top: calc(66px + var(--safe-t)); z-index: 4; background: var(--bg);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px 12px 10px;
}
.tab {
  min-height: 48px; border: 0; border-radius: 12px; background: var(--card);
  font-weight: 600; font-size: .95rem; position: relative; color: var(--muted);
}
.tab[aria-selected="true"] { background: var(--brand); color: #fff; }
.tab .count {
  position: absolute; top: -6px; right: -2px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--accent); color: #fff; font-size: .75rem; line-height: 22px;
}

/* --- contenu --- */
.content { padding: 4px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 0 var(--line);
}
.card h2 { font-size: 1.05rem; margin: 0 0 6px; }
.card p { margin: 0; color: var(--muted); }
.card.soon { border: 1.5px dashed var(--line); box-shadow: none; background: transparent; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); padding: 2px 8px; border-radius: 8px; margin-top: 8px; }
.banner {
  background: #fff4e8; color: #7a4318; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
  display: flex; gap: 10px; align-items: center;
}
@media (prefers-color-scheme: dark) { .banner { background: #3a2a1c; color: #f3c9a2; } }
.banner button { margin-left: auto; min-height: 42px; border: 0; border-radius: 10px; padding: 0 14px;
  background: var(--accent); color: #fff; font-weight: 700; }

.week-day { display: flex; gap: 14px; align-items: flex-start; }
.week-day .d { min-width: 96px; font-weight: 700; text-transform: capitalize; }
.week-day .d small { display: block; color: var(--muted); font-weight: 500; }
.week-day.today .d { color: var(--brand); }

.list-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 0 16px;
  border: 0; background: var(--card); border-radius: 14px; margin-bottom: 8px; text-align: left; font-weight: 600;
  box-shadow: 0 1px 0 var(--line);
}
.list-btn svg { width: 22px; height: 22px; stroke: var(--brand); flex: none; }
.list-btn .chev { margin-left: auto; color: var(--muted); }
.section-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 4px 8px; }
.muted { color: var(--muted); }

/* --- barre du bas --- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.nav button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: .78rem; font-weight: 600; color: var(--muted);
}
.nav svg { width: 26px; height: 26px; stroke: currentColor; }
.nav button[aria-current="page"] { color: var(--brand); }

/* --- divers --- */
.offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; text-align: center;
  padding: calc(8px + var(--safe-t)) 12px 8px; background: #4a4a4a; color: #fff; font-weight: 600; font-size: .9rem;
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px); max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600;
}
.sheet { max-width: 560px; margin: 0 auto; }
.form-card .field:last-of-type { margin-bottom: 8px; }

@media (min-width: 900px) {
  .content, .tabs, .top { max-width: 760px; margin-left: auto; margin-right: auto; }
  .tabs { top: 66px; }
  .nav { max-width: 760px; margin: 0 auto; border-radius: 18px 18px 0 0; border: 1px solid var(--line); }
}

.note { color: var(--muted); font-size: .9rem; }
.note.mt { margin-top: 18px; }
.mt-s { margin-top: 12px; }
.note.intro { margin: 0 4px 12px; }
.note.under { margin: -2px 6px 10px; }
.note.version { text-align: center; margin-top: 24px; font-size: .85rem; }
button.week-day { width: 100%; text-align: left; border: 0; font: inherit; color: inherit; }
