/* Eating tracker — mobile-first dark theme */
:root {
    --bg:        #0f0f10;
    --bg-card:   #1a1a1c;
    --bg-pill:   #2a2a2d;
    --bg-pill-h: #3a3a3f;
    --text:      #f2f2f3;
    --text-dim:  #8e8e93;
    --accent:    #4f8cff;
    --danger:    #ff453a;
    --success:   #30d158;
    --border:    #2c2c2e;

    --c-faim:     #30d158;  /* vert  */
    --c-habitude: #4f8cff;  /* bleu  */
    --c-emotions: #ff9f0a;  /* orange */
    --c-mental:   #bf5af2;  /* violet */
    --c-corps:    #ffd60a;  /* jaune */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 80px) env(safe-area-inset-left);
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

/* ---- Top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 {
    font-size: 17px;
    margin: 0;
    font-weight: 600;
}
.topbar nav { display: flex; gap: 14px; }
.topbar a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.topbar a.active { color: var(--accent); }

/* ---- Toast ---- */
.toast {
    background: var(--success);
    color: #002b0e;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 14px;
}
.toast.err { background: var(--danger); color: #fff; }

/* ---- Cards / sections ---- */
.card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}

.section-title {
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin: 18px 0 10px 4px;
}

/* ---- Pills (les boutons options) ---- */
.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.pills form { margin: 0; display: contents; }
.pill {
    background: var(--bg-pill);
    border: none;
    color: var(--text);
    padding: 12px 16px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, transform .1s;
    font-family: inherit;
    text-align: left;
}
.pill:active { background: var(--bg-pill-h); transform: scale(0.97); }
.pill[data-cat="FAIM PHYSIQUE"]            { border-left: 3px solid var(--c-faim); }
.pill[data-cat="HABITUDE / AUTOMATISME"]   { border-left: 3px solid var(--c-habitude); }
.pill[data-cat="ÉMOTIONS"]                 { border-left: 3px solid var(--c-emotions); }
.pill[data-cat="MENTAL / SOCIAL"]          { border-left: 3px solid var(--c-mental); }
.pill[data-cat="CORPS / FATIGUE"]          { border-left: 3px solid var(--c-corps); }

/* ---- Dashboard ---- */
.stats-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
}
.stats-total {
    font-size: 28px;
    font-weight: 700;
}
.stats-total small {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
    margin-left: 6px;
}

.period-switch {
    display: inline-flex;
    background: var(--bg-pill);
    border-radius: 999px;
    padding: 3px;
}
.period-switch a {
    padding: 6px 12px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
}
.period-switch a.on { background: var(--accent); color: #fff; }

/* ---- Camembert ---- */
.pie-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 4px;
    margin-bottom: 14px;
}
.pie {
    width: 160px;
    height: 160px;
    flex-shrink: 0;
    margin: 0 auto;
}
.pie-legend {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pie-legend li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.pie-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.pie-legend-name {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pie-legend-pct {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
@media (max-width: 420px) {
    .pie-wrap { flex-direction: column; gap: 12px; }
    .pie-legend { width: 100%; }
}

.top-reasons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.top-reason-row {
    display: flex;
    justify-content: space-between;
    background: var(--bg-pill);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
}
.top-reason-row .count { color: var(--text-dim); font-variant-numeric: tabular-nums; }

.empty {
    text-align: center;
    color: var(--text-dim);
    padding: 28px 12px;
    font-size: 14px;
}

/* ---- History list ---- */
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.history-list .meta {
    flex: 1;
    min-width: 0;
}
.history-list .reason {
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-list .when {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}
.history-list .cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cat-dot[data-cat="FAIM PHYSIQUE"]            { background: var(--c-faim); }
.cat-dot[data-cat="HABITUDE / AUTOMATISME"]   { background: var(--c-habitude); }
.cat-dot[data-cat="ÉMOTIONS"]                 { background: var(--c-emotions); }
.cat-dot[data-cat="MENTAL / SOCIAL"]          { background: var(--c-mental); }
.cat-dot[data-cat="CORPS / FATIGUE"]          { background: var(--c-corps); }

.btn-del {
    background: transparent;
    border: 1px solid #3a3a3f;
    color: var(--danger);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-del:active { background: rgba(255,69,58,.15); }

@media (min-width: 600px) {
    body { font-size: 17px; }
    .pill { font-size: 16px; padding: 13px 18px; }
}
