:root {
  --wood: #6b4226;
  --wood-dark: #4e2f1a;
  --bg: #f6f1e9;
  --surface: #ffffff;
  --text: #2b2118;
  --muted: #7a6a5a;
  --border: #e2d8ca;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

/* Скрытые элементы скрыты всегда, даже если у них в стилях задан display */
[hidden] { display: none !important; }

/* Заметная рамка фокуса при работе с клавиатуры (Tab) */
:focus-visible {
  outline: 2px solid var(--wood);
  outline-offset: 2px;
}

.site-header :focus-visible {
  outline-color: #fff;
}

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--wood); }

h1, h2, h3 { line-height: 1.25; }

/* ---------- Шапка и меню ---------- */

.site-header {
  position: relative;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  min-height: 56px;
  background: var(--wood);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  padding: 6px 0;
  color: #fff;
  text-decoration: none;
}

/* Знак-тройник: пропорции 3 : 2 */
.brand-logo {
  display: block;
  flex-shrink: 0;
  width: 69px;
  height: 46px;
}

.brand-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Название — одной строкой, одним шрифтом (на узком экране переносится) */
.brand-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav a {
  padding: 8px 12px;
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
  opacity: 0.85;
}

.site-nav a:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.site-nav a.active { opacity: 1; background: var(--wood-dark); }

.menu-toggle {
  display: none;
  padding: 4px 10px;
  border: 0;
  background: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

@media (max-width: 760px) {
  .brand-logo { width: 54px; height: 36px; }
  .brand-text { font-size: 15px; }
  .menu-toggle { display: block; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 8px;
    background: var(--wood);
    box-shadow: var(--shadow);
  }

  .site-header.menu-open .site-nav { display: flex; }
  .site-nav a { padding: 12px; }
}

/* ---------- Обычные страницы ---------- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.page--text { max-width: 760px; }

.page h1 { margin: 0 0 16px; font-size: 28px; }

.lead { font-size: 18px; }

.breadcrumbs { margin: 0 0 8px; }

/* ---------- Формы, вход, личный кабинет ---------- */

.page--narrow { max-width: 440px; }

.account-link { display: contents; }

.auth-card,
.panel {
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 19px; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 10px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab.active { color: var(--wood); border-bottom-color: var(--wood); }

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}

.form input,
.form select,
.form textarea {
  font: inherit;
  font-size: 15px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid var(--wood);
  outline-offset: -1px;
}

.form--inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form--inline label { flex: 1 1 220px; }
.form--inline .form-error,
.form--inline .form-success { flex-basis: 100%; }

.button {
  padding: 10px 18px;
  border: 0;
  border-radius: 6px;
  background: var(--wood);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover { background: var(--wood-dark); }
.button:disabled { opacity: 0.6; cursor: wait; }

.button--secondary {
  background: var(--surface);
  color: var(--wood);
  border: 1px solid var(--wood);
}

.button--secondary:hover { background: var(--bg); }

.form-hint { margin: 0; color: var(--muted); font-size: 14px; }

.form-heading { margin: 0; font-size: 20px; }

.form-error {
  margin: 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fdecea;
  color: #8a1c12;
  font-size: 14px;
}

.form-success {
  margin: 0;
  color: #2e7d32;
  font-size: 14px;
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--wood);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

/* Два поля в строку, на телефоне — друг под другом */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row > label { display: flex; }

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

.form .panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 0;
}

.form .panel h2 { margin: 0; }

.picker-map {
  height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.photo-preview {
  display: block;
  /* В колонке формы картинка иначе растягивается на всю ширину — сохраняем пропорции */
  align-self: flex-start;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--radius);
  background: #ddd;
}

.panel--notice {
  border: 1px solid #f0d58c;
  background: #fff8e1;
}

.panel--notice p { margin: 0 0 8px; }

.panel--danger {
  margin-top: 16px;
  border: 1px solid #f0c4be;
}

/* Заявки в личном кабинете */
.submission {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.submission-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.submission-meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.submission-text { margin: 6px 0 0; font-size: 14px; }

.submission-text--admin {
  padding: 6px 10px;
  border-left: 3px solid var(--wood);
  background: var(--bg);
}

/* ---------- Новости ---------- */

.news-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 8px;
}

.news-post {
  overflow: hidden;
  padding: 0 0 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.news-post > :not(.news-photo) { margin-left: 20px; margin-right: 20px; }

.news-photo {
  display: block;
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  background: #ddd;
}

.news-post > .credit { margin-top: 4px; }
.news-date { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.news-post h2 { margin: 4px 0 10px; font-size: 24px; }

.news-body {
  white-space: pre-line;
  font-size: 16px;
  line-height: 1.6;
}

.news-photo-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.news-photo-fields legend { padding: 0 4px; color: var(--muted); font-size: 14px; }

/* ---------- Наблюдения за состоянием ---------- */

.obs-section {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.obs-section h2 { margin: 0; }
.obs-latest { margin: 0; font-size: 15px; }
.obs-section > .button { align-self: flex-start; }

.observation {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.observation-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.observation-text {
  margin: 8px 0 0;
  white-space: pre-line;
}

.obs-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.obs-photos img {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  background: #ddd;
}

.checkbox {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 8px !important;
  color: var(--text) !important;
}

.checkbox input { margin-top: 3px; }

/* Переключатель «Заявки / Наблюдения» в модерации */
.type-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.type-button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.type-button.active {
  border-color: var(--wood);
  background: var(--wood);
  color: #fff;
}

/* Модерация */
.moderation-card { margin-top: 16px; }

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.diff-table th,
.diff-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.diff-table th { width: 150px; color: var(--muted); font-weight: 600; }
.diff-before { background: #fdecea; color: #6d1b13; word-break: break-word; }
.diff-after { background: #e8f5e9; word-break: break-word; }
.diff-after input,
.diff-after select,
.diff-after textarea { width: 100%; }
.empty-value { color: var(--muted); }

.moderation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 560px) {
  .diff-table th { width: 90px; }
}

/* ---------- Фильтры ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filters input,
.filters select,
.filters button,
.sort select {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.filters input[type="search"] { flex: 1 1 260px; }
.filters button { cursor: pointer; }
.filters button:hover { border-color: var(--wood); }

.filters--column { flex-direction: column; }
.filters--column input[type="search"] { flex: none; }

.results-count {
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Статус и подписи ---------- */

.status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
}

.credit {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}

a.credit:hover { text-decoration: underline; }

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Каталог ---------- */

.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sort { font-size: 14px; color: var(--muted); }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.catalog-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.catalog-photo img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #ddd;
}

.catalog-card > .credit { padding: 0 12px; }

.catalog-body { padding: 4px 12px 14px; }

.catalog-body h2 { margin: 6px 0 4px; font-size: 17px; }
.catalog-body h2 a { color: var(--text); text-decoration: none; }
.catalog-body h2 a:hover { color: var(--wood); }

.catalog-body p {
  margin: 2px 0;
  font-size: 14px;
  color: var(--muted);
}

.catalog-body .status { margin-top: 6px; }

.empty { color: var(--muted); }

/* ---------- Страница объекта ---------- */

.object-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px;
  align-items: start;
}

.object-photo { margin: 0; }

.object-photo img {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  background: #ddd;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 12px 0;
  font-size: 15px;
}

.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.description { margin: 12px 0; }

.object-map {
  height: 360px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Памятники на странице музея */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.mini-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}

.mini-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #ddd;
}

.mini-card-title { padding: 8px 10px 0; font-weight: 600; font-size: 14px; }
.mini-card-meta { padding: 0 10px 10px; color: var(--muted); font-size: 13px; }
.mini-card:hover .mini-card-title { color: var(--wood); }

/* ---------- Страница «Музеи» ---------- */

.museum-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.museum-card {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.museum-photo img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 240px;
  object-fit: cover;
  background: #ddd;
}

.museum-body { padding: 16px 20px; }
.museum-body h2 { margin: 0 0 4px; font-size: 21px; }
.museum-body h2 a { color: var(--text); text-decoration: none; }
.museum-body h2 a:hover { color: var(--wood); }
.museum-body h3 { margin: 14px 0 6px; font-size: 15px; }
.museum-meta { margin: 0 0 8px; color: var(--muted); font-size: 14px; }

.museum-items {
  margin: 0;
  padding-left: 18px;
}

.museum-items span { color: var(--muted); font-size: 14px; }

@media (max-width: 760px) {
  .museum-card { grid-template-columns: 1fr; }
  .museum-photo img { height: 200px; min-height: 0; }
}

@media (max-width: 760px) {
  .object-layout { grid-template-columns: 1fr; }
  .page h1 { font-size: 24px; }
}

/* ---------- Страница карты ---------- */

.page-map {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.map-layout {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

#map { flex: 1; }

/* Кнопка «Фильтры» в левом верхнем углу карты */
.filters-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.filters-toggle::before { content: "⚙"; color: var(--wood); }
.filters-toggle:hover { background: var(--bg); }

/* Число включённых фильтров на кнопке */
.filters-badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--wood);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

/* Сколько объектов показано — под кнопкой */
.map-count {
  position: absolute;
  top: 58px;
  left: 12px;
  z-index: 1000;
  margin: 0;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 13px;
}

/* Панель фильтров: целиком, поверх карты */
.map-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.map-panel .filters > * { width: 100%; min-width: 0; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title { margin: 0; font-size: 18px; }

.panel-close {
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.panel-close:hover { color: var(--text); }

.panel-done:disabled { opacity: 0.5; cursor: default; }

/* На телефоне панель занимает весь экран карты */
@media (max-width: 760px) {
  .map-panel {
    inset: 0;
    width: auto;
    max-height: none;
    border-radius: 0;
  }
}

.legend {
  position: absolute;
  left: 12px;
  bottom: 24px;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.7;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
  vertical-align: -1px;
}

.dot--museum {
  background: #6b4226;
  border-radius: 3px;
}

/* Круглая метка памятника (цвет — статус сохранности) */
.object-marker {
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* Группа близких меток: кружок с числом */
.cluster-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(107, 66, 38, 0.92);
  box-shadow: 0 0 0 4px rgba(107, 66, 38, 0.25), 0 1px 4px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

/* Квадратная метка музея на карте */
.museum-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 6px;
  background: #6b4226;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* Карточка во всплывающем окне карты */
.popup-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
}
.popup-card { width: 250px; }

.popup-card img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 4px;
  background: #ddd;
}

.popup-card h3 { margin: 6px 0 4px; font-size: 15px; }

.popup-card p {
  margin: 2px 0;
  font-size: 13px;
  color: var(--muted);
}

.popup-card .status { margin-top: 4px; }

.popup-links {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-weight: 600;
}
