:root {
    --bg: #14151a;
    --bg-elevated: #1d1f26;
    --border: #2b2d36;
    --text: #eceef2;
    --text-dim: #9a9dab;
    --accent: #5b8cff;
    --accent-dim: #34406b;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
}

/* --- Login --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 340px;
    text-align: center;
}
.login-card h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
.login-card .subtitle { color: var(--text-dim); margin: 0 0 1.5rem; font-size: .9rem; }
.login-card form { display: flex; flex-direction: column; gap: .75rem; }
.login-card input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .8rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
}
.login-card button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: .8rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.login-card button:hover { opacity: .9; }
.error { color: #ff6b6b; font-size: .85rem; }

/* --- Layout --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar nav { display: flex; align-items: center; gap: .75rem; }
.badge {
    font-size: .75rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    background: var(--accent-dim);
    color: #bcd0ff;
}
.badge-viewer { background: #333542; color: var(--text-dim); }
.logout-link { color: var(--text-dim); font-size: .85rem; text-decoration: none; }
.logout-link:hover { color: var(--text); }

main { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }

.empty-state { color: var(--text-dim); text-align: center; margin-top: 3rem; }

/* --- Gallery grid --- */
.day-group { margin-bottom: 1.75rem; }
.day-group:last-child { margin-bottom: 0; }
.day-heading {
    font-size: .95rem;
    font-weight: 600;
    color: var(--text-dim);
    margin: 0 0 .6rem;
    padding-top: .1rem;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.tile {
    display: block;
    aspect-ratio: 1 / 1;
    background: var(--bg-elevated);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}
.tile-link {
    display: block;
    width: 100%;
    height: 100%;
}
.tile img, .tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}

.tile-download {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 21, 26, .65);
    color: #fff;
    border-radius: 50%;
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
    backdrop-filter: blur(2px);
    transition: background .15s, transform .15s;
}
.tile-download:hover {
    background: var(--accent);
    transform: scale(1.08);
}

.tile-delete {
    position: absolute;
    bottom: 6px;
    left: 6px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 21, 26, .65);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: .95rem;
    line-height: 1;
    backdrop-filter: blur(2px);
    transition: background .15s, transform .15s;
}
.tile-delete:hover {
    background: #d64545;
    transform: scale(1.08);
}
.tile-delete:disabled {
    opacity: .5;
    cursor: default;
    transform: none;
}

/* --- Upload area --- */
.upload-area {
    max-width: 1100px;
    margin: 1.25rem auto 0;
    padding: 0 1.25rem;
}
.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-dim);
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--accent);
    color: var(--text);
}
.upload-icon { font-size: 1.8rem; color: var(--accent); }

.upload-queue { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.upload-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem .8rem;
    font-size: .85rem;
}
.upload-item .name { display: flex; justify-content: space-between; margin-bottom: .4rem; gap: .5rem; }
.upload-item .name span:last-child { color: var(--text-dim); white-space: nowrap; }
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar > div {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width .15s;
}
.upload-item.done .progress-bar > div { background: #4caf6d; }
.upload-item.error .progress-bar > div { background: #ff6b6b; width: 100% !important; }
.upload-item.error .name span:last-child { color: #ff6b6b; }
.upload-item {
    transition: opacity .4s ease, transform .4s ease, margin .4s ease, padding .4s ease, max-height .4s ease;
    max-height: 100px;
    overflow: hidden;
}
.upload-item.fade-out {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
}

/* --- Lightbox --- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 13, .95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.lightbox[hidden] { display: none; }
.lightbox-image {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 4px;
}
.lightbox-close, .lightbox-prev, .lightbox-next, .lightbox-download {
    position: absolute;
    background: rgba(255, 255, 255, .08);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover, .lightbox-download:hover {
    background: rgba(255, 255, 255, .18);
}
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-download { top: 1rem; right: 4.25rem; text-decoration: none; }
.lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: .85rem;
    opacity: .75;
}

@media (max-width: 600px) {
    .lightbox-prev, .lightbox-next, .lightbox-download { width: 38px; height: 38px; font-size: 1.2rem; }
    .lightbox-prev { left: .5rem; }
    .lightbox-next { right: .5rem; }
    .lightbox-close { top: .5rem; right: .5rem; }
    .lightbox-download { top: .5rem; right: 3.25rem; }
}
