.page-gallery-feed {
  min-height: 100vh;
  overflow: hidden;
}

.gallery-feed-shell {
  --feed-header-height: 82px;
  min-height: 100vh;
}

.gallery-feed-page {
  height: calc(100dvh - var(--feed-header-height));
  min-height: 0;
  overflow: hidden;
}

.gallery-feed-close {
  position: absolute;
  top: calc(var(--feed-header-height) + 12px);
  /* Прижат к правому верхнему углу активного комикса: JS копирует сюда
     --feed-comic-half-width текущей карточки. Ширина комиксов разная,
     поэтому позиция едет за активным. min() не даёт уйти за край экрана. */
  left: min(
    calc(50% + var(--feed-active-comic-half, 399px) + clamp(16px, 1.6vw, 24px)),
    calc(100% - 58px)
  );
  z-index: 6;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(2, 8, 20, 0.66);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 10px 26px rgba(0, 0, 0, 0.3);
  color: #cbd6e6;
  transition-property: color, background-color, scale, box-shadow, left;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

.gallery-feed-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.gallery-feed-close:hover {
  color: #fff;
  background: rgba(10, 22, 44, 0.82);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.24),
    0 12px 30px rgba(0, 0, 0, 0.36);
  scale: 1.06;
}

.gallery-feed-close:active {
  scale: 0.94;
}

.gallery-feed {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}

.gallery-feed:focus,
.gallery-feed:focus-visible {
  outline: none;
}

.gallery-feed::-webkit-scrollbar {
  display: none;
}

.gallery-feed-list {
  display: grid;
  justify-items: center;
}

.gallery-feed-item {
  display: grid;
  width: 100%;
  height: calc(100dvh - var(--feed-header-height) - 32px);
  min-height: 560px;
  align-items: start;
  justify-items: center;
  padding: 12px clamp(12px, 2.4vw, 36px) 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  box-sizing: border-box;
}

.gallery-feed-card {
  --feed-card-height: min(100%, calc(100dvh - var(--feed-header-height) - 64px));
  --feed-comic-half-width: 399px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  justify-content: stretch;
  gap: clamp(14px, 2vw, 28px);
  width: 100%;
  height: var(--feed-card-height);
}

.gallery-feed-comic {
  position: relative;
  grid-column: 2;
  justify-self: center;
  display: block;
  aspect-ratio: var(--feed-comic-aspect, 1 / 1);
  width: min(100%, var(--feed-comic-width, 798px));
  height: min(100%, var(--feed-comic-height, 798px));
  max-height: 100%;
  min-height: 0;
  align-self: start;
  overflow: hidden;
  border-radius: 14px;
  background: #040a14;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 24px 72px rgba(2, 10, 30, 0.42);
}

.gallery-feed-pages {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background: #040a14;
}

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

.gallery-feed-slide {
  display: grid;
  width: 100%;
  height: 100%;
  flex: 0 0 100%;
  align-items: start;
  justify-items: center;
  padding: 0;
}

.gallery-feed-page-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center top;
  outline: 1px solid rgba(255, 255, 255, 0.1);
  outline-offset: -1px;
}

.gallery-feed-empty {
  margin: auto;
  color: var(--soft);
  font-weight: 800;
}

.gallery-feed-page-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(124, 164, 232, 0.32);
  border-radius: 50%;
  background: rgba(6, 14, 28, 0.76);
  color: var(--ink);
  cursor: pointer;
  transform: translateY(-50%);
  backdrop-filter: blur(6px);
  transition-property: background-color, border-color, opacity, scale;
  transition-duration: 160ms;
  transition-timing-function: ease-out;
}

.gallery-feed-page-nav:hover {
  background: rgba(18, 36, 68, 0.9);
}

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

.gallery-feed-page-nav:active {
  scale: 0.96;
}

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

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

.gallery-feed-page-prev {
  left: 12px;
}

.gallery-feed-page-next {
  right: 12px;
}

.gallery-feed-counter {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 3;
  padding: 5px 12px;
  border: 1px solid rgba(124, 164, 232, 0.26);
  border-radius: 999px;
  background: rgba(6, 14, 28, 0.78);
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
  transform: translateX(-50%);
}

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

.gallery-feed-meta {
  position: absolute;
  right: calc(50% + var(--feed-comic-half-width) + clamp(18px, 2.2vw, 34px));
  bottom: 12px;
  z-index: 3;
  display: grid;
  width: min(340px, 100%);
  min-width: 0;
  gap: 9px;
  padding: 0 0 12px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.86);
}

.gallery-feed-title {
  margin: 0;
  color: #fff;
  font-size: clamp(18px, 1.8vw, 26px);
  line-height: 1.15;
  text-wrap: balance;
}

.gallery-feed-model-fallback {
  width: max-content;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid rgba(124, 164, 232, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(233, 240, 255, 0.82);
  font-size: 12px;
  font-weight: 800;
}

.gallery-feed-model-card {
  width: min(100%, 310px);
  margin-top: 4px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(8, 18, 36, 0.76);
  box-shadow:
    0 0 0 1px rgba(86, 167, 255, 0.22),
    0 18px 44px rgba(2, 8, 18, 0.28);
  backdrop-filter: blur(14px);
}

.gallery-feed-model-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-feed-model-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(124, 164, 232, 0.28);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
}

.gallery-feed-model-icon img {
  width: 27px;
  height: 27px;
  object-fit: contain;
}

.gallery-feed-model-icon.seedream-icon {
  background: linear-gradient(135deg, rgba(43, 137, 255, 0.28), rgba(34, 209, 167, 0.16));
}

.gallery-feed-model-icon.google-icon,
.gallery-feed-model-icon.openai-icon {
  background: #ffffff;
}

.gallery-feed-model-name {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.gallery-feed-model-name strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.08;
}

.gallery-feed-model-name em {
  color: var(--soft);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-feed-model-specs {
  display: grid;
  gap: 5px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.gallery-feed-model-specs li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.gallery-feed-model-specs strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.gallery-feed-spec-bar {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  width: 58px;
  gap: 5px;
}

.gallery-feed-spec-bar i {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: rgba(92, 105, 130, 0.55);
}

.gallery-feed-spec-bar.good i:nth-child(-n + 3),
.gallery-feed-spec-bar.mid i:nth-child(-n + 2),
.gallery-feed-spec-bar.bad i:nth-child(1) {
  background: var(--bar-color);
  box-shadow: 0 0 10px color-mix(in srgb, var(--bar-color) 42%, transparent);
}

.gallery-feed-spec-bar.good {
  --bar-color: #55df91;
}

.gallery-feed-spec-bar.mid {
  --bar-color: #ffc553;
}

.gallery-feed-spec-bar.bad {
  --bar-color: #ff6678;
}

.gallery-feed-actions {
  position: absolute;
  top: auto;
  bottom: clamp(18px, 5.2vh, 58px);
  left: calc(50% + var(--feed-comic-half-width) + clamp(16px, 1.6vw, 24px));
  z-index: 3;
  display: grid;
  gap: 15px;
  justify-items: center;
  padding-bottom: 12px;
}

.gallery-feed-action {
  display: grid;
  justify-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--soft);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.gallery-feed-action-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(124, 164, 232, 0.22);
  border-radius: 50%;
  background: rgba(9, 18, 34, 0.9);
  color: var(--ink);
  transition-property: transform, border-color, background-color, scale;
  transition-duration: 160ms;
  transition-timing-function: ease-out;
}

.gallery-feed-action:hover .gallery-feed-action-icon {
  border-color: rgba(86, 167, 255, 0.52);
  background: rgba(16, 36, 68, 0.94);
  transform: translateY(-1px);
}

.gallery-feed-action:active .gallery-feed-action-icon {
  scale: 0.96;
}

.gallery-feed-action svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
}

.gallery-feed-like.is-liked {
  color: #ff6f8b;
}

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

.gallery-feed-like.is-liked svg {
  fill: currentColor;
}

.gallery-feed-scroll-next {
  position: absolute;
  top: 50%;
  right: clamp(18px, 2.6vw, 52px);
  z-index: 3;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(86, 167, 255, 0.32);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(120, 189, 255, 0.22), transparent 44%),
    rgba(8, 20, 40, 0.86);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 40px rgba(4, 10, 22, 0.34),
    0 0 34px rgba(24, 116, 217, 0.14);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transform: translateY(-50%);
  transition-property: background-color, border-color, box-shadow, scale;
  transition-duration: 160ms;
  transition-timing-function: ease-out;
}

.gallery-feed-scroll-next:hover {
  border-color: rgba(86, 167, 255, 0.58);
  background:
    radial-gradient(circle at 35% 28%, rgba(120, 189, 255, 0.32), transparent 46%),
    rgba(15, 42, 78, 0.9);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.07),
    0 18px 44px rgba(4, 10, 22, 0.38),
    0 0 42px rgba(24, 116, 217, 0.24);
}

.gallery-feed-scroll-next:active {
  scale: 0.96;
}

.gallery-feed-scroll-next svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.gallery-feed-status {
  margin: 0;
  padding: 24px 0 48px;
  color: var(--soft);
  text-align: center;
  font-weight: 800;
}

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

@media (max-width: 760px) {
  .gallery-feed-shell {
    --feed-header-height: 72px;
  }

  .gallery-feed-close {
    top: calc(var(--feed-header-height) + 8px);
    left: auto;
    right: 10px;
    width: 40px;
    height: 40px;
  }

  .gallery-feed-close svg {
    width: 18px;
    height: 18px;
  }

  .gallery-feed-item {
    height: calc(100dvh - var(--feed-header-height) - 10px);
    min-height: 480px;
    padding: 6px 8px 0;
  }

  .gallery-feed-card {
    --feed-card-height: min(100%, calc(100dvh - var(--feed-header-height) - 18px));
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    width: 100%;
    position: relative;
  }

  .gallery-feed-comic {
    grid-column: 1;
    justify-self: center;
    align-self: start;
    border-radius: 14px;
  }

  .gallery-feed-actions {
    position: absolute;
    right: 10px;
    bottom: clamp(118px, 18vh, 168px);
    z-index: 5;
    display: grid;
    align-items: center;
    justify-items: center;
    gap: 12px;
    padding: 0;
  }

  .gallery-feed-action-icon {
    width: 42px;
    height: 42px;
    background: rgba(9, 18, 34, 0.74);
    backdrop-filter: blur(10px);
  }

  .gallery-feed-action {
    gap: 3px;
    font-size: 11px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.72);
  }

  .gallery-feed-action svg {
    width: 20px;
    height: 20px;
  }

  .gallery-feed-action span:last-child {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .gallery-feed-title {
    max-width: min(250px, calc(100vw - 124px));
    font-size: 18px;
  }

  .gallery-feed-meta {
    position: absolute;
    right: 86px;
    bottom: 18px;
    left: 14px;
    z-index: 4;
    width: auto;
    padding: 96px 0 0;
    background: linear-gradient(180deg, transparent 0%, rgba(3, 8, 18, 0.58) 60%, rgba(3, 8, 18, 0.9) 100%);
    pointer-events: none;
  }

  .gallery-feed-model-card {
    width: min(242px, calc(100vw - 112px));
    padding: 8px;
    border-radius: 14px;
  }

  .gallery-feed-model-head {
    gap: 8px;
  }

  .gallery-feed-model-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 10px;
  }

  .gallery-feed-model-icon img {
    width: 24px;
    height: 24px;
  }

  .gallery-feed-model-name strong {
    font-size: 13px;
  }

  .gallery-feed-model-name em,
  .gallery-feed-model-specs li {
    font-size: 10px;
  }

  .gallery-feed-model-specs {
    gap: 3px;
    margin-top: 6px;
  }

  .gallery-feed-spec-bar {
    width: 48px;
    gap: 4px;
  }

  .gallery-feed-spec-bar i {
    height: 6px;
  }

  .gallery-feed-model-specs strong {
    font-size: 11px;
  }

  .gallery-feed-scroll-next {
    display: none;
  }
}
