@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

.templates-marketplace-page {
  overflow-x: clip;
  background: #090611;
  color: #f8f4ff;
}

.templates-marketplace-page,
.templates-marketplace-page *,
.templates-marketplace-page *::before,
.templates-marketplace-page *::after {
  box-sizing: border-box;
}

.tm-reference {
  --tm-ink: #f8f4ff;
  --tm-muted: #a69db7;
  --tm-line: rgba(221, 194, 255, .15);
  min-height: 100vh;
  overflow-x: clip;
  background: radial-gradient(ellipse 78% 480px at 50% -150px, rgba(147, 88, 255, .13), transparent 72%), #090611;
  color: var(--tm-ink);
  font-family: 'Manrope', system-ui, sans-serif;
}

.tm-reference svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.tm-ref-shell {
  width: min(1680px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 76px;
}

.tm-ref-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 30px clamp(28px, 5vw, 80px) 28px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 24px;
  background:
    radial-gradient(ellipse 55% 85% at 88% 8%, rgba(168, 85, 247, .16), transparent 62%),
    radial-gradient(ellipse 42% 70% at 64% 100%, rgba(219, 39, 119, .09), transparent 66%),
    linear-gradient(180deg, #130c21 0%, #0d0818 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

.tm-ref-hero::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: '';
  background: radial-gradient(ellipse 70% 55% at 18% 0%, rgba(255, 255, 255, .05), transparent 60%);
}

.tm-ref-art {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: -40px;
  width: min(300px, 28vw);
  opacity: .5;
  filter: saturate(.92);
  transform: translateY(-50%);
  -webkit-mask-image: linear-gradient(102deg, transparent 4%, #000 42%);
  mask-image: linear-gradient(102deg, transparent 4%, #000 42%);
}

.tm-ref-art img {
  display: block;
  width: 100%;
  height: auto;
}

/* Превью подборки в hero — отдельный дизайн: аккуратная карточка в рамке,
   а не декоративная полупрозрачная иконка каталога, вылезающая за край */
.tm-col-hero-preview {
  position: absolute;
  z-index: 0;
  top: 50%;
  right: 26px;
  width: min(168px, 20vw);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid rgba(232, 121, 249, .35);
  border-radius: 20px;
  box-shadow: 0 14px 44px rgba(8, 5, 16, .55), 0 0 34px rgba(204, 76, 178, .18);
  transform: translateY(-50%);
}

.tm-col-hero-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Текст hero всегда поверх превью подборки (планшетные ширины 768–1100px) */
.tm-ref-crumbs,
.tm-ref-heading {
  position: relative;
  z-index: 1;
}

.tm-ref-eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  color: #b3a1d6;
  font: 600 11px 'Space Grotesk', sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.tm-ref-eyebrow span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e879f9;
  box-shadow: 0 0 10px rgba(232, 121, 249, .8);
}

/* Крошки в hero подборки — в стиле eyebrow, но кликабельные */
.tm-ref-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: #b3a1d6;
  font: 600 11px 'Space Grotesk', sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.tm-ref-crumbs .tm-ref-crumb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e879f9;
  box-shadow: 0 0 10px rgba(232, 121, 249, .8);
}

.tm-ref-crumbs a {
  color: #8f7ab8;
  text-decoration: none;
  transition: color .15s;
}

.tm-ref-crumbs a:hover {
  color: #e879f9;
}

.tm-ref-crumbs i {
  font-style: normal;
  color: rgba(179, 161, 214, .35);
}

.tm-ref-crumbs b {
  color: #e9d5ff;
  font-weight: 600;
}

.tm-ref-heading {
  max-width: 790px;
}

.tm-ref-heading h1 {
  margin: 0;
  font: 700 clamp(30px, 3.4vw, 44px) / 1.04 'Space Grotesk', sans-serif;
  letter-spacing: -.03em;
}

.tm-ref-heading h1 em {
  color: #e879f9;
  font-style: normal;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .tm-ref-heading h1 em {
    background: linear-gradient(94deg, #e879f9 10%, #a78bfa 85%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.tm-ref-heading p {
  max-width: 560px;
  margin: 10px 0 0;
  color: #b0a4c6;
  font-size: 14px;
  line-height: 1.55;
}

.tm-ref-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 58px;
  margin-top: 14px;
  padding: 5px 6px 5px 20px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .045);
  box-shadow: none;
  backdrop-filter: blur(14px);
  transition: border-color .25s ease, box-shadow .25s ease, background .25s ease;
}

.tm-ref-search:focus-within {
  border-color: rgba(197, 113, 220, .55);
  background: rgba(255, 255, 255, .065);
  box-shadow: 0 0 0 3px rgba(197, 113, 220, .14), 0 14px 38px rgba(120, 60, 180, .18);
}

.tm-ref-search > svg {
  flex: none;
  width: 22px;
  color: #c3a4fa;
}

.tm-ref-search input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0 16px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font: 15px 'Manrope', sans-serif;
}

.tm-ref-search input::placeholder {
  color: #91869f;
  transition: opacity .2s ease;
}

.tm-ref-search button,
.tm-ref-apply {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  cursor: pointer;
  color: #fff;
  font: 700 12px 'Manrope', sans-serif;
}

.tm-ref-search button {
  height: 46px;
  padding: 0 30px;
  border-radius: 13px;
  font-size: 13px;
  background: linear-gradient(135deg, #c026d3, #8b5cf6);
  box-shadow: 0 6px 18px rgba(147, 51, 234, .26);
  transition: filter .2s ease, transform .2s ease;
}

.tm-ref-search button:hover {
  filter: brightness(1.1);
}

.tm-ref-search button svg {
  width: 17px;
  height: 17px;
}

.tm-ref-apply svg {
  width: 15px;
  height: 15px;
}

.tm-ref-tabs {
  display: flex;
  flex: none;
  gap: 8px;
}

.tm-ref-tab,
.tm-ref-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--tm-line);
  border-radius: 12px;
  background: rgba(40, 23, 73, .58);
  color: #cfc4dc;
  cursor: pointer;
  font: 600 13px 'Manrope', sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

.tm-ref-tab svg,
.tm-ref-filter > svg {
  flex: none;
  width: 17px;
  height: 17px;
  color: #d5a8ff;
}

.tm-ref-tab.active {
  border-color: #db7ce8;
  background: rgba(211, 79, 186, .26);
  color: #fff;
}

.tm-ref-tab:hover,
.tm-ref-filter:hover {
  border-color: rgba(236, 137, 255, .62);
  color: #fff;
}

.tm-ref-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 73px;
  padding: 13px 3px;
  border-bottom: 1px solid var(--tm-line);
}

.tm-ref-filter select {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.tm-ref-filter option,
.tm-ref-sheet select option {
  background: #1a102c;
  color: #fff;
}

.tm-ref-community {
  margin-left: auto;
}

/* Строка активных фильтров: «показано N из M» + сброс */
.tm-ref-active-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 3px;
  border-bottom: 1px solid var(--tm-line);
  color: #9d8cac;
  font-size: 12.5px;
}

.tm-ref-active-filters b {
  color: #fff;
  font-weight: 600;
}

.tm-ref-active-filters a {
  color: #e29df1;
  font-weight: 600;
  text-decoration: none;
}

.tm-ref-active-filters a:hover {
  text-decoration: underline;
}

.tm-mobile-filter {
  display: none;
}

.tm-dropdown {
  position: relative;
  padding: 0 12px;
}

.tm-dropdown.enhanced > select {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tm-dropdown.enhanced > svg {
  display: none;
}

.tm-select-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 100%;
  min-width: 105px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.tm-select-trigger > svg {
  width: 15px;
  height: 15px;
  color: #d5a8ff;
}

.tm-select-trigger span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-select-chevron {
  width: 12px !important;
  height: 12px !important;
  flex: none;
  color: #a999b8;
  transition: transform .18s ease;
}

.tm-dropdown.open {
  z-index: 20;
  border-color: rgba(236, 137, 255, .7);
}

.tm-dropdown.open .tm-select-chevron {
  transform: rotate(180deg);
}

.tm-select-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 7px);
  left: 0;
  display: none;
  width: max(100%, 210px);
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(226, 132, 255, .28);
  border-radius: 11px;
  background: linear-gradient(180deg, #24103d, #10071f);
  box-shadow: 0 22px 55px rgba(0, 0, 0, .56);
}

.tm-dropdown.open .tm-select-menu {
  display: block;
}

.tm-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d6c8df;
  cursor: pointer;
  font: 11px 'Manrope', sans-serif;
  text-align: left;
}

.tm-select-option:hover,
.tm-select-option:focus-visible,
.tm-select-option.active {
  outline: 0;
  background: rgba(194, 77, 220, .19);
  color: #fff;
}

.tm-select-option svg {
  width: 13px;
  height: 13px;
  stroke: transparent;
}

.tm-select-option.active svg {
  stroke: #ebb5ff;
}

.tm-ref-section {
  margin-top: 35px;
}

.tm-ref-catalog {
  margin-top: 46px;
}

.tm-ref-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.tm-ref-section-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font: 600 20px 'Space Grotesk', sans-serif;
  letter-spacing: -.035em;
}

.tm-ref-section-head h2 span {
  margin-left: 2px;
  color: #9d8cac;
  font: 500 12px 'Manrope', sans-serif;
}

.tm-ref-section-head > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid var(--tm-line);
  border-radius: 10px;
  background: rgba(87, 42, 98, .22);
  color: #d8c8e8;
  font-size: 12px;
  text-decoration: none;
  transition: border-color .2s, background .2s, color .2s;
}

.tm-ref-section-head > a:hover {
  border-color: #c571dc;
  background: rgba(87, 42, 98, .42);
  color: #fff;
}

.tm-ref-section-head > a svg {
  width: 14px;
  height: 14px;
}

.tm-ref-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 13px;
}

.tm-ref-popular {
  position: relative;
  min-width: 0;
  aspect-ratio: 1.38;
  overflow: hidden;
  border: 1px solid var(--tm-line);
  border-radius: 16px;
  background: #1a102b;
}

.tm-ref-popular > img,
.tm-ref-popular > .tm-hover-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}

.tm-ref-popular:hover > img,
.tm-ref-popular:hover > .tm-hover-video,
.tm-ref-card:hover .tm-ref-card-media img,
.tm-ref-card:hover .tm-ref-card-media video {
  transform: scale(1.04);
}

.tm-ref-popular::after {
  position: absolute;
  inset: 35% 0 0;
  content: '';
  background: linear-gradient(transparent, rgba(8, 5, 15, .96));
  pointer-events: none;
}

.tm-ref-fav {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 9px;
  background: rgba(13, 8, 23, .62);
  color: #fff;
  cursor: pointer;
}

.tm-ref-fav svg {
  width: 15px;
  height: 15px;
}

.tm-ref-fav.active {
  color: #ff83cf;
}

.tm-ref-fav.active svg {
  fill: currentColor;
}

.tm-ref-popular-info {
  position: absolute;
  z-index: 3;
  right: 13px;
  bottom: 12px;
  left: 13px;
  color: #fff;
  text-decoration: none;
  /* Блок не перехватывает клики — карточки низкие (1.38), иначе вся середина
     вела на detail вместо превью-модалки. Кликабелен только сам заголовок. */
  pointer-events: none;
}

.tm-ref-popular-info strong {
  pointer-events: auto;
}

/* Вся карточка «Популярного» открывает превью-модалку: прозрачная кнопка-оверлей поверх медиа */
.tm-ref-popular-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: none;
  cursor: pointer;
}

/* Сердечко избранного — поверх ссылки-оверлея */
.tm-ref-popular .tm-ref-fav {
  z-index: 4;
}

.tm-ref-labels {
  display: flex;
  gap: 4px;
}

.tm-ref-labels span,
.tm-ref-badge {
  display: inline-flex;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 5px;
  background: rgba(6, 3, 14, .82);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
}

.tm-ref-popular-info strong {
  display: block;
  overflow: hidden;
  margin: 6px 0 3px;
  padding-right: 29px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-ref-popular-info small,
.tm-ref-provider,
.tm-ref-stat {
  color: #aaa1b6;
  font-size: 10px;
}

.tm-ref-popular-arrow {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 1px solid rgba(207, 167, 236, .15);
  border-radius: 7px;
  background: rgba(39, 17, 61, .71);
}

.tm-ref-popular-arrow svg {
  width: 13px;
  height: 13px;
}

.tm-ref-collections {
  display: flex;
  gap: 11px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.tm-ref-collections::-webkit-scrollbar {
  display: none;
}

.tm-ref-slider {
  position: relative;
}

.tm-ref-slider-btn {
  position: absolute;
  top: 50%;
  left: 8px;
  z-index: 3;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--tm-line);
  border-radius: 50%;
  background: rgba(22, 12, 36, .92);
  color: #eadffa;
  cursor: pointer;
  transform: translateY(-50%);
  transition: opacity .2s, background .2s;
}

.tm-ref-slider-btn svg {
  width: 18px;
  height: 18px;
}

.tm-ref-slider-btn:hover {
  background: rgba(52, 26, 80, .95);
}

.tm-ref-slider-btn[disabled] {
  opacity: 0;
  pointer-events: none;
}

.tm-ref-slider-next {
  right: 8px;
  left: auto;
}

.tm-ref-collection {
  position: relative;
  display: flex;
  flex: 0 0 calc((100% - 55px) / 6);
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  padding: 14px 13px;
  border: 1px solid var(--tm-line);
  border-radius: 14px;
  background: #1c112c;
  color: #fff;
  scroll-snap-align: start;
  text-decoration: none;
}

.tm-ref-collection::after {
  position: absolute;
  inset: 0;
  content: '';
  background: linear-gradient(180deg, rgba(8, 5, 15, .92) 0%, rgba(8, 5, 15, .55) 34%, rgba(10, 6, 18, 0) 62%);
}

.tm-ref-collection b,
.tm-ref-collection small {
  position: relative;
  z-index: 1;
}

.tm-ref-collection img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .9;
  transition: transform .3s;
}

.tm-ref-collection:hover img {
  transform: scale(1.05);
}

.tm-ref-collection b,
.tm-ref-collection small {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 72%;
}

.tm-ref-collection b {
  font-size: 14px;
  line-height: 1.18;
}

.tm-ref-collection small {
  margin-top: 9px;
  color: #a89caf;
  font-size: 11px;
}

.tm-ref-grid {
  display: block;
  column-gap: 15px;
  columns: 5 230px;
}

.tm-ref-card {
  position: relative;
  display: block;
  min-width: 0;
  margin: 0 0 15px;
  overflow: hidden;
  break-inside: avoid;
  border: 1px solid var(--tm-line);
  border-radius: 15px;
  background: #171027;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .16);
  transition: transform .2s ease, border-color .2s ease;
}

.tm-ref-card:hover {
  border-color: rgba(224, 118, 236, .57);
  transform: translateY(-3px);
}

.tm-ref-card-media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--tm-ratio, 4 / 5);
  min-height: 170px;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: #201332;
  cursor: pointer;
}

.tm-ref-card-media img,
.tm-ref-card-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}

.tm-ref-card-media video {
  background: #201332;
}

/* Плейсхолдер для шаблонов без превью (или с битым медиа) */
.tm-ref-media-ph {
  display: grid;
  width: 100%;
  aspect-ratio: 4 / 5;
  place-items: center;
  background: linear-gradient(160deg, #201332, #150d24);
  color: #5b4a75;
}

.tm-ref-media-ph svg {
  width: 34px;
  height: 34px;
}

.tm-ref-badge {
  position: absolute;
  z-index: 2;
  top: 9px;
  left: 9px;
}

.tm-ref-card-body {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: 40px 12px 12px;
  background: linear-gradient(180deg, rgba(9, 6, 17, 0) 0%, rgba(9, 6, 17, .82) 48%, rgba(9, 6, 17, .95) 100%);
}

.tm-ref-stat {
  flex: 1 0 auto;
}

/* Десктоп: информация о шаблоне появляется при наведении / фокусе */
@media (hover: hover) {
  .tm-ref-card-body {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .22s ease, transform .22s ease;
    pointer-events: none;
  }

  .tm-ref-card:hover .tm-ref-card-body,
  .tm-ref-card:focus-within .tm-ref-card-body {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

/* Тач-устройства: компактная плашка видна всегда — тап по медиа открывает превью */
@media (hover: none) {
  /* Плашка уходит ПОД медиа статичным блоком: на коротких карточках она
     перекрывала центр превью-кнопки и тап вёл на title-ссылку вместо превью */
  .tm-ref-card .tm-ref-card-body {
    position: static;
    padding: 10px 12px;
    background: none;
    opacity: 1;
    transform: none;
  }

  .tm-ref-title {
    -webkit-line-clamp: 1;
    min-height: 0;
  }

  .tm-ref-card .tm-ref-stat {
    display: none;
  }

  .tm-ref-card .tm-ref-apply {
    height: 38px;
    margin-top: 8px;
  }
}

.tm-ref-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  min-height: 35px;
  overflow: hidden;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.tm-ref-title:hover {
  color: #f3d7ff;
}

.tm-ref-provider {
  overflow: hidden;
  margin-top: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-ref-stat {
  margin-top: 3px;
}

.tm-ref-apply {
  width: 100%;
  height: 34px;
  margin-top: 12px;
  border: 1px solid rgba(220, 118, 221, .38);
  border-radius: 9px;
  background: rgba(204, 76, 178, .15);
  color: #e6c4ea;
}

.tm-ref-apply:hover {
  background: rgba(204, 76, 178, .29);
  color: #fff;
}

.tm-list .tm-ref-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  columns: auto;
}

.tm-list .tm-ref-card {
  display: grid;
  grid-template-columns: 300px 1fr;
  margin: 0;
}

.tm-list .tm-ref-card-media {
  grid-row: span 2;
  aspect-ratio: 4 / 3;
  min-height: 0;
}

.tm-list .tm-ref-card-media img,
.tm-list .tm-ref-card-media video {
  height: 100%;
  object-fit: cover;
}

.tm-list .tm-ref-card-body {
  position: static;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  align-items: center;
  gap: 10px 16px;
  padding: 12px;
  background: none;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.tm-list .tm-ref-title,
.tm-list .tm-ref-provider,
.tm-list .tm-ref-stat {
  grid-column: 1;
}

.tm-list .tm-ref-apply {
  grid-column: 2;
  grid-row: 1 / 4;
  height: 34px;
  margin-top: 0;
}

.tm-ref-view {
  display: flex;
  gap: 8px;
  color: #a472ec;
}

.tm-ref-view button {
  display: grid;
  width: 25px;
  height: 25px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: #806b95;
  cursor: pointer;
}

.tm-ref-view button.active {
  color: #d48ae7;
}

.tm-ref-view svg {
  width: 17px;
  height: 17px;
}

.tm-ref-pages {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 34px;
}

.tm-ref-pages a,
.tm-ref-pages span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 46px;
  padding: 0 15px;
  border: 1px solid rgba(197, 113, 220, .45);
  border-radius: 11px;
  background: rgba(139, 92, 246, .08);
  color: #e6dbf2;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .2s, background .2s, color .2s;
}

.tm-ref-pages a:hover {
  border-color: #c571dc;
  background: rgba(139, 92, 246, .18);
  color: #fff;
}

.tm-ref-pages .active {
  border-color: #8b5cf6;
  background: #572a62;
  color: #fff;
}

.tm-ref-pages .ellipsis {
  border-color: transparent;
}

.tm-ref-empty {
  padding: 70px 15px;
  color: var(--tm-muted);
  text-align: center;
}

.tm-ref-empty h2 {
  color: #fff;
  font: 600 20px 'Space Grotesk', sans-serif;
}

.tm-ref-empty a {
  display: inline-flex;
  margin-top: 10px;
  color: #d48ae7;
}

.tm-reference.tm-loading .tm-ref-shell {
  opacity: .55;
  pointer-events: none;
  transition: opacity .15s ease;
}

.tm-ref-shell {
  transition: opacity .18s ease;
}

.tm-ref-sheet,
.tm-ref-preview {
  display: none;
}

.tm-scroll-lock {
  overflow: hidden;
}

.tm-ref-preview.open {
  position: fixed;
  z-index: 10060;
  inset: 0;
  display: block;
  overflow: auto;
  padding: 20px;
  background: rgba(4, 3, 10, .88);
}

.tm-ref-preview-panel {
  position: relative;
  width: min(1180px, calc(100vw - 40px));
  margin: 2vh auto;
  padding: 14px;
  border: 1px solid rgba(191, 160, 255, .3);
  border-radius: 18px;
  background: #171027;
}

.tm-ref-preview-media {
  display: grid;
  min-height: min(280px, 52vh);
  max-height: 52vh;
  overflow: hidden;
  place-items: center;
  border-radius: 12px;
  background: #080611;
  color: var(--tm-muted);
}

.tm-ref-preview-media img,
.tm-ref-preview-media video {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 52vh;
  object-fit: contain;
}

.tm-ref-preview-close {
  position: absolute;
  z-index: 1;
  top: 22px;
  right: 22px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px;
  background: rgba(16, 13, 28, .9);
  color: #fff;
  cursor: pointer;
  font-size: 25px;
}

.tm-ref-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.tm-ref-control,
.tm-ref-preview-actions .tm-ref-apply {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 150px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 12px;
  text-decoration: none;
}

.tm-ref-control {
  border: 1px solid var(--tm-line);
  background: rgba(40, 23, 73, .58);
  color: #d8c7e7;
}

.tm-ref-control:hover {
  color: #fff;
}

.tm-ref-control:focus-visible,
.tm-ref-tab:focus-visible,
.tm-ref-filter:focus-visible,
.tm-ref-fav:focus-visible,
.tm-ref-card-media:focus-visible,
.tm-ref-apply:focus-visible,
.tm-ref-search button:focus-visible,
.tm-ref-preview-close:focus-visible,
.tm-ref-view button:focus-visible,
.tm-select-trigger:focus-visible,
.tm-select-option:focus-visible {
  outline: 2px solid #f59ad1;
  outline-offset: 3px;
}

@media (max-width: 1100px) {
  .tm-ref-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tm-ref-collection {
    flex-basis: calc((100% - 22px) / 3);
  }

  .tm-ref-art {
    right: -130px;
    opacity: .48;
  }

  .tm-col-hero-preview {
    right: 18px;
    width: 120px;
  }

  .tm-ref-heading {
    max-width: 680px;
  }
}

@media (max-width: 767px) {
  .tm-ref-shell {
    width: 100%;
    padding: 12px 0 50px;
  }

  .tm-ref-hero {
    padding: 22px 18px 18px;
    border-radius: 0 0 23px 23px;
  }

  .tm-ref-art {
    top: 16px;
    right: -110px;
    width: 240px;
    opacity: .3;
  }

  .tm-ref-heading {
    position: relative;
  }

  .tm-ref-heading h1 {
    font-size: 30px;
  }

  .tm-ref-heading p {
    font-size: 13px;
  }

  .tm-ref-search {
    margin-top: 14px;
  }

  .tm-ref-search-hint {
    display: none;
  }

  .tm-col-hero-preview {
    display: none;
  }

  .tm-ref-search button {
    padding: 0 16px;
  }

  .tm-ref-tabs {
    flex: 1 0 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tm-ref-tabs::-webkit-scrollbar {
    display: none;
  }

  .tm-ref-toolbar {
    flex-wrap: wrap;
    padding: 10px 16px;
    overflow: hidden;
  }

  .tm-ref-toolbar .tm-desktop-select {
    display: none;
  }

  .tm-mobile-filter {
    display: inline-flex;
  }

  .tm-ref-sort {
    margin-left: auto;
  }

  .tm-ref-community {
    display: none;
  }

  .tm-ref-section {
    margin-top: 29px;
    padding: 0 16px;
  }

  .tm-ref-catalog {
    margin-top: 39px;
  }

  .tm-ref-rail,
  .tm-ref-collections {
    display: flex;
    margin-right: -16px;
    overflow-x: auto;
    padding-right: 16px;
    scrollbar-width: none;
  }

  .tm-ref-rail::-webkit-scrollbar,
  .tm-ref-collections::-webkit-scrollbar {
    display: none;
  }

  .tm-ref-popular {
    flex: 0 0 76vw;
  }

  .tm-ref-collection {
    flex: 0 0 205px;
  }

  .tm-ref-slider-btn {
    display: none;
  }

  .tm-ref-grid {
    column-gap: 10px;
    columns: 2;
  }

  .tm-ref-card {
    margin-bottom: 10px;
    border-radius: 12px;
  }

  .tm-ref-card-body {
    padding: 28px 9px 9px;
  }

  .tm-ref-title {
    font-size: 12px;
  }

  .tm-ref-provider,
  .tm-ref-stat {
    font-size: 9px;
  }

  .tm-ref-stat {
    display: none;
  }

  .tm-ref-provider {
    flex: 1 0 auto;
  }

  .tm-ref-view {
    display: none;
  }

  .tm-ref-pages {
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 24px;
  }

  .tm-ref-pages a,
  .tm-ref-pages span {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    font-size: 11px;
  }

  .tm-ref-card-media {
    min-height: 130px;
  }

  .tm-list .tm-ref-listonly {
    display: none;
  }

  .tm-list .tm-ref-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    columns: auto;
  }

  .tm-list .tm-ref-card {
    display: block;
  }

  .tm-list .tm-ref-card-body {
    display: block;
  }

  .tm-list .tm-ref-apply {
    width: 100%;
    height: 34px;
    margin-top: 12px;
  }

  .tm-ref-sheet.open {
    position: fixed;
    z-index: 10050;
    inset: 0;
    display: block;
    background: rgba(4, 2, 9, .75);
  }

  .tm-ref-sheet-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 20px 16px calc(22px + env(safe-area-inset-bottom));
    border: 1px solid rgba(204, 154, 255, .2);
    border-radius: 22px 22px 0 0;
    background: #19112a;
  }

  .tm-ref-sheet-panel > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
  }

  .tm-ref-sheet-panel strong {
    font: 600 17px 'Space Grotesk', sans-serif;
  }

  .tm-ref-sheet-panel button {
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 22px;
  }

  .tm-ref-sheet-panel select {
    width: 100%;
    height: 45px;
    margin: 5px 0;
    padding: 0 12px;
    border: 1px solid var(--tm-line);
    border-radius: 10px;
    background: #110b20;
    color: #fff;
    font: 12px 'Manrope', sans-serif;
  }

  .tm-ref-preview.open {
    padding: 10px;
  }

  .tm-ref-preview-panel {
    width: 100%;
    margin: 3vh auto;
    padding: 10px;
  }

  .tm-ref-preview-media {
    min-height: min(240px, 42vh);
  }

  .tm-ref-preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tm-ref-control,
  .tm-ref-preview-actions .tm-ref-apply {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
  }
}

@media (max-width: 360px) {
  .tm-ref-collection {
    flex: 0 0 148px;
  }

  .tm-ref-heading h1 {
    font-size: 26px;
  }

  .tm-ref-popular {
    flex-basis: 79vw;
  }

  .tm-ref-grid {
    gap: 7px;
  }

  .tm-ref-title {
    font-size: 11px;
  }

  .tm-ref-search input {
    padding: 0 8px;
  }

  .tm-ref-search button {
    padding: 0 10px;
  }
}

/* Кнопка копирования промпта (список + модалка) */
.tm-ref-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--tm-line);
  border-radius: 10px;
  background: rgba(87, 42, 98, .22);
  color: #d8c8e8;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}

.tm-ref-copy svg {
  width: 14px;
  height: 14px;
}

.tm-ref-copy:hover {
  border-color: #c571dc;
  background: rgba(87, 42, 98, .42);
  color: #fff;
}

/* Элементы, видимые только в режиме списка */
.tm-ref-listonly {
  display: none;
}

.tm-list .tm-ref-desc {
  display: -webkit-box;
  grid-column: 1;
  margin: 0;
  overflow: hidden;
  color: #a89caf;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tm-list .tm-ref-copy {
  display: inline-flex;
  grid-column: 2;
  align-self: start;
  height: 34px;
  font-size: 11px;
}

/* Модалка превью: информация и промпт */
.tm-ref-preview-info {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tm-ref-preview-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.tm-ref-preview-name {
  color: #fff;
  font: 600 15px 'Space Grotesk', sans-serif;
}

.tm-ref-preview-meta {
  color: #9d8cac;
  font-size: 11px;
}

.tm-ref-preview-prompt {
  max-height: 96px;
  margin: 0;
  overflow: auto;
  color: #cfc5d8;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.tm-ref-preview-prompt.is-loading {
  color: #806b95;
}

.tm-ref-preview-actions {
  align-items: center;
}

@media (max-width: 767px) {
  .tm-ref-preview-media {
    max-height: 42vh;
  }

  .tm-ref-preview-media img,
  .tm-ref-preview-media video {
    max-height: 42vh;
  }

  .tm-ref-preview-copy {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tm-reference * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* ===== Модалка превью v2 (редизайн 2026-09) ===== */
.tm-ref-preview.open {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 27px 32px;
  overflow: hidden;
  background: rgba(3, 2, 9, .78);
  backdrop-filter: blur(7px) saturate(.72);
  -webkit-backdrop-filter: blur(7px) saturate(.72);
  animation: tmPreviewFade .18s ease;
}
@keyframes tmPreviewFade { from { opacity: 0; } }
.tm-ref-preview-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1280px, calc(100vw - 64px));
  height: min(860px, calc(100vh - 54px));
  max-width: none;
  max-height: calc(100vh - 54px);
  margin: 0;
  padding: 18px 24px 20px;
  overflow: hidden;
  border: 1px solid rgba(164, 104, 255, .28);
  border-radius: 22px;
  background: linear-gradient(120deg, #0B0913 0%, #0D0916 48%, #100A19 100%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55), 0 0 0 1px rgba(139, 84, 220, .05);
  animation: tmPreviewIn .24s cubic-bezier(.22, .8, .25, 1);
}
@keyframes tmPreviewIn { from { opacity: 0; transform: scale(.985) translateY(8px); } }
/* Атмосферные glow-пятна в правой части панели */
.tm-ref-preview-panel::before,
.tm-ref-preview-panel::after {
  content: '';
  position: absolute;
  right: -10%;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.tm-ref-preview-panel::before { top: -15%; background: rgba(109, 40, 217, .16); }
.tm-ref-preview-panel::after { bottom: -20%; background: rgba(190, 41, 222, .10); }
.tm-ref-preview-topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  margin-bottom: 14px;
}
.tm-ref-preview-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 999px;
  background: rgba(255, 255, 255, .045);
  color: #cfc4dc;
  font: 600 12.5px 'Manrope', sans-serif;
}
.tm-ref-preview-tag svg { width: 14px; height: 14px; color: #d5a8ff; fill: currentColor; }
.tm-ref-preview-tools { display: flex; gap: 8px; }
.tm-ref-preview-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 11px;
  background: rgba(255, 255, 255, .025);
  color: #cfc4dc;
  font-size: 0;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.tm-ref-preview-tool:hover { background: rgba(152, 85, 255, .09); border-color: rgba(165, 96, 255, .25); color: #fff; }
.tm-ref-preview-tool svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tm-ref-preview-close { position: static; font-size: 0; }
.tm-ref-preview-tool.done { color: #4ade80; border-color: rgba(74, 222, 128, .4); }
.tm-ref-preview-fav.active { color: #f472b6; border-color: rgba(244, 114, 182, .4); animation: tmPreviewFavPop .18s ease; }
.tm-ref-preview-fav.active svg { fill: currentColor; }
@keyframes tmPreviewFavPop { 50% { transform: scale(1.15); } }
.tm-ref-preview-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(380px, .88fr);
  gap: 28px;
  flex: 1;
  min-height: 0;
}
.tm-ref-preview-media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  max-height: none;
  height: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: #05040A;
  color: var(--tm-muted);
}
.tm-ref-preview-media img,
.tm-ref-preview-media video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
/* Десктоп: медиа жёстко вписываем в контейнер через absolute — иначе video сохраняет собственный
   aspect-ratio (вырос до 1122px при контейнере 574px), и низ кадра вместе с нативными контролами
   уходит под overflow: hidden — отсюда «обрезан низ» и «нет плеера» */
@media (min-width: 768px) {
  .tm-ref-preview-media > img,
  .tm-ref-preview-media > video { position: absolute; inset: 0; margin: auto; }
}
/* Большая кнопка Play поверх видео — без неё неочевидно, что это плеер (нативные контролы только при наведении) */
.tm-ref-preview-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  background: rgba(10, 7, 18, .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}
.tm-ref-preview-play:hover { background: rgba(139, 92, 246, .55); transform: translate(-50%, -50%) scale(1.06); }
.tm-ref-preview-play svg { width: 30px; height: 30px; fill: currentColor; margin-left: 3px; }
.tm-ref-preview-play.is-hidden { opacity: 0; pointer-events: none; }
.tm-ref-preview-media img { cursor: zoom-in; }
/* Базовый .tm-ref-apply имеет margin-top для сетки карточек — в панели действий модалки он ломает выравнивание по вертикали */
.tm-ref-preview-actions .tm-ref-apply { margin-top: 0; }
.tm-ref-preview-mediabadge {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 11px;
  background: rgba(7, 6, 12, .66);
  color: #e8e2f0;
  font: 600 12px 'Manrope', sans-serif;
}
.tm-ref-preview-side { display: flex; flex-direction: column; min-height: 0; }
.tm-ref-preview-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(153, 100, 220, .24) transparent;
}
.tm-ref-preview-scroll::-webkit-scrollbar { width: 5px; }
.tm-ref-preview-scroll::-webkit-scrollbar-thumb { background: rgba(153, 100, 220, .24); border-radius: 4px; }
.tm-ref-preview-name {
  margin: 2px 0 0;
  color: #F5F2FA;
  font: 650 30px/1.08 'Space Grotesk', sans-serif;
  letter-spacing: -.025em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tm-ref-preview-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #AAA3B5;
  font-size: 13px;
}
.tm-ref-preview-meta::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #8B48FF; }
.tm-ref-preview-desc {
  margin: 0;
  color: rgba(238, 233, 246, .68);
  font-size: 14px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tm-ref-preview-block {
  border: 1px solid rgba(154, 103, 223, .14);
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(255, 255, 255, .025), rgba(132, 67, 255, .022));
}
/* Промпт-карточка — акцентная подсветка как в референсе: заметный сиреневый оттенок + мягкое свечение */
.tm-ref-preview-promptcard {
  border-color: rgba(168, 120, 255, .24);
  background: linear-gradient(120deg, rgba(139, 92, 246, .10), rgba(190, 66, 237, .06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 0 24px rgba(139, 92, 246, .08);
}
.tm-ref-preview-blockhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  background: none;
  color: #ded6ea;
  font: 600 13px 'Manrope', sans-serif;
  cursor: default;
  pointer-events: none;
}
.tm-ref-preview-blockhead svg { display: none; }
.tm-ref-preview-blockbody { padding: 0 16px 14px; }
.tm-ref-preview-promptwrap { position: relative; }
.tm-ref-preview-prompt {
  margin: 0;
  padding: 0;
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: none;
  color: rgba(236, 231, 244, .76);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.tm-ref-preview-promptcard:not(.expanded) .tm-ref-preview-promptwrap::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 34px;
  background: linear-gradient(180deg, transparent, rgba(13, 9, 22, .95));
  pointer-events: none;
}
.tm-ref-preview-promptcard.expanded .tm-ref-preview-prompt { display: block; -webkit-line-clamp: unset; }
.tm-ref-preview-prompt.is-loading { color: #746E80; }
.tm-ref-preview-expand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: #c792ea;
  font: 600 12px 'Manrope', sans-serif;
  cursor: pointer;
}
.tm-ref-preview-expand:hover { color: #e0b0ff; }
.tm-ref-preview-expand svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .2s ease; }
.tm-ref-preview-promptcard.expanded .tm-ref-preview-expand svg { transform: rotate(180deg); }
.tm-ref-preview-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 10px; }
.tm-ref-preview-params > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .025);
}
.tm-ref-param-label { color: #746E80; font-size: 11px; }
.tm-ref-param-value { color: #F5F2FA; font-size: 13px; font-weight: 600; }
.tm-ref-preview-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tm-ref-preview-thumb {
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 10px;
  background: #05040A;
  cursor: pointer;
  transition: border-color .15s ease;
}
.tm-ref-preview-thumb:hover { border-color: rgba(219, 124, 232, .5); }
.tm-ref-preview-thumb.active { border-color: #db7ce8; }
.tm-ref-preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-ref-preview-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding-top: 14px;
  background: linear-gradient(to top, rgba(10, 7, 17, 1) 55%, rgba(10, 7, 17, 0));
}
.tm-ref-preview-actions .tm-ref-copy,
.tm-ref-preview-actions .tm-ref-control,
.tm-ref-preview-actions .tm-ref-apply { flex: 1 1 0; }
.tm-ref-preview-actions .tm-ref-copy,
.tm-ref-preview-actions .tm-ref-control,
.tm-ref-preview-actions .tm-ref-apply {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  width: auto;
  height: 50px;
  padding: 0 16px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}
.tm-ref-preview-actions .tm-ref-copy svg,
.tm-ref-preview-actions .tm-ref-control svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tm-ref-preview-actions .tm-ref-copy,
.tm-ref-preview-actions .tm-ref-control {
  border: 1px solid rgba(169, 112, 236, .25);
  /* Фиолетовая стеклянная заливка в тон панели — почти прозрачная white .018 читалась как «лишний чёрный фон» */
  background: rgba(169, 112, 236, .08);
  color: #e8e2f0;
}
.tm-ref-preview-actions .tm-ref-copy:hover,
.tm-ref-preview-actions .tm-ref-control:hover {
  background: rgba(139, 70, 255, .18);
  border-color: rgba(174, 108, 255, .40);
}
.tm-ref-preview-actions .tm-ref-apply {
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, .10);
  background: linear-gradient(100deg, #8B49FF 0%, #BF42ED 45%, #F14BAE 100%);
  box-shadow: 0 8px 24px rgba(182, 64, 223, .20), inset 0 1px 0 rgba(255, 255, 255, .13);
  font-size: 14px;
}
.tm-ref-preview-actions .tm-ref-apply svg { width: 16px; height: 16px; flex: none; fill: currentColor; stroke: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3)); }
@media (hover: hover) {
  .tm-ref-preview-actions .tm-ref-apply:hover { filter: brightness(1.07); transform: translateY(-1px); }
}
.tm-ref-preview-actions .tm-ref-apply:active { transform: scale(.985); }
.tm-ref-preview-hint { flex: 1 1 100%; margin: 0; text-align: center; color: rgba(235, 230, 242, .48); font-size: 11.5px; }
@media (max-width: 767px) {
  .tm-ref-preview.open { padding: 0; }
  .tm-ref-preview-panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: 0 0 calc(14px + env(safe-area-inset-bottom));
  }
  .tm-ref-preview-panel::before, .tm-ref-preview-panel::after { display: none; }
  .tm-ref-preview-topbar { height: 54px; margin: 0; padding: 0 14px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
  .tm-ref-preview-tag { height: 30px; font-size: 11.5px; }
  .tm-ref-preview-body { display: flex; flex-direction: column; gap: 0; overflow: hidden; }
  .tm-ref-preview-media { flex: none; height: clamp(250px, 38svh, 390px); border-radius: 0; }
  .tm-ref-preview-mediabadge { left: 12px; bottom: 12px; height: 30px; font-size: 11px; }
  .tm-ref-preview-side { flex: 1; min-height: 0; }
  .tm-ref-preview-scroll { padding: 14px 14px 0; gap: 12px; }
  .tm-ref-preview-name { order: 1; font-size: 21px; }
  .tm-ref-preview-meta { order: 2; font-size: 12px; }
  .tm-ref-preview-actions { order: 3; position: static; padding: 0; background: none; }
  .tm-ref-preview-actions .tm-ref-apply { order: -1; flex: 1 1 100%; height: 51px; font-size: 14px; }
  .tm-ref-preview-actions .tm-ref-copy,
  .tm-ref-preview-actions .tm-ref-control { flex: 1 1 0; height: 44px; font-size: 12px; }
  .tm-ref-preview-hint { order: 9; }
  .tm-ref-preview-desc { display: none; }
  .tm-ref-preview-promptcard { order: 4; }
  .tm-ref-preview-paramscard { order: 5; }
  .tm-ref-preview-thumbs { order: 6; }
  .tm-ref-preview-blockhead { pointer-events: auto; cursor: pointer; padding: 14px 16px; }
  .tm-ref-preview-blockhead svg { display: block; width: 16px; height: 16px; fill: none; stroke: #9d8cac; stroke-width: 2; transition: transform .2s ease; }
  .tm-ref-preview-block.open .tm-ref-preview-blockhead svg { transform: rotate(180deg); }
  .tm-ref-preview-block .tm-ref-preview-blockbody { display: none; }
  .tm-ref-preview-block.open .tm-ref-preview-blockbody { display: block; }
  .tm-ref-preview-thumbs { display: flex; gap: 8px; overflow-x: auto; }
  .tm-ref-preview-thumb { flex: 0 0 auto; width: 84px; height: 60px; aspect-ratio: auto; }
}
@media (max-width: 380px) {
  .tm-ref-preview-name { font-size: 19px; }
  .tm-ref-preview-media { height: clamp(230px, 33svh, 320px); }
  .tm-ref-preview-scroll { padding: 12px 12px 0; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-ref-preview.open, .tm-ref-preview-panel, .tm-ref-preview-fav.active { animation: none; }
}
/* ===== Подборки + страница сообщества (admin-редизайн, 2026-09) ===== */
/* Мозаика по соотношению сторон, как карточки каталога (ratio от превью подборки) */
.tm-collections-grid {
  display: block;
  columns: 5 220px;
  column-gap: 14px;
}
.tm-collections-grid .tm-ref-collection {
  flex: none;
  aspect-ratio: var(--tm-ratio, 1 / 1);
  margin: 0 0 14px;
  break-inside: avoid;
}
.tm-collections-grid .tm-ref-collection img {
  object-fit: cover;
}
@media (max-width: 640px) {
  .tm-collections-grid { columns: 2; column-gap: 10px; }
  .tm-collections-grid .tm-ref-collection { margin-bottom: 10px; }
}
.tm-ref-seo {
  margin-top: 34px;
  padding: 22px 24px;
  border: 1px solid var(--tm-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .02);
  color: var(--tm-muted);
  font-size: .94rem;
  line-height: 1.65;
}
.tm-ref-seo h2, .tm-ref-seo h3 { color: var(--tm-ink); margin: 18px 0 8px; }
.tm-ref-seo h2:first-child, .tm-ref-seo h3:first-child { margin-top: 0; }
.tm-ref-seo p { margin: 0 0 12px; }
.tm-ref-seo details { margin: 0 0 8px; }
.tm-ref-seo summary { cursor: pointer; color: var(--tm-ink); font-weight: 600; }
.tm-ut-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--tm-line);
  border-radius: 14px;
  background: rgba(169, 112, 236, .08);
  color: var(--tm-muted);
  font-size: .9rem;
  line-height: 1.5;
}
.tm-ut-banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.tm-ut-banner--beta { border-color: rgba(245, 158, 11, .4); background: linear-gradient(135deg, rgba(245, 158, 11, .12), rgba(236, 72, 153, .1)); }
.tm-ut-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: middle;
}
