/* =========================================================================
   Nous deux 💕 — thème rose / violet, verre dépoli, mignon
   ========================================================================= */
:root {
    --pink:        #ff8fc7;
    --pink-soft:   #ffc2e2;
    --violet:      #a86bff;
    --violet-deep: #7a3ff2;
    --magenta:     #ff5fa2;
    --ink:         #4a2b52;
    --white-glass: rgba(255, 255, 255, 0.16);
    --white-line:  rgba(255, 255, 255, 0.35);
    --shadow:      0 20px 60px rgba(122, 63, 242, 0.28);
    --radius:      28px;
    --font:        'Quicksand', system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    color: var(--ink);
    background: linear-gradient(135deg, #ffd6ee 0%, #ffb7e0 22%, #d8a0ff 60%, #a86bff 100%);
    background-size: 220% 220%;
    animation: driftBg 22s ease-in-out infinite;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.25);
}

@keyframes driftBg {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* Canvas Three.js en fond, derrière tout */
#bg3d {
    position: fixed;
    inset: 0;
    z-index: -1;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ---------------------------------------------------------------- layout */
.wrap {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 18px 80px;
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-top: max(24px, env(safe-area-inset-top));
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.35rem;
    color: #fff;
    text-shadow: 0 2px 14px rgba(122, 63, 242, 0.45);
}
.brand .beat { display: inline-block; animation: beat 1.4s ease-in-out infinite; }
@keyframes beat {
    0%, 100% { transform: scale(1); }
    15%      { transform: scale(1.25); }
    30%      { transform: scale(1); }
    45%      { transform: scale(1.18); }
}

.topbar nav { display: flex; align-items: center; gap: 10px; }

/* ------------------------------------------------------------------ glass */
.glass {
    background: var(--white-glass);
    border: 1px solid var(--white-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}

/* ------------------------------------------------------------------ login */
.login-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
             max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.login-card {
    width: min(420px, 92vw);
    padding: 40px 34px;
    text-align: center;
}
.login-card h1 {
    margin: 6px 0 4px;
    font-size: 1.9rem;
    color: #fff;
    text-shadow: 0 3px 18px rgba(122, 63, 242, 0.5);
}
.login-card .sub {
    margin: 0 0 26px;
    color: #fff;
    opacity: 0.9;
    font-weight: 500;
}
.big-heart { font-size: 3rem; animation: beat 1.4s ease-in-out infinite; }

/* ------------------------------------------------------------------ forms */
.field { text-align: left; margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #fff;
    opacity: 0.9;
}
input[type=text], input[type=password], .caption-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--white-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.65);
    font-family: var(--font);
    font-size: 1rem;
    color: var(--ink);
    outline: none;
    transition: box-shadow .2s, background .2s;
}
input[type=text]:focus, input[type=password]:focus, .caption-input:focus {
    background: #fff;
    box-shadow: 0 0 0 4px rgba(255, 143, 199, 0.45);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    padding: 14px 22px;
    border-radius: 999px;
    background: linear-gradient(120deg, var(--magenta), var(--violet-deep));
    box-shadow: 0 12px 26px rgba(122, 63, 242, 0.4);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s;
    text-decoration: none;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; margin-top: 6px; }
.btn.ghost {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: none;
    border: 1px solid var(--white-line);
}

/* --------------------------------------------------------------- messages */
.flash { list-style: none; margin: 0 0 18px; padding: 0; }
.flash li {
    padding: 12px 16px;
    border-radius: 14px;
    margin-bottom: 8px;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 95, 162, 0.55);
    border: 1px solid var(--white-line);
}
.flash li.success { background: rgba(120, 200, 140, 0.55); }

/* ----------------------------------------------------------------- streak */
.streak {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    color: #fff;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid var(--white-line);
}

/* --------------------------------------------------------------- day grid */
.day-title {
    color: #fff;
    text-align: center;
    margin: 4px 0 20px;
    text-shadow: 0 2px 14px rgba(122, 63, 242, 0.4);
}
.photos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}
.photo-card { padding: 18px; text-align: center; }
.photo-card h3 {
    margin: 0 0 12px;
    color: #fff;
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.frame {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid var(--white-line);
}
.frame img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.frame.reveal img { animation: pop .6s cubic-bezier(.2,.9,.3,1.4); }
@keyframes pop {
    0%   { transform: scale(.85); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

/* état verrouillé : flou + cadenas + nounours */
.frame.locked img { filter: blur(22px) brightness(.8) saturate(1.2); transform: scale(1.1); }
.locked-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px; text-align: center;
    color: #fff; padding: 20px;
    background: rgba(122, 63, 242, 0.28);
}
.locked-overlay .bear { font-size: 3.4rem; animation: floaty 3s ease-in-out infinite; }
.locked-overlay p { margin: 0; font-weight: 600; text-shadow: 0 2px 10px rgba(0,0,0,.25); }
@keyframes floaty {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50%      { transform: translateY(-10px) rotate(4deg); }
}

.frame.waiting {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px; color: #fff; text-align: center; padding: 20px;
}
.frame.waiting .bear { font-size: 3.4rem; animation: floaty 3s ease-in-out infinite; }

.caption {
    margin: 12px 4px 0;
    color: #fff;
    font-weight: 600;
    min-height: 1.2em;
    text-shadow: 0 2px 10px rgba(122, 63, 242, 0.4);
}

/* --------------------------------------------------------------- uploader */
.uploader { padding: 26px; text-align: center; margin-bottom: 24px; }
.uploader h2 { margin: 0 0 6px; color: #fff; }
.uploader p.hint { margin: 0 0 18px; color: #fff; opacity: .9; }

.drop {
    position: relative;
    border: 2px dashed var(--white-line);
    border-radius: 20px;
    padding: 26px;
    background: rgba(255, 255, 255, 0.14);
    transition: background .2s, border-color .2s;
    margin-bottom: 14px;
}
.drop.has-file { border-color: #fff; background: rgba(255, 255, 255, 0.24); }
.drop .file-input {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop .drop-label { color: #fff; font-weight: 600; pointer-events: none; }
.drop .preview {
    max-height: 240px; border-radius: 14px; margin-top: 14px;
    display: none; box-shadow: var(--shadow);
}

/* --------------------------------------------------------------- history */
.hist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.hist-day { padding: 12px; text-align: center; }
.hist-day .date { color: #fff; font-weight: 700; margin-bottom: 8px; }
.hist-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hist-pair .frame { aspect-ratio: 1; border-radius: 14px; }
.empty { text-align: center; color: #fff; padding: 40px; font-weight: 600; }

/* --------------------------------------------------------------- responsive */
/* boutons : cible tactile confortable */
.btn { min-height: 46px; }

/* ------------------------------------------------------- tablette / petit */
@media (max-width: 760px) {
    .day-title { font-size: clamp(1.05rem, 4.5vw, 1.5rem); }
    .brand { font-size: clamp(1rem, 4.5vw, 1.35rem); }
}

/* ---------------------------------------------------------------- mobile */
@media (max-width: 640px) {
    .wrap { padding-bottom: 56px; }
    .photos { grid-template-columns: 1fr; gap: 16px; }

    /* barre du haut : marque sur une ligne, actions dessous, bien étalées */
    .topbar { gap: 10px; margin-bottom: 18px; }
    .topbar nav {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }
    .topbar nav .btn.ghost {
        flex: 1;
        padding: 11px 10px;
        font-size: 0.9rem;
        min-height: 44px;
    }
    .streak { order: -1; }

    .login-card { padding: 30px 22px; width: min(440px, 100%); }
    .login-card h1 { font-size: clamp(1.5rem, 7vw, 1.9rem); }

    .uploader { padding: 20px 16px; }
    .photo-card { padding: 14px; }
    .frame { aspect-ratio: 4 / 5; }        /* un peu moins haut sur téléphone */

    .hist-grid { grid-template-columns: repeat(auto-fill, minmax(46%, 1fr)); gap: 12px; }
}

/* ------------------------------------------------------ très petit écran */
@media (max-width: 380px) {
    .topbar nav .btn.ghost { font-size: 0.82rem; padding: 10px 8px; }
    .big-heart { font-size: 2.4rem; }
    .login-card { padding: 26px 18px; }
    .field label { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
    body, .beat, .big-heart, .locked-overlay .bear, .frame.reveal img { animation: none !important; }
}
