/* OCULUS: terminal-green on near-black, readable first, hacker second. */
:root {
  --bg: #05080a;
  --bg-2: #0a1014;
  --bg-3: #101a20;
  --line: #1c2c33;
  --fg: #c8f7dc;
  --muted: #7fa392;
  --green: #39ff88;
  --cyan: #3be8ff;
  --amber: #ffc53d;
  --red: #ff4d5e;
  --violet: #b98cff;
  --font: ui-monospace, "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
  --radius: 6px;
  --topbar: 52px;
  --terminal: 46px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--font);
  display: grid;
  grid-template-rows: var(--topbar) 1fr auto;
  overflow: hidden;
}
a { color: var(--cyan); }
a:hover { color: var(--green); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font: inherit;
  font-size: 12px;
  color: var(--green);
}
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 9999; background: var(--bg); padding: 6px 10px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  color: var(--green);
  background: transparent;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  text-transform: lowercase;
}
.btn:hover { background: rgba(57, 255, 136, 0.12); }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--green); border-color: var(--green); }
.btn.small { padding: 1px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: progress; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.eye {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--green);
  box-shadow: 0 0 10px rgba(57, 255, 136, 0.6), inset 0 0 0 5px var(--bg), inset 0 0 0 9px var(--green);
  animation: pulse 3s ease-in-out infinite;
}
.brand-name { font-weight: 700; letter-spacing: 0.3em; color: var(--green); text-shadow: 0 0 8px rgba(57, 255, 136, 0.5); }
.brand-tag { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { color: var(--cyan); font-variant-numeric: tabular-nums; }
.sources { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.sources li {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line);
}
.sources li.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.sources li.down { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 250px 1fr 380px;
  min-height: 0;
}
.sidebar, .panel { background: var(--bg-2); min-height: 0; overflow-y: auto; }
.sidebar { border-right: 1px solid var(--line); padding: 12px; }
.panel { border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.15em; margin: 4px 0 10px; font-weight: 400; }
.hint { margin-top: 16px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; }

/* ---------- layer toggles ---------- */
.layer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--bg);
}
.layer-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.layer-head input { accent-color: var(--green); width: 16px; height: 16px; margin: 0; }
.layer-name { flex: 1; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.layer-desc { color: var(--muted); font-size: 12px; margin: 4px 0 0 24px; }
.layer-actions { margin: 6px 0 0 24px; display: flex; gap: 6px; flex-wrap: wrap; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 0 24px; }
.chip {
  font: inherit; font-size: 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted);
  padding: 0 8px; cursor: pointer;
}
.chip[aria-pressed="true"] { color: var(--bg); background: var(--amber); border-color: var(--amber); }

/* ---------- map ---------- */
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #0b0f12; }
.scanlines {
  pointer-events: none;
  position: absolute; inset: 0; z-index: 401;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.map-hud {
  position: absolute; left: 10px; bottom: 26px; z-index: 402;
  background: rgba(5, 8, 10, 0.85); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 8px; font-size: 12px; color: var(--muted);
  pointer-events: none;
}
.map-hud:empty { display: none; }
.layers-toggle { display: none; position: absolute; top: 10px; right: 10px; z-index: 402; background: var(--bg); }

.leaflet-container { font: 13px/1.4 var(--font); background: #0b0f12; }
.leaflet-tile-pane { filter: sepia(0.35) hue-rotate(95deg) saturate(1.6) brightness(1.1); }
.leaflet-labels-pane { pointer-events: none; opacity: 0.8; }
.leaflet-control-zoom a, .leaflet-bar a { background: var(--bg-2); color: var(--green); border-color: var(--line); }
.leaflet-control-zoom a:hover { background: var(--bg-3); color: var(--green); }
.leaflet-control-attribution { background: rgba(5, 8, 10, 0.75) !important; color: var(--muted); font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--green); border-radius: var(--radius);
  box-shadow: 0 0 16px rgba(57, 255, 136, 0.25);
}
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-tooltip { background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); font: 12px var(--font); }
.leaflet-tooltip::before { display: none; }

.pop-title { color: var(--green); font-weight: 700; margin-bottom: 4px; }
.pop-row { font-size: 12px; color: var(--muted); }
.pop-row b { color: var(--fg); font-weight: 400; }

.plane { width: 14px; height: 14px; display: grid; place-items: center; }
.plane span {
  display: block; color: var(--cyan); font-size: 12px; line-height: 1;
  transform: rotate(var(--rot, 0deg));
  text-shadow: 0 0 4px rgba(59, 232, 255, 0.8);
}
.plane.emergency span { color: var(--red); text-shadow: 0 0 6px var(--red); }
.iss-icon {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--violet); background: rgba(185, 140, 255, 0.25);
  display: grid; place-items: center; color: var(--violet); font-size: 10px; font-weight: 700;
  box-shadow: 0 0 14px var(--violet);
  animation: pulse 2s ease-in-out infinite;
}

/* ---------- tabs and views ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
.tabs [role="tab"] {
  flex: 1; font: inherit; text-transform: lowercase;
  background: transparent; color: var(--muted);
  border: 0; border-bottom: 2px solid transparent;
  padding: 10px 4px; cursor: pointer;
}
.tabs [role="tab"]:hover { color: var(--fg); }
.tabs [role="tab"][aria-selected="true"] { color: var(--green); border-bottom-color: var(--green); }
.views { flex: 1; min-height: 0; overflow-y: auto; }
[role="tabpanel"] { padding: 10px 12px 16px; }

.toolbar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.input {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 8px; flex: 1; min-width: 0;
}
.input:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 2px rgba(57, 255, 136, 0.2); }
.input::placeholder { color: #4d6a5c; }

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px;
  padding: 8px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid transparent;
}
.item:hover, .item:focus-visible { background: var(--bg-3); border-color: var(--line); }
.item + .item { margin-top: 2px; }
.badge {
  grid-row: span 2; align-self: start;
  min-width: 42px; text-align: center;
  font-size: 12px; font-weight: 700;
  border: 1px solid currentColor; border-radius: 4px; padding: 1px 4px;
}
.item-title { color: var(--fg); overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: 12px; }
a.item { text-decoration: none; }

.empty, .error, .loading { color: var(--muted); padding: 14px 4px; font-size: 13px; }
.error { color: var(--red); }
.loading::after { content: "_"; animation: blink 1s steps(1) infinite; }
.stale { color: var(--amber); font-size: 12px; margin-bottom: 8px; }

.c-green { color: var(--green); }
.c-cyan { color: var(--cyan); }
.c-amber { color: var(--amber); }
.c-red { color: var(--red); }
.c-violet { color: var(--violet); }

/* ---------- markets ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--bg); }
.tile-label { color: var(--muted); font-size: 12px; }
.tile-value { font-size: 16px; font-variant-numeric: tabular-nums; }
.up { color: var(--green); }
.down { color: var(--red); }
h3.sub { font-size: 12px; color: var(--muted); font-weight: 400; text-transform: uppercase; letter-spacing: 0.12em; margin: 14px 0 8px; }

/* ---------- recon ---------- */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 3px 10px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.rec-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 10px; background: var(--bg); }
.rec-block h4 { margin: 0 0 6px; color: var(--green); font-size: 13px; font-weight: 400; }
.rec-block h4::before { content: "> "; color: var(--muted); }
.examples { font-size: 12px; color: var(--muted); }
.examples button { font: inherit; background: none; border: 0; color: var(--cyan); cursor: pointer; padding: 0 2px; text-decoration: underline dotted; }
.tools { columns: 2; font-size: 12px; margin: 0; padding-left: 16px; }

/* ---------- terminal ---------- */
.terminal { border-top: 1px solid var(--line); background: var(--bg); padding: 6px 14px; }
#cmd-form { display: flex; align-items: center; gap: 10px; }
.prompt { color: var(--green); white-space: nowrap; }
#cmd {
  flex: 1; font: inherit; color: var(--fg); background: transparent;
  border: 0; outline: none; caret-color: var(--green); padding: 6px 0;
}
.cmd-out { display: block; color: var(--muted); font-size: 12px; white-space: pre-wrap; max-height: 30vh; overflow-y: auto; }
.cmd-out:empty { display: none; }

/* ---------- dialog ---------- */
dialog {
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--green); border-radius: var(--radius);
  max-width: min(640px, 92vw); padding: 18px 22px;
  box-shadow: 0 0 40px rgba(57, 255, 136, 0.2);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog h2 { color: var(--green); font-size: 16px; margin-top: 0; }
dialog h3 { color: var(--muted); font-size: 13px; font-weight: 400; }
dialog pre { background: var(--bg); border: 1px solid var(--line); padding: 10px; overflow-x: auto; color: var(--cyan); }
dialog li { margin-bottom: 4px; }

@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- responsive: tablet ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px 1fr 330px; }
  .brand-tag { display: none; }
}

/* ---------- responsive: phone, map on top and panel below ---------- */
@media (max-width: 760px) {
  body { overflow: auto; grid-template-rows: var(--topbar) auto auto; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .map-wrap { grid-row: 1; }
  .panel { grid-row: 2; border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .sidebar {
    position: fixed; top: var(--topbar); right: 0; bottom: 0; width: min(300px, 86vw);
    z-index: 1000; transform: translateX(100%); transition: transform 0.2s ease;
    border-left: 1px solid var(--green);
  }
  .sidebar.open { transform: none; }
  .layers-toggle { display: block; }
  .sources { display: none; }
  .terminal { position: sticky; bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* traffic camera popup */
.cam-img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; margin-top: 6px; background: #000; border: 1px solid var(--line); object-fit: cover; }
