:root {
    --bg: #fbfaf7;
    --surface: #ffffff;
    --surface-hover: #fff8f0;
    --border: #ece5d8;
    --text: #2a231c;
    --text-muted: #786f60;
    --text-faint: #a89f8f;
    --red: #c62b2b;
    --red-dark: #a01f1f;
    --gold: #e0a324;
    --gold-dark: #b9840f;
    --radius-sm: 4px;
    --radius-md: 8px;
    --shadow-card: 0 1px 2px rgba(42, 35, 28, 0.06), 0 6px 20px rgba(42, 35, 28, 0.05);
    --shadow-lift: 0 12px 32px rgba(42, 35, 28, 0.18);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Karla', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2 {
    font-family: 'Merriweather', Georgia, serif;
}

button, input {
    font-family: inherit;
}

:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}

.app { min-height: 100vh; }
.app--hidden { display: none; }

/* ---------- Topbar ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 18px 32px;
    background: var(--surface);
    border-bottom: 3px solid var(--red);
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 12px rgba(42, 35, 28, 0.05);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Merriweather', Georgia, serif;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
    white-space: nowrap;
    color: var(--text);
    text-decoration: none;
}

.brand-icon {
    width: 26px;
    height: 26px;
    color: var(--red);
    flex-shrink: 0;
}

.topbar__brand:hover .brand-icon { color: var(--red-dark); }

/* ---------- Breadcrumb ---------- */

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 14px;
    color: var(--text-muted);
    min-width: 0;
}

.breadcrumb__item {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 2px;
    border-radius: 3px;
    font-family: inherit;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breadcrumb__item:hover { color: var(--red); }

.breadcrumb__item--current {
    color: var(--text);
    font-weight: 600;
    cursor: default;
}

.breadcrumb__sep {
    color: var(--gold-dark);
    font-size: 15px;
}

/* ---------- Main / empty / loading / error states ---------- */

main {
    padding: 32px 32px 72px;
    max-width: 1600px;
    margin: 0 auto;
}

.empty-state, .error-state, .loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 100px 24px;
    color: var(--text-muted);
}

.empty-state--hidden { display: none; }

.empty-state svg {
    width: 56px;
    height: 56px;
    color: var(--gold-dark);
    margin-bottom: 20px;
}

.empty-state h2 {
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
}

.empty-state p {
    max-width: 420px;
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.loading { flex-direction: row; gap: 12px; padding: 64px 24px; }
.loading--hidden { display: none; }

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
    color: var(--red-dark);
}
.error-state--hidden { display: none; }
.error-state p {
    max-width: 480px;
    background: #fdf1ef;
    border: 1px solid #f3c9c2;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.6;
}

/* ---------- Folders grid (albums) ---------- */

.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 12px;
}

.folder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--gold);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    text-align: left;
    box-shadow: var(--shadow-card);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.folder-card:hover {
    background: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(42, 35, 28, 0.1);
}

.folder-card__icon {
    width: 34px;
    height: 34px;
    color: var(--red);
}

.folder-card__name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.folder-card__label {
    font-size: 11.5px;
    letter-spacing: 0.03em;
    color: var(--gold-dark);
    font-weight: 600;
}

/* ---------- Photos grid (justified-ish masonry via CSS columns) ---------- */

.photos-grid {
    column-count: 5;
    column-gap: 14px;
}

@media (max-width: 1400px) { .photos-grid { column-count: 4; } }
@media (max-width: 1000px) { .photos-grid { column-count: 3; } }
@media (max-width: 700px)  { .photos-grid { column-count: 2; } }
@media (max-width: 460px)  { .photos-grid { column-count: 1; } }

.photo-tile {
    break-inside: avoid;
    margin-bottom: 14px;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    opacity: 0;
    animation: fade-in 0.4s ease forwards;
    box-shadow: var(--shadow-card);
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.photo-tile img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.25s ease;
}

.photo-tile:hover img {
    transform: scale(1.035);
}

.photo-tile__overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 26px 12px 10px;
    background: linear-gradient(to top, rgba(20, 15, 8, 0.72), transparent);
    opacity: 0;
    transition: opacity 0.15s ease;
    font-size: 12.5px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-tile:hover .photo-tile__overlay { opacity: 1; }

/* ---------- Load more ---------- */

.load-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}
.load-more-wrap--hidden { display: none; }

#load-more {
    background: var(--red);
    border: none;
    color: #fff;
    padding: 12px 30px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
#load-more:hover { background: var(--red-dark); }

/* ---------- Lightbox ---------- */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(20, 16, 10, 0.94);
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.lightbox--hidden { display: none; }

.lightbox__stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 88px;
    min-height: 0;
}

.lightbox__stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: var(--shadow-lift);
}

.lightbox__close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: #e8e1d4;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.lightbox__close svg { width: 20px; height: 20px; }

.lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #e8e1d4;
    width: 48px;
    height: 48px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.lightbox__nav svg { width: 26px; height: 26px; }
.lightbox__nav--prev { left: 16px; }
.lightbox__nav--next { right: 16px; }

.lightbox__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    gap: 16px;
}

.lightbox__name {
    color: #d9d0c0;
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.lightbox__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.lightbox__link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e8e1d4;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.lightbox__link-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.lightbox__link-btn svg { width: 17px; height: 17px; }
.lightbox__link-btn--copied { color: var(--gold); border-color: var(--gold); }

.lightbox__download {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--red);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
    white-space: nowrap;
}
.lightbox__download:hover { background: var(--red-dark); }
.lightbox__download svg { width: 16px; height: 16px; }

@media (max-width: 640px) {
    .lightbox__stage { padding: 20px 56px; }
    .lightbox__nav { width: 40px; height: 40px; }
    .lightbox__name { display: none; }
}

/* ---------- Lock screen ---------- */

.lock-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 200;
}

.lock-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 320px;
    padding: 40px 32px;
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    border-top: 4px solid var(--red);
    box-shadow: var(--shadow-card);
}

.lock-emblem {
    color: var(--red);
    margin-bottom: 4px;
}
.lock-emblem svg { width: 40px; height: 40px; }

.lock-form h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.lock-hint {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 8px;
}

.lock-form input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
}
.lock-form input:focus { border-color: var(--red); }

.lock-form button {
    width: 100%;
    background: var(--red);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.lock-form button:hover { background: var(--red-dark); }

.lock-error {
    color: var(--red-dark);
    font-size: 13px;
    min-height: 16px;
    margin: 0;
}

/* ---------- Responsive topbar ---------- */

@media (max-width: 720px) {
    .topbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 14px 18px;
    }
    main { padding: 24px 18px 56px; }
}
