* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--font-family);
    background: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    touch-action: none; /* Предотвращает случайный зум страницы на мобильных */
}

/* Шапка */
.header {
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1000;
}

.header-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo-img { height: 36px; width: auto; }
.logo-text { color: white; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px; }

/* Кнопка меню для мобильных */
.menu-toggle {
    display: none;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius);
    cursor: pointer;
}

/* Основная область */
.main-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    position: relative;
}

/* Боковая панель */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 100;
}

.sidebar.hidden { transform: translateX(-100%); }

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 { font-size: 1.1rem; font-weight: 600; }
.sidebar-header h3 { font-size: 0.9rem; color: var(--text-light); margin: 16px 0 8px 0; text-transform: uppercase; letter-spacing: 0.5px; }

.close-btn {
    background: none; border: none; font-size: 1.8rem;
    color: var(--text-light); width: 44px; height: 44px;
    border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.sidebar-content { flex: 1; overflow-y: auto; padding: 16px; }

.layer-list { display: flex; flex-direction: column; gap: 8px; }

.layer-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; background: var(--bg-color);
    border-radius: var(--border-radius); cursor: pointer;
    transition: background 0.2s;
}
.layer-item:active { background: var(--border-color); }
.layer-item input { width: 20px; height: 20px; cursor: pointer; accent-color: var(--primary-color); }

/* Карта */
.map-container { flex: 1; position: relative; }
.map { width: 100%; height: 100%; }

/* Панель инструментов */
.toolbar {
    position: absolute; top: 16px; right: 16px;
    display: flex; flex-direction: column; gap: 8px; z-index: 100;
}

.tool-btn {
    width: 44px; height: 44px; /* Увеличено для пальцев */
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--border-radius); cursor: pointer;
    font-size: 1.2rem; box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.tool-btn:active { transform: scale(0.95); background: var(--primary-color); color: white; }

/* Попап */
.popup {
    position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--card-bg); padding: 16px; border-radius: 12px;
    box-shadow: var(--shadow-lg); z-index: 200; min-width: 250px;
    display: none; border: 1px solid var(--border-color);
}
.popup.active { display: block; }
.popup-close {
    position: absolute; top: 8px; right: 8px; background: none; border: none;
    font-size: 1.2rem; cursor: pointer; color: var(--text-light);
}
.popup-content { font-size: 0.9rem; line-height: 1.5; }

/* 📱 МОБИЛЬНАЯ АДАПТАЦИЯ */
@media (max-width: 768px) {
    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    
    /* Боковая панель становится нижним листом (Bottom Sheet) */
    .sidebar {
        position: fixed; bottom: 0; left: 0; right: 0;
        width: 100%; height: 60vh;
        border-right: none; border-top: 1px solid var(--border-color);
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }
    .sidebar.hidden { transform: translateY(100%); }
    .sidebar.visible { transform: translateY(0); }
    
    /* Затемнение фона при открытой панели */
    .sidebar-overlay {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5); z-index: 99;
        display: none;
    }
    .sidebar-overlay.active { display: block; }

    /* Панель инструментов внизу для удобства большого пальца */
    .toolbar {
        top: auto; bottom: 20px; right: 16px;
        flex-direction: row; /* Горизонтально на мобильных */
    }
    
    .logo-text { font-size: 1.2rem; }
}
