:root {
    color-scheme: dark;

    --bg: #000000;

    --panel: #1c1c1e;
    --panel-soft: #242426;
    --panel-strong: #2c2c2e;

    --text: #f5f5f7;
    --muted: #8e8e93;
    --muted-soft: #636366;

    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.12);

    --accent: #f5f5f7;
    --accent-text: #111111;

    --switch-on: #34c759;

    --button-hover: #3a3a3c;
}


* {
    box-sizing: border-box;
}


html,
body {
    margin: 0;

    background: var(--bg);
    color: var(--text);
}


body {
    padding-bottom: 0px;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Display",
        "SF Pro Text",
        "Pretendard",
        "Segoe UI",
        sans-serif;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}


button,
input,
a {
    font: inherit;

    -webkit-tap-highlight-color: transparent;
}


button {
    appearance: none;
}


[hidden] {
    display: none !important;
}


/* ==========================================================
   Layout
========================================================== */

.wrap {
    width: min(1100px, calc(100% - 28px));

    margin: 0 auto;

    padding: 32px 0 60px;
}


/* ==========================================================
   Header
========================================================== */

header {
    margin-bottom: 22px;
}


h1 {
    margin: 0 0 6px;

    font-size: 28px;
    font-weight: 750;

    letter-spacing: -0.035em;
}


.subtitle {
    margin: 0;

    color: var(--muted);

    font-size: 14px;
    line-height: 1.5;
}


.developer {
    margin: 8px 0 0;

    color: var(--muted-soft);

    font-size: 11px;
    line-height: 1.4;
}


.developer a {
    color: var(--muted);

    text-decoration: none;

    transition: color 0.15s ease;
}


.developer a:hover {
    color: var(--text);
}


/* ==========================================================
   Control Panel
========================================================== */

.control-panel {
    padding: 14px;

    margin-bottom: 12px;

    background: var(--panel);

    border: 1px solid var(--line);
    border-radius: 18px;
}


/* ==========================================================
   Main Tabs
========================================================== */

.tabs {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 3px;

    padding: 3px;

    margin-bottom: 12px;

    background: rgba(118, 118, 128, 0.24);

    border-radius: 11px;
}


.tab-btn {
    border: 0;
    border-radius: 8px;

    padding: 9px 10px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    font-size: 13px;
    font-weight: 650;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease;
}


.tab-btn.active {
    background: #3a3a3c;
    color: var(--text);

    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.3),
        0 0 0 0.5px rgba(255, 255, 255, 0.04);
}


/* ==========================================================
   Region Search
========================================================== */

.search-wrap {
    position: relative;

    z-index: 1200;

    margin-bottom: 14px;
}


.region-search {
    width: 100%;

    border: 1px solid var(--line);
    border-radius: 12px;

    padding: 11px 13px;

    outline: none;

    background: var(--panel-soft);
    color: var(--text);

    font-size: 13px;

    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}


.region-search::placeholder {
    color: var(--muted);
}


.region-search:focus {
    background: var(--panel-strong);

    border-color: rgba(255, 255, 255, 0.2);
}


.search-results {
    position: absolute;

    top: calc(100% + 6px);
    left: 0;
    right: 0;

    max-height: 260px;

    overflow-y: auto;

    padding: 5px;

    background: rgba(36, 36, 38, 0.98);

    border: 1px solid var(--line-strong);
    border-radius: 13px;

    box-shadow:
        0 14px 35px rgba(0, 0, 0, 0.48);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}


.search-result {
    width: 100%;

    border: 0;
    border-radius: 9px;

    padding: 10px 11px;

    background: transparent;
    color: var(--text);

    cursor: pointer;

    text-align: left;

    font-size: 12px;

    transition: background 0.12s ease;
}


.search-result:hover,
.search-result.active {
    background: rgba(255, 255, 255, 0.08);
}


.search-empty {
    padding: 10px 11px;

    color: var(--muted);

    font-size: 12px;
}


/* ==========================================================
   Labels
========================================================== */

.filter-label {
    margin: 0 0 8px 2px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 650;
}


/* ==========================================================
   Crime Header
========================================================== */

.crime-category-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;

    margin-bottom: 8px;
}


.crime-category-header .filter-label {
    margin: 0;
}


/* ==========================================================
   Integrity Header
========================================================== */

.integrity-header {
    display: flex;

    align-items: center;

    gap: 4px;

    margin-bottom: 8px;
}


.integrity-header .filter-label {
    margin: 0;
}


/* ==========================================================
   Filter Buttons
========================================================== */

.filters {
    display: flex;

    flex-wrap: wrap;

    gap: 7px;
}


.filter-btn {
    border: 1px solid var(--line);
    border-radius: 999px;

    padding: 7px 11px;

    background: var(--panel-soft);
    color: var(--muted);

    cursor: pointer;

    font-size: 12px;
    font-weight: 550;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease,
        transform 0.12s ease;
}


.filter-btn:hover {
    background: var(--panel-strong);
}


.filter-btn:active {
    transform: scale(0.97);
}


.filter-btn.active {
    background: var(--accent);
    color: var(--accent-text);

    border-color: var(--accent);

    font-weight: 700;
}


/* ==========================================================
   Other Crime Toggle
========================================================== */

.other-option {
    display: flex;

    align-items: center;

    gap: 4px;

    margin: 0;

    white-space: nowrap;
}


.switch-row {
    display: inline-flex;

    align-items: center;

    gap: 6px;

    cursor: pointer;

    user-select: none;
}


.switch-row input {
    position: absolute;

    opacity: 0;

    pointer-events: none;
}


.switch {
    position: relative;

    width: 34px;
    height: 20px;

    flex: 0 0 34px;

    border-radius: 999px;

    background: #3a3a3c;

    transition: background 0.16s ease;
}


.switch::after {
    content: "";

    position: absolute;

    top: 2px;
    left: 2px;

    width: 16px;
    height: 16px;

    border-radius: 50%;

    background: #ffffff;

    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.35);

    transition: transform 0.16s ease;
}


.switch-row input:checked+.switch {
    background: var(--switch-on);
}


.switch-row input:checked+.switch::after {
    transform: translateX(14px);
}


.switch-label {
    color: var(--muted);

    font-size: 10px;
    font-weight: 600;

    white-space: nowrap;
}


/* ==========================================================
   Info Button
========================================================== */

.info-btn {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    border: 0;

    padding: 3px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    font-size: 12px;
    line-height: 1;

    touch-action: none;

    transition:
        color 0.15s ease,
        transform 0.1s ease;
}


.info-btn:hover {
    color: var(--text);
}


.info-btn:active,
.info-btn.is-pressed {
    color: var(--text);

    transform: scale(0.92);
}


/* ==========================================================
   Press-and-hold Information
========================================================== */

.press-info {
    margin-top: 8px;

    padding: 10px 11px;

    background: var(--panel-soft);

    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.6;
}


.press-info strong {
    color: var(--text);

    font-weight: 650;
}


/* ==========================================================
   Crime Display Options
========================================================== */

.crime-options {
    margin-top: 13px;

    padding-top: 12px;

    border-top: 1px solid var(--line);
}


.metric-toggle {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 3px;

    width: min(290px, 100%);

    padding: 3px;

    background: rgba(118, 118, 128, 0.24);

    border-radius: 10px;
}


.metric-btn {
    min-width: 0;

    border: 0;
    border-radius: 7px;

    padding: 7px 10px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    font-size: 11px;
    font-weight: 650;

    white-space: nowrap;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        transform 0.12s ease;
}


.metric-btn:active {
    transform: scale(0.98);
}


.metric-btn.active {
    background: #3a3a3c;
    color: var(--text);

    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.24);
}


/* ==========================================================
   Map
========================================================== */

.map-card {
    position: relative;

    overflow: hidden;

    background: #111111;

    border: 1px solid var(--line);
    border-radius: 18px;
}


#map {
    width: 100%;
    height: 620px;

    background: #111111;
}


/* ==========================================================
   Detail Card
========================================================== */

.detail-card {
    position: absolute;

    left: 16px;
    bottom: 16px;

    width: min(390px, calc(100% - 32px));

    padding: 16px;

    background: rgba(28, 28, 30, 0.94);

    border: 1px solid var(--line-strong);
    border-radius: 16px;

    box-shadow:
        0 12px 34px rgba(0, 0, 0, 0.46);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);

    z-index: 700;
}


.detail-card h2 {
    margin: 0 34px 5px 0;

    color: var(--text);

    font-size: 18px;
    font-weight: 750;

    letter-spacing: -0.025em;
}


.detail-category {
    margin-bottom: 13px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 650;
}


.detail-stats {
    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 7px;
}


.detail-stat {
    min-width: 0;

    padding: 10px;

    background: rgba(255, 255, 255, 0.045);

    border: 1px solid rgba(255, 255, 255, 0.035);
    border-radius: 11px;
}


.detail-stat-label {
    margin-bottom: 5px;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.3;
}


.detail-stat-value {
    color: var(--text);

    font-size: 14px;
    font-weight: 700;

    line-height: 1.25;

    letter-spacing: -0.02em;

    word-break: keep-all;
}


.detail-items {
    margin-top: 11px;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.6;
}


/* ==========================================================
   Detail Close
========================================================== */

.detail-close {
    position: absolute;

    top: 10px;
    right: 10px;

    width: 28px;
    height: 28px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;

    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);

    cursor: pointer;

    font-size: 18px;
    font-weight: 400;
    line-height: 1;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        transform 0.12s ease;
}


.detail-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}


.detail-close:active {
    transform: scale(0.92);
}


/* ==========================================================
   Leaflet
========================================================== */

.leaflet-container {
    background: #111111;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Text",
        "Pretendard",
        "Segoe UI",
        sans-serif;
}


.leaflet-tooltip {
    padding: 6px 8px;

    background: rgba(28, 28, 30, 0.94);
    color: var(--text);

    border: 1px solid var(--line-strong);
    border-radius: 8px;

    box-shadow:
        0 5px 16px rgba(0, 0, 0, 0.35);

    font-size: 11px;
    font-weight: 650;
}


.leaflet-tooltip-top::before {
    border-top-color: rgba(28, 28, 30, 0.94);
}


/* ==========================================================
   Footer
========================================================== */

footer {
    margin-top: 24px;

    color: var(--muted-soft);

    text-align: center;

    font-size: 10px;
    line-height: 1.65;
}

/* ==========================================================
   Responsive
========================================================== */

@media (max-width: 640px) {

    .wrap {
        width: min(100% - 20px, 1100px);

        padding-top: 20px;
    }


    header {
        margin-bottom: 13px;
    }


    h1 {
        font-size: 24px;
    }


    .subtitle {
        font-size: 12px;
    }


    .developer {
        margin-top: 5px;

        font-size: 9px;
    }


    .control-panel {
        padding: 10px;

        margin-bottom: 8px;

        border-radius: 16px;
    }


    .tabs {
        margin-bottom: 8px;
    }


    .tab-btn {
        padding: 7px 8px;

        font-size: 12px;
    }


    .search-wrap {
        margin-bottom: 9px;
    }


    .region-search {
        padding: 8px 10px;

        border-radius: 10px;

        font-size: 11px;
    }


    .crime-category-header,
    .integrity-header {
        margin-bottom: 6px;
    }


    .filter-label {
        margin-bottom: 5px;

        font-size: 9px;
    }


    .filters {
        gap: 5px;
    }


    .filter-btn {
        padding: 5px 9px;

        font-size: 10px;
    }


    .switch {
        width: 30px;
        height: 18px;

        flex-basis: 30px;
    }


    .switch::after {
        width: 14px;
        height: 14px;
    }


    .switch-row input:checked+.switch::after {
        transform: translateX(12px);
    }


    .switch-label {
        font-size: 9px;
    }


    .info-btn {
        padding: 2px;

        font-size: 11px;
    }


    .press-info {
        margin-top: 6px;

        padding: 8px 9px;

        font-size: 8.5px;
    }


    .crime-options {
        margin-top: 9px;

        padding-top: 9px;
    }


    .metric-toggle {
        width: 100%;

        padding: 2px;
    }


    .metric-btn {
        padding: 6px 7px;

        font-size: 9px;
    }


    #map {
        height: 540px;
    }


    .detail-card {
        left: 10px;
        right: 10px;

        top: 10px;
        bottom: auto;

        width: auto;

        padding: 14px;
    }


    .detail-card h2 {
        font-size: 16px;
    }


    .detail-category {
        margin-bottom: 10px;

        font-size: 10px;
    }


    .detail-stat {
        padding: 9px 8px;
    }


    .detail-stat-value {
        font-size: 13px;
    }

}


@media (max-width: 420px) {

    #map {
        height: 500px;
    }


    .detail-stats {
        gap: 5px;
    }


    .detail-stat-label {
        font-size: 8px;
    }


    .detail-stat-value {
        font-size: 12px;
    }
}


@media (min-width: 900px) {

    .wrap {
        padding-top: 42px;
    }


    h1 {
        font-size: 30px;
    }
}