/* Шрифт PT Serif */
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRTQgYoZZY2vCFuvAFT_rC1cgT9rct48Q.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRTQgYoZZY2vCFuvAFT_rm1cgT9rct48Q.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRTQgYoZZY2vCFuvAFT_rO1cgT9rct48Q.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRTQgYoZZY2vCFuvAFT_r21cgT9rcs.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRQQgYoZZY2vCFuvAFT9gaQZyTfoOFC-I2irw.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRQQgYoZZY2vCFuvAFT9gaQZy3foOFC-I2irw.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRQQgYoZZY2vCFuvAFT9gaQZyffoOFC-I2irw.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
  font-family: 'PT Serif';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRQQgYoZZY2vCFuvAFT9gaQZynfoOFC-I0.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRVQgYoZZY2vCFuvAFbzr-_dSb_nco.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRVQgYoZZY2vCFuvAFSzr-_dSb_nco.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRVQgYoZZY2vCFuvAFYzr-_dSb_nco.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRVQgYoZZY2vCFuvAFWzr-_dSb_.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRSQgYoZZY2vCFuvAnt66qfVyvVp8NAyIw.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRSQgYoZZY2vCFuvAnt66qWVyvVp8NAyIw.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRSQgYoZZY2vCFuvAnt66qcVyvVp8NAyIw.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
}
@font-face {
  font-family: 'PT Serif';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ptserif/v18/EJRSQgYoZZY2vCFuvAnt66qSVyvVp8NA.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD
}

/* Сброс */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Токены дизайн-системы Familio */
:root {
  --fm-primary: hsl(223.26, 88.48%, 52.35%);
  --fm-primary-hover: hsl(223.24, 81.6%, 49.02%);
  --fm-primary-active: hsl(223.21, 100%, 42.75%);
  --fm-bg-page: #ffffff;
  --fm-bg-basic: #f6f6f6;
  --fm-bg-secondary: hsl(223.33, 90%, 96.08%);
  --fm-text-basic: #000000;
  --fm-text-secondary: hsl(210, 0.98%, 40%);
  --fm-text-weak: hsl(225, 2.86%, 72.55%);
  --fm-border-stroke: hsl(0, 0%, 92.16%);
  --fm-border-secondary: hsl(223.33, 90%, 96.08%);
  --fm-accent: #769AF7;
  --fm-font: 'PT Serif', serif;
  --fm-radius-md: 8px;
  --fm-radius-sm: 4px;
  --fm-header-h: 56px;
  --fm-subtitle-h: 56px;
  --colorButtonText: #1a56f1;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--fm-font);
  color: var(--fm-text-basic);
  background: var(--fm-bg-page);
}

/* Шапка */
.fm-header {
  height: var(--fm-header-h);
  background: var(--fm-bg-page);
  border-bottom: 1px solid var(--fm-border-stroke);
  flex-shrink: 0;
  z-index: 10;
}

.fm-header-inner {
  max-width: 100%;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.fm-header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.fm-header-logo svg {
  display: block;
}

.fm-header-divider {
  width: 1px;
  height: 24px;
  background: var(--fm-border-stroke);
  flex-shrink: 0;
}

/* Навигация */
.fm-header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.fm-nav-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 24px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fm-text-secondary);
  text-decoration: none;
  background: #f6f6f6;
  transition: color 0.15s;
  white-space: nowrap;
}

.fm-nav-link:hover {
  color: #003dda;
}

/* Правая часть шапки */
.fm-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.fm-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--fm-bg-secondary);
  border: 1px solid var(--fm-border-secondary);
  border-radius: 9999px;
  padding: 4px 14px;
  font-size: 0.8rem;
  color: var(--fm-text-secondary);
  white-space: nowrap;
  transition: background 0.15s;
}

.stat-badge strong {
  color: var(--fm-text-basic);
  font-weight: 700;
  font-size: 0.9rem;
}

.loading {
  font-size: 0.8rem;
  color: var(--fm-text-weak);
}

.error {
  font-size: 0.8rem;
  color: hsl(345.29, 100%, 60%);
}

/* Строка с подзаголовком и счётчиком */
#subtitle-bar {
  height: var(--fm-subtitle-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--fm-bg-basic);
  border-bottom: 1px solid var(--fm-border-stroke);
  flex-shrink: 0;
  gap: 16px;
}

.subtitle-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

#subtitle-bar .fm-stats {
  margin-left: auto;
}

.subtitle-text {
  font-size: 1rem;
  color: var(--fm-text-basic);
  letter-spacing: 0.01em;
}

/* Бургер-кнопка (только мобильные) */
.burger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  /*height: 36px;*/
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--fm-radius-sm);
  flex-shrink: 0;
  transition: background 0.15s;
}

.burger-btn:hover { background: var(--fm-bg-secondary); }

.burger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--fm-text-secondary);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
  transform-origin: center;
}

/* Крестик при открытом меню */
.burger-btn.burger-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn.burger-active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.burger-btn.burger-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Мобильное меню */
.mobile-menu {
  display: none;
  flex-direction: column;
  position: absolute;
  top: var(--fm-header-h);
  left: 0;
  right: 0;
  background: var(--fm-bg-page);
  border-bottom: 1px solid var(--fm-border-stroke);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  z-index: 200;
  padding: 8px 0;
}

.mobile-menu.mobile-menu-open { display: flex; }

.mobile-menu-link {
  display: block;
  padding: 12px 20px;
  font-size: 0.9rem;
  color: var(--fm-text-secondary);
  text-decoration: none;
  transition: background 0.15s;
}

.mobile-menu-link:hover {
  background: var(--fm-bg-secondary);
  color: var(--fm-text-basic);
}

.mobile-menu-divider {
  height: 1px;
  background: var(--fm-border-stroke);
  margin: 4px 0;
}

/* Адаптив: скрыть nav, показать бургер */
@media (max-width: 700px) {
  .fm-header-nav { display: none; }
  .fm-header-divider { display: none; }
  .burger-btn    { display: flex; }
  .stat-badge    { padding: 4px 8px; font-size: 0.72rem; }
  .footer { display: none; }
}

/* Карта */
#map { flex: 1; position: relative; }

.map-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  gap: 10px;
}

.map-add-btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--fm-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--fm-font);
  color: #fff;
  background: var(--fm-primary);
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
}

.map-add-btn:hover {
  background: var(--fm-primary-hover);
  box-shadow: 0 4px 14px rgba(0,0,0,0.16);
}


.map-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px 0 56px;
  border-radius: var(--fm-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--fm-font);
  color: var(--fm-text-basic);
  background: #ffffff;
  border: 1px solid var(--fm-border-stroke);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.map-toggle-btn:hover {
  background: #f8fafc;
}

/* ::before = трек (фон) — рендерится ПОД ::after */
.map-toggle-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 9px;
  transform: translateY(-50%);
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #d1d5db;
  transition: background 0.2s;
}

/* ::after = ползунок — рендерится НАД ::before */
.map-toggle-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-toggle-btn.map-toggle-btn-active {
  /*background: #eff6ff;*/
  color: #1d4ed8;
  /*border-color: #93c5fd;*/
}

/* трек — синий */
.map-toggle-btn.map-toggle-btn-active::before {
  background: #2563eb;
}

/* ползунок — сдвигается вправо: 9 + 38 - 18 - 2 = 27px */
.map-toggle-btn.map-toggle-btn-active::after {
  left: 27px;
}

.map-toggle-btn.map-toggle-btn-disabled {
  background: #f3f4f6;
  color: #9ca3af;
}

.map-toggle-btn.map-toggle-btn-disabled::before {
  background: #e5e7eb;
}

.map-toggle-btn.map-toggle-btn-disabled::after {
  background: #f3f4f6;
  box-shadow: none;
}

/* Подвал */
.footer {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--fm-radius-md);
  padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  z-index: 40;
  backdrop-filter: blur(4px);
}

.footer-menu {
  display: flex;
  align-items: center;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-menu a {
  font-size: 0.8rem;
  color: var(--fm-text-secondary);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.footer-menu a:hover {
  color: var(--fm-primary);
}

/* Всплывашка */
.map-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #1e293b;
  color: #f1f5f9;
  font-family: var(--fm-font);
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 12px 18px;
  border-radius: var(--fm-radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 200;
  max-width: calc(100vw - 32px);
  text-align: center;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.map-toast[hidden] {
  display: none;
}

.map-toast.map-toast-hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(6px);
}

.map-toast a {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.map-toast a:hover {
  color: #bfdbfe;
}

@media (max-width: 700px) {
  .map-toast {
    bottom: 16px;
    font-size: 0.85rem;
    padding: 10px 14px;
  }
}

/* Кнопки управления картой */

/* Позиционируем группу по центру правой стороны */
.maplibregl-ctrl-top-right {
  top: 50% !important;
  right: 16px !important;
  transform: translateY(-50%);
}

.maplibregl-ctrl-group {
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border: none !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}

.maplibregl-ctrl-group button {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.15s, box-shadow 0.15s !important;
  padding: 0 !important;
}

.maplibregl-ctrl-group button:hover {
  background: var(--fm-bg-secondary) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22) !important;
}

.maplibregl-ctrl-group button:disabled {
  opacity: 0.4 !important;
  cursor: default !important;
}

/* Разделитель между кнопками убираем (теперь они отдельные круглые) */
.maplibregl-ctrl-group button + button {
  border-top: none !important;
}

/* Убираем стандартные SVG-иконки MapLibre, рисуем + и - текстом */
.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon,
.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
  background-image: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
}

.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before {
  content: '+';
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  color: var(--fm-text-basic);
  font-family: sans-serif;
}

.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before {
  content: '−';
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  color: var(--fm-text-basic);
  font-family: sans-serif;
}

/* Компас скрыт — вращение отключено */
.maplibregl-ctrl-compass { display: none !important; }

/* Стили попапа */
.maplibregl-popup-content {
  border-radius: var(--fm-radius-md) !important;
  padding: 16px 18px !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12) !important;
  border: 1px solid var(--fm-border-stroke);
  font-family: var(--fm-font);
}

.maplibregl-popup-close-button {
  font-size: 20px;
  color: var(--fm-text-weak);
  padding: 4px 8px;
}

.maplibregl-popup-close-button:hover {
  color: var(--fm-text-basic);
  background: transparent;
}

.popup h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fm-text-basic);
  margin-bottom: 6px;
  line-height: 1.3;
}

.popup .count {
  font-size: 0.82rem;
  color: var(--fm-text-secondary);
  margin-bottom: 8px;
}

.popup .count strong {
  color: var(--fm-primary);
  font-weight: 700;
}

.popup ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.popup li {
  font-size: 0.8rem;
  color: var(--fm-text-basic);
  padding: 3px 0;
  border-bottom: 1px solid var(--fm-border-stroke);
  line-height: 1.4;
}

.popup li:last-child {
  border-bottom: none;
}

.popup .more {
  font-size: 0.75rem;
  color: var(--fm-text-weak);
  margin-top: 6px;
  font-style: italic;
}

/* Адаптив */
@media (max-width: 700px) {
  .stat-badge {
    padding: 3px 10px;
    font-size: 0.72rem;
  }

  .stat-badge strong {
    font-size: 0.8rem;
  }

  .subtitle-text {
    font-size: 0.8rem;
  }
}

@media (max-width: 500px) {
  /* На совсем узких экранах текст subtitle выезжает за границу — скрываем,
     оставляем только счётчик справа */
  .subtitle-text {
    display: none;
  }
}

/* Боковая панель */
.sidebar {
  position: fixed;
  top: calc(var(--fm-header-h) + var(--fm-subtitle-h));
  right: 0;
  bottom: 0;
  width: 360px;
  background: var(--fm-bg-page);
  border-left: 1px solid var(--fm-border-stroke);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.sidebar.sidebar-open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--fm-border-stroke);
  flex-shrink: 0;
}

.sidebar-title-block {
  flex: 1;
  min-width: 0;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--fm-text-basic);
  line-height: 1.3;
  margin: 0 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-title a {
  color: var(--fm-primary);
  text-decoration: none;
}

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

.sidebar-count {
  font-size: 0.8rem;
  color: var(--fm-text-secondary);
  margin: 0;
}

.sidebar-count strong {
  font-weight: 700;
}

.sidebar-close-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--fm-radius-sm);
  border: none;
  background: transparent;
  color: var(--fm-text-weak);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.sidebar-close-btn:hover {
  background: var(--fm-bg-basic);
  color: var(--fm-text-basic);
}

/* Список персон */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-list::-webkit-scrollbar {
  width: 4px;
}

.sidebar-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-list::-webkit-scrollbar-thumb {
  background: var(--fm-border-stroke);
  border-radius: 4px;
}

.person-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  transition: background 0.12s;
}

.person-item:hover {
  background: var(--fm-bg-basic);
}

.person-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--fm-bg-secondary);
  border: 1px solid var(--fm-border-stroke);
}

.person-link {
  font-size: 0.875rem;
  color: var(--fm-primary);
  text-decoration: none;
  line-height: 1.4;
  word-break: break-word;
}

.person-link:hover {
  text-decoration: underline;
}

.person-name-plain {
  font-size: 0.875rem;
  color: var(--fm-text-basic);
  line-height: 1.4;
}

.sidebar-more {
  padding: 8px 16px 12px;
  font-size: 0.78rem;
  color: var(--fm-text-weak);
  font-style: italic;
}

@media (max-width: 700px) {
  .sidebar {
    width: 100%;
    top: calc(var(--fm-header-h) + var(--fm-subtitle-h));
  }
}

/* Кнопки в шапке (навигация и Войти) — единый стиль */
.fm-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 24px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--fm-font);
  color: var(--fm-text-secondary);
  background: #f6f6f6;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.fm-login-btn:hover {
  color: #003dda;
}

.fm-login-btn.fm-login-btn-active {
  background: var(--fm-primary);
  color: #fff;
  padding: 0;
  width: 36px;
  min-width: 36px;
  border-radius: 50%;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.fm-login-btn.fm-login-btn-active:hover {
  background: var(--fm-primary-hover);
  color: #fff;
}

/* Кнопка «ℹ» в строке подзаголовка */
.subtitle-about-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--fm-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 0;
  padding: 0;
}

.subtitle-about-btn:hover {
  color: var(--fm-primary);
}

/* Модальные окна */
#modal-about {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#modal-about[aria-hidden="true"],
#modal-add[aria-hidden="true"] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 400ms ease;
}

.modal-container {
  background: var(--fm-bg-page);
  border-radius: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-width: 480px;
  width: calc(100% - 40px);
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
  overflow: hidden;
  font-family: var(--fm-font);
  transition: transform 480ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity 480ms ease-out;
  transform-origin: center;
  opacity: 1;
  transform: scale(1) translate(0, 0);
}

.modal-container.is-flying {
  opacity: 0;
  transform: translate(var(--fly-delta-x, 0px), var(--fly-delta-y, 0px)) 
             scale(var(--fly-scale, 0.2));
}

.modal-container.is-flying + .modal-overlay {
  opacity: 0;
}


.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--fm-border-stroke);
  flex-shrink: 0;
}

.modal-illustration {
  flex-shrink: 0;
  line-height: 0;
  border-bottom: 1px solid var(--fm-border-stroke);
}

.modal-illustration svg {
  display: block;
  width: 100%;
  height: auto;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fm-text-basic);
  margin: 0;
  line-height: 1.3;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--fm-radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fm-text-weak);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.modal-close::before {
  content: '✕';
  font-size: 16px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--fm-bg-basic);
  color: var(--fm-text-basic);
}

.modal-close:focus {
  outline: none;
}

.modal-content {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content p {
  font-size: 0.925rem;
  color: var(--fm-text-basic);
  line-height: 1.65;
  margin: 0;
}

.modal-content a {
  color: var(--fm-primary);
  text-decoration: none;
}

.modal-content a:hover {
  text-decoration: underline;
}

.modal-content ol {
  list-style-position: inside;
  font-size: 0.925rem;
  line-height: 1.65;
}

/*.modal-content ol li::marker {
  color: var(--fm-primary);
}*/

.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Убираем разделитель заголовка/контент в модалке добавления */
#modal-add .modal-header {
  border-bottom: none;
  padding-bottom: 8px;
}

.modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--fm-radius-sm);
  font-size: 0.875rem;
  font-family: var(--fm-font);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border: none;
  white-space: nowrap;
}

.modal-btn-primary {
  background: var(--fm-primary);
  color: #fff;
}

.modal-btn-primary:hover {
  background: var(--fm-primary-hover);
}

.modal-btn-secondary {
  background: #edf1fe;
  color: var(--colorButtonText);
}

.modal-btn-secondary:hover {
  background: var(--fm-bg-secondary);
  color: var(--fm-text-basic);
}

/* Форма добавления персоны */

.modal-add-label {
  font-size: 0.8rem;
  color: var(--fm-text-secondary);
  letter-spacing: 0.03em;
}

.modal-add-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--fm-border-stroke);
  border-radius: var(--fm-radius-sm);
  font-size: 0.875rem;
  font-family: var(--fm-font);
  color: var(--fm-text-basic);
  background: var(--fm-bg-page);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-add-input:focus {
  border-color: var(--fm-primary);
  box-shadow: 0 0 0 3px hsl(223.26, 88.48%, 52.35%, 0.15);
}

.modal-add-input::placeholder {
  color: var(--fm-text-weak);
}

.modal-add-error {
  font-size: 0.85rem;
  color: hsl(345, 90%, 48%);
  line-height: 1.5;
  padding: 6px 10px;
  background: hsl(345, 90%, 97%);
  border: 1px solid hsl(345, 80%, 88%);
  border-radius: var(--fm-radius-sm);
}

/* Spinner для состояния загрузки */
.modal-add-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--fm-border-stroke);
  border-top-color: var(--fm-primary);
  border-radius: 50%;
  animation: modal-spin 0.7s linear infinite;
  align-self: center;
  margin: 8px auto;
}

@keyframes modal-spin {
  to { transform: rotate(360deg); }
}

/* Иконка и тело результата */
.modal-add-result-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.modal-add-result-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  margin-top: 1px;
}

/* Кнопка отключена во время запроса */
.modal-btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

/* hidden-атрибут перебивается display:flex на .modal-content и .modal-footer */
.modal-add-state[hidden] {
  display: none !important;
}
