/* =========================================================================
   ProjetPerso — identité visuelle
   Mobile d'abord. Tout en local (polices système, aucun CDN).
   Chaque rubrique apporte sa couleur via --accent (posé sur <body>).
   ========================================================================= */

:root {
    /* Neutres */
    --bg:        #eef1f6;
    --card:      #ffffff;
    --ink:       #16202c;
    --ink-soft:  #3a4756;
    --muted:     #7a8699;
    --line:      #e6eaf1;
    --line-soft: #eef1f6;

    /* Couleur de marque (accueil) — chaque page peut la redéfinir */
    --accent:    #0ea678;
    --danger:    #e04657;

    /* Rayons */
    --r-sm: 12px;
    --r:    16px;
    --r-lg: 22px;

    /* Ombres douces et étagées */
    --shadow-sm: 0 1px 2px rgba(18,28,45,.05), 0 1px 3px rgba(18,28,45,.04);
    --shadow:    0 2px 6px rgba(18,28,45,.05), 0 10px 24px -8px rgba(18,28,45,.12);
    --shadow-lg: 0 18px 40px -14px rgba(18,28,45,.28);

    /* Confort tactile */
    --tap: 52px;
    --maxw: 640px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11", "tnum" 0;
}

h1, h2, h3 { letter-spacing: -.02em; line-height: 1.25; }

a { color: var(--accent); }

/* ======================= Barre d'application (haut) ===================== */
.appbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 46px 1fr 46px;
    align-items: center;
    gap: 6px;
    height: 58px;
    padding: 0 10px;
    padding-top: env(safe-area-inset-top);
    background: rgba(255,255,255,.82);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.appbar__lead, .appbar__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px; width: 40px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 22px;
    border: none; background: transparent; cursor: pointer;
}
.appbar__lead:active, .appbar__action:active { background: var(--line-soft); }
.appbar__brand {
    display: inline-flex; align-items: center; justify-content: flex-start;
    gap: 8px; height: 40px; padding-left: 4px;
    font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none;
    white-space: nowrap;
}
.appbar__brand .dot { font-size: 20px; }
.appbar__title {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; min-width: 0;
    font-weight: 700; font-size: 17px; color: var(--ink);
}
.appbar__title .ico { font-size: 20px; }
.appbar__title .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================= Conteneur ================================ */
.wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 18px 16px 104px;   /* marge basse pour la barre d'onglets */
}
.stack > * + * { margin-top: 14px; }

/* ============================= Accueil ================================== */
.hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--r-lg);
    padding: 22px 20px;
    color: #fff;
    background:
        radial-gradient(120% 120% at 85% -10%, rgba(255,255,255,.26), transparent 55%),
        linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 52%, #0b1f3a));
    box-shadow: var(--shadow-lg);
    margin-bottom: 18px;
}
.hero h1 { margin: 0 0 2px; font-size: 26px; font-weight: 800; }
.hero .date { margin: 0; opacity: .9; font-size: 14.5px; font-weight: 500; }
.hero__stats { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.stat {
    flex: 1 1 0; min-width: 120px;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 14px;
    padding: 11px 13px;
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.stat .k { display: block; font-size: 12px; opacity: .88; font-weight: 600; }
.stat .v { font-size: 21px; font-weight: 800; }
.stat .v small { font-size: 12px; font-weight: 600; opacity: .85; }

.section-lead { margin: 2px 2px 14px; font-size: 13px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 520px) { .grid { grid-template-columns: 1fr 1fr; } }

.tile {
    display: flex; align-items: center; gap: 14px;
    text-decoration: none; color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
    transition: transform .09s ease, box-shadow .09s ease;
}
.tile:active { transform: scale(.985); box-shadow: var(--shadow); }
.tile__ico {
    flex: 0 0 auto; width: 50px; height: 50px;
    display: grid; place-items: center; font-size: 26px;
    border-radius: 15px;
    background: color-mix(in srgb, var(--accent) 15%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.tile__txt { flex: 1 1 auto; min-width: 0; }
.tile__txt b { display: block; font-size: 16.5px; font-weight: 700; }
.tile__txt span { color: var(--muted); font-size: 13px; }
.tile__arrow { flex: 0 0 auto; color: color-mix(in srgb, var(--accent) 65%, var(--muted));
    font-size: 24px; font-weight: 300; }

/* ============================== Cartes ================================= */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    margin-bottom: 14px;
}
.card > h2 {
    margin: 0 0 14px;
    font-size: 15px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.card > h2 .tag { margin-left: auto; }
.card__intro { margin: -6px 0 14px; color: var(--muted); font-size: 14px; }

.section-note { color: var(--muted); font-size: 14.5px; margin: -2px 2px 16px; }

/* Accent décoratif à gauche d'une carte */
.card--accent { border-left: 4px solid var(--accent); }

/* ============================ Formulaires =============================== */
label.field { display: block; margin-bottom: 13px; }
label.field > span {
    display: block; font-size: 12.5px; font-weight: 700;
    color: var(--ink-soft); margin-bottom: 7px; letter-spacing: .01em;
}
input[type=text], input[type=number], input[type=date],
input[type=password], select, textarea {
    width: 100%; font: inherit; color: var(--ink);
    background: #fcfdfe;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    padding: 13px 14px;
    min-height: var(--tap);
    transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { min-height: 104px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
    background: #fff;
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1 1 0; min-width: 0; }
.row--grow-first > *:first-child { flex: 2 1 0; }

/* ============================== Boutons ================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: var(--tap);
    font: inherit; font-weight: 700; font-size: 15.5px;
    color: #fff; background: var(--accent);
    border: none; border-radius: 14px; padding: 13px 18px;
    cursor: pointer; text-decoration: none;
    box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
    -webkit-tap-highlight-color: transparent;
    transition: filter .1s ease, transform .06s ease;
}
.btn:active { filter: brightness(.95); transform: translateY(1px); }
.btn--ghost {
    background: color-mix(in srgb, var(--accent) 10%, #fff);
    color: color-mix(in srgb, var(--accent) 72%, #000);
    box-shadow: none;
    border: 1.5px solid color-mix(in srgb, var(--accent) 30%, var(--line));
}
.btn--mute { background: var(--line-soft); color: var(--ink-soft); box-shadow: none; }
.btn--danger { background: var(--danger); box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--danger) 80%, transparent); }
.btn--sm { width: auto; min-height: 44px; padding: 9px 16px; font-size: 14px; }

/* ========================= Listes à cocher ============================= */
.list { list-style: none; margin: 0; padding: 0; }
.list__item {
    display: flex; align-items: center; gap: 13px;
    padding: 13px 2px; border-bottom: 1px solid var(--line-soft);
}
.list__item:last-child { border-bottom: none; }
.list__item form { margin: 0; display: inline-flex; }

.check {
    flex: 0 0 auto; width: 32px; height: 32px;
    border: 1.5px solid var(--line); padding: 0;
    border-radius: 10px; background: #fff;
    display: grid; place-items: center; cursor: pointer;
    font-size: 17px; color: transparent;
    transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.check:active { transform: scale(.9); }
.check--on {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.list__label { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.list__label--done { color: var(--muted); }
.list__label--done b { text-decoration: line-through; }

.icon-btn {
    flex: 0 0 auto; width: 38px; height: 38px;
    border: none; background: transparent; color: var(--muted);
    font-size: 22px; line-height: 1; border-radius: 11px; cursor: pointer;
}
.icon-btn:active { background: var(--line-soft); color: var(--danger); }

/* ============================== Divers ================================= */
.total {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 15px 17px; border-radius: var(--r);
    background: color-mix(in srgb, var(--accent) 10%, #fff);
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
    margin-bottom: 14px; font-weight: 600;
}
.total b { font-size: 26px; font-weight: 800; color: color-mix(in srgb, var(--accent) 72%, #000); }
.total .total__unit { color: var(--muted); font-weight: 700; font-size: 13px; }

.tag, .pill {
    display: inline-block; font-size: 11.5px; font-weight: 800;
    padding: 4px 10px; border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 14%, #fff);
    color: color-mix(in srgb, var(--accent) 70%, #000);
    letter-spacing: .01em;
}
.pill--ok { background: #e4f7ee; color: #0c8a5a; }

.meta { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 15px; }

.flash {
    display: flex; align-items: center; gap: 9px;
    background: #e4f7ee; border: 1px solid #b4e6cd; color: #0b7a50;
    border-radius: 14px; padding: 12px 15px; margin-bottom: 16px; font-weight: 600;
}
.flash::before { content: "✓"; font-weight: 900; }

.day-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    margin: 22px 4px 10px;
}
.day-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.day-head .meta { white-space: nowrap; font-weight: 600; }

details.edit > summary {
    list-style: none; cursor: pointer; color: var(--muted);
    font-size: 13px; font-weight: 700; padding: 3px 0;
    display: inline-flex; align-items: center; gap: 5px;
}
details.edit > summary::-webkit-details-marker { display: none; }
details.edit > summary::before { content: "✎"; font-size: 12px; }
details.edit[open] > summary { color: var(--accent); }

/* ====================== Barre d'onglets (bas) ========================== */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex;
    gap: 2px;
    padding: 7px 6px;
    padding-bottom: calc(7px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.88);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--line);
}
.tab {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    text-decoration: none; color: var(--muted);
    font-size: 10.5px; font-weight: 700; letter-spacing: -.01em;
    padding: 2px 1px;
}
.tab__ico {
    width: 40px; height: 28px;
    display: grid; place-items: center; font-size: 20px;
    border-radius: 999px; opacity: .55;
    transition: background .14s ease, opacity .14s ease;
}
.tab__lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab--on { color: color-mix(in srgb, var(--accent) 72%, #000); }
.tab--on .tab__ico {
    opacity: 1;
    background: color-mix(in srgb, var(--accent) 17%, #fff);
}

/* ==================== Contenu éditorial (Régime) ======================= */
.plan-hero {
    border-radius: var(--r-lg); padding: 20px; color: #fff;
    background:
        radial-gradient(120% 120% at 85% -10%, rgba(255,255,255,.24), transparent 55%),
        linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #5a3410));
    box-shadow: var(--shadow-lg); margin-bottom: 16px;
}
.plan-hero h1 { margin: 0 0 6px; font-size: 23px; font-weight: 800; }
.plan-hero p { margin: 0; font-size: 14.5px; opacity: .95; }
.plan-hero .chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.plan-hero .chip {
    font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: 999px;
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.26);
}

.targets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.target {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 16px; padding: 14px; box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--accent);
}
.target .k { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.target .v { font-size: 22px; font-weight: 800; margin: 2px 0 0; }
.target .v small { font-size: 13px; font-weight: 700; color: var(--muted); }
.target .hint { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; }
.target--hero { grid-column: 1 / -1; border-top-color: #e04657; }
.target--star { border-top-color: var(--accent); }
.target--star .k::after { content: " ★"; color: var(--accent); }

.rules { counter-reset: r; list-style: none; margin: 0; padding: 0; }
.rules > li {
    counter-increment: r; position: relative;
    padding: 12px 2px 12px 44px; border-bottom: 1px solid var(--line-soft);
    line-height: 1.5;
}
.rules > li:last-child { border-bottom: none; }
.rules > li::before {
    content: counter(r); position: absolute; left: 0; top: 11px;
    width: 30px; height: 30px; border-radius: 10px;
    display: grid; place-items: center; font-weight: 800; font-size: 14px;
    color: #fff; background: var(--accent);
}
.rules b { font-weight: 800; }

.chips-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chips-list li {
    font-size: 14px; font-weight: 600; padding: 8px 13px; border-radius: 12px;
    background: color-mix(in srgb, var(--accent) 9%, #fff);
    border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
    color: var(--ink-soft);
}

.snacks { list-style: none; counter-reset: s; margin: 0; padding: 0; }
.snacks > li {
    counter-increment: s; display: flex; gap: 12px; align-items: flex-start;
    padding: 11px 2px; border-bottom: 1px solid var(--line-soft);
}
.snacks > li:last-child { border-bottom: none; }
.snacks > li::before {
    content: counter(s); flex: 0 0 auto;
    width: 26px; height: 26px; border-radius: 999px; margin-top: 1px;
    display: grid; place-items: center; font-weight: 800; font-size: 13px;
    color: color-mix(in srgb, var(--accent) 72%, #000);
    background: color-mix(in srgb, var(--accent) 16%, #fff);
}

.avoid { list-style: none; margin: 0; padding: 0; }
.avoid > li {
    position: relative; padding: 9px 2px 9px 28px; line-height: 1.5;
    border-bottom: 1px solid var(--line-soft); color: var(--ink-soft);
}
.avoid > li:last-child { border-bottom: none; }
.avoid > li::before {
    content: "✕"; position: absolute; left: 4px; top: 9px;
    color: var(--danger); font-weight: 800; font-size: 13px;
}

.steps { list-style: none; margin: 0; padding: 0; }
.steps > li {
    display: flex; gap: 12px; align-items: baseline;
    padding: 10px 2px; border-bottom: 1px solid var(--line-soft);
}
.steps > li:last-child { border-bottom: none; }
.steps .when {
    flex: 0 0 auto; min-width: 78px; font-weight: 800; font-size: 13px;
    color: color-mix(in srgb, var(--accent) 72%, #000);
}

/* ===================== Écrans code / partage =========================== */
.gate { min-height: calc(100vh - 160px); display: grid; place-items: center; padding: 10px; }
.gate .card { width: 100%; max-width: 360px; text-align: center; }
.gate .tile__ico { margin: 0 auto 12px; }
.gate h2 { margin: 0 0 4px; }
.error {
    background: #fdecec; border: 1px solid #f5c2c2; color: #b42318;
    border-radius: 12px; padding: 11px 13px; margin-bottom: 14px; font-size: 14px; font-weight: 600;
}

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 2px; }
