:root {
  --bg: #0f1420;
  --card: #151a28;
  --text: #e6e7eb;
  --muted: #9aa3b2;
  --accent: #3b82f6;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(15,20,32,0.95), rgba(15,20,32,0.6));
  backdrop-filter: blur(6px);
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}

.site-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.telegram-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid rgba(59, 130, 246, 0.3);
  transition: all 0.2s ease;
}

.telegram-link:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: var(--accent);
}

.telegram-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.export-btn:hover {
  background: #2563eb;
}

.export-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.export-btn-disabled {
  background: var(--muted) !important;
  color: var(--text) !important;
  cursor: not-allowed !important;
  opacity: 0.6;
}

.export-btn-disabled:hover {
  background: var(--muted) !important;
}

.filter-panel {
  background: var(--card);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.mode-buttons {
  display: flex;
  gap: 8px;
}

.divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.3);
  margin: 0 8px;
}

.filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Базовые стили для всех кнопок фильтрации */
.filter-btn, .mode-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-btn:hover, .mode-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

/* Режимные кнопки (взаимоисключающие) */
.mode-btn {
  padding: 6px 12px;
  font-weight: 600;
  font-size: 13px;
  border-radius: 16px;
  text-transform: uppercase;
}

.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.mode-btn.sfw {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.4);
  color: #22c55e;
}

.mode-btn.sfw.active {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}

.mode-btn.nsfw {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.mode-btn.nsfw.active {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

/* Дополнительные фильтры (комбинируемые) */
.filter-btn {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 16px;
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Старые классы для обратной совместимости */
.tag-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.grid {
  display: grid;
  /* Увеличено ~на 30%: 220px -> 286px */
  grid-template-columns: repeat(auto-fill, minmax(286px, 1fr));
  gap: 14px;
  padding: 18px;
}

.card {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  outline: none;
  transition: opacity 0.2s ease;
}

.card.filtered-out {
  display: none;
}

.card:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.media-wrapper {
  position: relative;
  width: 100%;
  padding-top: 150%; /* 2:3 portrait ratio similar to screenshot */
  overflow: hidden;
}

.media-wrapper img,
.media-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-wrapper video {
  display: none;
}

.card.hover .media-wrapper img { display: none; }
.card.hover .media-wrapper video { display: block; }

.title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.65));
  color: var(--text);
  font-size: 14px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.badge.number-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  padding: 2px 6px;
  border-radius: 6px;
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  /* Белый текст с черной обводкой для контраста на любом фоне */
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 0 2px #000;
}

.tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 340px;
  background: rgba(26, 32, 44, 0.98);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 10px 12px;
  font-size: 13px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  transform: translate(-50%, calc(-100% - 12px));
  pointer-events: none;
  display: none;
}

.tooltip.visible { display: block; }

/* Age Warning Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 24px 24px 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
}

.modal-body p {
  margin: 0 0 12px 0;
  color: var(--text);
  line-height: 1.5;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-footer {
  padding: 16px 24px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 120px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
}

.btn-primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .telegram-link,
  .export-btn {
    width: 100%;
    justify-content: center;
  }

  .site-header h1 {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 12px 16px;
  }

  .telegram-link,
  .export-btn {
    font-size: 13px;
    padding: 7px 12px;
  }
}

/* ============================================
   Adaptive Filter Dropdown (Mobile)
   ============================================ */

.filter-dropdown-wrapper {
  flex: 1;
  min-width: 200px;
}

.filter-dropdown {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path fill="%23e6e7eb" d="M6 8L2 4h8z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.filter-dropdown:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

.filter-dropdown:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.filter-dropdown option {
  background: var(--card);
  color: var(--text);
  padding: 8px;
}

/* Desktop: show buttons, hide dropdown */
@media (min-width: 768px) {
  .filter-buttons {
    display: flex !important;
  }

  .filter-dropdown-wrapper {
    display: none !important;
  }

  .divider {
    display: block !important;
  }
}

/* Mobile: show dropdown, hide buttons */
@media (max-width: 767px) {
  .filter-buttons {
    display: none !important;
  }

  .filter-dropdown-wrapper {
    display: block !important;
  }

  .divider {
    display: none !important;
  }

  .filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .mode-buttons {
    justify-content: center;
  }
}

