.collections-page {
  background: var(--kh-bg, #f4f6fa);
  color: var(--kh-text, #111318);
}

:root[data-theme="dark"] .collections-page {
  background: var(--kh-bg, #090b10);
  color: var(--kh-text, #f5f7fb);
}

.collections-shell {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(24px, 2vw, 36px) 15px 72px;
}

.collections-page.cub-catalog .collections-shell {
  padding-top: clamp(24px, 2vw, 36px);
  padding-bottom: 72px;
}

.collection-groups {
  display: grid;
  gap: 72px;
}

.collection-group {
  min-width: 0;
  padding-bottom: 50px;
}

.collection-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 25px;
}

.collection-group__heading {
  display: flex;
  align-items: center;
  gap: 24px;
}

.collection-group__heading h2 {
  margin: 0 0 2px;
  font-size: 32px;
  line-height: 1.1;
}

.collection-group__heading div > span,
.collection-group__all {
  color: var(--kh-accent);
  font-size: 16px;
}

.collection-group__all {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
  margin-left: -10px;
  padding: 0 10px;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease, transform 100ms ease-out;
}

.collection-group__all:focus-visible {
  outline: 3px solid var(--kh-accent, #0a84ff);
  outline-offset: 2px;
}

.collection-group__all:active {
  transform: scale(.97);
}

.collection-group__icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 3px solid #858585;
  border-radius: 14px;
  color: #858585;
  font-size: 34px;
  line-height: 1;
}

.collection-group__controls {
  display: flex;
  gap: 20px;
}

.collection-group__controls button {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  color: var(--kh-text, #111318);
  background: var(--kh-surface-soft, #e9edf4);
  font-size: 28px;
  cursor: pointer;
}

.collection-group__controls button:last-child {
  background: var(--kh-accent);
}

.collection-group__track {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 60px) / 3);
  gap: 30px;
  overflow-x: auto;
  padding-bottom: 2px;
  scroll-snap-type: inline mandatory;
  scrollbar-width: none;
}

.collection-group__track::-webkit-scrollbar {
  display: none;
}

.collections-page.cub-catalog .collection-group--focused .collection-group__track {
  width: 100%;
  grid-auto-flow: row;
  grid-auto-columns: initial;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 30px;
  overflow: visible;
  padding-right: 0;
  scroll-snap-type: none;
}

.collection-group--focused .collection-group__controls {
  display: none;
}

.collection-card {
  min-width: 0;
  overflow: hidden;
  border-radius: 40px;
  background: #fff;
  scroll-snap-align: start;
}

:root[data-theme="dark"] .collection-card {
  background: #252320;
}

.collection-card__link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.collection-card__image {
  position: relative;
  display: block;
  overflow: hidden;
  padding-bottom: 50%;
  border-radius: 40px 40px 0 0;
  background: #ddd;
}

.collection-card__image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 200ms ease;
}

.collection-card:hover .collection-card__image img {
  transform: scale(1.025);
}

.collection-card__body {
  position: relative;
  min-height: 245px;
  display: flex;
  flex-direction: column;
  padding: 18px 30px 28px;
}

.collection-card__avatar {
  position: absolute;
  top: 0;
  right: 30px;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 5px solid #fff;
  border-radius: 50%;
  color: var(--kh-accent-ink, #fff);
  background: var(--kh-accent);
  font-size: 28px;
  font-weight: 900;
}

:root[data-theme="dark"] .collection-card__avatar {
  border-color: #252320;
}

.collections-page.cub-catalog .collection-card__avatar,
.collections-page.cub-catalog .collection-creator__avatar {
  overflow: hidden;
  color: transparent;
  background: #08090c;
}

.collection-card__avatar img,
.collection-creator__avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.collection-card__author {
  margin-bottom: 18px;
  color: var(--kh-accent);
  font-size: 15px;
  font-weight: 600;
}

.collection-card__body h3 {
  min-height: 58px;
  margin: 0 0 22px;
  overflow: hidden;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.collection-card__footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 20px;
  margin-top: auto;
  color: rgba(62,62,62,.52);
  font-size: 14px;
}

.collection-card__count {
  color: var(--kh-accent);
}

.collection-card__date {
  grid-row: 2;
}

.collection-card__source {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: end;
  text-align: right;
}

:root[data-theme="dark"] .collection-card__footer {
  color: var(--kh-text-soft, #a7afbc);
}

.collection-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  grid-column: 1 / -1;
  padding: 32px;
  border-radius: 15px;
  color: #74716c;
  background: #fff;
  text-align: center;
}

:root[data-theme="dark"] .collection-empty {
  background: #252320;
}

.collection-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 9fr) minmax(260px, 3fr);
  gap: 30px;
  margin-bottom: 70px;
}

.collection-detail-hero,
.collection-creator {
  border-radius: 40px;
  background: #fff;
}

:root[data-theme="dark"] .collection-detail-hero,
:root[data-theme="dark"] .collection-creator {
  background: #252320;
}

.collection-detail-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  padding: 30px;
}

.collection-detail-hero__image {
  position: relative;
  overflow: hidden;
  min-height: 0;
  aspect-ratio: 20 / 13;
  border-radius: 28px;
  background: #ddd;
}

.collection-detail-hero__image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collection-detail-hero__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.collection-detail-hero__info h1 {
  margin: 0;
  overflow: hidden;
  font-size: 38px;
  font-weight: 400;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.collection-detail-hero__date {
  margin-top: 10px;
  color: #74716c;
  font-size: 16px;
}

.collection-detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
}

.collection-detail-actions button {
  width: 54px;
  height: 54px;
  border: 1px solid #ddd;
  border-radius: 50%;
  color: #777;
  background: transparent;
  font-size: 22px;
}

.collection-detail-stats,
.collection-creator__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: auto;
  padding: 20px 15px;
  border-radius: 28px;
  background: #f3f3f3;
  text-align: center;
}

:root[data-theme="dark"] .collection-detail-stats,
:root[data-theme="dark"] .collection-creator__stats {
  background: var(--kh-surface-soft, #1e2430);
}

.collection-detail-stats strong,
.collection-creator__stats strong {
  display: block;
  font-size: 24px;
}

.collection-detail-stats span,
.collection-creator__stats span {
  display: block;
  margin-top: 4px;
  color: #74716c;
  font-size: 14px;
}

.collection-creator {
  overflow: hidden;
}

.collection-creator__cover {
  height: auto;
  aspect-ratio: 2 / 1;
  display: block;
  overflow: hidden;
  border-radius: 40px 40px 0 0;
  background: var(--kh-accent);
}

.collection-creator__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(.75);
}

.collection-creator__body {
  position: relative;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  padding: 62px 30px 28px;
}

.collection-creator__avatar {
  position: absolute;
  top: 0;
  left: 30px;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 5px solid #fff;
  border-radius: 50%;
  color: var(--kh-accent-ink, #fff);
  background: var(--kh-accent);
  font-size: 32px;
  font-weight: 900;
}

:root[data-theme="dark"] .collection-creator__avatar {
  border-color: #252320;
}

.collection-creator__body h2 {
  margin: 0;
  color: var(--kh-accent);
  font-size: 21px;
}

.collection-creator__body p {
  margin: 8px 0 26px;
  color: #74716c;
}

.collection-creator__stats {
  margin-top: auto;
  padding: 14px 6px 0;
  background: transparent;
}

.collection-items {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 34px 30px;
}

.collection-load {
  min-height: 80px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 12px;
  padding-top: 22px;
}

.collection-load__status {
  margin: 0;
  color: var(--kh-text-soft, #5d6470);
  font-size: 14px;
  text-align: center;
}

.collection-load__status:empty {
  display: none;
}

.collection-load__more {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  color: var(--kh-accent-ink, #fff);
  background: var(--kh-accent, #0a84ff);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform 160ms cubic-bezier(.22,1,.36,1);
}

.collection-load__more[hidden] {
  display: none;
}

.collection-load__more:active {
  transform: scale(.97);
}

#collection-more:focus-visible {
  outline: 3px solid var(--kh-accent, #0a84ff);
  outline-offset: 3px;
}

.collection-load__sentinel {
  width: 100%;
  height: 2px;
  display: block;
}

.collection-load__sentinel[hidden] {
  display: none;
}

.collection-card--skeleton {
  min-height: 310px;
  border-radius: 16px;
  background: linear-gradient(
    100deg,
    var(--kh-surface-soft, #e9edf4) 20%,
    var(--kh-surface-solid, #fff) 40%,
    var(--kh-surface-soft, #e9edf4) 60%
  );
  background-size: 240% 100%;
  animation: collection-skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes collection-skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (max-width: 1200px) {
  .collections-shell { max-width: 1140px; }
  .collection-items { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .collection-detail-layout { grid-template-columns: 1fr; }
  .collection-creator { display: none; }
}

@media (max-width: 900px) {
  .collections-shell { max-width: 720px; padding-top: 66px; padding-bottom: 66px; }
  .collection-group__track { grid-auto-columns: calc((100% - 30px) / 2); }
  .collections-page.cub-catalog .collection-group--focused .collection-group__track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collection-detail-hero { grid-template-columns: 1fr; }
  .collection-detail-hero__image { min-height: 0; }
}

@media (max-width: 700px) {
  .collections-shell { padding: 38px 15px 64px; }
  .collections-page.cub-catalog .collections-shell { padding: 20px 20px 56px; }
  .collection-groups { gap: 36px; }
  .collection-group { padding-bottom: 20px; }
  .collection-group__heading { gap: 14px; }
  .collection-group__heading h2 { font-size: 22px; }
  .collection-group__icon { width: 44px; height: 44px; font-size: 27px; }
  .collection-group__controls { display: none; }
  .collection-group__track { grid-auto-columns: minmax(290px, 88vw); gap: 18px; }
  .collections-page.cub-catalog .collection-group--focused .collection-group__track {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 18px;
    padding-right: 0;
  }
  .collection-card { border-radius: 24px; }
  .collection-card__image { border-radius: 24px 24px 0 0; }
  .collection-card__body { min-height: 220px; padding: 18px 20px 22px; }
  .collection-card__avatar { right: 20px; }
  .collection-detail-hero { padding: 18px; border-radius: 24px; }
  .collection-detail-hero__image { min-height: 0; border-radius: 18px; }
  .collection-detail-hero__info h1 { font-size: 29px; }
  .collection-detail-stats { margin-top: 30px; }
  .collection-detail-stats strong { font-size: 19px; }
  .collection-items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 16px; }
  .collection-card--skeleton { min-height: 250px; }
}

@media (hover: hover) and (pointer: fine) {
  .collection-load__more:hover { filter: brightness(1.05); }
  .collection-group__all:hover { background: var(--kh-accent-soft, rgba(10,132,255,.11)); }
}

@media (prefers-reduced-motion: reduce) {
  .collection-card--skeleton { animation: none; }
  .collection-load__more { transition: none; }
  .collection-load__more:active { transform: none; filter: brightness(.94); }
  .collection-group__all { transition: none; }
  .collection-group__all:active { transform: none; background: var(--kh-accent-soft, rgba(10,132,255,.11)); }
}
