/* ── OSIRIS × Devin-style interface ─────────────────────────────── */
:root {
  --bg: #0b0b0d;
  --bg-elev: #131316;
  --bg-card: #16171b;
  --border: #26272c;
  --border-soft: #1e1f24;
  --text: #e6e6ea;
  --text-dim: #9a9aa3;
  --text-faint: #66666f;
  --accent: #6e5bff;
  --accent-soft: rgba(110, 91, 255, .14);
  --green: #34c07c;
  --amber: #e0a63f;
  --red: #e05c5c;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 10px;
  --topbar-h: 52px;
  --sidebar-w: 232px;
  --ticker-h: 34px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #app { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); font-size: 11.5px; }
.hidden { display: none !important; }

#app { display: flex; flex-direction: column; }

/* ── Top bar ── */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #2b2b33, #1a1a20);
  border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 13.5px; letter-spacing: .14em; }
.brand-sub { font-size: 10.5px; color: var(--text-dim); }

.cmdk {
  flex: 1; max-width: 420px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-faint);
  cursor: text;
  transition: border-color .15s;
}
.cmdk:hover, .cmdk:focus-within { border-color: #3a3b42; }
.cmdk-hint { flex: 1; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk kbd {
  font-family: var(--mono); font-size: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; color: var(--text-dim);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 9px;
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap;
}
.chip-label { color: var(--text-faint); font-size: 9.5px; letter-spacing: .08em; }
.chip .mono { color: var(--text); }
.chip-live { color: var(--green); font-weight: 600; font-size: 10.5px; letter-spacing: .06em; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--green); box-shadow: 0 0 0 3px rgba(52,192,124,.18); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(52,192,124,.05); } }

.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 7px;
  padding: 5px 11px; font-size: 12px; font-family: inherit;
  cursor: pointer; transition: .15s;
}
.btn-ghost:hover { color: var(--text); border-color: #3a3b42; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3f7dff);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: #fff;
  margin-left: 4px;
}

/* ── Body / layout ── */
.body { flex: 1; display: flex; min-height: 0; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.side-scroll { flex: 1; overflow-y: auto; padding: 10px 8px; }
.side-section { margin-bottom: 18px; }
.side-label {
  font-size: 10px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 0 8px; margin-bottom: 6px;
}
.side-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 7px;
  color: var(--text-dim); cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
}
.side-item:hover { background: rgba(255,255,255,.045); color: var(--text); }
.side-item.active { background: var(--accent-soft); color: var(--text); }
.side-item-icon { display: grid; place-items: center; color: var(--text-faint); flex-shrink: 0; }
.side-item.active .side-item-icon, .side-item:hover .side-item-icon { color: var(--text-dim); }
.side-item-name { flex: 1; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-count {
  font-family: var(--mono); font-size: 10px;
  color: var(--text-faint); background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 0 5px; min-width: 22px; text-align: center;
}
.side-footer { padding: 8px; border-top: 1px solid var(--border-soft); }

/* toggle switch */
.switch {
  width: 30px; height: 17px; border-radius: 10px;
  background: #2a2b31; position: relative;
  transition: background .15s; flex-shrink: 0;
}
.switch span {
  position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #888892; transition: .15s;
}
.switch.on { background: var(--accent); }
.switch.on span { left: 15px; background: #fff; }

/* segmented control */
.seg {
  display: flex; gap: 2px; margin: 0 8px 8px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 3px;
}
.seg-btn {
  flex: 1; background: transparent; border: 0;
  color: var(--text-faint); font-family: inherit; font-size: 11.5px;
  padding: 5px 0; border-radius: 6px; cursor: pointer; transition: .12s;
}
.seg-btn.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* ── Map area ── */
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
#map.basemap-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(190deg) brightness(.92) contrast(.88) saturate(.25); }
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution {
  background: rgba(11,11,13,.7) !important; color: var(--text-faint) !important;
  font-size: 9px !important; backdrop-filter: blur(4px);
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-popup-content-wrapper {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 12px;
}
.leaflet-popup-tip { background: var(--bg-card); border: 1px solid var(--border); }
.leaflet-popup-content { margin: 10px 14px; }
.leaflet-popup-close-button { color: var(--text-dim) !important; }
.popup-title { font-weight: 600; margin-bottom: 4px; font-size: 12.5px; }
.popup-row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-dim); }
.popup-row b { color: var(--text); font-family: var(--mono); font-weight: 500; font-size: 11px; }

.card {
  background: rgba(22,23,27,.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}

/* map controls */
.map-controls {
  position: absolute; left: 14px; bottom: 14px; z-index: 800;
  display: flex; flex-direction: column; overflow: hidden;
}
.mc-btn {
  width: 34px; height: 32px;
  background: transparent; border: 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim); font-size: 15px;
  cursor: pointer; display: grid; place-items: center;
  transition: .12s;
}
.mc-btn:last-child { border-bottom: 0; }
.mc-btn:hover { background: rgba(255,255,255,.05); color: var(--text); }

/* readout */
.map-readout {
  position: absolute; left: 14px; bottom: 60px; z-index: 800;
  padding: 6px 10px; color: var(--text-dim);
  font-size: 10.5px; letter-spacing: .04em;
}

/* feed panel */
.feed {
  position: absolute; top: 14px; right: 14px; z-index: 800;
  width: 300px; max-height: calc(100% - 60px);
  display: flex; flex-direction: column; overflow: hidden;
}
.feed-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-soft);
}
.feed-title { flex: 1; font-size: 12px; font-weight: 600; }
.feed-list { flex: 1; overflow-y: auto; padding: 6px; }
.feed-item {
  display: flex; gap: 9px; padding: 7px 8px;
  border-radius: 7px; align-items: flex-start;
}
.feed-item:hover { background: rgba(255,255,255,.035); }
.feed-icon {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--border-soft);
  font-size: 10px;
}
.feed-body { flex: 1; min-width: 0; }
.feed-text { font-size: 11.5px; line-height: 1.35; }
.feed-meta { font-size: 10px; color: var(--text-faint); margin-top: 2px; font-family: var(--mono); }

/* ── Ticker ── */
.ticker {
  height: var(--ticker-h); flex-shrink: 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; overflow: hidden;
}
.ticker-inner {
  display: flex; gap: 28px; white-space: nowrap;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
  padding-left: 14px;
  animation: tick 60s linear infinite;
}
@keyframes tick { to { transform: translateX(-50%); } }
.ticker-item { display: flex; gap: 6px; align-items: center; }
.t-up { color: var(--green); } .t-down { color: var(--red); }

/* ── Command palette ── */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
  display: flex; justify-content: center; padding-top: 14vh;
}
.palette { width: 480px; max-height: 320px; display: flex; flex-direction: column; overflow: hidden; }
.palette input {
  background: transparent; border: 0; outline: 0;
  color: var(--text); font-family: inherit; font-size: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft);
}
.palette-list { overflow-y: auto; padding: 6px; }
.palette-item {
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; gap: 9px; color: var(--text-dim);
}
.palette-item:hover, .palette-item.sel { background: var(--accent-soft); color: var(--text); }
.palette-item .kind { margin-left: auto; font-size: 10px; color: var(--text-faint); font-family: var(--mono); }

/* markers */
.mk { border-radius: 50%; border: 1.5px solid; background: rgba(0,0,0,.4); }
.mk-plane { width: 10px; height: 10px; border-color: #7db4ff; background: rgba(125,180,255,.55); }
.mk-ship { width: 9px; height: 9px; border-color: #4fd8c4; background: rgba(79,216,196,.5); border-radius: 2px; }
.mk-sat { width: 8px; height: 8px; border-color: #c9a6ff; background: rgba(201,166,255,.55); }
.mk-cam { width: 9px; height: 9px; border-color: #ffd479; background: rgba(255,212,121,.5); border-radius: 2px; }
.mk-quake { border-color: #ff8a6b; background: rgba(255,138,107,.6); }
.mk-quake-big { border-color: #ff5c5c; background: rgba(255,92,92,.75); box-shadow: 0 0 12px rgba(255,92,92,.5); }
.mk-incident { width: 9px; height: 9px; border-color: #ff9db1; background: rgba(255,157,177,.5); transform: rotate(45deg); border-radius: 2px; }
.mk-news { width: 8px; height: 8px; border-color: #8ab8ff; background: rgba(138,184,255,.5); }

/* stream viewer */
.viewer {
  position: absolute; bottom: 14px; right: 14px; z-index: 900;
  width: 340px; overflow: hidden;
}
.viewer-body { background: #000; aspect-ratio: 16/9; display: grid; place-items: center; }
.viewer-body iframe, .viewer-body video, .viewer-body img { width: 100%; height: 100%; border: 0; object-fit: cover; }
.viewer-meta { padding: 8px 12px; font-size: 10.5px; color: var(--text-dim); border-top: 1px solid var(--border-soft); }
.viewer-err { color: var(--text-dim); font-size: 11.5px; padding: 20px; text-align: center; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2c2d33; border-radius: 5px; border: 2px solid var(--bg-elev); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .brand-sub, .cmdk-hint, .chip-label, #support-btn { display: none; }
  .sidebar { width: 52px; }
  .side-item-name, .side-count, .side-label, .seg, .side-footer { display: none; }
  .side-item { justify-content: center; padding: 8px; }
  .feed { width: min(300px, calc(100vw - 90px)); }
}
