:root {
    --safe-top: 0px;
    --brand: #2E7D5B;
    --brand-light: #3a9970;
    --warm: #C4A66A;
    --warm-light: #e8dcc4;
    --action: #E8913A;
    --glamping: #9C27B0;
    --text: #2C3E3A;
    --text-hint: #7A8A85;
    --bg: #F7F5F0;
    --bg-card: #FFFFFF;
    --bg-secondary: #EDEAE4;
    --border: #D9D5CD;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

/* Верхняя панель фильтров */
.filters {
    position: fixed;
    top: var(--safe-top);
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-card);
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.search-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 7px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.search-input:focus {
    border-color: var(--brand);
}

.search-clear {
    padding: 7px 10px;
    border-radius: 10px;
    border: none;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    color: var(--tg-theme-hint-color, #999);
    font-size: 16px;
    cursor: pointer;
    display: none;
}

.search-clear.visible {
    display: block;
}

.filter-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-hint);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.filter-toggle-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* Счётчик */
.counter {
    position: fixed;
    top: calc(46px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: rgba(247, 245, 240, 0.95);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-hint);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    transition: top 0.2s;
}

.filters-panel {
    padding-top: 8px;
    transition: all 0.2s;
}

.filters-panel.hidden {
    display: none;
}

.filters-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    align-items: center;
}

.filters-row-icon {
    flex-shrink: 0;
    font-size: 14px;
    opacity: 0.6;
}

#region-filters .filter-chip {
    border-style: solid;
}

#activity-filters .filter-chip {
    border-style: dashed;
}

.filters-row::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-chip.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* Карта */
#map {
    position: fixed;
    top: calc(52px + var(--safe-top));
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Счётчик — теперь inline */
.counter.loading {
    color: var(--brand);
}

.counter.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--brand);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 6px;
    vertical-align: middle;
}

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

/* Карточка глэмпинга (нижняя панель) */
.card-overlay {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    z-index: 2000;
    background: var(--bg-card);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transition: bottom 0.3s ease;
    max-height: 60vh;
    overflow-y: auto;
}

.card-overlay.visible {
    bottom: 0;
}

/* Свайп-анимации */
.card-overlay.card-slide-left {
    transform: translateX(-100%);
    transition: transform 0.15s ease-in;
}
.card-overlay.card-slide-right {
    transform: translateX(100%);
    transition: transform 0.15s ease-in;
}
.card-overlay.card-enter-right {
    animation: enterFromRight 0.25s ease-out;
}
.card-overlay.card-enter-left {
    animation: enterFromLeft 0.25s ease-out;
}
@keyframes enterFromRight {
    from { transform: translateX(30%); opacity: 0.5; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes enterFromLeft {
    from { transform: translateX(-30%); opacity: 0.5; }
    to { transform: translateX(0); opacity: 1; }
}

.card-handle {
    width: 60px;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    margin: 10px auto 6px;
    cursor: pointer;
    touch-action: pan-y;
}
.card-handle-area {
    padding: 4px 0 8px;
    display: flex;
    justify-content: center;
    cursor: pointer;
    touch-action: pan-y;
}

.card-photos {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 4px;
    scrollbar-width: none;
    padding: 0 12px;
    touch-action: pan-x;  /* явно говорим браузеру: тут только горизонтальный скролл */
    overscroll-behavior: contain;  /* не пробрасываем скролл родителю */
}

.card-photos::-webkit-scrollbar {
    display: none;
}

.card-photos img {
    width: 200px;
    min-width: 200px;
    height: 130px;
    object-fit: cover;
    scroll-snap-align: start;
    border-radius: 10px;
    flex-shrink: 0;
}

.card-body {
    padding: 12px 16px 24px;
}

.card-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-hint);
    margin-bottom: 8px;
}
.card-price {
    color: var(--brand);
    font-weight: 600;
}
.card-sep {
    color: var(--border);
    margin: 0 2px;
}

.card-rating .star {
    color: var(--action);
}

.card-address {
    font-size: 13px;
    color: var(--text-hint);
    margin-bottom: 4px;
}

.card-coords-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.card-action-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.card-action-btn:active {
    opacity: 0.7;
}

.card-amenities {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
}

.card-ai-description {
    margin: 10px 0;
    padding: 12px 14px;
    background: var(--warm-light);
    border-left: 3px solid var(--brand);
    border-radius: 8px;
    font-style: italic;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.card-amenity {
    padding: 3px 8px;
    border-radius: 8px;
    background: var(--warm-light);
    font-size: 11px;
    color: var(--text);
}
.card-amenity.priority {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}

.card-contacts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-contact-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    background: var(--action);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    -webkit-appearance: none;
}

.card-contact-btn.secondary {
    background: var(--bg-secondary);
    color: var(--text);
}

/* Кнопка избранного (inline рядом с названием) */
.card-fav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    color: var(--border);
    transition: color 0.2s;
    vertical-align: middle;
    display: inline-block;
    outline: none;
    line-height: 0;
}
.card-fav-btn:focus {
    outline: none;
}
.card-fav-btn.active {
    color: #E53E3E;
}
.card-fav-btn.pop {
    animation: fav-pop 0.35s ease;
}
@keyframes fav-pop {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.5); }
    60%  { transform: scale(0.85); }
    100% { transform: scale(1); }
}

/* Заблокированные контакты */
.contacts-locked {
    text-align: center;
    padding: 16px 0;
}
.contacts-locked-icon {
    font-size: 32px;
    margin-bottom: 8px;
}
.contacts-locked-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.contacts-locked-hint {
    font-size: 13px;
    color: var(--text-hint);
    margin-bottom: 12px;
}
.contacts-empty {
    text-align: center;
    padding: 12px;
    color: var(--text-hint);
    font-size: 13px;
}

/* Toast уведомление */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    white-space: nowrap;
}
.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Auth bottom sheet */
.auth-sheet {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s;
}
.auth-sheet.hidden {
    display: none;
}
.auth-sheet-content {
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    padding: 28px 24px 32px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    animation: slideUp 0.25s;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.auth-sheet-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--brand);
}
.auth-sheet-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.auth-sheet-desc {
    font-size: 13px;
    color: var(--text-hint);
    margin-bottom: 20px;
}
.auth-sheet-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: #2AABEE;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
}
.auth-sheet-close {
    background: none;
    border: none;
    color: var(--text-hint);
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
}

/* Легенда */
.legend {
    position: fixed;
    bottom: 24px;
    left: 12px;
    right: 12px;
    max-width: 420px;
    z-index: 1000;
    background: var(--tg-theme-bg-color, rgba(255,255,255,0.95));
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    font-size: 11px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

/* Просмотр фото на весь экран */
.photo-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    background: rgba(0,0,0,0.95);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.photo-overlay.visible {
    display: flex;
}

.photo-overlay-carousel {
    width: 100%;
    height: 80vh;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    touch-action: pan-x;
    overscroll-behavior: contain;
}

.photo-overlay-carousel::-webkit-scrollbar {
    display: none;
}

.photo-overlay-cell {
    min-width: 100%;
    width: 100%;
    height: 80vh;
    flex-shrink: 0;
    scroll-snap-align: center;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-overlay-carousel img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center;
    transition: transform 0.2s ease-out;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}
.photo-overlay-carousel img.zoomed {
    touch-action: none;
    cursor: zoom-out;
}

.photo-overlay-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    font-size: 32px;
    line-height: 44px;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.photo-overlay-nav.prev { left: 12px; }
.photo-overlay-nav.next { right: 12px; }
.photo-overlay-nav:active {
    background: rgba(0, 0, 0, 0.75);
}
@media (max-width: 500px) {
    .photo-overlay-nav {
        width: 40px;
        height: 40px;
        font-size: 26px;
        line-height: 36px;
    }
}

.photo-overlay-close {
    position: absolute;
    top: calc(16px + var(--safe-top));
    right: 16px;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    z-index: 5001;
}

.photo-overlay-counter {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    margin-top: 12px;
}

/* Кнопка профиля */
.profile-btn-inline {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Панель профиля */
.profile-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 380px;
    height: 100%;
    z-index: 3000;
    background: var(--tg-theme-bg-color, #fff);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    overflow-y: auto;
}

.profile-panel.visible {
    right: 0;
}

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--tg-theme-hint-color, #eee);
}

.profile-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.profile-close {
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--tg-theme-secondary-bg-color, #f0f0f0);
    border: none;
}

.profile-section {
    padding: 12px 16px;
}

.profile-section h3 {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #888);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--tg-theme-secondary-bg-color, #f5f5f5);
    cursor: pointer;
}

.history-item:active {
    opacity: 0.7;
}

.fav-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #FEE2E2;
    color: #E53E3E;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.history-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--tg-theme-secondary-bg-color, #eee);
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 12px;
    color: var(--tg-theme-hint-color, #888);
    margin-top: 2px;
}

.history-time {
    font-size: 11px;
    color: var(--tg-theme-hint-color, #aaa);
    margin-top: 2px;
}

.history-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--tg-theme-hint-color, #aaa);
    font-size: 14px;
}

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.stat-card {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
}

.stat-label {
    font-size: 11px;
    color: var(--tg-theme-hint-color, #888);
    margin-top: 2px;
}

/* Yandex Maps хинты */
.ymaps-2-1-79-hint__content {
    font-size: 13px;
}

.popup-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.popup-rating {
    color: #f5a623;
    font-size: 13px;
}
