:root {
    --bg: #E7F2F8;
    --bg-soft: #D3E6F0;
    --ink: #163024;
    --ink-soft: #4A6758;
    --rouge: #178A7C;
    --rouge-dark: #0F5F56;
    --vert: #2F5A3E;
    --gold: #C9A24A;
    --sky: #1E7AB8;
    --line: #C3D6CE;
    --white: #F7FBFC;
    --paper: #F7FBFC;
    --fx-error: #FDECEA;
    --fx-viewer: #0F241C;
    --fx-viewer-ink: #F6F1E8;
    --shadow: 0 14px 36px rgba(22, 48, 36, 0.12);
    --serif: "Outfit", "Segoe UI", sans-serif;
    --sans: "Source Sans 3", "Segoe UI", sans-serif;
    --bg-image: radial-gradient(ellipse at 50% -18%, rgba(126, 184, 220, .55), transparent 52%),
        linear-gradient(180deg, #B7D7EC 0%, #E7F2F8 34%, #F1EBD2 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background-color: var(--bg);
    background-image: var(--bg-image);
    color: var(--ink);
    font-family: var(--sans);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
button, input { font-family: inherit; }
a { color: var(--rouge); }

.wrap {
    width: min(560px, 100%);
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.brand {
    text-align: center;
    padding: 8px 0 20px;
}
.brand-cover,
.event-cover,
.brand-fairepart {
    width: 100%;
    margin: 0 auto 16px;
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 16px;
    aspect-ratio: 16 / 7;
    box-shadow: var(--shadow);
}
.brand-cover img,
.event-cover img,
.brand-fairepart img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center 58%;
}
.brand h1 {
    font-family: var(--serif);
    font-weight: 700;
    font-style: normal;
    font-size: clamp(28px, 8vw, 40px);
    margin: 0 0 6px;
    letter-spacing: 0.02em;
}
.brand .date {
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 12px;
    color: var(--sky);
}
.brand .lieu {
    margin-top: 4px;
    font-size: 13px;
    color: var(--ink-soft);
}
.brand .rule {
    width: 96px;
    height: 6px;
    border-radius: 2px;
    background: var(--gold);
    margin: 12px auto 0;
}
.lang-pick {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.lang-pick button {
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--ink);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}
.lang-pick button.on {
    border-color: var(--rouge);
    color: var(--rouge);
    font-weight: 700;
}
html[dir="rtl"] .hello-row { flex-direction: row-reverse; }
html[dir="rtl"] .previews .pv-rm,
html[dir="rtl"] .previews button { right: auto; left: 4px; }
html[dir="rtl"] .admin-trash { right: auto; left: 8px; }
html[dir="rtl"] .viewer-bar { text-align: right; }
html[dir="rtl"] .hint, html[dir="rtl"] .hello { text-align: right; }
html[dir="rtl"] .brand, html[dir="rtl"] .brand .rule { text-align: center; }
html[dir="rtl"] .dl-choice { text-align: right; }
html[dir="rtl"] .drop { text-align: center; }
html[dir="rtl"] .slide-go { direction: ltr; }

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px 18px;
    box-shadow: var(--shadow);
}

label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 8px;
}
input[type="text"] {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink);
    border-radius: 12px;
    padding: 14px 14px;
    font-size: 18px;
    outline: none;
}
input[type="text"]:focus { border-color: var(--rouge); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: 0;
    border-radius: 999px;
    padding: 15px 18px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--rouge); color: #fff; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-quiet {
    background: transparent;
    color: var(--ink-soft);
    border: 0;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 8px 10px;
    line-height: 1.35;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

body.visite-on #screen-prenom,
body.visite-on #screen-home,
body.visite-on #screen-upload,
body.visite-on #screen-download,
body.visite-on #btnUpload,
body.visite-on #btnDownloadAll,
body.visite-on #btnChangeName,
body.visite-on #btnAvatar,
body.visite-on #btnAvatarHint,
body.visite-on #btnShare,
body.visite-on #btnBackHome {
    display: none !important;
}

.hint { color: var(--ink-soft); font-size: 14px; line-height: 1.45; text-align: center; }
.error {
    background: var(--fx-error);
    color: var(--rouge-dark);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    margin: 10px 0;
}
.ok { color: var(--vert); text-align: center; }

.hidden { display: none !important; }
.change-name {
    display: block;
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--ink-soft);
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
}

.mosaic {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 18px 0 8px;
}
.mosaic img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    background: var(--bg-soft);
}
.count {
    text-align: center;
    color: var(--ink-soft);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.drop {
    border: 1.5px dashed var(--rouge);
    border-radius: 16px;
    padding: 28px 14px;
    text-align: center;
    background: color-mix(in srgb, var(--white) 70%, transparent);
    cursor: pointer;
}
.drop strong { display: block; margin: 8px 0 4px; }
.previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 10px;
    margin: 14px 0;
}
.previews .pv {
    position: relative;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.previews .pv:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.previews .pv.has-custom {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}
.previews img {
    width: 100%;
    height: 95px;
    object-fit: cover;
    display: block;
}
.previews .pv-rm {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: rgba(225, 29, 72, 0.9);
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    line-height: 24px;
    text-align: center;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
    transition: transform .12s ease, background .12s ease;
}
.previews .pv-rm:hover {
    background: var(--rouge);
    transform: scale(1.1);
}
.previews .pv-footer {
    padding: 5px 6px;
    font-size: 11px;
    line-height: 1.25;
    background: var(--paper);
    border-top: 1px solid var(--line);
    min-height: 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
}
.previews .pv.has-custom .pv-footer {
    background: rgba(201, 162, 74, 0.15);
}
.previews .pv-caption-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-soft);
    font-style: italic;
    flex: 1;
}
.previews .pv.has-custom .pv-caption-text {
    color: var(--ink);
    font-weight: 600;
    font-style: normal;
}
.caption-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    backdrop-filter: blur(2px);
}
.caption-modal.hidden {
    display: none !important;
}
.caption-modal-box {
    background: var(--card, #fff);
    border-radius: 16px;
    max-width: 380px;
    width: 100%;
    padding: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    border: 1px solid var(--line);
}
.caption-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.caption-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}
.caption-modal-close {
    background: none;
    border: 0;
    font-size: 22px;
    cursor: pointer;
    color: var(--ink-soft);
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
}
.caption-modal-body img {
    width: 100%;
    max-height: 160px;
    object-fit: contain;
    background: #000;
    border-radius: 10px;
    display: block;
    margin: 0 auto;
}
.caption-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}

.slide-go {
    position: relative;
    height: 56px;
    width: 100%;
    max-width: 420px;
    margin: 16px auto 10px;
    border-radius: 999px;
    background: var(--paper);
    border: 1px solid var(--line);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}
.slide-go span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    pointer-events: none;
    padding-left: 48px;
    padding-right: 16px;
    transition: opacity .15s ease;
}
.slide-go-knob {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--rouge);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    cursor: grab;
    z-index: 2;
    transition: transform .1s ease;
}
.slide-go-knob:active {
    cursor: grabbing;
    transform: scale(1.05);
}
.slide-go.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.progress {
    text-align: center;
    margin: 14px 0;
    color: var(--ink-soft);
}
.bar {
    height: 6px;
    background: var(--bg-soft);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 8px;
}
.bar > span {
    display: block;
    height: 100%;
    background: var(--rouge);
    width: 0;
    transition: width 0.2s ease;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.gallery-grid button {
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}
.gallery-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.viewer {
    position: fixed;
    inset: 0;
    background: var(--fx-viewer);
    z-index: 50;
    display: flex;
    flex-direction: column;
}
.viewer.hidden { display: none !important; }
.viewer-img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: pan-y;
}
.viewer-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.viewer-bar {
    padding: 12px 16px 22px;
    color: var(--fx-viewer-ink);
    text-align: center;
}
.viewer-bar .who {
    font-family: var(--serif);
    font-style: normal;
    font-weight: 700;
    font-size: 22px;
}
.viewer-bar .when { font-size: 13px; opacity: 0.75; margin: 4px 0 12px; }
.viewer-actions { display: flex; gap: 8px; }
.viewer-actions .btn { flex: 1; }
.viewer-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
}

.dl-choices { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 8px; }
.dl-choice {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--bg);
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    color: var(--ink);
}
.dl-choice input { margin: 0 8px 8px 0; }
.dl-choice:has(input:checked) { border-color: var(--rouge); background: var(--white); }
.dl-choice:disabled { opacity: 0.45; cursor: not-allowed; }
.dl-choice strong { display: block; font-size: 16px; margin-bottom: 4px; }
.dl-choice span { display: block; font-size: 13px; color: var(--ink-soft); line-height: 1.4; }
.dl-choice .dl-mo { color: var(--rouge); font-weight: 700; margin-top: 6px; }
.dl-wait { margin: 16px 0 8px; text-align: center; }
.dl-pct {
    font-family: var(--serif);
    font-style: normal;
    font-weight: 700;
    font-size: 28px;
    margin: 10px 0 0;
    color: var(--rouge);
}

.hello-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0 0 8px;
}
.hello-text { text-align: left; min-width: 0; }
.hello {
    text-align: center;
    font-family: var(--serif);
    font-style: normal;
    font-weight: 700;
    font-size: 26px;
    margin: 0 0 4px;
}
.hello-text .hello { text-align: left; margin: 0 0 2px; }
.hello-text .change-name { margin-top: 0; text-align: left; }
.me-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid var(--rouge);
    background: var(--white);
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}
.me-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.me-avatar span {
    font-family: var(--serif);
    font-style: normal;
    font-weight: 700;
    font-size: 28px;
    color: var(--rouge);
    line-height: 1;
}
.who-av {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #eee;
}
.viewer-who-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.admin-av {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 6px;
}

.ticker {
    overflow: hidden;
    margin: 8px 0 12px;
    padding: 7px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--white);
    mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}
.ticker-track {
    display: inline-flex;
    width: max-content;
    animation: af2-ticker 20s linear infinite;
    will-change: transform;
}
.ticker-msg {
    font-family: var(--serif);
    font-style: normal;
    font-weight: 600;
    font-size: 17px;
    color: var(--sky);
    white-space: nowrap;
    padding-right: 4.5em;
}
@keyframes af2-ticker {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
    .ticker-track { animation: none; }
    .ticker-msg:nth-child(n+2) { display: none; }
    .ticker { mask-image: none; -webkit-mask-image: none; text-align: center; }
    .ticker-msg { padding-right: 0; white-space: normal; }
}
