html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
}
#container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}
#map {
    flex: 1;
    min-width: 0;
    height: 100vh;
}
#filters-wrapper {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#search-filter, #class-filters {
    background: #fff;
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    max-width: 200px;
    min-width: 120px;
}
#search-filter {
    position: relative;
}
#search-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}
#search-input:focus {
    outline: none;
    border-color: #2196F3;
}
#station-count {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    text-align: center;
    font-weight: 500;
}
#sidebar-content img {
    cursor: zoom-in;
    height: 200px;
    width: auto;
    max-width: 100%;
    transition: box-shadow 0.2s;
}
#sidebar-content img:hover {
    box-shadow: 0 0 6px #2196F3;
}
#sidebar-content a:not(.broken-link) {
    color: #1168a8;
    font-weight: 500;
    text-decoration-line: underline;
    text-decoration-thickness: 1.5px;
    text-decoration-color: rgba(17, 104, 168, 0.35);
    text-underline-offset: 2px;
    border-radius: 2px;
}
#sidebar-content a:not(.broken-link):hover,
#sidebar-content a:not(.broken-link):focus {
    color: #0b4f7d;
    text-decoration-color: currentColor;
    background: #edf7ff;
}
#sidebar-content a:not(.broken-link):focus-visible {
    outline: 2px solid #86c5f4;
    outline-offset: 2px;
}
.broken-link {
    color: #b42318;
    font-weight: 600;
    background: #fff1f0;
    border: 1px solid #ffb4a8;
    border-radius: 3px;
    padding: 1px 4px;
}

#sidebar-content del,
#sidebar-content del + strong {
    color: #b42318;
    font-weight: 600;
    background: #fff1f0;
}

#sidebar-content del + strong {
    margin-left: 4px;
}
#sidebar,
#sidebar-content {
    word-break: break-word;
    overflow-wrap: anywhere; /* safe fallback for extra-long URLs */
}
#sidebar {
    width: 400px;
    min-width: 220px;
    max-width: 600px;
    background: #fff;
    padding: 16px;
    overflow-y: auto;
    display: none;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    position: relative;
    box-sizing: border-box;
    z-index: 1500;
}
.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    background: rgba(0,0,0,0.05);
    z-index: 10;
}
#close-btn {
    cursor: pointer;
    background: #ddd;
    border: none;
    padding: 6px 12px;
    margin-bottom: 12px;
    font-size: 16px;
    float: right;
}
.leaflet-tile-pane.grayscale {
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
    transition: filter 0.3s ease;
}
.icon-filter-img {
    width: 32px;
    height: 32px;
    margin: 3px;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
    opacity: 0.5;
    border-radius: 4px;
}
.icon-filter-img.selected {
    opacity: 1;
    box-shadow: 0 0 4px #2196F3;
}
.class-filter-actions {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}
.class-filter-btn {
    cursor: pointer;
    padding: 2px 10px;
    background: #eee;
    border-radius: 5px;
    border: 1px solid #bbb;
    font-size: 14px;
    transition: background 0.2s;
    user-select: none;
}
.class-filter-btn:hover {
    background: #d0e7fa;
}
#filter-toggle-btn {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    padding: 10px 16px;
    font-size: 16px;
    border-radius: 30px;
    background-color: #2196F3;
    color: white;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
#filter-modal {
    display: none;
    position: fixed;
    top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,0.5);
    z-index: 1200;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
}
#filter-modal .modal-content {
    background: white;
    max-width: 320px;
    width: 90vw;
    border-radius: 8px;
    padding: 16px;
    max-height: 80vh;
    overflow-y: auto;
    margin: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    position: relative;
}
#filter-modal-close {
    float: right;
    font-size: 20px;
    border: none;
    background: none;
    cursor: pointer;
}
#modal-station-count {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    text-align: center;
    font-weight: 500;
}
@media (max-width: 600px) {
    #search-filter, #class-filters {
        display: none !important;
    }
    #filter-toggle-btn {
        display: block !important;
    }
    #sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        height: 60vh;
        width: 100vw;
        max-width: none;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -2px 8px #bbb;
        padding-top: 30px;
        padding-bottom: 40px;
        display: none;
        z-index: 1500;
        box-sizing: border-box;
    }
    #container {
        flex-direction: column;
    }
    #map {
        height: 100vh;
    }
    .resize-handle {
        display: none;
    }
    .resize-bar-mobile {
        width: 50px;
        height: 18px;
        background: #bbb;
        border-radius: 3px;
        margin: 0 auto;
        cursor: ns-resize;
        touch-action: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        z-index: 1510;
    }
}

/* Hide the default overlay checkbox for Grayscale (and optionally for other overlays) */
.leaflet-control-layers label:has(input[type="checkbox"]) input[type="checkbox"] {
  display: none !important;
}

/* Make label look like an icon filter image box */
.leaflet-control-layers label:has(input[type="checkbox"]) {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(33,150,243,0.10);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 10px 2px 2px;
  cursor: pointer;
  min-width: 38px;
  min-height: 38px;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-size: 15px;
  /* If you want to mimic the opacity of .icon-filter-img, add: */
  opacity: 0.5;
}

/* Inject your grayscale icon before the label text */
.leaflet-control-layers label:has(input[type="checkbox"])::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 28px;
  margin-right: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f0f0f0 0%, #bbb 50%, #444 100%);
  box-shadow: 0 0 0 1px #bbb inset, 0 1px 4px #ccc;
}

/* Style it blue like .icon-filter-img.selected when checked */
.leaflet-control-layers label:has(input[type="checkbox"]:checked) {
  border-color: #2196F3;
  box-shadow: 0 0 4px #2196F3;
  opacity: 1;
}

/* On hover, always show blue highlight as hover feedback (optional) */
.leaflet-control-layers label:has(input[type="checkbox"]):hover {
  border-color: #2196F3;
  box-shadow: 0 0 4px #2196F3;
  opacity: 1;
}

#image-viewer-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0,0,0,0.85);
z-index: 1600;
justify-content: center;
align-items: center;
}

#image-viewer-content {
position: relative;
max-width: 80vw;
max-height: 80vh;
display: flex;
align-items: center;
justify-content: center;
user-select: none;
}

#image-viewer-close,
#image-viewer-prev,
#image-viewer-next {
position: absolute;
background: none;
border: none;
color: white;
cursor: pointer;
user-select: none;
}

#image-viewer-close {
top: 10px;
right: 18px;
z-index: 1700;
font-size: 30px;
}

#image-viewer-prev,
#image-viewer-next {
font-size: 48px;
}

#image-viewer-prev {
left: 10px;
}

#image-viewer-next {
right: 10px;
}

#image-viewer-img {
max-width: 100%;
max-height: 100%;
box-shadow: 0 0 20px white;
border-radius: 4px;
}

#modal-search-filter {
margin-bottom: 12px;
}

#modal-search-input {
width: 100%;
padding: 6px 8px;
border: 1px solid #bbb;
border-radius: 4px;
font-size: 14px;
box-sizing: border-box;
}
