/* ============================================================================
   Design System — Suite Agenda / Mémos / Tâches / Notes
   Fichier partagé par toutes les pages : /assets/app.css
   Mobile-first, thème clair + sombre, cibles tactiles >= 44px, safe-areas iOS.
   ========================================================================== */

/* ---------------------------------------------------------------- 1. Tokens */
:root {
    /* Typographie */
    --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui,
                 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* Palette de marque (indigo) */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-200: #c7d2fe;
    --brand-300: #a5b4fc;
    --brand-400: #818cf8;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-800: #3730a3;
    --brand-900: #312e81;

    /* Neutres */
    --slate-50:  #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Couleurs sémantiques */
    --success: #059669;
    --success-soft: #d1fae5;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --danger:  #e11d48;
    --danger-soft: #ffe4e6;
    --info:    #0284c7;
    --info-soft: #e0f2fe;

    /* Catégories (agenda / mémos / tâches) */
    --cat-76:          #2563eb;
    --cat-association: #16a34a;
    --cat-personnel:   #ea580c;
    --cat-default:     #4f46e5;

    /* Surfaces — thème clair */
    --bg:            #f4f5fb;
    --bg-accent:     radial-gradient(1200px 600px at 15% -10%, #e8ecff 0%, transparent 60%),
                     radial-gradient(900px 500px at 100% 0%, #f2e9ff 0%, transparent 55%);
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --surface-3:     #f1f5f9;
    --surface-hover: #f1f5f9;
    --border:        #e5e9f0;
    --border-strong: #d3dae5;

    --text:        #0f172a;
    --text-muted:  #52607a;
    --text-subtle: #7c889e;
    --text-invert: #ffffff;

    --accent:          var(--brand-600);
    --accent-hover:    var(--brand-700);
    --accent-soft:     var(--brand-50);
    --accent-soft-2:   var(--brand-100);
    --accent-contrast: #ffffff;
    --ring: 0 0 0 3px rgba(99, 102, 241, .30);

    /* Élévation */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 28px rgba(15, 23, 42, .12), 0 4px 8px rgba(15, 23, 42, .05);
    --shadow-xl: 0 24px 56px rgba(15, 23, 42, .18);

    /* Rayons */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-full: 999px;

    /* Espacements */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;

    /* Divers */
    --appbar-h: 60px;
    --tap: 44px;
    --transition: 180ms cubic-bezier(.4, 0, .2, 1);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    color-scheme: light;
}

/* Thème sombre — automatique, sauf si le mode clair est forcé */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #0b1020;
        --bg-accent:     radial-gradient(1200px 600px at 15% -10%, #17204a 0%, transparent 60%),
                         radial-gradient(900px 500px at 100% 0%, #241a4d 0%, transparent 55%);
        --surface:       #121a2e;
        --surface-2:     #172136;
        --surface-3:     #1d2942;
        --surface-hover: #1d2942;
        --border:        #26324c;
        --border-strong: #33405f;

        --text:        #e8ecf6;
        --text-muted:  #a3b0c9;
        --text-subtle: #7f8ca8;

        --accent:          var(--brand-400);
        --accent-hover:    var(--brand-300);
        --accent-soft:     rgba(99, 102, 241, .16);
        --accent-soft-2:   rgba(99, 102, 241, .26);
        --accent-contrast: #0b1020;

        --success-soft: rgba(5, 150, 105, .20);
        --warning-soft: rgba(217, 119, 6, .20);
        --danger-soft:  rgba(225, 29, 72, .20);
        --info-soft:    rgba(2, 132, 199, .20);

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, .5);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
        --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
        --shadow-lg: 0 14px 32px rgba(0, 0, 0, .55);
        --shadow-xl: 0 28px 60px rgba(0, 0, 0, .65);
        --ring: 0 0 0 3px rgba(129, 140, 248, .35);
        color-scheme: dark;
    }
}

/* Thème sombre — forcé depuis le sélecteur */
:root[data-theme="dark"] {
    --bg:            #0b1020;
    --bg-accent:     radial-gradient(1200px 600px at 15% -10%, #17204a 0%, transparent 60%),
                     radial-gradient(900px 500px at 100% 0%, #241a4d 0%, transparent 55%);
    --surface:       #121a2e;
    --surface-2:     #172136;
    --surface-3:     #1d2942;
    --surface-hover: #1d2942;
    --border:        #26324c;
    --border-strong: #33405f;

    --text:        #e8ecf6;
    --text-muted:  #a3b0c9;
    --text-subtle: #7f8ca8;

    --accent:          var(--brand-400);
    --accent-hover:    var(--brand-300);
    --accent-soft:     rgba(99, 102, 241, .16);
    --accent-soft-2:   rgba(99, 102, 241, .26);
    --accent-contrast: #0b1020;

    --success-soft: rgba(5, 150, 105, .20);
    --warning-soft: rgba(217, 119, 6, .20);
    --danger-soft:  rgba(225, 29, 72, .20);
    --info-soft:    rgba(2, 132, 199, .20);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
    --shadow-lg: 0 14px 32px rgba(0, 0, 0, .55);
    --shadow-xl: 0 28px 60px rgba(0, 0, 0, .65);
    --ring: 0 0 0 3px rgba(129, 140, 248, .35);
    color-scheme: dark;
}

/* ------------------------------------------------------------ 2. Base/reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background-color: var(--bg);
    background-image: var(--bg-accent);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

img, svg { max-width: 100%; }

a { color: var(--accent); text-decoration: none; }

h1, h2, h3, h4 {
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -.015em;
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

::selection { background: var(--accent-soft-2); color: var(--text); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-full);
    border: 3px solid transparent;
    background-clip: content-box;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* --------------------------------------------------------- 3. Barre d'appli */
.appbar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: var(--appbar-h);
    padding: var(--s-2) clamp(12px, 3vw, 24px);
    padding-top: calc(var(--s-2) + var(--safe-t));
    padding-left: calc(clamp(12px, 3vw, 24px) + var(--safe-l));
    padding-right: calc(clamp(12px, 3vw, 24px) + var(--safe-r));
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.appbar-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: -.02em;
    white-space: nowrap;
}

.appbar-brand .logo {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 10px;
    background: linear-gradient(140deg, var(--brand-500), var(--brand-700));
    color: #fff;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

.appbar-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: var(--s-2);
    overflow-x: auto;
    scrollbar-width: none;
}
.appbar-nav::-webkit-scrollbar { display: none; }

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--r-sm);
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }

.appbar-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-left: auto;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 1.05rem;
    font-family: inherit;
    transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.active,
.icon-btn.active-toggle {
    background: var(--accent-soft);
    border-color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    color: var(--accent);
}

/* Dock de navigation mobile */
.mobile-dock { display: none; }

@media (max-width: 860px) {
    .appbar-nav { display: none; }

    .mobile-dock {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 950;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        gap: 2px;
        padding: 6px calc(6px + var(--safe-l)) calc(6px + var(--safe-b)) calc(6px + var(--safe-r));
        background: var(--surface);
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        -webkit-backdrop-filter: saturate(180%) blur(16px);
        backdrop-filter: saturate(180%) blur(16px);
        border-top: 1px solid var(--border);
    }

    .mobile-dock a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: var(--tap);
        padding: 6px 2px;
        border-radius: var(--r-sm);
        font-size: .68rem;
        font-weight: 600;
        color: var(--text-subtle);
        line-height: 1.1;
        text-align: center;
    }
    .mobile-dock a .ico { font-size: 1.15rem; line-height: 1; }
    .mobile-dock a.active { color: var(--accent); background: var(--accent-soft); }

    body { padding-bottom: calc(68px + var(--safe-b)); }
}

/* ------------------------------------------------------------- 4. Structure */
.container {
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: clamp(16px, 3vw, 28px) clamp(12px, 3vw, 28px);
    padding-left: calc(clamp(12px, 3vw, 28px) + var(--safe-l));
    padding-right: calc(clamp(12px, 3vw, 28px) + var(--safe-r));
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    flex-wrap: wrap;
    margin-bottom: var(--s-5);
}

.page-title {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    font-size: clamp(1.35rem, 1.05rem + 1.6vw, 1.9rem);
    font-weight: 800;
    letter-spacing: -.03em;
}

.page-sub {
    color: var(--text-muted);
    font-size: .92rem;
    margin-top: 2px;
    font-weight: 500;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}

.card-pad { padding: clamp(14px, 2.4vw, 22px); }

/* --------------------------------------------------------------- 5. Boutons */
.button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: var(--accent-contrast);
    font-family: inherit;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: background var(--transition), border-color var(--transition),
                box-shadow var(--transition), transform var(--transition), color var(--transition);
}

.button:hover,
.btn:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }
.button:active,
.btn:active { transform: translateY(1px); }
.button:disabled,
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Variantes */
.button.secondary,
.btn.secondary,
.button.ghost,
.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}
.button.secondary:hover,
.btn.secondary:hover,
.button.ghost:hover,
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.button.subtle {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: transparent;
    box-shadow: none;
}
.button.subtle:hover { background: var(--accent-soft-2); }

.button.primary, .btn-primary { background: var(--accent); color: var(--accent-contrast); }
.button.primary:hover, .btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.button.success, .btn-success { background: var(--success); color: #fff; }
.button.success:hover, .btn-success:hover { filter: brightness(1.07); background: var(--success); }

.button.warning, .btn-warning { background: var(--warning); color: #fff; }
.button.warning:hover, .btn-warning:hover { filter: brightness(1.07); background: var(--warning); }

.button.danger, .btn-danger { background: var(--danger); color: #fff; }
.button.danger:hover, .btn-danger:hover { filter: brightness(1.07); background: var(--danger); }

.button.info, .btn-info { background: var(--info); color: #fff; }
.button.info:hover, .btn-info:hover { filter: brightness(1.07); background: var(--info); }

.button.block, .btn.block { width: 100%; }
.button.sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }

.button-group {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
}

/* Bouton d'action flottant (mobile) */
.fab {
    position: fixed;
    right: calc(16px + var(--safe-r));
    bottom: calc(16px + var(--safe-b));
    z-index: 940;
    display: none;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: var(--r-full);
    background: linear-gradient(140deg, var(--brand-500), var(--brand-700));
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition);
}
.fab:active { transform: scale(.92); }

@media (max-width: 860px) {
    .fab { display: flex; bottom: calc(80px + var(--safe-b)); }
}

/* ------------------------------------------------------ 6. Barre d'outils */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
    margin-bottom: var(--s-4);
}

/* Menu déroulant (impression agenda) */
.dropdown { position: relative; display: inline-block; }

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 270px;
    z-index: 1000;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.dropdown-content a {
    display: block;
    padding: 11px 14px;
    border-radius: var(--r-xs);
    color: var(--text);
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.dropdown-content a:hover { background: var(--accent-soft); color: var(--accent); }

.dropdown.open .dropdown-content { display: block; }

@media (hover: hover) and (pointer: fine) {
    .dropdown:hover .dropdown-content { display: block; }
}

.dropdown > .button::after { content: "▾"; font-size: .85em; opacity: .8; }

@media (max-width: 860px) {
    .dropdown { width: 100%; }
    .dropdown > .button { width: 100%; }
    .dropdown-content { left: 0; right: 0; min-width: 0; }
}

/* -------------------------------------------------------- 7. Statistiques */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}

.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card h3 {
    font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.stat-card p {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card.warning::before { background: var(--warning); }
.stat-card.warning h3 { color: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card.success h3 { color: var(--success); }
.stat-card.info::before { background: var(--info); }
.stat-card.info h3 { color: var(--info); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.danger h3 { color: var(--danger); }

/* ------------------------------------------------------------- 8. Filtres */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--s-3);
    padding: var(--s-4);
    margin-bottom: var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
}

.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.filter-group label {
    font-size: .74rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* --------------------------------------------------- 9. Champs de formulaire */
input, select, textarea, button { font-family: inherit; }

input[type="text"],
input[type="search"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="time"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 13px;
    font-size: 16px; /* évite le zoom automatique sur iOS */
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

input::placeholder, textarea::placeholder { color: var(--text-subtle); }

input:hover, select:hover, textarea:hover { border-color: var(--text-subtle); }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

select {
    padding-right: 38px;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 19px) calc(50% + 2px), calc(100% - 13px) calc(50% + 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    cursor: pointer;
}

input[type="color"] {
    width: 100%;
    min-height: var(--tap);
    height: var(--tap);
    padding: 4px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

.form-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.form-group > label,
form > label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-row,
.color-priority-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--s-3);
}

.field-hint { font-size: .8rem; color: var(--text-subtle); }

/* Sélecteur de type / catégorie (agenda, mémos, tâches) */
.category-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: var(--s-2);
}

.category-btn {
    min-height: var(--tap);
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.category-btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }

.category-btn[data-category="76"].active {
    background: var(--cat-76);
    border-color: var(--cat-76);
    color: #fff;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--cat-76) 40%, transparent);
}
.category-btn[data-category="association"].active {
    background: var(--cat-association);
    border-color: var(--cat-association);
    color: #fff;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--cat-association) 40%, transparent);
}
.category-btn[data-category="personnel"].active {
    background: var(--cat-personnel);
    border-color: var(--cat-personnel);
    color: #fff;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--cat-personnel) 40%, transparent);
}

/* ---------------------------------------------- 10. Sélecteur segmenté */
.view-toggle {
    display: inline-flex;
    gap: 3px;
    padding: 4px;
    margin-bottom: var(--s-4);
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.view-toggle button {
    flex: 1;
    min-height: 38px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-xs);
}

@media (max-width: 600px) {
    .view-toggle { display: flex; width: 100%; }
}

/* --------------------------------------------------------------- 11. Badges */
.badge,
.memo-badge,
.todo-badge,
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: .74rem;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: .01em;
    text-transform: capitalize;
    background: var(--surface-3);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge-category { background: var(--accent-soft); color: var(--accent); }
.badge-priority-haute   { background: var(--danger-soft);  color: var(--danger); }
.badge-priority-moyenne { background: var(--warning-soft); color: var(--warning); }
.badge-priority-basse   { background: var(--success-soft); color: var(--success); }
.badge-status-todo       { background: var(--surface-3); color: var(--text-muted); }
.badge-status-inprogress { background: var(--info-soft); color: var(--info); }
.badge-status-done       { background: var(--success-soft); color: var(--success); }

.category-badge { padding: 5px 14px; font-size: .8rem; color: #fff; }
.category-badge.color-76 { background: var(--cat-76); }
.category-badge.color-association { background: var(--cat-association); }
.category-badge.color-personnel { background: var(--cat-personnel); }
.category-badge.color-default { background: var(--cat-default); }

.memo-badge.color-76,          .todo-badge.color-76          { background: var(--cat-76); color: #fff; }
.memo-badge.color-association, .todo-badge.color-association { background: var(--cat-association); color: #fff; }
.memo-badge.color-personnel,   .todo-badge.color-personnel   { background: var(--cat-personnel); color: #fff; }
.memo-badge.color-default,     .todo-badge.color-default     { background: var(--cat-default); color: #fff; }

/* Légende */
.legend {
    display: flex;
    gap: var(--s-4);
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: .83rem;
    font-weight: 600;
    color: var(--text-muted);
}

.legend-item { display: inline-flex; align-items: center; gap: 7px; }

.legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    display: inline-block;
    flex: 0 0 11px;
}
.legend-dot.color-76 { background: var(--cat-76); }
.legend-dot.color-association { background: var(--cat-association); }
.legend-dot.color-personnel { background: var(--cat-personnel); }
.legend-dot.color-default { background: var(--cat-default); }

/* ------------------------------------------------ 12. Modales / feuilles */
.modal,
.print-preview-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(9, 12, 24, .55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--s-4);
}

.print-preview-modal { z-index: 1300; }

.modal-content,
.print-preview-content {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: min(6vh, 60px) auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: modal-in 220ms cubic-bezier(.16, 1, .3, 1);
}

.print-preview-content { max-width: 900px; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(18px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.modal-header,
.print-preview-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 16px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.modal-header h2,
.print-preview-header h2 {
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.close {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: none;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition);
}
.close:hover { background: var(--danger-soft); color: var(--danger); }

.modal-body,
.print-preview-body {
    padding: 18px;
    max-height: calc(85vh - 70px);
    overflow-y: auto;
}

.print-preview-footer {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: var(--s-2);
    justify-content: flex-end;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.modal form { display: flex; flex-direction: column; gap: var(--s-4); }

.button-group-modal {
    display: flex;
    gap: var(--s-2);
    flex-wrap: wrap;
    padding-top: var(--s-2);
    margin-top: var(--s-1);
    border-top: 1px solid var(--border);
}

.button-group-modal button,
.button-group-modal .button {
    flex: 1 1 150px;
    min-height: var(--tap);
    padding: 11px 16px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface-3);
    color: var(--text);
}
.button-group-modal button:hover { filter: brightness(.97); }

.btn-save,
.button-group-modal button[type="submit"] { background: var(--accent) !important; color: var(--accent-contrast) !important; }
.btn-delete,
.delete-btn { background: var(--danger) !important; color: #fff !important; }
.btn-archive { background: var(--warning) !important; color: #fff !important; }
.btn-complete { background: var(--success) !important; color: #fff !important; }
.button-group-modal .btn-info { background: var(--info) !important; color: #fff !important; }
.button-group-modal .btn-ghost {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* Champ en lecture seule dans les modales */
.readonly-field {
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: .95rem;
    word-break: break-word;
}
.readonly-field.title { font-size: 1.05rem; font-weight: 700; }
.readonly-field.pre { white-space: pre-wrap; }

.field-label {
    display: block;
    margin-bottom: 7px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Modale plein écran / feuille glissante sur mobile */
@media (max-width: 640px) {
    .modal,
    .print-preview-modal { padding: 0; align-items: flex-end; }

    .modal-content,
    .print-preview-content {
        max-width: none;
        margin: 0;
        min-height: 100%;
        border: none;
        border-radius: 0;
        animation: sheet-in 260ms cubic-bezier(.16, 1, .3, 1);
    }

    .modal-header,
    .print-preview-header { padding-top: calc(14px + var(--safe-t)); }

    .modal-body,
    .print-preview-body {
        max-height: none;
        padding: 16px;
        padding-bottom: calc(28px + var(--safe-b));
    }

    .print-preview-footer { padding-bottom: calc(14px + var(--safe-b)); }

    .button-group-modal { flex-direction: column; }
    .button-group-modal button,
    .button-group-modal .button { width: 100%; flex: none; }

    @keyframes sheet-in {
        from { opacity: .6; transform: translateY(24px); }
        to   { opacity: 1; transform: none; }
    }
}

/* --------------------------------------------------------- 13. Listes */
.memo-list,
.todo-list { display: none; flex-direction: column; gap: var(--s-3); }
.memo-list.active,
.todo-list.active { display: flex; }

.memo-item,
.todo-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: 15px 17px 15px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.memo-item::before,
.todo-item::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--memo-color, var(--accent));
}

.memo-item:hover,
.todo-item:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

/* « C'est fait » en bout de ligne (mémos et tâches) */
.item-done-btn {
    flex: 0 0 auto;
    align-self: center;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--success);
    border-radius: var(--r-sm);
    background: var(--success-soft);
    color: var(--success);
    font: inherit;
    font-size: .85rem;
    font-weight: 640;
    white-space: nowrap;
    cursor: pointer;
}
.item-done-btn:hover { background: var(--success); color: #fff; }

/* Relance personnalisée : champ + bouton (ou unité) sur une ligne */
.remind-row { display: flex; gap: var(--s-2); align-items: stretch; }
.remind-row input { flex: 1; min-width: 0; }
.remind-row select,
.remind-row .button { flex: 0 0 auto; width: auto; }

/* Le liseré gauche porte la couleur du type ; seul « en retard » le
   reprend, car c'est une alerte. Priorité et statut restent lisibles via
   leurs pastilles, l'icône ⚠️ et le fond teinté. */
.todo-item.overdue::before { background: var(--danger); }
.todo-item.overdue { background: var(--danger-soft); }
.todo-item.overdue { background: color-mix(in srgb, var(--danger-soft) 45%, var(--surface)); }
.todo-item.completed { opacity: .62; }
.todo-item.completed .todo-title { text-decoration: line-through; color: var(--text-subtle); }

.memo-content-wrap,
.todo-content { flex: 1; min-width: 0; }

.memo-title,
.todo-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -.01em;
    word-break: break-word;
}

.memo-text {
    font-size: .9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 9px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.memo-meta,
.todo-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-subtle);
}

.todo-checkbox {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* État vide */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 46px 20px;
    text-align: center;
    color: var(--text-subtle);
}
.empty-state .emoji { font-size: 2.4rem; line-height: 1; margin-bottom: 4px; }
.empty-state strong { color: var(--text-muted); font-size: 1rem; }
.empty-state span { font-size: .88rem; }

/* --------------------------------------------------- 14. FullCalendar */
#calendar {
    --fc-border-color: var(--border);
    --fc-page-bg-color: var(--surface);
    --fc-neutral-bg-color: var(--surface-2);
    --fc-neutral-text-color: var(--text-muted);
    --fc-today-bg-color: var(--accent-soft);
    --fc-list-event-hover-bg-color: var(--surface-hover);
    --fc-highlight-color: var(--accent-soft-2);
    --fc-event-bg-color: var(--accent);
    --fc-event-border-color: var(--accent);
    --fc-event-text-color: #fff;
    --fc-more-link-bg-color: var(--surface-3);
    --fc-more-link-text-color: var(--text-muted);
    --fc-button-text-color: var(--text);
    --fc-button-bg-color: var(--surface);
    --fc-button-border-color: var(--border-strong);
    --fc-button-hover-bg-color: var(--surface-hover);
    --fc-button-hover-border-color: var(--text-subtle);
    --fc-button-active-bg-color: var(--accent);
    --fc-button-active-border-color: var(--accent);

    padding: clamp(10px, 1.6vw, 18px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fc { font-family: inherit; font-size: .92rem; }

.fc .fc-toolbar.fc-header-toolbar {
    gap: var(--s-2);
    flex-wrap: wrap;
    margin-bottom: var(--s-4);
}

.fc .fc-toolbar-title {
    font-size: clamp(1rem, .9rem + .7vw, 1.3rem) !important;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
    text-transform: capitalize;
}

.fc .fc-button {
    min-height: 38px;
    padding: 7px 13px !important;
    border-radius: var(--r-sm) !important;
    font-size: .85rem !important;
    font-weight: 600 !important;
    text-transform: capitalize;
    box-shadow: none !important;
    transition: all var(--transition);
}
.fc .fc-button:focus { box-shadow: var(--ring) !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { color: #fff !important; }
.fc .fc-button .fc-icon { font-size: 1.15em; vertical-align: middle; }

.fc .fc-button-group > .fc-button { border-radius: 0 !important; }
.fc .fc-button-group > .fc-button:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm) !important; }
.fc .fc-button-group > .fc-button:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0 !important; }

.fc .fc-col-header-cell-cushion {
    padding: 10px 4px;
    font-size: .74rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.fc .fc-daygrid-day-number {
    padding: 7px 9px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.fc .fc-day-today .fc-daygrid-day-number { color: var(--accent); font-weight: 800; }

.fc .fc-daygrid-day-frame { min-height: 66px; }

.fc .fc-daygrid-day.fc-day-sat .fc-daygrid-day-frame,
.fc .fc-daygrid-day.fc-day-sun .fc-daygrid-day-frame { background: var(--surface-2); }

.fc .fc-event,
.fc .fc-daygrid-event {
    padding: 3px 7px !important;
    margin: 2px 1px !important;
    border-radius: var(--r-xs) !important;
    border: none !important;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
    transition: filter var(--transition), transform var(--transition);
}
.fc .fc-event:hover { filter: brightness(1.08); }

.fc .fc-event-title,
.fc .fc-event-time {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.fc .fc-daygrid-event-dot { display: none !important; }
.fc .fc-event-main { color: #fff !important; }

.fc .fc-daygrid-more-link {
    padding: 2px 6px;
    border-radius: var(--r-xs);
    font-size: .76rem;
    font-weight: 700;
    color: var(--accent);
}

.fc .fc-popover {
    border: 1px solid var(--border) !important;
    border-radius: var(--r-md) !important;
    box-shadow: var(--shadow-lg) !important;
    background: var(--surface) !important;
    overflow: hidden;
}
.fc .fc-popover-header {
    padding: 10px 12px !important;
    background: var(--surface-2) !important;
    color: var(--text) !important;
    font-weight: 700;
    font-size: .88rem;
}

.fc .fc-list {
    border-radius: var(--r-md);
    overflow: hidden;
    border-color: var(--border) !important;
}
.fc .fc-list-day-cushion {
    padding: 11px 14px !important;
    background: var(--surface-2) !important;
    font-weight: 700;
    font-size: .86rem;
    color: var(--text);
}
.fc .fc-list-event { cursor: pointer; }
.fc .fc-list-event td { padding: 12px 14px !important; }
.fc .fc-list-event-time { font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.fc .fc-list-event-title { font-weight: 600; color: var(--text); }
.fc .fc-list-event:hover td { background: var(--surface-hover) !important; }
.fc .fc-list-empty { background: var(--surface-2); color: var(--text-subtle); font-weight: 600; }

.fc .fc-timegrid-slot-label-cushion,
.fc .fc-timegrid-axis-cushion { font-size: .76rem; color: var(--text-subtle); font-weight: 600; }

.fc .fc-scrollgrid { border-color: var(--border) !important; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border) !important; }

/* FullCalendar sur mobile */
@media (max-width: 768px) {
    .fc .fc-toolbar.fc-header-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .fc .fc-toolbar-chunk { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
    .fc .fc-toolbar-chunk .fc-button-group { flex-wrap: wrap; justify-content: center; }
    .fc .fc-toolbar-chunk .fc-button-group > .fc-button {
        border-radius: var(--r-sm) !important;
        margin: 2px;
    }
    .fc .fc-daygrid-day-frame { min-height: 54px; }
    .fc .fc-daygrid-day-number { padding: 5px 6px; font-size: .8rem; }
    .fc .fc-event { font-size: .72rem; }
    .fc .fc-col-header-cell-cushion { padding: 8px 2px; font-size: .66rem; letter-spacing: .03em; }
    .fc .fc-list-event td { padding: 11px 10px !important; }
}

@media (max-width: 420px) {
    .fc .fc-daygrid-day-frame { min-height: 46px; }
    .fc .fc-event { padding: 2px 4px !important; font-size: .66rem; }
}

/* --------------------------------------------------------- 15. Utilitaires */
.muted { color: var(--text-subtle); font-size: .88rem; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Notifications légères */
.toast-host {
    position: fixed;
    left: 50%;
    bottom: calc(24px + var(--safe-b));
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
    width: min(420px, calc(100vw - 32px));
}

.toast {
    width: 100%;
    padding: 12px 16px;
    background: var(--slate-900);
    color: #fff;
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    font-size: .9rem;
    font-weight: 600;
    animation: toast-in 220ms cubic-bezier(.16, 1, .3, 1);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
    .toast-host { bottom: calc(88px + var(--safe-b)); }
}

/* ------------------------------------------------------------ 16. Impression */
@media print {
    .appbar,
    .mobile-dock,
    .fab,
    .toolbar,
    .button-group,
    .filters,
    .view-toggle,
    .legend,
    .toast-host { display: none !important; }

    body {
        background: #fff !important;
        color: #000;
        padding: 0;
    }

    .container { max-width: 100%; padding: 0; }

    .card,
    .memo-item,
    .todo-item,
    #calendar {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        break-inside: avoid;
    }
}

/* Réservation de place pendant le montage de la barre (évite un saut visuel) */
#appbar-root {
    display: block;
    min-height: calc(var(--appbar-h) + var(--safe-t));
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

@media (max-width: 560px) {
    .appbar-brand .brand-text {
        max-width: 44vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: .95rem;
    }
}
