: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;
    --moon: #cbd5e1;
    --node: #fb923c;
}

* {
    box-sizing: border-box;
}

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

body {
    background: radial-gradient(circle at 22% 18%, #172c52 0, transparent 28%), linear-gradient(180deg, #040814 0%, #07111f 100%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.tellurium-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 370px;
    gap: 18px;
    padding: 18px;
}

body.controls-collapsed .tellurium-shell {
    grid-template-columns: minmax(0, 1fr);
}

.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;
    min-height: 0;
    background: #020611;
}

#tellurium-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#label-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.scene-label {
    position: absolute;
    transform: translate(-50%, -50%);
    max-width: 210px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(5, 12, 25, 0.76);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.scene-label.is-muted {
    color: #dbeafe;
    font-weight: 700;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    background: var(--panel-strong);
    overflow-y: auto;
}

body.controls-collapsed .control-panel {
    display: none;
}

.controls-float,
.panel-collapse {
    border: 1px solid rgba(214, 226, 255, 0.18);
    border-radius: 10px;
    background: rgba(96, 165, 250, 0.18);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.controls-float {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    min-height: 40px;
    padding: 0 14px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

.controls-float[hidden] {
    display: none;
}

.panel-collapse {
    min-height: 38px;
    margin-bottom: 8px;
    padding: 0 12px;
}

.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;
    text-transform: uppercase;
}

.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);
}

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

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

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

.button-row button:hover,
.segmented button:hover,
.segmented button.active {
    border-color: rgba(96, 165, 250, 0.62);
    background: rgba(96, 165, 250, 0.16);
}

label {
    color: #dbe7ff;
    font-weight: 800;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.toggle {
    display: flex;
    gap: 10px;
    align-items: center;
    color: #e2e8f6;
    font-weight: 700;
    cursor: pointer;
}

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

.status-box {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.28);
    color: #e4ecff;
    line-height: 1.35;
}

.legend {
    display: grid;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
    color: #dbe7ff;
    line-height: 1.35;
}

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

.dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.dot.ecliptic {
    background: #7dd3fc;
}

.dot.lunar {
    background: #c084fc;
}

.dot.node {
    background: var(--node);
}

.dot.solstice {
    background: #facc15;
}

.dot.moon-node {
    background: #f0abfc;
}

.fallback {
    position: absolute;
    inset: 16px;
    display: grid;
    place-items: center;
    padding: 22px;
    border-radius: 16px;
    background: rgba(5, 12, 25, 0.92);
    color: var(--text);
    font-weight: 800;
    text-align: center;
}

.fallback[hidden] {
    display: none;
}

@media (max-width: 1050px) {
    .tellurium-shell {
        grid-template-columns: 1fr;
    }

    .viewer-panel,
    #tellurium-canvas {
        min-height: 68vh;
    }
}

@media (max-width: 680px) {
    .tellurium-shell {
        padding: 10px;
    }

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