/* Espace personnel Majordome — pensé d'abord pour le téléphone (on y arrive depuis WhatsApp). */
:root {
  --paper: #f4f1ea;
  --card: #fffdf8;
  --ink: #17221e;
  --ink-2: #3c4a44;
  --muted: #727a75;
  --line: #e2dccf;
  --field: #ffffff;
  --green: #1d6b55;
  --green-ink: #ffffff;
  --green-deep: #0f2a23;
  --green-soft: #dfeee7;
  --brass: #96702c;
  --brass-soft: #f3e7cf;
  --danger: #b5432e;
  --danger-soft: #f8e1db;
  --radius: 16px;
  --shadow: 0 1px 0 rgba(23, 34, 30, .04), 0 12px 32px -22px rgba(15, 42, 35, .35);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Figtree", ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121815; --card: #1a221e; --ink: #e9eee9; --ink-2: #c3ccc6; --muted: #929c96; --line: #2b3630;
    --field: #141b18; --green: #5fb59a; --green-ink: #0c1a15; --green-soft: #1f342c; --brass: #d1a85d; --brass-soft: #3a3020;
    --danger: #ef8a74; --danger-soft: #3a221c; --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 1.9rem; line-height: 1.15; }
h2 { font-size: 1.6rem; line-height: 1.2; }
h3 { font-size: 1.12rem; }
p { margin: 0; }
a { color: var(--green); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); font-weight: 600; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 6px; }

.seal { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--green-deep); color: #f1e3c0; font-family: var(--serif); font-size: 1.5rem; flex: none; }
.seal.small { width: 32px; height: 32px; font-size: 1rem; }

/* ---------- Boutons et champs ---------- */
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; padding: .7rem 1.1rem; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; text-decoration: none; min-height: 46px; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--green); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.link { border: 0; background: none; color: var(--green); padding: .4rem .2rem; min-height: 0; font-weight: 500; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: .4rem .85rem; min-height: 36px; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: default; }

label, .label { display: block; font-size: .875rem; font-weight: 600; color: var(--ink-2); margin-bottom: .35rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .35rem; }
input[type="text"], input[type="tel"], input[type="email"], input[type="password"], input[type="date"], input[type="url"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem; min-height: 48px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
::placeholder { color: var(--muted); opacity: .8; }
.field { margin-bottom: 1.1rem; }
.field:last-child { margin-bottom: 0; }
.row { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
.stack { display: grid; gap: .8rem; }

/* ---------- Connexion ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.login-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 2rem 1.5rem; box-shadow: var(--shadow); display: grid; gap: .6rem; }
.login-card .stack { margin-top: 1rem; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.login-msg { min-height: 1.4em; font-size: .9rem; color: var(--danger); }

/* ---------- Structure ---------- */
.shell { min-height: 100dvh; }
.side { display: none; }
.main { max-width: 720px; margin: 0 auto; padding: 0 1rem calc(3rem + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; min-height: 56px; margin: 0 -1rem; padding: .4rem 1rem; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); }
.top-brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.back { display: inline-flex; align-items: center; gap: .15rem; text-decoration: none; font-weight: 600; min-height: 44px; padding-right: .6rem; margin-left: -.35rem; }
.view { outline: none; padding-top: .5rem; }
.view-head { margin-bottom: 1.4rem; display: grid; gap: .35rem; }
.view-head p { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h3 { margin-bottom: .2rem; }
.card > h3 + .muted { margin-bottom: 1rem; font-size: .92rem; }
.card > h3:only-child { margin-bottom: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.card-head .muted { font-size: .92rem; }

/* ---------- Accueil ---------- */
.hello { margin: .6rem 0 1.4rem; display: grid; gap: .4rem; }
.next { display: flex; gap: .9rem; align-items: center; background: var(--green-deep); color: #eef4ef; border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1.1rem; text-decoration: none; }
.next strong { display: block; font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.next span { font-size: .9rem; color: #b9cbc3; }
.next svg { margin-left: auto; color: #f1e3c0; }
.ring { --p: 0; width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 600; font-size: .85rem; color: #f1e3c0; background: radial-gradient(closest-side, var(--green-deep) 78%, transparent 80%), conic-gradient(#f1e3c0 calc(var(--p) * 1%), rgba(255, 255, 255, .16) 0); }
.tiles { display: grid; gap: .7rem; }
.tile { display: flex; align-items: center; gap: .9rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: border-color .15s, transform .1s; }
.tile:hover { border-color: var(--green); }
.tile:active { transform: scale(.995); }
.tile .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); flex: none; }
.tile b { display: block; font-weight: 600; }
.tile small { display: block; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.tile > svg { margin-left: auto; color: var(--muted); width: 18px; height: 18px; }
.tile .todo { color: var(--brass); }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .8rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list li:last-child { padding-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.list small { display: block; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--brass-soft); color: var(--brass); font-family: var(--serif); font-weight: 600; flex: none; }
.icon-btn { appearance: none; border: 0; background: none; color: var(--muted); cursor: pointer; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--green-soft); color: var(--ink); }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .03em; padding: .15rem .55rem; border-radius: 999px; background: var(--green-soft); color: var(--green); vertical-align: middle; }
.badge.brass { background: var(--brass-soft); color: var(--brass); }
.empty { text-align: center; color: var(--muted); padding: .6rem 0 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.note { background: var(--brass-soft); color: var(--ink); border-radius: 12px; padding: .8rem .95rem; font-size: .92rem; }
.note a { color: inherit; font-weight: 600; }

/* ---------- Pastilles (goûts) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { appearance: none; font: inherit; font-size: .93rem; font-weight: 500; border: 1px solid var(--line); background: var(--field); color: var(--ink-2); border-radius: 999px; padding: .45rem .9rem; min-height: 40px; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; transition: background .12s, border-color .12s, color .12s; }
.chip:hover { border-color: var(--green); }
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.chip.avoid[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.chip-add { display: flex; gap: .5rem; margin-top: .7rem; }
.chip-add input { min-height: 42px; padding: .5rem .8rem; }
.chip-add .btn { min-height: 42px; }

/* ---------- Interrupteurs ---------- */
.switch-row { display: flex; align-items: center; gap: 1rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.switch-row:first-of-type { border-top: 0; padding-top: 0; }
.switch-row:last-child { padding-bottom: 0; }
.switch-row .grow { flex: 1; min-width: 0; }
.switch-row b { display: block; font-weight: 600; }
.switch-row small { display: block; color: var(--muted); font-size: .875rem; }
.switch-row select { width: auto; min-height: 42px; padding: .4rem .7rem; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--field); flex-wrap: wrap; }
.seg button { appearance: none; border: 0; background: none; font: inherit; font-weight: 500; font-size: .93rem; color: var(--ink-2); padding: .4rem .9rem; border-radius: 999px; cursor: pointer; min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--green); color: var(--green-ink); }

/* ---------- Offres ---------- */
.usage { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin: .8rem 0 .4rem; }
.usage i { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.usage.full i { background: var(--danger); }
.plans { display: grid; gap: .8rem; }
.plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; background: var(--card); display: grid; gap: .5rem; }
.plan.current { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.plan .price { font-family: var(--serif); font-size: 1.5rem; }
.plan .price small { font-family: var(--sans); font-size: .85rem; color: var(--muted); }
.plan ul { margin: 0; padding: 0; list-style: none; font-size: .93rem; color: var(--ink-2); display: grid; gap: .25rem; }
.plan li::before { content: "✓ "; color: var(--green); font-weight: 600; }
.plan .btn { margin-top: .4rem; }

/* ---------- Fenêtre (ajout, confirmation) ---------- */
.sheet { border: 0; padding: 0; background: var(--card); color: var(--ink); width: min(520px, 100%); max-width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; margin: auto auto 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); }
.sheet::backdrop { background: rgba(10, 20, 16, .5); }
.sheet form { padding: 1.3rem 1.15rem calc(1.3rem + env(safe-area-inset-bottom)); }
.sheet h3 { font-size: 1.3rem; margin-bottom: .3rem; }
.sheet h3 + p { color: var(--muted); margin-bottom: 1.1rem; }
.sheet .actions { justify-content: flex-end; margin-top: 1.3rem; }
.sheet .actions .spacer { flex: 1; }
.sheet .err { color: var(--danger); font-size: .9rem; min-height: 1.3em; margin-top: .6rem; }

.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--green-deep); color: #eef4ef; padding: .65rem 1.1rem; border-radius: 999px; font-weight: 500; font-size: .93rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 2rem); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Grand écran : menu latéral ---------- */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 264px 1fr; }
  .side { display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100dvh; padding: 1.5rem 1rem; background: var(--green-deep); color: #e8efe9; }
  .brand { display: flex; align-items: center; gap: .7rem; font-family: var(--serif); font-size: 1.15rem; color: inherit; text-decoration: none; padding: 0 .5rem; }
  .brand .seal { background: #f1e3c0; color: var(--green-deep); }
  .brand em { display: block; font: 500 .7rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #93a79e; }
  .nav { display: grid; gap: .2rem; }
  .nav a { display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border-radius: 12px; color: #c9d6cf; text-decoration: none; font-weight: 500; }
  .nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
  .nav a[aria-current="page"] { background: rgba(255, 255, 255, .12); color: #fff; }
  .side-foot { margin-top: auto; padding: 0 .5rem; }
  .side-foot .btn { color: #e8efe9; border-color: rgba(255, 255, 255, .25); }
  .top { display: none; }
  .main { padding-top: 2.5rem; }
  .row { grid-template-columns: 1fr 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .plans { grid-template-columns: repeat(3, 1fr); }
  .sheet { border-radius: 22px; margin: auto; }
  .mobile-only { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Ajustements */
.plan .badge { justify-self: start; }
.sheet .actions { position: sticky; z-index: 1; bottom: calc(-1.3rem - env(safe-area-inset-bottom)); background: var(--card); padding: .8rem 1.15rem calc(1.3rem + env(safe-area-inset-bottom)); margin-inline: -1.15rem; margin-bottom: calc(-1.3rem - env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

/* Connexion : séparateur et case à cocher */
.or { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; color: var(--ink-2); margin: 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green); margin: 0; }
.login-card .stack > div label { margin-bottom: .35rem; }
