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

:root {
  --bg:        #0a0a0a;
  --bg-card:   #111111;
  --bg-nav:    #0d0d0d;
  --border:    #1e1e1e;
  --orange:    #ff6b00;
  --orange-dim:#c25200;
  --text:      #e8e8e8;
  --text-muted:#888888;
  --radius:    6px;
  --nav-h:     64px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; max-width: 100%; height: auto; }

/* ── Header / Nav ─────────────────────────────────────────────────────────── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
}

.nav-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--orange);
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; opacity: 0.85; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.nav-links a:hover { color: var(--text); background: var(--border); }
.nav-links a.active { color: var(--orange); }

/* ── Main content wrapper ─────────────────────────────────────────────────── */
#site-main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
#site-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}
#site-footer span { color: var(--orange); }

/* ── Page hero ────────────────────────────────────────────────────────────── */
.hero {
  padding: 64px 0 48px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--orange);
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 40px;
}

/* ── Nav card grid (home page) ────────────────────────────────────────────── */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.page-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
  text-decoration: none;
  color: inherit;
}
.page-card:hover {
  border-color: var(--orange-dim);
  transform: translateY(-2px);
  text-decoration: none;
}

.page-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.page-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.page-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.page-card .card-arrow {
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--orange);
  font-weight: 600;
}

/* ── Section heading ──────────────────────────────────────────────────────── */
.section-heading {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

/* ── Gallery grid ─────────────────────────────────────────────────────────── */
#gallery-status {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
  min-height: 1.4em;
}

#gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s, opacity 0.2s;
}

.gallery-item:hover img { transform: scale(1.04); opacity: 0.85; }

.gallery-item .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.gallery-item:hover .overlay { opacity: 1; }
.gallery-item .overlay svg { width: 32px; height: 32px; fill: #fff; }

/* empty/error state */
.gallery-empty {
  grid-column: 1 / -1;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.gallery-empty strong { display: block; color: var(--text); margin-bottom: 8px; font-size: 1rem; }

/* HEIC converting placeholder */
.heic-loading {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.heic-loading::after {
  content: "";
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent, #6c8ebf);
  border-radius: 50%;
  animation: heic-spin 0.8s linear infinite;
}
@keyframes heic-spin { to { transform: rotate(360deg); } }

.heic-error .heic-loading {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.heic-error .heic-loading::after { display: none; }

/* Lightbox loading state while HEIC converts */
#lightbox-img.loading {
  min-width: 80px;
  min-height: 80px;
  opacity: 0.3;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
}
#lightbox.open { display: flex; }

#lightbox-img {
  max-width: min(90vw, 1100px);
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  user-select: none;
}

#lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  opacity: 0.75;
  transition: opacity 0.15s;
}
#lightbox-close:hover { opacity: 1; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 1.4rem;
  transition: background 0.15s;
  user-select: none;
}
.lightbox-nav:hover { background: rgba(255,107,0,0.35); }
#lightbox-prev { left: 20px; }
#lightbox-next { right: 20px; }

#lightbox-caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-inner { gap: 16px; }
  .nav-links a { padding: 6px 8px; font-size: 0.82rem; }
  #site-main { padding: 32px 16px; }
  .hero { padding: 40px 0 32px; }
  #gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  #lightbox-prev { left: 8px; }
  #lightbox-next { right: 8px; }
}

/* ── Auth form ─────────────────────────────────────────────────────────────── */
.auth-wrap {
  max-width: 380px;
  margin: 80px auto 0;
}
.auth-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 28px;
  letter-spacing: -0.03em;
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type=text], input[type=password], select, textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
input[type=text]:focus, input[type=password]:focus, select:focus {
  border-color: var(--orange);
}
select { cursor: pointer; }

.form-error {
  color: #f66;
  font-size: 0.85rem;
  padding: 8px 12px;
  background: rgba(255,80,80,0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(255,80,80,0.2);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.checkbox-row input[type=checkbox] { width: auto; accent-color: var(--orange); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--border); border-color: #444; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dim); border-color: var(--orange-dim); }
.btn-danger { background: rgba(220,50,50,0.15); border-color: rgba(220,50,50,0.4); color: #f77; }
.btn-danger:hover { background: rgba(220,50,50,0.3); }
.btn-full { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-login { font-size: 0.85rem; padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-muted); background: transparent; text-decoration: none; transition: color 0.15s, border-color 0.15s; }
.btn-login:hover { color: var(--text); border-color: #555; text-decoration: none; }
.btn-logout { font-size: 0.8rem; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--text-muted); cursor: pointer; transition: color 0.15s; font-family: inherit; }
.btn-logout:hover { color: var(--text); }

/* ── Nav extras ────────────────────────────────────────────────────────────── */
.nav-end { margin-left: auto; display: flex; align-items: center; }
.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-username { font-size: 0.875rem; color: var(--text-muted); }
.nav-badge { font-size: 0.7rem; background: rgba(255,107,0,0.15); color: var(--orange); border: 1px solid rgba(255,107,0,0.3); border-radius: 4px; padding: 2px 6px; font-weight: 600; }

/* ── Page toolbar ──────────────────────────────────────────────────────────── */
.page-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }

/* ── Gallery list cards ────────────────────────────────────────────────────── */
.gallery-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.gallery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.gallery-card:hover { border-color: var(--orange-dim); transform: translateY(-2px); text-decoration: none; }
.gallery-card-header { display: flex; align-items: center; gap: 8px; }
.gallery-card-name { font-weight: 600; font-size: 1.05rem; }
.gallery-card-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.gallery-card-meta { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-top: auto; padding-top: 8px; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { font-size: 0.7rem; padding: 2px 7px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge-public  { background: rgba(80,200,120,0.15); color: #6be8a0; border: 1px solid rgba(80,200,120,0.25); }
.badge-private { background: rgba(120,120,120,0.15); color: var(--text-muted); border: 1px solid var(--border); }
.badge-admin   { background: rgba(255,107,0,0.15); color: var(--orange); border: 1px solid rgba(255,107,0,0.25); }
.badge-user    { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Modals ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ── Upload drop zone ──────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.drag-over { border-color: var(--orange); background: rgba(255,107,0,0.05); }
.drop-label { color: var(--orange); cursor: pointer; text-decoration: underline; }
.upload-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; gap: 8px; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; color: var(--text-muted); }
.upload-status { flex-shrink: 0; }
.upload-ok  { color: #6be8a0; }
.upload-err { color: #f66; }

/* ── Share list ────────────────────────────────────────────────────────────── */
.share-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; font-size: 0.875rem; }
.share-row span { font-weight: 500; flex: 1; min-width: 80px; }

/* ── Admin panel ───────────────────────────────────────────────────────────── */
.admin-section { margin-bottom: 48px; }
.admin-section-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 0; }
.table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th { text-align: left; padding: 10px 14px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--bg-card); }
.admin-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }
.table-actions { display: flex; gap: 6px; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.status-text { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; min-height: 1.4em; }
.back-link { font-size: 0.85rem; color: var(--text-muted); text-decoration: none; display: inline-block; margin-bottom: 4px; }
.back-link:hover { color: var(--orange); text-decoration: none; }
.gallery-desc-text { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.photo-delete-btn {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 0.75rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.gallery-item:hover .photo-delete-btn { display: flex; }

/* Spinner */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: heic-spin 0.7s linear infinite;
  margin: 0 auto;
}
