/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
    --bg:         #0a0a0a;
    --surface:    #161616;
    --surface2:   #1e1e1e;
    --border:     #2a2a2a;
    --text:       #e8e8e8;
    --text-muted: #888;
    --accent:     #008296;
    --accent-dim: #006270;
    --danger:     #c0392b;
    --success:    #27ae60;
    --nav-h:      52px;
    --radius:     6px;
    --gap:        16px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

img { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(10,10,10,0.95);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--accent);
}
.nav-logo:hover { color: var(--text); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.875rem;
    letter-spacing: 0.03em;
    transition: color 0.15s;
}
.nav-links a:hover { color: var(--text); }

/* ── Main ────────────────────────────────────────────────────────────────── */
main {
    min-height: calc(100vh - var(--nav-h));
}

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-box {
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 0.1em;
}

.auth-tagline {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password] {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 12px;
    font-size: 0.9375rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus {
    border-color: var(--accent-dim);
}

.form-group input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-check { flex-direction: row; align-items: center; }
.form-check label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 0.875rem; }

.hint { color: var(--text-muted); font-size: 0.75rem; }

.form-error {
    background: rgba(192,57,43,0.15);
    border: 1px solid rgba(192,57,43,0.4);
    border-radius: var(--radius);
    color: #e74c3c;
    padding: 10px 12px;
    font-size: 0.875rem;
}

.form-success {
    background: rgba(39,174,96,0.15);
    border: 1px solid rgba(39,174,96,0.4);
    border-radius: var(--radius);
    color: var(--success);
    padding: 10px 12px;
    font-size: 0.875rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #0a0a0a;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--text);
    border-color: var(--text);
    color: #0a0a0a;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-full { width: 100%; }

/* ── Gallery ─────────────────────────────────────────────────────────────── */
.gallery-container {
    padding: var(--gap) 24px 48px;
}

.gallery-hidden { display: none; }

.gallery-controls {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar {
    display: flex;
    gap: 4px;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s;
}
.filter-btn:hover, .filter-btn.active {
    background: var(--surface2);
    border-color: var(--text-muted);
    color: var(--text);
}
.filter-btn.active { border-color: var(--accent); color: var(--accent); }

.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 4px;
}

.photo-card {
    position: relative;
    aspect-ratio: 3/2;
    overflow: hidden;
    cursor: pointer;
    background: var(--surface);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s;
    opacity: 0;
}
.photo-card img.loaded { opacity: 1; }
.photo-card:hover img { transform: scale(1.04); }

.photo-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: flex-end;
    padding: 12px;
}
.photo-card:hover .photo-card-overlay { opacity: 1; }

.photo-card-title {
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.3;
}

.gallery-loading, .gallery-end {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-inner {
    display: flex;
    align-items: center;
    gap: 32px;
    max-width: 95vw;
    max-height: 95vh;
}

.lightbox-inner img {
    max-width: 75vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.lightbox-info {
    width: 240px;
    flex-shrink: 0;
}

.lightbox-close, .lightbox-prev, .lightbox-next {
    position: absolute;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    padding: 12px;
    transition: color 0.15s;
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { color: var(--text); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev  { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: 16px; top: 50%; transform: translateY(-50%); }

/* ── Photo detail ────────────────────────────────────────────────────────── */
.photo-detail {
    display: flex;
    gap: 40px;
    padding: 32px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.photo-detail-img-wrap {
    flex: 1;
    min-width: 0;
}

.photo-detail-img {
    width: 100%;
    border-radius: var(--radius);
    max-height: 85vh;
    object-fit: contain;
    background: var(--surface);
}

.photo-detail-info {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.photo-detail-title { font-size: 1.375rem; font-weight: 600; }
.photo-detail-desc  { color: var(--text-muted); line-height: 1.7; }
.photo-detail-date  { color: var(--text-muted); font-size: 0.875rem; }

.photo-detail-stats {
    display: flex;
    gap: 16px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.photo-detail-actions { display: flex; flex-direction: column; gap: 10px; }

.purchase-success {
    padding: 10px;
    background: rgba(39,174,96,0.15);
    border-radius: var(--radius);
    color: var(--success);
    font-size: 0.875rem;
    text-align: center;
}

/* ── Vote ────────────────────────────────────────────────────────────────── */
.vote-gate {
    position: fixed;
    inset: var(--nav-h) 0 0 0;
    z-index: 50;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.vote-gate-inner {
    width: 100%;
    max-width: 1000px;
    text-align: center;
}

.vote-page {
    padding: 40px 24px;
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.vote-heading   { font-size: 1.5rem; font-weight: 600; margin-bottom: 8px; }
.vote-subheading { color: var(--text-muted); margin-bottom: 32px; }

.vote-pair {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.vote-photo {
    flex: 1;
    max-width: 440px;
    cursor: pointer;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
}
.vote-photo:hover { border-color: var(--accent); transform: scale(1.01); }
.vote-photo.voted-winner { border-color: var(--success); }
.vote-photo.voted-loser  { opacity: 0.4; }

.vote-photo img {
    width: 100%;
    aspect-ratio: 3/2;
    object-fit: cover;
}

.vote-skip { margin-top: 8px; }
.vote-done { padding: 48px; }
.vote-loading { color: var(--text-muted); padding: 48px; }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.tag--location { border-color: #2980b9; color: #5dade2; }
.tag--category { border-color: #8e44ad; color: #bb8fce; }
.tag--subject  { border-color: #16a085; color: #48c9b0; }
.tag--mood     { border-color: #d35400; color: #e59866; }
.tag--event    { border-color: #c0392b; color: #e74c3c; }
.tag--technical { border-color: #333; color: #666; }

.photo-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Profile ─────────────────────────────────────────────────────────────── */
.profile-page   { padding: 32px 24px; max-width: 900px; margin: 0 auto; }
.page-title     { font-size: 1.5rem; font-weight: 600; margin-bottom: 24px; }
.profile-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

.invite-result { margin-top: 16px; }
.invite-link-wrap { display: flex; gap: 8px; margin-top: 6px; }
.invite-link-wrap input { flex: 1; }

.invite-list, .purchase-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.invite-item, .purchase-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--surface2);
    border-radius: var(--radius);
    font-size: 0.875rem;
}
.invite-item.used { opacity: 0.6; }
.invite-status { color: var(--text-muted); }
.invite-date   { font-size: 0.75rem; color: var(--text-muted); }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.admin-panel {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.admin-panel h4 { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-right: 8px; }

/* ── Error page ──────────────────────────────────────────────────────────── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
    text-align: center;
}
.error-page h1 { font-size: 5rem; color: var(--border); font-weight: 700; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); font-size: 0.875rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .photo-detail  { flex-direction: column; }
    .photo-detail-info { width: 100%; }
    .vote-pair     { flex-direction: column; }
    .profile-grid  { grid-template-columns: 1fr; }
    .lightbox-info { display: none; }
    .lightbox-inner img { max-width: 95vw; }
    .photo-grid    { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
