/*
 * Kolchart — общие стили для галереи и админки.
 * Без фреймворков: только обычный CSS.
 */

/* --- Сброс и базовые настройки --- */

/* Локальный DM Serif Display, SIL OFL 1.1: разрешено коммерческое использование. */
@font-face {
  font-family: "DM Serif Display";
  src: url("../fonts/dm-serif-display/DMSerifDisplay-Regular.8cc3643535edf039aa5d95440a8542735e9197e4f4b8d9303e980fefbf5ab616.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Авторские display-правила не должны отменять семантический hidden. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f5f5f5;
}

:root { --public-gallery-width: 806px; }

img {
  max-width: 100%;
  display: block;
}

a {
  color: #2563eb;
}

/* --- Шапка --- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
}

.site-title {
  margin: 0;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-synthesis: none;
  flex-shrink: 0;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-title a:hover {
  text-decoration: underline;
}

.site-header nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.site-header nav a {
  text-decoration: none;
  color: #444;
  white-space: nowrap;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: #000;
  font-weight: 600;
}

/* --- Контейнер контента --- */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.container--narrow {
  max-width: 520px;
}

/* --- Страница ошибки --- */

.error-page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.error-page > .public-header { flex-shrink: 0; }

.error-page__content {
  flex: 1;
  width: 100%;
  display: grid;
  place-items: center;
  text-align: center;
}

.error-page__content h1 { margin: 0; }

/* --- Контакты --- */

.contacts {
  padding-top: 3rem;
}

.contacts h1 {
  margin: 0 0 2rem;
}

.contacts__list {
  margin: 0;
}

.contacts__list > div {
  padding: 1rem 0;
  border-top: 1px solid #e5e5e5;
}

.contacts__list dt {
  color: #666;
  font-size: 0.9rem;
}

.contacts__list dd {
  margin: 0.25rem 0 0;
  font-size: 1.125rem;
  overflow-wrap: anywhere;
}

.public-header {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
}

.public-header .site-title {
  grid-column: 2;
  grid-row: 1;
  padding: 0;
  text-align: center;
}

.public-menu-toggle,
.public-search-link {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-row: 1;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  cursor: pointer;
}

.public-menu-toggle { grid-column: 1; }
.public-search-link { grid-column: 3; }
.public-menu-toggle svg,
.public-search-link svg { width: 1.5rem; height: 1.5rem; }

.public-menu-line {
  transform-origin: 12px 12px;
  transition: transform 200ms ease, opacity 200ms ease;
}
.public-menu-line--top { transform: translateY(-6px); }
.public-menu-line--bottom { transform: translateY(6px); }
.public-header--menu-open .public-menu-line--top { transform: rotate(45deg); }
.public-header--menu-open .public-menu-line--middle { opacity: 0; transform: scaleX(0.5); }
.public-header--menu-open .public-menu-line--bottom { transform: rotate(-45deg); }

.public-menu-toggle:focus-visible,
.public-search-link:focus-visible { outline: 2px solid #000; outline-offset: 2px; }

.public-header nav .search--header { display: none; }

.public-header nav {
  /* Hide before deferred scripts run; initialization must not fade out a visible menu. */
  display: none;
  grid-column: 1 / -1;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.public-header nav a { padding: 0.5rem 0.75rem; }
.public-header nav a[data-i18n="nav.contacts"] { font-weight: 400; }
.public-header nav a[data-i18n="nav.contacts"]:hover { text-decoration: underline; }
.public-header nav .lang-toggle {
  position: static;
  align-self: flex-start;
  text-align: left;
}

.public-header--enhanced .site-title,
.public-header--enhanced .public-search-link {
  transition: opacity 200ms ease, transform 200ms ease, visibility 0s;
}

.public-header--menu-open .site-title,
.public-header--menu-open .public-search-link {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-5px);
  transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
}

.public-header--enhanced nav [data-i18n="nav.gallery"] { display: none; }

.public-header--enhanced nav {
  display: grid;
  grid-column: 2 / -1;
  grid-row: 1;
  grid-template-columns: minmax(0, 1fr) 2.75rem;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(5px);
  transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
}

.public-header--menu-open nav {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

.public-header--enhanced nav > a:not(.lang-toggle) {
  justify-self: center;
  padding: 0.5rem 0;
}

.public-header--enhanced nav .lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  text-align: center;
}

.container--gallery .gallery-pagination {
  padding: 0 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}
.gallery-pagination a[rel="prev"],
.gallery-pagination a[rel="next"] { display: none; }
.gallery-pagination a,
.gallery-pagination span,
.gallery-pagination .gallery-order {
  display: inline-flex;
  flex: 0 0 2.5rem;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #000;
  border-radius: 50%;
  color: #000;
  background: transparent;
  text-decoration: none;
}
.gallery-pagination [aria-current="page"] { color: #fff; background: #000; }
.gallery-pagination .gallery-order { margin-right: .5rem; padding: 0; cursor: pointer; }
.gallery-order svg { width: 1.25rem; height: 1.25rem; }
.gallery-pagination .gallery-order[aria-pressed="true"] { color: #fff; background: #000; }
.gallery-pagination .gallery-order:focus-visible { outline: 2px solid #007aff; outline-offset: 3px; }
.gallery-pagination .gallery-order[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .public-menu-line,
  .public-header--enhanced .site-title,
  .public-header--enhanced .public-search-link,
  .public-header--enhanced nav { transition: none; }
}

.search-page__form { max-width: 806px; margin: 0 auto; padding: 1rem; }
.search--page { display: flex; gap: 0.5rem; }
.search--page .search__input { flex: 1; min-width: 0; }

.search-suggestions { max-width: 806px; margin: 0 auto; padding: 0 1rem 1rem; }
.search-suggestions__group + .search-suggestions__group { margin-top: 1.5rem; }
.search-suggestions__heading { margin: 0 0 0.5rem; color: #777; font-size: 1rem; font-weight: 400; }
.search-suggestions__list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.search-suggestions__list li { max-width: 100%; }
.search-suggestions__button {
  display: block;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 1rem;
  background: #fff;
  color: #222;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.search-suggestions__button:hover { border-color: #222; }
.search-suggestions__button:focus-visible { outline: 2px solid #000; outline-offset: 2px; }
.search-suggestions__toggle {
  margin-top: 0.5rem;
  padding: 0.375rem 0;
  border: 0;
  background: transparent;
  color: #555;
  font: inherit;
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.search-suggestions__toggle:hover { color: #000; }
.search-suggestions__toggle:focus-visible { outline: 2px solid #000; outline-offset: 2px; }

/* На телефоне публичная галерея занимает всю ширину без боковых полей. */
.container--gallery {
  max-width: none;
  padding: 1px 0 1.5rem;
}

/* --- Поиск (в шапке галереи и админки) --- */

.search {
  margin: 0;
}

.search--header {
  flex: 0 1 14rem;
  min-width: 8rem;
  width: 14rem;
}

.search__input {
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
  color: #1a1a1a;
}

/* Safari на iPhone увеличивает страницу при фокусе на слишком мелком тексте. */
@media (max-width: 48rem) {
  .search--page .search__input { font-size: max(16px, 1rem); }
}

.search__input:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  border-color: #2563eb;
}

.search__input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* Собственный крестик остаётся видимым и без фокуса, независимо от браузера. */
.search--clearable { position: relative; }
.search--clearable .search__input { padding-right: 2.75rem; }
.search--clearable .search__input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search--clearable .search__input::-ms-clear { display: none; }
.search__clear {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #666;
  cursor: pointer;
}
.search__clear svg { width: 1rem; height: 1rem; }
.search__clear:hover { color: #000; }
.search__clear:focus-visible { outline: 2px solid #000; outline-offset: -2px; }

/* --- Сообщения --- */

.message {
  text-align: center;
  color: #666;
  padding: 2rem 0;
}

.message--error {
  color: #b91c1c;
}

.message--success {
  color: #15803d;
}

/* --- Всплывающее сообщение (toast) в левом верхнем углу --- */
/* Информационные сообщения показываются поверх страницы и сами исчезают. */
.toast {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  max-width: 320px;
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #fff;
  color: #333;
  font-size: 0.9rem;
  text-align: left;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.toast[hidden] {
  display: none;
}

.toast--success {
  border-left: 4px solid #15803d;
  color: #15803d;
}

.toast--error {
  border-left: 4px solid #b91c1c;
  color: #b91c1c;
}

.hint {
  color: #666;
  font-size: 0.9rem;
}

.hint code {
  background: #eee;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
}

/* --- Сетка галереи --- */

.gallery {
  display: grid;
  /* Три колонки на телефоне, как в сетке профиля Instagram. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* Плотная сетка в стиле Instagram: отступ между плитками 2px со всех сторон */
  gap: 2px;
}

.gallery__item {
  /* Карточка — ссылка на страницу фото; убираем подчёркивание */
  display: block;
  position: relative;
  border: none;
  padding: 0;
  margin: 0;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.gallery__item:hover {
  /* Лёгкое затемнение вместо сдвига, чтобы плитки не наезжали друг на друга */
  opacity: 0.9;
}

.gallery__item:focus-visible {
  border-radius: 6px;
  outline: 2px solid #1a1a1a;
  outline-offset: -2px;
}

/* Blue selection frame, drawn inside the tile so neighbours never move. */
.gallery__item--selected::after {
  content: "";
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border: 3px solid #007aff;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.95);
  pointer-events: none;
}

.gallery__item--selected:hover { opacity: 1; }

.gallery__thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.gallery__item picture { display: block; }
.gallery-pagination { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.gallery-pagination [aria-current="page"] { font-weight: 700; }
.photo-modal__picture { display: contents; }

@media (min-width: 48rem) {
  .public-header {
    padding-inline: max(20px, calc((100% - var(--public-gallery-width)) / 2));
  }
  .public-menu-toggle { justify-content: flex-start; }
  .public-search-link { justify-content: flex-end; }

  .container--gallery {
    /* Четыре миниатюры по 200px и три промежутка по 2px.
       На узком десктопе сетка сжимается, сохраняя симметричные поля. */
    width: calc(100% - 40px);
    max-width: var(--public-gallery-width);
  }

  .gallery {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Маркер конца сетки для подгрузки следующей пачки (IntersectionObserver). */
.gallery-sentinel {
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  visibility: hidden;
  pointer-events: none;
}

.gallery-sentinel[hidden] {
  display: none;
}

/* --- Страница отдельного фото (/photo/<id>) --- */

/* --- Страница просмотра фото в стиле Instagram --- */

.message--light {
  color: #eee;
}

/* Белая подложка страницы фото, в том числе при прокрутке за край карточки. */
.photo-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "header" "photo";
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #fff;
}

.photo-body > .site-header { grid-area: header; }
.photo-body .photo-modal,
.photo-body .photo-modal__media { background: #fff; }
.photo-body .message--light { color: #666; }

/* Размер области фото учитывает реальную высоту шапки, в том числе в две строки. */
.photo-stage {
  --photo-info-width: 400px;
  --photo-row-inline-padding: 4.5rem;
  --photo-row-block-padding: 1rem;
  --photo-stack-block-padding: 1rem;
  grid-area: photo;
  position: relative;
  min-width: 0;
  min-height: 0;
  container-type: size;
}

.photo-controls {
  grid-area: photo;
  position: relative;
  z-index: 910;
  pointer-events: none;
}

.photo-controls > a,
.photo-controls > button { pointer-events: auto; }

/*
  Прокручиваемая область просмотра под общей шапкой. Центрирует фото и
  описание; на телефоне занимает место между верхней и нижней панелями.
*/
.photo-modal {
  position: absolute;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Отступы резервируют место под крестик (сверху) и стрелки (по бокам). */
  padding: var(--photo-row-block-padding, 1rem) var(--photo-row-inline-padding, 4.5rem);
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.75);
  overflow: auto;
}

.photo-modal[hidden] {
  display: none;
}

/*
  Разделённый блок: слева фото, справа информация. Между половинами нет
  зазора. Левые углы прямые, скруглены только правые (со стороны инфо).
  На узких экранах половины перестраиваются в колонку (инфо уходит под фото)
  — правило в media-запросе ниже.
*/
.photo-modal__dialog {
  display: flex;
  align-items: stretch;
  /*
    Ширину и высоту НЕ фиксируем — диалог обжимает содержимое
    (ширина фото + ширина инфо-панели), поэтому чёрных полей по краям нет.
  */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  box-shadow: none;
}

/*
  Левая половина — фотография на тёмном фоне. flex: 0 0 auto — половина НЕ
  сжимается и НЕ растягивается: её размер равен фактическому размеру картинки.
  Это важно: любой «усадочный» flex создаёт петлю пересчёта (ширина картинки
  зависит от ширины половины, а та — от картинки), из-за чего фото при
  перелистывании схлопывалось.
*/
.photo-modal__media {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

/*
  Размер фото считаем от ОКНА (vw/vh), а не от родителя — так нет петли
  пересчёта, и фото стабильно при перелистывании. Ограничения:
  - по высоте: высота области под шапкой минус небольшие поля (1rem × 2);
  - по ширине: ширина окна минус боковые отступы (4.5rem × 2) и панель
    инфо (.photo-modal__info = 400px).
  width/height: auto + object-fit: contain сохраняют пропорции без искажений.
*/
.photo-modal__image {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 2 * var(--photo-row-inline-padding, 4.5rem) - var(--photo-info-width, 400px));
  max-height: calc(100vh - 2 * var(--photo-row-block-padding, 1rem));
  object-fit: contain;
  cursor: default;
}

.photo-stage .photo-modal__image {
  max-height: calc(100cqh - 2 * var(--photo-row-block-padding));
}

.photo-modal__image--next { cursor: pointer; }

/* Пока вместо полного кадра стоит превью (другой crop) — заполняем бокс
   размера полной версии, чтобы блок не «пружинил» при смене src. */
.photo-modal__image--preview {
  object-fit: cover;
}

/* Крутилка поверх фото, пока грузится полный JPEG. */
.photo-modal__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.25rem;
  height: 2.25rem;
  margin: -1.125rem 0 0 -1.125rem;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: photo-spinner 0.7s linear infinite;
  pointer-events: none;
  z-index: 2;
}

.photo-modal__spinner[hidden] {
  display: none;
}

@keyframes photo-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Правая половина — доп. информация на белом фоне. */
.photo-modal__info {
  flex: 0 0 var(--photo-info-width, 400px);
  width: var(--photo-info-width, 400px);
  min-width: var(--photo-info-width, 400px);
  max-width: var(--photo-info-width, 400px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  background: #fff;
  color: #333;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Keep the panel's dimensions while its matching full image is loading. */
.photo-modal__info--loading { visibility: hidden; }

/* Temporary swipe cards live outside the scroller; the header/controls stay put. */
.photo-swipe__layer { position: fixed; z-index: 905; overflow: hidden; pointer-events: none; }
.photo-swipe__card { position: absolute; margin: 0; max-width: none; max-height: none; }
.photo-swipe--moving, .photo-swipe__card { will-change: transform; }
.photo-modal--swiping { overflow-x: clip; }
.photo-swipe__layer .photo-modal__image { width: 100%; height: auto; max-width: 100%; max-height: 70vh; }
.photo-modal__swipe-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.photo-modal__media--fresh .photo-modal__spinner { border-color: rgba(0, 0, 0, 0.15); border-top-color: #555; }

@media (max-width: 48rem) {
  /* Keep the mobile swipe copies free of edge shadows too. */
  .photo-body .photo-modal__dialog { touch-action: pan-y pinch-zoom; box-shadow: none; }
  .photo-body .photo-modal__image { -webkit-user-drag: none; user-select: none; }
}

/* Порядковый номер фото «№N» — на самом верху боковой панели. */
.photo-modal__number,
.photo-modal__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  color: #333;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.photo-modal__title-link { color: inherit; text-decoration: none; }
.photo-modal__title-link:hover,
.photo-modal__title-link:focus-visible { text-decoration: underline; }

.photo-modal__description {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  min-width: 0;
}

/* Теги под описанием: горизонтальный список «пилюль». */
.photo-modal__tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 100%;
}

.photo-modal__tag {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: #f0f0f0;
  color: #555;
  font-size: 0.85rem;
  line-height: 1.4;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

button.photo-modal__tag, a.photo-modal__tag {
  display: inline-block;
  border: none;
  font: inherit;
  cursor: pointer;
  appearance: none;
}

button.photo-modal__tag:hover, a.photo-modal__tag:hover {
  background: #e4e4e4;
  color: #111;
}

/* Локация «Страна, город» между описанием и тегами. */
.photo-modal__location {
  margin: 0;
  color: #777;
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.photo-modal__location-part {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  appearance: none;
}

.photo-modal__location-part:hover {
  color: #111;
}

/* Крестик закрытия — справа вверху оверлея. */
.photo-control-icon {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.photo-modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 910;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.photo-modal__close:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* Стрелки перелистывания — по центру слева и справа. */
.photo-modal__nav {
  text-decoration: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 910;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  line-height: 1;
  cursor: pointer;
}

.photo-modal__nav .photo-control-icon {
  width: 2rem;
  height: 2rem;
}

.photo-modal__nav:hover {
  background: rgba(0, 0, 0, 0.85);
}

.photo-modal__nav[hidden] {
  display: none;
}

.photo-modal__nav--prev {
  left: 1rem;
}

.photo-modal__nav--next {
  right: 1rem;
}

/* На десктопе тёмный круг появляется при наведении или фокусе. */
.photo-controls .photo-modal__nav,
.photo-controls .photo-modal__close {
  background: transparent;
  color: rgba(0, 0, 0, 0.65);
}

.photo-controls .photo-modal__nav:hover,
.photo-controls .photo-modal__close:hover,
.photo-controls .photo-modal__nav:focus-visible,
.photo-controls .photo-modal__close:focus-visible {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
}

/* На десктопе описание уходит вниз, если мешает показать кадр на доступную высоту. */
@media (min-width: 48.001rem) {
  .photo-modal--stacked {
    align-items: flex-start;
    padding-block: var(--photo-stack-block-padding);
  }

  .photo-modal--stacked .photo-modal__dialog {
    flex-direction: column;
    flex-shrink: 0;
    width: var(--photo-stacked-width, 100%);
    max-height: none;
    border-radius: 0 0 8px 8px;
  }

  .photo-modal--stacked .photo-modal__media { width: 100%; }
  .photo-stage .photo-modal--stacked .photo-modal__image {
    max-width: 100%;
    max-height: calc(100cqh - 2 * var(--photo-stack-block-padding));
  }

  .photo-modal--stacked .photo-modal__info {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    overflow: visible;
  }
}

/*
  Узкий экран (мобилы): блок не влезает по ширине — половины в колонку.
  Инфо переезжает под фото, зазора между ними нет.
*/
@media (max-width: 48rem) {
  .photo-modal {
    padding: 1px 0 0;
    align-items: flex-start;
  }

  /* Плавающие кнопки у нижнего края, без сплошной фоновой полосы. */
  .photo-controls {
    --photo-mobile-control-background: #fff;
    align-self: end;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    justify-items: center;
    padding: 0.5rem max(0.5rem, env(safe-area-inset-right)) calc(0.5rem + env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
    background: transparent;
    pointer-events: none;
  }

  .photo-controls .photo-modal__nav,
  .photo-controls .photo-modal__close {
    position: static;
    display: flex;
    transform: none;
    width: 3rem;
    height: 3rem;
    grid-row: 1;
    background: var(--photo-mobile-control-background);
    -webkit-tap-highlight-color: transparent;
  }

  .photo-controls .photo-modal__nav:hover,
  .photo-controls .photo-modal__close:hover,
  .photo-controls .photo-modal__nav:active,
  .photo-controls .photo-modal__close:active,
  .photo-controls .photo-modal__nav:focus-visible,
  .photo-controls .photo-modal__close:focus-visible {
    background: var(--photo-mobile-control-background);
    color: rgba(0, 0, 0, 0.65);
  }

  /* Без поддержки размытия сохраняется непрозрачная белая подложка. */
  @supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
    .photo-controls { --photo-mobile-control-background: rgba(255, 255, 255, 0.7); }
    .photo-controls .photo-modal__nav,
    .photo-controls .photo-modal__close {
      -webkit-backdrop-filter: blur(8px);
      backdrop-filter: blur(8px);
    }
  }

  .photo-modal__nav--prev { grid-column: 1; justify-self: start; }
  .photo-modal__close { grid-column: 2; }
  .photo-modal__nav--next { grid-column: 3; justify-self: end; }

  .photo-modal__dialog {
    flex-direction: column;
    /* В колонку диалог занимает всю ширину, высота — по содержимому. */
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
    /* Карточка доходит до краёв экрана без скруглённых боковых полей. */
    border-radius: 0;
  }

  .photo-modal__media {
    /* В колонку фото занимает всю ширину экрана. */
    flex: 0 0 auto;
    width: 100%;
  }

  .photo-stage .photo-modal__image {
    /* В колонку фото занимает всю ширину и высоту по содержимому. */
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 70vh;
  }

  .photo-modal__info {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    width: 100%;
    /* Последние теги можно прокрутить выше плавающих кнопок. */
    padding-bottom: calc(1.5rem + 4rem + env(safe-area-inset-bottom));
  }

}

/* --- Форма загрузки (админка) --- */

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field__label {
  font-size: 0.9rem;
  font-weight: 500;
}

.field input[type="file"],
.field input[type="password"] {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
}

.button {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 4px;
  background: #1a1a1a;
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.button:hover {
  background: #333;
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Прозрачная кнопка в шапке (например, «Выйти») */
.button--ghost {
  padding: 0.35rem 0.75rem;
  background: transparent;
  color: #444;
  border: 1px solid #ccc;
  font-weight: 400;
  font-size: 0.9rem;
}

.button--ghost:hover {
  background: #f0f0f0;
  color: #000;
}

/* --- Область drag-n-drop загрузки --- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 2.5rem 1.5rem;
  border: 2px dashed #bbb;
  border-radius: 8px;
  background: #fafafa;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: #1a1a1a;
  background: #f0f0f0;
  outline: none;
}

.dropzone--dragover {
  border-color: #15803d;
  background: #ecfdf3;
}

.dropzone--busy {
  opacity: 0.6;
  cursor: progress;
}

.dropzone__title {
  margin: 0;
  font-weight: 500;
}

.dropzone__hint {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
}

.upload-queue {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.upload-queue__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.8rem;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  border-left: 3px solid #ccc;
}

.upload-queue__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-queue__status {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: #666;
}

.upload-queue__item--uploading,
.upload-queue__item--generating {
  border-left-color: #2563eb;
}

.upload-queue__item--success {
  border-left-color: #15803d;
}

.upload-queue__item--success .upload-queue__status {
  color: #15803d;
}

.upload-queue__item--error {
  border-left-color: #b91c1c;
}

.upload-queue__item--error .upload-queue__status {
  color: #b91c1c;
}

/* --- Галерея в админке --- */

.admin-gallery-section {
  padding-top: 0;
}

.admin-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.admin-gallery__card {
  display: block;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.admin-gallery__card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.admin-gallery__thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
}

.admin-gallery__name {
  margin: 0;
  padding: 0.5rem 0.75rem 0;
  font-size: 0.9rem;
  font-weight: 500;
  word-break: break-all;
}

.admin-gallery__version {
  margin: 0;
  padding: 0.15rem 0.75rem 0;
  font-size: 0.8rem;
  color: #666;
}

.admin-gallery__date {
  margin: 0;
  padding: 0.35rem 0.75rem 0.15rem;
  font-size: 0.85rem;
  color: #555;
}

.admin-gallery__actions {
  padding: 0 0.75rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button--small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.button--danger {
  background: #b91c1c;
}

.button--danger:hover {
  background: #991b1b;
}

/* --- Переключатель представления (плитка / таблица) --- */

.view-toggle {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  margin: 0 0 1rem;
}

.view-toggle__button.is-active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.view-toggle__button.is-active:hover {
  background: #333;
}

/* --- Табличное представление списка фото в админке --- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.admin-table th,
.admin-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.admin-table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fafafa;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table__row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.admin-table__row:hover,
.admin-table__row:focus-visible {
  background: #f5f5f5;
  outline: none;
}

.admin-table__preview-cell {
  width: 56px;
}

.admin-table__thumb {
  display: block;
  width: 40px;
  height: 71px;
  object-fit: cover;
  border-radius: 4px;
}

.admin-table__name-cell {
  font-weight: 500;
  word-break: break-all;
}

.admin-table__version-cell,
.admin-table__date-cell {
  font-size: 0.85rem;
  color: #555;
  white-space: nowrap;
}

/* Показываем только активное представление внутри секции галереи. */
.admin-gallery-section[data-view="grid"] .admin-table {
  display: none;
}

.admin-gallery-section[data-view="table"] .admin-gallery {
  display: none;
}

/* --- Массовые операции: панель и выделение --- */

.bulk-panel {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  margin: 0 0 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.bulk-panel[hidden] {
  display: none;
}

.bulk-panel__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

/* Убираем стандартный маркер и рисуем свой поворачивающийся треугольник. */
.bulk-panel__summary::-webkit-details-marker {
  display: none;
}

.bulk-panel__summary::before {
  content: "▸";
  display: inline-block;
  color: #666;
  transition: transform 0.15s ease;
}

.bulk-panel[open] > .bulk-panel__summary::before {
  transform: rotate(90deg);
}

.bulk-panel__summary-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.bulk-panel__summary:hover {
  background: #fafafa;
}

/* Сворачиваемые разделы галереи (Опубликованные/Неопубликованные/Архивные). */
.admin-section__summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.admin-section__summary::-webkit-details-marker {
  display: none;
}

.admin-section__summary::before {
  content: "▸";
  display: inline-block;
  color: #666;
  transition: transform 0.15s ease;
}

.admin-section[open] > .admin-section__summary::before {
  transform: rotate(90deg);
}

/* Заголовок должен стоять в одну строку со стрелкой, без собственных отступов. */
.admin-section__summary h2 {
  margin: 0;
}

/* Количество фото в категории — приглушённой подписью рядом с заголовком. */
.admin-section__count {
  color: #888;
  font-size: 0.9rem;
  font-weight: 400;
}

.admin-section__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.admin-section__toolbar[hidden] {
  display: none;
}

/* Пейджер категории: кнопки сотен (100, 200, 300…). */
.admin-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1rem;
}

/* display: flex выше перебивает HTML-атрибут hidden — прячем явно. */
.admin-pager[hidden] {
  display: none;
}

.admin-pager__page.is-active {
  font-weight: 600;
  color: #111;
  background: #eee;
}

.bulk-panel__body {
  padding: 0 1.25rem 1rem;
}

.bulk-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.bulk-panel__count {
  margin-left: auto;
  font-size: 0.9rem;
  color: #555;
}

.bulk-panel__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bulk-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.bulk-actions__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.bulk-location {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.bulk-location__title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.bulk-location__hint {
  margin: 0 0 0.75rem;
}

.bulk-location__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.bulk-location__input {
  flex: 1 1 12rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}

.bulk-location__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bulk-panel__status {
  margin: 0.75rem 0 0;
}

/* --- Фильтры по тегам / локациям (админка) --- */

.filter-panel__body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.filter-panel__group-title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.filter-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.filter-panel__list:empty {
  display: none;
}

.filter-panel__chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.25rem 0.7rem;
  border: none;
  border-radius: 999px;
  background: #f0f0f0;
  color: #444;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
  appearance: none;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
}

.filter-panel__chip:hover {
  background: #e4e4e4;
  color: #111;
}

.filter-panel__chip-count {
  color: #888;
  font-size: 0.8em;
}

.filter-panel__empty {
  margin: 0;
}

/* Чекбокс выделения на карточке-плитке (поверх миниатюры). */
.admin-gallery__card {
  position: relative;
}

.admin-gallery__card.is-selected {
  outline: 2px solid #1a1a1a;
  outline-offset: 2px;
}

.select-check {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  cursor: pointer;
  accent-color: #1a1a1a;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* Ячейка чекбокса в таблице. */
.admin-table__select-cell {
  width: 40px;
  text-align: center;
}

.admin-table__row.is-selected {
  background: #eef2ff;
}

.admin-table__select-cell .select-check {
  position: static;
  box-shadow: none;
  background: none;
}

/* --- Страница редактирования фото --- */

.edit-back {
  margin: 0 0 1rem;
}

.edit-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0;
}

@media (max-width: 800px) {
  .edit-compare {
    grid-template-columns: 1fr;
  }
}

.edit-pane {
  margin: 0;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.edit-pane__label {
  margin: 0;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}

.edit-pane__image {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #fff;
}

.edit-pane__meta {
  margin: 0;
  padding: 0.45rem 0.85rem 0.65rem;
  font-size: 0.8rem;
  color: #555;
  border-top: 1px solid #eee;
  background: #fafafa;
}

/*
 * Общий блок «описание · теги · локация» (PhotoInfo) внутри панели публикации.
 * Переопределяем фиксированную ширину .photo-modal__info на всю ширину панели,
 * сохраняя стиль наполнения (описание/теги/локация) единым с галереей.
 */
.edit-pane__info {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  width: 100%;
  border-top: 1px solid #eee;
}

/* --- Метаданные (EXIF/IPTC/XMP) в панелях сравнения --- */

.edit-pane__metadata {
  padding: 0.5rem 0.85rem 0.85rem;
  font-size: 0.8rem;
  color: #555;
  border-top: 1px solid #eee;
}

.edit-pane__metadata-empty {
  margin: 0;
  color: #888;
}

.edit-pane__metadata-section {
  margin: 0.35rem 0 0;
  border: 1px solid #eee;
  border-radius: 4px;
  overflow: hidden;
}

.edit-pane__metadata-section > summary {
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-weight: 600;
  background: #fafafa;
  user-select: none;
}

.edit-pane__metadata-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.edit-pane__metadata-table th,
.edit-pane__metadata-table td {
  padding: 0.25rem 0.6rem;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid #f0f0f0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.edit-pane__metadata-table th {
  width: 45%;
  font-weight: 500;
  color: #444;
}

.edit-pane__metadata-table td {
  color: #222;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

/* --- Модалка обрезки --- */

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.7);
}

.crop-modal[hidden] {
  display: none;
}

.crop-modal__dialog {
  width: min(960px, 100%);
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.crop-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.25rem;
}

.crop-modal__header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.crop-modal__close {
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  color: #444;
}

.crop-modal__hint {
  margin: 0;
  padding: 0.5rem 1.25rem 0.75rem;
}

.crop-stage {
  position: relative;
  margin: 0 1.25rem;
  height: min(60vh, 520px);
  background: #111;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.crop-stage__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.crop-selection {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: move;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1px solid #333;
  box-sizing: border-box;
}

.crop-handle[data-crop-handle="nw"] { left: -6px; top: -6px; cursor: nwse-resize; }
.crop-handle[data-crop-handle="n"]  { left: 50%; top: -6px; margin-left: -6px; cursor: ns-resize; }
.crop-handle[data-crop-handle="ne"] { right: -6px; top: -6px; cursor: nesw-resize; }
.crop-handle[data-crop-handle="e"]  { right: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }
.crop-handle[data-crop-handle="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }
.crop-handle[data-crop-handle="s"]  { left: 50%; bottom: -6px; margin-left: -6px; cursor: ns-resize; }
.crop-handle[data-crop-handle="sw"] { left: -6px; bottom: -6px; cursor: nesw-resize; }
.crop-handle[data-crop-handle="w"]  { left: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }

.crop-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
}

/* --- Цепочка правок --- */

.edit-preview {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  background: #fafafa;
}

.edit-preview[hidden] {
  display: none;
}

.edit-preview__title {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.edit-preview__hint {
  margin: 0 0 0.75rem;
}

.edit-preview__pane {
  margin: 0 0 0.75rem;
}

.edit-preview__image {
  display: block;
  width: 100%;
  max-width: 240px;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
}

.edit-preview__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Описание фото (админка) --- */

.edit-description {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  background: #fafafa;
}

.edit-description[hidden] {
  display: none;
}

.edit-description__title {
  margin: 0 0 0.25rem;
}

.edit-description__input {
  width: 100%;
  box-sizing: border-box;
  margin: 0.5rem 0;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid #ccc;
  border-radius: 6px;
  resize: vertical;
}

.edit-description__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.edit-generate {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid #d6e4f0;
  border-radius: 8px;
  background: #f2f7fc;
}

.edit-generate[hidden] {
  display: none;
}

.edit-generate__title {
  margin: 0 0 0.25rem;
}

.edit-generate__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.edit-generate__result {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.edit-generate__result[hidden] {
  display: none;
}

.edit-generate__label {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.edit-generate__output {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.5rem;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  resize: vertical;
}

.edit-generate__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.edit-tags {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  background: #fafafa;
}

.edit-tags[hidden] {
  display: none;
}

.edit-tags__title {
  margin: 0 0 0.25rem;
}

.edit-tags__input {
  width: 100%;
  box-sizing: border-box;
  margin: 0.5rem 0;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.edit-tags__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.edit-location {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  background: #fafafa;
}

.edit-location[hidden] {
  display: none;
}

.edit-location__title {
  margin: 0 0 0.25rem;
}

.edit-location__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.edit-location__input {
  flex: 1 1 12rem;
  box-sizing: border-box;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.edit-location__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.edit-chain {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  background: #fafafa;
}

.edit-chain[hidden] {
  display: none;
}

.edit-chain__title {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.edit-chain__hint {
  margin: 0 0 0.75rem;
}

.chain-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chain-empty {
  margin: 0 0 0.75rem;
}

.chain-empty[hidden] {
  display: none;
}

.chain-item {
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  padding: 0.6rem 0.75rem;
}

.chain-item--dragging {
  opacity: 0.5;
}

.chain-item__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chain-item__handle {
  cursor: grab;
  color: #999;
  font-size: 1.1rem;
  line-height: 1;
}

.chain-item__title {
  font-weight: 600;
}

.chain-item__summary {
  color: #666;
  font-size: 0.9rem;
}

.chain-item__spacer {
  flex: 1;
}

.chain-item__move,
.chain-item__remove {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  width: 1.9rem;
  height: 1.9rem;
  cursor: pointer;
  line-height: 1;
  color: #333;
}

.chain-item__move:hover,
.chain-item__remove:hover {
  background: #f0f0f0;
}

.chain-item__move:disabled {
  opacity: 0.4;
  cursor: default;
}

.chain-item__remove {
  color: #b91c1c;
  border-color: #e0b4b4;
  font-size: 1.1rem;
}

.chain-item__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
}

.chain-item__note {
  margin: 0.4rem 0 0;
}

.chain-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chain-field__label {
  color: #444;
  font-size: 0.9rem;
}

.chain-field__range {
  width: 180px;
}

.chain-field__output {
  min-width: 3rem;
  font-variant-numeric: tabular-nums;
  color: #222;
}

.chain-field__select,
.chain-field__text,
.chain-field__number {
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.chain-field__text {
  min-width: 220px;
}

.chain-field__number {
  width: 120px;
}

.edit-chain__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e2e2e2;
}

.edit-chain__spacer {
  flex: 1;
}

.chain-add-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.chain-add-buttons__label {
  color: #444;
  font-size: 0.9rem;
}

/* --- SQL-консоль админки --- */

.sql-console h2 {
  margin: 0 0 0.5rem;
}

.sql-console__editor-label {
  display: block;
  margin: 1rem 0 0.75rem;
}

.sql-console__input {
  display: block;
  width: 100%;
  min-height: 12rem;
  margin-top: 0.35rem;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
  resize: vertical;
  box-sizing: border-box;
  background: #fff;
  color: #1a1a1a;
}

.sql-console__input:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  border-color: #2563eb;
}

.sql-console__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.sql-console__meta {
  color: #666;
  font-size: 0.9rem;
}

.sql-console__result {
  margin-top: 0.5rem;
}

.sql-console__table-scroll {
  overflow: auto;
  max-height: min(70vh, 40rem);
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
}

.sql-console__table {
  margin: 0;
  width: max-content;
  min-width: 100%;
}

.sql-console__table th,
.sql-console__table td {
  white-space: nowrap;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
}

.sql-console__null {
  color: #999;
  font-style: italic;
}

/* Default settings in the local admin. */
.settings-page { max-width: 720px; }
.settings-page fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.settings-card { padding: 1.5rem; margin-bottom: 1rem; background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; }
.settings-card h3 { margin: 0 0 1rem; }
.settings-card .field input { width: 100%; padding: 0.6rem; border: 1px solid #ccc; border-radius: 4px; font: inherit; }
.settings-check { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.settings-check input { width: 1.1rem; height: 1.1rem; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.settings-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.settings-page fieldset:disabled { opacity: 0.6; }
@media (max-width: 540px) {
  .settings-grid { grid-template-columns: 1fr; }
  body:has(.settings-page) .site-header { align-items: flex-start; flex-direction: column; }
  body:has(.settings-page) .site-header nav { flex-wrap: wrap; }
}
.settings-page .message { padding: 0.75rem 0; margin: 0 0 1rem; text-align: left; }
.settings-card textarea { display: block; width: 100%; padding: 0.6rem; border: 1px solid #ccc; border-radius: 4px; font: inherit; line-height: 1.5; resize: vertical; }
/* Одна пустая строка между группами тегов разных категорий. */
.photo-modal__tag-categories { display: flex; flex-direction: column; gap: 1.5rem; }
.photo-modal__tag-category-title { margin: 0 0 0.5rem; font-size: 0.875rem; font-weight: 400; color: #777; text-align: left; }
.photo-modal__tag-categories .photo-modal__tags { justify-content: flex-start; text-align: left; }
.photo-modal__tag-categories .photo-modal__tags > li { max-width: 100%; }
.tag-category-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 1rem; margin: 1rem 0; }
.tag-category-fields h4 { grid-column: 1 / -1; margin: 0; }
.tag-category-fields label { display: block; font-size: 0.85rem; color: #666; }
@media (max-width: 40rem) { .tag-category-fields { grid-template-columns: 1fr; } }

/* Collection tag dictionary and review. */
.tags-page { max-width: 1100px; }
.tags-page .message { text-align: left; }
.tags-page input[type="text"], .tags-page input[type="search"], .tags-page select {
  width: 100%; min-width: 0; padding: 0.6rem; border: 1px solid #ccc; border-radius: 4px; background: #fff; color: inherit; font: inherit;
}
.tags-filters { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin: 1.5rem 0 0; }
.tags-dictionary { max-height: 650px; overflow: auto; margin: 1rem 0; padding-right: 0.5rem; }
.tags-term { padding: 1rem; border: 1px solid #e5e5e5; border-radius: 6px; margin-bottom: 0.75rem; background: #fafafa; }
.tags-term-heading, .tags-photo-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.tags-term-heading .hint { margin: 0; }
.tags-term-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem 1rem; }
.tags-selection { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0; }
.tags-selection .hint { margin: 0; }
.tags-photos { margin-bottom: 1rem; }
.tags-photo { border-top: 1px solid #e5e5e5; padding: 1rem 0; }
.tags-photo-select { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; }
.tags-photo-select input { flex-shrink: 0; width: 1.1rem; height: 1.1rem; }
.tags-photo-heading a { flex-shrink: 0; font-size: 0.85rem; }
.tags-photo-body { display: flex; gap: 1rem; }
.tags-photo-body img { width: 72px; height: 128px; object-fit: cover; flex-shrink: 0; border-radius: 4px; background: #f3f3f3; }
.tags-photo-details { flex: 1; min-width: 0; }
.tags-diff { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0 0 0.75rem; font-size: 0.9rem; }
.tags-diff strong { width: 100%; font-size: 0.8rem; font-weight: 500; color: #777; }
.tags-diff span { padding: 0.15rem 0.45rem; border-radius: 4px; overflow-wrap: anywhere; }
.tags-diff-added { background: #eaf5ee; color: #205d36; }
.tags-diff-removed { background: #fcecec; color: #922e2e; }
.tags-page progress { width: 100%; height: 8px; margin-top: 1rem; }
@media (max-width: 600px) {
  .tags-term-grid, .tags-filters { grid-template-columns: 1fr; }
  .tags-page .settings-card { padding: 1rem; }
  body:has(.tags-page) .site-header { align-items: flex-start; flex-direction: column; }
  body:has(.tags-page) .site-header nav { flex-wrap: wrap; }
}

.metadata-page { max-width: 900px; }
.metadata-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem 1.5rem; }
.metadata-page .metadata-group { margin-top: 1.5rem; }
.metadata-page .metadata-group h4 { margin: 0 0 .75rem; }
.metadata-options .settings-check { align-items: flex-start; margin-bottom: .5rem; }
.metadata-options input { flex-shrink: 0; margin-top: .15rem; }
.metadata-existing { margin-top: 1.5rem; }
.metadata-errors { overflow-wrap: anywhere; color: #a32929; }
@media (max-width: 600px) { .metadata-options { grid-template-columns: 1fr; } }
