/* ===== БАЗОВЫЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0d1117;
    color: #f0f6fc;
    overflow: hidden;
}
#map {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ===== КАСТОМНЫЕ МАРКЕРЫ ===== */
.custom-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    border-radius: 50% 50% 50% 0;
    width: 44px;
    height: 44px;
    transform: rotate(-45deg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 2px solid #0d1117;
    transition: all 0.25s ease;
    cursor: pointer;
    animation: pinPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.custom-pin .pin-text {
    transform: rotate(45deg);
    font-size: 14px;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.custom-pin.visited {
    background: #238636;
}
.custom-pin.wishlist {
    background: #1f6feb;
}
.custom-pin:hover {
    transform: rotate(-45deg) scale(1.15);
}
.custom-pin.clicked {
    transform: rotate(-45deg) scale(1.3);
    filter: brightness(1.3);
}
@keyframes pinPop {
    0% { opacity: 0; transform: rotate(-45deg) scale(0.3); }
    100% { opacity: 1; transform: rotate(-45deg) scale(1); }
}

/* ===== КНОПКА ДОБАВЛЕНИЯ ===== */
#add-btn {
    position: absolute;
    bottom: 180px;
    right: 20px;
    z-index: 1000;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #238636;
    color: #fff;
    border: none;
    font-size: 36px;
    font-weight: 300;
    box-shadow: 0 6px 24px rgba(35, 134, 54, 0.5);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.2s, box-shadow 0.2s;
}
#add-btn:active {
    transform: scale(0.88);
    box-shadow: 0 2px 12px rgba(35, 134, 54, 0.3);
}

/* ===== ПАНЕЛЬ СТАТИСТИКИ ===== */
#stats-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(13, 17, 23, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.7);
    padding: 12px 20px 20px;
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(calc(100% - 70px));
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}
#stats-panel.open {
    transform: translateY(0);
}
#stats-handle {
    width: 40px;
    height: 4px;
    background: #4a5568;
    border-radius: 4px;
    margin: 0 auto 12px;
    cursor: pointer;
}
#stats-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}
.stat-item {
    background: rgba(255,255,255,0.04);
    border-radius: 16px;
    padding: 10px 6px;
    text-align: center;
}
.stat-label {
    display: block;
    font-size: 10px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #f0f6fc;
}
.stat-value.rating-avg {
    color: #f7c948;
}

/* ===== ФИЛЬТРЫ ===== */
.filter-bar {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 8px 0 12px;
}
.filter-btn {
    padding: 6px 14px;
    border-radius: 30px;
    border: 1px solid #2d3548;
    background: transparent;
    color: #8b949e;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    max-width: 100px;
    text-align: center;
}
.filter-btn.active {
    background: #238636;
    border-color: #238636;
    color: #fff;
}
.filter-btn:active {
    transform: scale(0.92);
}

/* ===== АЧИВКИ ===== */
#achievements {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px solid #2d3548;
}
.achievement {
    background: rgba(255,215,0,0.12);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 30px;
    padding: 4px 12px 4px 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #f0e6a0;
}
.achievement-icon {
    font-size: 16px;
}

.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0,0,0,0.6);
    display: none; /* по умолчанию все скрыты */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: modalBgFade 0.2s;
}
/* Удаляем [data-state] правила */

@keyframes modalBgFade {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-content {
    background: #1c2333;
    border-radius: 28px;
    padding: 24px 20px 20px;
    max-width: 440px;
    width: 92%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.8);
    color: #f0f6fc;
    animation: modalSlide 0.25s ease;
}
@keyframes modalSlide {
    from { transform: scale(0.92) translateY(12px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-content h2 {
    margin-top: 0;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 20px;
}
.modal-content label {
    display: block;
    margin: 12px 0 4px;
    font-size: 13px;
    color: #8b949e;
}
.modal-content input, .modal-content textarea, .modal-content select {
    width: 100%;
    padding: 12px 14px;
    background: #0d1117;
    border: 1px solid #2d3548;
    border-radius: 14px;
    color: #f0f6fc;
    font-size: 16px;
    box-sizing: border-box;
    transition: border 0.2s;
}
.modal-content input:focus, .modal-content textarea:focus, .modal-content select:focus {
    outline: none;
    border-color: #58a6ff;
}
.modal-content select option {
    background: #1c2333;
}
.modal-content .star-rating {
    display: flex;
    gap: 8px;
    font-size: 30px;
    cursor: pointer;
    padding: 4px 0;
}
.modal-content .star-rating .star {
    color: #4a5568;
    transition: color 0.15s;
}
.modal-content .star-rating .star.active {
    color: #f7c948;
}
.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: flex-end;
}
.modal-buttons button, #info-modal button {
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    touch-action: manipulation;
}
.modal-buttons button:active, #info-modal button:active {
    transform: scale(0.94);
}
#modal-cancel {
    background: #2d3548;
    color: #b1bac4;
}
#modal-save {
    background: #238636;
    color: #fff;
}
#coords-info {
    margin: 12px 0 8px;
    font-size: 14px;
    color: #8b949e;
    background: #0d1117;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px dashed #2d3548;
}

/* ===== КАРУСЕЛЬ ===== */
#carousel-images {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    border-radius: 16px;
    padding: 4px 0;
    scrollbar-width: none;
}
#carousel-images::-webkit-scrollbar {
    display: none;
}
#carousel-images img {
    min-width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 16px;
    scroll-snap-align: start;
    background: #0d1117;
}
#carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}
#carousel-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2d3548;
    display: inline-block;
    transition: all 0.3s;
    cursor: pointer;
}
#carousel-dots span.active-dot {
    background: #f0f6fc;
    transform: scale(1.2);
}

/* ===== ФАЙЛОВЫЙ ИНПУТ ===== */
.file-upload-wrapper {
    position: relative;
    display: block;
    width: 100%;
    margin: 6px 0 10px;
}
.file-upload-wrapper input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #2d3548;
    color: #f0f6fc;
    padding: 10px 18px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    border: 1px dashed #4a5568;
    cursor: pointer;
    transition: all 0.25s;
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
}
.file-upload-btn:hover {
    background: #3d4558;
    border-color: #58a6ff;
}
.file-upload-btn:active {
    transform: scale(0.97);
}
.file-upload-btn svg {
    width: 20px;
    height: 20px;
    stroke: #f0f6fc;
    stroke-width: 2;
    fill: none;
}
#existing-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0 12px;
}
#existing-photos > div {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #0d1117;
}
#existing-photos img {
    width: 76px;
    height: 76px;
    object-fit: cover;
    display: block;
}
#existing-photos button {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #da3633;
    color: #fff;
    border: 2px solid #1c2333;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
#existing-photos button:active {
    transform: scale(0.84);
}

/* ===== ИНФО МОДАЛКА ===== */
#info-modal .modal-content p {
    margin: 6px 0;
}
#info-modal .popup-tag {
    background: #2d3548;
    padding: 2px 10px;
    border-radius: 30px;
    font-size: 11px;
    color: #b1bac4;
}
#info-toggle-status {
    background: #1f6feb !important;
    color: #fff !important;
}
#info-toggle-status:hover {
    background: #388bfd !important;
}

/* ===== СПИСОК / ГАЛЕРЕЯ ===== */
#view-toggle {
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 6px;
    background: rgba(13,17,23,0.8);
    backdrop-filter: blur(8px);
    border-radius: 30px;
    padding: 4px;
    border: 1px solid #2d3548;
}
#view-toggle button {
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 20px;
    padding: 6px 12px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
}
#view-toggle button.active {
    background: #238636;
    color: #fff;
}
#places-list {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background: #0d1117;
    overflow-y: auto;
    padding: 80px 16px 100px;
    box-sizing: border-box;
}
#places-list.visible {
    display: block;
}
.place-card {
    background: #1c2333;
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    border: 1px solid #2d3548;
    display: flex;
    flex-direction: column;
}
.place-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.place-card .card-title {
    font-size: 18px;
    font-weight: 600;
}
.place-card .card-rating {
    color: #f7c948;
    font-size: 18px;
}
.place-card .card-photo {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
    margin: 10px 0;
    background: #0d1117;
}
.place-card .card-desc {
    color: #b1bac4;
    font-size: 14px;
    margin: 4px 0 8px;
}
.place-card .card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 6px 0;
}
.place-card .card-tag {
    background: #2d3548;
    padding: 2px 10px;
    border-radius: 30px;
    font-size: 11px;
    color: #b1bac4;
}
.place-card .card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #8b949e;
    margin-top: 8px;
}
.place-card .card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.card-empty {
    text-align: center;
    color: #8b949e;
    padding: 40px 0;
    font-size: 16px;
}

/* ===== ПОИСК ===== */
#search-input {
    position: absolute;
    top: 16px;
    left: 20px;
    z-index: 1000;
    width: calc(100% - 140px);
    max-width: 320px;
    padding: 10px 16px;
    border-radius: 30px;
    border: 1px solid #2d3548;
    background: rgba(13,17,23,0.85);
    backdrop-filter: blur(8px);
    color: #f0f6fc;
    font-size: 14px;
    outline: none;
    transition: border 0.2s;
}
#search-input:focus {
    border-color: #58a6ff;
}
#search-input::placeholder {
    color: #4a5568;
}

/* ===== АДАПТИВ ===== */
@media (max-width: 600px) {
    #stats-content {
        grid-template-columns: 1fr 1fr;
    }
    #add-btn {
        bottom: 170px;
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 30px;
    }
    #search-input {
        top: 12px;
        left: 12px;
        width: calc(100% - 100px);
        font-size: 13px;
        padding: 8px 14px;
    }
    #view-toggle {
        top: 10px;
        right: 12px;
        padding: 3px;
    }
    #view-toggle button {
        font-size: 16px;
        padding: 4px 10px;
    }
    .custom-pin {
        width: 36px;
        height: 36px;
    }
    .custom-pin .pin-text {
        font-size: 12px;
    }
    .place-card .card-title {
        font-size: 16px;
    }
    .place-card .card-photo {
        height: 100px;
    }
}
@media (max-width: 400px) {
    #stats-content {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .stat-item {
        padding: 6px 4px;
    }
    .stat-value {
        font-size: 15px;
    }
    .filter-btn {
        font-size: 11px;
        padding: 4px 8px;
        max-width: 70px;
    }
}
/* ===== КНОПКА ГЕОЛОКАЦИИ ===== */
#geo-btn {
    position: absolute;
    bottom: 250px; /* чуть выше кнопки добавления */
    right: 20px;
    z-index: 1000;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #1c2333;
    color: #f0f6fc;
    border: 1px solid #2d3548;
    font-size: 24px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#geo-btn:active {
    transform: scale(0.88);
    background: #2d3548;
}
#geo-btn.loading {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}