:root {
    --parchment: #f0e6c8;
    --gold: #c8963c;
    --dark: #0d0a06;
    --panel: rgba(13, 10, 5, 0.92);
    --border: rgba(200, 150, 60, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    width: 100%;
    font-family: 'Crimson Pro', serif;
    background: var(--dark);
    color: var(--parchment);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── HEADER ── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px;
    background: linear-gradient(135deg, #0d0a06, #1c1208 60%, #0f0d08);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}

.brand-de {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 22px;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(200, 150, 60, .35);
    letter-spacing: 2px;
}

.brand-ru {
    font-family: 'IM Fell English SC', serif;
    font-size: 9px;
    opacity: .5;
    letter-spacing: 2px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.cg {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cg>label {
    font-family: 'IM Fell English SC', serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--gold);
    opacity: .7;
}

select {
    background: rgba(200, 150, 60, .07);
    border: 1px solid var(--border);
    color: var(--parchment);
    font-family: 'Crimson Pro', serif;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 2px;
    cursor: pointer;
    outline: none;
    min-width: 230px;
}

select option {
    background: #1a1008;
}

.op-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    opacity: .8;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 3px;
    background: linear-gradient(to right, var(--gold) 70%, rgba(200, 150, 60, .2) 70%);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--dark);
    box-shadow: 0 0 8px rgba(200, 150, 60, .5);
}

.brow {
    display: flex;
    gap: 3px;
}

.bb {
    background: rgba(200, 150, 60, .07);
    border: 1px solid var(--border);
    color: var(--parchment);
    font-family: 'Crimson Pro', serif;
    font-size: 11px;
    padding: 3px 7px;
    cursor: pointer;
    border-radius: 2px;
    opacity: .6;
    transition: all .15s;
}

.bb:hover {
    opacity: 1;
    background: rgba(200, 150, 60, .14);
}

.bb.on {
    border-color: var(--gold);
    background: rgba(200, 150, 60, .18);
    opacity: 1;
    color: var(--gold);
}

.sbtn {
    background: rgba(200, 150, 60, .07);
    border: 1px solid var(--border);
    color: var(--parchment);
    font-family: 'IM Fell English SC', serif;
    font-size: 10px;
    letter-spacing: 1px;
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 2px;
    opacity: .7;
    transition: all .15s;
}

.sbtn:hover {
    opacity: 1;
    border-color: var(--gold);
    color: var(--gold);
}

.sbtn.on {
    border-color: var(--gold);
    background: rgba(200, 150, 60, .18);
    opacity: 1;
    color: var(--gold);
}

.sync-crosshair {
    position: absolute;
    top: 50%;
    z-index: 810;
    pointer-events: none;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
}

.sync-crosshair::before,
.sync-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(200, 150, 60, .85);
}

/* horizontal bar */
.sync-crosshair::before {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    margin-top: -0.5px;
}

/* vertical bar */
.sync-crosshair::after {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    margin-left: -0.5px;
}

.sync-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Crimson Pro', serif;
    font-size: 11px;
    opacity: .65;
    cursor: pointer;
    margin-top: 3px;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity .15s;
}

.sync-label:hover { opacity: 1; }

.sync-label input {
    accent-color: var(--gold);
    cursor: pointer;
    width: 12px;
    height: 12px;
}

.sep {
    width: 1px;
    height: 36px;
    background: var(--border);
    opacity: .4;
    flex-shrink: 0;
}

/* ── GEOLOCATION ── */
.loc-dot {
    border-radius: 50%;
    background: #3a82dc;
    border: 2.5px solid #fff;
    box-shadow: 0 0 0 2px rgba(58,130,220,.35), 0 2px 8px rgba(0,0,0,.45);
    animation: loc-pulse 2s ease-in-out infinite;
}

@keyframes loc-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(58,130,220,.35), 0 2px 8px rgba(0,0,0,.45); }
    50%       { box-shadow: 0 0 0 8px rgba(58,130,220,.1),  0 2px 8px rgba(0,0,0,.45); }
}

/* ── MAP ── */
#map {
    flex: 1;
    position: relative;
}

#badge {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 5px 16px;
    text-align: center;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    pointer-events: none;
    white-space: nowrap;
}

#badge h2 {
    font-family: 'IM Fell English SC', serif;
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--gold);
}

#badge p {
    font-size: 10px;
    opacity: .45;
    letter-spacing: 1px;
    margin-top: 1px;
}

.ipanel {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 900;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 12px 14px;
    max-width: 250px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.ipanel h3 {
    font-family: 'IM Fell English SC', serif;
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--gold);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    cursor: default;
}

.ipanel-arrow {
    font-size: 9px;
    opacity: .55;
    transition: transform .2s;
    display: none;
}

.ipanel-body {
    overflow: hidden;
    transition: max-height .25s ease, opacity .2s ease;
    max-height: 400px;
    opacity: 1;
}

/* ── Mobile: collapsed by default ── */
@media (max-width: 640px) {
    .ipanel h3 { cursor: pointer; margin-bottom: 0; }
    .ipanel-arrow { display: inline-block; }

    .ipanel-body {
        max-height: 0;
        opacity: 0;
    }
    .ipanel.open .ipanel-body {
        max-height: 400px;
        opacity: 1;
        margin-top: 6px;
    }
    .ipanel.open .ipanel-arrow {
        transform: rotate(180deg);
        opacity: .85;
    }

    /* Hide redundant status bar — layer name is visible in the badge */
    #status { display: none; }

    /* Lift ipanel slightly so coords label (bottom:8px ~24px tall) doesn't overlap */
    .ipanel { bottom: 40px; left: 8px; padding: 8px 10px; }
}

.ipanel p {
    font-size: 11px;
    opacity: .6;
    line-height: 1.65;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 8px;
}

.chip {
    font-family: 'Crimson Pro', serif;
    font-size: 11px;
    padding: 2px 7px;
    border: 1px solid var(--border);
    opacity: .58;
    cursor: pointer;
    transition: all .15s;
    border-radius: 1px;
    line-height: 1.4;
}

.chip:hover {
    opacity: 1;
    border-color: var(--gold);
    color: var(--gold);
}

/* status bar bottom-right */
#status {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 900;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 5px 12px;
    font-size: 11px;
    opacity: .7;
    font-family: 'IM Fell English SC', serif;
    letter-spacing: 1px;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* ── SPLIT HANDLE ── */
#shandle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(200, 150, 60, .85), transparent);
    z-index: 800;
    cursor: col-resize;
    display: none;
    box-shadow: 0 0 14px rgba(200, 150, 60, .35);
}

#shandle .knob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(13, 10, 6, .95);
    border: 1px solid rgba(200, 150, 60, .85);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(200, 150, 60, .95);
    font-size: 15px;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0 0 12px rgba(200, 150, 60, .4);
}

.split-label {
    position: absolute;
    top: 12px;
    background: rgba(13, 10, 6, .88);
    border: 1px solid var(--border);
    font-family: 'IM Fell English SC', serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--gold);
    padding: 3px 10px;
    pointer-events: none;
    white-space: nowrap;
    opacity: .9;
    z-index: 810;
    transform: translateX(-50%);
}

.split-label.left  {}
.split-label.right {}

/* ── LOADING ── */
#loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity .7s;
}

#loading.gone {
    opacity: 0;
    pointer-events: none;
}

.ltitle {
    font-family: 'UnifrakturMaguntia', cursive;
    font-size: 50px;
    color: var(--gold);
    text-shadow: 0 0 40px rgba(200, 150, 60, .4);
    animation: pulse 2s ease-in-out infinite;
}

.lsub {
    font-family: 'IM Fell English SC', serif;
    font-size: 11px;
    letter-spacing: 4px;
    opacity: .45;
}

.lline {
    width: 200px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    animation: scan 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: .55
    }

    50% {
        opacity: 1
    }
}

@keyframes scan {
    0% {
        transform: scaleX(.15);
        opacity: .15
    }

    50% {
        transform: scaleX(1);
        opacity: 1
    }

    100% {
        transform: scaleX(.15);
        opacity: .15
    }
}

/* ── LEAFLET OVERRIDES ── */
.leaflet-control-attribution {
    background: rgba(13, 10, 6, .8) !important;
    color: rgba(240, 230, 200, .4) !important;
    font-size: 9px !important;
}

.leaflet-control-attribution a {
    color: var(--gold) !important;
}

.leaflet-control-zoom a {
    background: rgba(13, 10, 6, .92) !important;
    color: var(--gold) !important;
    border-color: var(--border) !important;
}

.leaflet-popup-content-wrapper {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--parchment);
}

.leaflet-popup-tip {
    background: var(--panel);
}