/* ad adaptive start */
.ad-banner {
  text-align: center;
  margin: 16px 0;
  position: relative;
  transition: opacity 0.3s ease, height 0.3s ease;
}
.ad-banner .mrg-tag {
  width: 100% !important;
  max-width: 970px;
  height: auto;
  aspect-ratio: 970 / 250;
  display: inline-block;
}
.ad-banner.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (max-width: 1199px) {
  .ad-banner .mrg-tag {
    max-width: 728px;
    aspect-ratio: 728 / 90;
  }
}
@media (max-width: 768px) {
  .ad-banner .mrg-tag {
    max-width: 320px;
    aspect-ratio: 320 / 50;
  }
}
.ad-banner.hidden {
  opacity: 0;
  height: 0;
  overflow: hidden;
}
.ad-fallback {
  display: none;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  text-align: center;
}
.ad-fallback a {
  color: #dc3545;
  text-decoration: none;
  font-weight: 600;
}
.ad-banner.hidden .ad-fallback {
  display: block;
}
/* ad adaptive end */

#menuContainer.loading::before {
  content: '';
  display: block;
  height: 50px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

html, body {
  width: 100%;
  overflow-x: hidden;
}
body {
  max-width: none;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
}
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Улучшение для мобильных устройств */
@media (max-width: 768px) {
  .page {
    padding: 10px 15px;
    width: 100%;
    box-sizing: border-box;
  }
  
  h1 {
    font-size: 1.8rem;
    margin: 15px 0;
    line-height: 1.3;
  }
  
  .subtitle {
    font-size: 1rem;
    margin-bottom: 25px;
    line-height: 1.4;
  }
}

h1 {
  margin: 20px 0;
  text-align: center;
  color: #333;
  font-size: 2.5rem;
}
.subtitle {
  text-align: center;
  color: #555;
  font-size: 1.2rem;
  margin-bottom: 40px;
}
.category-section {
  margin-bottom: 40px;
}
.category-title {
  font-size: 1.5rem;
  color: #333;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid #ddd;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

/* Ключевое исправление для мобильных устройств */
@media (max-width: 768px) {
  .tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    overflow-x: visible;
    scroll-snap-type: none;
    padding-bottom: 0;
    -webkit-overflow-scrolling: auto;
    box-shadow: none;
    margin-bottom: 20px;
  }
  
  .tools-grid::-webkit-scrollbar {
    display: none;
  }
  
  .card {
    min-width: auto;
    max-width: 100%;
    width: 100%;
    margin-right: 0;
    scroll-snap-align: none;
    padding: 20px;
    animation: none;
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 480px) {
  .tools-grid {
    gap: 12px;
  }
  
  .card {
    padding: 16px;
  }
}

.card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
  animation-delay: calc(var(--i) * 0.1s);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  border-color: #007bff;
}
.card h2 {
  font-size: 1.25rem;
  margin: 0 0 12px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card p {
  margin: 0 0 20px;
  color: #555;
  line-height: 1.6;
}
.card a {
  display: inline-block;
  padding: 12px 20px;
  background: linear-gradient(90deg, #dc3545, #c82333);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
}
.card a:hover {
  background: linear-gradient(90deg, #c82333, #a00d25);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}
.card a:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}
.tool-placeholder {
  opacity: 0.6;
  cursor: not-allowed;
}
.tool-placeholder a {
  background: #6c757d !important;
  cursor: not-allowed;
}
.tool-placeholder a:hover {
  transform: none !important;
  box-shadow: none !important;
}
.tool-placeholder .favorite-btn {
  display: none;
}
.coming-soon {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #f8f9fa;
  color: #6c757d;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  border: 1px solid #dee2e6;
  z-index: 5;
}
.stats {
  text-align: center;
  margin: 40px 0;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.stat-item {
  text-align: center;
}
.stat-number {
  font-size: 2rem;
  font-weight: bold;
  color: #dc3545;
}
.stat-label {
  color: #555;
  font-size: 0.9rem;
}

/* Адаптация панели фильтров для мобильных */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.filter-bar input,
.filter-bar select,
.filter-bar button {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  flex: 1;
  min-width: 120px;
}
.filter-bar button {
  background: linear-gradient(90deg, #dc3545, #c82333);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}
.filter-bar button:hover {
  background: linear-gradient(90deg, #c82333, #a00d25);
}
.filter-bar button:active {
  transform: scale(0.95);
}
#sort-favorites.active {
  background: linear-gradient(90deg, #28a745, #218838);
}

@media (max-width: 768px) {
  .filter-bar {
    flex-direction: column;
    gap: 8px;
  }
  
  .filter-bar input,
  .filter-bar select,
  .filter-bar button {
    width: 100%;
    min-width: auto;
    padding: 14px 12px;
    font-size: 1rem;
    margin: 0;
  }
  
  .filter-bar button {
    padding: 14px;
  }
  
  .stats {
    margin: 30px 0;
    padding: 15px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
  }
  
  .stat-number {
    font-size: 1.5rem;
  }
  
  .category-title {
    font-size: 1.3rem;
    margin-bottom: 12px;
  }
  
  .card h2 {
    font-size: 1.1rem;
    margin-bottom: 10px;
  }
  
  .card p {
    font-size: 0.95rem;
    margin-bottom: 16px;
  }
  
  .card a {
    padding: 10px 16px;
    font-size: 0.95rem;
    display: block;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .filter-bar input,
  .filter-bar select,
  .filter-bar button {
    font-size: 0.95rem;
    padding: 12px 10px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  
  .stat-number {
    font-size: 1.3rem;
  }
  
  .stat-label {
    font-size: 0.8rem;
  }
  
  .coming-soon {
    font-size: 0.7rem;
    padding: 3px 6px;
  }
}

.filter-message {
  display: none;
  color: #dc3545;
  font-size: 0.9rem;
  margin-top: 10px;
}
.filter-message:not(.hidden) {
  display: block;
}

.cta {
  text-align: center;
  margin: 40px 0;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ddd;
}
.cta .btn {
  display: inline-block;
  padding: 12px 20px;
  background: linear-gradient(90deg, #dc3545, #c82333);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}
.cta .btn:hover {
  background: linear-gradient(90deg, #c82333, #a00d25);
}
.favorite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #555 !important;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s ease, color 0.2s ease, border 0.2s ease;
  padding: 10px;
}
.favorite-btn.favorite {
  color: #ffd700 !important;
  border: 1px solid #ffd700 !important;
}
.favorite-btn:active {
  animation: rotateStar 0.3s ease;
}
@keyframes rotateStar {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.favorite-btn:hover {
  transform: scale(1.2);
}
@media (max-width: 768px) {
  .favorite-btn {
    font-size: 1.6rem;
    padding: 12px;
  }
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Дополнительные улучшения для мобильных */
@media (max-width: 768px) {
  body {
    padding: 0;
    font-size: 16px;
  }
  
  .category-section {
    margin-bottom: 30px;
  }
  
  /* Улучшение доступности для тач-устройств */
  .card a,
  .filter-bar button {
    min-height: 44px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .favorite-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}