:root {
  --page-bg: #f6f7fb;
  --card-border: #dce0ea;
  --brand: #1f3f66;
  --gallery-cols: 4;
}

body {
  background: radial-gradient(circle at top left, #ffffff 0%, var(--page-bg) 55%, #edf0f7 100%);
  min-height: 100vh;
  padding-bottom: 68px;
}

h1,
h2 {
  color: var(--brand);
}

.category-btn.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.photo-card {
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 30px rgba(31, 63, 102, 0.08);
}

.upload-form {
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 8px 20px rgba(31, 63, 102, 0.06);
}

.photo-image {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  background: #f3f4f8;
  cursor: zoom-in;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.photo-meta {
  padding: 0.9rem 1rem 1rem;
}

.caption {
  font-weight: 600;
}

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

.gallery-grid[data-layout="manual"] {
  grid-template-columns: repeat(var(--gallery-cols), minmax(0, 1fr));
}

.gallery-grid[data-density="compact"] .photo-description,
.gallery-grid[data-density="compact"] .photo-badges,
.gallery-grid[data-density="compact"] .js-edit-meta {
  display: none;
}

.gallery-grid[data-density="minimal"] .photo-description,
.gallery-grid[data-density="minimal"] .photo-kv,
.gallery-grid[data-density="minimal"] .photo-badges,
.gallery-grid[data-density="minimal"] .photo-actions {
  display: none;
}

.gallery-grid[data-density="minimal"] .photo-meta {
  padding: 0.55rem 0.6rem 0.6rem;
}

.gallery-grid[data-density="minimal"] .caption {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.2;
}

.gallery-grid[data-density="thumbs"] .photo-meta {
  display: none;
}

.gallery-grid[data-density="thumbs"] .photo-image {
  aspect-ratio: 1 / 1;
  max-height: none;
  object-fit: cover;
}

.column-value {
  min-width: 3.5rem;
  text-align: right;
}

.column-control {
  min-width: 0;
  width: 100%;
  flex: 0 0 auto;
}

.column-control .form-range {
  min-width: 0;
  width: 100%;
  cursor: pointer;
  touch-action: pan-y;
}

.top-controls {
  flex-wrap: nowrap;
}

.sort-control {
  flex: 0 0 auto;
}

.sort-control .form-select {
  min-width: 8.25rem;
}

.switches-row {
  flex-wrap: nowrap;
}

@media (max-width: 575px) {
  .sort-label {
    display: none;
  }

  .sort-control .form-select {
    min-width: 7.1rem;
    max-width: 9.2rem;
  }
}

@media (min-width: 768px) {
  .switches-row {
    justify-content: flex-start !important;
    gap: 1.25rem !important;
  }

  .column-control {
    min-width: 320px;
    max-width: 560px;
    width: auto;
    flex: 0 0 auto;
  }

  .column-control .form-range {
    min-width: 220px;
    width: auto;
  }
}

.site-footer-fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--card-border);
  color: #2d3f5a;
  padding: 0.6rem 0;
}

body.viewer-open {
  overflow: hidden;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
}

.image-viewer.is-open {
  display: block;
}

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 19, 0.84);
  backdrop-filter: blur(2px);
}

.image-viewer-shell {
  position: relative;
  z-index: 1;
  height: 100%;
  width: min(96vw, 1400px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  color: #eef2fb;
}

.image-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.image-viewer-info-toggle {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.4rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.image-viewer-info-toggle[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.24);
}

.image-viewer-info-toggle:disabled {
  opacity: 0.45;
  cursor: default;
}

.image-viewer-close {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.4rem;
  font-size: 1.5rem;
  line-height: 1;
}

.image-viewer-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0.7rem;
  background: rgba(6, 9, 19, 0.62);
}

.image-viewer-img {
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  transition: transform 0.06s linear;
}

.image-viewer-info {
  display: none;
  margin: 0;
  border-radius: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: rgba(6, 9, 19, 0.62);
}

.image-viewer.show-info .image-viewer-info {
  display: block;
}

.image-viewer-caption,
.image-viewer-description,
.image-viewer-hint {
  margin: 0;
  text-align: center;
}

.image-viewer-caption {
  font-weight: 600;
}

.image-viewer-description {
  margin-top: 0.35rem;
  color: #d8dff0;
}

.image-viewer-hint {
  font-size: 0.85rem;
  color: #c9d2e8;
}

@media (max-width: 767px) {
  .photo-image {
    max-height: 62vh;
  }

  .image-viewer-shell {
    width: 100vw;
    padding: 0.7rem;
  }

  .image-viewer-hint {
    font-size: 0.75rem;
  }
}
