:root {
  --bg: #0b0c10;
  --bg-elev: #12141c;
  --bg-card: #171a24;
  --bg-hover: #1e2230;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f5f9;
  --text-muted: #949bb0;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-2: #818cf8;
  --danger: #f43f5e;
  --warning: #f59e0b;
  --success: #10b981;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ─── Top Navigation ──────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 12, 16, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ─── Buttons & Badges ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.52rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #080a0f;
  border-color: transparent;
}

.btn-primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.btn-danger {
  background: rgba(244, 63, 94, 0.14);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.35);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

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

.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn-sm {
  padding: 0.36rem 0.7rem;
  font-size: 0.8rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.badge-public {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.badge-unlisted {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.badge-private {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}

.badge-danger {
  background: rgba(244, 63, 94, 0.2);
  color: #fda4af;
}

/* ─── Hero & Container ────────────────────────────────────────── */
.container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.hero {
  padding: 1.5rem 0 1.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
}

.hero h1 {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.hero p {
  color: var(--text-muted);
  font-size: 0.98rem;
  max-width: 720px;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* ─── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.6rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.7rem 1.15rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── Album Cards Grid ────────────────────────────────────────── */
.albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.25rem;
}

.album-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.album-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: var(--shadow);
}

.album-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #10131b;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.album-card:hover .album-cover img {
  transform: scale(1.04);
}

.album-cover-placeholder {
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.album-body {
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.album-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.album-desc {
  color: var(--text-muted);
  font-size: 0.86rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.album-meta {
  margin-top: auto;
  padding-top: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Flickr-style Justified Photo Stream ─────────────────────── */
.photo-stream {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-stream::after {
  content: "";
  flex-grow: 999999999;
}

.photo-tile {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.photo-tile img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.82) 0%,
    rgba(0, 0, 0, 0.25) 38%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.75rem 0.85rem;
}

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

.photo-tile-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-tile-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.76);
  margin-top: 0.15rem;
}

/* ─── Lightbox Modal ──────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 6, 9, 0.96);
  backdrop-filter: blur(12px);
  display: none;
  flex-direction: row;
}

.lightbox.open {
  display: flex;
}

.lightbox-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3.5rem 4rem;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  transition: transform 0.2s ease;
  cursor: zoom-in;
}

.lightbox-stage img.zoomed {
  transform: scale(1.85);
  cursor: zoom-out;
}

.lb-top-controls {
  position: absolute;
  top: 1rem;
  left: 1.25rem;
  right: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
  pointer-events: none;
}

.lb-top-controls > * {
  pointer-events: auto;
}

.lb-counter {
  background: rgba(18, 20, 28, 0.8);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(23, 26, 36, 0.78);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: background 0.15s ease;
}

.lb-nav:hover {
  background: rgba(56, 189, 248, 0.25);
}

.lb-prev { left: 1.15rem; }
.lb-next { right: 1.15rem; }

.lightbox-sidebar {
  width: 360px;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  padding: 1.4rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  overflow-y: auto;
}

.lb-title {
  font-size: 1.15rem;
  font-weight: 700;
  word-break: break-word;
}

.lb-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.lb-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  text-align: center;
}

.lb-stat-val {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
}

.lb-stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.exif-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.exif-card h4 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.exif-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.75rem;
  font-size: 0.83rem;
}

.exif-item-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.exif-item-val {
  font-weight: 600;
  color: var(--text);
}

.lb-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ─── Generic Modals & Forms ──────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(5, 6, 9, 0.82);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h3 {
  font-size: 1.12rem;
  font-weight: 700;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  margin-bottom: 0.95rem;
}

.form-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input, .select, .textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

/* ─── Toast Notification ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  max-width: 360px;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--success);
}

@media (max-width: 900px) {
  .lightbox {
    flex-direction: column;
  }
  .lightbox-stage {
    padding: 3rem 0.75rem 1rem;
    min-height: 54vh;
  }
  .lightbox-sidebar {
    width: 100%;
    max-height: 46vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
