:root {
  --bg: #faf6f0; --card: #ffffff; --ink: #22252b; --muted: #6b6f78; --line: #ece5da; --soft: #f3ede4;
  --jao: #5b6cff; --mamie: #e07a5f; --accent: var(--jao);
  --ok: #1f9d63; --bad: #d64545; --warn: #f2a33a;
  --r: 18px; --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 18px rgb(60 40 20 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171c; --card: #1f2229; --ink: #eceef2; --muted: #9aa0ab; --line: #2d313a; --soft: #262a32;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h3 { margin: 0 0 10px; font-size: 1.05rem; }
h4 { margin: 0 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.tiny { font-size: .8rem; color: var(--muted); display: block; }
.center { text-align: center; }
.err { color: var(--bad); }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

#app { max-width: 620px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }
body[data-space="mamie"] { --accent: var(--mamie); }

/* en-tête */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px; background: var(--bg); }
.brand { font-weight: 700; font-size: 1.15rem; }
.switch { display: flex; background: var(--soft); border-radius: 999px; padding: 4px; flex: 1; max-width: 300px; }
.switch button { flex: 1; padding: 9px 10px; border-radius: 999px; font-weight: 600; color: var(--muted); position: relative; }
.switch button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 700; font-size: 1.1rem; flex: none; }
.badge { position: absolute; top: -2px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font: 700 .7rem/18px system-ui; font-style: normal; }

/* cartes */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card.link { cursor: pointer; }
.hero { --c: var(--accent); margin: 8px 0 12px; padding: 20px; border-radius: 22px; color: #fff;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, #000)); }
.hero.empty { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.hero.warn { background: linear-gradient(135deg, #f2a33a, #e0752f); }
.hero-label { font-size: .85rem; opacity: .85; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.hero-big { font-size: 1.6rem; line-height: 1.2; margin: 4px 0; }
.hero-sub { opacity: .92; }
.hero .btn { margin-top: 10px; }
.hero.empty .btn { background: var(--accent); color: #fff; }
.note-line { background: var(--card); border-radius: 12px; padding: 10px 14px; margin: 8px 0; box-shadow: var(--shadow); }
.alert { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-left: 5px solid var(--muted); }
.alert.ask { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--card)); }
.alert.bad { border-color: var(--bad); }
.alert-txt { flex: 1 1 220px; }
.alert-btns { display: flex; gap: 8px; }

/* boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; background: var(--soft); font-weight: 600; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 38px; padding: 0 14px; border-radius: 12px; font-size: .92rem; }
.btn.full { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.icon { width: 40px; height: 40px; border-radius: 12px; font-size: 1.3rem; display: inline-grid; place-items: center; flex: none; }
.icon:disabled { opacity: .25; }
.icon.del { font-size: .95rem; color: var(--muted); }
.icon.plus { background: var(--soft); color: var(--accent); margin-left: auto; }
.fab { position: fixed; right: max(16px, calc(50% - 294px)); bottom: calc(24px + env(safe-area-inset-bottom)); width: 64px; height: 64px;
  border-radius: 22px; background: var(--jao); color: #fff; font-size: 2rem; box-shadow: 0 8px 24px rgb(91 108 255 / .4); z-index: 6; }

/* calendrier */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cal-head h3 { margin: 0; }
.cal-title { font-weight: 700; text-transform: capitalize; font-size: 1.1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-grid > b { font-size: .75rem; color: var(--muted); padding: 2px 0 4px; }
.day { aspect-ratio: 1; border-radius: 12px; position: relative; display: grid; place-items: center; font-weight: 600; background: var(--soft); }
.day.set { background: var(--c); color: #fff; }
.day.out { opacity: .35; }
.day.today { outline: 3px solid var(--ink); outline-offset: 1px; }
.day.pend::after { content: ""; position: absolute; inset: 2px; border-radius: 10px; border: 2.5px dashed var(--p); }
.day .dot { position: absolute; bottom: 5px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.day:not(.set) .dot { background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: .85rem; color: var(--muted); }
.leg { display: inline-flex; align-items: center; gap: 6px; }
.leg i { width: 14px; height: 14px; border-radius: 5px; background: var(--c); }
.leg .pend-i { background: none; border: 2px dashed var(--muted); }
.leg .dot-i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.big-who { font-size: 1.2rem; margin-bottom: 10px; }

/* listes */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.when { font-weight: 700; margin-right: 6px; }
.when::first-letter { text-transform: uppercase; }
.who { font-weight: 700; color: var(--c); }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); font-weight: 600; }
.count { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: .85rem; margin-left: 4px; }

/* mamie */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: center; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; max-width: 124px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  font-size: .72rem; font-weight: 600; color: var(--muted); border-radius: 12px; }
.tabs .ic { font-size: 1.4rem; position: relative; filter: grayscale(1); opacity: .7; }
.tabs .on { color: var(--mamie); background: color-mix(in srgb, var(--mamie) 10%, transparent); }
.tabs .on .ic { filter: none; opacity: 1; }
.tabs .badge { right: -12px; }
.bar { margin: 8px 0; }
.vday { background: var(--card); border-radius: 16px; padding: 10px 14px; margin: 8px 0; box-shadow: var(--shadow); }
.vday.nobody { background: color-mix(in srgb, var(--warn) 9%, var(--card)); }
.vday-head { display: flex; align-items: center; gap: 8px; }
.vday-head b::first-letter { text-transform: uppercase; }
.nobody-txt { color: #c06a12; font-size: .9rem; font-weight: 600; }
.v-dispo { opacity: .85; }
.v-besoin { color: var(--bad); }
.slot { margin-top: 12px; }
.slot-lbl { font-weight: 700; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.med, .shop-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px; border-radius: 14px; background: var(--soft); margin: 6px 0; }
.box { width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--muted); display: grid; place-items: center; flex: none; font-weight: 800; }
.med.taken { background: color-mix(in srgb, var(--ok) 13%, var(--card)); }
.med.taken .box, .shop-item.done .box { background: var(--ok); border-color: var(--ok); color: #fff; }
.progress { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; margin-bottom: 4px; }
.progress i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.list.shop > li { display: flex; align-items: center; gap: 6px; padding: 0; border: 0; }
.shop-item.done .grow { text-decoration: line-through; color: var(--muted); }
.addbar { display: flex; gap: 8px; margin: 8px 0; }
.addbar input { flex: 1; }
.post-form { display: flex; flex-direction: column; gap: 8px; }
.post { background: var(--card); border-radius: 16px; padding: 12px 14px; margin: 10px 0; box-shadow: var(--shadow); }
.post-head { display: flex; align-items: center; gap: 8px; }
.post-head .tiny { display: inline; }
.post-head .del { margin-left: auto; width: 32px; height: 32px; }

/* demandes */
.sec { margin: 20px 4px 4px; display: flex; align-items: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--soft); color: var(--muted); white-space: nowrap; }
.chip.wait { background: color-mix(in srgb, var(--warn) 18%, var(--card)); color: #b8620a; }
.chip.doing { background: color-mix(in srgb, var(--jao) 15%, var(--card)); color: var(--jao); }
.chip.done { background: color-mix(in srgb, var(--ok) 15%, var(--card)); color: var(--ok); }
.chip.no { background: color-mix(in srgb, var(--bad) 13%, var(--card)); color: var(--bad); }
.req { background: var(--card); border-radius: 18px; padding: 12px 14px; margin: 10px 0; box-shadow: var(--shadow); border-left: 5px solid var(--line); }
.req.st-open { border-left-color: var(--warn); }
.req.st-accepted { border-left-color: var(--jao); }
.req.st-done, .req.st-refused { opacity: .8; }
.req.k-info { border-left-color: var(--mamie); }
.req-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.req-head .tiny { display: inline; }
.req-head .del { margin-left: auto; width: 32px; height: 32px; }
.req-txt { font-size: 1.05rem; margin: 6px 0; }
.req-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.req-meta:empty { display: none; }
.req-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.reply { background: var(--soft); border-radius: 12px; padding: 8px 12px; margin-top: 8px; }
.reply .tiny { display: inline; }
.reply-form { display: flex; gap: 6px; margin-top: 10px; }
.reply-form input { min-height: 40px; padding: 6px 12px; }
.reply-form .btn { flex: none; width: 44px; padding: 0; }
.composer { display: flex; flex-direction: column; gap: 10px; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer-row .field { flex: 1; margin: 0; }

/* formulaires */
input, select, textarea { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.field { display: block; margin: 12px 0; }
.lbl { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .field { margin: 0; }
details.field summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 4px 0; }
details.field .two { margin-top: 8px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.seg, .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label, .chips label { flex: 1; }
.seg input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .chips span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: 6px 10px;
  border-radius: 14px; background: var(--soft); font-weight: 600; cursor: pointer; border: 2px solid transparent; }
.seg input:checked + span { background: var(--accent); color: #fff; }
.chips input:checked + span { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--card)); color: var(--c, var(--accent)); }
.seg.three span { font-size: .9rem; }
form[data-type="garde"] [data-show="event"], form[data-type="event"] [data-show="garde"] { display: none; }
form.inline { display: flex; gap: 8px; margin: 14px 0; }
form.inline .btn { flex: none; }
form.sub { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

/* feuille du bas */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgb(0 0 0 / .4); animation: fade .2s; }
.sheet-card { position: relative; width: 100%; max-width: 620px; max-height: 90vh; overflow: auto; background: var(--card);
  border-radius: 24px 24px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet-card::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -10px auto 14px; }
.sheet-card h3 { font-size: 1.25rem; }
.sheet-card h3::first-letter { text-transform: uppercase; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

/* connexion */
.auth { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.auth h1 { margin: 10px 0 0; }
.auth form { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.auth .btn { margin-top: 4px; --accent: var(--jao); }
