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

:root {
    --bg:        #0d1117;
    --surface:   #161b22;
    --border:    #30363d;
    --text:      #e6edf3;
    --muted:     #8b949e;
    --accent:    #2f81f7;
    --accent-h:  #388bfd;
    --danger:    #f85149;
    --radius:    8px;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Header ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
}
.header-inner {
    max-width: 880px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.header-sub { color: var(--muted); font-size: 13px; }

/* ── Main ── */
main {
    max-width: 880px;
    margin: 24px auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Radar ── */
.radar-wrapper {
    display: flex;
    justify-content: center;
}
.radar-container {
    position: relative;
    width: 800px;
    height: 600px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #1a2030;
    box-shadow: 0 4px 24px rgba(0,0,0,.5);
}

/* Leaflet map fills the container */
#radarMap {
    width: 100%;
    height: 100%;
}

/* Arrow/label canvas on top of map */
#arrowCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 800;
}

/* Leaflet dark theme tweaks */
.leaflet-container {
    background: #1a2030;
    font-family: inherit;
}
.leaflet-control-attribution {
    background: rgba(0,0,0,0.5) !important;
    color: var(--muted) !important;
    font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--border) !important; }

.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.55);
    z-index: 1000;
    transition: opacity .2s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Controls ── */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
}
.transport { display: flex; gap: 6px; }
.ctrl-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    width: 34px; height: 34px;
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
}
.ctrl-btn:hover  { background: var(--border); }
.ctrl-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.ctrl-btn.primary:hover { background: var(--accent-h); border-color: var(--accent-h); }

.ts-display {
    flex: 1;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.speed-group { display: flex; align-items: center; gap: 6px; }
.speed-group .label { color: var(--muted); }
.speed-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: all .15s;
}
.speed-btn:hover  { border-color: var(--accent); color: var(--text); }
.speed-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Timeline ── */
.timeline-section {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tl-label-left, .tl-label-right {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
#timeline {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    cursor: pointer;
}
#timeline::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 2px var(--accent);
}
#timeline::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
}

/* ── Legend ── */
.legend {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 12px;
    color: var(--muted);
}
.legend-title { font-weight: 600; color: var(--text); }
.leg-item { display: flex; align-items: center; gap: 5px; }
.leg-dot {
    width: 12px; height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}
.leg-dot.s1 { background: #aad4f5; }
.leg-dot.s2 { background: #00c800; }
.leg-dot.s3 { background: #ffff00; }
.leg-dot.s4 { background: #ff8000; }
.leg-dot.s5 { background: #ff0000; }
.leg-sep { flex: 1; }
.leg-item svg { flex-shrink: 0; }

/* ── Info bar ── */
.info-bar {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    min-height: 18px;
}

/* ── Footer ── */
footer {
    max-width: 880px;
    margin: 8px auto 24px;
    padding: 0 16px;
    display: flex;
    gap: 24px;
    color: var(--muted);
    font-size: 12px;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 860px) {
    .radar-container {
        width: 100%;
        height: auto;
        aspect-ratio: 4/3;
    }
    #radarMap {
        position: absolute;
        inset: 0;
    }
}
