:root {
    --bg: #f7f5f2;
    --surface: #ffffff;
    --fg: #2a2724;
    --muted: #9b958c;
    --line: #e7e2db;
    --accent: #2a2724;
    --accent-fg: #ffffff;
    --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
    --sans: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 6px;
    --gap: 12px;
    --topbar-h: 60px;
}

* { box-sizing: border-box; }

/* L'attribut hidden doit toujours l'emporter sur les display des composants */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* --- Topbar --- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    background: rgba(247, 245, 242, 0.85);
    backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar__inner {
    max-width: 1600px;
    margin: 0 auto;
    height: 100%;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar__nav { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__logo { display: inline-flex; align-items: center; gap: 9px; flex: none; }
.topbar__logo-icon { display: block; }
.topbar__logo-text { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; letter-spacing: .3px; }
.topbar__logo:hover { opacity: .7; }
.topbar__sep { color: var(--line); font-size: 1.2rem; flex: none; }
.topbar__brand {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: .3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar__back {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 16px 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 400;
    max-width: 52vw;
    transition: background .18s, border-color .18s;
}
.topbar__back:hover { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.topbar__back span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__back-arrow { font-size: 1.3rem; line-height: 1; margin-top: -2px; }
.topbar__logout {
    font-size: .78rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}
.topbar__logout:hover { color: var(--fg); }

.main { min-height: calc(100vh - var(--topbar-h) - 70px); }
.container { max-width: 1600px; margin: 0 auto; padding: 36px 28px 80px; }
.page-title { font-family: var(--serif); font-size: 2rem; font-weight: 600; margin: 0 0 24px; }
.muted { color: var(--muted); }

/* --- Cartes centrées (login, erreurs) --- */
.centered {
    min-height: calc(100vh - var(--topbar-h) - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .05);
}
.card--narrow { width: 100%; max-width: 400px; }
.card h1 { font-family: var(--serif); margin: 0 0 8px; font-size: 2rem; font-weight: 600; }

/* --- Formulaires --- */
.login label, .modal label { display: block; margin: 18px 0; }
label > span {
    display: block;
    font-size: .74rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 7px;
}
input[type=text], input[type=password], input[type=email] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--sans);
    background: #fff;
}
input:focus { outline: none; border-color: var(--accent); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: #fff;
    color: var(--fg);
    font-family: var(--sans);
    font-size: .8rem;
    font-weight: 500;
    letter-spacing: .1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .18s, color .18s, transform .18s;
}
.btn:hover { background: var(--accent); color: var(--accent-fg); }
.btn--primary { background: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { transform: translateY(-1px); }
.btn--ghost { border-color: var(--line); }
.login .btn { width: 100%; justify-content: center; margin-top: 10px; }

.alert { padding: 11px 14px; border-radius: var(--radius); font-size: .9rem; margin: 14px 0; }
.alert--error { background: #fbeceb; color: #a5201e; }
.alert--ok { background: #ecf5ee; color: #1d7a34; }

/* --- Cover / hero plein cadre (galerie, album) --- */
.cover {
    position: relative;
    min-height: 52vh;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    text-align: center;
    background-color: #2a2724;
    background-image: var(--cover);
    background-size: cover;
    background-position: center;
}
.cover--album { min-height: 42vh; }
.cover__scrim {
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, .55), rgba(0, 0, 0, .12) 55%, rgba(0, 0, 0, .25));
}
.cover__content { position: relative; z-index: 1; color: #fff; padding: 0 20px 56px; }
.cover__crumb {
    font-size: .76rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    margin-bottom: 14px;
    opacity: .92;
}
.cover__crumb a { border-bottom: 1px solid rgba(255, 255, 255, .5); padding-bottom: 2px; }
.cover__title {
    font-family: var(--serif);
    font-weight: 500;
    font-size: clamp(2.4rem, 6vw, 4.4rem);
    line-height: 1.05;
    margin: 0;
    text-shadow: 0 2px 24px rgba(0, 0, 0, .3);
}
.cover__meta {
    margin: 14px 0 0;
    font-size: .8rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    opacity: .9;
}

/* --- Accueil : hero + grille de galeries --- */
.hero {
    background: linear-gradient(135deg, #2a2724 0%, #4a443c 100%);
    color: #fff;
    text-align: center;
    padding: 90px 20px 110px;
}
.hero__inner { max-width: 760px; margin: 0 auto; }
.hero__title { font-family: var(--serif); font-weight: 500; font-size: clamp(2.6rem, 6vw, 4rem); margin: 0 0 12px; }
.hero__subtitle { font-size: 1rem; letter-spacing: .04em; margin: 0; color: rgba(255, 255, 255, .8); }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 28px;
    margin-top: -60px;
}
.gcard {
    display: block;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
    transition: transform .25s, box-shadow .25s;
}
.gcard:hover { transform: translateY(-5px); box-shadow: 0 20px 48px rgba(0, 0, 0, .16); }
.gcard__cover { position: relative; aspect-ratio: 3 / 2; background: #e6e1da; overflow: hidden; }
.gcard__cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.gcard:hover .gcard__cover img { transform: scale(1.06); }
.gcard__overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .3), transparent 50%); }
.gcard__mono {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6b6459, #35312b);
    color: #fff;
}
.gcard__mono span { font-family: var(--serif); font-size: 3.4rem; font-weight: 600; opacity: .92; }
.gcard__lock { position: absolute; top: 14px; right: 14px; background: rgba(0, 0, 0, .45); border-radius: 999px; padding: 4px 9px; font-size: .85rem; line-height: 1; }
.gcard__body { padding: 16px 18px; }
.gcard__name { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; display: block; }
.gcard__meta { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* --- Grille des albums (dans une galerie) --- */
.albums {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 26px;
}
.album-card {
    display: block;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .07);
    transition: transform .25s, box-shadow .25s;
}
.album-card:hover { transform: translateY(-4px); box-shadow: 0 18px 44px rgba(0, 0, 0, .14); }
.album-card__cover { position: relative; aspect-ratio: 4 / 3; background: #e6e1da; overflow: hidden; }
.album-card__cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.album-card:hover .album-card__cover img { transform: scale(1.05); }
.album-card__shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .5), transparent 55%); }
.album-card__label {
    position: absolute; left: 18px; bottom: 14px; z-index: 1;
    color: #fff; font-family: var(--serif); font-weight: 600; font-size: 1.45rem;
    text-shadow: 0 1px 10px rgba(0, 0, 0, .4);
}
.album-card__empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.album-card__meta { padding: 12px 18px; }
.album-card__count { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* --- Onglets d'albums (navigation dans la galerie) --- */
.album-tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 20px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}
.album-tab {
    flex: none;
    padding: 8px 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .9rem;
    color: var(--muted);
    white-space: nowrap;
    transition: background .18s, color .18s, border-color .18s;
}
.album-tab:hover { color: var(--fg); border-color: var(--muted); }
.album-tab.is-current { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* --- Entête album --- */
.album-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.album-hint { margin: 0; font-size: .92rem; }

/* --- Pagination entre albums (bas de page) --- */
.album-pager {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 48px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}
.album-pager__link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 48%;
    padding: 14px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: background .18s, border-color .18s, transform .18s;
}
.album-pager__link:hover { border-color: var(--muted); transform: translateY(-2px); }
.album-pager__next { text-align: right; margin-left: auto; }
.album-pager__dir { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.album-pager__name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Loader de génération des vignettes --- */
.warmloader {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    margin-bottom: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .05);
}
.warmloader__spinner {
    flex: none;
    width: 26px; height: 26px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.warmloader__body { flex: 1; min-width: 0; }
.warmloader__text { font-size: .9rem; color: var(--fg); }
.warmloader__bar { margin-top: 8px; height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; }
.warmloader__bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s ease; }

/* --- Masonry --- */
.masonry { display: flex; align-items: flex-start; gap: var(--gap); }
.masonry__col { flex: 1 1 0; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.tile {
    position: relative;
    border-radius: 3px;
    overflow: hidden;
    background: #e6e1da;
    cursor: pointer;
}
.tile img { width: 100%; height: auto; display: block; opacity: 0; transition: opacity .5s ease, transform .5s ease; }
.tile img.loaded { opacity: 1; }
.tile:hover img.loaded { transform: scale(1.03); }
.tile__play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.tile__play::after {
    content: "";
    width: 60px; height: 60px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") no-repeat 56% center;
}
.tile__check {
    position: absolute; top: 10px; left: 10px;
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    display: none; align-items: center; justify-content: center; z-index: 2;
}
body.selecting .tile__check { display: flex; }
.tile.selected .tile__check { background: var(--accent); }
.tile.selected .tile__check::after {
    content: ""; width: 14px; height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") no-repeat center;
}
body.selecting .tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }

/* --- Barre de sélection flottante --- */
.selbar {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
    z-index: 50; display: flex; align-items: center; gap: 16px;
    padding: 12px 14px 12px 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .2);
}
.selbar__count { font-weight: 500; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }

/* --- Modale --- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal__box {
    position: relative; width: 100%; max-width: 440px; margin: 20px;
    background: var(--surface); border-radius: var(--radius); padding: 36px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.modal__box h2 { font-family: var(--serif); margin: 0 0 6px; font-size: 1.7rem; font-weight: 600; }
.modal__close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 1.9rem; line-height: 1; color: var(--muted); cursor: pointer; }
.modal__hint { font-size: .85rem; margin: 14px 0 0; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* --- Lightbox --- */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(12, 11, 10, .96); display: flex; align-items: center; justify-content: center; }
.lightbox__stage { max-width: 92vw; max-height: 88vh; display: flex; align-items: center; justify-content: center; }
.lightbox__stage img, .lightbox__stage video { max-width: 92vw; max-height: 88vh; width: auto; height: auto; box-shadow: 0 10px 50px rgba(0, 0, 0, .5); }
.lightbox__close, .lightbox__nav {
    position: absolute; background: rgba(255, 255, 255, .1); color: #fff; border: none;
    cursor: pointer; border-radius: 50%; width: 50px; height: 50px; font-size: 1.9rem;
    display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255, 255, 255, .25); }
.lightbox__close { top: 20px; right: 20px; }
.lightbox__nav--prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox__nav--next { right: 20px; top: 50%; transform: translateY(-50%); }

.footer { border-top: 1px solid var(--line); }
.footer__inner { max-width: 1600px; margin: 0 auto; padding: 24px 28px; color: var(--muted); font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; text-align: center; }

@media (max-width: 640px) {
    .container { padding: 24px 16px 70px; }
    .topbar__logo-text { display: none; }
    .topbar__back { max-width: 58vw; }
    .lightbox__nav { width: 42px; height: 42px; }
    .selbar { flex-wrap: wrap; justify-content: center; bottom: 12px; width: calc(100% - 24px); border-radius: 16px; }
    .gallery-grid { margin-top: -36px; }
    .album-actions { width: 100%; }
}
