:root {
    --bg: #040814;
    --panel: rgba(8, 16, 31, 0.9);
    --panel-strong: rgba(13, 27, 50, 0.96);
    --line: rgba(214, 226, 255, 0.14);
    --text: #f4f8ff;
    --muted: #a8b7d4;
    --accent: #60a5fa;
    --sun: #ffd166;
    --good: #75e4a4;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    min-height: 100vh;
    background: linear-gradient(180deg, #040814 0%, #07111f 100%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
select {
    font: inherit;
}

.cesium-daynight-shell {
    min-height: 100vh;
    height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    padding: 18px;
    overflow: hidden;
}

.viewer-panel,
.control-panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.viewer-panel {
    position: relative;
    overflow: hidden;
    height: calc(100vh - 36px);
    min-height: 0;
    background: #020611;
}

#cesiumContainer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    contain: strict;
}

.cesium-widget,
.cesium-widget canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.status-pill {
    position: absolute;
    left: 16px;
    bottom: 16px;
    max-width: min(420px, calc(100% - 32px));
    padding: 9px 12px;
    border: 1px solid rgba(214, 226, 255, 0.18);
    border-radius: 999px;
    background: rgba(5, 12, 25, 0.72);
    color: #fff;
    font-size: 0.86rem;
    backdrop-filter: blur(8px);
}

.observer-card {
    position: absolute;
    top: 16px;
    left: 16px;
    width: min(320px, calc(100% - 32px));
    padding: 12px;
    border: 1px solid rgba(214, 226, 255, 0.18);
    border-radius: 14px;
    background: rgba(5, 12, 25, 0.76);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.observer-title {
    margin-bottom: 8px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
}

.observer-sky {
    position: relative;
    height: 150px;
    overflow: hidden;
    border: 1px solid rgba(214, 226, 255, 0.14);
    border-radius: 10px;
    background: linear-gradient(180deg, #163f79 0%, #75b7ee 62%, #132033 63%, #09111f 100%);
}

.observer-sky.is-night {
    background: linear-gradient(180deg, #030712 0%, #0d1b32 62%, #09111f 63%, #050914 100%);
}

.observer-sun {
    position: absolute;
    left: 50%;
    top: 32%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border-radius: 50%;
    background: #ffd166;
    box-shadow: 0 0 22px rgba(255, 209, 102, 0.85);
    transform: translateY(0);
}

.observer-horizon {
    position: absolute;
    left: 0;
    right: 0;
    top: 61%;
    display: flex;
    width: 150%;
    border-top: 2px solid rgba(255, 255, 255, 0.65);
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    transform: translateX(0);
}

.observer-horizon span {
    flex: 1 0 20%;
    padding-top: 4px;
    text-align: center;
}

.observer-ground {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 37%;
    background: linear-gradient(180deg, rgba(22, 50, 35, 0.94), rgba(8, 18, 14, 0.98));
}

.observer-caption {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
}

.webgl-fallback {
    position: absolute;
    inset: 18px;
    display: grid;
    place-items: center;
    padding: 22px;
    border-radius: 14px;
    background: rgba(8, 16, 31, 0.92);
    color: #fff;
    text-align: center;
}

.webgl-fallback[hidden] {
    display: none;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    background: var(--panel-strong);
    max-height: calc(100vh - 36px);
    overflow: auto;
}

.panel-header h1,
.panel-block h2 {
    margin: 0;
}

.panel-header h1 {
    font-size: clamp(1.55rem, 3vw, 2.1rem);
    line-height: 1.1;
}

.panel-header p,
.panel-block p {
    color: var(--muted);
    line-height: 1.55;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--sun);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.panel-block {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid rgba(214, 226, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
}

.segmented,
.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.segmented button,
.button-row button,
select {
    min-height: 40px;
    border: 1px solid rgba(214, 226, 255, 0.18);
    border-radius: 10px;
    background: #0d1b32;
    color: var(--text);
}

select {
    width: 100%;
    padding: 0 10px;
    color-scheme: dark;
}

select option {
    background: #0d1b32;
    color: var(--text);
}

.segmented button,
.button-row button {
    cursor: pointer;
}

.segmented button.active {
    border-color: rgba(117, 228, 164, 0.68);
    background: rgba(117, 228, 164, 0.14);
}

label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
}

.toggle input {
    width: 18px;
    height: 18px;
}

.legend {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--muted);
}

.legend li {
    display: flex;
    align-items: center;
    gap: 9px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    display: inline-block;
}

.dot.day {
    background: #facc15;
}

.dot.night {
    background: #2f4a78;
}

.dot.place {
    background: var(--good);
}

.dot.line {
    background: #9fc7ff;
}

.dot.axis {
    background: #ff8fb3;
}

@media (max-width: 1050px) {
    .cesium-daynight-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .viewer-panel,
    #cesiumContainer {
        height: min(66vh, 620px);
        min-height: 420px;
    }

    .control-panel {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .cesium-daynight-shell {
        padding: 10px;
    }

    .segmented,
    .button-row {
        grid-template-columns: 1fr;
    }

    .viewer-panel,
    #cesiumContainer {
        height: 62vh;
        min-height: 340px;
    }

    .observer-card {
        width: min(260px, calc(100% - 20px));
        top: 10px;
        left: 10px;
        padding: 10px;
    }

    .observer-sky {
        height: 118px;
    }
}
