.gallery-page {
  width: min(1180px, 92vw);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 40px) 0 80px;
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.2vw, 28px);
}

.gallery-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.gallery-hero .section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--cyan);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.gallery-title {
  margin: 0;
  font-size: clamp(28px, 4.5vw, 46px);
  line-height: 1.08;
  background: linear-gradient(120deg, var(--ink), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gallery-subtitle {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: clamp(15px, 1.8vw, 18px);
}

.gallery-hero-cta {
  margin-top: 6px;
}

/* Toolbar / tabs */
.gallery-toolbar {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  width: max-content;
  margin: 0 auto;
}

.gallery-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 9px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.gallery-tab:hover {
  color: var(--ink);
}

.gallery-tab.is-active {
  color: #fff;
  background: linear-gradient(120deg, var(--blue), var(--cyan));
  box-shadow: 0 8px 22px var(--shadow);
}

.gallery-status {
  text-align: center;
  color: var(--soft);
  padding: 28px 0;
}

/* Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: clamp(16px, 2.2vw, 26px);
  margin-top: 24px;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: 0 18px 40px var(--shadow);
}

.gallery-card-cover {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: linear-gradient(160deg, #0a1626, #060d18);
  overflow: hidden;
}

.gallery-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

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

.gallery-card-cover.is-empty {
  display: grid;
  place-items: center;
}

.gallery-card-cover.is-empty span {
  color: var(--soft);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-card-views {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(3, 8, 18, 0.7);
  backdrop-filter: blur(6px);
  color: #dce8fb;
  font-size: 12px;
  font-weight: 600;
}

.gallery-card-views svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.gallery-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 8px;
}

.gallery-card-main h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-author {
  font-size: 13px;
  color: var(--soft);
}

.gallery-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px 16px;
  margin-top: auto;
}

.gallery-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.gallery-like svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: fill 0.18s ease, transform 0.18s ease;
}

.gallery-like:hover {
  color: #ff708a;
  border-color: rgba(255, 112, 138, 0.5);
}

.gallery-like.is-liked {
  color: #ff5d7d;
  border-color: rgba(255, 93, 125, 0.6);
  background: rgba(255, 93, 125, 0.12);
}

.gallery-like.is-liked svg {
  fill: #ff5d7d;
  transform: scale(1.08);
}

.gallery-card-make {
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  text-decoration: none;
  white-space: nowrap;
}

.gallery-card-make:hover {
  text-decoration: underline;
}

.gallery-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 32px;
}

.gallery-pagination[hidden] {
  display: none;
}

.gallery-page-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.gallery-page-info {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  min-width: 120px;
  text-align: center;
}

/* Viewer modal */
.gallery-viewer[hidden] {
  display: none;
}

.gallery-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 32px);
}

.gallery-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 14, 0.78);
  backdrop-filter: blur(6px);
}

.gallery-viewer-panel {
  position: relative;
  width: min(720px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--panel-strong);
  box-shadow: 0 30px 80px rgba(3, 16, 40, 0.6);
  overflow: hidden;
}

.gallery-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.gallery-viewer-meta h2 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--ink);
}

.gallery-viewer-meta span {
  color: var(--soft);
  font-size: 13px;
}

.gallery-viewer-close {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.gallery-viewer-close svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.gallery-viewer-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.gallery-viewer-pages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px;
  overflow-y: auto;
}

.gallery-viewer-page {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: block;
}

.gallery-viewer-loading {
  text-align: center;
  color: var(--soft);
  padding: 32px 0;
}

.gallery-viewer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
}

.gallery-viewer-actions .gallery-like {
  padding: 10px 16px;
  font-size: 14px;
}

body.gallery-viewer-open {
  overflow: hidden;
}

@media (max-width: 560px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }

  .gallery-card-main {
    padding: 12px 12px 6px;
  }

  .gallery-card-foot {
    padding: 6px 12px 12px;
  }

  .gallery-card-make {
    display: none;
  }
}

/* Auth modal — ported from creator.css so the gallery can prompt guests to sign in */
.auth-overlay[hidden] {
  display: none !important;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  padding: 24px;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: rgba(3, 7, 15, 0.78);
  backdrop-filter: blur(8px);
}

.auth-overlay .auth-consent {
  max-width: 460px;
  margin: 0;
  color: #aebbd1;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.auth-overlay .auth-consent a {
  color: #8bc2ff;
  text-decoration: underline;
}

.auth-panel {
  position: relative;
  isolation: isolate;
  display: block;
  width: min(100%, 620px);
  aspect-ratio: 1084 / 756;
  border: 0;
  border-radius: 34px;
  padding: 0;
  color: #f7fbff;
  overflow: hidden;
  background: transparent;
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.62),
    0 0 72px rgba(25, 111, 237, 0.22);
  text-align: center;
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("assets/auth-modal-panel.png") center / 100% 100% no-repeat;
  pointer-events: none;
}

.auth-mark {
  display: none;
}

.auth-panel h2 {
  position: absolute;
  top: 164px;
  left: 50%;
  max-width: 360px;
  margin: 0;
  transform: translateX(-50%);
  color: #f8fbff;
  font-size: 28px;
  line-height: 1.12;
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(12, 64, 136, 0.32);
}

.auth-actions {
  position: absolute;
  right: 29px;
  bottom: 51px;
  left: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 84px;
}

.auth-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  border: 0;
  border-radius: 22px;
  color: #f7fbff;
  background: transparent;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease;
}

.auth-button > span {
  transform: translate(-6px, 11px);
}

.auth-button:hover {
  transform: translateY(-1px);
}

.auth-button.is-disabled {
  cursor: not-allowed;
  color: rgba(247, 251, 255, 0.68);
}

.auth-button.is-disabled:hover {
  transform: none;
}

.auth-button--soon {
  pointer-events: none;
}

.auth-button--soon > span:not(.soon-badge) {
  filter: blur(1.4px);
  opacity: 0.58;
}

.auth-provider-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 50%;
}

.auth-provider-icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.google-auth-icon {
  background: #ffffff;
}

.yandex-auth-icon {
  color: #ffffff;
  background: #fc3f1d;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.auth-button--soon .soon-badge {
  position: absolute;
  top: 20px;
  right: 18px;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 9px;
  color: #f8fbff;
  background: rgba(12, 21, 39, 0.72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transform: none;
  backdrop-filter: blur(8px);
}

.auth-panel .auth-error {
  position: absolute;
  top: 302px;
  left: 50%;
  max-width: 390px;
  margin: 0;
  transform: translateX(-50%);
  color: #ffb3b3;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 12px;
  color: #aebbd1;
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease;
}

.auth-close:hover {
  color: #f7fbff;
}

.auth-close svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

@media (max-width: 768px) {
  .auth-overlay {
    padding: 16px 14px;
  }

  .auth-panel {
    width: min(calc(100vw - 28px), 390px, calc((100dvh - 32px) * 1084 / 756));
    height: auto;
    border-radius: clamp(18px, 7vw, 28px);
  }

  .auth-panel h2 {
    top: 34%;
    max-width: 80%;
    font-size: clamp(17px, 4.9vw, 20px);
  }

  .auth-actions {
    right: 4.9%;
    bottom: 9%;
    left: 4.9%;
    gap: 2.8%;
    height: 19.6%;
  }

  .auth-button {
    gap: 7px;
    padding: 0 10px;
    border-radius: 15px;
    font-size: clamp(13px, 3.8vw, 14px);
    line-height: 1;
  }

  .auth-button > span {
    transform: translateY(1px);
  }

  .auth-button--soon {
    justify-content: flex-start;
    padding-right: 42px;
    padding-left: 13%;
  }

  .auth-button--soon .soon-badge {
    top: 50%;
    right: 9px;
    padding: 3px 6px;
    font-size: 8px;
    transform: translateY(-50%);
  }

  .auth-provider-icon {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .auth-provider-icon img {
    width: 17px;
    height: 17px;
  }
}
