:root {
  --app-bg: #f4f6fb;
  --app-surface: #ffffff;
  --app-text: #182433;
  --app-muted: #5f6d80;
  --app-border: #e5e9f2;
  --app-primary: #1f5b95;
  --app-primary-soft: #e8f1fb;
  --app-shadow-soft: 0 10px 30px rgba(15, 32, 58, 0.06);
  --app-radius-lg: 16px;
  --app-max-width: 1200px;
}

.app-root {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, var(--app-bg) 220px, #f4f6fb 100%);
  color: var(--app-text);
}

.site-container {
  width: min(var(--app-max-width), calc(100% - 2rem));
  margin: 0 auto;
  padding-left: 0;
  padding-right: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 25;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--app-border);
}

.site-main {
  padding-top: 1rem;
  padding-bottom: 2rem;
  flex: 1;
}

.site-footer__inner {
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  border-top: 1px solid var(--app-border);
}

.site-footer__inner .site-container {
  padding-top: 2rem;
  padding-bottom: 0.35rem;
}

.site-footer-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.3fr) repeat(3, minmax(150px, 1fr));
  gap: 1.5rem 1.25rem;
  align-items: start;
}

.site-footer-section {
  min-width: 0;
}

.site-footer-section--brand {
  max-width: 420px;
}

.site-footer-title {
  margin: 0 0 0.85rem;
  color: #334155;
  font-size: 0.98rem;
  font-weight: 700;
}

.site-footer-links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer-links li + li {
  margin-top: 0.58rem;
}

.site-footer-links a {
  line-height: 1.35;
}

.site-footer-caption {
  color: #334155;
}

.site-footer-social {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--app-border);
  background: #fff;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.site-footer-social a:hover {
  border-color: #cfd8e6;
  background: #f4f8ff;
}

.site-footer-telegram {
  width: auto !important;
  height: auto !important;
  min-width: auto !important;
  padding: 0.25rem 0 !important;
  font-size: 0.9rem;
  color: var(--app-muted);
  background: transparent !important;
  border: none !important;
  transition: color 0.2s ease;
}

.site-footer-telegram:hover {
  color: #0088cc;
}

.site-footer-telegram i {
  font-size: 1.15rem;
}

.site-footer-cta {
  margin-top: 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  white-space: nowrap;
}

.site-footer-cta-btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  border-radius: 0.5rem;
  background: #0284c7;
  color: #fff;
  border: 0;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.site-footer-cta-btn:hover {
  background: #0369a1;
  color: #fff;
}

.site-footer-divider {
  margin: 1.35rem 0 0.85rem;
}

.site-footer-bottom {
  color: var(--app-muted);
  line-height: 1.4;
}

.site-brand {
  font-size: 1.18rem;
  font-weight: 700;
  color: #1f3243;
  letter-spacing: 0.01em;
}

.site-logo {
  width: 42px;
  height: auto;
}

.app-top-nav .navbar-nav .nav-link {
  font-weight: 500;
}

.app-nav-link {
  color: var(--app-text) !important;
  border-radius: 999px;
  padding: 0.45rem 0.85rem !important;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app-nav-link:hover {
  background-color: var(--app-primary-soft);
  color: var(--app-primary) !important;
}

.app-nav-link.active {
  background-color: var(--app-primary);
  color: #fff !important;
}

.app-cta {
  border: 0;
  background-color: var(--app-primary);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 1rem;
}

.app-cta:hover {
  background-color: #1a4f7f;
  color: #fff;
}

.app-cta:active {
  background-color: #143d62;
  color: #fff;
}

.app-link {
  color: var(--app-muted);
}

.app-link:hover {
  color: var(--app-text);
}

.app-muted {
  color: var(--app-muted);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(250px, 280px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.app-sidebar,
.app-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-soft);
}

.app-sidebar {
  padding: 0.75rem;
}

.app-content .app-card {
  padding: 1rem;
}

.app-sidebar-title {
  padding: 0.25rem 0.6rem 0.8rem;
  color: #1e2c3b;
  font-weight: 700;
}

.app-menu {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.app-menu-title {
  margin: 0.5rem 0 0.25rem;
  color: var(--app-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.app-menu-link {
  display: block;
  text-decoration: none;
  color: var(--app-text);
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  line-height: 1.25;
}

.app-menu-link:hover {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.app-menu-link.active {
  background: var(--app-primary);
  color: #fff;
}

.app-sidebar-profile .app-menu-link {
  display: block;
  width: 100%;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  border-radius: 0 0.5rem 0.5rem 0;
  text-decoration: none;
  background: transparent;
  border-left: 3px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.app-sidebar-profile .app-menu-link:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.app-sidebar-profile .app-menu-link.active {
  background: linear-gradient(90deg, #e8f1fb 0%, transparent 100%);
  color: var(--app-primary);
  border-left-color: var(--app-primary);
}

.app-sidebar-profile .app-sidebar-title {
  padding: 0.25rem 0.75rem 0.35rem;
  color: #0f172a;
  font-size: 1rem;
  font-weight: 700;
}

.app-sidebar-profile .app-sidebar-subtitle {
  margin: 0 0.75rem 0.75rem;
  color: #64748b;
  font-size: 0.75rem;
}

.app-sidebar-profile .app-menu-section + .app-menu-section {
  margin-top: 0.6rem;
  padding-top: 0.65rem;
  border-top: 1px solid #e2e8f0;
}

.app-sidebar-profile .app-menu-title {
  margin: 0 0 0.25rem;
  padding: 0 0.75rem;
  color: #64748b;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.app-sidebar-profile .app-menu-link:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

.app-title {
  margin-bottom: 0.25rem;
  font-size: 1.8rem;
}

.app-page-header {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--app-border);
}

.app-page-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--app-text);
}

.app-page-subtitle {
  margin: 0.35rem 0 0;
  color: var(--app-muted);
  font-size: 0.95rem;
}

.app-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.app-form-grid {
  display: grid;
  gap: 0.9rem;
}

.app-form-field .form-control,
.app-form-field .form-select {
  border-color: var(--app-border);
}

.app-form-field .form-control:focus,
.app-form-field .form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem rgba(31, 91, 149, 0.15);
}

.app-form-label {
  margin-bottom: 0.35rem;
  color: var(--app-text);
  font-weight: 600;
}

.app-form-required {
  color: #b42318;
}

.app-form-help {
  color: var(--app-muted);
}

.app-form-errors {
  margin: 0.35rem 0 0;
  padding-left: 1rem;
  color: #b42318;
}

.app-form-field.has-error .form-control,
.app-form-field.has-error .form-select {
  border-color: #b42318;
}

/* --- Поле пароля с кнопкой показать/скрыть --- */
.app-password-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

.app-password-wrap .form-control {
  padding-right: 2.75rem;
  border-radius: 0.5rem;
}

.app-password-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--app-muted);
  cursor: pointer;
  border-radius: 0.375rem;
  transition: color 0.2s ease, background 0.2s ease;
}

.app-password-toggle:hover {
  color: var(--app-primary);
  background: var(--app-primary-soft);
}

.app-password-toggle:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.app-password-toggle i {
  font-size: 1rem;
}

.app-form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* --- Профиль: блок «Мои страницы памяти» --- */
.profile-memory-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--app-border);
}

.profile-biography-promo {
  margin: 0 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: linear-gradient(180deg, #edf4ff 0%, #ffffff 100%);
}

.profile-biography-promo__title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.profile-biography-promo__text {
  margin: 0 0 0.75rem;
  color: var(--app-muted);
}

.profile-memory-header__top {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .profile-memory-header__top {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
  }
}

.profile-memory-header__title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--app-text);
  line-height: 1.3;
}

.profile-memory-header__subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--app-muted);
  line-height: 1.45;
  max-width: 520px;
}

.profile-memory-header__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background-color: #0284c7;
  border-radius: 0.5rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.profile-memory-header__cta:hover {
  background-color: #0369a1;
  color: #fff;
}

.profile-memory-header__cta--large {
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
}

.profile-memory-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1rem;
}

.profile-memory-empty__icon {
  font-size: 3rem;
  color: var(--app-primary);
  opacity: 0.6;
  margin-bottom: 1rem;
}

.profile-memory-empty__text {
  margin: 0 0 1.25rem;
  color: var(--app-muted);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 400px;
}

.profile-memory-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 576px) {
  .profile-memory-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .profile-memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.profile-memory-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--app-border);
}

.profile-memory-section__title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--app-text);
}

/* Карточка страницы памяти в профиле */
.profile-memory-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-soft);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.profile-memory-card:hover {
  border-color: #d1dbe8;
  box-shadow: 0 12px 36px rgba(15, 32, 58, 0.08);
}

.profile-memory-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, #edf2fb 0%, #f8fbff 100%);
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-memory-card__media img,
.profile-memory-card__media-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-memory-card__media-link {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.profile-memory-card__media--with-photo .profile-memory-card__media-link {
  flex: 1;
  min-height: 0;
}

.profile-memory-card__delete-photo {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.profile-memory-card__delete-photo:hover {
  background: rgba(185, 28, 28, 0.9);
  color: #fff;
}

.profile-memory-card__media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 1rem;
}

.profile-memory-card__media-placeholder a,
.profile-memory-card__media-placeholder button.profile-memory-card__add-photo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--app-muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.2s ease;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 100%;
  height: 100%;
}

.profile-memory-card__media-placeholder a:hover,
.profile-memory-card__media-placeholder button.profile-memory-card__add-photo-btn:hover {
  color: var(--app-primary);
}

.profile-memory-card__media-placeholder i {
  font-size: 2rem;
  opacity: 0.5;
}

.profile-memory-card__body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.profile-memory-card__name {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--app-text);
  line-height: 1.25;
}

.profile-memory-card__name a {
  color: inherit;
  text-decoration: none;
}

.profile-memory-card__name a:hover {
  color: var(--app-primary);
}

.profile-memory-card__full-name {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--app-text);
  line-height: 1.35;
}

.profile-memory-card__dates {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--app-muted);
}

.profile-memory-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--app-border);
}

.profile-memory-card__actions a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--app-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.profile-memory-card__actions a:hover {
  color: #1a4f7f;
  text-decoration: underline;
}

.profile-memory-card__actions .btn {
  margin-top: 0.5rem;
  width: 100%;
}

.app-memory-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-memory-hero {
  padding: 1.1rem;
}

.app-card .btn-sm.active,
.app-card .btn-sm.active:hover {
  background: var(--app-primary);
  color: #fff;
}

/* --- Настройки профиля --- */
.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-section {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--app-border);
}

.settings-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-section__title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-text);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--app-border);
}

.settings-section__content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.settings-field__label {
  font-size: 0.8125rem;
  color: var(--app-muted);
  font-weight: 500;
}

.settings-field__value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--app-text);
}

.settings-field__action {
  margin-top: 0.25rem;
  align-self: flex-start;
}

.settings-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
}

/* --- Форма смены пароля --- */
.password-change-form {
  max-width: 400px;
}

.settings-password-fields {
  max-width: 400px;
}

.settings-section__hint {
  color: var(--app-muted);
  font-size: 0.875rem;
}

.app-card > .container,
.app-card > .row,
.app-card > form,
.app-card > .app-memory-hero {
  width: 100%;
}

@media (max-width: 992px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .site-footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.15rem 1rem;
  }

  .site-footer-section--brand {
    grid-column: 1 / -1;
    max-width: none;
  }

  .app-top-nav .app-cta {
    width: 100%;
    text-align: left;
  }

  .site-container {
    width: calc(100% - 1rem);
  }
}

@media (max-width: 768px) {
  .site-footer-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .site-footer-cta {
    width: 100%;
  }

  .app-sidebar {
    padding: 0.5rem;
  }

  .app-sidebar-profile .app-menu-link {
    padding: 0.5rem 0.65rem 0.5rem 0.9rem;
  }

  .app-sidebar-profile .app-sidebar-title {
    font-size: 0.95rem;
    padding: 0 0.6rem 0.25rem;
  }

  .app-sidebar-profile .app-sidebar-subtitle {
    margin: 0 0.6rem 0.6rem;
    font-size: 0.72rem;
  }

  .app-sidebar-profile .app-menu-title {
    padding: 0 0.6rem;
  }

  .app-content .app-card {
    padding: 0.75rem;
  }

  .app-form-actions .btn {
    width: 100%;
  }

  .profile-memory-header__cta {
    width: 100%;
    justify-content: center;
  }

  .profile-memory-header__cta--large {
    width: 100%;
  }

  .profile-memory-grid {
    gap: 1rem;
  }
}
