html, body {
    height: 100%;
    margin: 0;
}

.leaflet-container {
    width: 100%;
    height: 100%;
}

/* Prevent PaperCSS from styling Leaflet internals */
.leaflet-container *,
.leaflet-container img,
.leaflet-container svg {
    border: none;
    border-radius: 0;
    box-shadow: none;
    box-sizing: content-box;
    max-width: none;
}

/* PaperCSS style for Leaflet controls */
.leaflet-container .leaflet-control-layers,
.leaflet-container .leaflet-bar {
    border: 2px solid var(--primary, #41403e) !important;
    border-bottom-left-radius: 15px 255px !important;
    border-bottom-right-radius: 225px 15px !important;
    border-top-left-radius: 255px 15px !important;
    border-top-right-radius: 15px 225px !important;
    box-shadow: 15px 28px 25px -18px rgba(0, 0, 0, 0.2) !important;
    font-family: Neucha, sans-serif;
    overflow: hidden;
}

.leaflet-container .leaflet-bar a,
.leaflet-container .leaflet-bar button {
    border: none !important;
    border-bottom: 1px solid #ccc !important;
    font-family: Neucha, sans-serif;
}

.leaflet-container .leaflet-bar a:last-child,
.leaflet-container .leaflet-bar button:last-child {
    border-bottom: none !important;
}

.leaflet-container .leaflet-control-layers-expanded {
    padding: 8px 12px;
    font-size: 13px;
}

.leaflet-container .leaflet-control-layers-separator {
    border-top: 2px solid var(--muted-light, #ccc) !important;
    margin: 6px 0;
}

/* Restore proper layout for Leaflet layer control inputs */
.leaflet-control-layers label,
.leaflet-control-layers label > span {
    display: flex;
    align-items: center;
}

.leaflet-control-layers input[type="radio"],
.leaflet-control-layers input[type="checkbox"] {
    position: static;
    margin: 0 4px 0 0;
    flex-shrink: 0;
}

/* Context menu */
.context-menu {
    display: none;
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 2px solid var(--primary, #41403e);
    border-bottom-left-radius: 15px 255px;
    border-bottom-right-radius: 225px 15px;
    border-top-left-radius: 255px 15px;
    border-top-right-radius: 15px 225px;
    box-shadow: 15px 28px 25px -18px rgba(0, 0, 0, 0.2);
    padding: 4px 0;
    min-width: 180px;
    font-family: Neucha, sans-serif;
    overflow: hidden;
}

.context-menu .ctx-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
}

.context-menu .ctx-item:hover {
    background: #f0f0f0;
}

.context-menu .ctx-item-danger {
    color: #c0392b;
}

.context-menu .ctx-item-danger:hover {
    background: #fdecea;
}

.context-menu .ctx-divider {
    border-top: 1px solid #e0e0e0;
    margin: 4px 0;
}

/* Dialog base */
dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    min-width: 320px;
    max-width: 90vw;
    overflow: hidden;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

/* Disable PaperCSS hover-transform on cards inside dialogs */
dialog .card:hover {
    transform: none;
}

/* Auth button inside Leaflet layer control */
.leaflet-auth-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    background: none;
    border: none;
    border-top: 2px solid var(--muted-light, #ccc);
    margin-top: 6px;
    cursor: pointer;
    font-family: Neucha, sans-serif;
    font-size: 13px;
    text-align: left;
}

.leaflet-auth-btn:hover {
    background: #f4f4f4;
}

/* Favorite toggle in edit dialog */
.favorite-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

.favorite-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    /* Context menu items — 44px touch targets */
    .context-menu .ctx-item {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px;
        display: flex;
        align-items: center;
    }

    /* Dialogs — fit mobile screens */
    dialog {
        max-width: 95vw;
        max-height: 85vh;
        overflow-y: auto;
    }

    /* Leaflet zoom buttons */
    .leaflet-container .leaflet-bar a,
    .leaflet-container .leaflet-bar button {
        width: 40px !important;
        height: 40px !important;
        line-height: 40px !important;
        font-size: 22px !important;
    }

    /* Layer control */
    .leaflet-container .leaflet-control-layers-expanded {
        font-size: 15px;
        padding: 10px 14px;
    }

    .leaflet-control-layers label {
        padding: 4px 0;
    }

    /* Form inputs — 16px font prevents iOS auto-zoom */
    dialog input[type="text"],
    dialog input[type="password"],
    dialog textarea,
    dialog select {
        min-height: 44px;
        font-size: 16px;
        padding: 8px 10px;
        box-sizing: border-box;
    }

    /* Buttons — 44px touch targets */
    dialog button,
    dialog input[type="submit"] {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 16px;
    }

    /* Auth button in layer control */
    .leaflet-auth-btn {
        font-size: 15px;
        padding: 10px 14px;
        min-height: 44px;
    }

    /* Favorite toggle */
    .favorite-toggle {
        font-size: 16px;
        min-height: 44px;
    }

    .favorite-toggle input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }
}
