/* Плавная прокрутка по якорям на страницах памяти */
.memory-page-shell {
  width: min(920px, calc(100% - 1rem));
  margin: 0 auto;
  color: var(--memory-text);
}

html:has(.memory-page-shell) {
  scroll-behavior: smooth;
}

/* Поиск по страницам памяти — на всю ширину контейнера */
.memory-page-search {
  width: 100%;
}

.memory-page-search__form {
  width: 100%;
}

.memory-page-search__container {
  background: var(--app-surface);
  border: 2px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.memory-page-search__container:focus-within {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}

/* Когда расширенный поиск открыт — прячем простую строку */
.memory-page-search__container:has(.memory-page-search__advanced[open]) .memory-page-search__simple {
  display: none;
}

.memory-page-search__line {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
}

.memory-page-search__line.memory-page-search__simple {
  /* inline display by default */
}

.memory-page-search__input {
  flex: 1;
  min-width: 0;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
  border: none;
  background: transparent;
  color: var(--app-text);
  outline: none;
  box-sizing: border-box;
}

.memory-page-search__input::placeholder {
  color: var(--app-muted);
}

.memory-page-search__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  background: var(--app-primary);
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}

.memory-page-search__btn i {
  font-size: 0.95em;
  line-height: 1;
}

.memory-page-search__btn:hover {
  background: #1a4f7f;
}

.memory-page-search__btn:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

/* Расширенный поиск — заменяет простую строку при раскрытии */
.memory-page-search__advanced {
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
  border: none;
}

/* Тоггл «Расширенный поиск» — показываем только когда простая строка видна */
.memory-page-search__advanced summary {
  display: block;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--app-border);
  cursor: pointer;
}

/* Когда расширенный открыт — summary компактнее, без верхней границы */
.memory-page-search__container:has(.memory-page-search__advanced[open]) .memory-page-search__advanced summary {
  border-top: none;
  padding: 0.5rem 1rem 0;
}

.memory-page-search__advanced-toggle {
  cursor: pointer;
  color: var(--app-primary);
  font-weight: 500;
  user-select: none;
  list-style: none;
  margin: 0;
  padding: 0;
  display: block;
  transition: color 0.2s ease;
}

.memory-page-search__advanced-toggle::-webkit-details-marker {
  display: none;
}

.memory-page-search__advanced-toggle::before {
  content: "▸ ";
  margin-right: 0.35rem;
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.2s ease;
}

.memory-page-search__advanced[open] .memory-page-search__advanced-toggle::before {
  transform: rotate(90deg);
}

.memory-page-search__advanced-toggle:hover {
  color: #1a4f7f;
}

.memory-page-search__advanced-fields {
  padding: 1rem 1.25rem 1.25rem;
}

.memory-page-search__advanced-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--app-border);
}

.memory-page-search__close-advanced {
  font-size: 0.9rem;
  color: var(--app-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.memory-page-search__close-advanced:hover {
  color: var(--app-primary);
}

.memory-page-search__advanced-row {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Верхняя строка: Фамилия, Имя, Отчество — широкие поля для длинных ФИО */
.memory-page-search__advanced-row--names {
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(280px, 1fr);
}

.memory-page-search__advanced-row--names .memory-page-search__input-sm {
  min-width: 100%;
  font-size: 1rem;
  padding: 0.6rem 1rem;
}

/* Нижняя строка: годы рождения и смерти — по центру на всю ширину */
.memory-page-search__advanced-row--years {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.memory-page-search__field--year {
  max-width: 120px;
}

.memory-page-search__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  color: var(--app-muted);
}

.memory-page-search__input-sm {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
  color: var(--app-text);
  transition: border-color 0.2s ease;
}

.memory-page-search__input-sm:hover {
  border-color: #cfd8e6;
}

.memory-page-search__input-sm:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 2px var(--app-primary-soft);
}

.memory-page-search__reset-link {
  font-size: 0.9rem;
  color: var(--app-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.memory-page-search__reset-link:hover {
  color: var(--app-primary);
}

/* Список страниц без фото */
.memory-page-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 720px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-soft);
  overflow: hidden;
}

.memory-page-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--app-border);
  transition: background-color 0.2s ease;
}

.memory-page-list__item:last-child {
  border-bottom: none;
}

.memory-page-list__item:hover {
  background-color: var(--app-primary-soft);
}

.memory-page-list__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.memory-page-list__name {
  font-weight: 600;
  color: var(--app-text);
}

.memory-page-list__dates {
  font-size: 0.9rem;
  color: var(--app-muted);
}

.memory-page-list__btn {
  flex-shrink: 0;
}

/* Адаптивность поиска */
@media (max-width: 768px) {
  .memory-page-search__line {
    flex-direction: column;
  }

  .memory-page-search__btn {
    justify-content: center;
  }

  .memory-page-search__advanced-row--names {
    grid-template-columns: 1fr;
  }

  .memory-page-search__field--year {
    max-width: none;
  }

  .memory-page-list__item {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .memory-page-list__info {
    justify-content: center;
  }

  .memory-page-list__btn {
    align-self: center;
  }
}

/* Каталог публичных страниц памяти */
.memory-directory {
  padding: clamp(0.35rem, 2vw, 1.25rem) 0 2rem;
}

.memory-directory__panel {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem);
  border: 1px solid rgba(184, 155, 94, 0.12);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 0, rgba(184, 155, 94, 0.07), transparent 34%),
    rgba(255, 253, 248, 0.92);
  box-shadow: 0 18px 48px rgba(75, 57, 35, 0.07);
}

.memory-directory__header {
  max-width: 760px;
  margin: 0 auto 2rem;
  text-align: center;
}

.memory-directory__title {
  margin: 0;
  color: var(--memory-text);
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  font-size: clamp(2.3rem, 4vw, 3.15rem);
  font-weight: 600;
  line-height: 1.05;
}

.memory-directory__mark {
  display: inline-flex;
  margin-top: 0.7rem;
  color: var(--memory-accent);
  font-size: 1.2rem;
}

.memory-directory__lead {
  max-width: 760px;
  margin: 0.85rem auto 0;
  color: var(--memory-muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.memory-directory__search {
  max-width: 940px;
  margin: 0 auto 2.25rem;
}

.memory-directory .memory-page-search__container {
  overflow: hidden;
  border: 1px solid rgba(184, 155, 94, 0.18);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 10px 28px rgba(75, 57, 35, 0.06);
}

.memory-directory .memory-page-search__container:focus-within {
  border-color: rgba(79, 107, 90, 0.42);
  box-shadow: 0 0 0 3px rgba(79, 107, 90, 0.12);
}

.memory-directory .memory-page-search__line {
  padding: 0.85rem 0.85rem 0.5rem;
}

.memory-directory .memory-page-search__input {
  min-height: 3rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--memory-border);
  border-radius: 8px 0 0 8px;
  background: var(--memory-surface);
}

.memory-directory .memory-page-search__btn {
  min-height: 3rem;
  padding: 0.7rem 1.25rem;
  border-radius: 0 8px 8px 0;
  background: var(--memory-accent);
}

.memory-directory .memory-page-search__btn:hover,
.memory-directory .memory-page-search__btn:focus-visible {
  background: var(--memory-accent-deep);
}

.memory-directory .memory-page-search__advanced summary {
  width: fit-content;
  margin: 0 0.85rem 0.85rem;
  padding: 0;
  border-top: 0;
  color: var(--memory-accent-deep);
  font-size: 0.9rem;
  font-weight: 700;
}

.memory-directory .memory-page-search__advanced-fields {
  padding: 0 0.85rem 1rem;
}

.memory-directory .memory-page-search__reset {
  margin-top: 0.7rem;
  text-align: center;
}

.memory-directory__result-note {
  margin: -0.75rem 0 2rem;
  color: var(--memory-muted);
  text-align: center;
}

.memory-directory__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto 1rem;
  max-width: 1040px;
}

.memory-directory__section-head h2 {
  margin: 0;
  color: var(--memory-text);
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  font-size: clamp(1.55rem, 2.4vw, 2rem);
  line-height: 1.15;
}

.memory-directory__section-head a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--memory-accent-deep);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.memory-directory__section-head a:hover {
  color: var(--memory-brass);
}

.memory-directory__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.65rem 1.75rem;
  max-width: 1040px;
  margin: 0 auto;
}

.memory-directory-card {
  overflow: hidden;
  border: 1px solid rgba(184, 155, 94, 0.18);
  border-radius: 12px;
  background: var(--memory-surface);
  box-shadow: 0 8px 22px rgba(75, 57, 35, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.memory-directory-card:hover {
  transform: translateY(-2px);
  border-color: rgba(184, 155, 94, 0.34);
  box-shadow: 0 14px 30px rgba(75, 57, 35, 0.08);
}

.memory-directory-card__image-link {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
}

.memory-directory-card__image-link img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.24s ease;
}

.memory-directory-card:hover .memory-directory-card__image-link img {
  transform: scale(1.035);
}

.memory-directory-card__shade {
  position: absolute;
  inset: auto 0 0;
  height: 55%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72));
}

.memory-directory-card__caption {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 0.8rem;
  display: grid;
  gap: 0.05rem;
  line-height: 1.1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.memory-directory-card__caption strong,
.memory-directory-card__caption span {
  font-size: 1.05rem;
}

.memory-directory-card__caption small {
  margin-top: 0.2rem;
  font-size: 0.9rem;
}

.memory-directory-card__body {
  display: flex;
  justify-content: center;
  padding: 0.9rem 1rem 1rem;
}

.memory-directory-card__button,
.memory-directory-text__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.45rem 1.05rem;
  border: 1px solid rgba(184, 155, 94, 0.28);
  border-radius: 8px;
  background: var(--memory-surface);
  color: var(--memory-accent-deep);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.memory-directory-card__button:hover,
.memory-directory-text__button:hover {
  border-color: var(--memory-accent);
  background: var(--memory-accent);
  color: #fff;
}

.memory-directory-text {
  max-width: 1040px;
  margin: 2rem auto 0;
  padding: 1.15rem 1.25rem;
  border: 1px solid rgba(184, 155, 94, 0.16);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.9);
}

.memory-directory-text h2 {
  margin: 0 0 1rem;
  color: var(--memory-text);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.memory-directory-text__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.memory-directory-text__item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
}

.memory-directory-text__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(111, 102, 92, 0.08);
  color: var(--memory-muted);
}

.memory-directory-text__content {
  display: grid;
  min-width: 0;
  gap: 0.15rem;
}

.memory-directory-text__content strong {
  overflow: hidden;
  color: var(--memory-text);
  font-size: 0.94rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-directory-text__content small {
  color: var(--memory-muted);
  font-size: 0.86rem;
}

@media (max-width: 991.98px) {
  .memory-directory__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-directory-text__list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  .memory-directory__panel {
    padding: 1.25rem 0.85rem 1.5rem;
    border-radius: 20px;
  }

  .memory-directory .memory-page-search__line {
    padding: 0.75rem;
  }

  .memory-directory .memory-page-search__input,
  .memory-directory .memory-page-search__btn {
    border-radius: 8px;
  }

  .memory-directory__section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .memory-directory__grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .memory-directory-card__image-link {
    aspect-ratio: 3 / 4;
  }

  .memory-directory-text {
    padding: 1rem 0.85rem;
  }

  .memory-directory-text__item {
    grid-template-columns: 2rem minmax(0, 1fr);
  }

  .memory-directory-text__button {
    grid-column: 2;
    justify-self: start;
  }
}

/* Форма создания страницы памяти — компактная */
.memory-page-create-wrap {
  display: flex;
  justify-content: center;
  padding: 2rem 0 3rem;
  min-height: 60vh;
}

.memory-page-create {
  max-width: 580px;
  width: 100%;
}

.memory-page-create__card {
  padding: 1.75rem 1.5rem;
}

.memory-page-create__header {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--app-border);
}

.memory-page-create__title {
  margin: 0 0 0.6rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--app-text);
  letter-spacing: 0.01em;
}

.memory-page-create__intro {
  margin: 0;
  color: var(--app-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.memory-page-create__block {
  margin-bottom: 1.5rem;
}

.memory-page-create__block-title {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--app-text);
  letter-spacing: 0.02em;
}

.memory-page-create__form .form-control,
.memory-page-create__form .form-select {
  border-radius: 10px;
  border-color: var(--app-border);
  transition: border-color 0.2s ease;
}

.memory-page-create__form .form-control:hover,
.memory-page-create__form .form-select:hover {
  border-color: #cfd8e6;
}

.memory-page-create__form .form-control:focus,
.memory-page-create__form .form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}

.memory-page-create__row {
  display: grid;
  gap: 0 1rem;
  margin-bottom: 1rem;
}

.memory-page-create__row--dates {
  grid-template-columns: 1fr 1fr;
}

.memory-page-create__field {
  min-width: 0;
}

.memory-page-create__field .form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--app-text);
  margin-bottom: 0.35rem;
}

.memory-page-create__field--epitaph {
  margin-bottom: 0.5rem;
}

.memory-page-create__hint {
  margin: -0.35rem 0 0.85rem;
  color: var(--app-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.memory-page-create__field--status {
  margin-bottom: 0.5rem;
}

.memory-page-create__field--epitaph textarea {
  resize: vertical;
  min-height: 72px;
}

.memory-page-create__actions {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.memory-page-create__submit {
  padding: 0.55rem 1.25rem;
  font-weight: 600;
}

.memory-page-create__submit:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.memory-page-create__cancel {
  font-size: 0.95rem;
  color: var(--app-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.memory-page-create__cancel:hover,
.memory-page-create__cancel:focus-visible {
  color: var(--app-primary);
}

@media (min-width: 576px) {
  .memory-page-create__row:first-of-type {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 575px) {
  .memory-page-create__row--dates {
    grid-template-columns: 1fr;
  }
}

.memory-page-section {
  background: linear-gradient(180deg, var(--memory-surface) 0%, #fffaf2 100%);
  border: 1px solid var(--memory-border);
  border-radius: var(--memory-radius-lg);
  box-shadow: var(--memory-shadow-soft);
  padding: 1.1rem 1.1rem 1.2rem;
}

section[id] {
  scroll-margin-top: 86px;
}

.memory-page-section + .memory-page-section,
.memory-page-actions + .memory-page-section {
  margin-top: 1rem;
}

.memory-page-section__header {
  font-size: 1.02rem;
  font-weight: 700;
  border-bottom: 1px solid var(--memory-border);
  padding-bottom: 0.7rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.memory-page-section__title {
  margin: 0;
  letter-spacing: 0.01em;
  color: var(--memory-text);
  font-family: "PT Serif", "Lora", "Georgia", serif;
  font-size: 1.18rem;
}

.memory-page-section--nested {
  padding: 0.85rem 1rem;
  border-radius: var(--memory-radius-sm);
}

/* Дополнительные разделы: контейнер и layout */
#memory-sections {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
}

#sections-edit-container {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

/* Список карточек — одна колонка на всю ширину */
.sections-edit__list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  min-width: 0;
}

/* Карточка раздела */
.section-edit-block {
  width: 100%;
  min-width: 0;
}

.section-edit-block__header {
  gap: 1rem;
}

.section-edit-block__actions {
  flex-shrink: 0;
}

/* Кнопка удаления: серая по умолчанию, красная при hover */
.section-delete-btn--muted {
  color: var(--app-muted) !important;
  border-color: var(--app-border) !important;
  background: transparent !important;
}

.section-delete-btn--muted:hover {
  color: #dc3545 !important;
  border-color: #dc3545 !important;
  background: transparent !important;
}

.section-text-improve-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
}

.section-text-improve-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.section-text-improve-compare textarea {
  min-height: 260px;
  resize: vertical;
}

@media (max-width: 768px) {
  .section-text-improve-compare {
    grid-template-columns: 1fr;
  }
}

.section-photo-edit {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

.section-photo-edit__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.section-photo-edit__hint {
  color: var(--app-muted);
  font-size: 0.86rem;
}

.section-photo-upload-status {
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
}

.section-photo-grid,
.section-photo-grid-edit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
}

.section-photo-grid-edit {
  grid-template-columns: repeat(auto-fill, minmax(132px, 160px));
  justify-content: start;
}

.section-photo-grid-edit.is-empty {
  display: none;
}

.section-photo-edit-item,
.section-photo-tile {
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
}

.section-photo-edit-item img,
.section-photo-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--app-bg);
}

.section-photo-edit-item {
  padding-bottom: 0.65rem;
}

.section-photo-edit-preview {
  display: block;
  width: 100%;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.section-photo-edit-preview:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: -2px;
}

.section-photo-edit-caption {
  display: block;
  padding: 0.55rem 0.65rem 0;
  color: var(--app-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.section-photo-edit-item .btn {
  display: block;
  width: calc(100% - 1rem);
  margin: 0.65rem auto 0;
}

.section-photo-tile {
  display: block;
  width: 100%;
  padding: 0;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.section-photo-tile:hover {
  border-color: var(--app-primary);
  box-shadow: 0 8px 20px rgba(15, 32, 58, 0.08);
  transform: translateY(-1px);
}

.section-photo-tile:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.section-photo-tile span {
  display: block;
  padding: 0.65rem 0.75rem;
  color: var(--app-muted);
  font-size: 0.9rem;
}

.memory-page-empty {
  margin: 0;
  color: var(--memory-muted);
  font-size: 0.95rem;
}

/* Кнопки выбора режима доступа в настройках приватности */
.privacy-type-buttons .btn {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.privacy-code-form {
  padding-top: 0.5rem;
  border-top: 1px solid var(--app-border);
}

/* Таблица значимых дат — слева год, справа описание */
.memory-page-significant-date-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.memory-page-significant-date-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  transition: border-color 0.2s ease;
}

.memory-page-significant-date-row:hover {
  border-color: #cfd8e6;
}

.memory-page-significant-date-row__year {
  flex-shrink: 0;
  min-width: 4ch;
  font-weight: 600;
  font-size: 1rem;
  color: var(--app-text);
}

.memory-page-significant-date-row__desc {
  flex: 1;
  min-width: 0;
  color: var(--app-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.memory-page-significant-date-row__delete {
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
}

.memory-page-significant-date-table--editable {
  display: flex;
}

.memory-page-significant-date-row--editable {
  align-items: center;
}

.memory-page-significant-date-row--editable.is-dragging {
  opacity: 0.55;
  border-color: var(--app-primary);
}

.memory-page-significant-date-row__drag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--app-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: grab;
}

.memory-page-significant-date-row__drag:active {
  cursor: grabbing;
}

.memory-page-significant-date-row__drag:hover,
.memory-page-significant-date-row__drag:focus-visible {
  color: var(--app-primary);
  background: var(--app-primary-soft);
  outline: none;
}

.memory-page-significant-date-row__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.memory-page-significant-date-row__move {
  width: 2rem;
  height: 2rem;
  padding: 0;
}

/* Кнопка удаления в модальном окне */
.memory-page-btn-danger {
  background-color: #dc3545 !important;
  color: #fff !important;
  border: none;
}

.memory-page-btn-danger:hover {
  background-color: #bb2d3b !important;
  color: #fff !important;
}

.memory-page-btn-danger:active {
  background-color: #b02a37 !important;
  color: #fff !important;
}

.memory-page-testimonials {
  display: grid;
  gap: 0.85rem;
}

.memory-page-testimonial {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface);
}

.memory-page-testimonial__text {
  color: var(--app-text);
  font-size: 0.96rem;
  line-height: 1.62;
}

.memory-page-testimonial__author {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  margin-top: 0.85rem;
  color: var(--app-text);
  font-weight: 600;
}

.memory-page-testimonial__author span {
  color: var(--app-muted);
  font-size: 0.88rem;
  font-weight: 400;
}

/* Модальное окно значимых дат */
.modal-content.memory-page-modal {
  border-radius: var(--app-radius-lg);
  border: 1px solid var(--app-border);
  box-shadow: var(--app-shadow-soft);
}

.modal-content.memory-page-modal .modal-title {
  color: var(--app-text);
  font-weight: 600;
}

.modal-content.memory-page-modal .modal-body {
  color: var(--app-muted);
}

/* Кнопка удаления в списке значимых дат — в стиле сайта */
.memory-page-btn-delete {
  border: 1px solid var(--app-border);
  color: var(--app-muted);
  background: transparent;
  border-radius: 6px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.memory-page-btn-delete:hover {
  border-color: #cfd8e6;
  color: var(--app-text);
  background: var(--app-primary-soft);
}

.memory-page-btn-delete:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--app-primary-soft);
}

/* Ошибки формы — вместо Bootstrap alert */
.memory-page-form-errors {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.9rem;
}

.memory-page-form-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.memory-page-justified {
  text-align: left;
  line-height: 1.7;
}

.memory-page-justified p {
  margin: 0 0 0.75rem;
}

.memory-page-justified ul,
.memory-page-justified ol {
  padding-left: 1.5rem;
  margin: 0 0 0.95rem;
}

.memory-page-justified ul {
  list-style: disc outside;
}

.memory-page-justified ol {
  list-style: decimal outside;
}

.memory-page-justified ul ul,
.memory-page-justified ol ol,
.memory-page-justified ul ol,
.memory-page-justified ol ul {
  margin: 0.35rem 0 0.6rem;
}

.memory-page-justified li {
  margin-bottom: 0.35rem;
}

.memory-page-justified blockquote {
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.8rem;
  border-left: 3px solid var(--memory-accent);
  background: var(--memory-brass-soft);
  color: var(--memory-text);
}

.memory-page-intro {
  background: linear-gradient(160deg, #fcf9f3, #ffffff);
  color: #344053;
}

.memory-page-promo {
  width: 100%;
  min-width: 0;
  background: linear-gradient(180deg, var(--memory-brass-soft) 0%, var(--memory-surface) 100%);
  border: 1px solid var(--memory-border);
  border-radius: var(--memory-radius-lg);
  box-shadow: var(--memory-shadow-soft);
  padding: 2.2rem 1.25rem;
  box-sizing: border-box;
}

.memory-page-promo__inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  min-width: 0;
}

.memory-page-promo__title {
  font-size: clamp(1.4rem, 1.1vw + 1rem, 2rem);
  margin: 0;
  color: var(--memory-text);
  font-family: "PT Serif", "Lora", "Georgia", serif;
}

.memory-page-promo__text {
  margin: 0.7rem auto 0;
  max-width: 100%;
  font-size: 1.05rem;
  color: var(--memory-muted);
  line-height: 1.5;
}

.memory-page-promo__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1.1rem;
  min-width: 200px;
  max-width: 100%;
  text-decoration: none;
  white-space: nowrap;
}

.memory-page-promo__button:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

/* Рекламный блок услуг: две карточки рядом */
.memory-page-promo--services .memory-page-promo__inner {
  max-width: 900px;
}

.memory-page-promo-card {
  background: var(--memory-surface);
  border: 1px solid var(--memory-border);
  border-radius: var(--memory-radius-lg);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--memory-shadow-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.memory-page-promo-card:hover {
  border-color: var(--memory-accent);
  box-shadow: 0 0 0 2px var(--memory-accent-soft);
}

.memory-page-promo-card__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--memory-text);
  margin: 0 0 0.5rem;
}

.memory-page-promo-card__text {
  font-size: 0.9rem;
  color: var(--memory-muted);
  line-height: 1.5;
  margin: 0 0 1rem;
}

.memory-page-promo-card .memory-page-promo__button {
  margin-top: 0;
  min-width: 160px;
}

.memory-page-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: center;
  background: linear-gradient(180deg, var(--memory-surface-soft) 0%, var(--memory-surface) 100%);
}

.memory-page-toc__title {
  margin-right: 0.2rem;
  font-size: 0.92rem;
  color: var(--memory-muted);
  font-weight: 600;
  flex: 0 0 100%;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.memory-page-toc__link {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--memory-accent);
  border-radius: 999px;
  background: rgba(79, 107, 90, 0.08);
  border: 1px solid rgba(79, 107, 90, 0.14);
}

.memory-page-toc__link:hover,
.memory-page-toc__link:focus-visible {
  color: var(--memory-accent-deep);
  background: var(--memory-accent-soft);
  border-color: rgba(79, 107, 90, 0.28);
}

/* Состояния разделов на странице редактирования: заполнено — синий, пусто — оранжевый */
.memory-page-toc--edit .memory-page-toc__link--filled {
  color: var(--memory-accent-deep);
  background: var(--memory-accent-soft);
  border-color: rgba(79, 107, 90, 0.3);
}

.memory-page-toc--edit .memory-page-toc__link--filled:hover,
.memory-page-toc--edit .memory-page-toc__link--filled:focus-visible {
  color: var(--memory-accent-deep);
}

.memory-page-toc--edit .memory-page-toc__link--empty {
  color: #8a6a2f;
  background: var(--memory-brass-soft);
  border-color: rgba(184, 155, 94, 0.34);
}

.memory-page-toc--edit .memory-page-toc__link--empty:hover,
.memory-page-toc--edit .memory-page-toc__link--empty:focus-visible {
  color: #765821;
}

.memory-page-toc__lock {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(111, 102, 92, 0.08);
  border: 1px dashed rgba(111, 102, 92, 0.3);
  color: var(--memory-muted);
  font-size: 0.88rem;
}

/* Ссылка «Наверх» в заголовке каждого раздела */
.memory-page-back-to-top {
  display: inline-block;
  padding: 0.05rem 0;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  color: var(--memory-accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.memory-page-back-to-top:hover,
.memory-page-back-to-top:focus-visible {
  color: var(--memory-accent-deep);
  text-decoration-thickness: 2px;
}

.memory-page-hero {
  text-align: center;
  padding: 1.8rem 1.3rem 1.65rem;
  background:
    radial-gradient(circle at top, rgba(184, 155, 94, 0.18), transparent 34%),
    linear-gradient(180deg, #fff9ef 0%, var(--memory-surface) 56%, #fffaf4 100%);
  border-color: rgba(184, 155, 94, 0.22);
}

.memory-page-hero__media {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}

.memory-page-hero__content {
  max-width: 760px;
  margin: 0 auto;
}

.memory-page-hero__photo {
  width: 248px;
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: cover;
  border-radius: 22px;
  border: 1px solid rgba(184, 155, 94, 0.28);
  box-shadow: var(--memory-shadow-card);
}

.memory-page-hero__photo--placeholder {
  width: 248px;
  aspect-ratio: 3 / 4;
  height: auto;
  border-radius: 22px;
  background: linear-gradient(180deg, #f6efe4, #fffaf2);
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(184, 155, 94, 0.28);
  box-shadow: var(--memory-shadow-card);
}

/* Иконка человека — крупная и строго по центру */
.memory-page-hero__photo--placeholder img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  object-position: center;
  opacity: 0.56;
  flex-shrink: 0;
}

.memory-page-hero__name {
  margin: 0;
  font-size: clamp(1.7rem, 2.2vw + 1.1rem, 2.5rem);
  line-height: 1.2;
  color: var(--memory-text);
  font-family: "PT Serif", "Lora", "Georgia", serif;
}

.memory-page-hero__meta {
  color: var(--memory-muted);
  margin-top: 0.35rem;
  font-size: 1.02rem;
}

.memory-page-hero__badges {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.memory-page-hero__military-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.38rem 0.75rem;
  border: 1px solid rgba(31, 91, 149, 0.2);
  border-radius: 999px;
  background: rgba(232, 241, 251, 0.88);
  color: var(--app-primary);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
}

.memory-page-hero__military-badge--svo_participant {
  border-color: rgba(31, 91, 149, 0.24);
  background: rgba(232, 241, 251, 0.94);
}

.memory-page-hero__military-badge--ww2_veteran {
  border-color: rgba(151, 107, 28, 0.28);
  background: rgba(255, 246, 224, 0.94);
  color: #7a5314;
}

.memory-page-hero__military-badge--combat_veteran {
  border-color: rgba(67, 113, 75, 0.26);
  background: rgba(235, 246, 236, 0.94);
  color: #315f3c;
}

.memory-page-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.memory-page-epitaph {
  max-width: 700px;
  margin: 1.05rem auto 0;
  border-top: 1px solid var(--memory-border);
  padding: 0.85rem 0 0;
  color: #5a4d40;
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.5;
}

/* Блок эпитафии в модальном окне — цитата с фоном */
.epitaph-modal-quote {
  background: #f7efe2;
  border: 1px solid #e3d0b1;
  border-left: 4px solid var(--app-primary);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  font-style: italic;
  color: #5c4a2f;
}

.epitaph-modal-text {
  font-size: 1.5rem;
  line-height: 1.6;
  color: #3d2f1a;
  resize: vertical;
}

.epitaph-modal-text:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem rgba(31, 91, 149, 0.18);
  outline: 0;
}

.memory-page-info-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem 0.65rem;
}

.memory-page-info-list > li {
  margin: 0;
  padding: 0.55rem 0.72rem;
  background: #fffaf2;
  border: 1px solid var(--memory-border);
  border-radius: 10px;
}

/* Дополнительная информация — отдельный блок на всю ширину внизу */
.memory-page-info-extra {
  margin-top: 1rem;
  padding: 1rem 1rem 1.05rem;
  background: #fff9f0;
  border: 1px solid var(--memory-border);
  border-radius: 10px;
  width: 100%;
  box-sizing: border-box;
}

.memory-page-info-extra strong {
  display: block;
  margin-bottom: 0.5rem;
}

.memory-page-info-extra__text {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
  color: var(--memory-text);
}

.memory-page-grid {
  display: grid;
  gap: 1rem;
}

.memory-page-grid--story {
  gap: 1rem;
}

.memory-page-grid--final {
  grid-template-columns: 1fr 1fr;
}

.memory-page-grid--final section:only-child {
  grid-column: 1 / -1;
}

.memory-page-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
  transition: max-height 0.25s ease;
  overflow: hidden;
  max-height: 15rem;
}

.memory-page-photo-grid.is-expanded {
  max-height: none;
}

.memory-page-photo-tile {
  position: relative;
  width: 100%;
  border: none;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #dfe6f2;
  cursor: pointer;
}

.memory-page-photo-tile:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.memory-page-photo-tile img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.memory-page-photo-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.45rem 0.5rem;
  font-size: 0.78rem;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

.memory-page-gallery-modal .carousel-item img {
  max-height: min(78vh, 620px);
  width: auto !important;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin-inline: auto;
}

.memory-page-gallery-modal .carousel-caption {
  position: static;
  margin-top: 0.85rem;
  color: var(--app-muted);
}

.memory-page-gallery-modal #memoryPhotoCarousel {
  position: relative;
}

.memory-page-gallery-modal .section-photo-carousel {
  position: relative;
}

.section-photo-open-link {
  color: var(--app-primary);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
}

.section-photo-open-link:hover {
  color: #1a4f7f;
  text-decoration: underline;
}

.section-photo-edit-modal__image {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  background: #111827;
  border-radius: 12px;
}

.memory-page-gallery-modal .carousel-control-prev,
.memory-page-gallery-modal .carousel-control-next {
  width: 3rem;
  height: 3rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.9;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  z-index: 10;
}

.memory-page-gallery-modal .carousel-control-prev {
  left: 0.5rem;
}

.memory-page-gallery-modal .carousel-control-next {
  right: 0.5rem;
}

.memory-page-gallery-modal .carousel-control-prev:hover,
.memory-page-gallery-modal .carousel-control-next:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.5);
}

/* Drag-drop зона и грид фотоальбома в режиме редактирования */
.memory-page-gallery-drop {
  width: 100%;
  min-height: 180px;
  border: 2px dashed var(--app-muted);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Полноэкранная область загрузки — на всю видимую область */
.memory-page-gallery-drop--fullscreen {
  min-height: min(70vh, 560px);
  padding: 2.5rem 1.5rem;
  background: linear-gradient(180deg, #f8fafc 0%, var(--app-primary-soft) 100%);
  border-radius: var(--app-radius-lg);
}

.memory-page-gallery-drop--fullscreen .memory-page-gallery-drop__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.memory-page-gallery-drop--fullscreen .memory-page-gallery-drop__icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  color: var(--app-primary);
}

.memory-page-gallery-drop--fullscreen .memory-page-gallery-drop__text {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--app-text);
}

.memory-page-gallery-drop--fullscreen .memory-page-gallery-drop__hint {
  display: block;
  margin-top: 0.35rem;
  color: var(--app-muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.memory-page-gallery-drop--fullscreen:hover .memory-page-gallery-drop__icon,
.memory-page-gallery-drop--fullscreen.is-dragover .memory-page-gallery-drop__icon {
  color: #1a4f7f;
}

.memory-page-gallery-drop--fullscreen.has-photos {
  min-height: 120px;
  padding: 1.25rem;
  background: var(--app-surface);
  border: 2px dashed var(--app-border);
}

.memory-page-gallery-drop--fullscreen.has-photos .memory-page-gallery-drop__icon {
  font-size: 1.75rem;
}

.memory-page-gallery-drop--fullscreen.has-photos .memory-page-gallery-drop__text {
  font-size: 0.95rem;
  font-weight: 600;
}

.memory-page-gallery-drop--fullscreen.has-photos .memory-page-gallery-drop__hint {
  display: none;
}

.memory-page-gallery-drop:hover,
.memory-page-gallery-drop.is-dragover {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}

.memory-page-gallery-drop__icon {
  font-size: 2.75rem;
  color: var(--app-muted);
  display: block;
  margin-bottom: 0.75rem;
}

.memory-page-gallery-drop:hover .memory-page-gallery-drop__icon,
.memory-page-gallery-drop.is-dragover .memory-page-gallery-drop__icon {
  color: var(--app-primary);
}

.memory-page-gallery-drop__text {
  color: var(--app-text);
  font-weight: 500;
  font-size: 1rem;
}

.memory-page-gallery-drop__hint {
  margin-top: 0.35rem !important;
  color: var(--app-muted) !important;
  font-size: 0.875rem;
}

.memory-page-gallery-drop__loading {
  color: var(--app-primary);
}

.memory-page-gallery-drop.has-photos {
  padding: 1.25rem;
  min-height: 100px;
}

.memory-page-gallery-drop.has-photos .memory-page-gallery-drop__text {
  font-size: 0.95rem;
  font-weight: 600;
}

.memory-page-gallery-drop.has-photos .memory-page-gallery-drop__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.memory-page-gallery-drop.has-photos .memory-page-gallery-drop__icon {
  font-size: 1.75rem;
}

@media (max-width: 768px) {
  .memory-page-gallery-drop {
    min-height: 160px;
    padding: 1.5rem 1rem;
  }

  .memory-page-gallery-drop--fullscreen {
    min-height: min(60vh, 400px);
    padding: 2rem 1rem;
  }

  .memory-page-gallery-drop--fullscreen .memory-page-gallery-drop__icon {
    font-size: 2.75rem;
  }

  .memory-page-gallery-drop--fullscreen .memory-page-gallery-drop__text {
    font-size: 1rem;
  }

  .memory-page-gallery-drop--fullscreen.has-photos {
    min-height: 100px;
  }
}

.memory-page-gallery-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Карточки страниц памяти родственников */
.memory-page-family-tree {
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: #f8fbff;
  padding: 1rem;
}

.memory-page-family-tree__canvas {
  position: relative;
  padding: 0.5rem 0 0;
}

.memory-page-family-tree__root {
  width: min(420px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--app-primary);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(31, 91, 149, 0.08);
}

.memory-page-family-tree__photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--app-border);
  background: #edf2fb;
}

.memory-page-family-tree__photo--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.memory-page-family-tree__photo--placeholder img {
  width: 28px;
  opacity: 0.5;
}

.memory-page-family-tree__relation {
  font-size: 0.78rem;
  color: var(--app-muted);
  margin-bottom: 0.15rem;
}

.memory-page-family-tree__name {
  font-weight: 700;
  color: var(--app-text);
  line-height: 1.25;
}

.memory-page-family-tree__years {
  font-size: 0.85rem;
  color: var(--app-muted);
  margin-top: 0.15rem;
}

.memory-page-family-tree__line {
  width: 1px;
  height: 30px;
  background: var(--app-border);
  margin: 0 auto;
}

.memory-page-family-tree__branches {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding-top: 22px;
}

.memory-page-family-tree__branches::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: var(--app-border);
}

.memory-page-family-tree__node {
  position: relative;
  min-width: 0;
}

.memory-page-family-tree__node-line {
  position: absolute;
  top: -22px;
  left: 50%;
  width: 1px;
  height: 22px;
  background: var(--app-border);
}

.memory-page-family-tree__node-card {
  min-height: 100%;
  display: block;
  text-align: center;
  text-decoration: none;
  color: inherit;
  padding: 0.85rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.memory-page-family-tree__node-card:hover,
.memory-page-family-tree__node-card:focus-visible {
  color: inherit;
  border-color: var(--app-primary);
  box-shadow: 0 8px 22px rgba(31, 91, 149, 0.1);
}

.memory-page-relations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.memory-page-relations-actions {
  display: flex;
  justify-content: flex-start;
}

.memory-page-relation-card-wrap {
  min-width: 0;
}

.memory-page-relation-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: stretch;
  background: #f8fbff;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  overflow: hidden;
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.memory-page-relation-card:hover {
  border-color: var(--app-primary);
  box-shadow: 0 4px 16px rgba(31, 91, 149, 0.12);
  color: inherit;
}

.memory-page-relation-card__media:focus-visible,
.memory-page-relation-card__link:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.memory-page-relation-card__media {
  display: block;
  padding: 0.55rem;
  background: var(--memory-surface-soft);
  border-right: 1px solid var(--app-border);
}

.memory-page-relation-card__photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  background: #fff;
}

.memory-page-relation-card__photo-placeholder {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #fff;
}

.memory-page-relation-card__photo-placeholder img {
  width: 40px;
  opacity: 0.5;
}

.memory-page-relation-card__body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 0.85rem 0.9rem;
}

.memory-page-relation-card__relation {
  font-size: 0.8rem;
  color: var(--app-muted);
  margin-bottom: 0.25rem;
}

.memory-page-relation-card__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--app-text);
  margin: 0;
  overflow-wrap: anywhere;
}

.memory-page-relation-card__years {
  font-size: 0.85rem;
  color: var(--app-muted);
  margin-top: 0.2rem;
  margin-bottom: 0.65rem;
}

.memory-page-relation-card__link {
  align-self: flex-start;
}

/* Отдельная страница семейного дерева */
.memory-tree-page {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto 2rem;
}

.memory-tree-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-soft);
  margin-bottom: 1rem;
}

.memory-tree-header__label {
  color: var(--app-muted);
  font-size: 0.9rem;
}

.memory-tree-header__title {
  color: var(--app-text);
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  line-height: 1.2;
}

.memory-tree-header__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.memory-tree-edit-panel {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background: var(--app-surface);
  box-shadow: var(--app-shadow-soft);
  margin-bottom: 1rem;
}

.memory-tree-edit-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.memory-tree-edit-panel__title {
  color: var(--app-text);
  font-size: 1rem;
  font-weight: 700;
}

.memory-tree-toolbar {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.memory-tree-viewport {
  position: relative;
  height: min(72vh, 760px);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  background:
    linear-gradient(rgba(31, 91, 149, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 91, 149, 0.05) 1px, transparent 1px),
    #f8fbff;
  background-size: 36px 36px;
  cursor: grab;
  touch-action: none;
}

.memory-tree-viewport.is-dragging {
  cursor: grabbing;
}

.memory-tree-empty {
  position: absolute;
  right: 1rem;
  top: 1rem;
  z-index: 2;
  width: min(320px, calc(100% - 2rem));
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--app-shadow-soft);
  cursor: default;
}

.memory-tree-empty__title {
  color: var(--app-text);
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.memory-tree-empty__text {
  color: var(--app-muted);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.memory-tree-board {
  position: absolute;
  left: 0;
  top: 0;
  width: 2400px;
  height: 1600px;
  transform-origin: 0 0;
}

.memory-tree-edges,
.memory-tree-nodes {
  position: absolute;
  inset: 0;
  width: 2400px;
  height: 1600px;
}

.memory-tree-edge {
  fill: none;
  stroke: rgba(31, 91, 149, 0.36);
  stroke-width: 2;
}

.memory-tree-edge-label {
  fill: var(--app-muted);
  font-size: 18px;
  font-weight: 600;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
}

.memory-tree-card {
  position: absolute;
  display: flex;
  width: 320px;
  min-height: 188px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
  box-shadow: 0 14px 34px rgba(15, 32, 58, 0.12);
  overflow: hidden;
}

.memory-tree-card--root {
  border-color: var(--app-primary);
  box-shadow: 0 18px 42px rgba(31, 91, 149, 0.18);
}

.memory-tree-card__media {
  flex: 0 0 126px;
  padding: 0.7rem;
  background: linear-gradient(180deg, #edf2fb, #f8fbff);
  border-right: 1px solid var(--app-border);
}

.memory-tree-card__photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: contain;
  object-position: center;
  display: block;
  border-radius: 10px;
  background: #fff;
}

.memory-tree-card__body {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  padding: 0.85rem;
}

.memory-tree-card__relation {
  color: var(--app-muted);
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.memory-tree-card__name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.35rem;
  color: var(--app-text);
  overflow-wrap: anywhere;
}

.memory-tree-card__years {
  color: var(--app-muted);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.memory-tree-card__body .btn {
  align-self: flex-start;
}

@media (max-width: 768px) {
  .memory-tree-page {
    width: min(100% - 1rem, 1280px);
  }

  .memory-tree-header {
    flex-direction: column;
  }

  .memory-tree-header__actions,
  .memory-tree-header__actions .btn {
    width: 100%;
  }

  .memory-tree-header__actions,
  .memory-tree-edit-panel__header {
    flex-direction: column;
  }

  .memory-tree-toolbar {
    justify-content: flex-start;
  }

  .memory-tree-viewport {
    min-height: 440px;
  }
}

.memory-page-gallery-modal .btn-close {
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.15));
}

.memory-page-qr-code {
  width: min(250px, 100%);
  border-radius: 12px;
  border: 1px solid var(--app-border);
}

.memory-page-qr-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.memory-page-copy-link {
  display: grid;
  gap: 0.75rem;
}

.memory-page-copy-link__input {
  overflow: hidden;
  text-overflow: ellipsis;
}

.memory-page-copy-link__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.memory-page-copy-link__actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
}

.memory-page-print-preview {
  display: inline-grid;
  gap: 0.35rem;
  width: min(100%, 190px);
  color: var(--app-text);
  text-decoration: none;
}

.memory-page-print-preview:hover,
.memory-page-print-preview:focus-visible {
  color: var(--app-primary);
}

.memory-page-print-preview:focus-visible {
  outline: 3px solid var(--app-primary-soft);
  outline-offset: 3px;
}

.memory-page-print-preview__sheet {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  aspect-ratio: 1 / 1.32;
  padding: 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface);
  box-shadow: var(--app-shadow-soft);
  text-align: center;
}

.memory-page-print-preview__brand {
  color: var(--app-primary);
  font-size: 0.68rem;
  font-weight: 700;
}

.memory-page-print-preview__title {
  color: var(--app-text);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.memory-page-print-preview__qr {
  width: 74px;
  height: 74px;
  padding: 0.25rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
}

.memory-page-print-preview__url {
  max-width: 100%;
  color: var(--app-muted);
  font-size: 0.58rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-page-print-preview__caption {
  color: var(--app-muted);
  font-size: 0.82rem;
}

.memory-page-share {
  margin-top: 1rem;
}

.share-dropdown {
  position: relative;
  display: inline-block;
}

.share-dropdown .share-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.125rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--app-primary);
  background: var(--app-surface);
  border: 2px solid var(--app-primary);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.share-dropdown .share-trigger:hover,
.share-dropdown .share-trigger:focus-visible {
  background: var(--app-primary-soft);
  color: var(--app-primary);
  border-color: var(--app-primary);
}

.share-dropdown .share-trigger:active {
  background: var(--app-primary);
  color: #fff;
}

.share-content {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--app-surface);
  border-radius: 12px;
  border: 1px solid var(--app-border);
  box-shadow: var(--app-shadow-soft);
  min-width: 200px;
  padding: 0.5rem 0;
}

.share-content__title {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.share-item,
.share-content .share-link-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.65rem 1rem;
  margin: 0;
  gap: 0.65rem;
  font-size: 0.95rem;
  color: var(--app-text);
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease;
  text-align: left;
}

.share-content .share-link-btn {
  font-family: inherit;
}

.share-item:hover,
.share-item:focus-visible,
.share-content .share-link-btn:hover,
.share-content .share-link-btn:focus-visible {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.share-item:active,
.share-content .share-link-btn:active {
  background: color-mix(in srgb, var(--app-primary-soft) 80%, var(--app-primary));
}

.share-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.share-content .share-link-btn .share-icon.fa-fw {
  width: 24px;
}

.share-icon--max {
  color: #00a86b;
  font-size: 1.05rem;
}

@media (max-width: 992px) {
  .memory-page-grid--final {
    grid-template-columns: 1fr;
  }

  .memory-page-hero__photo,
  .memory-page-hero__photo--placeholder {
    width: 220px;
    height: auto;
  }

  .memory-page-hero__photo--placeholder img {
    width: 140px;
    height: 140px;
  }
}

@media (max-width: 768px) {
  .memory-page-relations-grid {
    grid-template-columns: 1fr;
  }

  .memory-page-create-wrap {
    padding: 1.25rem 0 2rem;
  }

  .memory-page-create__card {
    padding: 1.25rem 1rem;
  }

  .memory-page-create__title {
    font-size: 1.35rem;
  }

  .memory-page-shell {
    width: calc(100% - 0.8rem);
  }

  .memory-page-hero__photo,
  .memory-page-hero__photo--placeholder {
    width: 170px;
    height: auto;
  }

  .memory-page-hero__photo--placeholder img {
    width: 110px;
    height: 110px;
  }

  .memory-page-toc {
    gap: 0.4rem 0.55rem;
  }

  .memory-page-toc__link {
    font-size: 0.86rem;
  }

  .memory-page-toc__title {
    font-size: 0.9rem;
  }

  .memory-page-info-list {
    grid-template-columns: 1fr;
  }

  .memory-page-gallery-modal .carousel-item img {
    max-height: min(60vh, 460px);
  }

  .memory-page-promo {
    padding: 1.8rem 1rem;
  }

  .memory-page-promo__text {
    font-size: 0.98rem;
  }

  .memory-page-promo__button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* Режим редактирования inline */
.memory-page-edit-banner {
  background: linear-gradient(180deg, var(--memory-accent-soft) 0%, #f6fbf7 100%);
  border: 1px solid rgba(79, 107, 90, 0.24);
  border-radius: var(--memory-radius-lg);
  padding: 0.9rem 1rem;
  box-shadow: var(--memory-shadow-soft);
}

.memory-page-autosave-hint {
  font-weight: 400;
  color: var(--memory-muted) !important;
}

.memory-page-hint {
  color: var(--memory-muted);
}

.memory-page-lock-note {
  background: linear-gradient(180deg, var(--memory-brass-soft) 0%, #fffaf1 100%);
  border: 1px solid rgba(184, 155, 94, 0.35);
  border-radius: var(--memory-radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--memory-shadow-soft);
}

.memory-page-lock-note__title {
  margin: 0 0 0.35rem;
  color: var(--memory-text);
  font-family: "PT Serif", "Lora", "Georgia", serif;
  font-size: 1.15rem;
}

.memory-page-lock-note__text {
  margin: 0;
  color: var(--memory-muted);
  line-height: 1.55;
}

.memory-page-lock-note__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
}

.memory-page-lock-note__list li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.75rem;
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid rgba(184, 155, 94, 0.26);
  border-radius: 999px;
  color: #6b5326;
  font-size: 0.9rem;
}

.memory-page-hero--edit .memory-page-hero__media--edit {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.memory-page-hero--edit .memory-page-hero__photo-wrap--clickable {
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.memory-page-hero--edit .memory-page-hero__input {
  text-align: center;
  font-weight: 600;
  border-color: var(--app-border);
}

.memory-page-hero--edit .memory-page-hero__input:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 2px var(--app-primary-soft);
}

.memory-page-hero--edit .memory-page-hero__epitaph {
  font-size: 0.95rem;
  border-color: var(--app-border);
  resize: vertical;
}

/* Формы редактирования — единый стиль с сайтом (как memory-page-create, app-form) */
.memory-page-edit-form .form-control,
.memory-page-edit-form .form-select {
  border: 1px solid var(--memory-border);
  border-radius: 10px;
  background: var(--memory-surface);
  color: var(--memory-text);
  padding: 0.5rem 0.85rem;
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.memory-page-edit-form .form-control::placeholder {
  color: var(--memory-muted);
}

.memory-page-edit-form .form-control:hover,
.memory-page-edit-form .form-select:hover {
  border-color: rgba(184, 155, 94, 0.45);
}

.memory-page-edit-form .form-control:focus,
.memory-page-edit-form .form-select:focus {
  border-color: var(--memory-accent);
  box-shadow: 0 0 0 3px rgba(79, 107, 90, 0.14);
  outline: none;
}

.memory-page-edit-form .form-control:focus-visible,
.memory-page-edit-form .form-select:focus-visible {
  outline: none;
}

.memory-page-biography-notebook {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 1fr);
  gap: 0.85rem;
}

.memory-page-biography-notebook__pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.memory-page-biography-hint {
  padding-left: 0.1rem;
  color: var(--memory-muted) !important;
}

.memory-page-biography-helper {
  border: 1px solid var(--app-primary);
  border-radius: 12px;
  background: linear-gradient(160deg, #ffffff, #eef6ff);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 8px 22px rgba(31, 91, 149, 0.12);
  position: relative;
}

.memory-page-biography-helper::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
  background: var(--app-primary);
}

.memory-page-biography-helper__header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: rgba(31, 91, 149, 0.08);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.memory-page-biography-helper__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--app-text);
}

.memory-page-biography-helper__output {
  min-height: 170px;
  line-height: 1.5;
  background: #fff;
  border-color: rgba(31, 91, 149, 0.35);
}

.memory-page-biography-helper__status {
  min-height: 1.2rem;
}

.memory-page-biography-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.memory-page-biography-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

.memory-page-biography-toolbar__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: #fff;
  color: var(--app-text);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.memory-page-biography-toolbar__button:hover,
.memory-page-biography-toolbar__button:focus-visible {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
  color: var(--app-primary);
  outline: none;
}

.memory-page-biography-toolbar__hint {
  width: 100%;
  margin: 0;
  color: var(--memory-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.memory-page-biography-editor__surface {
  border-radius: 12px;
  overflow: hidden;
  min-height: 320px;
  height: auto;
  overflow-y: hidden;
  resize: none;
}

.voice-input-textarea-wrap {
  position: relative;
}

.voice-input-textarea-wrap textarea.form-control {
  padding-bottom: 3.25rem;
}

.voice-input-trigger,
.memory-page-voice-button {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 2;
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(31, 91, 149, 0.28);
  border-radius: 999px;
  color: var(--app-primary);
  background: var(--app-surface);
  box-shadow: 0 8px 18px rgba(15, 32, 58, 0.1);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.voice-input-trigger:hover,
.voice-input-trigger:focus-visible,
.memory-page-voice-button:hover,
.memory-page-voice-button:focus-visible {
  border-color: var(--app-primary);
  background: var(--app-primary);
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

#memory-page-biography-toolbar.ql-snow {
  border-color: var(--app-border);
  background: #fafbfd;
}

.memory-page-biography-editor__surface.ql-container.ql-snow {
  border-color: var(--app-border);
  font-size: 1rem;
  color: var(--app-text);
  background: var(--app-surface);
  border-top: none;
  border-radius: 0 0 12px 12px;
}

.memory-page-biography-editor__surface .ql-editor {
  min-height: 340px;
  padding: 0.75rem 0.85rem;
  line-height: 1.55;
  font-family: inherit;
}

.memory-page-biography-editor__surface .ql-editor:focus {
  outline: none;
}

.memory-page-edit-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.memory-page-edit-card__intro {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(232, 241, 251, 0.72), rgba(255, 255, 255, 0.98));
}

.memory-page-edit-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-text);
}

.memory-page-edit-card__text {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.55;
}

.memory-page-map-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.memory-page-map-search {
  flex: 1 1 240px;
  min-width: 220px;
}

.memory-page-map-note,
.memory-page-map-status {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.memory-page-map-note {
  color: var(--memory-muted);
}

.memory-page-map-status {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(31, 91, 149, 0.08);
  color: var(--app-primary);
}

.memory-page-map-status.is-error {
  background: rgba(186, 59, 59, 0.1);
  color: #9b2c2c;
}

.memory-page-map {
  width: 100%;
  min-height: 320px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--app-border);
  background:
    radial-gradient(circle at top left, rgba(31, 91, 149, 0.08), transparent 40%),
    linear-gradient(180deg, #f9fbfe, #eef3f9);
}

.memory-page-map--edit {
  min-height: 380px;
}

.memory-page-map--compact {
  min-height: 280px;
}

/* AI-ассистент биографии (модальное окно) — чат */
.biography-assistant-modal-body {
  min-height: 520px;
  padding: 1.25rem 1.5rem;
}

.biography-assistant-chat {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
  height: 100%;
}

.biography-assistant-chat__messages {
  flex: 1;
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  background: var(--app-surface);
  border-radius: 12px;
  border: 1px solid var(--app-border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.biography-assistant-chat__empty {
  color: var(--app-muted);
  padding: 1rem;
  text-align: center;
}

.biography-assistant-msg {
  margin-bottom: 0.75rem;
}

.biography-assistant-msg--user {
  text-align: right;
}

.biography-assistant-msg--user .biography-assistant-msg__content {
  display: inline-block;
  max-width: 85%;
  padding: 0.4rem 0.75rem;
  background: var(--app-primary);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
  font-size: 0.9rem;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content {
  display: inline-block;
  max-width: 95%;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 12px 12px 12px 4px;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: left;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content p {
  margin: 0 0 0.5rem;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content p:last-child {
  margin-bottom: 0;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content ul,
.biography-assistant-msg--assistant .biography-assistant-msg__content ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content ul:last-child,
.biography-assistant-msg--assistant .biography-assistant-msg__content ol:last-child {
  margin-bottom: 0;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content li {
  margin-bottom: 0.25rem;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content strong {
  font-weight: 600;
}

.biography-assistant-msg--assistant .biography-assistant-msg__content {
  display: block;
  max-width: 100%;
}

.biography-assistant-msg__content--loading {
  display: inline-flex !important;
  align-items: center;
  gap: 0.55rem;
  color: var(--app-muted);
}

.biography-assistant-msg__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--app-border);
}

.biography-assistant-chat__hint {
  margin: 0;
  line-height: 1.4;
}

.biography-assistant-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.biography-assistant-chat__input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.biography-assistant-chat__input textarea {
  width: 100%;
  min-height: 6.5rem;
  resize: none;
}

@media (max-width: 992px) {
  .biography-assistant-modal-body {
    padding: 0.85rem 1rem;
    min-height: 460px;
  }

  .biography-assistant-chat__messages {
    min-height: 220px;
    max-height: 320px;
  }
}

/* Голосовой ввод текстовых полей */
.voice-input-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.voice-input-trigger {
  flex-shrink: 0;
}

.voice-text-recorder {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-primary-soft);
}

.voice-text-recorder__mic {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--app-primary);
  box-shadow: 0 0 0 0 rgba(31, 91, 149, 0.22);
}

.voice-text-recorder__mic.is-recording {
  animation: voicePulse 1.3s ease-out infinite;
}

.voice-text-recorder__title {
  font-weight: 600;
  color: var(--app-text);
}

.voice-text-recorder__hint {
  color: var(--app-muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.voice-text-transcript {
  min-height: 9rem;
  resize: vertical;
}

@keyframes voicePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 91, 149, 0.28);
  }
  70% {
    box-shadow: 0 0 0 13px rgba(31, 91, 149, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(31, 91, 149, 0);
  }
}

@media (max-width: 768px) {
  .voice-text-recorder {
    align-items: flex-start;
  }

  .voice-input-label-row {
    align-items: flex-start;
  }
}

.memory-page-biography-editor__surface .ql-editor h2,
.memory-page-biography-editor__surface .ql-editor h3,
.memory-page-biography-editor__surface .ql-editor h4 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.memory-page-biography-editor__surface .ql-editor p {
  margin-bottom: 0.75rem;
}

.memory-page-biography-editor__surface .ql-editor ul,
.memory-page-biography-editor__surface .ql-editor ol {
  padding-left: 1.2rem;
  margin-bottom: 0.75rem;
}

.memory-page-biography-editor__surface .ql-editor blockquote {
  margin: 0 0 0.9rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--app-primary);
  background: #f7faff;
}

.memory-page-biography-preview-card {
  border: 1px solid var(--app-border);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(160deg, #fff, #f4f8ff);
  min-height: 260px;
  display: flex;
  flex-direction: column;
}

.memory-page-biography-preview-card__header {
  padding: 0.5rem 0.75rem;
  background: #f0f4fc;
  border-bottom: 1px solid var(--app-border);
}

.memory-page-biography-preview-card__title {
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  color: var(--app-text);
}

.memory-page-biography-preview-card__content {
  padding: 0.9rem;
  color: var(--app-text);
  line-height: 1.56;
  overflow: auto;
  min-height: 240px;
  background: transparent;
}

.memory-page-biography-preview {
  font-family: "Georgia", "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.memory-page-biography-preview h2,
.memory-page-biography-preview h3 {
  margin-top: 0;
}

.memory-page-biography-preview blockquote,
.memory-page-quote-card {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border-left: 3px solid var(--app-primary);
  background: #f8faff;
}

.memory-page-quote-card {
  box-shadow: 0 2px 10px rgba(31, 91, 149, 0.08);
}

.memory-page-biography-blocks {
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 120px;
  max-height: 360px;
}

.memory-page-biography-blocks__header {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.65rem 0;
}

.memory-page-biography-blocks__title {
  font-size: 0.82rem;
  font-weight: 700;
}

.memory-page-biography-blocks__list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0 0.65rem 0.65rem;
  overflow: auto;
}

.memory-page-biography-blocks__item {
  width: 100%;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: #fff;
  color: var(--app-text);
  padding: 0.45rem 0.6rem;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.35;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: grab;
}

.memory-page-biography-blocks__item:hover,
.memory-page-biography-blocks__item:focus-visible,
.memory-page-biography-blocks__item.is-dragging {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}

.memory-page-editor {
  min-height: 260px;
  padding: 0.5rem 0.85rem;
  line-height: 1.5;
  overflow-wrap: break-word;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 1rem;
  font-family: inherit;
  background: var(--app-surface);
  border-radius: 12px;
  border-color: var(--app-border);
}

.memory-page-editor:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}

.memory-page-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--app-muted);
  pointer-events: none;
}

@media (max-width: 992px) {
  .memory-page-biography-notebook {
    grid-template-columns: 1fr;
  }

  .memory-page-biography-notebook__pane--preview {
    order: 2;
  }

  .memory-page-biography-preview-card {
    min-height: 220px;
  }

}

.memory-page-editor h2,
.memory-page-editor h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.7rem;
  line-height: 1.3;
}

.memory-page-editor p {
  margin: 0 0 0.85rem;
}

.memory-page-editor ul,
.memory-page-editor ol {
  padding-left: 1.25rem;
  margin-bottom: 0.85rem;
}

.memory-page-editor blockquote {
  margin: 0 0 0.85rem;
  padding: 0.5rem 0.8rem;
  border-left: 3px solid var(--app-primary);
  color: var(--app-text);
  background: #f7faff;
}

.memory-page-note-toolbar {
  position: sticky;
  top: 0.2rem;
  z-index: 2;
  padding: 0.5rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: #fafbfd;
}

.memory-page-note-toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.memory-page-note-toolbar__divider {
  width: 1px;
  height: 24px;
  background: var(--app-border);
}

.memory-page-note-toolbar__select {
  min-width: 180px;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.memory-page-edit-form textarea.form-control {
  resize: vertical;
  min-height: 2.5rem;
}

.memory-page-edit-form .form-label,
.memory-page-edit-form label.form-label {
  color: var(--app-text);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.memory-page-edit-form .form-control-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 8px;
}

.memory-page-edit-form .form-control-lg {
  padding: 0.6rem 1rem;
  font-size: 1.1rem;
  border-radius: 10px;
}

/* Блоки полей в формах редактирования */
.memory-page-edit-field {
  margin-bottom: 1rem;
}

.memory-page-edit-field:last-child {
  margin-bottom: 0;
}

/* Сетка краткой информации — вертикальный список полей */
.memory-page-info-list--edit {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.memory-page-info-list--edit .memory-page-edit-field,
.memory-page-info-list--edit > div {
  margin-bottom: 0;
}

.memory-page-info-list--edit .form-label {
  color: var(--app-text);
  font-weight: 600;
  font-size: 0.9rem;
}

/* Hero форма: ФИО и даты */
.memory-page-hero--edit .form-control,
.memory-page-hero--edit .memory-page-hero__input,
.memory-page-hero--edit .memory-page-hero__epitaph {
  border: 1px solid var(--memory-border);
  border-radius: 10px;
  background: var(--memory-surface);
  color: var(--memory-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.memory-page-hero--edit .form-control:hover,
.memory-page-hero--edit .memory-page-hero__input:hover,
.memory-page-hero--edit .memory-page-hero__epitaph:hover {
  border-color: rgba(184, 155, 94, 0.45);
}

.memory-page-hero--edit .form-control:focus,
.memory-page-hero--edit .memory-page-hero__input:focus,
.memory-page-hero--edit .memory-page-hero__epitaph:focus {
  border-color: var(--memory-accent);
  box-shadow: 0 0 0 3px rgba(79, 107, 90, 0.14);
  outline: none;
}

.memory-page-hero--edit .memory-page-hero__epitaph {
  resize: vertical;
  font-size: 0.95rem;
}

.memory-page-hero--edit .memory-page-hero__input {
  text-align: center;
  font-weight: 600;
}

.memory-page-hero--edit .form-label {
  color: var(--app-text);
  font-weight: 600;
  font-size: 0.9rem;
}

/* Hero photo: клик по области для загрузки */
.memory-page-hero__photo-wrap--clickable {
  cursor: pointer;
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  display: inline-block;
}

.memory-page-hero__photo-wrap--clickable .memory-page-hero__photo,
.memory-page-hero__photo-wrap--clickable .memory-page-hero__photo--placeholder {
  display: block;
}

.memory-page-hero__photo-wrap--clickable:hover .memory-page-hero__photo-hint {
  opacity: 1;
}

.memory-page-hero__photo-wrap--clickable:hover .memory-page-hero__photo,
.memory-page-hero__photo-wrap--clickable:hover .memory-page-hero__photo--placeholder {
  opacity: 0.92;
}

.memory-page-hero__photo-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.memory-page-hero__photo-wrap--loading {
  pointer-events: none;
  opacity: 0.75;
}

.memory-page-hero__photo-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(220, 53, 69, 0.9);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.memory-page-hero__photo-delete-btn:hover {
  background: #dc3545;
  transform: scale(1.08);
}

.memory-page-hero__photo-delete-btn:focus-visible {
  outline: 2px solid #dc3545;
  outline-offset: 2px;
}

.memory-page-hero__photo-delete-btn i {
  font-size: 0.9rem;
}

.memory-page-hero__ai-photo-btn {
  margin-top: 0.75rem;
}

.hero-photo-ai-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: stretch;
}

.hero-photo-ai-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hero-photo-ai-panel__header {
  margin-bottom: 0.5rem;
  color: var(--app-text);
  font-weight: 700;
}

.hero-photo-ai-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 320px;
  height: min(62vh, 560px);
  aspect-ratio: 3 / 4;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-bg);
  overflow: hidden;
}

.hero-photo-ai-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 12px;
  object-fit: contain;
  background: var(--app-surface);
}

.hero-photo-ai-empty {
  display: inline-flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
  justify-content: center;
  max-width: 280px;
  color: var(--app-muted);
  text-align: center;
  line-height: 1.45;
}

.hero-photo-ai-empty i {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
  font-size: 1.1rem;
}

.hero-photo-ai-loading {
  display: inline-flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
  justify-content: center;
  color: var(--app-muted);
  text-align: center;
}

.hero-photo-ai-description {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-surface);
}

.hero-photo-ai-description h6 {
  margin: 0 0 0.35rem;
  color: var(--app-text);
  font-weight: 700;
}

.hero-photo-ai-description p {
  color: var(--app-muted);
  line-height: 1.6;
}

.hero-photo-ai-status {
  min-height: 1.25rem;
  margin-top: 0.75rem;
}

.hero-photo-ai-note {
  margin-top: 1rem;
}

.hero-photo-ai-note .form-label {
  color: var(--app-text);
  font-weight: 700;
}

.hero-photo-ai-note .form-control {
  resize: vertical;
}

.hero-photo-ai-footer {
  justify-content: center;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .hero-photo-ai-grid {
    grid-template-columns: 1fr;
  }

  .hero-photo-ai-preview {
    aspect-ratio: 3 / 4;
    min-height: 0;
    height: auto;
  }

  .hero-photo-ai-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-photo-ai-footer .btn {
    width: 100%;
  }
}

.memory-page-settings-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.memory-page-settings-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 1.25rem;
  align-items: stretch;
  padding: 1.25rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-bg);
}

.memory-page-settings-hero__eyebrow {
  margin-bottom: 0.4rem;
  color: var(--app-primary);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.memory-page-settings-hero__title {
  margin: 0 0 0.5rem;
  color: var(--app-text);
  font-size: 1.35rem;
  font-weight: 800;
}

.memory-page-settings-hero__text {
  max-width: 720px;
  margin: 0;
  color: var(--app-muted);
  line-height: 1.6;
}

.memory-page-settings-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.memory-page-settings-progress {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
}

.memory-page-settings-progress__value {
  color: var(--app-text);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.memory-page-settings-progress__label,
.memory-page-settings-progress__meta {
  color: var(--app-muted);
  font-size: 0.88rem;
}

.memory-page-settings-progress__bar {
  height: 8px;
  margin: 0.75rem 0 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--app-border);
}

.memory-page-settings-progress__bar span {
  display: block;
  width: var(--settings-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--app-primary);
}

.memory-page-settings-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.memory-page-settings-stat {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
}

.memory-page-settings-stat__label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--app-muted);
  font-size: 0.82rem;
}

.memory-page-settings-stat strong {
  display: block;
  color: var(--app-text);
  font-size: 1.35rem;
  line-height: 1.2;
}

.memory-page-settings-stat a {
  display: inline-block;
  margin-top: 0.45rem;
  color: var(--app-primary);
  font-size: 0.88rem;
  text-decoration: none;
}

.memory-page-settings-stat a:hover,
.memory-page-settings-stat a:focus-visible {
  text-decoration: underline;
}

.memory-page-settings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.memory-page-settings-action {
  display: flex;
  gap: 0.85rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  color: var(--app-text);
  text-decoration: none;
  background: var(--app-surface);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.memory-page-settings-action:hover,
.memory-page-settings-action:focus-visible {
  border-color: var(--app-primary);
  color: var(--app-text);
  background: var(--app-primary-soft);
  transform: translateY(-1px);
}

.memory-page-settings-action--primary {
  border-color: var(--app-primary);
}

.memory-page-settings-action__icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--app-primary);
  background: var(--app-primary-soft);
}

.memory-page-settings-action strong,
.memory-page-settings-action small {
  display: block;
}

.memory-page-settings-action strong {
  margin-bottom: 0.25rem;
  font-weight: 800;
}

.memory-page-settings-action small {
  color: var(--app-muted);
  line-height: 1.45;
}

.memory-page-settings-checklist,
.memory-page-settings-next {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-surface);
}

.memory-page-settings-checklist__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.memory-page-settings-checkitem {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  color: var(--app-text);
  text-decoration: none;
  background: var(--app-bg);
}

.memory-page-settings-checkitem:hover,
.memory-page-settings-checkitem:focus-visible {
  color: var(--app-primary);
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}

.memory-page-settings-checkitem__mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--app-primary);
  background: var(--app-primary-soft);
  font-size: 0.8rem;
}

.memory-page-settings-checkitem.is-filled .memory-page-settings-checkitem__mark {
  color: #ffffff;
  background: var(--app-primary);
}

.memory-page-settings-next h5 {
  margin: 0 0 0.4rem;
  color: var(--app-text);
  font-weight: 800;
}

.memory-page-settings-next p {
  color: var(--app-muted);
}

.memory-page-settings-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.memory-page-settings-tags span {
  display: inline-flex;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  color: var(--app-primary);
  background: var(--app-primary-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

@media (max-width: 992px) {
  .memory-page-settings-hero,
  .memory-page-settings-status-grid,
  .memory-page-settings-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .memory-page-settings-hero {
    padding: 1rem;
  }

  .memory-page-settings-checklist__grid {
    grid-template-columns: 1fr;
  }
}

.memory-page-privacy-form {
  max-width: 920px;
}

.memory-page-privacy-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.memory-page-privacy-choice {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 132px;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  color: var(--app-text);
  background: var(--app-surface);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.memory-page-privacy-choice:hover,
.memory-page-privacy-choice:focus-within {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
}

.memory-page-privacy-choice.is-active {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(31, 91, 149, 0.12);
}

.memory-page-privacy-choice__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.memory-page-privacy-choice__body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.memory-page-privacy-choice__title {
  color: var(--app-text);
  font-weight: 800;
}

.memory-page-privacy-choice__text {
  color: var(--app-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.memory-page-access-code-panel {
  max-width: 420px;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-bg);
}

@media (max-width: 992px) {
  .memory-page-privacy-choices {
    grid-template-columns: 1fr;
  }

.memory-page-privacy-choice {
  min-height: 0;
  }
}

.ai-biography-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ai-biography-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 1.25rem;
  align-items: stretch;
  padding: 1.25rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-bg);
}

.ai-biography-hero__eyebrow {
  margin-bottom: 0.4rem;
  color: var(--app-primary);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.ai-biography-hero__title {
  margin: 0 0 0.5rem;
  color: var(--app-text);
  font-size: 1.35rem;
  font-weight: 800;
}

.ai-biography-hero__text {
  max-width: 760px;
  margin: 0;
  color: var(--app-muted);
  line-height: 1.6;
}

.ai-biography-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.ai-biography-readiness {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
}

.ai-biography-readiness__value {
  color: var(--app-text);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.ai-biography-readiness__label,
.ai-biography-readiness__meta {
  color: var(--app-muted);
  font-size: 0.88rem;
}

.ai-biography-readiness__bar {
  height: 8px;
  margin: 0.75rem 0 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--app-border);
}

.ai-biography-readiness__bar span {
  display: block;
  width: var(--ai-biography-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--app-primary);
}

.ai-biography-sources {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.ai-biography-source {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
}

.ai-biography-source__label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--app-muted);
  font-size: 0.82rem;
}

.ai-biography-source strong {
  display: block;
  color: var(--app-text);
  font-size: 1.5rem;
  line-height: 1.15;
}

.ai-biography-source small {
  display: block;
  margin-top: 0.35rem;
  color: var(--app-muted);
  line-height: 1.4;
}

.ai-biography-generate,
.ai-biography-result {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-surface);
}

.ai-biography-generate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1rem;
  align-items: center;
}

.ai-biography-generate h3 {
  margin: 0 0 0.45rem;
  color: var(--app-text);
  font-size: 1.1rem;
  font-weight: 800;
}

.ai-biography-generate p {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.6;
}

.ai-biography-generate__meta {
  margin-top: 0.75rem;
  color: var(--app-muted);
  font-size: 0.92rem;
}

.ai-biography-generate__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
}

.ai-biography-status {
  min-height: 1.25rem;
}

.ai-biography-pending,
.ai-biography-empty {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 1rem;
  border-radius: 12px;
  color: var(--app-muted);
  background: var(--app-bg);
}

.ai-biography-pending strong,
.ai-biography-pending small,
.ai-biography-empty strong,
.ai-biography-empty span {
  display: block;
}

.ai-biography-pending strong,
.ai-biography-empty strong {
  color: var(--app-text);
}

.ai-biography-result__text {
  max-height: 70vh;
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-bg);
}

.ai-page-draft-review {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.ai-page-draft-card {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-bg);
}

.ai-page-draft-card__toggle {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.8rem;
  color: var(--app-text);
  font-weight: 800;
  cursor: pointer;
}

.ai-page-draft-card__toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--app-primary);
}

.ai-page-draft-card__compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.ai-page-draft-card__compare > div {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-surface);
}

.ai-page-draft-card__compare strong {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--app-text);
  font-size: 0.88rem;
}

.ai-page-draft-card__compare p {
  max-height: 240px;
  margin: 0;
  overflow: auto;
  color: var(--app-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.ai-page-draft-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.ai-page-draft-notes > div {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-bg);
}

.ai-page-draft-notes strong {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--app-text);
}

.ai-page-draft-notes ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--app-muted);
}

.ai-draft-confirm-sources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.ai-draft-confirm-sources > div {
  padding: 0.8rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-bg);
}

.ai-draft-confirm-sources strong,
.ai-draft-confirm-sources span {
  display: block;
}

.ai-draft-confirm-sources strong {
  color: var(--app-text);
  font-size: 1.25rem;
  line-height: 1.1;
}

.ai-draft-confirm-sources span {
  margin-top: 0.25rem;
  color: var(--app-muted);
  font-size: 0.86rem;
}

@media (max-width: 992px) {
  .ai-biography-hero,
  .ai-biography-generate,
  .ai-biography-sources,
  .ai-page-draft-card__compare,
  .ai-page-draft-notes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .ai-draft-confirm-sources {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .ai-biography-hero {
    padding: 1rem;
  }
}

/* Страница настроек/редактора: без сайдбара, кнопки и формы в стиле сайта */
.memory-page-editor-wrap .app-card,
.app-editor-content .app-card {
  padding: 1rem;
}

/* Кнопки редактора — в цветах дизайн-системы */
.memory-page-editor-wrap .btn-primary,
.memory-page-editor-wrap .btn-primary:hover,
.memory-page-editor-wrap .privacy-type-buttons .btn-primary,
.app-editor-content .btn-primary,
.app-editor-content .btn-primary:hover,
.app-editor-content .privacy-type-buttons .btn-primary {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
  color: #fff;
}

.memory-page-editor-wrap .btn-primary:hover,
.app-editor-content .btn-primary:hover {
  background-color: #1a4f7f;
  border-color: #1a4f7f;
}

.memory-page-editor-wrap .btn-outline-primary,
.app-editor-content .btn-outline-primary {
  border-color: var(--app-primary);
  color: var(--app-primary);
}

.memory-page-editor-wrap .btn-outline-primary:hover,
.app-editor-content .btn-outline-primary:hover {
  background-color: var(--app-primary-soft);
  border-color: var(--app-primary);
  color: var(--app-primary);
}

.memory-page-editor-wrap .btn-outline-secondary,
.app-editor-content .btn-outline-secondary {
  border-color: var(--app-border);
  color: var(--app-muted);
}

.memory-page-editor-wrap .btn-outline-secondary:hover,
.app-editor-content .btn-outline-secondary:hover {
  background-color: #f8fafc;
  border-color: #cfd8e6;
  color: var(--app-text);
}

.memory-page-editor-wrap .btn-outline-danger,
.app-editor-content .btn-outline-danger {
  border-color: #dc3545;
  color: #dc3545;
}

.memory-page-editor-wrap .btn-outline-danger:hover,
.app-editor-content .btn-outline-danger:hover {
  background-color: #fef2f2;
  border-color: #dc3545;
  color: #dc3545;
}

.memory-page-editor-wrap .btn-danger,
.app-editor-content .btn-danger {
  background-color: #dc3545;
  border-color: #dc3545;
}

.memory-page-editor-wrap .btn-danger:hover:not(:disabled),
.app-editor-content .btn-danger:hover:not(:disabled) {
  background-color: #bb2d3b;
  border-color: #bb2d3b;
}

/* Таблица редакторов — в стиле сайта */
.memory-page-editor-wrap .table,
.app-editor-content .table {
  color: var(--app-text);
}

.memory-page-editor-wrap .table tbody tr,
.app-editor-content .table tbody tr {
  border-bottom: 1px solid var(--app-border);
}

.memory-page-editor-wrap .table tbody tr:hover,
.app-editor-content .table tbody tr:hover {
  background-color: var(--app-primary-soft);
}

.memory-page-editor-wrap .table td,
.app-editor-content .table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.memory-page-editor-wrap .app-link.text-danger:hover,
.app-editor-content .app-link.text-danger:hover {
  color: #bb2d3b !important;
}

/* Модальное окно удаления — в стиле сайта */
.memory-page-editor-wrap .modal-content,
.app-editor-content .modal-content {
  border-radius: var(--app-radius-lg);
  border: 1px solid var(--app-border);
  box-shadow: var(--app-shadow-soft);
}

.memory-page-editor-wrap .modal-content .modal-title,
.app-editor-content .modal-content .modal-title {
  color: var(--app-text);
  font-weight: 600;
}

.memory-page-editor-wrap .modal-content .form-control,
.app-editor-content .modal-content .form-control {
  border-color: var(--app-border);
  border-radius: 10px;
}

.memory-page-editor-wrap .modal-content .form-control:focus,
.app-editor-content .modal-content .form-control:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px var(--app-primary-soft);
}

/* Кнопки редактора — крупнее, не btn-sm */
.memory-page-editor-wrap .btn-sm,
.app-editor-content .btn-sm {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 500;
}

/* Поле ввода email и кода доступа — ограниченная ширина, не на весь экран */
.memory-page-editor-wrap .memory-page-edit-form .row > .col-auto.flex-grow-1,
.app-editor-content .memory-page-edit-form .row > .col-auto.flex-grow-1 {
  flex-grow: 0;
  flex-basis: auto;
  max-width: 320px;
}

/* --- Promo alignment: public memory page and inline editor --- */
.memory-page-shell {
  width: min(980px, calc(100% - 1rem));
}

.memory-page-section {
  background:
    radial-gradient(circle at top right, rgba(184, 155, 94, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(247, 240, 229, 0.92));
  border-color: rgba(184, 155, 94, 0.24);
  box-shadow: 0 16px 34px rgba(75, 57, 35, 0.08);
}

.memory-page-section__header {
  border-bottom-color: rgba(184, 155, 94, 0.22);
}

.memory-page-toc {
  background: rgba(255, 253, 248, 0.92);
}

.memory-page-toc__link,
.memory-page-toc__lock {
  border-color: rgba(184, 155, 94, 0.24);
  background: rgba(255, 251, 244, 0.86);
  color: var(--memory-text);
}

.memory-page-toc__link:hover,
.memory-page-toc__link:focus-visible,
.memory-page-toc__link--filled {
  border-color: rgba(79, 107, 90, 0.34);
  background: var(--memory-accent-soft);
  color: var(--memory-accent-deep);
}

.memory-page-toc__link--empty,
.memory-page-toc__lock {
  color: var(--memory-muted);
}

.memory-page-hero {
  padding: clamp(1.35rem, 3vw, 2.1rem);
  background:
    radial-gradient(circle at 50% 0%, rgba(184, 155, 94, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(255, 249, 239, 0.98), rgba(255, 253, 248, 0.94) 58%, rgba(247, 240, 229, 0.72));
  border-color: rgba(184, 155, 94, 0.28);
}

.memory-page-hero__photo,
.memory-page-hero__photo--placeholder {
  width: clamp(170px, 30vw, 248px);
  aspect-ratio: 3 / 4;
  height: auto;
  border-radius: 24px;
  border-color: rgba(184, 155, 94, 0.32);
  box-shadow: 0 18px 42px rgba(75, 57, 35, 0.13);
}

.memory-page-hero__photo--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(184, 155, 94, 0.16), transparent 35%),
    linear-gradient(180deg, #f7efe3, #fffaf2);
  color: rgba(79, 107, 90, 0.68);
}

.memory-page-hero__photo--placeholder img {
  display: none;
}

.memory-page-hero__photo--placeholder i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54%;
  height: 54%;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid rgba(184, 155, 94, 0.22);
  font-size: clamp(3.2rem, 8vw, 5.25rem);
  line-height: 1;
}

.memory-page-hero__name,
.memory-page-section__title {
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  letter-spacing: 0;
}

.memory-page-info-list > li,
.memory-page-info-extra,
.memory-page-significant-date-row,
.memory-page-biography-preview-card,
.memory-page-biography-blocks,
.memory-page-editor,
.memory-page-note-toolbar {
  background: rgba(255, 253, 248, 0.9);
  border-color: rgba(184, 155, 94, 0.22);
}

.memory-page-photo-tile,
.memory-page-relation-card__photo {
  background: var(--memory-surface-soft);
}

.memory-page-gallery-drop,
.memory-page-gallery-drop--fullscreen {
  border-color: rgba(184, 155, 94, 0.42);
  background:
    radial-gradient(circle at top, rgba(184, 155, 94, 0.1), transparent 35%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(246, 239, 227, 0.84));
}

.memory-page-relation-card {
  background: rgba(255, 253, 248, 0.94);
  border-color: rgba(184, 155, 94, 0.22);
}

.memory-page-relation-card:hover,
.memory-page-relation-card:focus-within {
  border-color: rgba(79, 107, 90, 0.38);
  box-shadow: 0 12px 28px rgba(75, 57, 35, 0.1);
}

.memory-page-relation-card__photo-placeholder {
  background:
    radial-gradient(circle at center, rgba(184, 155, 94, 0.13), transparent 36%),
    linear-gradient(180deg, var(--memory-surface-soft), var(--memory-surface));
  border-bottom-color: rgba(184, 155, 94, 0.22);
}

.memory-page-biography-helper,
.memory-page-biography-toolbar,
#memory-page-biography-toolbar.ql-snow,
.memory-page-edit-card__intro,
.memory-page-biography-preview-card,
.memory-page-biography-preview-card__header,
.memory-page-biography-preview blockquote,
.memory-page-quote-card,
.memory-page-editor blockquote,
.memory-page-map,
.memory-page-map-status {
  background:
    radial-gradient(circle at top right, rgba(184, 155, 94, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(247, 240, 229, 0.86));
  border-color: rgba(184, 155, 94, 0.24);
  box-shadow: none;
}

.memory-page-biography-helper {
  border-color: rgba(79, 107, 90, 0.28);
  box-shadow: 0 12px 28px rgba(75, 57, 35, 0.08);
}

.memory-page-biography-helper__header {
  background: rgba(238, 243, 238, 0.78);
}

.memory-page-biography-helper__output,
.memory-page-biography-editor__surface.ql-container.ql-snow,
.memory-page-biography-blocks__item {
  background: var(--memory-surface);
  border-color: rgba(184, 155, 94, 0.24);
}

.memory-page-map-status {
  color: var(--memory-accent-deep);
}

.memory-page-editor-wrap .btn-primary:hover,
.app-editor-content .btn-primary:hover {
  background-color: var(--app-primary-hover);
  border-color: var(--app-primary-hover);
}

.memory-page-editor-wrap .btn-outline-secondary:hover,
.app-editor-content .btn-outline-secondary:hover {
  background-color: var(--memory-surface-soft);
  border-color: rgba(184, 155, 94, 0.34);
}

.memory-page-edit-banner,
.memory-page-lock-note {
  border: 1px solid rgba(184, 155, 94, 0.24);
  border-radius: var(--memory-radius-lg);
  background:
    radial-gradient(circle at top right, rgba(184, 155, 94, 0.1), transparent 28%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(247, 240, 229, 0.9));
  box-shadow: 0 14px 30px rgba(75, 57, 35, 0.07);
}

.memory-page-edit-banner {
  padding: 1rem;
}

.memory-page-edit-banner .badge.bg-primary {
  background-color: var(--memory-accent) !important;
  color: var(--memory-accent-contrast, #fff);
}

.memory-page-lock-note {
  padding: 1.1rem;
}

.memory-page-lock-note__list li {
  background: rgba(255, 253, 248, 0.78);
  border-color: rgba(184, 155, 94, 0.22);
}

@media (max-width: 575.98px) {
  .memory-page-shell {
    width: calc(100% - 0.75rem);
  }

  .memory-page-hero {
    padding: 1rem;
  }

  .memory-page-hero__photo,
  .memory-page-hero__photo--placeholder {
    width: min(68vw, 210px);
    height: auto;
    border-radius: 20px;
  }
}

/* --- Memory page layout v2: screenshots reference --- */
.memory-page-shell--public {
  box-sizing: border-box;
  width: 100vw;
  max-width: none;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.memory-page-shell--public *,
.memory-page-shell--public *::before,
.memory-page-shell--public *::after {
  box-sizing: border-box;
}

.memory-page-shell--public .memory-page-hero {
  display: grid;
  grid-template-columns: minmax(210px, 300px) minmax(0, 620px);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: clamp(340px, 38vw, 480px);
  margin: -1rem 0 0;
  padding: clamp(2rem, 5vw, 4rem) max(1rem, calc((100vw - var(--app-max-width)) / 2));
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0.2) 36%, rgba(247, 241, 232, 0.94) 100%),
    url("../img/memorypage-sky-bg.png") center top / cover no-repeat;
}

.memory-page-shell--public .memory-page-hero--with-facts {
  grid-template-columns: minmax(210px, 300px) minmax(0, 1fr) minmax(260px, 340px);
  justify-content: stretch;
}

.memory-page-shell--public .memory-page-hero__media {
  margin: 0;
}

.memory-page-shell--public .memory-page-hero__content {
  max-width: 620px;
  margin: 0;
  text-align: left;
}

.memory-page-shell--public .memory-page-hero__photo,
.memory-page-shell--public .memory-page-hero__photo--placeholder {
  width: clamp(210px, 22vw, 285px);
  aspect-ratio: 3 / 4;
  height: auto;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(54, 47, 35, 0.2);
}

.memory-page-shell--public .memory-page-hero__name {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
  color: #272722;
}

.memory-page-shell--public .memory-page-hero__meta {
  margin-top: 0.75rem;
  color: #4f4f49;
  font-size: 1.08rem;
}

.memory-page-shell--public .memory-page-actions {
  justify-content: flex-start;
  margin-top: 1.35rem;
}

.memory-page-hero__facts {
  display: grid;
  gap: 1.1rem;
  padding: 1.25rem;
  border: 1px solid rgba(184, 155, 94, 0.18);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 18px 42px rgba(75, 57, 35, 0.08);
  backdrop-filter: blur(10px);
}

.memory-page-hero-fact {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.memory-page-hero-fact__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(79, 107, 90, 0.1);
  color: var(--memory-accent-deep);
  font-size: 0.85rem;
}

.memory-page-hero-fact__label {
  margin: 0 0 0.22rem;
  color: var(--memory-text);
  font-size: 0.9rem;
  font-weight: 700;
}

.memory-page-hero-fact__value {
  margin: 0;
  color: var(--memory-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.memory-page-story-panel {
  box-sizing: border-box;
  width: min(var(--app-max-width), calc(100% - 2rem));
  margin: -2.2rem auto 0;
  padding: 1.5rem;
  position: relative;
  z-index: 2;
  border: 1px solid rgba(184, 155, 94, 0.14);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 46px rgba(75, 57, 35, 0.08);
}

.memory-page-story-panel .memory-page-toc {
  display: flex;
  align-items: center;
  gap: 0;
  margin: -1.5rem -1.5rem 1.25rem !important;
  padding: 0 1.5rem;
  overflow-x: auto;
  border-width: 0 0 1px;
  border-radius: 20px 20px 0 0;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: none;
}

.memory-page-story-panel .memory-page-toc__title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.memory-page-story-panel .memory-page-toc__link {
  min-height: 4rem;
  padding: 0.25rem 1.15rem;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #34342f;
  font-weight: 600;
  white-space: nowrap;
}

.memory-page-story-panel .memory-page-toc__link:hover,
.memory-page-story-panel .memory-page-toc__link:focus-visible,
.memory-page-story-panel .memory-page-toc__link:first-of-type {
  border-bottom-color: var(--memory-accent);
  background: transparent;
  color: var(--memory-accent-deep);
}

.memory-page-story-panel .memory-page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.memory-page-public-columns {
  --bs-gutter-y: 1rem;
}

.memory-page-story-panel .memory-page-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.8fr);
  gap: 1.25rem;
  align-items: start;
}

.memory-page-story-panel .memory-page-two-column:has(.memory-page-column--media:not(:has(.memory-page-section))) {
  grid-template-columns: 1fr;
}

.memory-page-story-panel .memory-page-column {
  display: grid;
  gap: 1.25rem;
  align-content: start;
}

.memory-page-story-panel .memory-page-column--media:not(:has(.memory-page-section)) {
  display: none;
}

.memory-page-story-panel .memory-page-grid--final {
  margin-top: 1.25rem !important;
}

.memory-page-story-panel .memory-page-section {
  height: auto;
  padding: clamp(1.15rem, 2vw, 1.45rem);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: none;
}

.memory-page-story-panel .memory-page-two-column .memory-page-section {
  height: auto;
}

.memory-page-story-panel .memory-page-section__header {
  margin-bottom: 1rem;
  padding-bottom: 0;
  border-bottom: 0;
}

.memory-page-story-panel .memory-page-section__title {
  font-size: 1.35rem;
  line-height: 1.15;
}

.memory-page-story-panel .memory-page-back-to-top {
  display: none;
}

.memory-page-story-panel .memory-page-info-list {
  grid-template-columns: 1fr;
}

.memory-page-story-panel .memory-page-info-list > li,
.memory-page-story-panel .memory-page-info-extra {
  background: transparent;
  border: 0;
  padding: 0;
}

.memory-page-story-panel .memory-page-info-list > li + li {
  margin-top: 0.75rem;
}

.memory-page-story-panel .memory-page-photo-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-height: none;
  gap: 0.8rem;
}

.memory-page-story-panel .memory-page-column--media .memory-page-photo-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.memory-page-story-panel .memory-page-photo-tile {
  border-radius: 10px;
  background: var(--memory-surface-soft);
}

.memory-page-story-panel .memory-page-photo-tile img {
  height: 118px;
}

.memory-page-story-panel .section-photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 160px));
  justify-content: start;
  max-height: none;
}

.memory-page-story-panel .section-photo-grid-edit {
  grid-template-columns: repeat(auto-fill, minmax(132px, 160px));
  justify-content: start;
}

.memory-page-story-panel .section-photo-tile {
  border-radius: 10px;
  background: var(--memory-surface-soft);
}

.memory-page-story-panel .section-photo-tile img {
  aspect-ratio: 4 / 3;
  height: auto;
}

.memory-page-story-panel .memory-page-column--media .memory-page-relations-grid {
  grid-template-columns: 1fr;
}

.memory-page-story-panel .memory-page-column--media .memory-page-relation-card {
  grid-template-columns: 96px minmax(0, 1fr);
}

.memory-page-story-panel .memory-page-map {
  min-height: 190px;
}

.memory-page-story-panel .memory-page-qr-code {
  width: min(220px, 70vw);
  height: auto;
}

.memory-page-story-panel #memory-significant-dates,
.memory-page-story-panel #memory-life-history,
.memory-page-story-panel #memory-sections,
.memory-page-story-panel #memory-personality,
.memory-page-story-panel #memory-relations {
  grid-column: 1 / -1;
}

.memory-page-story-panel #memory-significant-dates .memory-page-section,
.memory-page-story-panel #memory-life-history .memory-page-section {
  height: auto;
}

.memory-page-story-panel #memory-significant-dates .memory-page-significant-date-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.5rem;
  position: relative;
}

.memory-page-story-panel #memory-significant-dates .memory-page-significant-date-table--editable {
  display: flex;
  grid-template-columns: none;
  gap: 0.5rem;
}

.memory-page-story-panel #memory-significant-dates .memory-page-significant-date-row {
  position: relative;
  padding: 0.2rem 0 0.2rem 1.7rem;
  border: 0;
  background: transparent;
}

.memory-page-story-panel #memory-significant-dates .memory-page-significant-date-row--editable {
  padding: 0.75rem 1rem;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
}

.memory-page-story-panel #memory-significant-dates .memory-page-significant-date-row::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.65rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--memory-accent);
  box-shadow: 0 0 0 4px rgba(79, 107, 90, 0.12);
}

.memory-page-story-panel #memory-significant-dates .memory-page-significant-date-row--editable::before {
  content: none;
}

.memory-page-story-panel #memory-significant-dates .memory-page-significant-date-row__year {
  min-width: 0;
  margin-bottom: 0.25rem;
  color: var(--memory-text);
  font-size: 1rem;
}

.qr-plate-landing {
  display: grid;
  gap: 1.25rem;
}

.qr-plate-hero-section {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  gap: clamp(1.25rem, 4vw, 2.25rem);
  align-items: center;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--app-border);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(232, 241, 251, 0.85), rgba(255, 255, 255, 0.96) 42%),
    var(--app-surface);
}

.qr-plate-hero-section__content {
  display: grid;
  gap: 1rem;
}

.qr-plate-status {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(31, 91, 149, 0.18);
  border-radius: 999px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
  font-size: 0.82rem;
  font-weight: 700;
}

.qr-plate-hero-section__title {
  max-width: 12em;
  margin: 0;
  color: var(--app-text);
  font-size: clamp(2rem, 5vw, 3.45rem);
  line-height: 1.02;
}

.qr-plate-hero-section__lead {
  max-width: 620px;
  margin: 0;
  color: var(--app-muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.qr-plate-actions,
.qr-plate-order-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.qr-plate-spec-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.qr-plate-spec-strip div {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.qr-plate-spec-strip dt {
  margin-bottom: 0.25rem;
  color: var(--app-muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.qr-plate-spec-strip dd {
  margin: 0;
  color: var(--app-text);
  font-weight: 700;
}

.qr-plate-gallery {
  display: grid;
  grid-template-columns: 1.05fr 0.75fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  min-height: 420px;
}

.qr-plate-gallery img {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 18px 48px rgba(15, 32, 58, 0.14);
}

.qr-plate-gallery__main {
  grid-row: 1 / -1;
}

.qr-plate-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.qr-plate-info-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-surface);
}

.qr-plate-info-card__icon {
  display: inline-flex;
  width: 2.4rem;
  height: 2.4rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.85rem;
  border-radius: 50%;
  background: #f3efe7;
  color: #6e5130;
  font-size: 0.85rem;
  font-weight: 800;
}

.qr-plate-info-card h3,
.qr-plate-split h3,
.qr-plate-order-panel h3 {
  margin: 0 0 0.5rem;
  color: var(--app-text);
  font-size: 1.12rem;
  line-height: 1.25;
}

.qr-plate-info-card p,
.qr-plate-split p,
.qr-plate-order-panel p {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.6;
}

.qr-plate-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.qr-plate-split > div,
.qr-plate-order-panel {
  padding: 1.2rem;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: #fbfcff;
}

.qr-plate-check-list,
.qr-plate-steps {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  color: var(--app-text);
}

.qr-plate-order-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  background: #f8faf4;
}

.qr-plate-order-panel__actions {
  justify-content: flex-end;
}

.qr-plate-order-panel__actions form {
  margin: 0;
}

@media (max-width: 1099.98px) {
  .memory-page-shell--public .memory-page-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 0;
    padding: 1.5rem 1rem 2rem;
    text-align: center;
  }

  .memory-page-shell--public .memory-page-hero__content {
    text-align: center;
  }

  .memory-page-shell--public .memory-page-actions {
    justify-content: center;
  }

  .memory-page-hero__facts {
    width: min(100%, 560px);
  }

  .memory-page-story-panel {
    width: min(720px, calc(100% - 1.25rem));
    margin-top: -0.75rem;
    padding: 0.85rem;
  }

  .memory-page-story-panel .memory-page-toc {
    margin: -0.85rem -0.85rem 0.85rem !important;
    padding: 0 0.85rem;
  }

  .memory-page-story-panel .memory-page-grid,
  .memory-page-story-panel .memory-page-grid--final,
  .memory-page-story-panel #memory-significant-dates .memory-page-significant-date-table {
    grid-template-columns: 1fr;
  }

  .memory-page-public-columns {
    --bs-gutter-y: 0.85rem;
  }

  .memory-page-story-panel .memory-page-column {
    gap: 0.85rem;
  }

  .qr-plate-hero-section,
  .qr-plate-order-panel {
    grid-template-columns: 1fr;
  }

  .qr-plate-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qr-plate-order-panel__actions {
    justify-content: flex-start;
  }
}

@media (min-width: 768px) and (max-width: 1099.98px) {
  .memory-page-story-panel {
    width: min(var(--app-max-width), calc(100% - 1.25rem));
  }

  .memory-page-story-panel .memory-page-two-column {
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  }
}

@media (max-width: 575.98px) {
  .memory-page-shell--public .memory-page-hero {
    margin-top: -1rem;
    padding-top: 1.25rem;
  }

  .memory-page-shell--public .memory-page-hero__photo,
  .memory-page-shell--public .memory-page-hero__photo--placeholder {
    width: min(66vw, 230px);
    height: auto;
  }

  .memory-page-shell--public .memory-page-hero__name {
    font-size: clamp(1.8rem, 8vw, 2.35rem);
  }

  .memory-page-hero__facts {
    gap: 0.85rem;
    padding: 1rem;
    text-align: left;
  }

  .memory-page-story-panel .memory-page-toc__link {
    min-height: 3.5rem;
    padding-inline: 0.75rem;
    font-size: 0.9rem;
  }

  .memory-page-story-panel {
    width: calc(100% - 0.6rem);
    padding: 0.65rem;
    border-radius: 16px;
  }

  .memory-page-story-panel .memory-page-section {
    padding: 1rem;
    border-radius: 14px;
  }

  .memory-page-story-panel .memory-page-section__title {
    font-size: 1.18rem;
  }

  .memory-page-story-panel .memory-page-photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-page-story-panel .memory-page-photo-tile img {
    height: 132px;
  }

  .qr-plate-hero-section {
    padding: 1rem;
    border-radius: 14px;
  }

  .qr-plate-hero-section__title {
    max-width: none;
  }

  .qr-plate-spec-strip,
  .qr-plate-info-grid,
  .qr-plate-split {
    grid-template-columns: 1fr;
  }

  .qr-plate-gallery {
    grid-template-columns: 1fr 1fr;
    min-height: 0;
  }

  .qr-plate-gallery img {
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .qr-plate-gallery__main {
    grid-column: 1 / -1;
    grid-row: auto;
    aspect-ratio: 4 / 3 !important;
  }
}

/* --- Полученные воспоминания --- */
.contribution-detail__meta,
.contribution-detail__summary,
.contribution-detail__facts > div,
.contribution-file-item {
  display: flex;
  gap: 0.75rem;
}

.contribution-detail__meta {
  flex-wrap: wrap;
  color: var(--app-muted);
  font-size: 0.92rem;
}

.contribution-detail__meta span:not(:last-child)::after {
  content: "·";
  margin-left: 0.75rem;
  color: var(--app-border);
}

.contribution-detail__summary {
  flex-wrap: wrap;
  margin-top: 1rem;
}

.contribution-detail__summary > div {
  min-width: 150px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-bg);
}

.contribution-detail__label,
.contribution-detail__facts dt,
.contribution-file-item span {
  display: block;
  color: var(--app-muted);
  font-size: 0.82rem;
}

.contribution-detail__facts {
  display: grid;
  gap: 0.85rem;
}

.contribution-detail__facts > div {
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--app-border);
}

.contribution-detail__facts dd {
  margin: 0;
  text-align: right;
}

.contribution-detail__story {
  padding: 1rem;
  border-radius: 12px;
  background: var(--app-bg);
  color: var(--app-text);
  line-height: 1.65;
}

.contribution-answer-grid,
.contribution-photo-grid {
  display: grid;
  gap: 1rem;
}

.contribution-answer-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.contribution-answer-card,
.contribution-photo-card,
.contribution-file-item {
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
}

.contribution-answer-card {
  padding: 1rem;
}

.contribution-answer-card h6,
.contribution-attachment-group__title {
  margin: 0 0 0.5rem;
  color: var(--app-text);
  font-weight: 700;
}

.contribution-answer-card p,
.contribution-photo-card__body p,
.contribution-file-item p {
  margin: 0;
  color: var(--app-muted);
}

.contribution-attachment-group + .contribution-attachment-group {
  margin-top: 1.25rem;
}

.contribution-photo-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.contribution-photo-card {
  overflow: hidden;
}

.contribution-photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--app-bg);
}

.contribution-photo-card__body {
  padding: 0.85rem;
}

.contribution-file-list {
  display: grid;
  gap: 0.75rem;
}

.contribution-file-item {
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
}

.contribution-file-item span {
  flex: 0 0 auto;
}

.memory-page-section__eyebrow {
  margin: 0 0 0.35rem;
  color: var(--app-primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.archive-product-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.62fr);
  gap: 1.25rem;
  align-items: stretch;
}

.archive-product-hero__content {
  min-width: 0;
}

.archive-product-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.archive-product-flow {
  display: grid;
  gap: 0.75rem;
}

.archive-product-flow > div {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-bg);
}

.archive-product-flow strong,
.archive-product-flow span {
  display: block;
}

.archive-product-flow strong {
  margin-bottom: 0.25rem;
  color: var(--app-text);
}

.archive-product-flow span {
  color: var(--app-muted);
  line-height: 1.45;
}

.archive-service-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.archive-service-card {
  display: flex;
  min-width: 0;
  min-height: 100%;
  flex-direction: column;
  padding: 1.15rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
  box-shadow: var(--app-shadow-soft);
}

.archive-service-card__icon {
  display: inline-flex;
  width: 2.75rem;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.85rem;
  border-radius: 999px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.archive-service-card h6 {
  margin: 0 0 0.55rem;
  color: var(--app-text);
  font-weight: 700;
  line-height: 1.25;
}

.archive-service-card p {
  margin: 0 0 1rem;
  color: var(--app-muted);
  line-height: 1.55;
}

.archive-service-card .btn {
  margin-top: auto;
  align-self: flex-start;
}

@media (max-width: 768px) {
  .archive-product-hero,
  .archive-service-grid {
    grid-template-columns: 1fr;
  }

  .archive-product-hero__actions .btn,
  .archive-service-card .btn {
    width: 100%;
  }

  .contribution-detail__facts > div,
  .contribution-file-item {
    display: block;
  }

  .contribution-detail__facts dd {
    margin-top: 0.25rem;
    text-align: left;
  }

  .contribution-file-item span {
    margin-top: 0.5rem;
  }
}
