:root {
  --bg1: #0b1a2e;
  --bg2: #02070f;
  --panel: rgba(10, 22, 40, .78);
  --line: rgba(140, 190, 255, .16);
  --text: #e8f1ff;
  --muted: #8ea5c4;
  --accent: #4aa8ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at 50% 35%, var(--bg1), var(--bg2) 75%);
}

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; }

/* Etiquetas 3D */
.label {
  pointer-events: none;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.6);
  white-space: nowrap;
  transition: opacity .3s;
}
.label.small { font-size: 10px; font-weight: 400; }
.label.dim { opacity: .35; }

/* Barra superior */
#topbar {
  position: fixed;
  top: 16px; left: 16px; right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}
#topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.flag { display: flex; width: 36px; height: 24px; border-radius: 4px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.flag i { flex: 1; background: #4997d0; }
.flag i:nth-child(2) { background: #fff; }
h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .5px; }
h1 span { color: var(--accent); }
#crumbs { font-size: 13px; color: var(--muted); }
#crumbs button { all: unset; cursor: pointer; }
#crumbs button:hover { color: var(--text); text-decoration: underline; }
#crumbs .sep { margin: 0 6px; opacity: .6; }
#crumbs .current { color: var(--text); }

.btn {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background .2s, border-color .2s;
}
.btn:hover { background: rgba(74,168,255,.25); border-color: var(--accent); }

/* Panel lateral */
#panel {
  position: fixed;
  top: 84px; right: 16px; bottom: 16px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  z-index: 4;
}
.eyebrow { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
#info h2 { margin: 4px 0 4px; font-size: 24px; line-height: 1.15; }
#info-sub { margin: 0; font-size: 13px; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stats:empty { display: none; }
.stat { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 17px; }
.stat small { font-size: 11px; color: var(--muted); }

#search {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

#list { list-style: none; margin: 0; padding: 0 4px 0 0; overflow-y: auto; flex: 1; }
#list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
#list li:hover, #list li.active { background: rgba(74,168,255,.16); }
#list li.selected { background: rgba(74,168,255,.3); }
#list .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
#list .count { margin-left: auto; font-size: 12px; color: var(--muted); }
#list::-webkit-scrollbar { width: 6px; }
#list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

#tooltip {
  position: fixed;
  pointer-events: none;
  padding: 6px 10px;
  font-size: 13px;
  background: rgba(5, 12, 24, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  opacity: 0;
  transform: translate(14px, 14px);
  transition: opacity .15s;
  z-index: 10;
}
#tooltip small { display: block; color: var(--muted); font-size: 11px; }

#hint {
  position: fixed;
  left: 16px; bottom: 12px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  z-index: 3;
}

#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: var(--bg2);
  z-index: 20;
  transition: opacity .6s;
}
#loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 42px; height: 42px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  #topbar { top: 12px; left: 12px; right: 12px; }
  h1 { font-size: 18px; }
  #panel {
    top: auto; left: 12px; right: 12px; bottom: 12px;
    width: auto;
    height: 38vh;
    padding: 14px;
  }
  #info h2 { font-size: 19px; }
  .stats { display: none; }
  #hint { display: none; }
}
