:root {
  --bg: #0b1020; --panel: rgba(16, 22, 40, 0.94); --card: #141c33; --line: rgba(150, 175, 230, 0.16);
  --text: #e6ecff; --muted: #94a0c4; --accent: #7cb4ff; --good: #5ad19a; --ok: #e8c35a; --bad: #ff7b6b; --sprite: #ff4d6d;
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.small { font-size: 12.5px; } .muted { color: var(--muted); }
#top { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; display: flex; gap: 8px; align-items: center; padding: calc(8px + var(--safe-t)) 12px 8px; background: linear-gradient(#0b1020ee, #0b102099 70%, transparent); pointer-events: none; }
#top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: .3px; color: var(--accent); }
.brand span { color: var(--text); }
#search { flex: 1; position: relative; max-width: 460px; }
#q { width: 100%; padding: 9px 12px; border-radius: 22px; border: 1px solid var(--line); background: #10172bdd; outline: none; }
#sugg { position: absolute; top: 42px; left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
#sugg div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); } #sugg div:hover { background: #1d2848; }
.icon { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #10172bdd; display: grid; place-items: center; cursor: pointer; }
#offline { position: fixed; top: calc(56px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 1200; background: #5a2a14; border: 1px solid #c86a3a; color: #ffd9c2; padding: 7px 14px; border-radius: 20px; font-size: 13px; box-shadow: 0 4px 20px #0008; }
#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: #0b1020; }
.leaflet-container { background: #0b1020; font: inherit; }
.leaflet-control-attribution { background: #0b1020aa !important; color: #8892b0 !important; font-size: 10px; }
.leaflet-control-attribution a { color: #9ab !important; }
.fab { position: absolute; right: 12px; top: calc(64px + var(--safe-t)); z-index: 900; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; cursor: pointer; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.floating { position: absolute; right: 12px; top: calc(114px + var(--safe-t)); z-index: 900; width: 250px; display: none; }
.floating.show { display: block; }
.floating label { display: block; padding: 4px 0; font-size: 14px; }
.cardhead { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 6px 0 6px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

/* side panel / bottom sheet */
.sheet { position: absolute; z-index: 950; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
@media (min-width: 821px) { .sheet { top: calc(64px + var(--safe-t)); left: 12px; bottom: 84px; width: 390px; border-radius: var(--radius); } .grab { display: none; } }
@media (max-width: 820px) {
  .sheet { left: 0; right: 0; bottom: calc(64px + var(--safe-b)); height: 46vh; border-radius: 18px 18px 0 0; transition: height .25s; }
  .sheet.min { height: 54px; } .sheet.max { height: calc(100vh - 140px - var(--safe-t) - var(--safe-b)); }
  .grab { width: 44px; height: 5px; border-radius: 3px; background: #4a5578; margin: 7px auto 2px; flex: none; }
  .floating { width: auto; left: 12px; }
}
.tabs { display: flex; gap: 4px; padding: 8px 10px 0; flex: none; }
.tabs button { flex: 1; background: none; border: 0; padding: 8px 4px; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.tab { display: none; overflow-y: auto; padding: 10px 14px 18px; flex: 1; -webkit-overflow-scrolling: touch; }
.tab.on { display: block; }
.empty { color: var(--muted); padding: 30px 6px; text-align: center; }
.place { font-size: 18px; font-weight: 700; } .sub { color: var(--muted); font-size: 13px; }
.score { display: flex; align-items: center; gap: 12px; margin: 12px 0; padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.score .num { font-size: 30px; font-weight: 800; width: 62px; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat .k { font-size: 11.5px; color: var(--muted); } .stat .v { font-size: 16px; font-weight: 650; margin-top: 2px; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 500; }
.btn { border: 1px solid var(--line); background: #1b2544; border-radius: 10px; padding: 9px 14px; cursor: pointer; }
.btn.primary { background: #2f5fd0; border-color: #4b7ae6; font-weight: 650; }
.btn.big { width: 100%; padding: 12px; font-size: 15.5px; margin: 6px 0; }
.btn:disabled { opacity: .5; }
.row { margin: 7px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row label { display: flex; gap: 8px; align-items: center; }
select, input[type=text], input[type=number] { background: #10172b; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
canvas.chart { width: 100%; height: 150px; display: block; background: var(--card); border-radius: 10px; border: 1px solid var(--line); margin: 6px 0; }
canvas.polar { width: 190px; height: 190px; display: block; margin: 4px auto; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; background: #22305a; font-size: 12px; margin: 2px 3px 2px 0; }
.tag.good { background: #1d4a38; } .tag.ok { background: #4b4320; } .tag.bad { background: #5a2626; }
.site { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; cursor: pointer; }
.site.sel { border-color: var(--accent); }
.site .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bar { height: 6px; border-radius: 3px; background: #26304f; overflow: hidden; margin-top: 3px; } .bar i { display: block; height: 100%; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* time bar */
#timebar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1100; display: flex; align-items: center; gap: 8px; padding: 8px 12px calc(8px + var(--safe-b)); background: var(--panel); border-top: 1px solid var(--line); }
.tl { flex: 1; position: relative; height: 40px; }
#tlCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; border-radius: 6px; }
#time { position: absolute; inset: 0; width: 100%; margin: 0; z-index: 2; background: transparent; -webkit-appearance: none; appearance: none; height: 40px; }
#time::-webkit-slider-thumb { -webkit-appearance: none; width: 6px; height: 40px; border-radius: 3px; background: #fff; box-shadow: 0 0 0 2px #2f5fd0; }
#time::-moz-range-thumb { width: 6px; height: 40px; border-radius: 3px; background: #fff; border: 0; }
#time::-webkit-slider-runnable-track { background: transparent; } #time::-moz-range-track { background: transparent; }
#timeLbl { min-width: 104px; font-size: 13px; text-align: center; line-height: 1.25; }
.pill { border: 1px solid var(--line); background: #1b2544; border-radius: 18px; padding: 7px 12px; cursor: pointer; white-space: nowrap; font-size: 13.5px; }
@media (max-width: 520px) { #tonightBtn { display: none; } #timeLbl { min-width: 84px; font-size: 12px; } .brand span { display: none; } }

/* 3D view */
#view3d { position: absolute; inset: 0; z-index: 1050; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
#view3d canvas.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#view3d .hud { position: absolute; z-index: 5; }
.hud-top { top: calc(8px + var(--safe-t)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.hud-title { text-align: center; text-shadow: 0 1px 4px #000; font-size: 13px; display: flex; flex-direction: column; } .hud-title b { font-size: 14.5px; }
#view3d .pill { background: #0b1020b0; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#menu3d { top: calc(54px + var(--safe-t)); right: 10px; width: 330px; max-height: calc(100% - 150px); overflow-y: auto; }
@media (max-width: 520px) { #menu3d { left: 10px; width: auto; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #172042; border-radius: 16px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.chip.on { background: #2f5fd0; border-color: #6d95f0; }
.hud-center { left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.reticle { width: 18px; height: 18px; border: 1.5px solid #ffffff55; border-radius: 50%; }
.hud-read { left: 12px; bottom: calc(76px + var(--safe-b)); font-size: 12.5px; text-shadow: 0 1px 3px #000; color: #dfe7ff; line-height: 1.45; pointer-events: none; }
#pick3d { left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--safe-b)); max-width: 92vw; font-size: 13.5px; }
.loading { inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: #050810e0; color: var(--muted); font-size: 14px; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #2a3560; border-top-color: var(--accent); animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.labels3d { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.labels3d div { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 11.5px; color: #cfe0ff; text-shadow: 0 0 3px #000, 0 0 2px #000; margin: -7px 0 0 6px; will-change: transform; }
.labels3d .cardi { margin-left: -6px; font-weight: 700; color: #9fd0ff; font-size: 12px; }
.labels3d .cardi.main { font-size: 15px; color: #fff; }
.labels3d .gridlbl { color: #7fb6ffaa; font-size: 10.5px; } .labels3d .mer { color: #ffd27faa; } .labels3d .ecl { color: #ffb070cc; }
.labels3d .star { color: #b8c8ff99; font-size: 10.5px; } .labels3d .planet { color: #ffe9b0; font-weight: 600; } .labels3d .sun { color: #ffd060; }
.labels3d .dome { color: #ffb36b; font-size: 11px; } .labels3d .storm { color: #ff8aa0; font-weight: 700; } .labels3d .mw { color: #c9c3ff; }

.modal { position: fixed; inset: 0; z-index: 3000; background: #0008; display: grid; place-items: center; padding: 16px; }
.modal .card { width: min(480px, 100%); }
.modal label.row { flex-direction: column; align-items: stretch; }
.leaflet-tooltip.lbl { background: #10172be6; color: var(--text); border: 1px solid var(--line); }
.mk { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #08101e; border: 2px solid #0b1020; box-shadow: 0 1px 6px #000a; }
.selmk { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid #2f5fd0; box-shadow: 0 0 0 3px #2f5fd055; }

body.in3d #top, body.in3d #offline:not(.hidden) ~ #top { display: none; }
body.in3d #offline { top: calc(50px + var(--safe-t)); }
a.btn { color: var(--text); text-decoration: none; display: inline-block; }
.site .row { gap: 6px; } .site .row .btn { padding: 7px 10px; font-size: 13px; }
@media (max-width: 820px) { .leaflet-control-zoom { display: none; } }
