*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --surface2: #242424;
  --accent:   #4a9eff;
  --text:     #e0e0e0;
  --muted:    #888;
  --radius:   8px;
  --gap:      10px;
}

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

/* ── Header ─────────────────────────────── */
.site-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid #2a2a2a;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-count {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.back-link:hover { text-decoration: underline; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.82; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; opacity: 1; }

/* ── Home link ──────────────────────────── */
.home-link {
  color: #fff;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.home-link span { color: #60a5fa; }
.home-link:hover { text-decoration: none; opacity: 0.85; }

/* ── Breadcrumb ──────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.crumb-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}
.crumb-link:hover { text-decoration: underline; }
.crumb-sep { color: #444; font-size: 0.85rem; }
.crumb-current {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-label {
  padding: 16px 24px 0;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ── Album grid ──────────────────────────── */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--gap);
  padding: 24px;
}

.album-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  border: 1px solid #2a2a2a;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}
.album-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.6);
  border-color: #3a3a3a;
}

.album-cover {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--surface2);
}
.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}
.album-card:hover .album-cover img { transform: scale(1.06); }

.no-cover {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #444;
}

.album-meta {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.album-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.album-count {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Photo grid ──────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--gap);
  padding: 24px;
}

.photo-thumb {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface2);
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease, filter 0.25s ease;
}
.photo-thumb:hover img {
  transform: scale(1.08);
  filter: brightness(1.12);
}

/* ── Lightbox ────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.lightbox.active {
  opacity: 1;
  pointer-events: all;
}

.lb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.93);
  cursor: zoom-out;
}

.lb-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100vw - 130px);
  max-height: calc(100vh - 90px);
}

#lb-img {
  max-width: 100%;
  max-height: calc(100vh - 90px);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.8);
  display: block;
  transition: opacity 0.18s ease;
}
#lb-img.loading { opacity: 0; }

.lb-btn {
  position: absolute;
  z-index: 2;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}
.lb-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.lb-close { top: 14px; right: 14px; font-size: 1rem; }
.lb-prev  { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next  { right: 14px; top: 50%; transform: translateY(-50%); }
.lb-play  { bottom: 44px; left: 50%; transform: translateX(-50%); font-size: 1rem; }

.lb-footer {
  position: absolute;
  z-index: 2;
  bottom: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}
#lb-caption {
  color: #bbb;
  font-size: 0.82rem;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lb-counter {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

/* ── Upload ──────────────────────────────── */
.upload-wrap {
  max-width: 520px;
  margin: 40px auto;
  padding: 0 24px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.upload-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.875rem;
  color: var(--muted);
}

.upload-form input[type="text"],
.upload-form input[type="password"],
.upload-form select {
  background: var(--surface2);
  border: 1px solid #333;
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.upload-form input:focus,
.upload-form select:focus { border-color: var(--accent); }

.upload-form input[type="file"] {
  color: var(--muted);
  font-size: 0.875rem;
}

.msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.msg-success { background: #0e2d0e; color: #6fcf6f; border: 1px solid #1a4a1a; }
.msg-error   { background: #2d0e0e; color: #cf6f6f; border: 1px solid #4a1a1a; }

/* ── Select / Delete ─────────────────────── */
.btn-danger {
  background: #c0392b;
  color: #fff;
  border: none;
}
.btn-danger:hover { opacity: 0.85; }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

.select-check {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  background: rgba(74, 158, 255, 0.45);
  border-radius: var(--radius);
  pointer-events: none;
}

.photo-grid.select-mode .photo-thumb {
  cursor: pointer;
  position: relative;
}
.photo-grid.select-mode .photo-thumb:hover { outline: 2px solid var(--accent); }
.photo-grid.select-mode .select-check { display: flex; opacity: 0; transition: opacity 0.15s; }
.photo-grid.select-mode .photo-thumb.selected .select-check { opacity: 1; }
.photo-grid.select-mode .photo-thumb.selected { outline: 3px solid var(--accent); }

.delete-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid #333;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.delete-bar.hidden { display: none; }
.delete-bar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Progress bar ────────────────────────── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress-wrap.hidden { display: none; }

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #333;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 640px) {
  .site-header { padding: 10px 12px; }
  .site-header h1 { font-size: 1rem; }
  .btn { font-size: 0.78rem; padding: 6px 10px; }
  .album-grid  { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); padding: 10px; gap: 8px; }
  .photo-grid  { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); padding: 10px; gap: 5px; }
  .lb-content  { max-width: 100vw; max-height: calc(100vh - 80px); }
  .lb-prev, .lb-next { width: 36px; height: 36px; font-size: 1.1rem; }
  .delete-bar  { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
}
