/* Галерея — главная страница */
:root {
  --gallery-h-padding: 20px;
}

* {
  box-sizing: border-box;
  font-family: 'Roboto', sans-serif;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  background: #0b1020;
  color: #f5f5f5;
  min-height: 100vh;
}

/* Контент главной (галерея + блок новостей выше) — по верхнему краю */
.main-wrap:has(.gallery-wrap) {
  align-items: flex-start;
  justify-content: flex-start;
}

.gallery-wrap {
  padding: 24px var(--gallery-h-padding);
  width: 100%;
  max-width: none;
  margin: 0;
}

.gallery-section-header {
  margin-bottom: 20px;
}

.gallery-section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #f5f5f5;
}

.gallery-grid {
  column-count: 5;
  column-gap: 16px;
  width: 100%;
  max-width: 100%;
}

@media (max-width: 1200px) {
  .gallery-grid {
    column-count: 4;
  }
}

@media (max-width: 900px) {
  .gallery-grid {
    column-count: 3;
  }
}

@media (max-width: 600px) {
  .gallery-grid {
    column-count: 2;
  }
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  cursor: pointer;
}

.gallery-item:hover {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: top;
}

.gallery-item-inner {
  position: relative;
}

.gallery-item-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fecaca;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.gallery-item-delete:hover {
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
}

.gallery-item-like {
  position: absolute;
  bottom: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 20px;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  z-index: 2;
}

.gallery-item-like:hover {
  background: rgba(0, 0, 0, 0.8);
  color: #e2e8f0;
}

.gallery-item-like.liked {
  color: #f87171;
}

.gallery-item-like.liked:hover {
  color: #fca5a5;
}

.gallery-item-like svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.modal-likes-row .gallery-item-like {
  position: static;
}

.gallery-modal-overlay {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.gallery-modal-overlay.open {
  display: flex;
}

.gallery-modal {
  background: rgba(15, 23, 42, 0.98);
  border-radius: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  overflow: hidden;
  border: none;
  display: flex;
  flex-wrap: nowrap;
}

.gallery-modal-left {
  flex: 1 1 auto;
  min-width: 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal-left img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.gallery-modal-right {
  flex: 0 0 320px;
  width: 320px;
  min-width: 320px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  border-left: 1px solid rgba(148, 163, 184, 0.2);
}

.gallery-modal-right h4 {
  margin: 0 0 4px;
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
}

.gallery-modal-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.gallery-modal-author-avatar-wrap {
  flex-shrink: 0;
}

.gallery-modal-author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.gallery-modal-author-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal-author-avatar-placeholder svg {
  width: 20px;
  height: 20px;
  color: rgba(148, 163, 184, 0.8);
}

.gallery-modal-author-nick {
  font-size: 14px;
  color: #e2e8f0;
}

.gallery-modal-right p {
  margin: 0 0 12px;
  font-size: 14px;
  color: #e2e8f0;
}

.gallery-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #f9fafb;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  z-index: 2;
}

.gallery-modal-close:hover {
  background: rgba(51, 65, 85, 0.9);
}

.gallery-modal .modal-actions {
  margin-top: auto;
  padding-top: 16px;
}

.btn-use-settings {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: 15px;
}

.btn-use-settings:hover {
  filter: brightness(1.1);
}

.gallery-loading {
  text-align: center;
  padding: 40px;
  color: #94a3b8;
}

.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
  font-size: 1.1rem;
}

/* Панель «Новости» на главной — по верхнему краю, отступы как у галереи */
.home-news-panel {
  width: 100%;
  background: rgba(15, 23, 42, 0.98);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding: 16px 40px 28px;
}

.home-news-panel-inner {
  width: 100%;
  max-width: none;
  margin: 0;
}

.home-news-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.home-news-panel-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #f5f5f5;
}

.home-news-panel-all {
  font-size: 14px;
  color: #38bdf8;
  text-decoration: none;
}

.home-news-panel-all:hover {
  text-decoration: underline;
}

.home-news-panel-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 100%;
}

@media (max-width: 1200px) {
  .home-news-panel-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .home-news-panel-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .home-news-panel-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.home-news-card {
  display: block;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
  text-decoration: none;
  color: inherit;
}

.home-news-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.home-news-card-image {
  aspect-ratio: 16 / 10;
  background: rgba(15, 23, 42, 0.6);
  overflow: hidden;
}

.home-news-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-news-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: rgba(148, 163, 184, 0.4);
}

.home-news-card-placeholder svg {
  width: 40px;
  height: 40px;
}

.home-news-card-body {
  padding: 14px;
}

.home-news-card-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 500;
  color: #f5f5f5;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-news-card-excerpt {
  margin: 0 0 6px;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-news-card-date {
  font-size: 12px;
  color: #94a3b8;
}
