:root {
    --bg-color: #020617;
    --card-bg: #0B0F19; /* Solid background for timeline card to mask lines */
    --neon-green: #6BE13F; 
    --neon-blue: #00F0FF;
    --text-main: #FFFFFF;
    --text-muted: #64748B;
    --border-color: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: #020617;
    display: flex;
    justify-content: center;
    color: var(--text-main);
}

.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.5);
}

/* ========================================== */
/* ПРОГРЕСС-БА́Р (ВЕРХНЯЯ ПАНЕЛЬ)              */
/* ========================================== */

.progress-header {
    background: linear-gradient(to bottom, rgba(11, 15, 25, 0.95), rgba(11, 15, 25, 0.85));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 10050;
    border-bottom: 1px solid var(--border-color);
    isolation: isolate;
}

.progress-header-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.progress-header-main {
    flex: 1;
    min-width: 0;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-percent {
    font-size: 15px;
    font-weight: 700;
    color: var(--neon-blue);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.progress-km {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #007BFF, var(--neon-blue));
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================== */
/* ИНТЕРАКТИВНАЯ КАРТА                        */
/* ========================================== */

.map-wrapper {
    position: relative;
    width: 100%;
    overflow: visible;
}

#map,
.map-canvas {
    position: relative;
    width: 100%;
    height: 260px;
    background-color: #070a12;
}

/* Псевдо-fullscreen: фиксированный слой на весь viewport (без нативного Fullscreen API) */
.map-wrapper.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background-color: #070a12;
    overflow: hidden;
}

.map-wrapper.fullscreen-mode #map,
.map-wrapper.fullscreen-mode .map-canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 0;
}

body.map-pseudo-fullscreen {
    overflow: hidden;
}

/* Кнопка fullscreen: одна иконка, состояние — .fullscreen-active на #fullscreen-btn */
.map-wrapper #fullscreen-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    background: rgba(11, 15, 25, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #E2E8F0;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.2);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.map-wrapper #fullscreen-btn:hover,
.map-wrapper #fullscreen-btn:focus-visible {
    background: rgba(11, 15, 25, 0.9);
    color: #FFFFFF;
    border-color: rgba(26, 194, 255, 0.35);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 14px rgba(26, 194, 255, 0.25);
    outline: none;
}

.map-wrapper #fullscreen-btn:active {
    background: rgba(30, 41, 59, 0.95);
    transform: scale(0.96);
}

.map-wrapper #fullscreen-btn.fullscreen-active {
    color: var(--neon-blue);
    border-color: rgba(26, 194, 255, 0.45);
}

.map-wrapper #fullscreen-btn .fullscreen-btn__icon {
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}

.map-wrapper #fullscreen-btn .fullscreen-btn__glyph {
    transition: opacity 0.2s ease, stroke 0.2s ease;
}

.map-wrapper #fullscreen-btn .fullscreen-btn__glyph--compress {
    opacity: 0;
}

.map-wrapper #fullscreen-btn .fullscreen-btn__glyph--expand {
    opacity: 1;
}

.map-wrapper #fullscreen-btn.fullscreen-active .fullscreen-btn__glyph--expand {
    opacity: 0;
}

.map-wrapper #fullscreen-btn.fullscreen-active .fullscreen-btn__glyph--compress {
    opacity: 1;
}

/* Стилизация кастомных маркеров Leaflet */
.custom-route-marker {
    background: none;
    border: none;
}

.marker-pin-node {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0B0F19;
    border: 3px solid #64748B;
    box-shadow: 0 0 6px rgba(0,0,0,0.6);
    transition: all 0.3s ease;
}

.marker-pin-node.passed {
    border-color: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
}

.marker-pin-node.current {
    border-color: var(--neon-blue);
    background: #131A2A;
    box-shadow: 0 0 12px var(--neon-blue);
    transform: scale(1.2);
}

/* ========================================== */
/* ТАЙМЛАЙН-ЛЕНТА (СТУПЕНЧАТЫЙ ТАЙМЛАЙН)      */
/* ========================================== */

.timeline-container {
    padding: 20px;
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.timeline-list {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

.timeline-item, .segment-item {
    position: relative;
}

/* ========================================== */
/* ВЕРТИКАЛЬНАЯ ЛИНИЯ ТАЙМЛАЙНА               */
/* ========================================== */

.timeline-item::before, .timeline-item::after,
.segment-trigger-wrapper::before, .segment-trigger-wrapper::after {
    content: '';
    position: absolute;
    width: 2px;
    z-index: 0;
    left: 15px;
}

.timeline-item::before, .segment-trigger-wrapper::before {
    top: 0;
    bottom: 50%;
}

.timeline-item::after, .segment-trigger-wrapper::after {
    top: 50%;
    bottom: 0;
}

.timeline-list > :first-child::before { display: none !important; }
.timeline-list > :last-child::after { display: none !important; }

/* Особое правило для градиента: чтобы он не зависал на уровне пустоты, мы гарантируем, 
что у крупных элементов линия растягивается корректно */
.timeline-item.major-city.line-gradient-in::before { background: linear-gradient(to bottom, var(--neon-green), var(--neon-blue)) !important; }
.timeline-item.major-city.line-gradient-out::after { background: linear-gradient(to bottom, var(--neon-blue), transparent) !important; }

.line-passed-in::before { background: var(--neon-green) !important; }
.line-gradient-in::before { background: linear-gradient(to bottom, var(--neon-green), var(--neon-blue)) !important; }
.line-future-in::before { background: repeating-linear-gradient(to bottom, #334155, #334155 6px, transparent 6px, transparent 12px) !important; }

.line-passed-out::after { background: var(--neon-green) !important; }
.line-gradient-out::after { background: linear-gradient(to bottom, var(--neon-green), #35B8A0) !important; }
.line-future-out::after { background: repeating-linear-gradient(to bottom, #334155, #334155 6px, transparent 6px, transparent 12px) !important; }

/* ========================================== */
/* ЭЛЕМЕНТЫ: MAJOR И MINOR ГОРОДА             */
/* ========================================== */

.timeline-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    min-height: 72px;
    position: relative;
    z-index: 1;
}

/* Для минорного города зажимаем отступы и тушим яркость */
.timeline-item.minor-city {
    padding: 6px 0; 
    min-height: auto; /* Сбрасываем жесткую высоту */
    position: relative;
}

/* Иконки статусов слева */
.status-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 16px;
    flex-shrink: 0;
    font-size: 15px;
    border: 2px solid transparent;
    background: var(--card-bg); /* Mask the line */
    z-index: 2;
    position: relative;
}

/* Отвязанная неоновая точка минорного города */
.timeline-item.minor-city .status-icon {
    width: 8px !important;
    height: 8px !important;
    border: none !important;
    position: static;
    transform: none;
    margin: 0 28px 0 12px !important; /* Центрируем 8px точку на линии (15px), и выравниваем текст */
}

/* Состояния чекпоинтов */
.status-passed {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 10px rgba(107, 225, 63, 0.25);
    background: var(--card-bg);
}

.status-current {
    border-color: var(--neon-blue);
    color: var(--neon-blue);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.45);
    background: #131A2A;
}

.status-future {
    border-color: #334155;
    background: var(--card-bg);
}

/* Цвета минорных точек */
.status-future-dot {
    background-color: #475569 !important;
}
.status-passed-dot {
    background-color: var(--neon-green) !important;
    box-shadow: 0 0 10px rgba(107, 225, 63, 0.25) !important;
}
.status-current-dot {
    background-color: var(--neon-blue) !important;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.45) !important;
}

/* Контент строк */
.timeline-item-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.city-name {
    font-size: 17px;
    font-weight: 600;
    color: #FFFFFF;
}

.timeline-item.minor-city .city-name {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted); /* Тусклый по умолчанию */
}

.timeline-item.minor-city.status-future-minor .city-name {
    color: #64748B; /* Еще более тусклый для будущего */
}

.timeline-item.minor-city.status-passed-minor .city-name,
.timeline-item.minor-city.status-current-minor .city-name {
    color: #CBD5E1; /* Приглушенный белый для текущих и пройденных */
}

.city-details {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.timeline-item.minor-city .city-details {
    font-size: 11px;
}

.timeline-item.minor-city.status-future-minor .city-details {
    color: var(--text-muted);
}

/* ========================================== */
/* КНОПКА INFO (СТРОГО ПО ПЛАНУ)              */
/* ========================================== */

.info-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94A3B8;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 12px;
    z-index: 5;
}

.info-btn:active {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

.timeline-item.minor-city .info-btn {
    padding: 4px 8px;
    font-size: 11px;
    opacity: 0.8;
}

/* ========================================== */
/* СТРОКА ПЕРЕГОНА (АККОРДЕОН С ЕБЕЙШИМ КЛИКОМ)*/
/* ========================================== */

.segment-item {
    display: flex;
    flex-direction: column;
    margin: 6px 0 6px 15px; /* Начинаем прямо от оси таймлайна */
    position: relative;
    z-index: 1;
}

.segment-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 10px 12px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: none; /* Приклеиваем к линии */
    border-radius: 0 12px 12px 0;
    margin: 6px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 1px; /* Чуть сдвигаем вправо, чтобы не перекрывать саму линию 2px */
}

.segment-trigger:active {
    background: rgba(30, 41, 59, 0.5);
}

.segment-text {
    font-size: 13px;
    font-weight: 600;
    color: #38BDF8;
}

.segment-chevron {
    font-size: 16px;
    color: #64748B;
    transition: transform 0.2s ease;
    line-height: 1;
}

.segment-item.open .segment-chevron {
    transform: rotate(90deg);
}

.segment-content {
    display: none;
    flex-direction: column;
}

.segment-item.open .segment-content {
    display: flex;
}

/* ========================================== */
/* УНИВЕРСАЛЬНАЯ ВСПЛЫВАЮЩАЯ МОДАЛКА          */
/* ========================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: #0E1524;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 90%;
    max-width: 400px;
    max-height: 85vh;
    border-radius: 24px;
    padding: 0;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-overlay.open .modal-card {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
}

.modal-close:active {
    color: #FFFFFF;
}

.modal-header-block {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    margin-top: 0;
    padding: 24px 24px 16px;
    flex-shrink: 0;
}

.modal-scroll-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 24px 16px;
}

.modal-body-block {
    margin-bottom: 0;
    padding-bottom: 8px;
}

.modal-media-item--clickable {
    cursor: pointer;
}

.modal-media-item--clickable:hover {
    opacity: 0.92;
}

.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 30000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.media-lightbox[hidden] {
    display: none !important;
}

.media-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.media-lightbox-close {
    position: absolute;
    top: max(12px, env(safe-area-inset-top, 0px));
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

body.media-lightbox-open {
    overflow: hidden;
}

.modal-media-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.modal-media-item {
    width: 100%;
    border-radius: 6px;
    object-fit: cover;
    max-height: 100px;
    height: 100px;
    background: #1E293B;
    display: block;
}

.modal-media-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.modal-car-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(26, 194, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 14px;
    flex-shrink: 0;
}

.modal-title-text h3 {
    font-size: 20px;
    font-weight: 700;
    color: #FFFFFF;
}

.modal-title-text h3 span {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.modal-subtitle {
    font-size: 12px;
    color: var(--neon-blue);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.modal-media-num {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 1;
    background: rgba(0, 0, 0, 0.55);
    color: #1AC2FF;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 5px;
    line-height: 1.4;
}

.modal-note {
    font-size: 15px;
    color: #E2E8F0;
    line-height: 1.5;
    margin-bottom: 14px;
    white-space: pre-wrap;
}

.modal-distance {
    font-size: 13px;
    color: #1AC2FF;
    font-weight: 500;
    display: block;
    text-align: left;
}

/* Кнопка навигации по ТЗ */
.modal-map-btn {
    position: absolute;
    bottom: 20px;
    right: 24px;
    background: #007BFF;
    border: none;
    color: #FFFFFF;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: background 0.2s;
}

.modal-map-btn:active {
    background: #0056D2;
}

.modal-card.has-map-btn .modal-scroll-body {
    padding-bottom: 52px;
}

.modal-upload-send-btn {
    background: #007BFF;
    border: none;
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.modal-upload-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-pending-bar {
    margin-bottom: 10px;
}

.modal-pending-count {
    display: block;
    font-size: 11px;
    color: #94A3B8;
    margin-bottom: 6px;
}

.modal-pending-thumbs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}

.modal-pending-item {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
}

.modal-pending-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    background: #1E293B;
}

.modal-pending-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.9);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* ========================================== */
/* СТУПЕНЧАТЫЙ ТАЙМЛАЙН: СТИЛИЗАЦИЯ ИЕРАРХИИ  */
/* ========================================== */

/* Мажорный город: фиксируем флексы для выравнивания кнопки info */
.timeline-item.major-city {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
}

/* КНОПКА INFO (СТРОГО ПО ПЛАНУ В ПРАВОМ КРАЮ) */
.info-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94A3B8;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto; /* Выталкивает кнопку строго в правый край */
}

.info-btn:active {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

.timeline-item.minor-city .info-btn {
    padding: 3px 8px;
    font-size: 10px;
    opacity: 0.7;
}

/* ========================================== */
/* СТРОКА ПЕРЕГОНА (АККОРДЕОН С ЕБЕЙШИМ КЛИКОМ)*/
/* ========================================== */

.segment-item {
    display: flex;
    flex-direction: column;
    margin: 0; /* Без левого отступа, занимает всю ширину списка */
    padding: 0; 
    position: relative;
    z-index: 1;
}

.segment-trigger-wrapper {
    position: relative;
    padding: 0; /* Убрал вертикальный паддинг, чтобы линия не разрывалась */
    z-index: 2;
    min-height: 48px; /* Добавил минимальную высоту, чтобы было пространство для линии */
}

.segment-trigger {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px; /* Элегантная скругленная форма */
    margin: 8px 0 8px 32px; /* Аккуратные отступы от линии и соседних элементов */
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px; /* Расстояние между текстом и стрелочкой */
    width: fit-content; /* Кнопка по размеру контента, а не на всю ширину */
}

.segment-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}

.segment-trigger:active {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.97);
}

.segment-text {
    font-size: 12px;
    font-weight: 500;
    color: #94A3B8; /* Приглушенный цвет, чтобы не спорить с опорными городами */
}

.segment-chevron {
    font-size: 14px;
    color: #94A3B8;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    line-height: 1;
}

/* Анимация шеврона при раскрытии */
.segment-item.open .segment-chevron {
    transform: rotate(90deg);
}

.segment-content {
    display: none;
    flex-direction: column;
}

.segment-item.open .segment-content {
    display: flex;
}

/* КНОПКА «В ГОРОД» В МОДАЛКЕ */
.modal-map-btn {
    position: absolute;
    bottom: 20px;
    right: 24px;
    background: #007BFF;
    border: none;
    color: #FFFFFF;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: background 0.2s;
}

.modal-map-btn:active {
    background: #0056D2;
}

/* ========================================== */
/* ЛОКАЛЬНАЯ КАРТА ГОРОДА (FULLSCREEN OVERLAY)*/
/* ========================================== */

.city-map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    z-index: 20000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.city-map-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

#city-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: #070a12;
}

/* OSM-тайлы делаем тёмными через CSS-фильтр.
   Карта остаётся настоящей OpenStreetMap — со всеми домами и улицами,
   но визуально совпадает с основной тёмной картой маршрута. */
.city-map-overlay .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.92) saturate(0.65);
}

.city-map-overlay .leaflet-control-attribution {
    background: rgba(2, 6, 23, 0.55) !important;
    color: #94A3B8 !important;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 6px 0 0 0;
}
.city-map-overlay .leaflet-control-attribution a {
    color: #1AC2FF !important;
}

.city-map-overlay .leaflet-control-zoom {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(11, 15, 25, 0.85);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.city-map-overlay .leaflet-control-zoom a {
    background: transparent !important;
    color: #E2E8F0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}
.city-map-overlay .leaflet-control-zoom a:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

.city-map-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #E2E8F0;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    transition: background 0.2s, transform 0.15s;
}
.city-map-close:hover  { background: rgba(11, 15, 25, 1); }
.city-map-close:active { transform: scale(0.94); }

/* ========================================== */
/* КАСТОМНЫЙ LEAFLET-КОНТРОЛ «НАЗАД»          */
/* ========================================== */

/* Контейнер контрола в стэке Leaflet (отступы наследует от .leaflet-control). */
.custom-back-control {
    pointer-events: auto;
}

.custom-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px 7px 10px;
    background: rgba(11, 15, 25, 0.92);
    color: var(--neon-blue);
    border: 1px solid var(--neon-blue);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow:
        0 0 8px rgba(0, 240, 255, 0.45),
        inset 0 0 6px rgba(0, 240, 255, 0.10);
    transition:
        background 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease,
        text-shadow 0.2s ease;
}

.custom-back-btn:hover,
.custom-back-btn:focus-visible {
    background: var(--neon-blue);
    color: #0B0F19;
    text-shadow: none;
    box-shadow:
        0 0 18px rgba(0, 240, 255, 0.85),
        0 0 6px rgba(0, 240, 255, 0.55),
        inset 0 0 4px rgba(255, 255, 255, 0.25);
    outline: none;
}

.custom-back-btn:active {
    transform: scale(0.96);
}

.custom-back-btn__arrow {
    font-size: 18px;
    line-height: 1;
    transform: translateY(-1px);
}

/* На самых узких экранах прячем подпись, оставляем только стрелку */
@media (max-width: 360px) {
    .custom-back-btn__label { display: none; }
    .custom-back-btn {
        padding: 7px 11px;
    }
}

.city-map-pill {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #E2E8F0;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Кастомный маркер объекта на локальной карте */
.city-object-marker {
    background: rgba(11, 15, 25, 0.95);
    border: 2px solid var(--neon-blue);
    color: var(--neon-blue);
    border-radius: 50%;
    width: 30px !important;
    height: 30px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 0 10px rgba(26, 194, 255, 0.45), 0 4px 12px rgba(0, 0, 0, 0.55);
}

.city-object-marker.azs   { border-color: #FFD24A; color: #FFD24A; box-shadow: 0 0 10px rgba(255, 210, 74, 0.45), 0 4px 12px rgba(0, 0, 0, 0.55); }
.city-object-marker.hotel { border-color: #6BE13F; color: #6BE13F; box-shadow: 0 0 10px rgba(107, 225, 63, 0.45), 0 4px 12px rgba(0, 0, 0, 0.55); }
.city-object-marker.cafe  { border-color: #FF6BA8; color: #FF6BA8; box-shadow: 0 0 10px rgba(255, 107, 168, 0.45), 0 4px 12px rgba(0, 0, 0, 0.55); }
.city-object-marker.med   { border-color: #FF5A5A; color: #FF5A5A; box-shadow: 0 0 10px rgba(255, 90, 90, 0.45), 0 4px 12px rgba(0, 0, 0, 0.55); }

.leaflet-popup-content-wrapper {
    background: #0E1524;
    color: #E2E8F0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-tip {
    background: #0E1524;
}

.leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

.popup-title {
    font-size: 15px;
    font-weight: 700;
    color: #FFFFFF;
    margin-bottom: 4px;
}

.popup-type {
    display: inline-block;
    font-size: 11px;
    color: var(--neon-blue);
    background: rgba(26, 194, 255, 0.12);
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.popup-row {
    font-size: 12px;
    color: #CBD5E1;
    margin-bottom: 3px;
}

.popup-row b {
    color: var(--text-muted);
    font-weight: 500;
}

/* ========================================== */
/* ОНЛАЙН-ЧАТ                                 */
/* ========================================== */

/*
 * Десктоп (≥900px): чат слева, журнал справа, карта 480px по центру.
 * Мобилка: боковые панели скрыты.
 * TWA: карта и бургер скрыты, чат на весь экран.
 */

/* --- Базовая разметка чата --- */

.chat-sidebar,
.journal-sidebar {
    box-sizing: border-box;
}

.chat-widget,
.journal-widget {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    height: 100%;
}

.chat-header,
.journal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(11, 15, 25, 0.95);
    flex-shrink: 0;
}

.chat-title,
.journal-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--neon-blue);
}

.journal-body {
    flex: 1;
    min-height: 0;
}

.chat-bot-link {
    flex-shrink: 0;
    margin-left: auto;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid rgba(26, 194, 255, 0.35);
    background: rgba(26, 194, 255, 0.08);
    color: #1AC2FF;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.2;
    transition: background 0.15s, border-color 0.15s;
}

.chat-bot-link:hover {
    background: rgba(26, 194, 255, 0.16);
    border-color: rgba(26, 194, 255, 0.55);
}

.chat-close-btn,
.journal-close-btn {
    display: none;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #94A3B8;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.12s;
}

.chat-close-btn:hover,
.journal-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #E2E8F0;
}

.chat-close-btn:active,
.journal-close-btn:active {
    transform: scale(0.94);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.chat-load-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 0 8px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-bubble {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 8px 10px;
    cursor: pointer;
}

.chat-message--admin .chat-bubble {
    background: rgba(0, 123, 255, 0.12);
    border-color: rgba(26, 194, 255, 0.35);
    box-shadow: 0 0 12px rgba(26, 194, 255, 0.12);
}

.chat-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.chat-author {
    font-size: 12px;
    font-weight: 700;
    color: #E2E8F0;
}

.chat-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.chat-tag--guest {
    color: #94A3B8;
    background: rgba(148, 163, 184, 0.15);
}

.chat-tag--admin {
    color: #1AC2FF;
    background: rgba(26, 194, 255, 0.18);
}

.chat-time {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
}

.chat-text {
    font-size: 14px;
    line-height: 1.45;
    color: #E2E8F0;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-reactions-display {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.chat-reaction-pill {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 2px 6px;
}

.chat-actions {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 4px;
}

.chat-actions.visible {
    display: flex;
}

.chat-action-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
}

.chat-action-btn--text {
    font-size: 12px;
    color: #CBD5E1;
    padding: 5px 10px;
}

.chat-action-btn--open {
    color: #1AC2FF;
    font-weight: 600;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.chat-reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-left: 0;
}

.chat-reaction-btn {
    background: transparent;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
}

.chat-compose-dock {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(11, 15, 25, 0.98);
    border-top: 1px solid var(--border-color);
}

.chat-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 0;
}

.chat-reply-bar[hidden] {
    display: none !important;
}

.chat-reply-bar__body {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-left: 3px solid #1AC2FF;
    border-radius: 8px;
    background: rgba(26, 194, 255, 0.08);
}

.chat-reply-bar__author {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #1AC2FF;
    margin-bottom: 2px;
}

.chat-reply-bar__text {
    display: block;
    font-size: 12px;
    color: #94A3B8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-reply-bar__close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: #94A3B8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.chat-reply-quote {
    margin-bottom: 6px;
    padding: 6px 8px;
    border-left: 3px solid rgba(26, 194, 255, 0.55);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.18);
}

.chat-reply-quote__author {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #1AC2FF;
    margin-bottom: 2px;
}

.chat-reply-quote__text {
    display: block;
    font-size: 12px;
    color: #94A3B8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: transparent;
    flex-shrink: 0;
    border-top: none;
}

.chat-name-input {
    width: 72px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px;
    color: #fff;
    font-size: 13px;
}

.chat-attach-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #94A3B8;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-text-input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 10px;
    color: #fff;
    font-size: 14px;
}

.chat-send-btn {
    flex-shrink: 0;
    background: #007BFF;
    border: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Мобильный бургер и выпадающее меню --- */

.burger-btn {
    display: none;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin-top: 2px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #E2E8F0;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.burger-btn:hover {
    border-color: rgba(26, 194, 255, 0.35);
    background: rgba(26, 194, 255, 0.08);
}

.burger-btn[aria-expanded="true"] {
    border-color: rgba(26, 194, 255, 0.45);
    background: rgba(26, 194, 255, 0.12);
    box-shadow: 0 0 16px rgba(26, 194, 255, 0.15);
}

.burger-btn__icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 18px;
    height: 14px;
}

.burger-btn__icon span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    transition: transform 0.25s ease, opacity 0.2s ease, width 0.2s ease;
    transform-origin: center;
}

.burger-btn[aria-expanded="true"] .burger-btn__icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.burger-btn[aria-expanded="true"] .burger-btn__icon span:nth-child(2) {
    opacity: 0;
    width: 0;
}

.burger-btn[aria-expanded="true"] .burger-btn__icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    z-index: 10040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu {
    display: none;
    position: absolute;
    top: calc(100% - 4px);
    right: 12px;
    min-width: 196px;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid rgba(26, 194, 255, 0.22);
    background: linear-gradient(165deg, rgba(14, 21, 36, 0.98), rgba(11, 15, 25, 0.96));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.45),
        0 0 24px rgba(26, 194, 255, 0.08);
    z-index: 10060;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.mobile-menu.open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.mobile-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #E2E8F0;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.mobile-menu__item:hover,
.mobile-menu__item:focus-visible {
    background: rgba(26, 194, 255, 0.1);
    border-color: rgba(26, 194, 255, 0.35);
    outline: none;
}

.mobile-menu__item:active {
    transform: scale(0.98);
}

.mobile-menu__item--link {
    color: #E2E8F0;
}

.mobile-menu__icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.mobile-menu__label {
    flex: 1;
}

/* --- TWA: только чат на весь экран --- */

body.twa-mode .chat-name-input,
body.twa-mode .progress-header .burger-btn,
body.twa-mode .mobile-menu,
body.twa-mode .journal-sidebar,
body.twa-mode .app-container {
    display: none !important;
}

body.twa-mode .chat-sidebar {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 5000;
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 0;
    background: var(--bg-color);
    justify-content: center;
}

body.twa-mode .chat-widget {
    width: 100%;
    max-width: 480px;
    height: 100%;
    border-radius: 0;
    border: none;
}

body.twa-mode .chat-close-btn {
    display: none !important;
}

body.twa-mode .chat-bot-link {
    display: inline-flex;
    align-items: center;
}

body.twa-mode .chat-pending-bar,
body.twa-mode,
body.chat-mobile-open {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

body.twa-mode .chat-text-input,
body.twa-mode .chat-name-input,
body.chat-mobile-open .chat-text-input,
body.chat-mobile-open .chat-name-input {
    font-size: 16px;
}

body.twa-mode .chat-compose-dock,
body.chat-mobile-open .chat-compose-dock {
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
}

body.twa-mode .chat-compose-dock--fixed,
body.chat-mobile-open .chat-compose-dock--fixed,
.chat-compose-dock--portaled {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5100;
    width: 100%;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}

body.twa-mode .chat-messages--dock-padded,
body.chat-mobile-open .chat-messages--dock-padded {
    scroll-padding-bottom: 12px;
}

body.twa-mode .chat-pending-thumbs,
body.twa-mode .modal-pending-thumbs {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

body.twa-mode .chat-pending-thumbs::-webkit-scrollbar,
body.twa-mode .modal-pending-thumbs::-webkit-scrollbar {
    display: none;
}

body.twa-mode .modal-overlay {
    z-index: 25000;
}

body.twa-mode .modal-card {
    max-height: 90vh;
}

/* --- Мобилка: чат по кнопке из меню --- */

@media (max-width: 899px) {
    .progress-header {
        padding: 14px 14px 16px 16px;
    }

    .chat-sidebar,
    .journal-sidebar {
        display: none;
    }

    body:not(.twa-mode):not(.chat-mobile-open):not(.journal-mobile-open) .progress-header .burger-btn {
        display: flex;
    }

    body.chat-mobile-open .app-container,
    body.journal-mobile-open .app-container {
        visibility: hidden;
        pointer-events: none;
    }

    body.chat-mobile-open .progress-header .burger-btn,
    body.chat-mobile-open .mobile-menu,
    body.journal-mobile-open .progress-header .burger-btn,
    body.journal-mobile-open .mobile-menu {
        display: none !important;
    }

    body.chat-mobile-open .chat-sidebar {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 2400;
        padding: 0;
        background: var(--bg-color);
        justify-content: center;
    }

    body.chat-mobile-open .chat-widget {
        width: 100%;
        max-width: 480px;
        height: 100%;
        border-radius: 0;
        border: none;
    }

    body.chat-mobile-open .chat-close-btn {
        display: inline-flex;
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
    }

    body.chat-mobile-open .chat-close-btn:active {
        transform: translateY(-50%) scale(0.94);
    }

    body.chat-mobile-open .chat-header {
        position: relative;
        justify-content: center;
    }

    body.chat-mobile-open .chat-bot-link {
        display: none;
    }

    body.chat-mobile-open .chat-title {
        display: block;
        text-align: center;
        flex: 1;
    }

    body.journal-mobile-open .journal-sidebar {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 2400;
        padding: 0;
        background: var(--bg-color);
        justify-content: center;
    }

    body.journal-mobile-open .journal-widget {
        width: 100%;
        max-width: 480px;
        height: 100%;
        border-radius: 0;
        border: none;
    }

    body.journal-mobile-open .journal-close-btn {
        display: inline-flex;
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
    }

    body.journal-mobile-open .journal-close-btn:active {
        transform: translateY(-50%) scale(0.94);
    }

    body.journal-mobile-open .journal-header {
        position: relative;
        justify-content: center;
    }

    body.journal-mobile-open .journal-title {
        display: block;
        text-align: center;
        flex: 1;
    }
}

/* --- Десктоп: чат слева, журнал справа --- */

@media (min-width: 900px) {
    .progress-header .burger-btn,
    .mobile-menu {
        display: none !important;
    }

    .chat-sidebar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: calc((100vw - 480px) / 2);
        min-width: 280px;
        height: 100vh;
        padding: 16px;
        z-index: 50;
        box-sizing: border-box;
    }

    .journal-sidebar {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        width: calc((100vw - 480px) / 2);
        min-width: 280px;
        height: 100vh;
        padding: 16px;
        z-index: 50;
        box-sizing: border-box;
    }

    .chat-widget,
    .journal-widget {
        width: 100%;
        height: calc(100vh - 32px);
    }

    .chat-close-btn,
    .journal-close-btn {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .chat-name-input {
        width: 60px;
    }

    .chat-send-btn {
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* =====================================================
   МЕДИА В ЧАТЕ
   ===================================================== */

.chat-attach-btn.has-file {
    border-color: rgba(26, 194, 255, 0.5);
    background: rgba(26, 194, 255, 0.12);
    color: #1AC2FF;
    position: relative;
}

.chat-attach-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #007BFF;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.chat-pending-bar {
    padding: 8px 10px 6px;
    border-top: 1px solid var(--border-color);
    background: rgba(11, 15, 25, 0.98);
    flex-shrink: 0;
}

.chat-pending-bar--preparing {
    font-size: 12px;
    color: #94A3B8;
    text-align: center;
    padding: 10px;
}

.chat-pending-count {
    display: block;
    font-size: 11px;
    color: #94A3B8;
    margin-bottom: 6px;
}

.chat-pending-thumbs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.chat-pending-item {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
}

.chat-pending-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    background: #1E293B;
}

.chat-pending-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.9);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-unread-divider {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #1AC2FF;
    padding: 10px 12px;
    margin: 4px 0;
    border-radius: 8px;
    background: rgba(26, 194, 255, 0.08);
    border: 1px solid rgba(26, 194, 255, 0.2);
    flex-shrink: 0;
}

.chat-media-gallery {
    display: block;
    max-width: min(100%, 240px);
    margin: 6px 0 4px;
}

.chat-media-gallery .modal-media-wrap {
    display: block;
    width: 100%;
}

.chat-media-gallery .modal-media-item {
    width: 100%;
    height: auto;
    min-height: 64px;
    max-height: 280px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.chat-media-gallery .modal-media-item--clickable {
    cursor: pointer;
}

.chat-media-unavailable {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    max-height: 120px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.45);
    font-size: 13px;
    text-align: center;
}

/* =====================================================
   ЗАГРУЗКА ФОТО В МОДАЛКЕ ГОРОДА (только для админов)
   ===================================================== */

.modal-admin-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.modal-upload-btn {
    background: rgba(26, 194, 255, 0.1);
    border: 1px solid rgba(26, 194, 255, 0.3);
    color: #1AC2FF;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.modal-upload-btn:hover {
    background: rgba(26, 194, 255, 0.2);
    border-color: rgba(26, 194, 255, 0.5);
}

.modal-upload-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
