:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    background: #05070b;
    color: #fff;
    --cyan: #69d9ff;
    --blue: #347fe8;
    --panel: rgba(7, 11, 18, 0.76);
    --line: rgba(255, 255, 255, 0.13);
}

* { box-sizing: border-box; }
html, body, #cesiumContainer { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #05070b; }
#cesiumContainer { position: fixed; inset: 0; }

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background:
        linear-gradient(to bottom, rgba(0, 0, 0, 0.42), transparent 28%),
        linear-gradient(to top, rgba(0, 0, 0, 0.48), transparent 30%),
        radial-gradient(circle at center, transparent 50%, rgba(0, 0, 0, 0.34));
}

.hud {
    position: fixed;
    z-index: 10;
    right: 20px;
    bottom: 92px;
    width: min(420px, calc(100vw - 40px));
    pointer-events: none;
}

.title-block, .status-block, .controls, .layer-trigger, .layer-menu {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px) saturate(135%);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.title-block {
    width: 100%;
    padding: 13.5px 15px;
    border-radius: 14px;
}
.eyebrow, .panel-kicker { display: block; color: #7cb7ff; font-size: 10px; font-weight: 800; letter-spacing: 0.16em; }
.eyebrow { margin-bottom: 5px; font-size: 8px; }
h1 { margin: 0; font-size: clamp(17px, 2.25vw, 27px); line-height: 1.05; letter-spacing: -0.035em; }
#locationDescription { max-width: 52ch; margin: 7.5px 0 0; color: rgba(255,255,255,.68); font-size: 10px; line-height: 1.55; }

.status-block {
    position: fixed;
    top: 20px;
    left: 20px;
    min-height: 54px;
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 15px;
    color: rgba(255,255,255,.78);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.system-status { color: #9de4ff; }
.separator { padding: 0 8px; color: rgba(255,255,255,.32); }

.layer-console { position: fixed; z-index: 12; top: 20px; right: 20px; width: min(330px, calc(100vw - 40px)); }
.layer-trigger {
    appearance: none;
    width: 100%;
    min-height: 54px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    text-align: left;
}
.layer-trigger:hover { border-color: rgba(105,217,255,.4); background: rgba(10,18,30,.86); }
.trigger-icon { width: 34px; height: 34px; display: grid; place-content: center; gap: 4px; border: 1px solid rgba(105,217,255,.25); border-radius: 11px; background: rgba(105,217,255,.08); }
.trigger-icon span { display: block; width: 15px; height: 2px; border-radius: 10px; background: var(--cyan); box-shadow: 0 0 10px rgba(105,217,255,.5); }
.trigger-copy { min-width: 0; flex: 1; }
.trigger-copy small { display: block; margin-bottom: 2px; color: rgba(255,255,255,.45); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.trigger-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; letter-spacing: .01em; }
.chevron { font-size: 20px; color: rgba(255,255,255,.55); transition: transform .2s ease; }
.layer-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.layer-menu { margin-top: 8px; max-height: calc(100vh - 96px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; border-radius: 18px; animation: menuIn .18s ease-out; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(.985); } to { opacity: 1; transform: none; } }
.layer-menu-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 12px 12px 9px; border-bottom: 1px solid rgba(255,255,255,.08); }
.layer-menu-head h2 { margin: 4px 0 0; font-size: 15px; letter-spacing: -.02em; }
.live-indicator { display: flex; align-items: center; gap: 6px; color: #a5f3c7; font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.live-indicator i { width: 7px; height: 7px; border-radius: 50%; background: #5bf49a; box-shadow: 0 0 12px #5bf49a; }
.layer-options { display: grid; gap: 4px; padding: 7px; }
.layer-option {
    width: 100%;
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    text-align: left;
}
.layer-option:hover { background: rgba(255,255,255,.06); }
.layer-option.active { border-color: rgba(105,217,255,.34); background: linear-gradient(90deg, rgba(52,127,232,.18), rgba(105,217,255,.07)); }
.layer-swatch { width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(255,255,255,.14); background: var(--swatch); box-shadow: inset 0 0 18px rgba(255,255,255,.08); }
.layer-copy strong { display: block; font-size: 12px; }
.layer-copy small { display: block; margin-top: 3px; color: rgba(255,255,255,.46); font-size: 10px; }
.layer-radio { width: 15px; height: 15px; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; }
.layer-option.active .layer-radio { border: 4px solid #69d9ff; box-shadow: 0 0 12px rgba(105,217,255,.45); }

.environment-options { padding: 7px; border-top: 1px solid rgba(255,255,255,.08); }
.environment-head { display: flex; align-items: center; justify-content: space-between; padding: 1px 3px 5px; }
.environment-head span { color: rgba(255,255,255,.74); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.environment-head small { color: rgba(105,217,255,.62); font-size: 8px; font-weight: 850; letter-spacing: .13em; }
.mini-option, .sun-option, .quality-option { display: flex; align-items: center; min-height: 32px; padding: 5px 7px; border-radius: 10px; cursor: pointer; }
.mini-option:hover, .sun-option:hover, .quality-option:hover { background: rgba(255,255,255,.05); }
.mini-option > span { min-width: 0; flex: 1; }
.mini-option strong, .sun-option strong, .quality-option strong { display: block; font-size: 11px; line-height: 1.2; }
.mini-option small, .sun-option small, .quality-option small { display: block; margin-top: 2px; color: rgba(255,255,255,.42); font-size: 9px; }
.mini-option input { position: absolute; opacity: 0; pointer-events: none; }
.mini-option i { position: relative; width: 30px; height: 17px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(255,255,255,.08); transition: .18s ease; }
.mini-option i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: rgba(255,255,255,.65); transition: .18s ease; }
.mini-option input:checked + i { border-color: rgba(105,217,255,.45); background: rgba(52,127,232,.48); box-shadow: 0 0 12px rgba(105,217,255,.16); }
.mini-option input:checked + i::after { left: 15px; background: #d9f7ff; }
.mini-option input:focus-visible + i { outline: 2px solid #91c3ff; outline-offset: 2px; }
.sun-option { display: block; cursor: default; }
.sun-option-copy { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.sun-option-copy > span { display: flex; align-items: baseline; gap: 5px; }
.sun-option-copy small { margin: 0; }
#sunTimeLabel { color: #9de4ff; font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
#sunTimeSlider { width: 100%; height: 3px; margin: 0; accent-color: var(--cyan); cursor: pointer; }
.quality-option { display: block; margin-top: 2px; cursor: default; }
.quality-option-copy { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.quality-option-copy > span { min-width: 0; }
#qualityDetail { margin-top: 3px; }
#qualityLabel { flex: 0 0 auto; padding: 3px 7px; border: 1px solid rgba(105,217,255,.22); border-radius: 999px; background: rgba(105,217,255,.08); color: #9de4ff; font-size: 9px; font-weight: 850; letter-spacing: .04em; }
#qualitySlider { width: 100%; height: 3px; margin: 0; accent-color: var(--cyan); cursor: pointer; }
.quality-scale { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 5px; padding: 0 1px; }
.quality-scale small { margin: 0; color: rgba(255,255,255,.52); font-size: 9px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.quality-scale small:first-child { text-align: left; }
.quality-scale small:nth-child(2) { text-align: center; }
.quality-scale small:last-child { text-align: right; }

.layer-menu-foot { display: flex; justify-content: space-between; gap: 10px; padding: 8px 11px 9px; border-top: 1px solid rgba(255,255,255,.08); color: rgba(255,255,255,.4); font-size: 9px; letter-spacing: .08em; }
.layer-menu-foot strong { color: rgba(255,255,255,.68); font-weight: 700; }

.controls { position: fixed; z-index: 10; right: 20px; bottom: 28px; left: auto; width: min(360px, calc(100vw - 40px)); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 8px; border-radius: 16px; transform: none; }
.controls button { appearance: none; width: 100%; min-width: 0; border: 0; border-radius: 11px; padding: 11px 15px; cursor: pointer; background: rgba(255,255,255,.09); color: #fff; font: inherit; font-size: 13px; font-weight: 750; }
.controls button:hover { background: rgba(255,255,255,.16); }
.controls button.primary { background: #347fe8; }
.controls button.primary:hover { background: #438df4; }
button:focus-visible { outline: 2px solid #91c3ff; outline-offset: 2px; }
.progress { position: fixed; z-index: 10; left: 20px; right: 20px; bottom: 16px; height: 4px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.13); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: #65a7ff; transform-origin: left center; }
.error-panel { position: fixed; z-index: 20; left: 50%; top: 50%; width: min(560px, calc(100vw - 40px)); padding: 20px; border: 1px solid rgba(255,110,110,.42); border-radius: 16px; transform: translate(-50%,-50%); background: rgba(24,8,10,.92); color: #ffd3d3; line-height: 1.55; }
.cesium-viewer-bottom { z-index: 8; }

@media (max-width: 1120px) {
    .hud { width: min(390px, calc(100vw - 40px)); }
    .layer-console { width: 280px; }
    .status-block { font-size: 11px; padding: 9px 11px; }
    .separator { padding: 0 5px; }
}

@media (max-width: 900px) {
    .hud {
        right: 12px;
        bottom: 88px;
        width: min(360px, calc(100vw - 24px));
    }
    .status-block { top: 12px; left: 12px; }
    .layer-console { top: 82px; right: 12px; width: 270px; }
}

@media (max-width: 720px) {
    .hud {
        right: 12px;
        bottom: 86px;
        width: calc(100vw - 24px);
    }
    .title-block { padding: 11px 12px; }
    #locationDescription { display: none; }
    .status-block { top: 12px; left: 12px; min-height: 46px; max-width: calc(100vw - 24px); font-size: 11px; }
    .system-status, .status-block .separator:first-of-type { display: none; }
    .layer-console { top: 70px; right: 12px; width: calc(100vw - 24px); }
    .layer-trigger { min-height: 50px; }
    .controls { right: 12px; bottom: 25px; left: auto; width: calc(100vw - 24px); }
    .progress { left: 12px; right: 12px; bottom: 14px; }
}


/* Extra contour control adds one row; keep the visual matrix usable on short screens. */
@media (max-width: 900px) {
    .layer-menu { max-height: calc(100vh - 150px); }
}

@media (max-width: 720px) {
    .layer-menu { max-height: calc(100vh - 138px); }
}
