/* ─── Design tokens ──────────────────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg:             #F5F5F1;
    --surface:        #FFFFFF;
    --surface-soft:   #F0EFE9;
    --surface-dark:   #1C1B18;

    /* Pastels */
    --pastel-blue:    #C3E1E9;
    --pastel-mint:    #D4E8C0;
    --pastel-yellow:  #F5E89A;
    --pastel-coral:   #F5C5C0;
    --pastel-rose:    #F9D0D8;
    --pastel-rose-d:  #F0B0BC;
    --pastel-peach:   #F5D5BC;
    --pastel-cream:   #F0E4D0;
    --pastel-blue-d:  #A8D0DC;
    --pastel-mint-d:  #B6D4A0;

    /* Text */
    --text:           #1A1A1A;
    --text-soft:      #6B6B66;
    --text-muted:     #9A9A95;

    /* Borders */
    --border:         #ECECE7;
    --border-soft:    #F5F5F1;

    /* Status / accents */
    --accent:         #F5E89A;
    --accent-hover:   #EFDF7A;
    --danger:         #ef4444;
    --danger-soft:    #fee2e2;
    --ok:             #6B8E5A;

    /* Radii */
    --radius-xl:      28px;
    --radius:         22px;
    --radius-sm:      14px;
    --radius-xs:      10px;
    --pill:           100px;

    /* Spacing */
    --gap-xs:         6px;
    --gap-sm:         10px;
    --gap:            14px;
    --gap-lg:         18px;
    --gap-xl:         24px;

    /* Shadows */
    --shadow:         0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:      0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg:      0 8px 24px rgba(0, 0, 0, 0.10);
}

/* ─── Reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Helvetica Neue", sans-serif;
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
    overflow-x: hidden;
}

a { color: inherit; }

/* ─── Loading screen ─────────────────────────────────────────────────── */
.loading-screen {
    position: fixed; inset: 0; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 500; transition: opacity 0.3s;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.spinner {
    width: 30px; height: 30px;
    border: 3px solid var(--border); border-top-color: var(--text);
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Layout ─────────────────────────────────────────────────────────── */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 14px 18px 100px;
}

/* ─── Nav ────────────────────────────────────────────────────────────── */
nav {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg);
    padding: 14px 18px 8px;
}

.nav-top {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 auto 10px;
    max-width: 480px;
    gap: 10px;
}

.nav-logo {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.4px;
    color: var(--text);
}

.nav-actions {
    display: flex; gap: 6px; align-items: center;
}

.btn-nav {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 14px;
    border: none;
    background: var(--surface);
    border-radius: var(--pill);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.18s, color 0.18s;
    box-shadow: var(--shadow);
}
.btn-nav:hover { background: var(--border); color: var(--text); }
.btn-nav.btn-icon { padding: 9px 11px; }
.btn-logout:hover { background: var(--danger-soft); color: var(--danger); }

.nav-tabs-wrap {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -18px;
    padding: 0 18px;
}
.nav-tabs-wrap::-webkit-scrollbar { display: none; }

.nav-tabs {
    display: flex; gap: 4px; list-style: none;
    width: max-content;
    padding: 4px;
    background: var(--surface);
    border-radius: var(--pill);
    box-shadow: var(--shadow);
}

.nav-tab {
    padding: 8px 16px;
    border-radius: var(--pill);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    display: inline-block;
}
.nav-tab:hover  { color: var(--text); }
.nav-tab.active { background: var(--text); color: #fff; cursor: default; }
.nav-tab.active:hover { color: #fff; }
.nav-tab.soon   { opacity: 0.4; cursor: default; }
.nav-tab.soon:hover { color: var(--text-soft); }

/* ─── Page heading ───────────────────────────────────────────────────── */
.page-greet {
    font-size: 13px; color: var(--text-muted);
    margin-bottom: 4px;
}
.page-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.05;
    margin-bottom: 6px;
    color: var(--text);
}
.page-sub {
    font-size: 14px;
    color: var(--text-soft);
    margin-bottom: 22px;
    line-height: 1.4;
}

/* ─── Cards & stats ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    animation: fadeUp 0.4s ease both;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 17px; font-weight: 600;
    margin-bottom: 14px;
    letter-spacing: -0.2px;
}
.card-sub {
    font-size: 12.5px; color: var(--text-muted);
    margin-top: -8px; margin-bottom: 18px;
    line-height: 1.4;
}

.stat-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    margin-bottom: 12px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.4s ease both;
}
.stat-card.dark   { background: var(--text); color: #fff; }
.stat-card.blue   { background: var(--pastel-blue); }
.stat-card.mint   { background: var(--pastel-mint); }
.stat-card.peach  { background: var(--pastel-peach); }
.stat-card.yellow { background: var(--pastel-yellow); }
.stat-card.coral  { background: var(--pastel-coral); }

.stat-label {
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.stat-card.dark .stat-label { color: rgba(255, 255, 255, 0.5); }

.stat-value {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1.4px;
    line-height: 1;
}
.stat-unit {
    font-size: 14px; font-weight: 400;
    color: var(--text-muted);
    margin-left: 3px;
}
.stat-card.dark .stat-unit { color: rgba(255, 255, 255, 0.5); }

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.35;
}
.stat-card.dark .stat-sub { color: rgba(255, 255, 255, 0.5); }

/* ─── Toast ──────────────────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--text); color: #fff;
    padding: 12px 22px; border-radius: var(--pill);
    font-size: 13.5px; font-weight: 500;
    opacity: 0; transition: opacity 0.28s, transform 0.28s;
    z-index: 300; pointer-events: none; white-space: nowrap;
    box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Modal ──────────────────────────────────────────────────────────── */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
    padding: 18px;
}
.overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 26px;
    width: 100%; max-width: 420px;
    transform: translateY(16px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.overlay.open .modal { transform: translateY(0) scale(1); }
.modal-title {
    font-size: 22px; font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.modal-sub {
    font-size: 13px; color: var(--text-muted);
    margin-bottom: 18px;
}
.m-label {
    display: block;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.m-input {
    width: 100%;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.18s;
    -webkit-appearance: none;
}
.m-input:focus { border-color: var(--text); }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; }
.btn-ok, .btn-cancel {
    flex: 1; padding: 13px;
    font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    border-radius: var(--radius-sm);
    transition: opacity 0.15s, background 0.15s;
    border: none;
}
.btn-ok { background: var(--text); color: #fff; }
.btn-ok:hover { opacity: 0.85; }
.btn-cancel {
    background: var(--bg);
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-cancel:hover { background: var(--border); }

/* ─── Buttons utilitaires ────────────────────────────────────────────── */
.btn-primary {
    background: var(--text); color: #fff;
    border: none; border-radius: var(--radius-sm);
    padding: 13px 22px;
    font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    transition: opacity 0.18s;
}
.btn-primary:hover  { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 22px;
    font-size: 14px; font-weight: 500;
    color: var(--text);
    cursor: pointer; font-family: inherit;
    transition: background 0.18s;
}
.btn-secondary:hover { background: var(--border); }

/* ─── Responsive desktop ────────────────────────────────────────────────── */
@media (min-width: 640px) {
    .container { padding: 18px 24px 120px; max-width: 640px; }
    nav { padding: 18px 24px 10px; }
    .page-title { font-size: 38px; }
}

@media (min-width: 900px) {
    .container { max-width: 820px; padding: 24px 32px 140px; }
    nav { padding: 22px 32px 10px; }
    .nav-top { max-width: 820px; }
    .page-title { font-size: 44px; }
}

/* ─── Widget Oui / Non ──────────────────────────────────────────────────── */
.yn-item {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    user-select: none;
}
.yn-body { flex: 1; min-width: 0; }
.yn-label {
    font-size: 15.5px; font-weight: 600;
    line-height: 1.3; letter-spacing: -0.2px;
    color: var(--text);
}
.yn-meta {
    font-size: 12.5px; color: var(--text-muted);
    margin-top: 2px; line-height: 1.35;
}
.yn-btns { display: flex; gap: 6px; flex-shrink: 0; }
.yn-btn {
    padding: 7px 14px;
    border-radius: var(--pill);
    border: 1.5px solid var(--border);
    background: var(--bg);
    font-size: 13px; font-weight: 600;
    color: var(--text-soft);
    cursor: pointer; font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}
.yn-btn:hover { background: var(--border); color: var(--text); }
.yn-btn.yn-oui {
    background: var(--pastel-coral);
    border-color: var(--pastel-coral);
    color: var(--text);
}
.yn-btn.yn-non {
    background: var(--pastel-mint);
    border-color: var(--pastel-mint);
    color: var(--text);
}

/* ─── Preview contextuelle ──────────────────────────────────────────────── */
.preview-section {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.preview-title {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.preview-list {
    list-style: none;
    display: flex; flex-direction: column; gap: 5px;
}
.preview-list li {
    font-size: 13px; color: var(--text-muted);
    padding-left: 14px; position: relative;
    line-height: 1.4;
}
.preview-list li::before {
    content: "·";
    position: absolute; left: 0;
    color: var(--text-muted);
}

/* ─── RDV dashboard — dégradé animé (jour J / veille) ───────────────── */
@keyframes rdv-shimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.check-item.rdv-urgent {
    background: linear-gradient(135deg, #FFF7ED, #FECACA, #FEF3C7, #FFF7ED);
    background-size: 300% 300%;
    animation: rdv-shimmer 3s ease infinite;
    border: none;
}
.check-item.rdv-urgent .check-box {
    background: rgba(255,255,255,0.6);
    border-color: rgba(0,0,0,0.1);
}
.check-item.rdv-urgent .check-label { color: var(--text); }
.check-item.rdv-urgent .check-meta  { color: var(--text-soft); }

/* RDV dashboard — grisé (7 jours avant) */
.check-item.rdv-soon {
    background: var(--surface);
    border: 1.5px dashed var(--border);
    opacity: 0.65;
}
.check-item.rdv-soon .check-label { color: var(--text-soft); font-weight: 500; }

/* Tag badge inline */
.check-tag {
    font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: var(--pill);
    flex-shrink: 0; white-space: nowrap;
}
.check-tag.urgent  { background: rgba(255,255,255,0.7); color: #92400E; }
.check-tag.soon    { background: var(--border); color: var(--text-muted); }
.check-tag.checkup { background: var(--pastel-yellow); color: #78450A; }

/* ─── Heatmap Good News ───────────────────────────────────────────────── */
.heatmap-grid {
    display: flex; gap: 3px; flex-wrap: wrap;
}
.hm-cell {
    width: 16px; height: 16px; border-radius: 4px;
    background: var(--border);
}
.hm-cell.l1 { background: #C8E6C9; }
.hm-cell.l2 { background: #81C784; }
.hm-cell.l3 { background: #43A047; }
.hm-cell.l4 { background: #1B5E20; }

/* ─── Calendrier — grille desktop ───────────────────────────────────── */
.cal-grid-desktop {
    display: grid; grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}
.cal-cell-desktop {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 6px; min-height: 80px;
    background: var(--surface);
    cursor: pointer;
    transition: background 0.12s;
}
.cal-cell-desktop:hover { background: var(--bg); }
.cal-cell-desktop.other-month { background: #FAFAF8; }
.cal-cell-desktop.today { background: #F0F9FF; }
.cal-cell-desktop .day-num {
    font-size: 12px; font-weight: 600; color: var(--text-soft);
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 4px;
}
.cal-cell-desktop.today .day-num { background: var(--text); color: #fff; font-weight: 700; }
.cal-cell-desktop.other-month .day-num { color: var(--border); }
.cal-pill {
    display: block; font-size: 10px; font-weight: 600;
    padding: 2px 6px; border-radius: 5px; margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-pill.rdv     { background: #FEE2E2; color: #B91C1C; }
.cal-pill.sport   { background: var(--pastel-mint); color: #3D6B2A; }
.cal-pill.checkup { background: var(--pastel-yellow); color: #92400E; }

/* Grille mobile compacte */
.cal-grid-mobile {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-cell-mobile {
    aspect-ratio: 1; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 500; color: var(--text-soft);
    cursor: pointer; gap: 2px;
    transition: background 0.12s;
}
.cal-cell-mobile:hover { background: var(--border); }
.cal-cell-mobile.today { background: var(--text); color: #fff; font-weight: 700; }
.cal-cell-mobile.other-month { color: var(--border); }
.cal-cell-mobile.selected { background: var(--pastel-blue); color: var(--text); }
.cal-dots { display: flex; gap: 2px; }
.cal-dot { width: 4px; height: 4px; border-radius: 50%; }
.cal-dot.rdv     { background: #EF4444; }
.cal-dot.sport   { background: var(--ok); }
.cal-dot.checkup { background: #F59E0B; }

/* Panneau inline (clic jour mobile) */
.cal-day-detail {
    background: var(--pastel-blue);
    border-radius: var(--radius-sm);
    padding: 12px 14px; margin: 6px 0;
}
.cal-day-detail-title {
    font-size: 11px; font-weight: 700; color: var(--text);
    margin-bottom: 8px; text-transform: capitalize;
}

/* Sidebar calendrier */
.cal-sidebar {
    width: 200px; flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
}
.cal-main { flex: 1; min-width: 0; }
@media (max-width: 640px) {
    .cal-sidebar { display: none; }
}

/* Upcoming event card */
.upcoming-ev {
    padding: 9px 10px; border-radius: var(--radius-sm);
    margin-bottom: 6px; background: var(--bg);
    border-left: 3px solid var(--border);
}
.upcoming-ev.rdv     { border-color: #EF4444; }
.upcoming-ev.sport   { border-color: var(--ok); }
.upcoming-ev.checkup { border-color: #F59E0B; }
.upcoming-ev-title { font-size: 12px; font-weight: 600; color: var(--text); }
.upcoming-ev-date  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.upcoming-ev-badge {
    display: inline-block; font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: var(--pill); margin-top: 4px;
}
.upcoming-ev-badge.soon { background: #FEE2E2; color: #B91C1C; }
.upcoming-ev-badge.ok   { background: var(--pastel-mint); color: #3D6B2A; }

/* ─── Mobile : masquer la nav, compenser le padding ─────────────────── */
@media (max-width: 639px) {
    nav { display: none; }
    .container { padding: 42px 18px 40px; }
}

/* ─── Desktop full-width (pages modules) ────────────────────────────── */
@media (min-width: 900px) {
    .container.full-width {
        max-width: none;
        padding-left: 40px;
        padding-right: 40px;
    }
    .page-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        align-items: start;
        margin-top: 14px;
    }
    .page-grid > .full-col {
        grid-column: 1 / -1;
    }
}

/* ─── Overlay Convalescence ──────────────────────────────────────────────── */
.conv-overlay-meds { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.conv-med-row {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface-soft); border-radius: var(--radius-sm); padding: 8px 10px;
}
.conv-med-name {
    flex: 1; background: transparent; border: 1px solid var(--border);
    border-radius: 6px; padding: 6px 10px; font-size: 14px; color: var(--text);
    font-family: inherit;
}
.conv-med-name:focus { outline: none; border-color: var(--accent); }
.conv-med-slots { display: flex; gap: 4px; }
.conv-med-slot {
    font-size: 12px; padding: 4px 8px; border-radius: 5px;
    border: 1.5px solid var(--border); background: var(--bg);
    color: var(--text-soft); cursor: pointer; font-family: inherit;
    transition: all 0.15s; user-select: none;
}
.conv-med-slot.active { background: var(--accent); border-color: var(--accent-hover); color: var(--text); font-weight: 600; }
.conv-med-del {
    background: transparent; border: none; cursor: pointer; color: var(--text-muted);
    padding: 4px 6px; border-radius: 5px; font-size: 16px; line-height: 1;
    transition: all 0.15s;
}
.conv-med-del:hover { background: var(--danger-soft); color: var(--danger); }
.conv-tasks-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px;
}
.conv-task-check {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-soft); cursor: pointer; padding: 4px 2px;
}
.conv-task-check input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--text); }
.conv-banner {
    background: var(--pastel-rose); border-radius: var(--radius);
    padding: 12px 16px; display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 0;
}
.conv-banner-cause { flex: 1; font-size: 15px; font-weight: 600; color: var(--text); }
.conv-banner-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.conv-banner-actions { display: flex; gap: 8px; }
.conv-btn-end {
    background: var(--pastel-rose-d); border: none; border-radius: var(--radius-sm);
    padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text);
    cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.conv-btn-end:hover { background: #d090a0; }
.conv-btn-edit {
    background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 7px 14px; font-size: 13px; color: var(--text-soft);
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.conv-btn-edit:hover { border-color: var(--text-soft); color: var(--text); }
/* Bouton Convalescence dans l'en-tête de section */
.conv-activate-btn {
    background: transparent; border: 1.5px solid var(--pastel-rose-d);
    border-radius: 20px; padding: 4px 12px; font-size: 12px; color: var(--text-soft);
    cursor: pointer; font-family: inherit; transition: all 0.15s; white-space: nowrap;
}
.conv-activate-btn:hover { background: var(--pastel-rose); color: var(--text); }

/* Convalescence — ligne indicateur dans le tracker heatmap */
.tk-conv-row .tk-row-label { font-size: 13px; line-height: 1; }
.tk-conv-row td.tk-cell { height: 8px; }
.tk-conv-day { background: var(--pastel-peach) !important; }

/* Convalescence dans le calendrier */
.cal-cell-mobile.convalescent:not(.today):not(.selected) { background: var(--pastel-peach); }
.cal-cell-desktop.convalescent:not(.today) { background: var(--pastel-peach); }
.cal-dot.convalescent { background: #D4845A; }
.cal-pill.convalescent { background: var(--pastel-peach); color: #7A3E1A; }

/* ─── Panneau Séance Kettlebell (slide plein écran) ────────────────────── */
body.kb-open { overflow: hidden; }

.kb-panel {
    position: fixed; inset: 0;
    z-index: 300;
    background: var(--bg);
    display: flex; flex-direction: column;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.34s;
    padding-top: env(safe-area-inset-top);
}
.kb-panel.open { transform: translateX(0); visibility: visible; }

.kb-head {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 18px 20px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.kb-head-txt { flex: 1; min-width: 0; }
.kb-title {
    font-family: Palatino, "Palatino Linotype", Georgia, serif;
    font-size: 22px; font-weight: 700; color: var(--text);
    letter-spacing: -0.4px;
}
.kb-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.kb-close {
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-soft);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.kb-close:hover { background: var(--text); border-color: var(--text); color: #fff; }

/* Barre minuteur (collée sous l'en-tête) */
.kb-timerbar {
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    transition: background 0.3s;
}
.kb-timerbar.running.work { background: var(--pastel-mint); border-bottom-color: var(--pastel-mint-d); }
.kb-timerbar.running.rest { background: var(--pastel-blue); border-bottom-color: var(--pastel-blue-d); }
.kb-timerbar.running.prep { background: var(--pastel-yellow); border-bottom-color: var(--accent-hover); }

.kb-tb-idle { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.kb-tb-idle-txt { flex: 1; min-width: 140px; }
.kb-tb-idle-title { font-size: 15.5px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.kb-tb-idle-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.kb-tb-idle-btns { display: flex; gap: 8px; flex-shrink: 0; }

.kb-tb-run { display: flex; align-items: center; gap: 16px; }
.kb-tb-count {
    font-variant-numeric: tabular-nums;
    font-size: 44px; font-weight: 700;
    letter-spacing: -2px; color: var(--text);
    min-width: 74px; line-height: 1;
}
.kb-tb-info { flex: 1; min-width: 0; }
.kb-tb-phase {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-soft);
}
.kb-tb-ex {
    font-size: 15.5px; font-weight: 700; color: var(--text);
    letter-spacing: -0.2px; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-tb-next {
    font-size: 12px; color: var(--text-soft); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-tb-btns { display: flex; gap: 6px; flex-shrink: 0; }
.kb-tb-progress {
    height: 4px; border-radius: 4px;
    background: rgba(0, 0, 0, 0.08);
    margin-top: 12px; overflow: hidden;
}
.kb-tb-progress span {
    display: block; height: 100%;
    background: var(--text);
    border-radius: 4px;
    transition: width 0.9s linear;
}

.kb-btn {
    border-radius: var(--pill);
    padding: 9px 16px;
    font-size: 13px; font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-soft);
    transition: all 0.15s;
    white-space: nowrap;
}
.kb-btn:hover { background: var(--border); color: var(--text); }
.kb-btn.primary { background: var(--text); border-color: var(--text); color: #fff; }
.kb-btn.primary:hover { opacity: 0.88; background: var(--text); color: #fff; }
.kb-timerbar.running .kb-btn {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.9);
    color: var(--text);
    min-width: 42px; text-align: center;
}
.kb-timerbar.running .kb-btn:hover { background: #fff; }

/* Liste des exercices */
.kb-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.kb-inner {
    max-width: 720px; margin: 0 auto;
    padding: 18px 20px calc(40px + env(safe-area-inset-bottom));
}
.kb-list { display: flex; flex-direction: column; gap: 10px; }

.kb-ex {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s, background 0.2s;
}
.kb-ex.done   { background: var(--pastel-mint); }
.kb-ex.active { border-color: var(--text); }

.kb-ex-head {
    display: flex; align-items: center; gap: 14px;
    padding: 15px 18px;
    cursor: pointer; user-select: none;
}
.kb-box {
    width: 28px; height: 28px; flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
}
.kb-box svg { width: 13px; height: 13px; color: #fff; opacity: 0; transition: opacity 0.15s; }
.kb-ex.done .kb-box { background: var(--text); border-color: var(--text); }
.kb-ex.done .kb-box svg { opacity: 1; }

.kb-ex-body { flex: 1; min-width: 0; }
.kb-ex-label {
    font-size: 15px; font-weight: 600; color: var(--text);
    letter-spacing: -0.2px; line-height: 1.3;
}
.kb-ex-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; margin-right: 8px;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 11px; font-weight: 700;
    vertical-align: 1px;
}
.kb-ex.done .kb-ex-num { background: rgba(255, 255, 255, 0.6); color: var(--text); }
.kb-ex-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.35; }
.kb-ex.done .kb-ex-meta { color: var(--text-soft); }

.kb-play {
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
    border-radius: var(--pill);
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-soft);
    padding: 7px 13px 7px 11px;
    font-size: 12px; font-weight: 700;
    font-family: inherit; cursor: pointer;
    transition: all 0.15s;
}
.kb-play svg { width: 11px; height: 11px; }
.kb-play:hover { background: var(--text); border-color: var(--text); color: #fff; }
.kb-ex.done .kb-play { background: rgba(255, 255, 255, 0.65); border-color: rgba(255, 255, 255, 0.9); color: var(--text); }

.kb-media { padding: 0 18px; }
.kb-media img {
    display: block; width: 100%;
    max-height: 300px; object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
}

.kb-cues {
    list-style: none; counter-reset: kbcue;
    padding: 14px 18px 16px;
    display: flex; flex-direction: column; gap: 7px;
}
.kb-cues li {
    counter-increment: kbcue;
    position: relative;
    padding-left: 24px;
    font-size: 13px; line-height: 1.45;
    color: var(--text-soft);
}
.kb-cues li::before {
    content: counter(kbcue);
    position: absolute; left: 0; top: 1px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text-muted);
    font-size: 9.5px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.kb-ex.done .kb-cues li { color: var(--text-soft); }
.kb-ex.done .kb-cues li::before { background: rgba(255, 255, 255, 0.6); color: var(--text-soft); }

.kb-tips {
    margin-top: 18px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.kb-tips-title {
    font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
    text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 10px;
}
.kb-tips ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.kb-tips li {
    font-size: 13px; line-height: 1.45; color: var(--text-soft);
    padding-left: 14px; position: relative;
}
.kb-tips li::before {
    content: ''; position: absolute; left: 0; top: 8px;
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--pastel-mint-d);
}
.kb-source {
    display: inline-block; margin-top: 12px;
    font-size: 12.5px; font-weight: 600;
    color: var(--text-soft);
    border-bottom: 1.5px solid var(--accent);
    text-decoration: none;
}
.kb-source:hover { color: var(--text); }

/* Bouton d'ouverture (dashboard + carte Sport) */
.kb-open-btn {
    display: inline-flex; align-items: center; gap: 6px;
    border-radius: var(--pill);
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-soft);
    padding: 8px 15px;
    font-size: 12.5px; font-weight: 600;
    font-family: inherit; cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.kb-open-btn:hover { background: var(--text); border-color: var(--text); color: #fff; }

@media (max-width: 520px) {
    .kb-tb-count { font-size: 36px; min-width: 60px; }
    .kb-tb-run { gap: 12px; }
    .kb-tb-btns { flex-direction: column; gap: 5px; }
    .kb-timerbar.running .kb-btn { padding: 7px 10px; }
    .kb-media img { max-height: 220px; }
}

/* Bouton "Exercices" sur l'item Kettlebell du dashboard — accentué pour rester
   repérable sur petit écran */
.side-btn.kb-side {
    background: var(--accent);
    border-color: var(--accent-hover);
    color: var(--text);
    font-weight: 700;
    padding: 7px 14px;
}
.side-btn.kb-side:hover { background: var(--accent-hover); color: var(--text); }
.check-item.done .side-btn.kb-side,
.check-item.off-day .side-btn.kb-side {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(255, 255, 255, 0.9);
}

/* Sur écran étroit, l'item passe sur deux lignes plutôt que de pousser le
   bouton hors de l'écran */
@media (max-width: 430px) {
    .check-item:has(.side-btn.kb-side) { flex-wrap: wrap; }
    .check-item:has(.side-btn.kb-side) .check-body { flex: 1 1 100%; }
    .check-item:has(.side-btn.kb-side) .side-btn.kb-side { margin-left: auto; }
}

/* Placeholder quand le GIF local n'est pas installé */
.kb-media.missing { padding: 0 18px; }
.kb-media-ph {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    padding: 18px;
    text-align: center;
}
.kb-media-ph-title { font-size: 13px; font-weight: 700; color: var(--text-soft); }
.kb-media-ph-sub   { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.kb-media-ph-sub code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 5px;
}

/* ─── Bloc Habitudes en acquisition (plusieurs en parallèle) ────────────── */
.habit-block {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 14px 12px;
    margin-bottom: 10px;
}
.habit-block-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 10px; padding: 0 4px;
}
.habit-block-title {
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-soft);
}
.habit-block-title em {
    font-style: normal;
    background: var(--accent);
    color: var(--text);
    border-radius: var(--pill);
    padding: 1px 8px;
    margin-left: 4px;
}
.check-item.habit-hero { background: var(--pastel-yellow); }
.check-item.habit-hero.done { background: var(--pastel-mint); }

.habit-bar {
    height: 4px; border-radius: 4px;
    background: rgba(0, 0, 0, 0.09);
    margin-top: 7px; overflow: hidden;
    max-width: 260px;
}
.habit-bar span {
    display: block; height: 100%;
    background: var(--text);
    border-radius: 4px;
}
.habit-jx {
    flex-shrink: 0;
    font-size: 12.5px; font-weight: 700;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--pill);
    padding: 4px 10px;
    white-space: nowrap;
}
.habit-acquired-strip {
    margin-top: 10px; padding: 9px 12px;
    background: #F3E5B8;
    border-radius: var(--radius-sm);
    font-size: 12px; color: #7A5F14;
    line-height: 1.5;
}
.habit-acquired-strip span { font-weight: 600; }
.habit-acquired-strip span + span::before { content: ' · '; font-weight: 400; }

/* ─── Bloc DEMAIN (aperçu de la matinée, lecture seule) ─────────────────── */
.tomorrow-block {
    margin-top: 20px;
    background: var(--surface-dark);
    color: #F2F1EC;
    border-radius: var(--radius);
    padding: 20px 22px 18px;
    box-shadow: var(--shadow-md);
}
.tmr-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tmr-title {
    font-family: Palatino, "Palatino Linotype", Georgia, serif;
    font-size: 26px; font-weight: 700;
    letter-spacing: 1.5px; text-transform: uppercase;
}
.tmr-date { font-size: 12.5px; color: rgba(242, 241, 236, 0.6); }
.tmr-sub  { font-size: 12px; color: rgba(242, 241, 236, 0.45); margin-top: 2px; }

.tmr-list { margin-top: 14px; display: flex; flex-direction: column; }
.tmr-row {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 0;
    border-top: 1px solid rgba(242, 241, 236, 0.12);
}
.tmr-row:first-child { border-top: none; }
.tmr-icon { font-size: 15px; width: 22px; text-align: center; flex-shrink: 0; }
.tmr-label { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.tmr-meta {
    font-size: 11.5px; color: rgba(242, 241, 236, 0.5);
    text-align: right; flex-shrink: 0;
}

.tmr-prep {
    margin-top: 16px;
    background: rgba(242, 241, 236, 0.08);
    border-radius: var(--radius-sm);
    padding: 13px 15px;
}
.tmr-prep-title {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    color: rgba(242, 241, 236, 0.55);
    margin-bottom: 7px;
}
.tmr-prep ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.tmr-prep li {
    font-size: 13px; line-height: 1.4;
    padding-left: 15px; position: relative;
    color: rgba(242, 241, 236, 0.9);
}
.tmr-prep li::before {
    content: ''; position: absolute; left: 0; top: 7px;
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent);
}

/* Écran hors ligne (session valide mais serveur injoignable) */
.offline-screen {
    position: fixed; inset: 0; z-index: 500;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.offline-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 28px;
    max-width: 380px; text-align: center;
}
.offline-title { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 8px; }
.offline-card p { font-size: 13.5px; color: var(--text-soft); line-height: 1.5; margin-bottom: 18px; }
