@import url(/assets/fonts.css);

:root {
  --bg: #F6F0E8;
  --bg-2: #EFE6DA;
  --card: #FFFCF8;
  --ink: #3B2E25;
  --ink-2: #5E4D41;
  --muted: #8E7B6C;
  --line: #E7DCCF;
  --walnut: #6B4A33;
  --accent: #C0706B;
  --accent-ink: #9E5450;
  --accent-soft: #F6E3DF;
  --sage: #7D9A80;
  --sage-soft: #E4ECE3;
  --gold: #C7A36A;
  --gold-soft: #F5EBD8;
  --danger: #B5473F;
  --shadow: 0 6px 24px rgba(75, 52, 35, .08), 0 1px 2px rgba(75, 52, 35, .06);
  --radius: 20px;
  --radius-s: 12px;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1F1915; --bg-2: #2A221C; --card: #2C241E; --ink: #F3EBE2; --ink-2: #D9CCBF; --muted: #A89584;
    --line: #3F342C; --walnut: #D8B899; --accent: #D98E88; --accent-ink: #F0B3AE; --accent-soft: #432E2C;
    --sage: #93B096; --sage-soft: #2B3A2E; --gold: #D6B47E; --gold-soft: #3F3627; --danger: #E07B73;
    --shadow: 0 6px 24px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1F1915; --bg-2: #2A221C; --card: #2C241E; --ink: #F3EBE2; --ink-2: #D9CCBF; --muted: #A89584;
  --line: #3F342C; --walnut: #D8B899; --accent: #D98E88; --accent-ink: #F0B3AE; --accent-soft: #432E2C;
  --sage: #93B096; --sage-soft: #2B3A2E; --gold: #D6B47E; --gold-soft: #3F3627; --danger: #E07B73;
  --shadow: 0 6px 24px rgba(0,0,0,.35); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background-image: radial-gradient(1200px 500px at 50% -200px, var(--bg-2), transparent 70%);
}
body.no-nav { padding-bottom: 0; }
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; margin: 0; color: var(--ink); }
h1 { font-size: 30px; line-height: 1.15; font-variation-settings: 'opsz' 60; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.tiny { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* En-tête */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.topbar h1 { font-size: 22px; flex: 1; }
.topbar .eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-family: var(--font-display); font-size: 16px; border: 0; cursor: pointer; }
main { padding: 16px 16px 24px; max-width: 760px; margin: 0 auto; }
@media (min-width: 900px) { main { max-width: 1040px; } .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 16px; }
.page-title .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* Cartes */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.card + .card { margin-top: 12px; }
.card h2, .card h3 { margin-bottom: 10px; }
.card.soft { background: var(--bg-2); box-shadow: none; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { font-size: 20px; }
.section-title a, .section-title .link { font-size: 14px; color: var(--accent-ink); font-weight: 600; }

/* Listes */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); cursor: pointer; text-align: left; width: 100%; transition: transform .08s ease, background .15s; }
.item:active { transform: scale(.985); }
.item .title { font-weight: 600; color: var(--ink); }
.item .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item.done .title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.item .thumb { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: var(--bg-2); flex: none; }
.item .thumb.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 20px; }

/* Cases à cocher rondes */
.check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); flex: none; display: grid; place-items: center; cursor: pointer; transition: all .15s; padding: 0; }
.check:hover { border-color: var(--sage); }
.check.on { background: var(--sage); border-color: var(--sage); color: #fff; }
.check svg { width: 16px; height: 16px; }
.check.sm { width: 22px; height: 22px; } .check.sm svg { width: 12px; height: 12px; }

/* Puces & badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg-2); color: var(--ink-2); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge.sage { background: var(--sage-soft); color: var(--sage); }
.badge.gold { background: var(--gold-soft); color: #8C6A2B; }
.badge.danger { background: #F8E1DE; color: var(--danger); }
.badge.outline { background: transparent; border: 1px solid var(--line); }
:root[data-theme="dark"] .badge.gold, :root:not([data-theme="light"]) .badge.gold { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.gold { color: var(--gold); } :root:not([data-theme="light"]) .badge.danger { background: #4A2A27; } }
.st-a_choisir, .st-a_acheter, .st-a_racheter { background: var(--accent-soft); color: var(--accent-ink); }
.st-commande { background: var(--gold-soft); color: #8C6A2B; }
.st-livre, .st-achete, .st-fait, .st-livree { background: var(--sage-soft); color: var(--sage); }
.st-plus_tard, .st-plus_tard_france, .st-ecarte, .st-hors_budget { background: var(--bg-2); color: var(--muted); }
.st-annulee, .st-remboursement { background: #F8E1DE; color: var(--danger); }
.st-a_verifier, .st-en_cours { background: var(--gold-soft); color: #8C6A2B; }

/* Progression */
.progress { height: 10px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #D99A8F); transition: width .5s ease; }
.progress.sage > span { background: linear-gradient(90deg, var(--sage), #A3BFA5); }
.progress.gold > span { background: linear-gradient(90deg, var(--gold), #DEC08A); }
.progress.walnut > span { background: linear-gradient(90deg, var(--walnut), #9A7557); }
.prog-row { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.prog-row:last-child { border-bottom: 0; }
.prog-row .lbl { display: flex; justify-content: space-between; align-items: baseline; }
.prog-row .lbl b { font-family: var(--font-display); font-weight: 500; font-size: 17px; }
.prog-row .lbl span { color: var(--muted); font-size: 13px; }

/* Chiffres */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--bg-2); border-radius: 14px; padding: 12px 14px; }
.kpi .v { font-family: var(--font-display); font-size: 22px; font-weight: 500; letter-spacing: -.02em; }
.kpi .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.accent { background: var(--accent-soft); } .kpi.accent .v { color: var(--accent-ink); }
.kpi.sage { background: var(--sage-soft); } .kpi.sage .v { color: var(--sage); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 14px; border: 1px solid transparent; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; transition: filter .15s, transform .08s; text-decoration: none; }
.btn:hover { filter: brightness(1.05); } .btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.sage { background: var(--sage); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }

/* Onglets / filtres */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer; min-height: 38px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.segmented { display: flex; background: var(--bg-2); border-radius: 14px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 9px 6px; font-weight: 700; color: var(--muted); cursor: pointer; min-height: 40px; }
.segmented button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* Formulaires */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); letter-spacing: .02em; }
.field input, .field select, .field textarea { font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; min-height: 46px; width: 100%; outline: none; transition: border-color .15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.form-grid { display: grid; gap: 14px; }
.form-grid .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .cols3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.error { color: var(--danger); font-size: 14px; font-weight: 600; }
.warn { background: var(--gold-soft); color: #7B5B1F; border-radius: 12px; padding: 10px 12px; font-size: 14px; display: flex; gap: 8px; align-items: flex-start; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warn { color: var(--gold); } }

/* Modale / feuille */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(40, 28, 20, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 92dvh; border-radius: 24px 24px 0 0; padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; animation: up .22s cubic-bezier(.2,.8,.2,1); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 22px; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 24px; max-height: 88vh; } }
@keyframes up { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* Navigation basse */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); display: flex; justify-content: space-around; align-items: stretch; z-index: 30; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--accent-ink); }
.nav a.on svg { stroke: var(--accent); }
.fab { position: fixed; right: 18px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; box-shadow: 0 10px 24px rgba(160, 90, 80, .35); display: grid; place-items: center; cursor: pointer; z-index: 29; }
.fab svg { width: 28px; height: 28px; }
@media (min-width: 900px) { .fab { right: calc(50% - 520px + 18px); } }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 60; box-shadow: var(--shadow); animation: up .2s; max-width: 92vw; }
.toast.err { background: var(--danger); color: #fff; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos img, .photos .add { aspect-ratio: 1; width: 100%; border-radius: 12px; object-fit: cover; background: var(--bg-2); cursor: pointer; }
.photos .add { display: grid; place-items: center; border: 1.5px dashed var(--line); color: var(--muted); font-size: 26px; border-radius: 12px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 70; display: grid; place-items: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 85vh; border-radius: 10px; object-fit: contain; }
.lightbox .cap { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #fff; }

/* Activité */
.feed { display: grid; gap: 0; }
.feed .ev { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.feed .ev:last-child { border-bottom: 0; }
.feed .dot { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; font-weight: 700; font-family: var(--font-display); }
.feed .dot.t { background: var(--sage-soft); color: var(--sage); }
.feed time { display: block; color: var(--muted); font-size: 12px; }

/* Tableaux */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 8px 6px; text-align: left; border-bottom: 1px dashed var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 700; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Plans */
.plan { background: #FBF8F3; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); touch-action: none; height: min(60vh, 520px); position: relative; }
.plan img { width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; will-change: transform; user-select: none; -webkit-user-drag: none; }
.plan .zoom { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }

/* Options à comparer */
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.opt { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; }
.opt.chosen { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
.opt .cover { aspect-ratio: 4/3; background: var(--bg-2); object-fit: cover; width: 100%; display: grid; place-items: center; color: var(--muted); }
.opt .body { padding: 12px 14px; display: grid; gap: 6px; flex: 1; }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 15px; }

/* Connexion */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px 24px; }
.auth .logo { width: 64px; height: 64px; margin: 0 auto 14px; }
.auth h1 { text-align: center; font-size: 30px; }
.auth .tag { text-align: center; color: var(--muted); margin: 6px 0 22px; font-style: italic; font-family: var(--font-display); font-size: 17px; }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-style: italic; font-family: var(--font-display); font-size: 17px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
details.group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-family: var(--font-display); font-size: 19px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary .n { font-family: var(--font-body); font-size: 13px; color: var(--muted); font-weight: 700; }
details.group[open] > summary { margin-bottom: 8px; }
.sub-list { display: grid; gap: 6px; margin-top: 8px; }
.sub-list .sub { display: flex; gap: 10px; align-items: center; font-size: 14.5px; }
.sub-list .sub.done span { text-decoration: line-through; color: var(--muted); }
.sub-list input { flex: 1; }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
