@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── CSS Variables (Design Tokens) ─────────────────────────── */
:root {
  --font-cinzel: 'Cinzel', serif;
  --font-inter: 'Inter', sans-serif;
  --l2-dark: #0f1923;
  --l2-navy: #162236;
  --l2-navy-light: #1c2d45;
  --l2-accent: #e63946;
  --l2-accent-dark: #c1121f;
  --l2-accent-light: #ff4d5a;
  --l2-bg: #f4f5f7;
  --l2-card: #ffffff;
  --l2-border: #e1e4ea;
  --l2-text: #1a1a2e;
  --l2-text-secondary: #4a5568;
  --l2-text-muted: #8892a4;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--l2-bg);
  color: var(--l2-text);
  font-family: var(--font-inter);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.font-cinzel { font-family: var(--font-cinzel); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--l2-accent); }

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-25%); }
}

.animate-fade-in-up { animation: fadeInUp 0.3s ease-out both; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-bounce { animation: bounce 1s infinite; }

.shimmer-text {
  background: linear-gradient(90deg, #fff 0%, #e63946 20%, #fff 40%, #e63946 60%, #fff 80%, #e63946 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 6s linear infinite;
}

/* Watermark */
.watermark-overlay { position: relative; overflow: hidden; background: var(--l2-navy-light); }
.watermark-overlay::after {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(-45deg, transparent, transparent 80px, rgba(255,255,255,0.03) 80px, rgba(255,255,255,0.03) 81px);
  pointer-events: none; z-index: 2;
}
.watermark-text {
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none; overflow: hidden;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 20px; transform: rotate(-25deg) scale(1.5);
}
.watermark-text span {
  font-family: var(--font-cinzel); font-size: 15px; font-weight: 700;
  color: rgba(255,255,255,0.13); text-transform: uppercase;
  letter-spacing: 4px; white-space: nowrap; user-select: none;
}

/* Card hover — эффект на inner с border-radius */
.card-hover {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  border-radius: 1rem;
  overflow: hidden;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.card-hover:hover {
  transform: translateY(-4px) translateZ(0);
  box-shadow: 0 12px 40px rgba(15,25,35,0.10), 0 4px 12px rgba(15,25,35,0.06);
}
.resource-card {
  display: flex; flex-direction: column;
  min-height: 0;
  contain: layout style;
}
@media (max-width: 639px) {
  .resource-card { contain: none; }
}

/* Wave animations */
@keyframes waveBack {
  0%   { d: path("M0,70 C120,140 280,20 440,80 C600,140 750,10 920,60 C1090,110 1240,150 1360,50 C1410,20 1440,60 1440,50 L1440,200 L0,200 Z"); }
  50%  { d: path("M0,90 C160,30 300,130 460,60 C620,0 780,120 940,80 C1100,40 1280,130 1380,70 C1420,50 1440,80 1440,70 L1440,200 L0,200 Z"); }
  100% { d: path("M0,70 C120,140 280,20 440,80 C600,140 750,10 920,60 C1090,110 1240,150 1360,50 C1410,20 1440,60 1440,50 L1440,200 L0,200 Z"); }
}
@keyframes waveMid {
  0%   { d: path("M0,110 C180,60 320,140 500,90 C680,40 800,130 980,80 C1160,30 1280,120 1400,70 C1430,60 1440,90 1440,85 L1440,200 L0,200 Z"); }
  50%  { d: path("M0,90 C200,140 340,50 520,110 C700,170 820,60 1000,100 C1180,140 1300,50 1420,100 C1435,110 1440,95 1440,90 L1440,200 L0,200 Z"); }
  100% { d: path("M0,110 C180,60 320,140 500,90 C680,40 800,130 980,80 C1160,30 1280,120 1400,70 C1430,60 1440,90 1440,85 L1440,200 L0,200 Z"); }
}
@keyframes waveFront {
  0%   { d: path("M0,145 C160,110 300,170 460,130 C620,90 760,160 940,120 C1120,80 1260,155 1380,115 C1420,105 1440,130 1440,125 L1440,200 L0,200 Z"); }
  50%  { d: path("M0,130 C180,165 320,100 480,145 C640,190 780,110 960,140 C1140,170 1280,105 1400,135 C1425,140 1440,125 1440,130 L1440,200 L0,200 Z"); }
  100% { d: path("M0,145 C160,110 300,170 460,130 C620,90 760,160 940,120 C1120,80 1260,155 1380,115 C1420,105 1440,130 1440,125 L1440,200 L0,200 Z"); }
}
/* Движение через scaleY от нижнего края — работает во всех браузерах
   (в т.ч. мобильных, где анимация свойства `d` не поддерживается) и
   никогда не открывает пустоты по краям, так как низ прижат к 200. */
@keyframes waveBreatheBack  { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(1.10); } }
@keyframes waveBreatheMid   { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(0.90); } }
@keyframes waveBreatheFront { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(1.07); } }
.wave-back, .wave-mid, .wave-front { transform-box: fill-box; transform-origin: bottom; }
.wave-back  { animation: waveBack 8s ease-in-out infinite, waveBreatheBack 8s ease-in-out infinite; }
.wave-mid   { animation: waveMid 6s ease-in-out infinite, waveBreatheMid 6s ease-in-out infinite; }
.wave-front { animation: waveFront 7s ease-in-out infinite, waveBreatheFront 7s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .wave-back, .wave-mid, .wave-front { animation: none; }
}

/* Line clamp */
.line-clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.line-clamp-3 {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ─── Layout Utilities ──────────────────────────────────────── */
.container { max-width: 80rem; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 640px) { .container { padding: 0 1.5rem; } }
@media (min-width: 1024px) { .container { padding: 0 2rem; } }

.hidden { display: none !important; }
.sm-hidden { display: none; }
@media (min-width: 640px) { .sm-hidden { display: initial; } .sm-show { display: initial; } }
@media (max-width: 639px) { .sm-show { display: none !important; } }

/* ─── Header ────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--l2-dark); border-bottom: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}
.site-header .inner {
  display: flex; align-items: center; justify-content: flex-start;
  height: 4rem;
}
@media (min-width: 1024px) { .site-header .inner { height: 4.5rem; } }

.logo-wrap { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; text-decoration: none; }
.site-logo { display: block; flex-shrink: 0; }
.site-logo--brand { width: 2.25rem; height: 2.25rem; }
.logo-title { font-family: var(--font-cinzel); font-size: 1.125rem; font-weight: 700; color: #fff; letter-spacing: 0.05em; line-height: 1; }
.logo-sub { font-size: 10px; color: rgba(255,255,255,0.4); letter-spacing: 0.2em; text-transform: uppercase; }
.site-logo--admin { width: 2rem; height: 2rem; }
.site-logo--login { width: 3rem; height: 3rem; margin: 0 auto 0.75rem; }

/* ─── Hero ──────────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden; background: var(--l2-dark);
}
.hero-bg { position: absolute; inset: 0; }
.hero-bg .gradient { position: absolute; inset: 0; background: linear-gradient(to bottom right, var(--l2-dark), var(--l2-navy), var(--l2-dark)); }
.hero-bg .blob1 {
  position: absolute; top: 0; right: 0; width: 600px; height: 600px;
  background: rgba(230,57,70,0.08); border-radius: 50%; filter: blur(120px);
  transform: translateY(-50%) translateX(33%);
}
.hero-bg .blob2 {
  position: absolute; bottom: 0; left: 0; width: 400px; height: 400px;
  background: rgba(28,45,69,0.5); border-radius: 50%; filter: blur(100px);
  transform: translateY(33%) translateX(-25%);
}
.hero-bg .grid {
  position: absolute; inset: 0; opacity: 0.03;
  background-image: linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 60px 60px;
}
.hero-content {
  position: relative; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; text-align: center; padding: 0 1rem 9rem;
}
@media (min-width: 1024px) { .hero-content { min-height: 70vh; padding-bottom: 10rem; } }

.hero-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 1rem; border-radius: 9999px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 2rem; font-size: 0.875rem; color: rgba(255,255,255,0.7); font-weight: 500;
}
.hero-badge svg { color: var(--l2-accent); width: 1rem; height: 1rem; }
.hero h1 {
  font-family: var(--font-cinzel); font-size: 2.25rem; font-weight: 700;
  margin-bottom: 1.25rem; line-height: 1.1;
}
@media (min-width: 640px) { .hero h1 { font-size: 3rem; } }
@media (min-width: 768px) { .hero h1 { font-size: 3.75rem; } }
@media (min-width: 1024px) { .hero h1 { font-size: 4.5rem; } }
.hero-sub { font-size: 1.125rem; color: rgba(255,255,255,0.6); margin-bottom: 2.5rem; font-weight: 300; max-width: 36rem; }
@media (min-width: 640px) { .hero-sub { font-size: 1.25rem; } }
@media (min-width: 768px) { .hero-sub { font-size: 1.5rem; } }
.hero-sub strong { color: #fff; font-weight: 500; }
.hero-actions { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
@media (min-width: 640px) { .hero-actions { flex-direction: row; } }
.btn-hero {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 2rem; background: var(--l2-accent); color: #fff;
  font-weight: 700; font-size: 1rem; border-radius: 0.75rem; text-decoration: none;
  transition: all 0.2s; box-shadow: 0 20px 25px rgba(230,57,70,0.25);
}
.btn-hero:hover { background: var(--l2-accent-dark); transform: scale(1.03); box-shadow: 0 20px 25px rgba(230,57,70,0.35); }
.hero-count { color: rgba(255,255,255,0.3); font-size: 0.875rem; }

.hero-waves { position: absolute; bottom: 0; left: 0; right: 0; z-index: 5; }
.hero-waves svg { width: 100%; height: 120px; display: block; }
@media (min-width: 640px) { .hero-waves svg { height: 160px; } }
@media (min-width: 1024px) { .hero-waves svg { height: 200px; } }

/* ─── Search Bar ────────────────────────────────────────────── */
.search-bar { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem; }
@media (min-width: 640px) { .search-bar { flex-direction: row; } }

.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap svg {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  width: 1.25rem; height: 1.25rem; color: var(--l2-text-muted);
}
.search-input {
  width: 100%; padding: 0.75rem 1rem 0.75rem 3rem;
  background: #fff; border: 1px solid var(--l2-border); border-radius: 0.75rem;
  color: var(--l2-text); font-size: 1rem; transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.search-input::placeholder { color: var(--l2-text-muted); }
.search-input:focus { outline: none; border-color: rgba(230,57,70,0.4); box-shadow: 0 0 0 2px rgba(230,57,70,0.1); }

.filter-dropdown { position: relative; }
.filter-btn {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem; background: #fff;
  border: 1px solid var(--l2-border); border-radius: 0.75rem;
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  min-width: 200px; width: 100%; justify-content: space-between;
  transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
@media (min-width: 640px) { .filter-btn { width: auto; } }
.filter-btn.active-filter { border-color: rgba(15,25,35,0.3); box-shadow: 0 4px 6px rgba(0,0,0,0.07); }
.filter-btn.open { border-color: rgba(230,57,70,0.4); box-shadow: 0 0 0 2px rgba(230,57,70,0.1); }
.filter-panel {
  position: absolute; top: calc(100% + 0.5rem); left: 0; right: 0;
  background: #fff; border: 1px solid var(--l2-border); border-radius: 0.75rem;
  box-shadow: 0 20px 25px rgba(0,0,0,0.1); z-index: 50; overflow: hidden;
}
@media (min-width: 640px) { .filter-panel { right: auto; min-width: 260px; } }
.filter-option {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; padding: 0.75rem 1rem; border: none; background: none;
  font-size: 0.875rem; cursor: pointer; text-align: left; transition: background 0.15s;
}
.filter-option:hover { background: var(--l2-bg); }
.filter-option.selected { background: var(--l2-dark); color: #fff; }
.filter-option .count {
  margin-left: auto; padding: 0.125rem 0.5rem; border-radius: 0.375rem;
  font-size: 0.75rem; font-weight: 700;
}
.filter-option.selected .count { background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7); }
.filter-option:not(.selected) .count { background: var(--l2-bg); color: var(--l2-text-muted); }

.sort-wrap { position: relative; }
.sort-wrap svg {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  width: 1rem; height: 1rem; color: var(--l2-text-muted); pointer-events: none;
}
.sort-select {
  padding: 0.75rem 2rem 0.75rem 2.75rem; background: #fff;
  border: 1px solid var(--l2-border); border-radius: 0.75rem;
  color: var(--l2-text); font-size: 0.875rem; cursor: pointer;
  min-width: 200px; width: 100%; appearance: none;
  transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
@media (min-width: 640px) { .sort-select { width: auto; } }
.sort-select:focus { outline: none; border-color: rgba(230,57,70,0.4); box-shadow: 0 0 0 2px rgba(230,57,70,0.1); }

/* ─── Results & Pagination ────────────────────────────────────── */
.results-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.results-count { font-size: 0.875rem; color: var(--l2-text-muted); }
.results-count strong { color: var(--l2-text); font-weight: 600; }

.pagination { display: flex; align-items: center; gap: 0.25rem; }
.page-btn {
  min-width: 2rem; height: 2rem; border: none; border-radius: 0.5rem;
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  color: var(--l2-text-muted); background: transparent; transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { color: var(--l2-text); background: #fff; }
.page-btn.active { background: var(--l2-dark); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-btn.nav { padding: 0.375rem; }
.pagination-bottom { display: flex; justify-content: center; margin-top: 2rem; }
.pagination-bottom .page-btn { min-width: 2.25rem; height: 2.25rem; font-size: 0.875rem; }
.pagination-bottom .page-btn.active { box-shadow: 0 4px 6px rgba(0,0,0,0.1); }

/* ─── Resource Grid ─────────────────────────────────────────── */
.resource-grid {
  display: grid; grid-template-columns: 1fr; gap: 1.5rem; align-items: start;
}
@media (min-width: 640px) { .resource-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .resource-grid { grid-template-columns: repeat(3, 1fr); } }

/* Лоадер каталога (скелетоны) */
.catalog-wrap { position: relative; }
.catalog-loading .resource-grid { visibility: hidden; position: absolute; width: 100%; pointer-events: none; }
.catalog-loader {
  display: none; grid-template-columns: 1fr; gap: 1.5rem; align-items: start;
}
.catalog-loading .catalog-loader { display: grid; }
@media (min-width: 640px) { .catalog-loader { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .catalog-loader { grid-template-columns: repeat(3, 1fr); } }
.skeleton-card {
  border-radius: 1rem; overflow: hidden; background: #fff;
  border: 1px solid var(--l2-border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.skeleton-img {
  aspect-ratio: 16/9; background: linear-gradient(90deg, #e8ecf1 25%, #f4f6f9 50%, #e8ecf1 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.skeleton-body { padding: 1rem 1.125rem 1.125rem; display: flex; flex-direction: column; gap: 0.625rem; }
.skeleton-line {
  height: 0.75rem; border-radius: 999px;
  background: linear-gradient(90deg, #e8ecf1 25%, #f4f6f9 50%, #e8ecf1 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.skeleton-line--title { width: 72%; height: 1rem; }
.skeleton-line--short { width: 45%; }
.skeleton-meta { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.skeleton-meta span {
  flex: 1; height: 2rem; border-radius: 0.5rem;
  background: linear-gradient(90deg, #e8ecf1 25%, #f4f6f9 50%, #e8ecf1 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.resource-card-inner {
  background: #fff; border: 1px solid var(--l2-border); border-radius: 1rem;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  /* Убираем выделение текста и синюю подсветку тапа при клике по карточке */
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.resource-card-inner:hover {
  border-color: rgba(22,34,54,0.2);
  box-shadow: 0 8px 24px rgba(15,25,35,0.08);
}
.card-image {
  position: relative; flex-shrink: 0;
  /* Пропорция вместо фиксированной высоты — картинка масштабируется
     вместе с шириной карточки, поэтому карточка выглядит одинаково
     на десктопе, планшете и мобильном (одинаковые пропорции). */
  aspect-ratio: 15 / 8; overflow: hidden;
}
/* Фолбэк для старых браузеров без поддержки aspect-ratio */
@supports not (aspect-ratio: 1) {
  .card-image { height: 13rem; }
}
.card-image img {
  width: 100%; height: 100%; object-fit: cover;
  background: var(--l2-navy-light);
  transform: translateZ(0);
}
.card-image .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.5), rgba(0,0,0,0.1), transparent);
  z-index: 4;
}
.card-rating {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 6;
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0.25rem 0.5rem; background: rgba(255,255,255,0.95);
  backdrop-filter: blur(4px); border-radius: 0.375rem; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  font-size: 11px; font-weight: 700;
}
.card-rating svg { width: 0.8rem; height: 0.8rem; color: var(--l2-accent); fill: var(--l2-accent); }
.card-downloads {
  position: absolute; bottom: 0.75rem; right: 0.75rem; z-index: 6;
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.25rem 0.625rem; background: rgba(15,25,35,0.7);
  backdrop-filter: blur(4px); border-radius: 0.375rem;
  font-size: 11px; color: rgba(255,255,255,0.8); font-weight: 500;
}
.card-downloads svg { width: 0.75rem; height: 0.75rem; color: rgba(255,255,255,0.7); }

.card-body {
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem;
  flex: 0 0 auto;
}
/* Строка «название слева + теги справа» */
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.625rem;
}
/* Название — с тонкой акцентной чертой снизу */
.card-title {
  position: relative; flex: 1 1 auto; min-width: 0;
  font-family: var(--font-cinzel); font-size: 17px; font-weight: 700;
  color: var(--l2-text); margin-bottom: 0; line-height: 1.35;
  padding-bottom: 0.625rem; letter-spacing: 0.2px;
  transition: color 0.2s;
}
.card-title::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 2.25rem; height: 3px; border-radius: 999px;
  background: linear-gradient(90deg, var(--l2-accent), var(--l2-accent-light));
  transition: width 0.25s ease;
}
.card-hover:hover .card-title { color: var(--l2-accent); }
.card-hover:hover .card-title::after { width: 3.5rem; }

/* Описание */
.card-desc {
  font-size: 13px; color: var(--l2-text-secondary); line-height: 1.6;
  margin-bottom: 1rem; min-height: 4rem;
}

/* Теги — контурные пилюли (тёмно-синие), справа от названия */
.card-tags {
  display: flex; flex-wrap: wrap; gap: 0.375rem;
  margin-bottom: 0; min-height: 0; max-height: none;
  justify-content: flex-end; flex: 0 1 auto; max-width: 55%;
}
.card-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.625rem; line-height: 1.2;
  background: rgba(22,34,54,0.06);
  color: var(--l2-navy); font-size: 11px; font-weight: 600;
  border-radius: 999px; border: 1px solid rgba(22,34,54,0.25);
  transition: background 0.2s, border-color 0.2s;
}
.card-hover:hover .card-tag {
  background: rgba(22,34,54,0.1); border-color: rgba(22,34,54,0.45);
}
.card-tag svg { width: 10px; height: 10px; }

/* Разноцветные иконки тегов (циклично по позиции) */
.card-tag:nth-child(6n+1) svg { color: #e63946; } /* красный */
.card-tag:nth-child(6n+2) svg { color: #2a9d8f; } /* бирюзовый */
.card-tag:nth-child(6n+3) svg { color: #4361ee; } /* синий */
.card-tag:nth-child(6n+4) svg { color: #f77f00; } /* оранжевый */
.card-tag:nth-child(6n+5) svg { color: #8338ec; } /* фиолетовый */
.card-tag:nth-child(6n)   svg { color: #06a77d; } /* зелёный */

/* Мета-информация — контурная «стека» из трёх боксов */
.card-meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
  margin-top: 0; margin-bottom: 0;
}
.card-meta div {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  padding: 0.5rem 0.375rem; overflow: hidden; text-align: center;
  border: 1px solid var(--l2-border); border-radius: 0.625rem;
  background: linear-gradient(180deg, #fff 0%, var(--l2-bg) 100%);
  color: var(--l2-text-secondary);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.card-hover:hover .card-meta div {
  border-color: rgba(22,34,54,0.35);
  box-shadow: 0 1px 3px rgba(15,25,35,0.06);
}
.card-meta svg { width: 0.9rem; height: 0.9rem; flex-shrink: 0; color: var(--l2-navy); }
.card-meta span {
  font-size: 10.5px; font-weight: 600; color: var(--l2-text); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.btn-download {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1rem; background: var(--l2-dark); color: #fff;
  font-weight: 600; font-size: 0.875rem; border: none; border-radius: 0.75rem;
  cursor: pointer; transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-download:hover { background: var(--l2-accent); box-shadow: 0 4px 6px rgba(230,57,70,0.2); }
.btn-download svg { width: 1rem; height: 1rem; }

/* Empty state */
.empty-state { text-align: center; padding: 6rem 0; }
.empty-state svg { width: 3.5rem; height: 3.5rem; color: var(--l2-text-muted); margin: 0 auto 1rem; opacity: 0.3; }
.empty-state h3 { font-family: var(--font-cinzel); font-size: 1.25rem; font-weight: 700; margin-bottom: 0.5rem; }
.empty-state p { color: var(--l2-text-muted); margin-bottom: 1.5rem; font-size: 0.875rem; }
.btn-reset {
  padding: 0.625rem 1.5rem; background: var(--l2-dark); color: #fff;
  font-size: 0.875rem; font-weight: 500; border: none; border-radius: 0.75rem;
  cursor: pointer; transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-reset:hover { background: var(--l2-accent); }

/* CTA Banner */
.cta-banner {
  margin-top: 4rem; padding: 2rem; border-radius: 1rem;
  background: var(--l2-dark); position: relative; overflow: hidden;
  box-shadow: 0 20px 25px rgba(15,25,35,0.1);
}
@media (min-width: 640px) { .cta-banner { padding: 2.5rem; } }
.cta-banner .blob-a {
  position: absolute; top: 0; right: 0; width: 20rem; height: 20rem;
  background: rgba(230,57,70,0.1); border-radius: 50%; filter: blur(100px);
  transform: translateY(-50%) translateX(33%);
}
.cta-banner .blob-b {
  position: absolute; bottom: 0; left: 0; width: 15rem; height: 15rem;
  background: rgba(28,45,69,0.6); border-radius: 50%; filter: blur(80px);
  transform: translateY(50%) translateX(-25%);
}
.cta-inner { position: relative; z-index: 10; text-align: center; }
.cta-inner h3 { font-family: var(--font-cinzel); font-size: 1.5rem; font-weight: 700; color: #fff; margin-bottom: 0.75rem; }
@media (min-width: 640px) { .cta-inner h3 { font-size: 1.875rem; } }
.cta-inner p { color: rgba(255,255,255,0.4); margin-bottom: 2rem; max-width: 32rem; margin-left: auto; margin-right: auto; font-size: 0.875rem; }
.btn-cta {
  padding: 0.75rem 2rem; background: var(--l2-accent); color: #fff;
  font-weight: 700; border: none; border-radius: 0.75rem; cursor: pointer;
  transition: all 0.2s; box-shadow: 0 10px 15px rgba(230,57,70,0.25);
}
.btn-cta:hover { background: var(--l2-accent-dark); transform: scale(1.03); }

/* ─── Footer ────────────────────────────────────────────────── */
.site-footer { background: var(--l2-dark); color: #fff; }
.site-footer .inner { padding: 3rem 1rem 3.5rem; }
.footer-center {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; max-width: 36rem; margin: 0 auto;
}
.footer-logo {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  text-decoration: none; margin-bottom: 1.25rem;
}
.footer-logo .site-logo { width: 2.5rem; height: 2.5rem; }
.footer-logo-text { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.footer-logo .logo-title {
  font-family: var(--font-cinzel); font-size: 1.25rem; font-weight: 700;
  color: #fff; letter-spacing: 0.05em; line-height: 1;
}
.footer-logo .logo-sub {
  font-size: 10px; color: rgba(255,255,255,0.4);
  letter-spacing: 0.2em; text-transform: uppercase;
}
.footer-desc {
  font-size: 0.875rem; color: rgba(255,255,255,0.4);
  line-height: 1.625; margin: 0;
}

/* ─── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
}
.modal-backdrop.light { background: rgba(0,0,0,0.6); }
.modal-box {
  position: relative; background: #fff; border-radius: 1rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3); width: 100%; max-width: 24rem;
  overflow: hidden; animation: fadeInUp 0.3s ease-out both;
}
.modal-box.wide { max-width: 28rem; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; border-radius: 1rem; box-shadow: 0 25px 50px rgba(0,0,0,0.25); }
.modal-header {
  background: var(--l2-dark); padding: 0.75rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header.center { padding: 1.25rem; text-align: center; position: relative; }
.modal-header.center .modal-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  padding: 0.375rem; border-radius: 0.5rem;
}
.modal-header.center .modal-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.modal-header h2 { font-family: var(--font-cinzel); font-size: 1.125rem; font-weight: 700; color: #fff; }
.modal-header p { color: rgba(255,255,255,0.35); font-size: 0.75rem; margin-top: 0.25rem; }
.modal-close {
  background: none; border: none; color: rgba(255,255,255,0.3);
  cursor: pointer; padding: 0.25rem; border-radius: 0.25rem; transition: color 0.15s;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 1.25rem; }
.modal-scroll { overflow-y: auto; max-height: calc(90vh - 180px); }

/* Ad overlay */
.ad-area {
  background: var(--l2-dark); border-radius: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  height: 420px; position: relative; overflow: hidden; margin-bottom: 1rem;
}
.ad-area p { color: rgba(255,255,255,0.6); font-size: 0.875rem; font-weight: 500; }
.progress-bar { width: 100%; background: var(--l2-bg); border-radius: 9999px; height: 6px; margin-bottom: 0.5rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--l2-accent); border-radius: 9999px; transition: width 0.1s linear; width: 0%; }
.btn-green {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1rem; background: #22c55e; color: #fff;
  font-weight: 600; font-size: 0.875rem; border: none; border-radius: 0.75rem;
  cursor: pointer; transition: all 0.2s;
}
.btn-green:hover { background: #16a34a; }

/* ─── Resource Modal (слайдер + рейтинг) ─────────────────────── */
#resource-modal {
  padding: 1rem;
}
#resource-modal .modal-box.rm-box {
  position: relative;
  max-width: 40rem; width: 100%; max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 1rem; background: #fff;
  box-shadow: 0 25px 50px rgba(0,0,0,0.35);
}
.rm-close {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border: none; border-radius: 50%;
  background: rgba(15,25,35,0.65); color: #fff; cursor: pointer;
  backdrop-filter: blur(4px); transition: background 0.2s, transform 0.2s;
}
.rm-close:hover { background: var(--l2-accent); transform: scale(1.05); }

/* Слайдер */
.rm-slider {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: var(--l2-navy-light); overflow: hidden; flex-shrink: 0;
}
.rm-track { display: flex; height: 100%; transition: transform 0.35s ease; }
.rm-slide {
  flex: 0 0 100%; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.rm-slide img { width: 100%; height: 100%; object-fit: cover; }
.rm-noimg { color: rgba(255,255,255,0.25); }
.rm-noimg svg { width: 4rem; height: 4rem; }
.rm-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 15;
  display: flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border: none; border-radius: 50%;
  background: rgba(255,255,255,0.92); color: var(--l2-dark); cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2); transition: background 0.2s, color 0.2s;
}
.rm-nav:hover { background: var(--l2-navy); color: #fff; }
.rm-prev { left: 0.75rem; }
.rm-next { right: 0.75rem; }
.rm-dots {
  position: absolute; bottom: 0.75rem; left: 50%; transform: translateX(-50%);
  z-index: 15; display: flex; gap: 0.375rem;
}
.rm-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,0.5); transition: background 0.2s, width 0.2s;
}
.rm-dot.active { background: #fff; width: 1.25rem; border-radius: 999px; }

/* Контент модалки */
.rm-content {
  display: flex; flex-direction: column; gap: 0.875rem;
  padding: 1.25rem; overflow-y: auto; flex: 1 1 auto; min-height: 0;
}
/* Серый блок вокруг содержимого (категория, название, описание, мета) */
.rm-info {
  display: flex; flex-direction: column; gap: 0.875rem;
  background: #f0f2f5; border: 1px solid var(--l2-border);
  border-radius: 0.875rem; padding: 1rem 1.125rem;
}
.rm-cat {
  display: inline-flex; align-items: center; gap: 0.3rem; align-self: flex-start;
  font-size: 11px; font-weight: 600; color: var(--l2-navy);
  background: rgba(22,34,54,0.08); border: 1px solid rgba(22,34,54,0.2);
  padding: 0.2rem 0.6rem; border-radius: 999px;
}
.rm-cat svg { width: 11px; height: 11px; color: var(--l2-navy); }
.rm-title {
  font-family: var(--font-cinzel); font-size: 1.25rem; font-weight: 700;
  color: var(--l2-text); line-height: 1.3; margin: 0;
  overflow-wrap: anywhere;
}
.btn-recommend {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1rem; margin: 0; flex-shrink: 0;
  background: #fff; color: var(--l2-accent);
  font-weight: 700; font-size: 0.875rem;
  border: 2px solid var(--l2-accent); border-radius: 0.75rem;
  cursor: pointer; transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-recommend svg { width: 1.05rem; height: 1.05rem; color: currentColor; fill: currentColor; }
.btn-recommend:hover { background: rgba(230,57,70,0.08); }
.btn-recommend:active { transform: scale(0.98); }
.btn-recommend.active {
  background: var(--l2-accent); color: #fff;
  box-shadow: 0 6px 16px rgba(230,57,70,0.28);
}
.btn-recommend.active:hover { background: var(--l2-accent-dark); }
.btn-recommend:disabled { opacity: 0.7; cursor: default; }
.rm-desc {
  font-size: 0.9375rem; color: var(--l2-text-secondary); line-height: 1.65;
  margin: 0 0 1rem; white-space: pre-line;
  overflow-wrap: anywhere; word-break: break-word;
}
.rm-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.75rem; margin: 0;
}
.rm-head .rm-title { flex: 1 1 auto; min-width: 0; }
.rm-tags {
  display: flex; flex-wrap: wrap; gap: 0.375rem; margin: 0;
  justify-content: flex-end; flex: 0 1 auto; max-width: 55%;
}
.rm-meta {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.625rem; margin: 0 0 1.5rem;
}
.rm-meta div {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  padding: 0.5rem 0.375rem; overflow: hidden; text-align: center;
  border: 1px solid var(--l2-border); border-radius: 0.625rem;
  background: linear-gradient(180deg, #fff 0%, var(--l2-bg) 100%);
  color: var(--l2-text-secondary);
}
.rm-meta svg { width: 0.9rem; height: 0.9rem; color: var(--l2-navy); flex-shrink: 0; }
.rm-meta span {
  font-size: 10.5px; font-weight: 600; color: var(--l2-text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rm-download { width: 100%; flex-shrink: 0; }

/* Планшет и десктоп: шире модалка, мета в 4 колонки */
@media (min-width: 640px) {
  #resource-modal { padding: 1.5rem; }
  #resource-modal .modal-box.rm-box { max-width: 32rem; }
  .rm-content { padding: 1.5rem; gap: 1rem; }
  .rm-title { font-size: 1.375rem; }
  .rm-meta { grid-template-columns: repeat(4, 1fr); }
}

/* Десктоп: две колонки — слайдер слева, информация справа */
@media (min-width: 900px) {
  #resource-modal .modal-box.rm-box {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    grid-template-rows: 1fr;
    max-width: 58rem;
    width: min(92vw, 58rem);
    height: min(85vh, 42rem);
    max-height: min(85vh, 42rem);
  }
  .rm-slider {
    grid-column: 1; grid-row: 1;
    width: 100%; height: 100%; min-height: 0;
    aspect-ratio: auto;
  }
  .rm-content {
    grid-column: 2; grid-row: 1;
    width: 100%; height: 100%; min-height: 0;
    border-left: 1px solid var(--l2-border);
    padding: 1.5rem 1.75rem;
    justify-content: safe center;
    overflow-y: auto;
  }
  .rm-close { top: 1rem; right: 1rem; }
  .rm-meta { grid-template-columns: repeat(2, 1fr); margin-bottom: 0; }
  /* Убираем растяжение описания — иначе появляется пустота до меты */
  .rm-desc {
    flex: 0 0 auto; min-height: 0; overflow: visible;
    margin-bottom: 0; padding-right: 0.25rem;
  }
}

/* ─── Main content area ─────────────────────────────────────── */
main { padding: 1rem 0 3rem; }
@media (min-width: 1024px) { main { padding: 1.5rem 0 4rem; } }

/* SVG icons inline sizing */
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
