@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage-grotesque-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ink: #1C2333;
  --ink-soft: #565F78;
  --paper: #FBF9F4;
  --card: #FFFFFF;
  --line: #E4E1D8;
  --accent: #E4572E;
  --accent-2: #F2794F;
  --accent-soft: #FBE3D8;
  --moss: #4FA35B;
  --sea: #17A2A2;
  --ring: #2A3EB1;
  --danger: #C43D3D;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(28,35,51,.06), 0 6px 20px rgba(28,35,51,.07);
  --shadow-lift: 0 6px 16px rgba(228,87,46,.22);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #ECE9E0; --ink-soft: #A8AEC0; --paper: #14161F; --card: #1C1F2B; --line: #2C3040;
  --accent-soft: #3A2620; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
  --shadow-lift: 0 6px 18px rgba(228,87,46,.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ECE9E0; --ink-soft: #A8AEC0; --paper: #14161F; --card: #1C1F2B; --line: #2C3040;
    --accent-soft: #3A2620; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
    --shadow-lift: 0 6px 18px rgba(228,87,46,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; font-family: 'Bricolage', system-ui, sans-serif; background: var(--paper); color: var(--ink);
  -webkit-font-smoothing: antialiased; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { font-family: 'Bricolage', system-ui, sans-serif; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
p { line-height: 1.5; }
a { color: var(--ring); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.muted { color: var(--ink-soft); }
.hint { color: var(--ink-soft); font-size: .8rem; }
.strike { text-decoration: line-through; color: var(--ink-soft); }

/* ── Mise en page ── */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1.2rem; padding: .7rem 1.2rem; padding-top: calc(.7rem + env(safe-area-inset-top, 0px)); background: var(--card); box-shadow: 0 1px 0 var(--line), 0 4px 14px rgba(28,35,51,.05); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .55rem; font-size: 1.08rem; white-space: nowrap; }
.auth-mark { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(155deg, var(--accent-2), var(--accent)); color: #fff; font-weight: 800; box-shadow: 0 3px 8px rgba(228,87,46,.3); }
.auth-mark.small { width: 27px; height: 27px; font-size: .92rem; border-radius: 8px; }
.nav-desktop { display: none; gap: .2rem; flex: 1; }
.nav-desktop .nav-item { display: flex; align-items: center; gap: .4rem; padding: .5rem .8rem; border-radius: 999px; color: var(--ink-soft); text-decoration: none; font-size: .92rem; transition: background-color .15s ease, color .15s ease, transform .15s ease; }
.nav-desktop .nav-item:hover { background: var(--line); color: var(--ink); transform: translateY(-1px); }
.nav-desktop .nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-desktop .nav-item span { display: none; }
main#view { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 1rem 1rem 5.5rem; }
.nav-mobile { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 20; }
.nav-mobile .nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem 0 .4rem; color: var(--ink-soft); text-decoration: none; font-size: .68rem; transition: color .15s ease; }
.nav-mobile .nav-item.on { color: var(--accent); }
.nav-mobile .nav-item.on svg { filter: drop-shadow(0 1px 3px rgba(228,87,46,.3)); }

@media (min-width: 860px) {
  .nav-desktop { display: flex; }
  .nav-desktop .nav-item span { display: inline; }
  .nav-mobile { display: none; }
  main#view { padding-bottom: 2rem; }
}

/* ── Boutons, icônes ── */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 999px; border: none; background: transparent; color: var(--ink); cursor: pointer; position: relative; transition: background-color .15s ease, transform .1s ease; }
.icon-btn:hover { background: var(--line); }
.icon-btn:active { transform: scale(.92); }
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: .5rem .95rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: .9rem; text-decoration: none; transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease; }
.btn:hover { border-color: var(--ink-soft); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.small { padding: .32rem .7rem; font-size: .82rem; }
.btn.primary { background: linear-gradient(155deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 2px 8px rgba(228,87,46,.25); }
.btn.primary:hover { filter: brightness(1.05); box-shadow: var(--shadow-lift); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; justify-content: center; }
.notif-btn .badge { position: absolute; top: 2px; right: 2px; background: var(--accent); color: #fff; font-size: .62rem; font-weight: 700; border-radius: 999px; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }

/* ── En-tête de page ── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.row { display: flex; align-items: center; }
.row.gap { gap: .5rem; }
.row.between { justify-content: space-between; }
.row.center { align-items: center; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.stack.big { gap: 1.2rem; }

/* ── Cartes ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); transition: box-shadow .2s ease; }
.card.alert { border-color: var(--accent); }
.empty { color: var(--ink-soft); padding: 1.2rem 0; text-align: center; }

/* ── Puces de filtre ── */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .32rem .85rem; font-size: .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; transition: background-color .15s ease, transform .12s ease; }
.chip:hover { transform: translateY(-1px); }
.chip.on { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(228,87,46,.25); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.big { width: 12px; height: 12px; }

/* ── Modales ── */
dialog.modal { border: none; border-radius: var(--radius); padding: 0; width: min(480px, 92vw); max-height: 88vh; background: var(--card); color: var(--ink); box-shadow: 0 24px 70px rgba(0,0,0,.22); overflow: hidden; display: flex; flex-direction: column; }
dialog.modal.wide { width: min(680px, 94vw); }
dialog.modal::backdrop { background: rgba(20, 22, 31, .5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1.1rem; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; }
.field input, .field select, .field textarea { font-weight: 400; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); width: 100%; }
.field textarea { resize: vertical; }
.check-field { display: inline-flex; align-items: flex-start; gap: .5rem; font-weight: 400; }
.check-field input { margin-top: .2rem; }
.check-chip { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; }
.swatch-row { display: flex; flex-wrap: wrap; gap: .55rem; padding: .2rem 0; }
.swatch-btn { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: transform .12s ease; }
.swatch-btn:hover { transform: scale(1.1); }
.swatch-btn.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.check-chip { border: 1px solid var(--line); border-radius: 999px; padding: .3rem .7rem; font-size: .85rem; }
.form-error { color: var(--danger); font-size: .85rem; min-height: 1em; }
.addr-suggestions { display: flex; flex-direction: column; gap: 2px; }
.addr-suggestion { text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .4rem .6rem; font-size: .85rem; cursor: pointer; }
.addr-suggestion:hover { border-color: var(--ink-soft); background: var(--line); }

/* ── Notifications toast ── */
.toast { position: fixed; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; z-index: 100; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); }
@media (min-width: 860px) { .toast { bottom: 1.2rem; } }

/* ── Agenda ── */
.cal-nav { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.cal-title { flex: 1; text-align: center; text-transform: capitalize; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.hol-tag { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .25rem .7rem; font-size: .78rem; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: 26px repeat(7, 1fr); gap: 3px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--card); text-align: center; font-size: .72rem; color: var(--ink-soft); padding: .3rem 0; text-transform: uppercase; letter-spacing: .04em; }
.cal-week { background: var(--paper); display: flex; align-items: center; justify-content: center; font-size: .62rem; color: var(--ink-soft); font-weight: 600; }
.cal-week-head { background: var(--card); }
@media (max-width: 599px) { .cal-grid { grid-template-columns: 18px repeat(7, 1fr); } .cal-week { font-size: .58rem; } }
.day { background: var(--card); border: none; min-height: 64px; padding: .3rem; display: flex; flex-direction: column; align-items: stretch; gap: 2px; cursor: pointer; text-align: left; }
.day.out { opacity: .35; }
.day.sel { outline: 2px solid var(--ring); outline-offset: -2px; }
.day.today .num { background: var(--accent); color: #fff; border-radius: 50%; }
.day.hol { background: var(--accent-soft); }
.num { font-size: .8rem; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.evs { display: none; flex-direction: column; gap: 1px; }
.ev { font-size: .68rem; border-left: 2px solid var(--c); padding-left: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { font-size: .65rem; color: var(--ink-soft); }
.dots { display: flex; gap: 2px; flex-wrap: wrap; }
.stripes { display: flex; gap: 1px; height: 4px; margin-top: auto; }
.stripes span { flex: 1; border-radius: 2px; }
@media (min-width: 600px) { .day { min-height: 92px; } .evs { display: flex; } .dots { display: none; } }
.day-panel { margin-top: 1rem; }
.night-list, .ev-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.night-list li { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.tile.mini { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; font-size: .75rem; font-weight: 700; }
.ev-row { display: flex; align-items: center; gap: .7rem; width: 100%; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--radius-sm); padding: .55rem .7rem; cursor: pointer; text-align: left; }
.ev-time { font-size: .78rem; color: var(--ink-soft); min-width: 3.6em; }
.ev-title { flex: 1; display: flex; flex-direction: column; font-weight: 600; }
.ev-title small { color: var(--ink-soft); font-weight: 400; }
.tag { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: 999px; background: var(--line); font-size: .75rem; font-weight: 600; }
.tag.pending { background: var(--accent-soft); color: var(--accent); }
.notes { white-space: pre-wrap; }
.lead { font-weight: 600; }

/* ── Garde ── */
.child-month { margin-bottom: 1.3rem; }
.child-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.tile-grid { display: grid; grid-template-columns: 22px repeat(7, 1fr); gap: 4px; }
.tile-dow { text-align: center; font-size: .68rem; color: var(--ink-soft); }
.tile-week { display: flex; align-items: center; justify-content: center; font-size: .62rem; color: var(--ink-soft); font-weight: 600; }
.tile-week-head { font-size: .68rem; }
.tile { aspect-ratio: 1; border-radius: 7px; border: 1px solid var(--line); background: var(--card); font-size: .78rem; cursor: pointer; }
.tile.ghost { border: none; background: transparent; cursor: default; }
.tile.empty { color: var(--ink-soft); }
.tile.filled { border-color: transparent; font-weight: 700; }
.tile.sel { outline: 2px solid var(--ring); outline-offset: 1px; }
.tile.today { box-shadow: inset 0 0 0 2px var(--ink); }
.tile.hol::after { content: ''; }
.legend { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; font-size: .82rem; margin-top: .4rem; }
.legend-item { display: flex; align-items: center; gap: .35rem; }
.swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.action-bar { position: sticky; bottom: 70px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .6rem; z-index: 10; }
.action-bar[hidden] { display: none; }
.bar-text { font-size: .92rem; }
.stats-grid { display: grid; gap: 1.2rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .stats-grid { grid-template-columns: 1fr 1fr; } }
.stat-group h4 { margin: 0 0 .5rem; font-size: .85rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }
.stat-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.stat-name { display: flex; align-items: center; gap: .4rem; min-width: 6em; font-size: .85rem; }
.stat-bar { flex: 1; display: flex; height: 20px; border-radius: 5px; overflow: hidden; }
.stat-bar span { display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; }
.swap-list, .swap-history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.swap { display: flex; justify-content: space-between; align-items: center; gap: .8rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .8rem; flex-wrap: wrap; }
.status { font-weight: 700; font-size: .8rem; }
.status.accepted { color: var(--moss); }
.status.declined, .status.cancelled { color: var(--ink-soft); }
.hol-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.hol-list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* ── Tâches / courses ── */
.task-list, .shop-list, .doc-list, .contact-list, .member-list, .circle-list, .notif-list, .balance-list, .cat-list, .expense-list, .post-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.task-row, .shop-row, .doc-row, .contact-row, .member-row, .circle-row, .balance-list li, .expense-row { display: flex; align-items: center; gap: .7rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .55rem .7rem; }
.task-row.overdue .task-title { color: var(--danger); }
.task-main, .doc-main, .contact-main, .member-main, .expense-main { flex: 1; display: flex; flex-direction: column; cursor: pointer; min-width: 0; }
.task-title { font-weight: 600; }
.done-block summary { cursor: pointer; color: var(--ink-soft); font-size: .85rem; margin: .4rem 0; }
.quick-add { display: flex; gap: .5rem; margin-bottom: .8rem; }
.quick-add input { flex: 1; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }

/* ── Budget ── */
.cat-bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: .25rem; }
.cat-bar span { display: block; height: 100%; background: var(--sea); }
.split-rows { display: flex; flex-direction: column; gap: .4rem; }
.split-row { display: flex; align-items: center; gap: .5rem; justify-content: space-between; }

/* ── Documents / contacts ── */
.doc-group h3 { font-size: .85rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; margin: 1rem 0 .4rem; }
.doc-row a.doc-main { text-decoration: none; color: inherit; }
.contact-row { cursor: pointer; }
.avatar { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; box-shadow: 0 0 0 2px var(--card); }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { flex: 1; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }

/* ── Fil familial / chat ── */
.composer { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: 1rem; }
.composer textarea { width: 100%; border: none; background: transparent; resize: vertical; font-size: .95rem; }
.photo-preview img { max-height: 140px; border-radius: var(--radius-sm); margin-top: .5rem; }
.post { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.post-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.post-head > div { flex: 1; }
.post-body { white-space: pre-wrap; margin: .3rem 0; }
.post-photo { width: 100%; border-radius: var(--radius-sm); margin-top: .4rem; }
.chat-list { display: flex; flex-direction: column; gap: .6rem; max-height: 55vh; overflow-y: auto; padding: .5rem 0; }
.chat-msg { display: flex; gap: .5rem; align-items: flex-start; }
.chat-bubble { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .5rem .7rem; display: inline-block; }
.chat-msg.mine .chat-bubble { background: var(--accent-soft); }
.chat-compose { display: flex; gap: .5rem; margin-top: .6rem; }
.chat-compose input { flex: 1; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }
.notif-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.notif-list li.unread { font-weight: 700; }
.notif-list a { text-decoration: none; color: inherit; }

/* ── Écrans d'authentification ── */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: radial-gradient(circle at 20% -10%, var(--accent-soft), transparent 55%), var(--paper); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.8rem; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: .6rem; margin-bottom: .3rem; }
.auth-brand h1 { margin: 0; }
.auth-subtitle { color: var(--ink-soft); margin: 0 0 1.2rem; }

@media (prefers-reduced-motion: no-preference) {
  .day, .btn, .tile { transition: background-color .12s ease, border-color .12s ease; }
}
