/* Charte Saint-Joseph de Tivoli — alignée https://tivoli-33.org/ */

/* Typographie fluide : base 14px (≤320px) → 16px (≥750px), tous les rem scalent proportionnellement */
html {
    font-size: clamp(14px, calc(12.5px + 0.4vw), 16px);
}

:root {
    --tivoli-blue: #1e3a5f;
    --tivoli-blue-dark: #152a45;
    --tivoli-blue-light: #2a5080;
    --tivoli-gold: #c9a962;
    --tivoli-gold-dark: #a88b4a;
    --tivoli-logo-gold: #c8b880;
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #5c6b7a;
    --primary: var(--tivoli-blue);
    --primary-hover: var(--tivoli-blue-dark);
    --accent: var(--tivoli-gold);
    --danger: #b42318;
    --border: #dde4ec;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(30, 58, 95, 0.08);
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-heading: "Playfair Display", Georgia, "Times New Roman", serif;
    --header-h: 68px;
    --page-gutter: clamp(0.75rem, 3vw, 1.25rem);
    --cal-weekend-bg: #eef0f3;
    --cal-holiday-bg: #eef0f3;
    --cal-vacation-bg: #d4dae3;
    font-family: var(--font-body);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

body:not(.login-page) {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body:not(.login-page) > main {
    flex: 1 0 auto;
}

[hidden] { display: none !important; }

/* ——— Logo ——— */
.tivoli-logo {
    display: block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.header-logo {
    max-height: 52px;
    width: auto;
}

.auth-logo {
    max-height: 120px;
    margin-bottom: 1.25rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));
}

/* ——— Pages connexion ——— */
.login-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: 100svh;
    overflow-x: clip;
    background:
        radial-gradient(ellipse 80% 60% at 15% 20%, rgba(201, 169, 98, 0.14), transparent 55%),
        radial-gradient(ellipse 70% 50% at 85% 80%, rgba(42, 80, 128, 0.35), transparent 50%),
        linear-gradient(145deg, var(--tivoli-blue-dark) 0%, var(--tivoli-blue) 48%, #243d5c 100%);
}

.auth-layout {
    flex: 1 0 auto;
    min-height: 0;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
}

.auth-brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: clamp(2rem, 5vw, 3.5rem);
    text-align: center;
    color: #fff;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.auth-brand-panel__glow {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.12) 100%),
        repeating-linear-gradient(
            -12deg,
            transparent,
            transparent 48px,
            rgba(255, 255, 255, 0.02) 48px,
            rgba(255, 255, 255, 0.02) 49px
        );
    pointer-events: none;
}

.auth-brand-panel::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--tivoli-gold) 20%, var(--tivoli-gold) 80%, transparent);
}

.auth-brand-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 22rem;
}

.auth-establishment {
    margin: 0;
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.auth-school-name {
    margin: 0.4rem 0 0;
    font-size: clamp(1.2rem, 3.5vw, 1.45rem);
    font-weight: 700;
    line-height: 1.2;
    font-family: var(--font-heading);
}

.auth-brand-title {
    margin-top: 1.75rem;
}

.auth-brand-title .brand-title {
    align-items: center;
}

.auth-brand-title .brand-title__word {
    font-size: clamp(2rem, 6vw, 2.85rem);
}

.auth-product-line {
    margin: 1rem 0 0;
    font-size: 0.9rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.82);
    max-width: 16rem;
}

.auth-location {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

.auth-portal-link {
    margin: 2rem 0 0;
    font-size: 0.88rem;
}

.auth-portal-link a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(200, 184, 128, 0.45);
    color: var(--tivoli-logo-gold);
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.auth-portal-link a:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--tivoli-logo-gold);
}

.login-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 3rem);
    background: var(--bg);
}

.login-card__panel {
    width: 100%;
    max-width: 26rem;
    background: var(--card);
    border-radius: calc(var(--radius) + 4px);
    border: 1px solid var(--border);
    box-shadow:
        0 1px 2px rgba(30, 58, 95, 0.04),
        0 12px 40px rgba(30, 58, 95, 0.1);
    overflow: hidden;
}

.login-card__panel::before {
    content: "";
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--tivoli-blue), var(--tivoli-gold) 55%, var(--tivoli-blue-light));
}

.login-card__brand-mobile {
    display: none;
    padding: 1.25rem 1.5rem 0;
    justify-content: center;
}

.login-card__header {
    padding: 1.75rem 1.75rem 0;
}

.login-card__title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 4vw, 1.75rem);
    font-weight: 700;
    color: var(--tivoli-blue);
    line-height: 1.2;
}

.login-card__subtitle {
    margin: 0.5rem 0 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--muted);
    overflow-wrap: break-word;
}

.login-card__body {
    padding: 1.25rem 1.75rem 1.75rem;
}

.login-card__body .error,
.login-card__body .info {
    margin: 0 0 1rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.88rem;
}

.login-card__body .error {
    background: rgba(180, 35, 24, 0.08);
    border: 1px solid rgba(180, 35, 24, 0.2);
}

.login-card__body .info {
    background: rgba(30, 58, 95, 0.06);
    border: 1px solid rgba(30, 58, 95, 0.12);
}

.brand-title--light .brand-title {
    align-items: center;
}

.brand-title--light .brand-title__pilo {
    color: var(--tivoli-blue-light);
}

.brand-title--light .brand-title__tiv,
.brand-title--light .brand-title__mark {
    color: var(--tivoli-gold-dark);
    text-shadow: none;
}

.brand-title--light .brand-title__env {
    color: var(--muted);
}

.auth-form label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--tivoli-blue);
    margin-bottom: 1rem;
}

.auth-form label input {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.72rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: var(--bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-form label input:focus {
    outline: none;
    border-color: var(--tivoli-blue-light);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
    background: var(--card);
}

.auth-form .btn-primary,
.auth-form .btn-secondary {
    width: 100%;
    box-sizing: border-box;
    margin-top: 0.25rem;
    padding: 0.8rem 1.25rem;
    font-size: 1rem;
    border-radius: 10px;
}

.login-card__body .hint {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.login-card__body .hint code {
    word-break: break-all;
}

/* Aide placée APRÈS un formulaire : la marge négative de .hint, prévue pour
   coller une aide sous son champ, la ferait toucher le bouton de validation. */
.login-card__body .hint--after-form {
    margin-top: 0.9rem;
    text-align: center;
}

/* Étape d'activation d'un compte SyRes importé : la carte n'affiche que ça, donc
   les trois étapes portent l'explication et le bouton reste l'unique action. */
.login-activation__steps {
    margin: 0 0 1.35rem;
    padding-left: 1.2rem;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--muted);
}

.login-activation__steps li {
    margin-bottom: 0.5rem;
}

.login-activation__steps strong {
    color: var(--text);
}

.login-activation__back {
    margin: 1.1rem 0 0;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.86rem;
}

.login-card__body .login-links {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Action principale : consultation du calendrier en lecture seule */
.login-consult {
    margin-bottom: 1.5rem;
}

.login-consult__btn {
    width: 100%;
    box-sizing: border-box;
    gap: 0.55rem;
    padding: 0.95rem 1.25rem;
    font-size: 1rem;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(201, 169, 98, 0.28);
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.login-consult__btn:hover {
    box-shadow: 0 8px 22px rgba(201, 169, 98, 0.36);
    transform: translateY(-1px);
}

.login-consult__icon {
    width: 1.2rem;
    height: 1.2rem;
    flex-shrink: 0;
}

.login-consult__hint {
    margin: 0.7rem 0 0;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
}

/* Connexion réservée : présentation discrète quand la consultation est ouverte */
.login-signin--muted {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.login-signin__text {
    margin: 0 0 1.15rem;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
}

/* Repli : le formulaire réservé n'apparaît que sur demande (élément <details>) */
.login-signin--fold {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
}

.login-signin__summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
    transition: color 0.15s ease, background 0.15s ease;
}

/* Masquer le triangle natif (Safari/anciens WebKit + moteurs standards) */
.login-signin__summary::-webkit-details-marker { display: none; }
.login-signin__summary::marker { content: ""; }

.login-signin__summary:hover {
    color: var(--tivoli-blue);
    background: var(--bg);
}

.login-signin__summary:focus-visible {
    outline: 2px solid var(--tivoli-blue-light);
    outline-offset: 2px;
}

.login-signin__chevron {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.login-signin--fold[open] .login-signin__chevron {
    transform: rotate(180deg);
}

.login-signin--fold .login-signin__panel {
    padding-top: 1.1rem;
}

.login-signin--muted .auth-form label {
    color: var(--muted);
    font-size: 0.84rem;
}

.login-signin--muted .auth-form .btn-secondary {
    border-width: 1px;
    border-color: var(--border);
    background: transparent;
    color: var(--tivoli-blue);
}

.login-signin--muted .auth-form .btn-secondary:hover {
    border-color: var(--tivoli-blue);
    background: var(--bg);
}

/* Auth — tablette et mobile */
@media (max-width: 1024px) {
    .login-page .auth-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        min-height: 100dvh;
        min-height: 100svh;
    }

    .login-page .auth-brand-panel {
        flex-shrink: 0;
        padding:
            max(1.25rem, env(safe-area-inset-top, 0px))
            max(var(--page-gutter), env(safe-area-inset-right, 0px))
            1.25rem
            max(var(--page-gutter), env(safe-area-inset-left, 0px));
        border-right: none;
    }

    .login-page .auth-brand-panel::after {
        display: none;
    }

    .login-page .auth-brand-inner {
        max-width: 100%;
    }

    .login-page .auth-logo {
        max-height: clamp(64px, 18vw, 96px);
        margin-bottom: 0.75rem;
    }

    .login-page .auth-brand-title {
        display: none;
    }

    .login-page .auth-product-line,
    .login-page .auth-location {
        display: none;
    }

    .login-page .auth-portal-link {
        margin-top: 1rem;
    }

    .login-page .auth-portal-link a {
        max-width: 100%;
        justify-content: center;
        text-align: center;
    }

    .login-page .login-card {
        flex: 1 0 auto;
        align-items: stretch;
        justify-content: flex-start;
        min-height: 0;
        padding:
            1rem
            max(var(--page-gutter), env(safe-area-inset-right, 0px))
            max(1.5rem, env(safe-area-inset-bottom, 0px))
            max(var(--page-gutter), env(safe-area-inset-left, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .login-page .login-card__panel {
        max-width: 28rem;
        margin-inline: auto;
        width: 100%;
    }

    .login-page .login-card__brand-mobile {
        display: flex;
    }

    .login-page .login-card__brand-mobile .brand-title__word {
        font-size: clamp(1.35rem, 7vw, 1.75rem);
    }

    .login-page .login-card__header {
        padding: clamp(1.15rem, 4vw, 1.5rem) clamp(1.15rem, 4vw, 1.5rem) 0;
    }

    .login-page .login-card__body {
        padding: clamp(1rem, 3vw, 1.25rem) clamp(1.15rem, 4vw, 1.5rem) clamp(1.25rem, 4vw, 1.5rem);
    }

    .login-page .auth-form label input {
        font-size: 16px; /* évite le zoom iOS sur focus */
        min-height: 2.75rem;
    }

    .login-page .auth-form .btn-primary,
    .login-page .auth-form .btn-secondary {
        min-height: 2.85rem;
    }

    .login-page .login-consult__btn {
        min-height: 3rem;
    }
}

@media (max-width: 480px) {
    .login-page .auth-establishment {
        letter-spacing: 0.14em;
        font-size: 0.62rem;
    }

    .login-page .auth-school-name {
        font-size: 1.1rem;
    }

    .login-page .login-card__title {
        font-size: 1.35rem;
    }

    .login-page .login-card__subtitle {
        font-size: 0.88rem;
    }

    .login-page .login-card__panel {
        border-radius: var(--radius);
    }

    .login-page .auth-portal-link a {
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 1024px) and (max-height: 32rem) and (orientation: landscape) {
    .login-page .auth-layout {
        grid-template-rows: auto 1fr;
    }

    .login-page .auth-brand-panel {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .login-page .auth-logo {
        max-height: 52px;
        margin-bottom: 0.35rem;
    }

    .login-page .auth-school-name {
        font-size: 1rem;
    }

    .login-page .auth-portal-link {
        margin-top: 0.65rem;
    }

    .login-page .login-card {
        padding-top: 0.65rem;
        padding-bottom: 0.75rem;
    }

    .login-page .login-card__brand-mobile {
        padding-top: 0.85rem;
    }

    .login-page .login-card__header {
        padding-top: 0.85rem;
    }
}

.login-card h1,
.accounts-form h2,
.accounts-list h2,
#event-form h2,
.sidebar-title {
    font-family: var(--font-heading);
}

.subtitle { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.92rem; }
.error { color: var(--danger); margin-bottom: 1rem; }
.info { color: var(--tivoli-blue-light); margin-bottom: 1rem; font-size: 0.9rem; }
.success { color: #166534; margin-bottom: 1rem; }
.login-links { margin-top: 1.25rem; text-align: center; font-size: 0.9rem; }
.login-links a { color: var(--tivoli-blue); font-weight: 600; }
.hint { font-size: 0.82rem; color: var(--muted); margin: -0.5rem 0 1rem; }
.hint code { font-size: 0.85em; background: var(--bg); padding: 0.1em 0.35em; border-radius: 4px; }

/* ——— En-tête application ——— */
.app-header {
    background: linear-gradient(180deg, var(--tivoli-blue-dark) 0%, var(--tivoli-blue) 100%);
    color: #fff;
    padding: 0.65rem var(--page-gutter);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
    border-bottom: 4px solid var(--tivoli-gold);
    box-shadow: 0 2px 12px rgba(30, 58, 95, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ——— Commandes d'affichage : plier la bannière / plein écran ———
   Sur index.php / voir.php, ce sont deux boutons de la barre du calendrier
   (#btn-banner et #btn-fullscreen, cf. app.js). Ailleurs — journal, comptes… —
   il n'y a pas de barre : nav.js pose le même duo dans un groupe flottant ancré
   sous la bannière collante via --header-h, décalé à droite pour ne rien
   recouvrir au centre. Le groupe est enfant du <body> et non de l'en-tête, sans
   quoi `.app-header.is-collapsed > *` le masquerait — bannière repliée, plus
   aucun moyen de la déplier. */
.page-actions {
    position: fixed;
    right: clamp(1rem, 5vw, 3.5rem);
    top: calc(var(--header-h, 0px) + 0.45rem);
    display: flex;
    gap: 0.35rem;
    /* Sous l'en-tête (z-index 100) : le menu déroulant mobile passe devant. */
    z-index: 90;
}

.page-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: var(--tivoli-blue);
    color: var(--tivoli-gold);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(30, 58, 95, 0.3);
    transition: background 0.15s ease;
}

.page-action-btn:hover {
    background: var(--tivoli-blue-dark);
}

.page-action-btn:focus-visible {
    outline: 2px solid var(--tivoli-gold);
    outline-offset: 2px;
}

.page-action-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

.app-header.is-collapsed {
    padding-top: 0;
    padding-bottom: 0;
    gap: 0;
}

.app-header.is-collapsed > * {
    display: none;
}

/* Mode incorporation (iframe créaTiv') : en-tête/pied masqués, calendrier seul. */
body.embed { background: #fff; }
body.embed .calendar-wrap { padding-top: clamp(0.5rem, 1.5vw, 0.9rem); }

/* --header-h vaut 68px par défaut et nav.js ne le corrige qu'en MESURANT
   .app-header — absent ici. Les hauteurs calculées (calc(100dvh - var(--header-h)
   - …)) retranchaient donc 68px pour une bannière qui n'est pas peinte : autant
   de perdu pour le calendrier, et c'est énorme dans une iframe basse (téléphone
   couché). Même raisonnement pour le pied de page. */
body.embed { --header-h: 0px; --footer-h: 0px; }

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    line-height: 1.15;
    min-width: 0;
}

.brand-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.12rem;
}

.brand-title__word {
    display: inline-flex;
    align-items: baseline;
    font-size: clamp(1.2rem, 2.6vw, 1.55rem);
    letter-spacing: -0.02em;
    line-height: 1;
    white-space: nowrap;
}

.brand-title__pilo {
    font-family: var(--font-body);
    font-weight: 300;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.72em;
    margin-right: 0.08em;
    padding-bottom: 0.06em;
}

.brand-title__tiv {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--tivoli-logo-gold);
    letter-spacing: -0.03em;
    text-shadow: 0 1px 10px rgba(200, 184, 128, 0.35);
}

.brand-title__mark {
    font-family: var(--font-heading);
    font-weight: 400;
    font-style: italic;
    color: var(--tivoli-logo-gold);
    font-size: 0.92em;
    margin-left: -0.04em;
}

.brand-title__env {
    font-family: var(--font-body);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.brand-title:not(:has(.brand-title__word)) {
    font-size: clamp(0.88rem, 3vw, 1.05rem);
    font-weight: 700;
    font-family: var(--font-heading);
}

.brand-user {
    font-size: 0.82rem;
    opacity: 0.88;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
}

.level-filters-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.level-toggle-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.level-toggle-bar--dialog {
    margin-bottom: 0.5rem;
}

.level-toggle-sep {
    color: var(--muted);
}

.btn-filter-toggle {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--tivoli-blue-dark);
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-filter-toggle:hover {
    background: var(--tivoli-gold);
    color: var(--tivoli-blue-dark);
    border-color: var(--tivoli-gold-dark);
}

.btn-link {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tivoli-blue);
    cursor: pointer;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--tivoli-blue-dark);
}

.level-filters {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
    align-items: flex-start;
}

.level-chip,
.event-levels .event-level-chip {
    --chip-color: #e2e8f0;
    display: inline-flex;
    margin-top: auto;
    margin-bottom: auto;
    align-items: center;
    overflow: hidden;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 2px solid var(--tivoli-blue);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    background: var(--chip-color);
    color: var(--tivoli-blue-dark);
    box-shadow: 0 1px 2px rgba(30, 58, 95, 0.1);
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    max-width: 100%;
}

.level-chip-label,
.event-levels .event-level-chip span {
    color: inherit;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.level-chip input,
.event-levels .event-level-chip input {
    accent-color: var(--tivoli-blue);
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    margin: 0;
}

.level-chip.off,
.event-levels .event-level-chip.off {
    opacity: 1;
    box-shadow: none;
    font-weight: 500;
}

.level-chip.off .level-chip-label,
.event-levels .event-level-chip.off span {
    text-decoration: line-through;
    text-decoration-color: rgba(71, 85, 105, 0.55);
}

/* Catégorie parente « incluse » : une de ses sous-catégories est cochée, elle est donc
   implicite. Ni cochée ni vraiment éteinte — pas de texte barré, bordure pointillée. */
.event-levels .event-level-chip.is-implied {
    border-style: dashed;
    opacity: 0.75;
}

.event-levels .event-level-chip.is-implied span {
    text-decoration: none;
    font-style: italic;
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger {
    border: none;
    border-radius: 8px;
    padding: 0.55rem 0.95rem;
    min-height: 2.5rem;
    font: inherit;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--tivoli-gold);
    color: var(--tivoli-blue-dark);
}

.btn-primary:hover {
    background: var(--tivoli-gold-dark);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: var(--tivoli-blue);
    border: 2px solid var(--tivoli-blue);
}

.btn-secondary:hover {
    background: var(--bg);
}

.app-header .btn-primary {
    background: #fff;
    color: var(--tivoli-blue);
}

.app-header .btn-primary:hover {
    background: var(--tivoli-gold);
    color: var(--tivoli-blue-dark);
}

.btn-ghost {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--tivoli-gold);
}

/* Boutons de navigation à icône + libellé (Connexion, Connectiv') */
.toolbar .btn-ghost {
    gap: 0.45rem;
}

.btn-nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-ghost.btn-nav-active {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--tivoli-gold);
    font-weight: 700;
}

.btn-ghost.btn-nav-active:hover {
    background: rgba(255, 255, 255, 0.22);
}

.login-card .btn-ghost,
.accounts-page .btn-ghost {
    color: var(--tivoli-blue);
    border-color: var(--border);
    background: var(--card);
}

.login-card .btn-ghost:hover,
.accounts-page .btn-ghost:hover {
    background: var(--bg);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

/* ——— Calendrier ——— */
.calendar-wrap {
    --sidebar-dur: 0.48s;
    --sidebar-ease: cubic-bezier(0.33, 1, 0.68, 1);
    padding: var(--page-gutter);
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
    gap: clamp(0.75rem, 2vw, 1rem);
    align-items: start;
    width: 100%;
    transition:
        grid-template-columns var(--sidebar-dur) var(--sidebar-ease),
        gap var(--sidebar-dur) var(--sidebar-ease);
}

.calendar-sidebar {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem;
    border-top: 3px solid var(--tivoli-gold);
    position: sticky;
    top: calc(var(--header-h) + 0.75rem);
    min-width: 0;
    overflow: hidden;
    transition:
        background var(--sidebar-dur) var(--sidebar-ease),
        box-shadow var(--sidebar-dur) var(--sidebar-ease),
        border-color var(--sidebar-dur) var(--sidebar-ease),
        border-radius var(--sidebar-dur) var(--sidebar-ease),
        padding var(--sidebar-dur) var(--sidebar-ease);
}

.sidebar-title {
    margin: 0;
    color: var(--tivoli-blue);
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    max-width: 260px;
    transition:
        max-width var(--sidebar-dur) var(--sidebar-ease),
        opacity calc(var(--sidebar-dur) * 0.75) var(--sidebar-ease);
}

.calendar-main {
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ——— Plein écran ——— */
/* Bouton autonome inséré dans la toolbar FC, à côté d'« Année » (voir app.js :
   élément unique que nous possédons → pas de dédoublement par le moteur FC). */
.btn-fullscreen.fc-button,
.btn-banner.fc-button {
    margin-left: 0.4rem;
    padding-inline: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-fullscreen svg,
.btn-banner svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Le pied de page n'a pas d'utilité en plein écran. La bannière, elle, reste
   pilotée par son bouton (#btn-banner) : repliée à l'entrée, elle disparaît
   complètement — pas même le filet doré —, mais peut être rétablie sans sortir
   du plein écran, puisque c'est la page entière qui y passe (voir app.js). */
body.is-fullscreen .app-footer { display: none !important; }
body.is-fullscreen .app-header.is-collapsed { display: none !important; }

/* Page réellement passée en plein écran natif (l'UA la peindrait en noir) */
html:fullscreen {
    background: var(--bg);
    overflow: auto;
}

/* Repli CSS quand l'API plein écran est indisponible (iframe incorporée) :
   overlay couvrant la fenêtre. Il démarre sous la bannière (--header-h vaut 0
   quand elle est repliée) pour qu'elle reste visible si on la déplie. */
body.is-immersive .calendar-wrap {
    position: fixed;
    top: var(--header-h, 0px);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    max-width: none;
    margin: 0;
    height: auto;
    overflow: auto;
    background: var(--bg);
    padding: clamp(0.5rem, 1.5vw, 1rem);
}

#calendar {
    background: var(--card);
    border-radius: var(--radius);
    padding: 0.85rem;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--tivoli-gold);
    --fc-sticky-header-top: var(--header-h);
    min-width: 420px;
    width: 100%;
    box-sizing: border-box;
}

#calendar .fc {
    width: 100%;
    max-width: 100%;
}

/* ═══════════════ Barre de commandes au-dessus du calendrier ═══════════════
   Une seule mécanique pour TOUTES les vues (Mois / Semaine / Jour / Liste /
   Année). FullCalendar produit trois blocs anonymes ; app.js leur pose une
   classe stable (.fc-chunk-nav / -title / -views) et sort nos deux boutons
   dans .fc-toolbar-actions, enfant direct de la barre. La composition n'est
   plus alors qu'une affaire d'`order` flex :

     ≥ 1000px  ·  nav │ titre │ vues │ actions          (une ligne)
     600–999   ·  nav │ titre │ actions                 (deux lignes)
                  ─────── vues ───────
     < 600px   ·  nav │ actions                         (trois lignes)
                  ─────── titre ──────
                  ─────── vues ───────

   En vues Liste et Année, les blocs nav + titre sont masqués et la navigation
   propre à la vue (#year-nav-years / .list-grid-nav) occupe la place du bloc
   nav : la barre garde exactement la même silhouette. */
#calendar .fc-header-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.85rem;
    min-width: 0;
}

/* Aucun bloc ne doit imposer sa largeur intrinsèque à la barre. */
#calendar .fc-header-toolbar > * {
    min-width: 0;
}

/* FC espace ses enfants à la marge ; on passe au `gap` (compatible avec le
   retour à la ligne, contrairement aux marges). */
#calendar .fc-header-toolbar > * > :not(:first-child) {
    margin-left: 0;
}

#calendar .fc-chunk-nav {
    order: 1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
    flex: 0 0 auto;
}

#calendar .fc-chunk-title {
    order: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 8rem;
    overflow: hidden;
}

#calendar .fc-chunk-views {
    order: 3;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

#calendar .fc-toolbar-actions {
    order: 4;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
}

/* Navigations propres aux vues Liste / Année : elles prennent la place du
   bloc nav ET du titre (elles contiennent les deux). */
#calendar .fc-header-toolbar > .year-grid-nav-years,
#calendar .fc-header-toolbar > .list-grid-nav {
    order: 1;
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 0.4rem;
    min-width: 0;
    margin: 0;
}

#calendar .fc-header-toolbar .fc-toolbar-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* — Deux lignes : le sélecteur de vue passe seul en dessous — */
@media (max-width: 999px) {
    #calendar .fc-toolbar-actions { order: 3; }

    #calendar .fc-chunk-views {
        order: 4;
        flex: 1 0 100%;
        justify-content: center;
    }
}

/* — Trois lignes : nav + actions, puis titre, puis vues pleine largeur — */
@media (max-width: 599px) {
    #calendar .fc-header-toolbar {
        gap: 0.45rem 0.5rem;
    }

    #calendar .fc-chunk-nav { flex: 1 1 auto; }

    #calendar .fc-toolbar-actions {
        order: 2;
        margin-left: auto;
    }

    #calendar .fc-chunk-title {
        order: 3;
        flex: 1 0 100%;
    }

    #calendar .fc-header-toolbar > .year-grid-nav-years,
    #calendar .fc-header-toolbar > .list-grid-nav {
        flex: 1 1 12rem;
        justify-content: flex-start;
    }

    /* Les chevrons doivent rester collés à leur intitulé : c'est le couple
       « ‹ titre › » qui fait sens, pas chaque bouton isolé sur sa ligne. */
    #calendar .year-grid-nav-title,
    #calendar .list-grid-nav-title {
        min-width: 0;
    }

    /* « Année scolaire 2025–2026 » → « 2025–2026 » : le contexte est donné par
       le bouton « Liste » actif juste en dessous. */
    .nav-title-prefix {
        display: none;
    }
}

/* — Très petits écrans : on rogne les chevrons plutôt que la typographie —
   « Sep. 2026 – Août 2027 » doit rester lisible et sur une seule ligne. */
@media (max-width: 399px) {
    #calendar .year-grid-nav-years .btn-sm,
    #calendar .list-grid-nav .btn-sm {
        padding: 0.35rem 0.4rem;
    }

    #calendar .fc-toolbar-actions .fc-button {
        padding-inline: 0.4rem;
    }

    /* Sélecteur de vue pleine largeur, parts égales : cinq libellés courts
       tiennent sans rognage jusqu'à 320px de fenêtre. */
    #calendar .fc-chunk-views .fc-button-group {
        display: flex;
        width: 100%;
    }

    #calendar .fc-chunk-views .fc-button-group > .fc-button {
        flex: 1 1 0;
        min-width: 0;
        padding-inline: 0.2rem;
        font-size: 0.74rem;
    }
}

/* ——— Journal des modifications ——— */
.journal-page {
    padding: var(--page-gutter);
    max-width: 52rem;
    margin: 0 auto;
}

.journal-panel {
    margin-bottom: 2rem;
}

.journal-title {
    margin: 0 0 0.35rem;
    font-family: var(--font-heading);
    color: var(--tivoli-blue);
    font-size: clamp(1.25rem, 4vw, 1.6rem);
}

.journal-intro {
    margin: 0 0 1.25rem;
    max-width: 42rem;
}

.journal-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.journal-filter-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.journal-select {
    min-width: 12rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: var(--card);
}

.journal-filter-label--search {
    flex: 1 1 14rem;
    min-width: min(100%, 14rem);
}

.journal-search {
    width: 100%;
    min-width: 12rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: var(--card);
}

.journal-search:focus {
    outline: 2px solid var(--tivoli-gold);
    outline-offset: 1px;
    border-color: var(--tivoli-blue-light);
}

.journal-search::-webkit-search-cancel-button {
    cursor: pointer;
}

.journal-status {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.journal-status--error {
    color: var(--danger);
}

.journal-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.journal-entry {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
}

.journal-entry__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.journal-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.journal-badge--created {
    background: rgba(46, 125, 50, 0.12);
    color: #2e7d32;
}

.journal-badge--updated {
    background: rgba(30, 58, 95, 0.1);
    color: var(--tivoli-blue);
}

.journal-badge--deleted {
    background: rgba(180, 35, 24, 0.1);
    color: var(--danger);
}

.journal-entry__time {
    font-size: 0.82rem;
    color: var(--muted);
}

.journal-entry__title {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.journal-entry__meta {
    margin: 0 0 0.5rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.journal-entry__user {
    font-weight: 600;
    color: var(--tivoli-blue);
}

.journal-entry__levels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

.journal-level {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: rgba(30, 58, 95, 0.08);
    color: var(--tivoli-blue);
}

.journal-details {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0.65rem 0 0;
    border-top: 1px dashed var(--border);
    font-size: 0.82rem;
}

.journal-details li {
    display: grid;
    grid-template-columns: minmax(4.5rem, auto) 1fr auto 1fr;
    gap: 0.25rem 0.5rem;
    align-items: baseline;
    margin-bottom: 0.35rem;
}

.journal-details__label {
    font-weight: 600;
    color: var(--muted);
}

.journal-details__val {
    color: var(--text);
    word-break: break-word;
}

.journal-details__val--after {
    font-weight: 600;
}

.journal-details__arrow {
    color: var(--muted);
    text-align: center;
}

.journal-more-row {
    margin-top: 1.25rem;
    text-align: center;
}

@media (max-width: 640px) {
    .journal-details li {
        grid-template-columns: 1fr;
    }

    .journal-details__arrow {
        display: none;
    }
}

/* ——— Pied de page ——— */
.app-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 0.85rem var(--page-gutter);
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: var(--card);
}

.app-footer__line {
    margin: 0;
    line-height: 1.5;
}

.app-footer a {
    color: var(--tivoli-blue);
    font-weight: 600;
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.login-page .app-footer {
    background: transparent;
    border-top-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.75);
}

.login-page .app-footer a {
    color: var(--tivoli-logo-gold);
}

/* FullCalendar — thème Tivoli */
.fc {
    --fc-border-color: var(--border);
    --fc-button-bg-color: var(--tivoli-blue);
    --fc-button-border-color: var(--tivoli-blue);
    --fc-button-hover-bg-color: var(--tivoli-blue-dark);
    --fc-button-hover-border-color: var(--tivoli-blue-dark);
    --fc-button-active-bg-color: var(--tivoli-blue-dark);
    --fc-button-active-border-color: var(--tivoli-blue-dark);
    --fc-today-bg-color: rgba(201, 179, 130, 0.2);
    --fc-bg-event-opacity: 1;
}

/* Titre des vacances/fériés en bas de cellule pour ne pas masquer le numéro de jour */
.fc-bg-event .fc-event-title {
    position: absolute;
    bottom: 2px;
    top: auto;
    left: 2px;
    right: 2px;
    font-size: 0.62em;
    font-weight: 500;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    line-height: 1;
    pointer-events: none;
}

.fc .fc-toolbar-title {
    color: var(--tivoli-blue);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1rem, 3.5vw, 1.25rem);
}

/* Titre cliquable → sélecteur mois / semaine / jour */
.fc-toolbar-title-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
}

#calendar .fc-toolbar-title--picker {
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0.15rem 1.25rem 0.15rem 0.35rem;
    margin: 0;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    max-width: 100%;
    text-align: center;
}

#calendar .fc-toolbar-title--picker:hover,
#calendar .fc-toolbar-title--picker:focus-visible {
    background: rgba(30, 58, 95, 0.08);
    color: var(--tivoli-blue-dark);
    outline: 2px solid rgba(30, 58, 95, 0.25);
    outline-offset: 2px;
}

#calendar .fc-toolbar-title--picker::after {
    content: '';
    position: absolute;
    right: 0.35rem;
    top: 50%;
    margin-top: 0.12em;
    border: 0.28em solid transparent;
    border-top-color: currentColor;
    opacity: 0.55;
    pointer-events: none;
}

.cal-period-picker {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.fc .fc-col-header-cell-cushion {
    color: var(--tivoli-blue);
    font-weight: 600;
}

.fc-timeGridWeek-view .fc-day-header-goto-day {
    cursor: pointer;
}

.fc-timeGridWeek-view .fc-day-header-goto-day:hover {
    text-decoration: underline;
}

/* Vues Semaine / Jour : colonne horaire + libellé « Toute la journée » */
.fc-timeGridWeek-view,
.fc-timeGridDay-view {
    --fc-timegrid-axis-width: clamp(3rem, 10vw, 4.75rem);
}

.fc-timeGridWeek-view .fc-timegrid-axis:has(.tivoli-all-day-label),
.fc-timeGridDay-view .fc-timegrid-axis:has(.tivoli-all-day-label) {
    vertical-align: middle;
    background: linear-gradient(180deg, rgba(30, 58, 95, 0.07) 0%, rgba(30, 58, 95, 0.02) 100%);
}

.fc-timeGridWeek-view .fc-timegrid-axis-cushion:has(.tivoli-all-day-label),
.fc-timeGridDay-view .fc-timegrid-axis-cushion:has(.tivoli-all-day-label) {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 2.5rem;
    padding: 0.25rem 0.15rem;
    overflow: visible;
}

.tivoli-all-day-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    width: 100%;
    max-width: 100%;
    color: var(--tivoli-blue);
    font-weight: 600;
    font-size: clamp(0.58rem, 1.55vw, 0.72rem);
    line-height: 1.15;
    text-align: center;
    letter-spacing: 0.02em;
}

.tivoli-all-day-label__icon {
    width: clamp(0.9rem, 2.8vw, 1.15rem);
    height: clamp(0.9rem, 2.8vw, 1.15rem);
    color: var(--tivoli-gold);
    flex-shrink: 0;
}

.tivoli-all-day-label__text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.04rem;
    min-width: 0;
}

.tivoli-all-day-label__line {
    display: block;
    white-space: nowrap;
}

.tivoli-all-day-label__text--short {
    display: none;
    font-size: clamp(0.62rem, 1.8vw, 0.7rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Événements : styles inline + renfort CSS (FullCalendar 6) */
.fc-event.fc-event-tivoli,
.fc-h-event.fc-event-tivoli,
.fc-v-event.fc-event-tivoli {
    cursor: grab;
    border-width: 2px !important;
}

.fc-event.fc-event-tivoli.fc-event-dragging,
.fc-event.fc-event-tivoli:active {
    cursor: grabbing;
}

.fc-event.fc-event-tivoli .tivoli-ev-body,
.fc-event.fc-event-tivoli .fc-event-title,
.fc-event.fc-event-tivoli .fc-event-time {
    font-weight: 700 !important;
}

.fc-event.fc-event-tivoli .fc-event-main {
    color: inherit !important;
}

.fc-daygrid-block-event .fc-event-tivoli .fc-event-main,
.fc-daygrid-dot-event .fc-event-tivoli .fc-event-main {
    padding: 0;
}

.tivoli-ev-body {
    width: 100%;
    min-height: 100%;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
    background: var(--tivoli-gold-dark);
    border-color: var(--tivoli-gold-dark);
    color: #fff;
}

/* ——— Champ mot de passe avec toggle ——— */
.pw-wrap {
    position: relative;
    margin-top: 0.35rem;
}

.pw-wrap input {
    margin-top: 0;
    padding-right: 2.75rem;
    width: 100%;
}

/* Edge / IE ajoutent leur propre bouton de révélation : il ferait doublon avec
   .pw-toggle (voir js/nav.js). On ne garde que le nôtre, présent sur tous les
   navigateurs et accessible au clavier. */
.pw-wrap input::-ms-reveal {
    display: none;
    width: 0;
    height: 0;
}

.pw-wrap input::-ms-clear {
    display: none;
    width: 0;
    height: 0;
}

.pw-toggle {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.pw-toggle:hover {
    color: var(--tivoli-blue);
    background: rgba(30, 58, 95, 0.06);
}

.pw-toggle svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.pw-eye-hide {
    display: none;
}

/* ——— Formulaires ——— */
label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

input:focus,
textarea:focus {
    outline: 2px solid var(--tivoli-gold);
    outline-offset: 1px;
    border-color: var(--tivoli-blue-light);
}

.accounts-page {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--page-gutter) var(--page-gutter) 2.5rem;
    width: 100%;
}

.accounts-page .login-card {
    border-radius: var(--radius);
    justify-content: flex-start;
    box-shadow: var(--shadow);
}

.accounts-page .app-header {
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.accounts-form {
    margin-bottom: 2rem;
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--tivoli-gold);
}

.accounts-form h2 {
    margin-top: 0;
    color: var(--tivoli-blue);
}

.accounts-list {
    background: var(--card);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.accounts-list h2 {
    color: var(--tivoli-blue);
    font-size: 1.1rem;
}

.accounts-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.accounts-list li {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}

.accounts-list code {
    color: var(--tivoli-blue);
    font-size: 0.9em;
}

#event-dialog {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    width: min(480px, calc(100vw - 2 * var(--page-gutter)));
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    box-shadow: 0 16px 48px rgba(30, 58, 95, 0.25);
    border-top: 4px solid var(--tivoli-gold);
}

#event-dialog::backdrop {
    background: rgba(30, 58, 95, 0.4);
}

#event-form {
    padding: 1.25rem;
}

.dialog-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dialog-title {
    flex: 1 1 0;
    margin: 0;
    color: var(--tivoli-blue);
}

#event-form h2 {
    margin-top: 0;
    color: var(--tivoli-blue);
}

.dialog-close-btn {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.dialog-close-btn:hover {
    background: var(--bg);
    color: var(--tivoli-blue);
}

.dialog-close-btn svg {
    width: 18px;
    height: 18px;
}

/* ——— Toast notifications ——— */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--tivoli-blue);
    color: #fff;
    padding: 0.65rem 1.1rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(30, 58, 95, 0.3);
    opacity: 0;
    transform: translateY(0.4rem);
    transition: opacity 0.22s, transform 0.22s;
    white-space: nowrap;
}

.toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox input { width: auto; margin: 0; }

fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 0 0 1rem;
    padding: 0.5rem 0.75rem 0.75rem;
}

fieldset legend {
    color: var(--tivoli-blue);
    font-weight: 600;
    padding: 0 0.25rem;
}

.event-levels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

/* ——— Titre : événements précédents contenant les mots saisis ——— */
.title-matches {
    margin: 0.4rem 0 0.9rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--tivoli-gold);
    border-radius: 6px;
    background: var(--bg);
    max-height: 14rem;
    overflow-y: auto;
    padding: 0.25rem;
}

.title-matches-head {
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    padding: 0.25rem 0.45rem;
}

.title-match-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: none;
    border-radius: 5px;
    background: none;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: var(--tivoli-text, #152a45);
}

.title-match-item:hover,
.title-match-item.is-active {
    background: var(--card);
}

.title-match-main {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    min-width: 0;
}

.title-match-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.title-match-badge {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.02rem 0.3rem;
}

.title-match-meta {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--tivoli-blue);
    white-space: nowrap;
}

/* Popup de choix de portée pour la récurrence */
.scope-dialog {
    border: none;
    border-radius: 12px;
    padding: 1.4rem 1.6rem 1.1rem;
    box-shadow: 0 8px 32px rgba(15,23,42,0.22);
    max-width: 360px;
    width: calc(100% - 2rem);
}

.scope-dialog::backdrop {
    background: rgba(15,23,42,0.35);
}

.scope-dialog-hint {
    font-size: 0.88rem;
    font-weight: 600;
    color: #334155;
    margin: 0 0 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.scope-dialog-btns {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scope-dialog-btns .btn-secondary {
    justify-content: flex-start;
    text-align: left;
}

.scope-dialog-cancel-row {
    margin: 0.85rem 0 0;
    text-align: center;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.dialog-actions .spacer { flex: 1 1 0.5rem; }

.event-duvoisin-block {
    margin: 0.15rem 0 0.35rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--tivoli-gold);
    border-radius: var(--radius);
}

.event-duvoisin-summary {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.85rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--tivoli-blue);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.event-duvoisin-summary::-webkit-details-marker { display: none; }

/* Indicateur de configuration planifiée (date de l'événement), à droite du summary */
.event-duvoisin-config {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.event-duvoisin-config .swatch {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    border: 1px solid rgba(21, 42, 69, 0.2);
    flex: 0 0 auto;
}
.event-duvoisin-config.is-none,
.event-duvoisin-config.is-loading {
    color: var(--muted);
    font-weight: 500;
    font-style: italic;
}

.event-duvoisin-summary::before {
    content: '';
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 6px solid var(--tivoli-gold);
    transition: transform 0.15s ease;
}

.event-duvoisin-block[open] > .event-duvoisin-summary::before {
    transform: rotate(90deg);
}

.event-duvoisin-panel {
    padding: 0 0.85rem 0.85rem;
}

.syres-duvoisin-embed {
    display: block;
    width: 100%;
    height: min(420px, 52vh);
    min-height: 300px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

#event-dialog:has(.event-duvoisin-block[open]) {
    width: min(960px, calc(100vw - 1rem));
    max-width: calc(100vw - 1rem);
}

.subpage .brand {
    flex: 1 1 12rem;
    min-width: 0;
}

.subpage-header .brand h1 {
    margin: 0;
    font-size: 1.1rem;
}

/* ——— Pages d'administration ——— */
.admin-page {
    max-width: 860px;
    margin: 0 auto;
    padding: var(--page-gutter) var(--page-gutter) 3rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.admin-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border-left: 4px solid var(--tivoli-gold);
}

.admin-card h2 {
    margin: 0 0 0.5rem;
    color: var(--tivoli-blue);
    font-family: var(--font-heading);
    font-size: 1.15rem;
}

.count-badge {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    font-family: var(--font-body);
}

.field-hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

.form-actions {
    margin-top: 1rem;
}

.row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

/* Flash messages */
.flash {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.flash--success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Rôles */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.role-badge--admin { background: #fef3c7; color: #92400e; border: 1px solid #fbbf24; }
.role-badge--user  { background: #e0f2fe; color: #0c4a6e; border: 1px solid #7dd3fc; }

/* Petits boutons */
.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    min-height: auto;
}
.btn-outline {
    background: transparent;
    color: var(--tivoli-blue);
    border: 1.5px solid var(--tivoli-blue);
}
.btn-outline:hover {
    background: var(--tivoli-blue);
    color: #fff;
}

/* Liste utilisateurs */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.user-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-card-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.user-identity {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-login {
    font-size: 0.82rem;
    color: var(--tivoli-blue-light);
    background: var(--card);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-levels-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.user-levels-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    flex: 1 1 0;
    min-width: 0;
}

.mini-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1.5px solid;
    font-size: 0.78rem;
    font-weight: 600;
    color: #152a45;
}

.muted-text { color: var(--muted); font-size: 0.87rem; }

.section-actions {
    margin-bottom: 0.75rem;
}

/* Liste catégories */
.cats-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cat-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
}

.cat-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid rgba(0,0,0,0.12);
    flex-shrink: 0;
}

.cat-info {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex: 1 1 0;
    min-width: 0;
}

.cat-code {
    font-size: 0.8rem;
    color: var(--muted);
    background: var(--card);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.cat-color-hex {
    font-size: 0.8rem;
    color: var(--muted);
    font-family: monospace;
}

.cat-drag-handle {
    color: var(--muted);
    cursor: grab;
    font-size: 1rem;
    padding: 0 0.1rem;
    flex-shrink: 0;
    user-select: none;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.cat-row:hover .cat-drag-handle {
    opacity: 1;
}

.cat-row--dragging {
    opacity: 0.35;
}

.cat-row--drag-over {
    border-color: var(--tivoli-blue);
    background: rgba(30, 58, 95, 0.06);
    box-shadow: 0 0 0 2px var(--tivoli-blue);
}

/* Hiérarchie catégories / sous-catégories (page admin) */
.cat-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.cat-row--parent {
    background: var(--card);
    border-width: 2px;
}

.cat-row--parent .cat-info strong {
    font-size: 1rem;
}

.cat-toggle-spacer {
    flex-shrink: 0;
    width: 1.25rem;
}

.btn-cat-toggle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--tivoli-blue);
    padding: 0;
    transition: background 0.15s;
}

.btn-cat-toggle:hover {
    background: var(--bg);
}

.btn-cat-toggle[aria-expanded="false"] .subgroup-toggle-icon {
    transform: rotate(-90deg);
}

.cat-sub-count {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.cat-subgroup {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-left: 0.75rem;
    margin-left: 1.1rem;
    border-left: 3px solid var(--tivoli-blue);
    overflow: hidden;
    max-height: 2000px;
    opacity: 1;
    transition: max-height 0.25s ease, margin-top 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
}

.cat-subgroup.is-collapsed {
    max-height: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    border-left-color: transparent;
}

.cat-row--sub {
    padding: 0.45rem 0.85rem;
    background: var(--bg);
    border-style: dashed;
}

.cat-row--sub .cat-swatch {
    width: 22px;
    height: 22px;
}

.cat-row--sub .cat-info strong {
    font-size: 0.9rem;
    font-weight: 500;
}

.cat-sub-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-right: 0.35rem;
}

.cat-shared-badge {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}

/* Visibilité d'une sous-catégorie : un seul bouton qui parcourt les trois états */
.btn-vis {
    flex-shrink: 0;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: none;
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0.15rem 0.6rem;
}

.btn-vis--public   { border-color: #86b8f0; color: #1d5da8; }
.btn-vis--discreet { border-color: #d9b06a; color: #8a6412; }
.btn-vis--private  { border-color: #cfd4db; color: var(--muted); }

.btn-vis:hover {
    filter: brightness(0.92);
}

.btn-add-cat-sub {
    flex-shrink: 0;
}

/* Saisie couleur combinée */
.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}
.color-input-wrap input[type="color"] {
    width: 3rem;
    height: 2.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.15rem;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}
.color-input-wrap input[type="text"] {
    margin: 0;
    flex: 1 1 0;
    min-width: 0;
    font-family: monospace;
}

/* Dialog catégorie / niveaux */
.dialog-inner {
    padding: 1.25rem;
}
.dialog-inner h2 { margin: 0 0 0.25rem; color: var(--tivoli-blue); font-family: var(--font-heading); }

/* Weekends (hors vacances) — vues Jour / Semaine / Mois */
.fc .fc-day-sat:not(.fc-day-today):not(.fc-day-vacation),
.fc .fc-day-sun:not(.fc-day-today):not(.fc-day-vacation) {
    background-color: var(--cal-weekend-bg);
}

.fc .fc-day-vacation:not(.fc-day-today) {
    background-color: var(--cal-vacation-bg);
}

/* Bandeau « configuration Espace Duvoisin » (planning SyRes) — bande fine en haut
   de la cellule-jour, superposée sans masquer le fond vacances/férié ni les events. */
.fc .fc-day-duvoisin { position: relative; }
.fc .fc-day-duvoisin::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: var(--duv-color, transparent);
    z-index: 4;
    pointer-events: none;
}

/* Contrôle opt-in + légende dans la barre latérale */
.duvoisin-bg-control {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.duvoisin-bg-toggle { font-size: 0.9rem; }
/* Une ligne par configuration : les descriptions d'aménagement sont trop longues
   pour la disposition en ligne d'origine, qui les aurait tronquées. */
.duvoisin-legend {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding-left: 1.7rem;
}
.duvoisin-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--muted);
}
.duvoisin-legend-text {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
}
.duvoisin-legend-label { font-weight: 600; }
.duvoisin-legend-desc {
    font-size: 0.74rem;
    line-height: 1.25;
    opacity: 0.85;
}
.duvoisin-legend-swatch {
    width: 22px;
    height: 8px;
    border-radius: 2px;
    border: 1px solid rgba(21, 42, 69, 0.18);
    flex: 0 0 auto;
    margin-top: 0.32rem; /* aligne la pastille sur la 1re ligne de texte */
}

/* Vue Année (grille custom) — bandeau haut dans la cellule-jour */
/* Spécificité doublée (.yg-cell.yg-cell--duvoisin) car la règle .yg-cell définie
   plus bas dans le fichier réécrit sinon `padding` en entier (même spécificité). */
.yg-cell.yg-cell--duvoisin {
    position: relative;
    /* Réserve la hauteur du bandeau pour ne pas recouvrir le libellé de date. */
    padding-top: 7px;
}
.yg-cell--duvoisin::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--duv-color, transparent);
    z-index: 2;
    pointer-events: none;
}

/* Indicateur lecture seule sur événements */
.fc-event-tivoli.fc-event--readonly {
    opacity: 0.82;
    cursor: default !important;
}

/* Loading */
.loading-msg { color: var(--muted); font-style: italic; }

/* select */
select {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}
select:focus {
    outline: 2px solid var(--tivoli-gold);
    outline-offset: 1px;
    border-color: var(--tivoli-blue-light);
}

/* ——— Hamburger ——— */
.btn-hamburger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.4rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}

.btn-hamburger:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--tivoli-gold);
}

.hamburger-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.22s ease, opacity 0.15s ease;
    transform-origin: center;
}

.btn-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.btn-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.btn-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ——— Hiérarchie de catégories dans la sidebar ——— */

.level-group {
    width: 100%;
}

.level-group-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
}

.level-subgroup {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.25rem;
    padding-left: 1.2rem;
    border-left: 2px solid var(--border);
    margin-left: 0.5rem;
    overflow: hidden;
    max-height: 800px;
    opacity: 1;
    transition: max-height 0.25s ease, margin-top 0.2s ease, opacity 0.2s ease;
}

.level-subgroup.is-collapsed {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
}

.btn-subgroup-toggle {
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--tivoli-blue);
    padding: 0;
    transition: background 0.15s;
}

.btn-subgroup-toggle:hover {
    background: var(--bg);
}

.subgroup-toggle-icon {
    width: 13px;
    height: 13px;
    transition: transform 0.25s ease;
}

.btn-subgroup-toggle[aria-expanded="false"] .subgroup-toggle-icon {
    transform: rotate(-90deg);
}

.level-group-row--sub {
    opacity: 0.9;
}

.level-group-row--sub .level-chip {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
}


.btn-add-subcat,
.btn-edit-subcat,
.btn-toggle-vis {
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--tivoli-blue);
    line-height: 1;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
}

.btn-add-subcat:hover,
.btn-edit-subcat:hover,
.btn-toggle-vis:hover {
    background: var(--tivoli-blue);
    border-color: var(--tivoli-blue);
    color: #fff;
}

/* Rappel de l'état courant dans le volet latéral (l'icône seule est ambiguë) */
.btn-toggle-vis--public   { border-color: #86b8f0; }
.btn-toggle-vis--discreet { border-color: #d9b06a; }
.btn-toggle-vis--private  { border-color: #cfd4db; }

.subcat-private-icon {
    font-size: 0.7rem;
    margin-left: 0.25rem;
    opacity: 0.75;
    cursor: default;
}

/* Sous-catégories dans le formulaire d'événement */
.event-levels-subgroup {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
    margin-left: 0.25rem;
    margin-top: 0.1rem;
    margin-bottom: 0.25rem;
    width: 100%;
}

/* Dialogue sous-catégorie */
.subcat-dialog {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(30, 58, 95, 0.25);
    padding: 0;
    max-width: min(400px, calc(100vw - 2rem));
    width: 100%;
}

.subcat-dialog::backdrop {
    background: rgba(30, 58, 95, 0.4);
}

.subcat-dialog .dialog-inner {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.subcat-dialog .dialog-title {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
    color: var(--tivoli-blue);
}

.subcat-dialog label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tivoli-blue-dark);
}

.subcat-dialog input[type="text"],
.subcat-dialog input[type="color"] {
    width: 100%;
}

.field-hint {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--muted);
}

/* ——— Volet Catégories : version compacte ———
   Portée limitée au volet latéral : les chips du formulaire d'événement
   gardent leur taille confortable (cibles tactiles du dialogue). */
.calendar-sidebar .level-chip {
    gap: 0.3rem;
    padding: 0.28rem 0.55rem;
    font-size: 0.8rem;
    border-width: 1.5px;
}

.calendar-sidebar .level-chip input {
    width: 0.85rem;
    height: 0.85rem;
}

.calendar-sidebar .level-group-row--sub .level-chip {
    font-size: 0.74rem;
    padding: 0.2rem 0.45rem;
}

.calendar-sidebar .level-filters {
    gap: 0.25rem;
}

.calendar-sidebar .level-group-row {
    gap: 0.2rem;
}

.calendar-sidebar .level-subgroup {
    gap: 0.15rem;
    margin-top: 0.15rem;
    padding-left: 0.9rem;
}

.calendar-sidebar .btn-add-subcat,
.calendar-sidebar .btn-edit-subcat,
.calendar-sidebar .btn-toggle-vis {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.7rem;
}

.calendar-sidebar .btn-subgroup-toggle {
    width: 1.05rem;
    height: 1.05rem;
}

.calendar-sidebar .level-filters-group {
    gap: 0.4rem;
}

.calendar-sidebar .sidebar-body {
    margin-top: 0.55rem;
}

/* ——— Sidebar pliable ——— */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background: var(--card);
    border: 1px solid rgba(30, 58, 95, 0.1);
    border-top: 2px solid var(--tivoli-gold);
    border-radius: 50%;
    cursor: pointer;
    color: var(--tivoli-blue);
    flex-shrink: 0;
    box-shadow:
        0 2px 10px rgba(30, 58, 95, 0.12),
        0 1px 2px rgba(30, 58, 95, 0.06);
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle-btn:focus-visible {
    outline: 2px solid var(--tivoli-gold);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .sidebar-toggle-btn:hover {
        border-color: rgba(30, 58, 95, 0.18);
        border-top-color: var(--tivoli-gold-dark);
        box-shadow: 0 4px 16px rgba(30, 58, 95, 0.16);
        color: var(--tivoli-blue-dark);
        transform: translateY(-1px);
    }
}

@media (hover: none) {
    .sidebar-toggle-btn:active {
        background: var(--bg);
        box-shadow: 0 1px 6px rgba(30, 58, 95, 0.1);
        transform: scale(0.96);
    }
}

.sidebar-toggle-icon {
    width: 15px;
    height: 15px;
    transition: transform var(--sidebar-dur) var(--sidebar-ease);
}

.sidebar-body {
    display: grid;
    grid-template-rows: 1fr;
    margin-top: 0.75rem;
    opacity: 1;
    overflow: hidden;
    transition:
        grid-template-rows var(--sidebar-dur) var(--sidebar-ease),
        margin-top var(--sidebar-dur) var(--sidebar-ease),
        opacity calc(var(--sidebar-dur) * 0.8) var(--sidebar-ease);
}

.sidebar-body-inner {
    min-height: 0;
    overflow: hidden;
    transition: transform var(--sidebar-dur) var(--sidebar-ease);
    transform: translate3d(0, 0, 0);
}

.calendar-sidebar.is-collapsed .sidebar-body {
    grid-template-rows: 0fr;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .calendar-wrap,
    .calendar-sidebar,
    .sidebar-title,
    .sidebar-body,
    .sidebar-body-inner,
    .sidebar-toggle-icon {
        transition-duration: 0.01ms !important;
    }
}

/* ——— Responsive ——— */
@media (max-width: 1100px) {
    /* Volet empilé au-dessus du calendrier : c'est la PAGE qui défile.
       Le calendrier prend sa hauteur naturelle et se voit en entier en
       faisant défiler vers le bas, au lieu d'être comprimé dans le viewport. */
    .calendar-wrap {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
        min-height: calc(100dvh - var(--header-h));
        overflow: visible;
        align-items: start;
        align-content: start;   /* sinon les lignes auto s'étirent : trou entre volet et calendrier */
    }

    /* Vues Année / Liste : elles gardent leur défilement interne (en-têtes
       collants + scroll horizontal), donc la grille se cale sur le viewport.
       Mais le volet Catégories déplié peut à lui seul le remplir : la grille
       garde alors un plancher lisible et c'est la PAGE qui défile pour l'y
       rejoindre. Sans ce plancher, la ligne 1fr tombait à zéro et le calendrier
       devenait inatteignable — la carte verrouillée à 100dvh interdisant tout
       défilement vertical.
       `max-content` et non `auto` pour la ligne du volet : une ligne `auto` se
       laisse comprimer jusqu'à son min-content dès que la ligne suivante réclame
       son plancher — et le volet, qui masque son débordement, se retrouvait
       tronqué.
       `min-height` et non `height` : une hauteur FIGÉE ne grandit pas avec son
       contenu, si bien que le volet déplié débordait de la carte et se peignait
       PAR-DESSUS le pied de page, placé lui après la boîte. En min-height, la
       carte occupe exactement la place disponible tant que ça tient, puis
       s'allonge — le pied de page suit alors toujours le contenu. */
    .calendar-wrap:has(.calendar-main.is-year-view),
    .calendar-wrap:has(.calendar-main.is-list-view) {
        grid-template-rows: max-content minmax(min(26rem, 60dvh), 1fr);
        height: auto;
        min-height: calc(100dvh - var(--header-h) - var(--footer-h, 0px));
        overflow: visible;
        align-items: stretch;
        align-content: stretch;
    }

    .calendar-sidebar {
        position: static;
    }

    /* Replié, le volet n'est plus qu'un bandeau d'appel : il ne doit pas
       repousser le calendrier hors de l'écran à l'ouverture de la page. */
    .calendar-sidebar.is-collapsed {
        padding: 0.3rem 0.6rem;
    }

    .calendar-sidebar.is-collapsed .sidebar-title {
        font-size: 0.95rem;
    }

    .calendar-sidebar.is-collapsed .sidebar-toggle-btn {
        width: 1.9rem;
        height: 1.9rem;
    }

    /* Vues Mois / Semaine / Jour : aucun conteneur de défilement ici, sinon il
       piégerait le défilement vertical (overflow-x:auto implique overflow-y). */
    .calendar-main:not(.is-year-view):not(.is-list-view) {
        display: block;
        min-height: 0;
        overflow: visible;
    }

    /* Le défilement horizontal (grille < 420px) est confiné à la GRILLE, pas à
       la carte : la barre de commandes au-dessus reste toujours entièrement
       visible, sans jamais déborder de la fenêtre. La hauteur reste automatique
       (pas de barre verticale interne). */
    .calendar-main:not(.is-year-view):not(.is-list-view) #calendar {
        display: block;
        width: 100%;
        max-width: none;
        min-width: 0;
        overflow: visible;
    }

    .calendar-main:not(.is-year-view):not(.is-list-view) #calendar .fc {
        min-width: 0;
    }

    .calendar-main:not(.is-year-view):not(.is-list-view) #calendar .fc-view-harness {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .calendar-main:not(.is-year-view):not(.is-list-view) #calendar .fc-view-harness > .fc-view {
        min-width: 420px;
    }

    /* Vue Année : toolbar fixe + grille scrollable (vertical et horizontal).
       `max-height` borne la carte à la fenêtre utile : la piste de grille
       n'étant plus figée (elle doit pouvoir s'allonger pour le volet déplié),
       c'est ce plafond qui garde le défilement interne — et il s'adapte seul à
       la hauteur réelle de la barre de commandes, contrairement à un retrait
       forfaitaire. */
    .calendar-main.is-year-view,
    .calendar-main.is-list-view {
        height: 100%;
        max-height: calc(100dvh - var(--header-h) - var(--footer-h, 0px) - 5rem);
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
    }

    .calendar-main.is-year-view #calendar,
    .calendar-main.is-list-view #calendar {
        flex-shrink: 0;
    }

    .calendar-main.is-year-view #year-grid-wrap,
    .calendar-main.is-list-view #list-grid-wrap {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .calendar-main.is-year-view #year-grid,
    .calendar-main.is-list-view #list-grid {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .calendar-main.is-year-view .year-grid-scroll,
    .calendar-main.is-list-view .list-grid-scroll {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* Pas de défilement interne : la page défile, deux zones de scroll
       imbriquées seraient pénibles au doigt. Le volet prend sa hauteur
       naturelle (elle reste modeste depuis la version compacte des chips). */
    .sidebar-body {
        max-height: none;
    }

    /* Chips en grille qui s'enroulent */
    .level-filters {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.35rem;
    }

    /* Chaque groupe prend sa largeur naturelle (ne force plus 100%) */
    .level-group {
        width: auto;
        flex: 0 0 auto;
        max-width: 100%;
    }

    .level-group-row {
        width: auto;
    }

    /* Sous-catégories : elles s'enroulent aussi horizontalement */
    .level-subgroup {
        flex-direction: row;
        flex-wrap: wrap;
        padding-left: 0.75rem;
        margin-left: 0.25rem;
        gap: 0.2rem;
        margin-top: 0.15rem;
        border-left-width: 1px;
    }

    .level-group-row--sub {
        width: auto;
        flex: 0 0 auto;
    }

    /* Sous-chips légèrement plus petits */
    .level-group-row--sub .level-chip {
        font-size: 0.78rem;
        padding: 0.28rem 0.55rem;
    }

    /* Boutons +/✏ moins imposants */
    .btn-add-subcat,
    .btn-edit-subcat {
        width: 1.3rem;
        height: 1.3rem;
        font-size: 0.82rem;
    }

    .row-3 {
        grid-template-columns: 1fr 1fr;
    }

    /* Collapse vertical sur mobile */
    /* Corps masqué via .calendar-sidebar.is-collapsed .sidebar-body (global) */

    /* ∨ → ∧ : indique "déplier vers le bas" */
    .calendar-sidebar.is-collapsed .sidebar-toggle-icon {
        transform: rotate(180deg);
    }
}

/* Collapse horizontal sur desktop */
@media (min-width: 1101px) {
    .calendar-wrap:has(.calendar-sidebar.is-collapsed) {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    /* Carte masquée — seul le bouton reste visible */
    .calendar-sidebar.is-collapsed {
        background: transparent;
        box-shadow: none;
        border-top-color: transparent;
        border-radius: 0;
        padding: 0.6rem 0;
    }

    .calendar-sidebar.is-collapsed .sidebar-header {
        justify-content: center;
        gap: 0;
    }

    .calendar-sidebar.is-collapsed .sidebar-title {
        max-width: 0;
        opacity: 0;
    }

    .calendar-sidebar.is-collapsed .sidebar-body-inner {
        transform: translate3d(-0.4rem, 0, 0);
    }

    /* Corps masqué via .calendar-sidebar.is-collapsed .sidebar-body (global) */

    /* ∨ → ‹ : indique "replier à gauche" */
    .sidebar-toggle-icon {
        transform: rotate(90deg);
    }

    /* ∨ → › : indique "déplier à droite" */
    .calendar-sidebar.is-collapsed .sidebar-toggle-icon {
        transform: rotate(-90deg);
    }

    /* ——— Vue Année : hauteur fixe + défilement interne ——— */
    .calendar-main.is-year-view,
    .calendar-main.is-list-view {
        height: calc(100dvh - var(--header-h) - 3rem);
        overflow: hidden;              /* remplace overflow-x: visible */
        display: flex;
        flex-direction: column;
    }

    .calendar-main.is-year-view #calendar,
    .calendar-main.is-list-view #calendar {
        flex-shrink: 0;
    }

    .calendar-main.is-year-view #year-grid-wrap,
    .calendar-main.is-list-view #list-grid-wrap {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .calendar-main.is-year-view #year-grid,
    .calendar-main.is-list-view #list-grid {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Le conteneur de scroll gère maintenant aussi le défilement vertical */
    .calendar-main.is-year-view .year-grid-scroll,
    .calendar-main.is-list-view .list-grid-scroll {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }
}

@media (max-width: 900px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-brand-panel {
        padding: 2rem var(--page-gutter) 1.75rem;
        border-right: none;
    }

    .auth-brand-panel::after {
        display: none;
    }

    .auth-brand-title {
        display: none;
    }

    .auth-product-line,
    .auth-location {
        display: none;
    }

    .auth-portal-link {
        margin-top: 1.25rem;
    }

    .login-card__brand-mobile {
        display: flex;
    }

    .login-card__brand-mobile .brand-title__word {
        font-size: clamp(1.35rem, 6vw, 1.65rem);
    }

    .login-card {
        padding: 1.25rem var(--page-gutter) 2rem;
    }

    .login-card__header,
    .login-card__body {
        padding-left: 1.35rem;
        padding-right: 1.35rem;
    }

    .btn-hamburger {
        display: flex;
    }

    .app-header {
        flex-wrap: nowrap;
    }

    .toolbar {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 99;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem var(--page-gutter) 1rem;
        background: linear-gradient(180deg, var(--tivoli-blue-dark) 0%, var(--tivoli-blue) 100%);
        border-top: 2px solid var(--tivoli-gold);
        box-shadow: 0 8px 24px rgba(30, 58, 95, 0.3);
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .app-header.menu-open .toolbar {
        display: flex;
    }

    .toolbar .btn-primary,
    .toolbar .btn-ghost,
    .toolbar .btn-secondary {
        width: 100%;
        justify-content: flex-start;
        padding-left: 1rem;
    }

    /* La composition de la barre est pilotée par les règles
       « Barre de commandes au-dessus du calendrier » (ordre flex). */

    .fc .fc-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.82rem;
        min-height: 2.5rem;
    }

    #calendar {
        padding: 0.5rem;
    }

    /* Vue Semaine/Jour : labels horaires réduits */
    .fc .fc-timegrid-slot-label-cushion {
        font-size: 0.72rem;
        padding-inline: 0.2rem;
    }

    .fc-timeGridWeek-view,
    .fc-timeGridDay-view {
        --fc-timegrid-axis-width: clamp(2.65rem, 11vw, 3.75rem);
    }

    .tivoli-all-day-label {
        font-size: clamp(0.54rem, 2.8vw, 0.66rem);
        gap: 0.12rem;
    }

    /* Titre de la toolbar : éviter le débordement */
    .fc .fc-toolbar-title {
        font-size: clamp(0.9rem, 4vw, 1.15rem);
        min-width: 0;
    }

    /* Événements : police légèrement réduite */
    .fc-event.fc-event-tivoli .fc-event-title,
    .fc-event.fc-event-tivoli .fc-event-time,
    .fc-event.fc-event-tivoli .tivoli-ev-body {
        font-size: 0.75rem;
        line-height: 1.22;
    }

    .fc-daygrid-dot-event.fc-event-tivoli .fc-event-title {
        font-size: 0.7rem;
    }

    .ev-badge {
        font-size: 0.68em;
    }

    .ev-recur-icon {
        font-size: 0.72em;
    }

    .yg-chip {
        font-size: 0.6rem;
        line-height: 1.2;
    }

    .yg-badge {
        font-size: 0.8em;
    }
}

@media (max-width: 700px) {
    .row-2,
    .row-3 {
        grid-template-columns: 1fr;
    }

    .header-logo {
        max-height: 44px;
    }

    .brand-title__word {
        font-size: 1.15rem;
    }

    .brand-title__pilo {
        font-size: 0.68em;
    }

    .brand-title:not(:has(.brand-title__word)) {
        font-size: 0.95rem;
    }

    .brand-user {
        font-size: 0.78rem;
    }

    .dialog-actions .btn-danger {
        order: 10;
        width: 100%;
    }

    .dialog-actions .btn-secondary,
    .dialog-actions .btn-primary {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .accounts-page .app-header {
        border-radius: 0;
        margin-bottom: 0;
    }

    .accounts-form,
    .accounts-list,
    .admin-card {
        padding: 1rem;
    }

    .cat-color-hex { display: none; }

    .user-card-main { flex-direction: column; align-items: flex-start; }

    /* Vue Année : cellules plus étroites */
    .yg-cell {
        min-width: 3.75rem;
    }

    .year-grid-table {
        min-width: calc(12 * 3.75rem + 2.2rem);
    }

    /* Vue Année : navigation repliable sur petits écrans */
    .year-grid-nav-years {
        flex-wrap: wrap;
        gap: 0.35rem 0.4rem;
    }

    .yg-month-select {
        font-size: 0.68rem;
        padding: 0.18rem 0.25rem;
        max-width: 5.5rem;
        width: 5.5rem;
    }

    .fc-event.fc-event-tivoli .fc-event-title,
    .fc-event.fc-event-tivoli .fc-event-time,
    .fc-event.fc-event-tivoli .tivoli-ev-body {
        font-size: 0.68rem;
        line-height: 1.2;
    }

    .fc-daygrid-dot-event.fc-event-tivoli .fc-event-title {
        font-size: 0.62rem;
    }

    .yg-chip {
        font-size: 0.58rem;
    }
}

@media (max-width: 640px) {
    /* Vue Semaine : en-têtes de colonnes compacts */
    .fc-timegrid .fc-col-header-cell-cushion {
        font-size: 0.72rem;
        padding: 0.2rem 0.05rem;
        white-space: normal;
        line-height: 1.2;
        text-align: center;
        display: block;
    }

    .fc-timeGridWeek-view,
    .fc-timeGridDay-view {
        --fc-timegrid-axis-width: clamp(2.35rem, 12vw, 3.1rem);
    }

    .tivoli-all-day-label__icon {
        width: 0.85rem;
        height: 0.85rem;
    }

    .fc .fc-timegrid-slot-label-cushion {
        font-size: 0.64rem;
        padding-inline: 0.1rem;
    }

    /* Texte des événements (mois, semaine, jour) */
    .fc-event.fc-event-tivoli .fc-event-title,
    .fc-event.fc-event-tivoli .fc-event-time,
    .fc-event.fc-event-tivoli .tivoli-ev-body {
        font-size: 0.62rem !important;
        line-height: 1.18;
    }

    .fc-daygrid-dot-event.fc-event-tivoli .fc-event-title {
        font-size: 0.58rem !important;
    }

    .fc-daygrid-block-event .fc-event-tivoli .fc-event-main,
    .fc-daygrid-dot-event .fc-event-tivoli .fc-event-main {
        padding: 0 1px;
    }

    .ev-badge {
        font-size: 0.65em;
    }

    .ev-recur-icon {
        font-size: 0.68em;
    }

    .yg-chip {
        font-size: 0.56rem;
        padding: 0.06rem 0.1rem 0.06rem 0.2rem;
    }

    .yg-badge {
        font-size: 0.78em;
    }

    /* Numéros de jours et en-têtes de colonnes */
    .fc .fc-daygrid-day-number,
    .fc .fc-col-header-cell-cushion {
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    /* Chips sidebar : taille réduite, pas de largeur forcée */
    .level-chip {
        font-size: 0.8rem;
        padding: 0.32rem 0.6rem;
    }

    /* Sous-chips encore plus compacts */
    .level-group-row--sub .level-chip {
        font-size: 0.73rem;
        padding: 0.22rem 0.45rem;
    }

    /* Sous-groupe : indentation réduite sur très petit écran */
    .level-subgroup {
        padding-left: 0.5rem;
        margin-left: 0.15rem;
    }

    /* Boutons ✏/🌐 cachés sur très petit écran */
    .btn-edit-subcat,
    .btn-toggle-vis {
        display: none;
    }

    /* Bouton + encore plus petit */
    .btn-add-subcat {
        width: 1.1rem;
        height: 1.1rem;
        font-size: 0.75rem;
    }

    .event-levels .event-level-chip {
        width: 100%;
        justify-content: flex-start;
    }

    .level-toggle-bar {
        flex-wrap: wrap;
    }

    .btn-filter-toggle {
        flex: 1 1 calc(50% - 0.2rem);
        min-height: 2.5rem;
    }

    #event-dialog {
        width: 100%;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }

    #event-form {
        padding: 1rem var(--page-gutter);
    }

    .fc .fc-daygrid-day-number,
    .fc .fc-col-header-cell-cushion {
        font-size: 0.78rem;
    }

    /* Vue Semaine : ultra-compact */
    .fc-timegrid .fc-col-header-cell-cushion {
        font-size: 0.62rem;
        padding: 0.1rem 0;
        white-space: normal;
        line-height: 1.2;
        text-align: center;
    }

    .fc-timeGridWeek-view,
    .fc-timeGridDay-view {
        --fc-timegrid-axis-width: clamp(2rem, 13vw, 2.65rem);
    }

    .fc-timeGridWeek-view .fc-timegrid-axis-cushion:has(.tivoli-all-day-label),
    .fc-timeGridDay-view .fc-timegrid-axis-cushion:has(.tivoli-all-day-label) {
        min-height: 2.1rem;
        padding: 0.15rem 0.08rem;
    }

    .tivoli-all-day-label {
        font-size: 0.52rem;
        gap: 0.08rem;
    }

    .tivoli-all-day-label__icon {
        width: 0.75rem;
        height: 0.75rem;
    }

    .tivoli-all-day-label__text--full {
        display: none;
    }

    .tivoli-all-day-label__text--short {
        display: block;
    }

    .fc .fc-timegrid-slot-label-cushion {
        font-size: 0.58rem;
        padding-inline: 0.05rem;
    }

    /* Réduire la hauteur des créneaux pour limiter le scroll vertical */
    .fc .fc-timegrid-slot {
        height: 1.4em;
    }

    /* Événements : encore plus compacts */
    .fc-event.fc-event-tivoli .fc-event-title,
    .fc-event.fc-event-tivoli .fc-event-time,
    .fc-event.fc-event-tivoli .tivoli-ev-body {
        font-size: 0.55rem !important;
        line-height: 1.15;
    }

    .fc-daygrid-dot-event.fc-event-tivoli .fc-event-title {
        font-size: 0.52rem !important;
    }

    .ev-badge {
        font-size: 0.62em;
    }

    .ev-recur-icon {
        font-size: 0.65em;
    }

    /* Vue Année : cellules encore plus petites */
    .yg-cell {
        min-width: 2.75rem;
    }

    .year-grid-table {
        min-width: calc(12 * 2.75rem + 2.2rem);
    }

    .yg-chip {
        font-size: 0.52rem;
        padding: 0.04rem 0.08rem 0.04rem 0.2rem;
        line-height: 1.15;
    }

    .yg-badge {
        font-size: 0.75em;
    }

    .yg-dow {
        font-size: 0.52rem;
    }

    .yg-month-select {
        font-size: 0.62rem;
        max-width: 4.5rem;
        width: 4.5rem;
        padding: 0.15rem 0.2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}

/* ——— Titres d'événements : wrapping autorisé (toutes vues) ——— */
.fc-daygrid-block-event .fc-event-tivoli .fc-event-title,
.fc-h-event.fc-event-tivoli .fc-event-title,
.fc-v-event.fc-event-tivoli .fc-event-title {
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    line-height: 1.3;
    text-overflow: unset;
}

/* ——— Bouton impression dans la sidebar ——— */
.sidebar-print-bar {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-print,
.btn-export,
.btn-copy-table {
    width: 100%;
    font-size: 0.82rem;
}

/* ——— Tableau copiable (aperçu avant copie) ——— */
.copy-table-dialog {
    border: none;
    border-radius: 12px;
    padding: 1.2rem 1.4rem 1rem;
    box-shadow: 0 8px 32px rgba(15,23,42,0.22);
    width: min(1040px, calc(100% - 2rem));
    max-width: none;
    max-height: 88vh;
}

/* `display` n'est posé que sur le dialogue ouvert : sans le sélecteur [open],
   la règle écraserait le `display:none` du navigateur et le tableau resterait
   visible en permanence. */
.copy-table-dialog[open] {
    display: flex;
    flex-direction: column;
}

.copy-table-dialog::backdrop {
    background: rgba(15,23,42,0.35);
}

.copy-table-meta {
    margin: 0 0 0.6rem;
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.copy-table-count {
    font-weight: 600;
    color: var(--tivoli-blue);
}

.copy-table-preview {
    flex: 1 1 auto;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
}

.copy-table-preview table {
    width: 100%;
}

.copy-table-empty {
    margin: 0;
    padding: 1rem;
    text-align: center;
    font-style: italic;
    color: var(--muted);
}

.copy-table-hint {
    margin: 0.6rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

/* ——— Vue Liste (grille hebdomadaire) ——— */
.calendar-main.is-list-view {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-top: 3px solid var(--tivoli-gold);
    overflow-x: visible;
}

.calendar-main.is-list-view #calendar {
    background: transparent;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding-bottom: 0;
    min-width: 0;
    overflow: hidden;
    /* La zone calendrier ne sert que de barre d'outils : elle ne doit pas conserver
       la hauteur figée par FullCalendar (le harness est masqué). Sans cela, #calendar
       occupe toute la place et écrase la grille de la vue Liste. */
    height: auto !important;
    min-height: 0 !important;
}

.calendar-main.is-list-view #calendar > .fc {
    height: auto !important;
    min-height: 0 !important;
}

.calendar-main.is-list-view #calendar .fc-view-harness,
.calendar-main.is-list-view #calendar .fc-scrollgrid {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
}

.calendar-main.is-list-view #calendar .fc-header-toolbar {
    margin-bottom: 0.65rem;
}

.calendar-main.is-list-view #list-grid-wrap {
    padding: 0 0.85rem 0.85rem;
}

.list-grid-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.list-grid-nav-title {
    font-family: var(--font-heading);
    font-size: clamp(0.95rem, 3.5vw, 1.15rem);
    font-weight: 700;
    color: var(--tivoli-blue);
    text-align: center;
    white-space: nowrap;
    /* Largeur de confort pour éviter que les chevrons ne dansent d'une année à
       l'autre — mais jamais au prix d'un débordement sur petit écran. */
    min-width: min(12rem, 100%);
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-grid-scroll {
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    isolation: isolate;
    max-height: calc(100vh - 230px);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.list-grid-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
    width: 100%;
}

.list-grid-table th,
.list-grid-table td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0.28rem 0.4rem;
    vertical-align: top;
}

.list-grid-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    text-align: center;
    vertical-align: middle;
}

.list-grid-table thead tr:first-child th {
    height: 1.75rem;
}

.list-grid-table thead tr:nth-child(2) th {
    top: 1.75rem;
    z-index: 3;
}

.lg-cat-head {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

.lg-sub-head {
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--tivoli-blue);
    line-height: 1.15;
}

.lg-corner {
    background: var(--tivoli-blue);
    color: #fff;
    position: sticky;
    left: 0;
    font-size: 0.72rem;
}

/* Le coin figé (« Sem. » / « Semaine du ») doit rester au-dessus des intitulés
   de catégories, qui défilent en dessous de lui. Sélecteur aligné sur celui de
   `.list-grid-table thead th` : à spécificité égale, `.lg-corner` seul perdait
   son z-index et l'ordre du DOM faisait passer les intitulés devant. */
.list-grid-table thead th.lg-corner {
    z-index: 6;
}

.lg-corner.lg-du {
    left: 2.8rem;
}

.lg-sem {
    width: 2.8rem;
    min-width: 2.8rem;
    text-align: center;
}

.lg-du {
    width: 5rem;
    min-width: 5rem;
    text-align: center;
    white-space: nowrap;
}

.list-grid-table tbody .lg-sem,
.list-grid-table tbody .lg-du {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #f4f6fa;
    font-weight: 600;
    color: var(--tivoli-blue);
    text-align: center;
    vertical-align: middle;
}

.list-grid-table tbody .lg-du {
    left: 2.8rem;
}

.lg-cell {
    min-width: 8rem;
}

/* Même affordance qu'en vue Année (.yg-cell--can-create) */
.lg-cell--can-create {
    cursor: pointer;
}

.lg-cell--can-create:hover {
    outline: 1px dashed rgba(30, 58, 95, 0.35);
    outline-offset: -1px;
}

.lg-vacation {
    background: var(--cal-vacation-bg); /* gris, comme la vue Année */
    color: #3f4b5c;
    font-weight: 700;
    font-style: italic;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.lg-chip {
    display: block;
    border-left: 3px solid;
    border-radius: 4px;
    padding: 0.14rem 0.4rem;
    margin-bottom: 0.22rem;
    font-size: 0.74rem;
    line-height: 1.2;
    cursor: pointer;
    word-break: break-word;
}

.lg-chip:last-child {
    margin-bottom: 0;
}

.lg-chip:hover {
    filter: brightness(0.97);
}

/* Jour de l'événement, en tête de puce */
.lg-chip-day {
    font-weight: 700;
    margin-right: 0.28rem;
    opacity: 0.82;
    font-variant-numeric: tabular-nums;
}

/* Pastille(s) de configuration Espace Duvoisin du jour de l'événement */
.lg-chip-duv {
    display: inline-flex;
    gap: 2px;
    margin-left: 0.32rem;
    vertical-align: middle;
}

.lg-chip-duv-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

/* ——— Vue grille annuelle (carte unique via .calendar-main.is-year-view) ——— */
.fc-year-grid-hidden {
    display: none !important;
}

.calendar-main.is-year-view {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-top: 3px solid var(--tivoli-gold);
    overflow-x: visible; /* Pas de scroll container : year-grid-scroll gère le sien */
}

.calendar-main.is-year-view #calendar {
    background: transparent;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding-bottom: 0;
    min-width: 0;
    overflow: hidden;
}

.calendar-main.is-year-view #calendar .fc-view-harness,
.calendar-main.is-year-view #calendar .fc-scrollgrid {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
}

.calendar-main.is-year-view #year-grid-wrap {
    margin: 0;
    padding: 0 0.85rem 0.85rem;
    background: transparent;
    box-shadow: none;
    border: none;
    border-radius: 0;
}

.calendar-main.is-year-view #calendar .fc-header-toolbar {
    margin-bottom: 0.65rem;
}

.year-grid-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.85rem;
}

.year-grid-nav-years {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    min-width: 0;
}

/* Les deux sélecteurs de bornes forment un couple : ils passent à la ligne
   ensemble plutôt que de se retrouver l'un au-dessus de l'autre. */
.yg-month-range {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.year-grid-nav-views {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.year-grid-nav-title {
    font-family: var(--font-heading);
    font-size: clamp(0.95rem, 3.5vw, 1.15rem);
    font-weight: 700;
    color: var(--tivoli-blue);
    min-width: 3rem;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    min-height: unset;
    font-size: 0.82rem;
}

.yg-month-select {
    font: inherit;
    font-size: 0.72rem;
    padding: 0.22rem 0.3rem;
    max-width: 6.5rem;
    width: 6.5rem;
    flex-shrink: 1;
    min-width: 0;
    border: 2px solid var(--tivoli-blue);
    border-radius: 8px;
    background: #fff;
    color: var(--tivoli-blue);
    cursor: pointer;
}

.yg-month-select:focus {
    outline: 2px solid var(--tivoli-gold);
    outline-offset: 1px;
}

.year-grid-scroll {
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    isolation: isolate;
}

.year-grid-table {
    width: 100%;
    min-width: calc(12 * 5rem + 2.2rem); /* 12 mois × min-cell + coin */
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.72rem;
    table-layout: fixed;
}

.year-grid-table thead {
    position: sticky;
    top: 0;
    z-index: 4;
}

.year-grid-table thead tr {
    background: var(--card);
}

.yg-corner {
    width: 2.2rem;
    min-width: 2.2rem;
    position: sticky;
    left: 0;
    top: 0;
    z-index: 6;
    background: var(--card);
    background-clip: padding-box;
    /* Masque le contenu qui défile juste au-dessus de la ligne des mois */
    box-shadow: -8px -10px 0 10px var(--card), 8px 0 0 0 var(--card);
}

.yg-month-header {
    padding: 0.35rem 0.2rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--tivoli-blue);
    border-bottom: 2px solid var(--tivoli-blue);
    white-space: nowrap;
    background: var(--card);
    background-clip: padding-box;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 -10px 0 10px var(--card);
}

.yg-month-clickable {
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s;
}

.yg-month-clickable:hover {
    background-color: var(--tivoli-blue);
    color: #fff;
}

.yg-month-year {
    display: block;
    font-size: 0.62rem;
    font-weight: 500;
    opacity: 0.75;
    line-height: 1.1;
}

.yg-day-label {
    text-align: center;
    font-weight: 700;
    font-size: 0.68rem;
    color: var(--muted);
    padding: 0.1rem 0.15rem;
    border-right: 2px solid var(--border);
    background: var(--card);
    position: sticky;
    left: 0;
    z-index: 1;
    white-space: nowrap;
    vertical-align: top;
}

.yg-cell {
    border: 1px solid var(--border);
    padding: 0.1rem 0.15rem;
    vertical-align: top;
    min-width: 5rem;
    min-height: 1.4rem;
}

.yg-cell--void {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.yg-cell--vacation {
    background: var(--cal-vacation-bg);
}

.yg-cell--holiday:not(.yg-cell--vacation) {
    background: var(--cal-holiday-bg);
}

.yg-cell--weekend:not(.yg-cell--vacation) {
    background: var(--cal-weekend-bg);
}

.yg-vacation-label {
    display: block;
    font-size: 0.58em;
    color: #4a5a6e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-top: 1px;
    font-style: italic;
}

.yg-cell--can-create {
    cursor: pointer;
}

.yg-cell--can-create:hover {
    outline: 1px dashed rgba(30, 58, 95, 0.35);
    outline-offset: -1px;
}

.yg-dow {
    display: block;
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--muted);
    line-height: 1.1;
    margin-bottom: 0.05rem;
    letter-spacing: 0.02em;
}

.yg-chip {
    display: block;
    font-size: 0.65rem;
    line-height: 1.25;
    padding: 0.1rem 0.2rem 0.1rem 0.35rem;
    border-radius: 2px;
    margin-bottom: 0.1rem;
    cursor: pointer;
    /* Levier 2 : chip sur une seule ligne + « … » → hauteur des jours chargés
       fortement réduite. Titre complet au survol (title) et à l'impression
       (le bloc @media print rétablit white-space:normal). */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 600;
    border-left: 3px solid transparent;
    transition: opacity 0.1s;
}

.yg-chip:hover {
    opacity: 0.78;
}

.yg-badge {
    display: inline-block;
    font-size: 0.85em;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.13);
    border-radius: 2px;
    padding: 0 0.22em;
    margin-right: 0.2em;
    vertical-align: baseline;
    letter-spacing: 0.01em;
    opacity: 0.85;
}

.ev-badge {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 700 !important;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
    padding: 0.05em 0.28em;
    margin-right: 0.3em;
    vertical-align: middle;
    opacity: 0.85;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.ev-recur-icon {
    display: inline-block;
    font-size: 0.8em;
    margin-left: 0.25em;
    opacity: 0.55;
    vertical-align: middle;
    font-style: normal;
    line-height: 1;
}

.yg-chip[draggable="true"] {
    cursor: grab;
}

.yg-chip--dragging {
    opacity: 0.35;
    cursor: grabbing;
}

.yg-cell--drag-over {
    outline: 2px solid #1e3a5f;
    outline-offset: -2px;
    background: rgba(30, 58, 95, 0.1) !important;
}

.yg-loading,
.yg-error {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.yg-error {
    color: var(--danger);
}

/* ——— En-tête d'impression (invisible en ligne) ——— */
#print-header {
    display: none;
}

/* ——— Impression ——— */
@media print {
    /* Pas de size/orientation ici : le choix reste dans la boîte d'impression du navigateur */
    @page {
        margin: 10mm;
    }

    #print-header {
        display: block !important;
        padding-bottom: 0.6rem;
        margin-bottom: 0.75rem;
        border-bottom: 2px solid #1e3a5f;
    }

    .print-header-top {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        margin-bottom: 0.3rem;
    }

    .print-header-title {
        font-size: 15pt;
        font-weight: 700;
        color: #1e3a5f;
        font-family: Georgia, serif;
    }

    .print-header-date {
        font-size: 8pt;
        color: #555;
        font-style: italic;
        white-space: nowrap;
    }

    .print-header-categories {
        display: flex;
        align-items: center;
        gap: 0.3rem;
        flex-wrap: wrap;
        font-size: 8pt;
    }

    .print-header-label {
        font-weight: 700;
        color: #1e3a5f;
        margin-right: 0.2rem;
    }

    .print-cat-chip {
        display: inline-block;
        padding: 1pt 5pt;
        border-radius: 3pt;
        font-size: 7.5pt;
        font-weight: 600;
        color: #152a45;
    }

    .app-header,
    .app-footer,
    .page-actions,
    .calendar-sidebar,
    .fc-toolbar,
    .year-grid-nav,
    .list-grid-nav,
    #event-dialog,
    .btn-print {
        display: none !important;
    }

    body {
        background: #fff !important;
        font-size: 10pt;
        display: block !important;
        min-height: auto !important;
        overflow: visible !important;
    }

    body:not(.login-page) > main {
        flex: none !important;
    }

    .calendar-wrap {
        display: block !important;
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .calendar-main {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    .calendar-main.is-year-view {
        height: auto !important;
        overflow: visible !important;
    }

    .calendar-main.is-year-view #calendar,
    .calendar-main.is-year-view #year-grid-wrap,
    .calendar-main.is-year-view #year-grid {
        flex: none !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    /* Vue Liste : déplier entièrement pour l'impression */
    .calendar-main.is-list-view,
    .calendar-main.is-list-view #calendar,
    .calendar-main.is-list-view #list-grid-wrap,
    .calendar-main.is-list-view #list-grid {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    .list-grid-scroll {
        max-height: none !important;
        overflow: visible !important;
        border: none !important;
    }

    .list-grid-table {
        font-size: 8pt !important;
    }

    .list-grid-table thead th,
    .list-grid-table tbody .lg-sem,
    .list-grid-table tbody .lg-du {
        position: static !important;
    }

    .list-grid-table thead {
        display: table-header-group;
    }

    .list-grid-table tr,
    .lg-chip {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    #calendar,
    #year-grid-wrap,
    #list-grid-wrap {
        box-shadow: none !important;
        border-top: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    #calendar .fc {
        height: auto !important;
        min-height: 0 !important;
    }

    /* FullCalendar : déplier les zones scrollables (hauteur viewport en ligne) */
    #calendar .fc-view-harness,
    #calendar .fc-scroller-harness,
    #calendar .fc-scroller-harness-liquid,
    #calendar .fc-scroller,
    #calendar .fc-scroller-liquid-absolute,
    #calendar .fc-scrollgrid,
    #calendar .fc-scrollgrid-section-body table,
    #calendar .fc-daygrid-body,
    #calendar .fc-timegrid-body {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        position: static !important;
    }

    /* Titres complets dans la vue mois/semaine */
    .fc-event-tivoli .fc-event-title {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        word-break: break-word !important;
    }

    /* Grille annuelle : police réduite pour tout faire tenir */
    .year-grid-table {
        font-size: 6pt !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .yg-month-header {
        font-size: 7pt !important;
        position: static !important;
        box-shadow: none !important;
    }

    .yg-day-label {
        font-size: 6pt !important;
        position: static !important;
    }

    .yg-chip {
        font-size: 5.5pt !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        border-left-width: 2px !important;
    }

    .year-grid-scroll {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }

    .year-grid-table thead,
    .yg-corner {
        position: static !important;
        box-shadow: none !important;
    }

    .yg-cell {
        min-width: 0 !important;
    }

    /* Masquer le nom du jour (trop petit à l'impression) */
    .yg-dow {
        display: none !important;
    }

    .yg-month-year {
        font-size: 6pt !important;
    }
}

/* ——— Écran bas en paysage (téléphone couché, fenêtre écrasée) ———
   Ici la hauteur est la ressource rare et la largeur est abondante. Les vues
   Année et Liste sont les seules à en souffrir vraiment : elles bornent leur
   grille à la fenêtre et défilent à l'intérieur, au lieu de laisser la page
   s'allonger comme le font Mois / Semaine / Jour. Chaque pixel pris par le
   décor est donc un pixel de grille en moins, et il n'y en a qu'une poignée à
   partager.
   On rabote donc l'air, pas le contenu : mêmes commandes, mêmes libellés.
   Bloc placé en fin de feuille à dessein — il doit l'emporter sur ceux de
   ≤1100px, ≤900px et ≥1101px, qui portent la même spécificité. */
@media (orientation: landscape) and (max-height: 32rem) {
    .calendar-wrap {
        padding-block: 0.35rem;
        gap: 0.4rem;
    }

    body.embed .calendar-wrap { padding-top: 0.35rem; }

    /* Le volet replié redevient ce qu'il est : un bandeau d'appel. */
    .calendar-sidebar.is-collapsed { padding: 0.1rem 0.5rem; }
    .calendar-sidebar.is-collapsed .sidebar-title { font-size: 0.85rem; }

    .calendar-sidebar.is-collapsed .sidebar-toggle-btn {
        width: 1.6rem;
        height: 1.6rem;
    }

    /* ——— La grille reprend sa hauteur naturelle, c'est la PAGE qui défile ———
       Ailleurs, Année et Liste se bornent à la fenêtre et défilent dans leur
       carte : la barre de commandes et le volet restent alors visibles en
       permanence. Sur un écran aussi bas, ce cadre figé coûte plus qu'il ne
       rapporte — il ne restait qu'une poignée de lignes au centre. En laissant
       la page défiler, comme le font déjà Mois / Semaine / Jour à cette
       largeur, le décor s'efface au premier geste et toute la hauteur revient
       à la grille.
       Le défilement HORIZONTAL reste, lui, dans .year-grid-scroll : sa boîte
       garde overflow:auto mais n'est plus bornée en hauteur, donc elle ne
       déclenche que la barre du bas. (Un overflow-y:visible en face d'un
       overflow-x:auto serait recalculé en auto par le moteur : il faut bien
       lever la contrainte de hauteur, pas déclarer visible.) */
    .calendar-wrap:has(.calendar-main.is-year-view),
    .calendar-wrap:has(.calendar-main.is-list-view) {
        grid-template-rows: max-content auto;
        align-items: start;
        align-content: start;
    }

    .calendar-main.is-year-view,
    .calendar-main.is-list-view {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .calendar-main.is-year-view #year-grid-wrap,
    .calendar-main.is-list-view #list-grid-wrap,
    .calendar-main.is-year-view #year-grid,
    .calendar-main.is-list-view #list-grid {
        flex: none;
        min-height: 0;
    }

    .calendar-main.is-year-view .year-grid-scroll,
    .calendar-main.is-list-view .list-grid-scroll {
        flex: none;
        height: auto;
        min-height: 0;
        max-height: none;

        /* La boîte reste un conteneur de défilement — overflow:auto lui est
           nécessaire pour l'axe horizontal, et un overflow-y:visible en face
           serait de toute façon recalculé en auto. Elle capte donc le geste
           vertical. `contain` lui interdisait alors de le repasser à la page :
           le doigt posé sur la grille ne faisait rien, il fallait viser la
           marge. On rétablit la propagation — sans hauteur à faire défiler,
           le geste vertical revient intégralement à la page.
           Le confinement garde tout son sens ailleurs, où la grille défile
           pour de bon et ne doit pas entraîner la page derrière elle. */
        overscroll-behavior: auto;
        -webkit-overflow-scrolling: auto;
    }

    /* Barre de commandes : elle passe volontiers sur deux lignes à cette
       largeur, d'où l'attention portée à la hauteur de chaque ligne. */
    #calendar { padding: 0.3rem; }

    #calendar .fc-header-toolbar { gap: 0.3rem 0.5rem; }

    .fc .fc-button {
        min-height: 2rem;
        padding-block: 0.25rem;
    }

    .fc .fc-toolbar-title { font-size: 0.95rem; }

    .calendar-main.is-year-view #calendar .fc-header-toolbar,
    .calendar-main.is-list-view #calendar .fc-header-toolbar {
        margin-bottom: 0.35rem;
    }

    /* Les chevrons d'année sont remontés dans la barre (cf. .fc-header-toolbar
       > .year-grid-nav-years) : ces boîtes ne gardent souvent que leur marge. */
    .year-grid-nav,
    .list-grid-nav { margin-bottom: 0.2rem; }

    .calendar-main.is-year-view #year-grid-wrap,
    .calendar-main.is-list-view #list-grid-wrap {
        padding-bottom: 0.35rem;
    }
}
