:root {
    color-scheme: dark;
    --ws3d-bg: #081016;
    --ws3d-panel: rgba(10, 17, 23, 0.9);
    --ws3d-panel-solid: #101820;
    --ws3d-line: rgba(255, 255, 255, 0.16);
    --ws3d-line-strong: rgba(255, 255, 255, 0.28);
    --ws3d-text: #f4f7f9;
    --ws3d-muted: #9eadb8;
    --ws3d-accent: #2fb8c6;
    --ws3d-accent-2: #f0b44d;
    --ws3d-danger: #e95f5f;
    --ws3d-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--ws3d-bg);
    color: var(--ws3d-text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid var(--ws3d-line);
    color: var(--ws3d-text);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

button:hover {
    border-color: var(--ws3d-line-strong);
    background: rgba(255, 255, 255, 0.12);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--ws3d-accent);
    outline-offset: 2px;
}

#map3d {
    position: fixed;
    inset: 0;
}

.ws3d-loading {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(6, 10, 14, 0.78);
    color: var(--ws3d-text);
    font-weight: 700;
    transition: opacity 180ms ease, visibility 180ms ease;
}

.ws3d-loading.is-hidden {
    visibility: hidden;
    opacity: 0;
}

.ws3d-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid rgba(255, 255, 255, 0.22);
    border-top-color: var(--ws3d-accent);
    border-radius: 50%;
    animation: ws3d-spin 820ms linear infinite;
}

@keyframes ws3d-spin {
    to {
        transform: rotate(360deg);
    }
}

.ws3d-topbar,
.ws3d-panel,
.ws3d-search,
.ws3d-toast {
    position: fixed;
    z-index: 15;
    border: 1px solid var(--ws3d-line);
    background: var(--ws3d-panel);
    box-shadow: var(--ws3d-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ws3d-topbar {
    top: 14px;
    left: 14px;
    right: 14px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    pointer-events: auto;
}

.ws3d-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--ws3d-text);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 0;
}

.ws3d-brand img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.ws3d-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ws3d-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ws3d-muted);
    font-size: 13px;
    white-space: nowrap;
}

.ws3d-mode-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 3px;
    border: 1px solid var(--ws3d-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

.ws3d-mode-switch a {
    min-width: 78px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--ws3d-muted);
    text-align: center;
    text-decoration: none;
    font-size: 12px;
    font-weight: 850;
}

.ws3d-mode-switch a:hover,
.ws3d-mode-switch a.is-active {
    color: #eaffff;
    background: rgba(47, 184, 198, 0.2);
}

.ws3d-search {
    top: 82px;
    left: 14px;
    width: min(420px, calc(100vw - 28px));
    border-radius: 8px;
    overflow: hidden;
}

.ws3d-search input {
    width: 100%;
    height: 42px;
    border: 0;
    padding: 0 14px;
    color: var(--ws3d-text);
    background: rgba(255, 255, 255, 0.08);
}

.ws3d-search input::placeholder {
    color: rgba(244, 247, 249, 0.58);
}

.ws3d-search-results {
    display: none;
    max-height: 310px;
    overflow: auto;
    border-top: 1px solid var(--ws3d-line);
}

.ws3d-search-results.is-open {
    display: block;
}

.ws3d-search-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    text-align: left;
}

.ws3d-search-item:hover,
.ws3d-search-item.is-active {
    background: rgba(47, 184, 198, 0.14);
}

.ws3d-search-name,
.ws3d-search-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ws3d-search-name {
    font-weight: 750;
}

.ws3d-search-meta {
    margin-top: 2px;
    color: var(--ws3d-muted);
    font-size: 12px;
}

.ws3d-search-kind {
    align-self: center;
    color: var(--ws3d-accent-2);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ws3d-panel {
    top: 82px;
    right: 14px;
    width: 320px;
    max-height: calc(100vh - 110px);
    padding: 14px;
    border-radius: 8px;
    overflow: auto;
}

.ws3d-panel.is-collapsed {
    max-height: 50px;
    overflow: hidden;
}

.ws3d-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.ws3d-panel-head span {
    font-size: 13px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ws3d-panel-head button,
.ws3d-actions button {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 8px;
}

.ws3d-field {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
}

.ws3d-field span,
.ws3d-section-title {
    color: var(--ws3d-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ws3d-field select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--ws3d-line);
    border-radius: 8px;
    padding: 0 10px;
    color: var(--ws3d-text);
    background: var(--ws3d-panel-solid);
}

.ws3d-section {
    display: grid;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ws3d-section label {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 26px;
    color: rgba(244, 247, 249, 0.92);
    font-size: 14px;
}

.ws3d-section input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--ws3d-accent);
}

.ws3d-range {
    display: grid !important;
    gap: 8px !important;
    align-items: stretch !important;
}

.ws3d-range span {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.ws3d-range input {
    width: 100%;
    accent-color: var(--ws3d-accent);
}

.ws3d-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 12px;
}

.ws3d-toast {
    right: 14px;
    bottom: 30px;
    max-width: min(420px, calc(100vw - 28px));
    padding: 10px 12px;
    border-radius: 8px;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.ws3d-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.maplibregl-ctrl-bottom-right {
    right: 12px;
    bottom: 12px;
}

.maplibregl-ctrl-bottom-left {
    left: 12px;
    bottom: 128px;
}

.ws3d-popup .maplibregl-popup-content {
    width: min(390px, calc(100vw - 40px));
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--ws3d-line);
    border-radius: 8px;
    background: #101820;
    color: var(--ws3d-text);
    box-shadow: var(--ws3d-shadow);
}

.ws3d-popup .maplibregl-popup-close-button {
    width: 30px;
    height: 30px;
    color: var(--ws3d-text);
    font-size: 20px;
}

.ws3d-popup-card {
    padding: 14px;
}

.ws3d-popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-right: 24px;
}

.ws3d-popup-kicker {
    display: inline-flex;
    margin-bottom: 5px;
    color: var(--ws3d-accent-2);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.ws3d-popup-title {
    margin: 0;
    font-size: 18px;
    line-height: 1.18;
}

.ws3d-popup-time {
    color: var(--ws3d-muted);
    font-size: 12px;
    white-space: nowrap;
}

.ws3d-popup-value {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 14px 0;
    padding: 12px;
    border: 1px solid var(--ws3d-line);
    border-left: 5px solid var(--ws3d-marker-color, var(--ws3d-accent));
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

.ws3d-popup-value strong {
    font-size: 32px;
    line-height: 1;
}

.ws3d-popup-value span {
    color: var(--ws3d-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.ws3d-popup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.ws3d-popup-metric {
    min-width: 0;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.045);
}

.ws3d-popup-metric dt {
    margin: 0 0 4px;
    color: var(--ws3d-muted);
    font-size: 11px;
}

.ws3d-popup-metric dd {
    margin: 0;
    font-weight: 800;
}

.ws3d-popup-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(47, 184, 198, 0.5);
    border-radius: 8px;
    color: #9be5ec;
    text-decoration: none;
    background: rgba(47, 184, 198, 0.12);
}

.ws3d-popup-media {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
    background: #05080b;
}

.ws3d-popup-video {
    height: 190px;
    max-height: none;
    border: 0;
}

@media (max-width: 860px) {
    .ws3d-topbar {
        height: 50px;
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .ws3d-status {
        display: none;
    }

    .ws3d-mode-switch {
        margin-left: 0;
    }

    .ws3d-mode-switch a {
        min-width: 58px;
        padding-inline: 8px;
    }

    .ws3d-search {
        top: 70px;
        left: 10px;
        width: calc(100vw - 20px);
    }

    .ws3d-panel {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 84px;
        width: auto;
        max-height: 45vh;
    }

    .ws3d-toast {
        right: 10px;
        bottom: 74px;
    }

    .maplibregl-ctrl-bottom-left {
        display: none;
    }

    .ws3d-popup-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .ws3d-actions {
        grid-template-columns: 1fr;
    }

    .ws3d-brand span {
        max-width: 210px;
    }
}
