:root {
    color-scheme: light;
    --bg: #f3f4f6;
    --panel: rgba(255, 255, 255, 0.95);
    --border: #d1d5db;
    --text: #111827;
    --muted: #6b7280;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b91c1c;
    --map-control-border: rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Instrument Sans", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 36%),
        radial-gradient(circle at top right, rgba(30, 64, 175, 0.16), transparent 30%),
        var(--bg);
    color: var(--text);
    overflow: hidden;
}

.page {
    height: 100vh;
    padding: 1rem;
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    overflow: hidden;
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 20px;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(14px);
}

.sidebar {
    padding: 1rem;
    height: calc(100vh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
}

h1 {
    margin: 0;
    font-size: clamp(1.7rem, 4.3vw, 2.35rem);
    line-height: 1.05;
}

.intro {
    margin: 0.65rem 0 0.95rem;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.95rem;
}

.hint {
    margin: 0 0 0.85rem;
    padding: 0.75rem 0.85rem;
    border-radius: 14px;
    background: rgba(15, 118, 110, 0.08);
    color: var(--primary-dark);
    font-size: 0.95rem;
}

.alert {
    display: none;
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    font-size: 0.92rem;
}

.alert.is-visible {
    display: block;
}

.alert-success {
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
}

.alert-error {
    background: rgba(185, 28, 28, 0.12);
    color: var(--danger);
}

form {
    display: grid;
    gap: 0.72rem;
}

label {
    display: grid;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 600;
}

input,
textarea,
select,
.report-submit-button {
    font: inherit;
}

input,
textarea,
select {
    width: 100%;
    padding: 0.68rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.coordinates {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-submit-button {
    padding: 0.78rem 0.95rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease;
    box-shadow: 0 12px 25px rgba(15, 118, 110, 0.25);
}

.report-submit-button:hover {
    transform: translateY(-1px);
}

.report-submit-button:disabled {
    cursor: wait;
    opacity: 0.7;
    transform: none;
}

.map-shell {
    height: calc(100vh - 2rem);
    overflow: hidden;
    position: relative;
}

#report-map {
    width: 100%;
    height: 100%;
}

.leaflet-popup-content {
    max-width: min(301px, calc(100vw - 80px));
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
}

.report-popup-content,
.report-popup-content * {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
}

.report-popup-action {
    cursor: pointer;
    transition: opacity 120ms ease, filter 120ms ease;
}

.report-popup-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
    padding-top: 0.55rem;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.96) 32%,
        rgba(255, 255, 255, 0.98)
    );
}

.report-popup-action-confirm {
    background: #0f766e;
}

.report-popup-action-clear {
    background: #92400e;
}

.report-popup-action:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    filter: saturate(0.75);
}

.map-location-button {
    border: 2px solid var(--map-control-border);
    border-radius: 999px;
    width: 43px;
    height: 43px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.96);
    color: var(--primary-dark);
    font: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    cursor: pointer !important;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
    text-align: center;
}

.map-location-button:hover,
.map-location-button:focus {
    background: #f8fafc;
    outline: none;
}

.map-location-button svg {
    width: 1.2rem;
    height: 1.2rem;
    display: block;
}

.leaflet-control-geocoder {
    display: flex;
    align-items: center;
    gap: 0.28rem;
    width: min(320px, calc(100vw - 2.5rem));
    max-width: 320px;
    padding: 0.28rem;
    border: 1px solid var(--map-control-border);
    border-radius: 16px;
    overflow: visible;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
    background: rgba(255, 255, 255, 0.98);
    position: relative;
    z-index: 800;
}

.leaflet-control-container .leaflet-top.leaflet-left,
.leaflet-control-container .leaflet-left.leaflet-top {
    padding: 0.75rem 0 0 0.75rem;
}

.leaflet-control-geocoder form {
    display: flex;
    align-items: center;
    margin: 0;
    gap: 0.28rem;
    min-width: 0;
}

.leaflet-control-geocoder-form {
    flex: 1 1 auto;
    min-width: 0;
}

.leaflet-control-geocoder .leaflet-control-geocoder-alternatives {
    display: none !important;
}

.leaflet-control-geocoder-form input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 2.35rem;
    border: 0;
    border-radius: 12px;
    padding: 0 0.75rem;
    background: #ffffff;
    color: var(--text);
    font-size: 0.95rem;
}

.leaflet-control-geocoder-icon {
    width: 2.35rem;
    height: 2.35rem;
    border: 0;
    border-radius: 12px;
    padding: 0;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: none;
    transform: none;
    transition: none;
}

.leaflet-control-geocoder-icon:hover,
.leaflet-control-geocoder-icon:focus,
.leaflet-control-geocoder-icon:active {
    background-color: #ffffff;
    box-shadow: none;
    transform: none;
}

.leaflet-control-container .leaflet-top.leaflet-left .leaflet-control,
.leaflet-control-container .leaflet-left.leaflet-top .leaflet-control,
.leaflet-control-container .leaflet-bottom.leaflet-left .leaflet-control,
.leaflet-control-container .leaflet-left.leaflet-bottom .leaflet-control,
.leaflet-control-container .leaflet-bottom.leaflet-right .leaflet-control,
.leaflet-control-container .leaflet-right.leaflet-bottom .leaflet-control {
    margin: 0;
}

.leaflet-control-container .leaflet-top.leaflet-left .leaflet-control + .leaflet-control,
.leaflet-control-container .leaflet-left.leaflet-top .leaflet-control + .leaflet-control {
    margin-top: 0.875rem;
}

.leaflet-control-container .leaflet-bottom.leaflet-left,
.leaflet-control-container .leaflet-left.leaflet-bottom {
    padding: 0 0 0.75rem 0.75rem;
}

.leaflet-control-container .leaflet-bottom.leaflet-right,
.leaflet-control-container .leaflet-right.leaflet-bottom {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 0 0.75rem 0.75rem 0;
}

.leaflet-control-container .leaflet-bottom.leaflet-right .map-location-button,
.leaflet-control-container .leaflet-right.leaflet-bottom .map-location-button {
    order: 1;
}

.leaflet-control-container .leaflet-bottom.leaflet-right .leaflet-control-zoom,
.leaflet-control-container .leaflet-right.leaflet-bottom .leaflet-control-zoom {
    order: 2;
}

.leaflet-control-container .leaflet-bottom.leaflet-right .leaflet-control-attribution,
.leaflet-control-container .leaflet-right.leaflet-bottom .leaflet-control-attribution {
    order: 3;
}

.leaflet-control-zoom.leaflet-bar {
    border: 2px solid var(--map-control-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
}

.leaflet-control-zoom.leaflet-bar a {
    width: 2.45rem;
    height: 2.45rem;
    line-height: 2.45rem;
    border-color: var(--map-control-border);
    color: #0f172a;
    background: #ffffff;
}

.leaflet-control-zoom.leaflet-bar a:hover,
.leaflet-control-zoom.leaflet-bar a:focus {
    background: #f8fafc;
}

.geocoder-result-icon span {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 3px solid #ffffff;
    background: #0f766e;
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.2);
}

.geocoder-suggestions {
    list-style: none;
    margin: 0;
    padding: 0.25rem;
    width: 100%;
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    max-height: 240px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 26px rgba(15, 23, 42, 0.12);
    z-index: 801;
}

.geocoder-suggestion-item {
    width: 100%;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 0.5rem 0.65rem;
    cursor: pointer;
    font-size: 0.88rem;
    line-height: 1.35;
}

.geocoder-suggestion-item:hover,
.geocoder-suggestion-item:focus {
    background: rgba(15, 118, 110, 0.1);
    outline: none;
}

.geocoder-suggestion-item.is-active {
    background: rgba(15, 118, 110, 0.14);
}

.legend {
    margin-top: 0.9rem;
    display: grid;
    gap: 0.42rem;
}

.utility-links {
    margin-top: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.utility-links a {
    color: var(--primary-dark);
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.legend-icon {
    width: 20px;
    height: 20px;
    color: #334155;
    flex: 0 0 auto;
}

.legend-icon-svg,
.popup-category-icon-svg,
.category-marker-icon-svg {
    display: block;
    width: 100%;
    height: 100%;
}

.category-marker-icon {
    background: transparent;
    border: 0;
}

.category-marker-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.18);
}

.category-marker-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #ffffff;
}

.category-marker-icon-svg {
    width: 20px;
    height: 20px;
}

.popup-category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #475569;
    flex: 0 0 auto;
}

.current-location-icon {
    background: transparent;
    border: 0;
}

.current-location-dot {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.95);
    background: #3b82f6;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.22);
}

.map-cluster {
    background: transparent;
    border: 0;
}

.map-cluster div {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.95);
    background: #14b8a6;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-cluster span {
    color: #ffffff;
    font-weight: 800;
    font-size: 0.86rem;
    line-height: 1;
    display: block;
}

.map-cluster.cluster-small div {
    background: #22c55e;
}

.map-cluster.cluster-medium div {
    background: #f59e0b;
}

.map-cluster.cluster-large div {
    background: #ef4444;
}

@media (max-width: 960px) {
    body {
        overflow: auto;
    }

    .page {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: 2;
        height: auto;
        overflow: visible;
    }

    .map-shell {
        order: 1;
    }

    .map-shell,
    #report-map {
        min-height: 60vh;
        height: 60vh;
    }

    .geocoder-suggestions {
        width: 100%;
        max-height: min(38vh, 260px);
    }

}

@media (max-height: 860px) and (min-width: 961px) {
    .sidebar {
        padding: 0.9rem;
    }

    .intro {
        margin: 0.55rem 0 0.8rem;
        font-size: 0.92rem;
    }

    .hint {
        margin-bottom: 0.7rem;
        padding: 0.65rem 0.75rem;
        font-size: 0.9rem;
    }

    form {
        gap: 0.62rem;
    }

    textarea {
        min-height: 84px;
    }

    .legend,
    .utility-links {
        margin-top: 0.7rem;
    }
}

@media (max-width: 768px) {
    .leaflet-control-container .leaflet-top.leaflet-left,
    .leaflet-control-container .leaflet-left.leaflet-top {
        left: 0.6rem;
        right: 0.6rem;
        padding: 0.6rem 0 0;
    }

    .leaflet-control-container .leaflet-bottom.leaflet-left,
    .leaflet-control-container .leaflet-left.leaflet-bottom {
        padding: 0 0 calc(2.2rem + env(safe-area-inset-bottom, 0px)) 0.6rem;
    }

    .leaflet-control-container .leaflet-bottom.leaflet-right,
    .leaflet-control-container .leaflet-right.leaflet-bottom {
        padding: 0 0.6rem calc(2.2rem + env(safe-area-inset-bottom, 0px)) 0;
    }

    .leaflet-control-geocoder {
        width: 100%;
        max-width: none;
    }

    .leaflet-control-geocoder-form input {
        font-size: 16px;
    }

    .geocoder-suggestions {
        width: 100%;
        max-height: min(34vh, 220px);
    }
}

@media (max-width: 600px) {
    .leaflet-control-geocoder {
        width: 100%;
        max-width: none;
    }

    .geocoder-suggestions {
        width: 100%;
        max-height: min(32vh, 220px);
    }
}
