* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  background: #f5f5f5;
}

/* ====== Основной контейнер ====== */
body, .gallery-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
}

/* ====== Хедер и навигация ====== */
.gallery-header {
  text-align: center;
  margin: 18px 0 9px 0;
  padding: 0 10px;
}

nav {
  margin: 10px 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ====== Альбомы ====== */
#albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  padding: 8px 3vw 12px 3vw;
  width: 100%;
  max-width: 100vw;
}

.album-item, .album-add-btn {
  aspect-ratio: 1/1;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform 0.17s cubic-bezier(.3,1.3,.3,1);
  min-width: 0;
}

.album-item:hover, .album-add-btn:hover {
  transform: scale(1.035);
  z-index: 3;
  box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.album-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
}

.album-item div {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  background: rgba(10,10,10,0.52);
  color: #fff;
  font-size: 1.04rem;
  font-weight: 500;
  padding: 9px 6px 8px 8px;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  box-sizing: border-box;
  text-align: center;
  backdrop-filter: blur(2.5px);
  line-height: 1.16;
  pointer-events: none;
}

.album-add-btn {
  justify-content: center;
  align-items: center;
  border: 2px dashed #4070ff;
  color: #4070ff;
  font-size: 2.1rem;
  background: #fcfcff;
  min-width: 70px;
  min-height: 70px;
  margin-bottom: 7px;
}

.album-add-btn:hover {
  background: #eaf1ff;
  color: #264ca2;
}

/* ====== Галерея (Masonry) ====== */
.gallery-grid {
  flex: 1;
  width: 100%;
  max-width: 100vw;
  padding: 6px 3vw 10px 3vw;
  box-sizing: border-box;
  column-width: 120px;
  column-gap: 9px;
  background: none;
  overflow-y: auto;
}

.photo-item {
  display: inline-block;
  width: 100%;
  margin: 0 0 9px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
  cursor: pointer;
  background: #fff;
  transition: transform 0.2s;
  min-width: 0;
}

.photo-item:hover {
  transform: scale(1.025);
}

.photo-item img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* ====== Модалка (для фото) ====== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.94);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  animation: modalIn .25s;
}

@keyframes modalIn { from { opacity:0; } to { opacity:1; } }

.modal.show {
  display: flex;
}

.modal-content {
  max-width: 96vw;
  max-height: 82vh;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  border-radius: 8px;
  background: #222;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 19px;
  color: #fff;
  font-size: 35px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.16s;
  z-index: 1100;
}
.close-btn:hover {
  color: #bbb;
}

/* ====== Photo upload grid (upload.html) ====== */
.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px,1fr));
  gap: 8px;
  margin: 20px 0;
}
.photo-thumb { position: relative; border-radius: 9px; overflow: hidden; }
.photo-thumb img { width: 100%; height: 108px; object-fit: cover; display: block;}
.photo-thumb .delete-btn {
  position: absolute; top: 6px; right: 7px;
  background: rgba(32,32,32,0.88); color: #fff; font-size: 20px; border: none;
  border-radius: 4px; cursor: pointer; padding: 2px 6px; transition: background .18s;
}
.photo-thumb .delete-btn:hover { background: #d33; }
.upload-bar { margin: 16px 0; }
.upload-bar input[type=file] { margin-right:10px; }

/* ====== Кнопки ====== */
.btn {
  display: inline-block;
  padding: 8px 16px;
  background: #293ead;
  color: #fff;
  border-radius: 7px;
  text-decoration: none;
  font-size: 1rem;
  transition: background 0.15s;
  margin-left: 7px;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover {
  background: #1e276b;
  color: #fff;
}

/* ====== Всплывающие сообщения ====== */
#message-box {
  position: fixed;
  z-index: 2000;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  max-width: 98vw;
  pointer-events: none;
}
.message {
  background: #3568f5;
  color: #fff;
  font-size: 1em;
  border-radius: 9px;
  padding: 12px 18px;
  margin: 0 0 7px 0;
  box-shadow: 0 3px 24px rgba(40,30,160,.09);
  animation: fadein .3s, fadeout .35s 2.5s;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 0.2s;
  position: relative;
}
.message.success { background: #38a274; }
.message.error   { background: #d13232; }
.message.visible { opacity: 1; }
.message .close-msg {
  position: absolute; right: 10px; top: 5px;
  background: none; border: none; color: #fff;
  font-size: 19px; cursor: pointer; font-weight: bold; opacity: 0.78;
}
@keyframes fadein { from {opacity: 0;} to {opacity: 1;} }
@keyframes fadeout { from {opacity: 1;} to {opacity: 0;} }

/* ====== Мобайл оптимизация ====== */
@media (max-width: 700px) {
  .gallery-header {
    margin: 8px 0 8px 0;
    font-size: 1.03em;
  }
  .btn {
    font-size: 0.98rem;
    padding: 7px 10px;
    margin-left: 4px;
  }
  .gallery-grid {
    column-width: 85px;
    column-gap: 6px;
    padding: 5px 2vw 8px 2vw;
  }
  #albums-grid {
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    gap: 6px;
    padding: 7px 1vw 9px 1vw;
  }
  .photo-list {
    grid-template-columns: repeat(auto-fit, minmax(68px,1fr));
    gap: 5px;
    margin: 10px 0;
  }
  .photo-thumb img { height: 68px; }
}
