/* =========================================
   TOKENS
   ========================================= */
:root {
  --color-white: #ffffff;
  --color-text-primary: rgba(255, 255, 255, 0.9);
  --color-accent-blue: #7b8cff;
  --color-accent-cyan: #00f0ff;
  --color-accent-pink: #ff4d79;
  --color-accent-red: #ff0033;
  --color-accent-purple: #bd00ff;
  --color-accent-gold: #ffb800;
  --panel-bg-overlay: rgba(10, 15, 30, 0.3);
  --panel-bg-soft: rgba(255, 255, 255, 0.02);
  --panel-bg-hover: rgba(255, 255, 255, 0.08);
  --panel-bg-mobile: #111526;
  --panel-bg-mobile-section: #1a1f35;
  --panel-bg-mobile-item: #232942;
  --panel-bg-input: rgba(7, 10, 20, 0.9);
  --panel-bg-scrim-strong: rgba(0, 0, 0, 0.75);
  --panel-bg-button-blue: linear-gradient(45deg, #1c234f, #2c2f7a);
  --panel-bg-gallery: rgba(20, 25, 45, 0.4);
  --panel-bg-gallery-strong: rgba(20, 25, 45, 0.85);
  --panel-bg-gallery-item: rgba(0, 0, 0, 0.3);
  --panel-bg-overlay-dark: rgba(5, 8, 20, 0.8);
  --panel-border-soft: rgba(255, 255, 255, 0.15);
  --panel-border-strong: rgba(255, 255, 255, 0.3);
  --panel-border-faint: rgba(255, 255, 255, 0.08);
  --panel-border-subtle: rgba(255, 255, 255, 0.05);
  --panel-border-mid: rgba(255, 255, 255, 0.2);
  --panel-border-light: rgba(255, 255, 255, 0.1);
  --panel-border-accent: rgba(120, 150, 255, 0.3);
  --panel-border-accent-soft: rgba(120, 150, 255, 0.14);
  --panel-border-accent-faint: rgba(120, 150, 255, 0.2);
  --panel-shadow-heavy: 0 25px 50px rgba(0, 0, 0, 0.5);
  --panel-shadow-overlay-strong: 0 25px 50px rgba(0, 0, 0, 0.9), 0 0 0 2000px rgba(0, 0, 0, 0.75);
  --panel-shadow-gallery: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.05);
  --panel-shadow-image-strong: 0 0 40px rgba(0, 0, 0, 1);
  --glow-blue-soft: rgba(120, 150, 255, 0.35);
  --glow-blue-mid: rgba(120, 150, 255, 0.5);
  --glow-blue-strong: rgba(120, 150, 255, 0.8);
  --glow-blue-inner: rgba(120, 150, 255, 0.15);
  --glow-pink-soft: rgba(255, 77, 121, 0.3);
  --glow-pink-mid: rgba(255, 77, 121, 0.6);
  --glow-pink-strong: rgba(255, 77, 121, 0.8);
  --glow-pink-inner: rgba(255, 77, 121, 0.2);
  --nsfw-space-bg: radial-gradient(ellipse at bottom, #2a0b15 0%, #000 100%);
  --text-accent-soft: #e2e8ff;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 14px;
  --space-lg: 16px;
  --space-xl: 20px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 18px;
  --radius-xl: 20px;
  --size-touch: 44px;
  --size-btn-sm: 46px;
}

/* visibility: desktop vs mobile */
.desktop-only { display: inline-flex !important; }
.mobile-only { display: none !important; }

/* =========================================
   MOBILE TOP RAIL
   ========================================= */
.mobile-top-rail {
  display: none;
}
.mobile-explore-wrap {
  position: relative;
}
.mobile-top-rail-btn {
  position: relative;
  width: 100%;
  min-width: 0 !important;
  height: 56px !important;
  min-height: 56px !important;
  padding: 0 12px !important;
  border-radius: 18px !important;
  gap: 10px;
  justify-content: flex-start !important;
  text-align: left;
  letter-spacing: 0 !important;
  text-transform: none !important;
  overflow: hidden;
}
.mobile-top-rail-btn .magic-core {
  opacity: 0.82;
}
.mobile-top-rail-icon {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(27, 34, 58, 0.96), rgba(14, 19, 33, 0.98));
  border: 1px solid rgba(160, 183, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 18px rgba(2, 5, 14, 0.2);
}
.mobile-top-rail-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.mobile-top-rail-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.mobile-top-rail-label {
  display: block;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.1;
  font-weight: 700;
  color: rgba(246, 249, 255, 0.98);
}
.mobile-top-rail-hint {
  display: block;
  max-width: 100%;
  font-size: 11px;
  line-height: 1.25;
  color: rgba(184, 198, 239, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-top-rail-hint[data-state="on"] {
  color: rgba(245, 248, 255, 0.98);
}
.mobile-top-rail-btn:hover,
.mobile-top-rail-btn:active,
.mobile-top-rail-btn.active {
  border-color: rgba(145, 167, 255, 0.28) !important;
  background: rgba(17, 22, 40, 0.94) !important;
}
.mobile-top-rail-btn.active .mobile-top-rail-icon,
.mobile-top-rail-btn-menu.active .mobile-top-rail-icon {
  background: linear-gradient(180deg, rgba(54, 71, 125, 0.98), rgba(25, 33, 60, 0.98));
}

/* =========================================
   MOBILE MENU (hamburger)
   ========================================= */
.mobile-menu-wrap {
  position: relative;
}
.mobile-menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  min-width: 280px;
  padding: 10px;
  background: var(--panel-bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border-soft);
  border-radius: 22px;
  box-shadow: var(--panel-shadow-heavy);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}
.mobile-menu-dropdown.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.mobile-explore-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(280px, calc(100vw - 24px));
  padding: 8px;
  background: rgba(10, 15, 30, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 110;
}
.mobile-explore-dropdown.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.mobile-explore-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: rgba(245, 248, 255, 0.96);
  text-align: left;
}
.mobile-explore-item:hover,
.mobile-explore-item:active {
  background: rgba(255, 255, 255, 0.06);
}
.mobile-explore-item + .mobile-explore-item {
  margin-top: 4px;
}
.mobile-explore-item-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(22, 28, 48, 0.92);
  border: 1px solid rgba(160, 183, 255, 0.14);
}
.mobile-explore-item-icon svg {
  width: 15px;
  height: 15px;
}
.mobile-explore-item-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mobile-explore-item-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}
.mobile-explore-item-hint {
  font-size: 11px;
  line-height: 1.25;
  color: rgba(184, 198, 239, 0.8);
}
.mobile-menu-panel-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 4px 10px;
}
.mobile-menu-eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(160, 180, 255, 0.72);
}
.mobile-menu-title {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  color: rgba(242, 246, 255, 0.96);
}
.mobile-menu-section {
  display: grid;
  gap: 6px;
}
.mobile-menu-section + .mobile-menu-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(150, 173, 255, 0.12);
}
.mobile-menu-section-label {
  margin: 0;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(164, 181, 237, 0.68);
}
.mobile-menu-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  padding: 10px 12px;
  margin: 0;
  border: none;
  border-radius: 16px;
  background: rgba(14, 18, 33, 0.58);
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
  border: 1px solid rgba(145, 167, 255, 0.08);
}
.mobile-menu-item:hover,
.mobile-menu-item:active {
  background: rgba(20, 27, 48, 0.86);
  border-color: rgba(145, 167, 255, 0.18);
}
.mobile-menu-item.active {
  background: rgba(37, 53, 96, 0.82);
  border-color: rgba(132, 154, 255, 0.34);
  color: rgba(238, 244, 255, 0.98);
}
.mobile-menu-item-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(26, 33, 58, 0.96), rgba(16, 21, 39, 0.98));
  color: rgba(233, 239, 255, 0.94);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 18px rgba(2, 4, 12, 0.18);
}
.mobile-menu-item-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.mobile-menu-item-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.mobile-menu-item-label {
  display: block;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
  color: rgba(248, 250, 255, 0.98);
}
.mobile-menu-item-description {
  display: block;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(174, 188, 229, 0.78);
}
.mobile-menu-item-meta {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(236, 241, 255, 0.88);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.mobile-menu-item.active .mobile-menu-item-meta {
  background: rgba(123, 140, 255, 0.16);
  border-color: rgba(123, 140, 255, 0.3);
  color: rgba(245, 248, 255, 0.96);
}
.mobile-menu-item-account.active .mobile-menu-item-meta,
.mobile-menu-state-pill[data-state="on"] {
  background: rgba(88, 124, 255, 0.2);
  border-color: rgba(123, 140, 255, 0.36);
  color: #f5f7ff;
}
.mobile-menu-state-pill[data-state="off"] {
  color: rgba(202, 212, 239, 0.82);
}
.mobile-menu-item-toggle.active .mobile-menu-item-icon {
  background: linear-gradient(180deg, rgba(57, 73, 128, 0.98), rgba(25, 33, 61, 0.98));
}
.hamburger-icon {
  width: 22px;
  height: 22px;
}

/* =========================================
   TOP CONTROLS AND CATEGORIES
   ========================================= */
.top-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  /* 🔥 кнопки справа */
  gap: var(--space-sm);
  flex-wrap: wrap;
  max-width: calc(100vw - 20px);
  padding: var(--space-sm) var(--space-xl);
  position: fixed;
  /* 🔥 закрепляем сверху */
  top: 0;
  right: 0;
  z-index: 20;
}

.categories-wrapper {
  position: relative;
  display: inline-block;
}

/* CATTEGORIES BUTTON */

.categories-bar {
  z-index: 20;
}

/* --- 2. МЕНЮ КАТЕГОРИЙ (УНИВЕРСАЛЬНОЕ ДЛЯ ПК И ТЕЛЕФОНА) --- */
.cat-dropdown {
  position: absolute !important;
  top: calc(100% + 15px) !important;
  right: 0 !important;
  left: auto !important;

  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;

  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) !important;
  transition: all 0.3s ease !important;

  background:
    linear-gradient(180deg, rgba(8, 12, 24, 0.97) 0%, rgba(12, 16, 30, 0.95) 100%) !important;
  backdrop-filter: blur(18px) saturate(130%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(130%) !important;
  border: 1px solid rgba(126, 151, 255, 0.24) !important;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.78),
    0 0 0 1px rgba(126, 151, 255, 0.08) inset !important;
  border-radius: var(--radius-xl) !important;
  isolation: isolate !important;

  padding: var(--space-sm) !important;
  max-height: calc(100vh - 90px) !important;
  overflow-y: auto !important;
  width: 320px !important;
}

/* Анимация появления для ПК */
.cat-dropdown.show {
  opacity: 1 !important;
  transform: translateY(0) !important;
  pointer-events: auto !important;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.82),
    0 0 0 100vmax rgba(3, 5, 12, 0.22),
    0 0 0 1px rgba(126, 151, 255, 0.08) inset !important;
}

/* Заголовки групп (AESTHETICS, BASE ART и т.д.) */
.cat-dropdown>div:not(:first-child)>div:first-child {
  background: linear-gradient(90deg, rgba(30, 35, 65, 0.5) 0%, rgba(20, 25, 45, 0.1) 100%) !important;
  border-left: 3px solid var(--color-accent-blue) !important;
  border-radius: 8px !important;
  margin-bottom: 6px !important;
  padding: 8px 12px !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  letter-spacing: 0.9px !important;
  color: var(--text-accent-soft) !important;
  transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
}

.cat-dropdown>div:not(:first-child)>div:first-child:hover {
  background: linear-gradient(90deg, rgba(45, 50, 95, 0.7) 0%, rgba(20, 25, 45, 0.2) 100%) !important;
  border-left: 3px solid var(--color-accent-pink) !important;
  padding-left: var(--space-xl) !important;
  text-shadow: 0 0 8px rgba(120, 150, 255, 0.5) !important;
}

/* Сами кнопочки подкатегорий */
.cat-btn {
  background: var(--panel-bg-soft) !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 9px !important;
  box-shadow: 0 0 5px var(--color-accent-purple), inset 0 0 4px rgba(255, 255, 255, 0.08) !important;

  color: var(--color-text-primary) !important;
  margin: 0 !important;
  padding: 8px 10px !important;
  min-height: 38px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  font-family: 'Orbitron', sans-serif !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  cursor: pointer !important;
}

/* Эффект при наведении мыши */
.cat-btn:hover {
  background: var(--panel-bg-hover) !important;
  border-color: var(--color-accent-purple) !important;
  color: var(--color-white) !important;
  transform: translate(3px, -2px) !important;
  box-shadow: 0 0 12px var(--color-accent-purple), inset 0 0 8px var(--color-accent-purple) !important;
}

.cat-dropdown::before,
.cat-dropdown::after {
  display: none !important;
}

@keyframes skeleton-loading {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

@keyframes preloaderShimmer {
  0% {
    background-position: 0% 50%;
    filter: drop-shadow(0 0 6px rgba(189, 0, 255, 0.18));
  }

  50% {
    background-position: 100% 50%;
    filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.24));
  }

  100% {
    background-position: 0% 50%;
    filter: drop-shadow(0 0 6px rgba(189, 0, 255, 0.18));
  }
}

h1 {
  margin: 10px 0;
}

#categories {
  margin-bottom: 10px;
}

/* DOWNLOAD BUTTON */

.icon-btn {
  position: relative;
  height: 52px;
  width: 52px;
  padding: 0;
  border-radius: var(--radius-md);

  background: var(--panel-bg-button-blue);
  border: 1px solid var(--glow-blue-soft);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  box-shadow:
    0 0 14px var(--glow-blue-mid),
    0 0 35px rgba(120, 150, 255, 0.25),
    inset 0 0 12px var(--glow-blue-inner);

  transition: all .25s ease;
}

.icon-btn svg {
  transition: transform .25s ease, filter .25s ease;
  width: 22px;
  height: 22px;
  fill: var(--color-white);
}

.top-download {
  position: static;
}

.icon-btn:hover {
  /* Объединили transform в одну строку, чтобы работали оба эффекта */
  transform: translateY(2px) scale(1.1);
  filter: drop-shadow(0 0 6px var(--color-accent-blue));
}

.cat-btn.active {
  background: rgba(255, 77, 121, 0.15) !important;
  border-color: var(--color-accent-pink) !important;
  color: var(--color-white) !important;
  transform: scale(1.05) !important;
  box-shadow: 0 0 15px var(--color-accent-pink), inset 0 0 10px var(--color-accent-pink) !important;
  text-shadow: 0 0 5px var(--color-accent-pink) !important;
}

/* =========================================
   BASE LAYOUT
   ========================================= */
html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  /* overflow-x: hidden; */
}

body {
  font-family: Arial, sans-serif;
  color: var(--color-white);
  text-align: center;
  background: black;
  min-width: 100vw;
  overflow: hidden;
  height: 100dvh;
  /*  isolation: isolate; */
}

#preloader {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(189, 0, 255, 0.18), transparent 42%),
    radial-gradient(circle at 50% 60%, rgba(255, 255, 255, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(6, 4, 16, 0.98) 0%, rgba(3, 2, 10, 0.99) 100%);
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

#preloader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.preloader-star {
  position: absolute;
  width: var(--star-size, 6px);
  height: var(--star-size, 6px);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.98) 0%, rgba(233, 217, 255, 0.92) 24%, rgba(191, 139, 255, 0.52) 48%, transparent 100%);
  opacity: 0;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center;
  overflow: visible;
  mix-blend-mode: screen;
  will-change: transform, opacity;
}

.preloader-star::before,
.preloader-star::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(228, 212, 255, 0.24) 24%,
      rgba(250, 246, 255, 0.94) 50%,
      rgba(219, 183, 255, 0.28) 76%,
      rgba(255, 255, 255, 0) 100%
    );
  border-radius: 999px;
  opacity: var(--preloader-cross-opacity, 0.9);
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.2));
}

.preloader-star::before {
  width: 1px;
  height: var(--star-cross, 18px);
}

.preloader-star::after {
  width: var(--star-cross, 18px);
  height: 1px;
}

.preloader-star-glint {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--star-cross, 18px) * 0.82);
  height: calc(var(--star-cross, 18px) * 0.82);
  transform: translate(-50%, -50%) scale(var(--star-glint-scale, 1));
  transform-origin: center;
  border-radius: 50%;
  pointer-events: none;
  opacity: var(--star-glint-opacity, 0.38);
  background:
    linear-gradient(45deg, transparent 0%, transparent 38%, rgba(255, 255, 255, 0.9) 50%, transparent 62%, transparent 100%),
    linear-gradient(-45deg, transparent 0%, transparent 40%, rgba(232, 214, 255, 0.82) 50%, transparent 60%, transparent 100%);
  filter: blur(0.35px) drop-shadow(0 0 6px rgba(204, 170, 255, 0.22));
  mix-blend-mode: screen;
}

.preloader-brand {
  position: relative;
  padding: 18px 24px;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(34px, 8vw, 78px);
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  color: rgba(236, 222, 255, 0.95);
  text-shadow:
    0 0 18px rgba(189, 0, 255, 0.24),
    0 0 42px rgba(255, 255, 255, 0.12);
}
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .preloader-brand {
    color: transparent;
    background: linear-gradient(
      120deg,
      rgba(189, 0, 255, 0.82) 0%,
      rgba(236, 222, 255, 0.96) 32%,
      rgba(255, 255, 255, 1) 50%,
      rgba(226, 203, 255, 0.94) 68%,
      rgba(164, 94, 255, 0.88) 100%
    );
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    animation: none;
  }
}

.preloader-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(189, 0, 255, 0.12), transparent 68%);
  filter: blur(8px);
  z-index: -1;
}

#space {
  pointer-events: none;
  display: block;
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  background: radial-gradient(ellipse at bottom, #17062e 0%, #030208 100%);
}

body.feed-mode.pin-viewer-active #space {
  display: none;
}

.card-frame {
  width: fit-content;
  max-width: 95vw;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 24px;
  border: 1px solid rgba(120, 150, 255, 0.18);
  box-shadow:
    0 0 60px rgba(120, 150, 255, 0.2),
    0 0 100px rgba(189, 0, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  background: transparent;
  box-sizing: border-box;
}

.card-inner {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  box-sizing: border-box;
  background: rgba(10, 15, 40, 0.72);
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.image-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.5);
  max-width: 100%;
  min-width: 0;
}

/* 🔥 СЛОЙ 1: Бегущий конический градиент (сама полоска) */
.image-wrapper::before {
  content: '';
  position: absolute;
  width: 150%;
  /* Делаем больше карточки, чтобы при вращении не было углов */
  height: 150%;
  /* Неоновый синий градиент, переходящий в прозрачный */
  background: conic-gradient(from 0deg,
      transparent 0%,
      transparent 70%,
      /* 70% окружности пусто */
      #7b8cff 90%,
      /* Яркий хвост */
      #ffffff 100%
      /* Белая голова полоски */
    );
  /* Изначально вращение выключено */
  animation: rotateBorder 1.5s linear infinite;
  animation-play-state: paused;
  /* Прячем, пока не идет загрузка */
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

/* 🔥 СЛОЙ 2: Внутренняя маска (закрывает центр градиента) */
.image-wrapper::after {
  content: '';
  position: absolute;
  /* Отступаем по 3 пикселя с каждой стороны. 
     Это и будет видимая толщина нашей полоски! */
  inset: 3px;
  background: #0a0f28;
  /* Цвет фона карточки */
  border-radius: 13px;
  /* Чуть меньше, чем у родителя */
  z-index: 1;
}

.main {
  height: 100dvh;
  box-sizing: border-box !important;
  /* Убираем жесткие паддинги, которые ломают центровку */
  padding: 60px 10px 100px 10px !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  overflow: hidden !important;
  position: relative;
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  height: 100vh;

  display: flex;
  flex-direction: column;
  overflow-y: auto;

  transform: translateX(-100%);
  transition: transform .4s ease;

  z-index: 999 !important;

  background: rgba(10, 15, 40, 0.75);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(120, 150, 255, 0.35);

  /* 🔥 МАГИЯ 2: Жестко заставляем телефон использовать GPU (видеоускоритель) для этой панели */
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

#sidebar.open {
  transform: translateX(0);
}

#sidebar h2 {
  margin-top: 8px;
  /* Точно такой же отступ от потолка, как у кнопки */
  margin-bottom: 15px;
  /* Отступ внизу до сетки с картинками */
  height: 44px;
  /* Жестко задаем высоту, равную высоте кнопки меню */
  line-height: 44px;
  /* Идеально центрируем текст внутри этой высоты */
  text-align: center;
  font-size: 1.5rem;
  color: #ffffff;
}

/* =========================================
   УЛУЧШЕННЫЙ ДИЗАЙН ИСТОРИИ
   ========================================= */

/* 1. Контейнер истории */
#history {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: max-content;
  gap: 12px;
  /* 🔥 Убрали 70px сверху, оставили аккуратный отступ в 5px */
  padding: 5px 15px 20px 15px;
  /* 🔥 УДАЛИЛИ overflow-y: auto; теперь скроллится вся панель целиком! */
  align-content: start;
}

/* 2. Бронебойная обертка: идеальный квадрат для любых мобилок */
.history-item-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  /* 🔥 Магия старой школы: 100% от ширины делает идеальный квадрат */
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
  cursor: pointer;
}

/* Эффект нажатия оставляем */
.history-item-wrapper:active {
  transform: scale(0.95);
}

/* 3. Сама картинка: отвязываем её от сетки */
.history-item {
  position: absolute;
  /* 🔥 Обязательно absolute, чтобы картинка слушалась padding-bottom */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

/* Кнопка "Открыть оригинал" в углу миниатюры */
.open-original-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: rgba(20, 30, 60, 0.6);
  backdrop-filter: blur(8px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
  text-decoration: none;
}

.open-original-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

.history-item-wrapper:hover .open-original-btn {
  opacity: 1;
  transform: translateY(0);
}

.open-original-btn svg {
  width: 14px;
  height: 14px;
  fill: var(--color-text-primary);
  transition: fill 0.2s ease;
}

.open-original-btn:hover {
  background: rgba(120, 150, 255, 0.8);
  box-shadow: 0 0 10px rgba(120, 150, 255, 0.6);
  transform: scale(1.1) rotate(5deg);
}

/* Toggle button */
#toggleHistory {
  position: fixed;
  top: 8px;
  left: 20px;
  z-index: 1000 !important;
  font-size: 16px;
  padding: 10px 14px;
  border-radius: 12px;
}

#waifu {
  z-index: 2;
  position: relative;
  display: block;

  max-width: 100%;
  /* 🔥 Ограничиваем аппетиты картинки! 
     65vh означает, что картинка займет максимум 65% высоты экрана.
     Ты можешь поиграть с этой цифрой: 60vh (поменьше) или 70vh (побольше) */
  max-height: 65vh !important;

  object-fit: contain;
  border-radius: 12px;
}

#waifu-buffer {
  z-index: 2;
  position: absolute;
  /* 🔥 Жизненно важно! Буфер должен висеть поверх, а не раздвигать экран */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* 🔥 Анимация вращения градиента */
@keyframes rotateBorder {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* 🔥 Класс, который JS будет включать во время загрузки */
.image-wrapper.loading::before {
  opacity: 1;
  animation-play-state: running;
}

.fade-out {
  opacity: 0;
  transform: scale(.95);
}

.button-wrapper {
  position: fixed !important;
  /* Отвязываем от карточки */
  bottom: 40px !important;
  /* Расстояние от нижнего края экрана */
  left: 50% !important;
  /* Центрируем... */
  transform: translateX(-50%) !important;
  /* ...ровно посередине */
  margin: 0 !important;
  z-index: 50 !important;
  /* Поверх всего */

  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}


#toggleHistory,
.cat-toggle,
.icon-btn {
  height: var(--size-touch);
  min-width: var(--size-touch);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Красивый скроллбар ===== */
::-webkit-scrollbar {
  width: 6px;
  /* Делаем его тоньше и элегантнее */
}

::-webkit-scrollbar-track {
  background: transparent;
  /* Убираем некрасивую черную полосу */
}

::-webkit-scrollbar-thumb {
  background: rgba(120, 150, 255, 0.4);
  /* Нежный синеватый ползунок */
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 150, 255, 0.8);
  /* Ярче при касании */
}

/* =========================================
   SIDEBAR AND HISTORY
   ========================================= */
#sidebar .glass {
  position: absolute;
  inset: 0;
  z-index: 0;

  background:
    linear-gradient(180deg,
      rgba(100, 120, 255, 0.15),
      rgba(10, 15, 40, 0.05));

  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  border-right: 1px solid rgba(120, 150, 255, 0.35);

  box-shadow:
    5px 0 25px rgba(0, 0, 0, 0.7),
    0 0 45px rgba(120, 150, 255, 0.45);

  pointer-events: none;
}

/* =========================================
   IMAGE META AND NSFW STATE
   ========================================= */
/* ===== SPACE MINIMAL TEXT ===== */


.char-name {
  color: #ffffff;
  font-weight: 500;
}

.divider {
  margin: 0 10px;
  color: rgba(180, 200, 255, 0.6);
}

.anime-name {
  color: #8ca8ff;
  font-weight: 400;
}

.empty-history {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.1rem;
  margin-top: 20px;
}

/* Стиль ТОЛЬКО для активного состояния (ВКЛЮЧЕНО) */
#nsfw-toggle.active-nsfw {
  font-weight: bold;
  background: linear-gradient(45deg, #e60049, #9b0032);
  color: var(--color-white);
  border-color: var(--color-accent-pink);
  box-shadow:
    0 0 15px rgba(255, 77, 121, 0.6),
    0 0 30px rgba(255, 77, 121, 0.2),
    inset 0 0 10px rgba(255, 77, 121, 0.1);
}

#calm-toggle.active-calm {
  font-weight: bold;
  background: linear-gradient(45deg, #1e3142, #274d5c);
  color: var(--color-white);
  border-color: rgba(0, 240, 255, 0.6);
  box-shadow:
    0 0 14px rgba(0, 240, 255, 0.35),
    0 0 26px rgba(0, 240, 255, 0.12),
    inset 0 0 8px rgba(0, 240, 255, 0.08);
}

/* 🔥 ГЛОБАЛЬНЫЙ ИНДИКАТОР NSFW-РЕЖИМА 🔥 */
body.nsfw-mode .card-frame {
  border-color: rgba(255, 77, 121, 0.4);
  box-shadow: 0 0 45px rgba(255, 77, 121, 0.25);
}

body.nsfw-mode #space {
  background: var(--nsfw-space-bg);
}

body.calm-mode #space,
body.calm-mode #lightbox-space,
body.calm-mode .preloader-stars,
body.calm-mode .preloader-star {
  display: none !important;
}

body.calm-mode *,
body.calm-mode *::before,
body.calm-mode *::after {
  animation: none !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

body.calm-mode .magic-btn,
body.calm-mode .cat-btn,
body.calm-mode .music-player,
body.calm-mode #sidebar,
body.calm-mode .gallery-content,
body.calm-mode .cat-dropdown,
body.calm-mode .history-item-wrapper,
body.calm-mode .gallery-item,
body.calm-mode .feed-card,
body.calm-mode .search-card,
body.calm-mode .pin-viewer-sheet,
body.calm-mode .image-feedback,
body.calm-mode #waifu,
body.calm-mode #waifu-buffer {
  transition: none !important;
  animation: none !important;
  box-shadow: none !important;
}

body.calm-mode .magic-core,
body.calm-mode .image-wrapper::before,
body.calm-mode .feed-card::before,
body.calm-mode .feed-card::after {
  display: none !important;
}

body.calm-mode .pin-viewer-page {
  background: rgb(6, 8, 18) !important;
}

body.calm-mode .pin-viewer-page::before,
body.calm-mode .pin-viewer-page::after,
body.calm-mode .pin-viewer-stage-shell::before,
body.calm-mode .pin-viewer-stage-shell::after,
body.calm-mode .pin-viewer-stage-main::before,
body.calm-mode .pin-viewer-stage-main::after,
body.calm-mode .pin-viewer-media::before,
body.calm-mode .pin-viewer-media::after,
body.calm-mode .pin-viewer-discovery::before,
body.calm-mode .pin-viewer-discovery::after {
  display: none !important;
  opacity: 0 !important;
  background: none !important;
  background-image: none !important;
}

body.calm-mode .music-player {
  background: rgba(13, 18, 30, 0.82) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}

body.calm-mode .magic-btn:hover,
body.calm-mode .cat-btn:hover,
body.calm-mode .feed-card:hover,
body.calm-mode .gallery-item:hover,
body.calm-mode .search-card:hover,
body.calm-mode .mobile-menu-item:hover,
body.calm-mode .mobile-top-rail-btn:hover,
body.calm-mode .pin-viewer-action:hover,
body.calm-mode .pin-viewer-close:hover,
body.calm-mode .feed-action:hover {
  transform: none !important;
  filter: none !important;
  box-shadow: none !important;
}

@supports (content-visibility: auto) {
  .gallery-content,
  .search-results-grid,
  body.feed-mode .pin-viewer-discovery {
    content-visibility: auto;
  }

  .gallery-content {
    contain-intrinsic-size: 980px;
  }

  .search-results-grid {
    contain-intrinsic-size: 920px;
  }

  body.feed-mode .pin-viewer-discovery {
    contain-intrinsic-size: 560px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .magic-btn,
  .history-item-wrapper,
  .gallery-item,
  #waifu,
  #waifu-buffer,
  .image-feedback {
    transition: none !important;
    animation: none !important;
  }
}

@keyframes pureFadeSmooth {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

body {
  /* Запрещаем выделять текст долгим нажатием */
  -webkit-user-select: none;
  user-select: none;

  /* Отключаем обновление страницы по свайпу вниз (Pull-to-refresh) */
  overscroll-behavior-y: none;
}

button,
a {
  /* Убираем синий квадрат при тапе по кнопкам на Android */
  -webkit-tap-highlight-color: transparent;
}

/* 1. Блокируем шатание экрана влево-вправо при свайпах */
body {
  overflow-x: hidden;
}

/* 2. Жестко центрируем весь контент на мобилках */
/* (Если твоя обертка называется не .container, замени на свой класс) */
.container,
.top-bar {
  margin: 0 auto !important;
  width: 100%;
  max-width: 600px;
}

/* =========================================
   MOTION AND INTERACTION UTILS
   ========================================= */
/* 3. Новая анимация вылета для свайпа */
@keyframes slideInRight {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }

  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

/* =========================================
   GLOBAL INTERACTION AND SAFE AREAS
   ========================================= */

/* 1. Убираем задержку в 300мс при тапе. Приложение станет реагировать мгновенно! */
button,
.cat-btn,
.icon-btn,
.history-item-wrapper,
a {
  touch-action: manipulation;
}

/* 2. Защита от "челок" (Notch) и нижней полоски свайпа на iPhone/Android */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Сдвигаем верхние кнопки, если есть вырез под камеру */
.top-controls {
  top: env(safe-area-inset-top);
  right: env(safe-area-inset-right);
}

/* Сдвигаем панель истории от нижней полоски телефона */
#history {
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
