:root {
  --ink-900: #0a0e1a;
  --ink-800: #121729;
  --ink-700: #1c2340;
  --ink-600: #2a3358;
  --brass: #c6a04a;
  --brass-bright: #e0bd6b;
  --brass-dim: #7d6631;
  --parchment: #ece4d0;
  --parchment-dim: #9a9683;
  --exo: #8fd3c5;
  --panel-bg: rgba(14, 18, 34, 0.86);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #03040a;
  color: var(--parchment);
  font-family: var(--sans);
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: grab;
  touch-action: none;
}
#sky.dragging { cursor: grabbing; }

button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 0.75rem 1.2rem;
  background: linear-gradient(rgba(5, 7, 14, 0.92), rgba(5, 7, 14, 0));
  pointer-events: none;
  z-index: 10;
}
.topbar > * { pointer-events: auto; }
.brand { flex: 0 0 auto; }
.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 0.2rem;
}
.topbar h1 {
  font-family: var(--serif);
  font-weight: normal;
  font-size: 1.45rem;
  margin: 0;
  letter-spacing: 0.01em;
}
.search-wrap { position: relative; flex: 1 1 auto; max-width: 30rem; margin-left: auto; }
#search {
  width: 100%;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--ink-600);
  background: rgba(18, 23, 41, 0.9);
  color: var(--parchment);
  font-size: 0.86rem;
}
#search:focus { outline: none; border-color: var(--brass-dim); }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--ink-800);
  border: 1px solid var(--ink-600);
  border-radius: 6px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.search-results li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.84rem;
  cursor: pointer;
}
.search-results li.active, .search-results li:hover { background: var(--ink-700); }
.search-results .kind { font-family: var(--mono); font-size: 0.68rem; color: var(--parchment-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.top-actions { display: flex; gap: 0.5rem; align-items: center; }
#pack-select {
  background: rgba(18, 23, 41, 0.9);
  color: var(--parchment);
  border: 1px solid var(--ink-600);
  border-radius: 6px;
  padding: 0.42rem 0.5rem;
  font-size: 0.78rem;
  max-width: 17rem;
}
.icon-btn {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--ink-600);
  background: rgba(18, 23, 41, 0.9);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}
.icon-btn:hover { border-color: var(--brass-dim); color: var(--brass-bright); }
.icon-btn.small { width: 1.6rem; height: 1.6rem; font-size: 0.85rem; }

.data-banner {
  position: fixed;
  top: 4.1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: rgba(60, 40, 10, 0.75);
  border: 1px solid var(--brass-dim);
  color: var(--brass-bright);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- panels ---------- */
.panel {
  position: fixed;
  top: 4.6rem;
  bottom: 4.2rem;
  width: 19rem;
  background: var(--panel-bg);
  border: 1px solid var(--ink-600);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  overflow-y: auto;
  z-index: 8;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-600) transparent;
}
.panel.left { left: 1rem; }
.panel.right { right: 1rem; padding: 1.1rem 1.2rem; }
.tabs {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--ink-800);
  border-bottom: 1px solid var(--ink-600);
  z-index: 1;
}
.tab {
  flex: 1;
  padding: 0.6rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--parchment-dim);
}
.tab.active { color: var(--brass-bright); border-bottom-color: var(--brass); }
.tab-body { padding: 0.9rem 1rem 1.2rem; }
.panel h3 {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 1.1rem 0 0.45rem;
}
.panel h3:first-child { margin-top: 0.2rem; }
.hint { font-size: 0.75rem; color: var(--parchment-dim); margin: 0 0 0.5rem; line-height: 1.45; }
.btn-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.btn {
  padding: 0.42rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--ink-600);
  background: var(--ink-700);
  cursor: pointer;
  font-size: 0.78rem;
}
.btn:hover { border-color: var(--brass-dim); color: var(--brass-bright); }
.btn.primary { background: rgba(198, 160, 74, 0.16); border-color: var(--brass-dim); color: var(--brass-bright); }
.btn.active { border-color: var(--brass); color: var(--brass-bright); }
.filter {
  width: 100%;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.4rem;
  border-radius: 5px;
  border: 1px solid var(--ink-600);
  background: var(--ink-800);
  color: var(--parchment);
  font-size: 0.78rem;
}
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-600) transparent;
}
.list li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.3rem 0.45rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}
.list li:hover, .list li.active { background: var(--ink-700); }
.list li.active { color: var(--brass-bright); }
.list .meta { color: var(--parchment-dim); font-family: var(--mono); font-size: 0.7rem; white-space: nowrap; }
.exo-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--exo); vertical-align: middle; }
.toggle { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; padding: 0.2rem 0; cursor: pointer; }
.toggle input { accent-color: var(--brass); }
.slider { display: block; font-size: 0.78rem; margin: 0.35rem 0 0.6rem; }
.slider output { float: right; font-family: var(--mono); font-size: 0.72rem; color: var(--brass-bright); }
.slider input { width: 100%; accent-color: var(--brass); margin-top: 0.3rem; }
.seg { display: flex; border: 1px solid var(--ink-600); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; padding: 0.35rem; background: none; border: none; cursor: pointer; font-size: 0.76rem; color: var(--parchment-dim); }
.seg button.active { background: var(--ink-700); color: var(--brass-bright); }
.about { font-size: 0.76rem; line-height: 1.5; color: var(--parchment-dim); }
.about p { margin: 0 0 0.5rem; }
.about strong { color: var(--parchment); font-weight: 600; }

/* ---------- info panel ---------- */
.close { position: absolute; top: 0.7rem; right: 0.7rem; }
#info-body h2 { font-family: var(--serif); font-weight: normal; font-size: 1.45rem; margin: 0 2rem 0.15rem 0; line-height: 1.2; }
#info-body .sub { font-family: var(--mono); font-size: 0.72rem; color: var(--parchment-dim); margin: 0 0 0.8rem; letter-spacing: 0.04em; }
#info-body dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.8rem; margin: 0.6rem 0 0.9rem; font-size: 0.8rem; }
#info-body dt { color: var(--parchment-dim); }
#info-body dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
#info-body .note {
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.6rem 0.7rem;
  margin: 0.7rem 0;
  border-left: 2px solid var(--exo);
  background: rgba(143, 211, 197, 0.06);
  border-radius: 0 6px 6px 0;
}
#info-body .note.warn { border-left-color: var(--brass); background: rgba(198, 160, 74, 0.07); }
#info-body .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0; }
.ext-link {
  display: inline-block;
  margin: 0.35rem 1rem 0 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--brass-bright);
  text-decoration: none;
  border-bottom: 1px solid var(--brass-dim);
}
.ext-link:hover { color: #fff; border-color: var(--brass-bright); }
.ext-link.exo { color: var(--exo); border-color: rgba(143, 211, 197, 0.4); }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.2rem 0.75rem;
  background: linear-gradient(rgba(5, 7, 14, 0), rgba(5, 7, 14, 0.9));
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--parchment-dim);
  z-index: 7;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-block { line-height: 1.6; min-width: 16rem; }
.hud-block.right { text-align: right; }
.hud-block b { color: var(--parchment); font-weight: normal; }
.hud-block .mode { color: var(--brass-bright); }
.hud-time { display: flex; align-items: center; gap: 0.6rem; }
#s-time { width: min(30vw, 22rem); accent-color: var(--brass); }
#o-time { min-width: 9rem; color: var(--parchment); }

/* ---------- labels ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.lbl {
  position: absolute;
  left: 0; top: 0;
  white-space: nowrap;
  font-size: 0.72rem;
  color: rgba(236, 228, 208, 0.82);
  text-shadow: 0 0 4px #000, 0 0 2px #000;
  will-change: transform;
}
.lbl.con {
  font-family: var(--serif);
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(224, 189, 107, 0.55);
}
.lbl.con.hi { color: rgba(224, 189, 107, 0.95); }
.lbl.host::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  border: 1.5px solid var(--exo);
  vertical-align: -1px;
}
.lbl.host { color: rgba(170, 225, 214, 0.9); }
.lbl.ring { font-family: var(--mono); font-size: 0.64rem; color: rgba(125, 140, 190, 0.8); }
.lbl.sel { color: var(--brass-bright); }
.reticle {
  position: fixed;
  left: 0; top: 0;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border: 1.5px solid var(--brass-bright);
  border-radius: 50%;
  pointer-events: none;
  z-index: 6;
  box-shadow: 0 0 8px rgba(224, 189, 107, 0.4);
}
.reticle-hover { border-color: rgba(236, 228, 208, 0.45); box-shadow: none; width: 20px; height: 20px; margin: -10px 0 0 -10px; }

/* ---------- overlays ---------- */
.loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--ink-900);
  z-index: 50;
  transition: opacity 0.5s;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading p { margin: 0; }
#loading-text { font-family: var(--serif); font-size: 1.1rem; }
.loading .bar { width: 16rem; height: 3px; background: var(--ink-700); border-radius: 2px; overflow: hidden; margin-top: 0.6rem; }
#loading-bar { width: 0; height: 100%; background: var(--brass); transition: width 0.2s; }
.loading.error #loading-text { color: #ff9b8a; max-width: 34rem; text-align: center; }

.help { position: fixed; inset: 0; background: rgba(3, 4, 10, 0.7); display: flex; align-items: center; justify-content: center; z-index: 40; }
.help[hidden] { display: none; }
.help-card { position: relative; background: var(--ink-800); border: 1px solid var(--ink-600); border-radius: 12px; padding: 1.4rem 1.8rem; min-width: 22rem; }
.help-card h2 { font-family: var(--serif); font-weight: normal; margin: 0 0 0.8rem; }
.help-card dl { display: grid; grid-template-columns: 7rem 1fr; gap: 0.35rem 1rem; margin: 0; font-size: 0.84rem; }
.help-card dt { font-family: var(--mono); color: var(--brass-bright); font-size: 0.78rem; }
.help-card dd { margin: 0; }

@media (max-width: 900px) {
  .panel { width: calc(100% - 2rem); top: auto; bottom: 4.4rem; max-height: 45vh; }
  .panel.left { display: none; }
  .topbar { flex-wrap: wrap; gap: 0.5rem 0.8rem; padding: 0.6rem 0.8rem; }
  .topbar h1 { font-size: 1.1rem; }
  .brand .eyebrow { display: none; }
  .top-actions { margin-left: auto; }
  #pack-select { max-width: 10rem; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .data-banner { top: 6.2rem; white-space: normal; text-align: center; width: calc(100% - 2rem); border-radius: 8px; font-size: 0.6rem; }
  .hud { padding: 0.5rem 0.8rem 0.6rem; justify-content: center; }
  .hud-block { min-width: 0; }
  #hud-pos, #hud-stats { display: none; }
  #s-time { width: 45vw; }
}
