html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100vh;
}

.leaflet-control-attribution {
    font-size: 10px;
}

#language-switcher { display: flex; gap: 4px; }

.language-button {
    border: none;
    background: transparent;

    font-size: 20px;
    line-height: 1;

    padding: 5px 7px;

    cursor: pointer;
    border-radius: 4px;
}

.language-button:hover {
    background: #f0f0f0;
}

.language-button.active {
    background: #e5e7eb;
}

.language-button img,
#menu-flag {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

#map-filters {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 1000;
    width: min(220px, calc(100vw - 70px));
    max-height: calc(100dvh - 30px);
    overflow-y: auto;
    box-sizing: border-box;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
    font: 12px/1.3 Arial, sans-serif;
}
#map-filters select, #case-search {
    box-sizing: border-box;
    width: 100%;
    min-height: 32px;
    margin-bottom: 8px;
    padding: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: white;
    color: #1f2937;
    font: inherit;
}

#year-range-control {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    margin: 14px 0 22px;
}

#year-filter {
    width: 100%;
    margin-left: 2px;
    margin-right: 2px;
    height: 4px;
    border: 0;
    box-shadow: none;
}

#year-filter.disabled {
    opacity: 0.5;
    pointer-events: none;
}

#year-filter .noUi-connect {
    background: #2563eb;
}

#year-filter .noUi-base,
#year-filter .noUi-connects {
    height: 4px;
}

#year-filter .noUi-handle {
    right: -7px;
    top: -5px;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #2563eb;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
    cursor: grab;
}

#year-filter .noUi-handle::before,
#year-filter .noUi-handle::after {
    display: none;
}

#year-filter .noUi-handle:active {
    cursor: grabbing;
}

#year-filter .noUi-tooltip {
    bottom: -20px;
    border: 0;
    padding: 0;
    background: transparent;
    color: #2563eb;
    font-size: 10px;
    line-height: 1;
}

#year-filter-value {
    min-width: 28px;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

#district-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 9px;
}

#district-filter .form-selectgroup-item {
    margin: 0;
}

#district-filter .district-label {
    min-height: 0;
    padding: 3px 7px;
    border-color: currentColor;
    border-radius: 999px;
    color: var(--district-color);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
}

#district-filter .form-selectgroup-input:checked + .district-label {
    background: var(--district-color);
    border-color: var(--district-color);
    color: #ffffff;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--district-color) 22%, transparent);
}

#district-filter .form-selectgroup-input:disabled + .district-label {
    opacity: 0.5;
    cursor: default;
}

.district-hanley { --district-color: #2563eb; }
.district-burslem { --district-color: #dc2626; }
.district-stoke { --district-color: #16a34a; }
.district-tunstall { --district-color: #9333ea; }
.district-fenton { --district-color: #ea580c; }
.district-longton { --district-color: #0891b2; }
.district-newcastle { --district-color: #be123c; }
.district-biddulph { --district-color: #4f46e5; }
.district-kidsgrove { --district-color: #0f766e; }

#reset-filters {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f1f5f9;
    cursor: pointer;
}

#reset-filters img,
#hide-menu img,
#show-menu img {
    display: block;
    width: 20px;
    height: 20px;
}

#filter-results { color: #475569; }

.case-marker-icon {
    transition: filter 140ms ease, transform 140ms ease;
}

.case-marker-icon.active {
    filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 9px #2563eb);
    transform: scale(1.18) translateY(-4px);
    transform-origin: bottom center;
}

.case-details { overflow-wrap: anywhere; padding-right: 28px; }
.case-details h3 { margin: 0 0 8px; font-size: 18px; line-height: 1.25; }
.case-details-meta { margin-bottom: 8px; color: #64748b; font-size: 12px; line-height: 1.3; }
.case-details-date-category { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.case-details-date, .case-details-location, .case-details-category { overflow-wrap: anywhere; }
.case-details-category { margin-left: auto; text-align: right; }
.case-details-location { margin-top: 3px; }
.case-details .case-description { white-space: pre-wrap; margin: 12px 0; }
.case-details .case-links { display: grid; gap: 6px; margin-top: 10px; }
.case-source-link {
    color: #2563eb;
    font-size: 12px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.case-details .case-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; color: #64748b; font-size: 12px; }
.case-tag { display: inline-flex; align-items: center; padding: 3px 7px; border: 1px solid #cbd5e1; border-radius: 999px; background: #f1f5f9; color: #475569; font: inherit; line-height: 1.2; }
button.case-tag { cursor: pointer; }
.case-tag.district-tag { border-color: currentColor; background: transparent; color: var(--district-color); }
.case-tag.district-tag:hover, .case-tag.district-tag:focus-visible { background: var(--district-color); color: #fff; }
.case-category-pill {
    --category-color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border: 1px solid var(--category-color);
    border-radius: 999px;
    background: color-mix(in srgb, var(--category-color) 12%, white);
    color: var(--category-color);
    font: inherit;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
}
.case-category-pill:hover, .case-category-pill:focus-visible { background: var(--category-color); color: #fff; }
.category-icon-arson { --category-color: #f97316; }
.category-icon-assault { --category-color: #7c3aed; }
.category-icon-burglary { --category-color: #16a34a; }
.category-icon-disturbing-the-peace { --category-color: #16a34a; }
.category-icon-drugs-alcohol-violations { --category-color: #06b6d4; }
.category-icon-dui { --category-color: #e11d48; }
.category-icon-fraud { --category-color: #f97316; }
.category-icon-homicide { --category-color: #dc2626; }
.category-icon-motor-vehicle-theft { --category-color: #2563eb; }
.category-icon-road-accident { --category-color: #2563eb; }
.category-icon-robbery { --category-color: #eab308; }
.category-icon-sex-crimes { --category-color: #14b8a6; }
.category-icon-theft { --category-color: #d946ef; }
.category-icon-vandalism { --category-color: #c2410c; }
.category-icon-weapons { --category-color: #2563eb; }

#map-menu [hidden] { display: none !important; }

#filter-navigation {
    margin-top: 10px;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
}
#filter-navigation a {
    display: block;
    padding: 10px 8px;
    border-radius: 4px;
    color: #1f2937;
    text-decoration: none;
}
#filter-navigation a:hover { background: #f1f5f9; }
#filter-navigation a:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.filter-navigation-logo {
    display: block;
    width: min(200px, 100%);
    height: auto;
    margin: 0 auto;
}
.menu-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
#hide-menu { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid #cbd5e1; border-radius: 4px; background: #f1f5f9; cursor: pointer; }
#show-menu { position: absolute; top: 5px; right: 5px; z-index: 1000; display: flex; align-items: center; justify-content: center; gap: 4px; width: 72px; height: 44px; border: 0; border-radius: 6px; background: rgba(255, 255, 255, 0.9); font-size: 24px; cursor: pointer; box-shadow: 0 1px 5px rgba(0,0,0,.3); }
#map-menu button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }


#case-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    max-height: 40vh;
    max-height: 40dvh;
    overflow: hidden;
    box-sizing: border-box;
    padding: 28px 0 0;
    background: white;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.24);
    font: 14px/1.45 Arial, sans-serif;
    transform: translateY(100%);
    transition: transform 180ms ease;
}

#case-panel.dragging {
    transition: none;
    user-select: none;
}

#case-panel.resized {
    max-height: 90vh;
    max-height: 90dvh;
}

#case-panel.expanded { height: 90vh; height: 90dvh; max-height: 90vh; max-height: 90dvh; }
#case-panel-content { overflow-y: auto; min-height: 0; padding: 12px 18px calc(18px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.case-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; flex: 0 0 auto; padding: 4px 12px 8px 18px; border-bottom: 1px solid #e2e8f0; }
.case-panel-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.case-panel-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; }
.case-panel-actions button { border: 0; background: transparent; color: #0054a6; text-decoration: none; font: inherit; padding: 4px; cursor: pointer; }
.case-panel-actions button:focus-visible, .case-panel-actions .case-panel-icon-button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.case-panel-actions .case-panel-icon-button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 4px; border: 0; background: transparent; color: inherit; text-decoration: none; cursor: pointer; }
.case-panel-actions .case-panel-icon-button img { display: block; width: 26px; height: 26px; object-fit: contain; }
.case-panel-actions .case-panel-icon-button[hidden] { display: none; }
#case-panel-content .case-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#case-panel-content .case-images img { max-width: 100%; height: auto; }
#case-panel-content .case-images figure { margin: 0; }
#case-panel-content .case-description { white-space: pre-line; }

#case-panel.open {
    transform: translateY(0);
}

#case-panel[hidden] {
    display: block !important;
    visibility: hidden;
}

.site-panel-content { max-width: 760px; margin: 0 auto; border: 0 !important; box-shadow: none !important; background: transparent !important; }
.site-panel-content > .banner {
    display: block;
    width: min(420px, 100%);
    height: auto;
    margin: 0 auto 20px;
}
#case-panel-content [hidden] { display: none !important; }
.site-panel-content h1, .site-panel-content h2 { margin: 0 28px 16px 0; font-size: 16px; }
.site-panel-content label { display: block; margin: 16px 0 6px; font-weight: 600; }
.site-panel-content input:not([type="hidden"]), .site-panel-content textarea {
    box-sizing: border-box; width: 100%; padding: 10px; border: 1px solid #94a3b8;
    border-radius: 6px; background: white; color: inherit; font: inherit;
}
.site-panel-content textarea { height: 3.2em; min-height: 3.2em; resize: vertical; }
.site-panel-content .hint { margin-top: 6px; font-size: 13px; color: #475569; }
.site-panel-content .actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.site-panel-content .actions { justify-content: center; }
.site-panel-content .action {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px;
    border: 1px solid #cbd5e1; border-radius: 6px; background: #f1f5f9; color: #1f2937;
    font: inherit; cursor: pointer;
}
.site-panel-content .action img { width: 24px; height: 24px; }
.site-panel-content .send { background: #dbeafe; border-color: #93c5fd; }
.site-panel-content .action:disabled { opacity: .6; cursor: wait; }
.site-panel-content form { border: 0; box-shadow: none; }
.site-panel-content .notice, .page-load-error { padding: 14px; border-radius: 6px; overflow-wrap: anywhere; }
.site-panel-content .error, .page-load-error { background: #fee2e2; color: #991b1b; }
.site-panel-content .success { background: #dcfce7; color: #166534; }
.site-panel-content .trap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.site-panel-content :is(button, input, textarea):focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

.case-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.case-gallery-photo {
    display: block;
    padding: 0;
    border: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #e2e8f0;
    cursor: zoom-in;
    aspect-ratio: 4 / 3;
    min-width: 0;
}
.case-gallery-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.case-gallery-photo:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
#case-panel-content .case-images-carousel { max-width: 900px; margin-inline: auto; }
#case-panel-content .case-images-carousel .carousel-inner { background: #f6f8fb; border-radius: .5rem; }
#case-panel-content .case-images-carousel .carousel-item img { width: 100%; max-height: 70vh; object-fit: contain; }
#case-panel-content .case-carousel-caption { padding: .75rem 1rem; text-align: center; overflow-wrap: anywhere; }
#case-panel-content .case-carousel-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .75rem; margin-top: .75rem; }
#case-panel-content .case-carousel-indicators { position: static; display: flex; gap: .35rem; width: auto; margin: 0; }
#case-panel-content .case-carousel-indicators button { width: 2.25rem; height: 2.25rem; margin: 0; border: 1px solid #dce1e7; border-radius: .25rem; background: white; color: #0054a6; text-indent: 0; opacity: 1; }
#case-panel-content .case-carousel-indicators button.active { background: #0054a6; color: white; }
#case-panel-content .case-youtube-videos { max-width: 900px; margin: 1.25rem auto; }
#case-panel-content .case-youtube-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
#case-panel-content .case-youtube-link { display: block; color: inherit; text-decoration: none; }
#case-panel-content .case-youtube-link img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 1px solid #dce1e7; border-radius: .5rem; }
#case-panel-content .case-youtube-link span { display: block; padding-top: .5rem; overflow-wrap: anywhere; }
#case-panel-content .case-youtube-link:hover span, #case-panel-content .case-youtube-link:focus-visible span { color: #0054a6; text-decoration: underline; }
#case-panel-content .case-public-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }
#case-panel-content .case-correction-link { display: inline-flex; align-items: center; gap: .5rem; color: #0054a6; text-decoration: none; }
#case-panel-content .case-correction-link img { width: 24px; height: 24px; object-fit: contain; }
#case-panel-content .case-correction-link:hover, #case-panel-content .case-correction-link:focus-visible { text-decoration: underline; }
.case-lightbox {
    box-sizing: border-box;
    width: min(90vw, 1000px);
    max-width: 90vw;
    max-height: 94vh;
    padding: 48px 16px 16px;
    border: 0;
    border-radius: 12px;
    background: #0f172a;
    color: #fff;
}
.case-lightbox::backdrop { background: rgb(0 0 0 / 80%); }
.case-lightbox figure { margin: 0; }
.case-lightbox figure img { display: block; width: 100%; max-width: 100%; max-height: 76vh; object-fit: contain; margin: auto; }
.case-lightbox figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; overflow-wrap: anywhere; font: 14px/1.5 Arial, sans-serif; }
.case-lightbox-caption-text { flex: 1 1 auto; text-align: center; }
.case-lightbox-navigation { display: flex; justify-content: flex-end; gap: 6px; flex: 0 0 auto; }
.case-lightbox-navigation[hidden] { display: none; }
.case-lightbox-navigation button { width: 29px; height: 29px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.case-lightbox-navigation button img { display: block !important; width: 80% !important; height: 80% !important; max-width: none !important; max-height: none !important; margin: auto; object-fit: contain; visibility: visible !important; opacity: 1 !important; }
.case-lightbox figcaption .case-lightbox-navigation button img { width: 80%; height: 80%; max-width: none; max-height: none; visibility: visible; opacity: 1; }
.case-lightbox-navigation button:hover { background: #475569; }
.case-lightbox-navigation button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.case-lightbox-close {
    position: absolute; right: 8px; top: 6px; width: 36px; height: 36px;
    border: 0; border-radius: 50%; background: #334155; color: white;
    font-size: 28px; cursor: pointer;
}
.case-lightbox-close:focus-visible { outline: 3px solid #93c5fd; }
@media (max-width: 420px) { .case-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

#case-panel-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 74px;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    transform: translateX(-50%);
    cursor: ns-resize;
    touch-action: none;
}

#case-panel-handle::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: #cbd5e1;
    transform: translateX(-50%);
}

#case-panel-handle:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -4px;
}

#case-panel-close:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

@media (min-width: 720px) {
    #case-panel {
        left: 50%;
        right: auto;
        width: min(680px, calc(100vw - 40px));
        transform: translate(-50%, 100%);
    }

    #case-panel.open {
        transform: translate(-50%, 0);
    }
}
.site-panel-content .close,
.site-panel-content .back,
.site-panel-content .back-link { display: none !important; }
.case-lightbox-close img { display: block !important; width: 80% !important; height: 80% !important; max-width: none !important; max-height: none !important; margin: auto; object-fit: contain; visibility: visible !important; opacity: 1 !important; }
.case-lightbox-close > img { max-width: none; max-height: none; visibility: visible; opacity: 1; }

#case-panel.case-page {
    left: 50%;
    right: auto;
    width: min(680px, calc(100vw - 40px));
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    transform: translate(-50%, 100%);
}

#case-panel.case-page.open { transform: translate(-50%, 0); }
body:has(#case-panel.case-page.open) #map-menu { display: none; }
body:has(#case-panel.case-page.open) #map .leaflet-marker-pane,
body:has(#case-panel.case-page.open) #map .leaflet-shadow-pane,
body:has(#case-panel.case-page.open) #map .leaflet-tooltip-pane { display: none; }
#case-panel.case-page .site-panel-content { max-width: none; }
.info-page { height: 60vh; max-height: 60vh; }
.case-location-map { height: 260px; margin: 1rem 0; border-radius: 8px; overflow: hidden; }
.site-panel-content .case-meta { margin-bottom: 1rem; }
.site-panel-content .case-meta-row { display: flex; justify-content: space-between; gap: 1rem; }
.site-panel-content .case-meta-location { margin-top: .25rem; }
#case-panel.case-page.expanded {
    bottom: 5vh;
    bottom: 5dvh;
    height: 90vh;
    height: 90dvh;
    max-height: 90vh;
    max-height: 90dvh;
}
