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

.gallery-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding-left: 22px;
  text-align: left;
}

.gallery-hero::before {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #78bdff, var(--blue));
  box-shadow: 0 0 22px rgba(55, 143, 255, 0.36);
  content: "";
}

.gallery-kicker {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.gallery-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(32px, 4.4vw, 48px);
  font-weight: 850;
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

/* Unified catalogue controls */
.gallery-controls {
  position: relative;
  padding: 18px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 12% 0%, rgba(42, 127, 240, 0.12), transparent 34%),
    linear-gradient(145deg, rgba(10, 19, 35, 0.94), rgba(5, 12, 24, 0.9));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 20px 52px rgba(0, 0, 0, 0.2);
}

.gallery-toolbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.gallery-control-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.gallery-feed-mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  align-self: end;
  min-height: 48px;
  padding: 10px 22px;
  border-radius: 16px;
  background: linear-gradient(120deg, var(--blue), var(--cyan));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 8px 22px var(--shadow);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition-property: filter, scale, box-shadow;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

.gallery-feed-mode-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.gallery-feed-mode-button:hover {
  filter: brightness(1.12);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16),
    0 10px 26px var(--shadow);
}

.gallery-feed-mode-button:active {
  scale: 0.96;
}

.gallery-control-label,
.gallery-filter-label {
  color: #8190a8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gallery-toolbar {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(2, 8, 20, 0.66);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.09),
    0 8px 24px rgba(0, 0, 0, 0.14);
  width: max-content;
  margin: 0;
}

.gallery-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;
  padding: 8px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition-property: color, background-color, scale;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

.gallery-tab:active {
  scale: 0.96;
}

.gallery-tab[href] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

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

.gallery-mobile-filter-toggle {
  display: none;
}

.gallery-mobile-filter-toggle[hidden] {
  display: none;
}

/* Tag filters (universes / genres) */
.gallery-filters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.gallery-filters[hidden],
.gallery-filter-group[hidden] {
  display: none;
}

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

.gallery-filter-group {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  width: 100%;
}

.gallery-filter-label {
  padding-top: 10px;
}

.gallery-filter-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.gallery-filter-chip {
  position: relative;
  min-height: 36px;
  border: 0;
  background: rgba(2, 8, 20, 0.56);
  box-shadow: 0 0 0 1px rgba(111, 165, 242, 0.25);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 12px;
  cursor: pointer;
  /* `backwards` + a from-only keyframe: chips enter staggered (JS sets the
     delay) and land on their own computed style, so disabled chips still
     settle at their dimmed opacity. */
  animation: gallery-chip-in 320ms ease-out backwards;
  transition-property: color, background-color, box-shadow, opacity, scale;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

@keyframes gallery-chip-in {
  from {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(4px);
  }
}

/* Chips are ~34px tall — extend the hit area toward the 40px minimum.
   -4px on each side stays within the 8px gap, so neighbours never overlap. */
.gallery-filter-chip::after {
  content: "";
  position: absolute;
  inset: -4px;
}

.gallery-filter-chip:hover:not(:disabled) {
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(91, 170, 255, 0.62);
}

.gallery-filter-chip:active:not(:disabled) {
  scale: 0.96;
}

.gallery-filter-chip:disabled {
  opacity: 0.35;
  cursor: default;
}

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

.gallery-filter-count {
  opacity: 0.65;
  font-weight: 500;
  font-size: 12px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

.gallery-filter-reset-reveal {
  display: grid;
  min-height: 0;
  grid-template-rows: 0fr;
  margin-top: -12px;
  opacity: 0;
  pointer-events: none;
  transition-property: grid-template-rows, margin-top, opacity;
  transition-duration: 0.24s, 0.24s, 0.16s;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.gallery-filter-reset-clip {
  min-height: 0;
  overflow: hidden;
}

.gallery-filters.has-active-filters .gallery-filter-reset-reveal {
  grid-template-rows: 1fr;
  margin-top: 0;
  opacity: 1;
  pointer-events: auto;
}

.gallery-filter-more {
  min-height: 40px;
  border: 0;
  background: rgba(2, 8, 20, 0.28);
  box-shadow: 0 0 0 1px rgba(111, 165, 242, 0.2);
  color: var(--soft);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 12px;
  cursor: pointer;
  transition-property: color, box-shadow, scale;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

.gallery-filter-more:active {
  scale: 0.96;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-filter-chip {
    animation: none;
  }

  .gallery-filter-chip:active:not(:disabled),
  .gallery-filter-more:active,
  .gallery-tab:active,
  .gallery-filter-reset:active,
  .gallery-mobile-filter-toggle:active {
    scale: none;
  }

  .gallery-filter-reset-reveal {
    transition: none;
  }

  .gallery-mobile-filter-toggle svg {
    transition: none;
  }
}

.gallery-filter-more:hover {
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(91, 170, 255, 0.62);
}

.gallery-filter-reset {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 40px;
  margin-left: 110px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--soft);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition-property: color, scale;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

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

.gallery-filter-reset:active {
  scale: 0.96;
}

.gallery-tab:focus-visible,
.gallery-filter-chip:focus-visible,
.gallery-filter-more:focus-visible,
.gallery-filter-reset:focus-visible,
.gallery-mobile-filter-toggle:focus-visible {
  outline: 2px solid #8ac4ff;
  outline-offset: 2px;
}

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

/* Dynamic counters (likes, views) — tabular digits prevent layout shift
   when the values change. */
.gallery-card-views,
[data-like-count],
[data-gallery-viewer-likes] {
  font-variant-numeric: tabular-nums;
}

/* A hairline outline gives covers and pages consistent depth on any art.
   Pure white, per the design rule: tinted outlines read as dirt. */
.gallery-card-cover img,
.gallery-viewer-page,
.gallery-tiktok-page {
  outline: 1px solid rgba(255, 255, 255, 0.1);
  outline-offset: -1px;
}

/* 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;
  text-wrap: balance;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.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 {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  text-decoration: none;
  white-space: nowrap;
  transition-property: color, scale;
  transition-duration: 160ms;
  transition-timing-function: ease-out;
}

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

.gallery-card-make:active {
  scale: 0.96;
}

.gallery-card-make:focus-visible {
  outline: 2px solid #8ac4ff;
  outline-offset: 2px;
}

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

.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;
  font-variant-numeric: tabular-nums;
}

.page-gallery .site-footer {
  margin-top: 18px;
}

@media (min-width: 781px) {
  .page-gallery .site-footer {
    width: min(1180px, 92vw);
  }
}

@media (max-width: 780px) {
  .gallery-page {
    width: calc(100% - 28px);
    padding: 20px 0 22px;
    gap: 18px;
  }

  .gallery-hero {
    padding-left: 17px;
  }

  .gallery-title {
    font-size: clamp(30px, 9.4vw, 40px);
  }

  .gallery-controls {
    padding: 13px;
    border-radius: 20px;
  }

  .gallery-toolbar-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .gallery-control-group {
    width: 100%;
    align-items: flex-start;
  }

  .gallery-feed-mode-button {
    width: 100%;
    align-self: stretch;
  }

  .gallery-toolbar {
    display: flex;
    width: 100%;
  }

  .gallery-control-group {
    gap: 6px;
  }

  .gallery-tab {
    min-width: 0;
    flex: 1 1 0;
    padding-inline: 10px;
  }

  .gallery-mobile-filter-toggle:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    min-height: 44px;
    margin-top: 12px;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    background: rgba(2, 8, 20, 0.48);
    box-shadow: 0 0 0 1px rgba(111, 165, 242, 0.25);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition-property: background-color, box-shadow, scale;
    transition-duration: 0.18s;
    transition-timing-function: ease-out;
  }

  .gallery-mobile-filter-toggle:hover {
    background: rgba(8, 20, 39, 0.72);
    box-shadow: 0 0 0 1px rgba(91, 170, 255, 0.5);
  }

  .gallery-mobile-filter-toggle:active {
    scale: 0.96;
  }

  .gallery-mobile-filter-meta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--soft);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .gallery-mobile-filter-toggle svg {
    width: 18px;
    height: 18px;
    transition-property: transform;
    transition-duration: 0.18s;
    transition-timing-function: ease-out;
  }

  .gallery-mobile-filter-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  .gallery-mobile-filter-toggle[aria-expanded="false"] + .gallery-filters {
    display: none;
  }

  .gallery-filters {
    margin-top: 12px;
    padding-top: 12px;
  }

  .gallery-filter-group {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .gallery-filter-label {
    padding-top: 0;
  }

  .gallery-filter-reset {
    margin-left: 0;
  }

  .gallery-pagination {
    gap: 10px;
  }

  .gallery-page-info {
    min-width: 0;
  }

  .page-gallery .site-footer {
    margin-top: 14px;
  }
}

@media (max-width: 420px) {
  .gallery-controls {
    padding: 11px;
  }

  .gallery-tab {
    padding-inline: 7px;
    font-size: 12px;
    white-space: nowrap;
  }

  .gallery-filter-chip,
  .gallery-filter-more {
    padding-inline: 11px;
    font-size: 13px;
  }

  .gallery-page-button {
    padding-inline: 12px;
  }
}

@media (max-width: 780px) and (prefers-reduced-motion: reduce) {
  .gallery-mobile-filter-toggle:active {
    scale: none;
  }

  .gallery-mobile-filter-toggle svg {
    transition: none;
  }
}

/* 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 {
  /* Ширина/высота страницы комикса; точное значение проставляет gallery.js.
     Панель обнимает страницу по бокам вместо пустых полей: ширина считается
     от высоты сцены (высота панели минус шапка 59px и паддинги слайда). */
  --viewer-page-aspect: calc(2 / 3);
  --viewer-height: min(94vh, calc(100vh - 2 * clamp(12px, 3vw, 32px)));

  position: relative;
  width: min(1100px, 96vw, calc((var(--viewer-height) - 59px - 24px) * var(--viewer-page-aspect) + 28px));
  height: var(--viewer-height);
  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;
}

/* Compact single-row header so the comic gets the maximum vertical space. */
.gallery-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.gallery-viewer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.gallery-viewer-meta h2 {
  margin: 0;
  max-width: 100%;
  font-size: 18px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-viewer-model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.gallery-viewer-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.gallery-viewer-like {
  height: 38px;
  padding: 0 14px;
  font-size: 14px;
  line-height: 1;
}

.gallery-viewer-like svg {
  flex-shrink: 0;
}

.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-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

/* Absolute fill gives the carousel a definite height, so each page can be
   bounded by max-height and shown in full (contain) instead of clipping. */
.gallery-viewer-pages {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
}

.gallery-viewer-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 320ms ease;
  will-change: transform;
}

.gallery-viewer-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  box-sizing: border-box;
}

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

.gallery-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(6, 14, 28, 0.72);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.gallery-viewer-nav:hover {
  background: rgba(14, 30, 58, 0.92);
}

.gallery-viewer-nav:disabled {
  opacity: 0.32;
  cursor: default;
}

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

.gallery-viewer-nav svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.gallery-viewer-nav-prev {
  left: 12px;
}

.gallery-viewer-nav-next {
  right: 12px;
}

.gallery-viewer-counter {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(6, 14, 28, 0.82);
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

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

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

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

/* ===================== TikTok mode ===================== */
.gallery-tiktok[hidden] {
  display: none;
}

.gallery-tiktok {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 28px);
  background: rgba(2, 5, 11, 0.92);
  backdrop-filter: blur(8px);
}

.gallery-tiktok-close {
  position: absolute;
  top: clamp(12px, 2vw, 22px);
  right: clamp(12px, 2vw, 24px);
  z-index: 4;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(8, 16, 30, 0.7);
  color: var(--soft);
  cursor: pointer;
  display: grid;
  place-items: center;
}

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

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

.gallery-tiktok-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

/* Phone-like card: solid header bar on top, comic body below. */
.gallery-tiktok-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: min(88vh, 880px);
  aspect-ratio: 10 / 16;
  max-width: 94vw;
  background: #04070e;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(2, 10, 30, 0.7);
  transition: transform 240ms ease, opacity 240ms ease;
  will-change: transform, opacity;
}

.gallery-tiktok-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.gallery-tiktok-pages {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
}

.gallery-tiktok-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 300ms ease;
  will-change: transform;
}

.gallery-tiktok-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-tiktok-page {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.gallery-tiktok-loading {
  margin: auto;
  color: var(--soft);
  font-size: 14px;
}

/* Page arrows reuse .gallery-viewer-nav; nudge them inside the body. */
.gallery-tiktok-body .gallery-viewer-nav {
  z-index: 3;
}

/* Header bar: title / model — sits above the comic, no overlap. */
.gallery-tiktok-head {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.6);
}

.gallery-tiktok-title {
  margin: 0;
  max-width: 100%;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-tiktok-model {
  margin: 0;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* TikTok-style action rail on the right edge of the card. */
.gallery-tiktok-rail {
  position: absolute;
  right: 12px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.gallery-tiktok-like {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
}

.gallery-tiktok-like svg {
  width: 40px;
  height: 40px;
  fill: rgba(255, 255, 255, 0.18);
  stroke: #fff;
  stroke-width: 1.6;
  transition: fill 0.18s ease, transform 0.18s ease;
}

.gallery-tiktok-like:hover svg {
  transform: scale(1.06);
}

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

/* Double-tap-to-like heart burst over the comic. */
.gallery-tiktok-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: 110px;
  height: 110px;
  color: #ff3b5c;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.3);
  animation: tiktok-heart-burst 750ms ease-out forwards;
}

.gallery-tiktok-burst svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55));
}

@keyframes tiktok-heart-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.18);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.98);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

.gallery-tiktok-feedbtn {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(8, 16, 30, 0.72);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.gallery-tiktok-feedbtn:hover {
  background: rgba(20, 34, 62, 0.92);
}

.gallery-tiktok-feedbtn:disabled {
  opacity: 0.32;
  cursor: default;
}

.gallery-tiktok-feednext {
  background: linear-gradient(120deg, var(--blue), var(--cyan));
  border-color: transparent;
}

.gallery-tiktok-feedbtn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.gallery-tiktok-status {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--soft);
  font-size: 14px;
}

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

@media (max-width: 560px) {
  .gallery-tiktok {
    padding: 8px;
  }

  /* Card hugs the comic: fills width, height follows the image — no big
     empty bands above/below it. */
  .gallery-tiktok-card {
    height: auto;
    max-height: 96vh;
    width: 100%;
    max-width: 100%;
    aspect-ratio: auto;
    border-radius: 16px;
  }

  .gallery-tiktok-head {
    padding: 10px 14px;
  }

  .gallery-tiktok-body {
    flex: 0 1 auto;
  }

  .gallery-tiktok-pages {
    position: relative;
    inset: auto;
  }

  .gallery-tiktok-track,
  .gallery-tiktok-slide {
    height: auto;
  }

  .gallery-tiktok-page {
    width: 100%;
    height: auto;
    max-height: calc(96vh - 58px);
  }

  .gallery-tiktok-rail {
    right: 8px;
    bottom: 12px;
    gap: 12px;
  }
}

@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 {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 6px 12px 12px;
  }

  .gallery-card-make {
    min-width: 0;
    min-height: 40px;
    justify-content: flex-end;
    border-radius: 0;
    padding: 0 2px;
    background: transparent;
    box-shadow: none;
    color: var(--cyan);
    font-size: 12px;
    font-weight: 600;
  }

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

  .gallery-viewer-panel {
    --viewer-height: 86vh;
    width: min(92vw, calc((var(--viewer-height) - 59px - 20px) * var(--viewer-page-aspect) + 20px));
    height: var(--viewer-height);
    max-height: 86vh;
    border-radius: 18px;
  }

  .gallery-viewer-slide {
    padding: 10px;
  }

  .gallery-viewer-nav {
    width: 40px;
    height: 40px;
  }

  .gallery-viewer-nav-prev {
    left: 6px;
  }

  .gallery-viewer-nav-next {
    right: 6px;
  }
}

@media (max-width: 560px) and (prefers-reduced-motion: reduce) {
  .gallery-card-make {
    transition: none;
  }

  .gallery-card-make:active {
    scale: 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.webp") 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;
  }
}
