.polyhasher-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.polyhasher-grid > .map-card {
    order: 1;
}

.polyhasher-grid > .controls-panel {
    order: 2;
}

@media (min-width: 992px) {
    .polyhasher-grid {
        grid-template-columns: minmax(0, 1fr) minmax(400px, 480px);
    }
}

.status-block {
    line-height: 1.5;
}

.map-container {
    height: clamp(360px, 64vh, 720px);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
    background: #e6ebef;
}

/* Prevent global image rules from shrinking Leaflet tiles. */
.map-container .leaflet-tile {
    max-width: none !important;
    max-height: none !important;
}

/* Keep tile images unaffected by global img styling rules. */
.map-container .leaflet-tile-pane img,
.map-container .leaflet-marker-pane img {
    max-width: none !important;
    max-height: none !important;
}

.status-chip {
    font-size: 0.85rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.map-card {
    display: flex;
    position: relative;
}

.map-card .map-container {
    flex: 1 1 auto;
}

.map-canvas-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 700;
}

.map-maximize-button {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 0.2rem 0.75rem rgba(0, 0, 0, 0.2);
}

.map-maximize-button svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.polyhasher-grid.map-maximized {
    position: fixed;
    top: var(--map-maximized-top, 0);
    right: 0;
    bottom: var(--site-footer-height, 60px);
    left: 0;
    z-index: 1100;
    display: block;
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(32rem, 40vw);
    background: var(--bs-body-bg);
    margin: 0;
    gap: 1rem;
    padding: 1rem;
    align-items: stretch;
}

.polyhasher-grid.map-maximized .map-card {
    position: relative;
    border-radius: 0;
    margin: 0;
    min-height: 0;
}

.polyhasher-grid.map-maximized .map-container {
    height: 100%;
    min-height: 100%;
    border-radius: 0;
    border: 0;
}

.polyhasher-grid.map-maximized .controls-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-height: 100%;
    overflow: auto;
    margin: 0;
    box-shadow: 0 0.9rem 2rem rgba(0, 0, 0, 0.25);
}

@media (max-width: 991.98px) {
    .polyhasher-grid.map-maximized {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(40vh, 1fr) auto;
    }

    .polyhasher-grid.map-maximized .map-card {
        min-height: 40vh;
    }

    .polyhasher-grid.map-maximized .controls-panel {
        max-height: 45vh;
    }
}
