:root {
  --bg: #05080a;
  --panel: rgba(6, 12, 14, 0.86);
  --line: rgba(120, 255, 190, 0.18);
  --fg: #cfeee0;
  --dim: #7fa396;
  --accent: #5dffb0;
  --warn: #ffb347;
  --err: #ff6b6b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 13px/1.4 var(--mono); overflow: hidden; }
#globe { position: fixed; inset: 0; }
/* Keep provider attribution visible (required by Esri / Google 3D Tiles), just tucked bottom-left and dimmed. */
.cesium-viewer-bottom { left: auto; right: 8px; bottom: 4px; opacity: 0.7; font-size: 10px; }
.cesium-credit-logoContainer img { max-height: 18px; }
.cesium-credit-lightbox-overlay { z-index: 50; }

a { color: var(--accent); }
button { font: inherit; color: var(--fg); background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.on { background: rgba(93,255,176,0.14); border-color: var(--accent); color: #fff; }
button.primary { background: var(--accent); color: #002314; border-color: var(--accent); }

.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; gap: 16px; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  pointer-events: none; letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--err); box-shadow: 0 0 8px var(--err); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.clock { margin-left: auto; color: var(--dim); }
.coords { color: var(--dim); min-width: 170px; text-align: right; }
body.no-hud .hud-top { display: none; }

.fab { position: fixed; z-index: 21; top: calc(env(safe-area-inset-top) + 44px); left: 12px; width: 40px; height: 40px; padding: 0; background: var(--panel); font-size: 18px; }

.panel {
  position: fixed; z-index: 20; top: calc(env(safe-area-inset-top) + 92px); left: 12px; bottom: 12px;
  width: 300px; max-width: calc(100vw - 24px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 4px 14px 14px; transition: transform .2s ease, opacity .2s ease;
}
.panel.closed { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.panel section { border-bottom: 1px solid var(--line); padding: 10px 0; }
.panel h2 { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin: 4px 0 8px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.row input { accent-color: var(--accent); }
.row em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--dim); white-space: nowrap; }
.row em.ok { color: var(--accent); }
.row em.warn { color: var(--warn); }
.row em.err { color: var(--err); }
.sub { padding: 2px 0 6px 24px; }
select { font: inherit; width: 100%; color: var(--fg); background: #0b1512; border: 1px solid var(--line); border-radius: 6px; padding: 5px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.seg button { flex: 1 1 auto; padding: 5px 8px; font-size: 12px; }
.hint { color: var(--dim); font-size: 11px; margin: 6px 0 0; }
.actions { display: grid; gap: 6px; }
.credits { color: var(--dim); font-size: 10.5px; padding-top: 10px; }

#launches { margin: 0; padding-left: 18px; }
#launches li { margin-bottom: 8px; cursor: pointer; }
#launches li small { display: block; color: var(--dim); }
#launches li .t { color: var(--warn); }

.card {
  position: fixed; z-index: 20; right: 12px; bottom: 36px; width: 320px; max-width: calc(100vw - 24px);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 12px 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 0 24px rgba(93,255,176,0.15);
}
.card h3 { margin: 0 0 6px; font-size: 14px; color: #fff; letter-spacing: 0.04em; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.card dt { color: var(--dim); }
.card dd { margin: 0; text-align: right; }
.card .links { margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.card .close { position: absolute; top: 6px; right: 6px; border: none; background: none; font-size: 18px; padding: 2px 8px; }
.card .track { margin-top: 8px; width: 100%; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; }

dialog { background: #08110e; color: var(--fg); border: 1px solid var(--accent); border-radius: 12px; max-width: 440px; width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h2 { margin-top: 0; font-size: 15px; }
dialog label { display: grid; gap: 4px; margin: 12px 0; }
dialog input { font: inherit; color: var(--fg); background: #0b1512; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
code { color: var(--accent); }

@media (max-width: 640px) {
  .coords { display: none; }
  .panel { width: calc(100vw - 24px); bottom: auto; max-height: 62vh; }
  .card { left: 12px; right: 12px; width: auto; }
}

/* ---------- Lock chip (vault state) ---------- */
.fab.lock { top: calc(env(safe-area-inset-top) + 44px); left: auto; right: 12px; }

/* ---------- Weather timeline ---------- */
.timeline {
  position: fixed; z-index: 19; left: 50%; transform: translateX(-50%); bottom: 12px;
  width: min(620px, calc(100vw - 24px)); display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.timeline button { padding: 4px 8px; }
.timeline input[type=range] { flex: 1; accent-color: var(--accent); min-width: 60px; }
#tlLabel { min-width: 112px; text-align: center; font-size: 12px; color: var(--fg); }
#tlLabel.live { color: var(--err); font-weight: 700; letter-spacing: 0.1em; }
body.tl-on .card { bottom: 64px; }
body.tl-on .cesium-viewer-bottom { bottom: 58px; }

/* ---------- Power up dialog ---------- */
dialog { max-height: calc(100vh - 32px); overflow-y: auto; max-width: 520px; }
dialog .warn { color: var(--warn); }
dialog .err { color: var(--err); }
dialog small { color: var(--dim); font-weight: normal; }
.prov { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.prov.next { opacity: 0.75; }
.prov-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.prov input { width: 100%; font: inherit; color: var(--fg); background: #0b1512; border: 1px solid var(--line); border-radius: 6px; padding: 7px; margin-top: 4px; }
.prov .hint { margin: 4px 0; }
.tag { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--dim); }
.tag.active { color: var(--accent); border-color: var(--accent); }
.tag.set { color: #002314; background: var(--accent); border-color: var(--accent); }
.tag.route { color: var(--fg); }
button.danger { color: var(--err); border-color: rgba(255,107,107,0.4); margin-right: auto; }

@media (max-width: 640px) {
  #tlLabel { min-width: 84px; font-size: 11px; }
  .timeline #tlBack, .timeline #tlFwd { display: none; }
}
.timeline[hidden], .fab[hidden] { display: none; }

/* ---------- Cameras ---------- */
button.wide { width: 100%; margin: 4px 0 2px; }
.cam-img { display: block; width: 100%; max-height: 240px; object-fit: contain; background: #000; border: 1px solid var(--line); border-radius: 6px; margin: 4px 0 6px; }

/* ---------- Search + locate ---------- */
.search {
  position: fixed; z-index: 22; top: calc(env(safe-area-inset-top) + 44px); left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100vw - 128px)); display: flex; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px 4px 3px 10px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; font: inherit; color: var(--fg); background: transparent; border: 0; outline: 0; padding: 7px 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search button.icon { border: 0; background: transparent; padding: 6px 8px; font-size: 15px; line-height: 1; }
.search button.icon:hover { background: rgba(255,255,255,0.06); }
#locateBtn.busy { animation: blink 1s infinite; }
#locateBtn.on { background: rgba(77,163,255,0.22); border-radius: 6px; }
.search.busy { border-color: var(--warn); }
#searchList {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: #08110e; border: 1px solid var(--line); border-radius: 10px; max-height: 50vh; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
#searchList[hidden] { display: none; }
#searchList li { padding: 7px 9px; border-radius: 6px; cursor: pointer; }
#searchList li b { display: block; font-weight: 600; color: #fff; }
#searchList li small { display: block; color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#searchList li.on, #searchList li:hover { background: rgba(93,255,176,0.12); }
@media (max-width: 640px) {
  .search { width: calc(100vw - 120px); }
  .panel { top: calc(env(safe-area-inset-top) + 92px); }
}

/* ---------- Outdoors ---------- */
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 4px; }
.btn-grid.three { grid-template-columns: 1.3fr 1fr 1fr; margin: 6px 0 0; }
.btn-grid button { font-size: 12px; padding: 7px 6px; }
.btn-grid button:disabled { opacity: 0.4; cursor: default; }
.btn-grid button.on { background: rgba(255,59,212,0.18); border-color: #ff3bd4; }
.track-box { border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; margin-top: 6px; }
.track-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; }
#trackStats { color: var(--dim); font-size: 11px; text-align: right; }
#trackStats.rec { color: #ff3bd4; }
.row.units { cursor: default; justify-content: space-between; margin-top: 6px; }
.row.units select { width: auto; flex: 0 1 190px; }
.hint.warn { color: var(--warn); }
.warnbox { background: rgba(255,179,71,0.12); border: 1px solid rgba(255,179,71,0.5); border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12px; line-height: 1.5; }
.hours { display: flex; gap: 4px; margin: 6px 0; }
.hours span { flex: 1; text-align: center; font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 2px; }
.hours b { display: block; color: var(--dim); font-weight: normal; }
.hours i { display: block; font-style: normal; color: #6ec6ff; }
.bigcoords { font-size: 18px; letter-spacing: 0.03em; color: #fff; margin: 4px 0 8px; user-select: all; }
.card .links button { font-size: 12px; }
.card .links a { font-size: 12px; }
.progress { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
.progress[hidden] { display: none; }
#offBar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.card { max-height: calc(100vh - 140px); overflow-y: auto; }

/* ---------- Power up: key how-tos and tests ---------- */
.prov details.howto { margin: 4px 0 6px; font-size: 12px; }
.prov details.howto summary { cursor: pointer; color: var(--accent); }
.prov details.howto ol { margin: 6px 0 4px; padding-left: 20px; line-height: 1.5; }
.prov details.howto li { margin-bottom: 3px; }
.key-row { display: flex; gap: 6px; align-items: center; }
.key-row input { flex: 1; margin-top: 0 !important; }
.key-row button { flex: 0 0 auto; padding: 7px 10px; }
.test-msg { margin: 5px 0 0; }
.test-msg.ok { color: var(--accent); }
.test-msg.err { color: var(--err); }
details.coming { margin: 10px 0; border-top: 1px solid var(--line); padding-top: 8px; }
details.coming > summary { cursor: pointer; color: var(--dim); font-size: 12px; }
/* Windy images: never upscaled (terms), capped to the card width */
.wc-img { display: block; width: auto; max-width: 100%; height: auto; margin: 4px 0 6px; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- Power up: single-screen setup ---------- */
.pass-box { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 8px; margin: 10px 0; }
.pass-box legend, h3.keys-h { font-size: 13px; color: #fff; padding: 0 4px; }
h3.keys-h { margin: 14px 0 4px; padding: 0; }
h3.keys-h small, h4.group-h small { color: var(--dim); font-weight: normal; }
h4.group-h { margin: 12px 0 2px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.key-row button.icon { padding: 6px 8px; }
