:root {
  color-scheme: dark light;
  --background: #0f172a;
  --foreground: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --card-bg: rgba(15, 23, 42, 0.65);
  --card-border: rgba(148, 163, 184, 0.25);
  --shadow: 0 20px 60px rgba(8, 11, 22, 0.55);
  --grid-gap: 1rem;
}

* {
  box-sizing: border-box;
}

body.page {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(circle at bottom, rgba(192, 132, 252, 0.25), transparent 45%),
    var(--background);
  color: var(--foreground);
  font-family: "Inter", "SF Pro Text", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

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

.site-header {
  width: min(1320px, 96vw);
  margin: 0 auto;
  padding: 4rem 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  text-align: center;
}

.site-header .branding h1 {
  margin: 0;
  font-size: clamp(2.7rem, 6.5vw, 4rem);
  letter-spacing: -0.05em;
}

.site-header .branding p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.theme-nav {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.theme-nav a {
  color: var(--foreground);
  text-decoration: none;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.4);
  transition: background 0.2s ease, transform 0.2s ease;
}

.theme-nav a:hover {
  background: rgba(56, 189, 248, 0.25);
  transform: translateY(-2px);
}

.layout {
  width: min(1320px, 96vw);
  margin: 0 auto 4rem;
  display: grid;
  gap: 1.6rem;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 240px);
}

.layout__main {
  display: flex;
  flex-direction: column;
}

.layout__sidebar {
  align-self: flex-start;
}

.wrapper {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--grid-gap);
}

.gallery--animating .photo-card:not([hidden]) {
  animation: gallery-fade-in 0.35s ease;
}

.photo-card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  cursor: pointer;
  outline: none;
}

.photo-card:hover,
.photo-card:focus-visible {
  transform: translateY(-10px);
  box-shadow: 0 26px 65px rgba(8, 11, 22, 0.55);
}

.photo-frame {
  overflow: hidden;
}

.photo-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 3 / 4;
  transition: transform 0.6s ease;
}

.photo-card:hover .photo-frame img,
.photo-card:focus-visible .photo-frame img {
  transform: scale(1.03);
}

.photo-info {
  padding: 1.2rem 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.photo-title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.photo-description {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.photo-tags {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.photo-tags .theme-badge {
  text-decoration: none;
}

.theme-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  background: rgba(56, 189, 248, 0.18);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.photo-card[hidden] {
  display: none !important;
}

.photo-edit-link {
  display: none;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: rgba(147, 197, 253, 0.95);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.photo-edit-link--visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.photo-edit-link--visible:hover,
.photo-edit-link--visible:focus-visible,
.photo-edit-link:hover,
.photo-edit-link:focus-visible {
  background: rgba(37, 99, 235, 0.25);
  border-color: rgba(96, 165, 250, 0.6);
  color: #dbeafe;
}

.theme-badge--link {
  text-decoration: none;
  color: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-badge--link:hover,
.theme-badge--link:focus-visible {
  background: rgba(56, 189, 248, 0.32);
  border-color: rgba(56, 189, 248, 0.6);
  color: #f0f9ff;
}

.sidebar-card {
  position: sticky;
  top: 2.5rem;
  padding: 1.6rem;
  border-radius: 18px;
  background: rgba(9, 13, 25, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-list li a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--foreground);
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.25);
  transition: background 0.2s ease;
}

.sidebar-list li a:hover {
  background: rgba(56, 189, 248, 0.18);
}

.sidebar-count {
  color: var(--muted);
  font-size: 0.8rem;
}

.theme-directory {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.theme-card {
  display: block;
  text-decoration: none;
  color: var(--foreground);
  border-radius: 16px;
  padding: 2rem 1.6rem;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.theme-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 55px rgba(8, 11, 22, 0.6);
}

.theme-card__content h2 {
  margin: 0 0 0.6rem 0;
  font-size: 1.4rem;
}

.theme-card__count {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 2.5rem auto 0;
  flex-wrap: wrap;
}

.pagination button {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.5);
  color: var(--foreground);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.pagination button:hover,
.pagination button:focus-visible {
  background: rgba(56, 189, 248, 0.25);
  border-color: rgba(56, 189, 248, 0.45);
  color: #f0f9ff;
  transform: translateY(-1px);
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.pagination__pages {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.pagination__page {
  min-width: 2.25rem;
  justify-content: center;
}

.pagination__page--active {
  background: rgba(56, 189, 248, 0.32);
  border-color: rgba(56, 189, 248, 0.65);
  color: #f0f9ff;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 3rem;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: stretch;
  justify-content: center;
  z-index: 50;
  width: 100vw;
  height: var(--lightbox-viewport-height, 100dvh);
  min-height: var(--lightbox-viewport-height, 100vh);
  padding: 0;
  overflow: hidden;
  color: #f1f5f9;
}

.lightbox--open {
  display: flex;
}

.lightbox__backdrop {
  position: fixed;
  top: calc(-1 * env(safe-area-inset-top));
  left: calc(-1 * env(safe-area-inset-left));
  right: calc(-1 * env(safe-area-inset-right));
  bottom: calc(-1 * env(safe-area-inset-bottom));
  background: rgba(4, 6, 14, 0.96);
  backdrop-filter: blur(24px);
  width: 100vw;
  height: var(--lightbox-viewport-height, 100dvh);
  min-height: var(--lightbox-viewport-height, 100vh);
}

.lightbox__dialog {
  position: relative;
  width: min(1100px, 94vw);
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 1.5rem);
  min-height: min(92vh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 1.5rem));
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 20px;
  box-shadow: 0 30px 120px rgba(8, 11, 22, 0.7);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior: contain;
}

.lightbox__body {
  display: flex;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  height: 100%;
  min-height: 0;
}

.lightbox__close {
  position: absolute;
  top: calc(22px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.65);
  color: var(--foreground);
  font-size: 1.4rem;
  cursor: pointer;
}

.lightbox__meta-toggle {
  position: absolute;
  top: calc(22px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.18);
  color: #bae6fd;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.lightbox__meta-toggle:hover,
.lightbox__meta-toggle:focus-visible {
  background: rgba(56, 189, 248, 0.32);
  border-color: rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
}

.lightbox__stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: calc(4.2rem + env(safe-area-inset-top)) 3rem calc(2.5rem + env(safe-area-inset-bottom));
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  width: 100%;
  align-self: stretch;
  touch-action: pan-y;
}

.lightbox__nav {
  border: none;
  background: rgba(15, 23, 42, 0.6);
  color: var(--foreground);
  font-size: 1.8rem;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.25);
  transition: transform 0.2s ease;
}

.lightbox__nav:hover {
  transform: translateY(-2px);
}

.lightbox__figure {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  align-items: center;
  margin: 0;
}

.lightbox__figure img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 16px;
  object-fit: contain;
  box-shadow: 0 18px 50px rgba(8, 11, 22, 0.8);
}

.lightbox__figure--animate-next,
.lightbox__figure--animate-prev {
  animation-duration: 0.28s;
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
}

.lightbox__figure--animate-next {
  animation-name: lightbox-swipe-next;
}

.lightbox__figure--animate-prev {
  animation-name: lightbox-swipe-prev;
}

.lightbox__figure--animate-next img,
.lightbox__figure--animate-prev img {
  will-change: transform, opacity;
}

@keyframes lightbox-swipe-next {
  0% {
    transform: translateX(36px);
    opacity: 0.55;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes lightbox-swipe-prev {
  0% {
    transform: translateX(-36px);
    opacity: 0.55;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.lightbox__caption {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
}

.lightbox__title {
  margin: 0;
  font-weight: 600;
  font-size: 1.2rem;
}

.lightbox__themes {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.lightbox__themes .theme-badge {
  background: rgba(56, 189, 248, 0.25);
}

.lightbox__description {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.lightbox__meta {
  width: 280px;
  padding: 3.5rem 2.4rem 2.5rem;
  border-left: 1px solid rgba(71, 85, 105, 0.4);
  background: rgba(10, 13, 24, 0.9);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  transition: width 0.3s ease, padding 0.3s ease, opacity 0.25s ease;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lightbox__meta--collapsed {
  width: 0;
  padding: 3.5rem 0 2.5rem;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.lightbox__meta--open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__meta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.lightbox__meta h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(191, 219, 254, 0.9);
}

.lightbox__edit {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: rgba(191, 219, 254, 0.95);
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.lightbox__edit:hover,
.lightbox__edit:focus-visible {
  background: rgba(37, 99, 235, 0.25);
  border-color: rgba(96, 165, 250, 0.6);
  color: #dbeafe;
}

.lightbox__edit[hidden] {
  display: none !important;
}

#lightbox-exif {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

#lightbox-exif li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.7rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
}

#lightbox-exif li span:first-child {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

#lightbox-exif li a {
  text-decoration: none;
  color: rgba(191, 219, 254, 0.95);
}

#lightbox-exif li a:hover,
#lightbox-exif li a:focus-visible {
  text-decoration: underline;
}

html.lightbox-open,
body.lightbox-open {
  overflow: hidden;
  height: 100%;
}

html.lightbox-open {
  touch-action: none;
  overscroll-behavior: none;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .layout__sidebar {
    position: static;
  }

  .lightbox__body {
    flex-direction: column;
    align-items: stretch;
  }

  .lightbox__dialog {
    flex: 1;
    height: 100%;
    min-height: 100%;
    max-height: none;
  }

  .lightbox__stage {
    justify-content: flex-start;
    padding: calc(3.4rem + env(safe-area-inset-top)) 2rem 2rem;
  }

  .lightbox__meta {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(71, 85, 105, 0.4);
    padding: 2.4rem 2rem;
  }
}

@media (max-width: 720px) {
  .lightbox {
    align-items: stretch;
  }

  .site-header {
    padding: 3rem 1rem 1.5rem;
  }

  .layout {
    width: 90vw;
    gap: 1.6rem;
  }

  .gallery {
    gap: 1.1rem;
  }

  .lightbox__dialog {
    width: 100vw;
    max-width: 100vw;
    height: var(--lightbox-viewport-height, 100dvh);
    min-height: var(--lightbox-viewport-height, 100vh);
    border-radius: 0;
    margin: 0;
  }

  .lightbox__stage {
    flex-direction: column;
    justify-content: flex-start;
    padding: calc(3rem + env(safe-area-inset-top)) 0.8rem calc(1.2rem + env(safe-area-inset-bottom));
  }

  .lightbox__figure {
    width: 100%;
  }

  .lightbox__figure img {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 14rem);
  }

  .lightbox__caption {
    padding: 0 0.4rem;
  }

  .lightbox__meta {
    padding: 1.6rem 1.4rem calc(2rem + env(safe-area-inset-bottom));
  }
}

@media (min-width: 1025px) {
  .lightbox {
    align-items: center;
  }
}
