/* ============================================================
   Campos semánticos · atlas orbital
   Sistema visual: vacío profundo, vidrio, plasma y precisión.
   ============================================================ */

/* ---------- Tokens ---------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-2: #0d0d0e;
  --panel: rgba(20, 20, 21, 0.55);
  --panel-strong: rgba(22, 22, 23, 0.92);
  --panel-solid: #121213;
  --stroke: rgba(255, 255, 255, 0.075);
  --stroke-2: rgba(255, 255, 255, 0.16);
  --ink: #ececec;
  --ink-2: #b8b8bb;
  --mute: #7b7b7f;
  --faint: #545457;
  --accent: #9aa5b4;
  --accent-2: #c3cad4;
  --accent-3: #c6a972;
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 34%, transparent);
  --sun-core: #d8dee6;
  --stage-bg: #0b0b0c;
  --shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9), 0 2px 12px -6px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 30px 70px -25px rgba(0, 0, 0, 0.85);
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f3;
  --bg-2: #ededeb;
  --panel: rgba(255, 255, 255, 0.68);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --panel-solid: #ffffff;
  --stroke: rgba(18, 20, 24, 0.085);
  --stroke-2: rgba(18, 20, 24, 0.18);
  --ink: #121212;
  --ink-2: #3a3a3d;
  --mute: #6b6b6f;
  --faint: #9b9b9f;
  --accent: #566274;
  --accent-2: #66707f;
  --accent-3: #8a6a2f;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 32%, transparent);
  --sun-core: #7e8a9c;
  --stage-bg: #f8f8f6;
  --shadow: 0 30px 60px -42px rgba(24, 26, 32, 0.4), 0 2px 10px -6px rgba(24, 26, 32, 0.18);
  --shadow-pop: 0 30px 60px -28px rgba(24, 26, 32, 0.36);
}


/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent-line); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid var(--stroke-2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-2);
}
[data-theme="light"] kbd { background: rgba(18, 20, 24, 0.04); }

/* ---------- Ambiente ---------- */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 620px at 12% -10%, rgba(255, 255, 255, 0.045), transparent 62%),
    radial-gradient(800px 560px at 100% 0%, rgba(255, 255, 255, 0.022), transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  opacity: 0.035;
  mix-blend-mode: overlay;
}
[data-theme="light"] .ambient {
  background:
    radial-gradient(900px 620px at 8% -12%, rgba(0, 0, 0, 0.035), transparent 60%),
    radial-gradient(780px 540px at 104% -8%, rgba(0, 0, 0, 0.018), transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
[data-theme="light"] .ambient::after { opacity: 0.035; }

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  min-width: 0;
  border-radius: 12px;
}
.brand-mark {
  width: 38px; height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--accent-3);
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.10), transparent 60%),
    var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 20px -16px rgba(0, 0, 0, 0.8);
}
.brand-mark svg { width: 23px; height: 23px; fill: none; stroke-width: 1.3; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-kicker {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1.2;
}
.brand h1 {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
  white-space: nowrap;
}
.brand-version {
  align-self: flex-start;
  margin-left: 2px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--mute);
  white-space: nowrap;
}

/* Buscador */
.search { position: relative; max-width: 620px; width: 100%; justify-self: center; }
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 10px 0 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015)), var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
[data-theme="light"] .search-field {
  background: rgba(255, 255, 255, 0.8);
}
.search-field:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 16px 34px -30px rgba(0, 0, 0, 0.7);
}
.search-icon {
  width: 17px; height: 17px;
  flex: none;
  fill: none;
  stroke: var(--mute);
  stroke-width: 1.6;
  stroke-linecap: round;
  transition: stroke 0.18s ease;
}
.search-field:focus-within .search-icon { stroke: var(--accent); }
#q {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  outline: none;
}
#q::placeholder { color: var(--mute); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-kbd { flex: none; opacity: 0.8; }
.search-field:focus-within .search-kbd { opacity: 0.35; }

.palette {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  max-height: min(430px, 62vh);
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--stroke-2);
  background: var(--panel-strong);
  backdrop-filter: blur(26px) saturate(140%);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 50;
  animation: pop-in 0.16s ease both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.99); } }
.palette-head {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}
.hit {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 9px 10px;
  text-align: left;
}
.hit:hover, .hit.active { background: var(--accent-soft); }
.hit.active .hit-lab { color: var(--ink); }
.hit-ico {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mute);
}
.hit.active .hit-ico { border-color: var(--accent-line); color: var(--accent); }
.hit-main { min-width: 0; }
.hit-lab { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hit-lab mark { background: transparent; color: var(--accent); font-weight: 600; }
.hit-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.hit-type {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  color: var(--mute);
  white-space: nowrap;
}
.hit-type.campo { color: var(--accent); border-color: var(--accent-line); }
.hit-type.hoja { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 35%, transparent); }
.palette-empty { padding: 26px 16px; text-align: center; color: var(--mute); font-size: 12.5px; }
.palette-foot {
  position: sticky;
  bottom: 0;
  display: flex; gap: 14px;
  padding: 8px 10px 8px;
  margin-top: 4px;
  border-top: 1px solid var(--stroke);
  background: var(--panel-strong);
  backdrop-filter: blur(14px);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--faint);
}

.top-actions { display: flex; align-items: center; gap: 8px; justify-self: end; }


.stat-pill {
  display: flex; align-items: center; gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--mute);
  white-space: nowrap;
}
.stat-pill .stat-num { color: var(--ink); font-size: 11.5px; font-weight: 500; }
.pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 50%, transparent);
  animation: pulse 2.6s ease-out infinite;
  flex: none;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 45%, transparent); }
  70% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent-2) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 0%, transparent); }
}
.icon-btn {
  width: 34px; height: 34px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  color: var(--ink-2);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--stroke-2); background: rgba(255, 255, 255, 0.06); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn .i-sun { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: block; }
[data-theme="dark"] .icon-btn .i-moon { display: none; }
.mobile-only { display: none; }

/* ---------- Layout / paneles ---------- */
.layout {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 344px;
  gap: 14px;
  padding: 0 14px 14px;
  min-height: 0;
}
.panel {
  position: relative;
  min-height: 0;
  min-width: 0;
  border-radius: var(--r-lg);
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012)), var(--panel);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(22px) saturate(125%);
  overflow: hidden;
}
[data-theme="light"] .panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.66)), var(--panel);
  box-shadow: var(--shadow), inset 0 1px 0 #fff;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
}
.panel-kicker {
  margin: 0 0 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mute);
}
.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 8px;
}
.panel-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--mute);
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
}
.sort-btn {
  height: 28px;
  min-width: 34px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.sort-btn:hover { color: var(--ink); border-color: var(--stroke-2); }

/* ---------- Rail ---------- */
.rail { display: flex; flex-direction: column; }
.bars {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 2px 8px 10px;
  scrollbar-width: thin;
}
.field {
  --meter: 0%;
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 9px 8px;
  margin: 2px 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  color: var(--ink-2);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.field:hover { background: rgba(255, 255, 255, 0.035); color: var(--ink); transform: translateX(2px); }
[data-theme="light"] .field:hover { background: rgba(18, 20, 24, 0.035); }
.field.sel {
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
.field.sel::before {
  content: "";
  position: absolute;
  left: -8px; top: 9px; bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.field-rank {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--faint);
  text-align: right;
  letter-spacing: 0.02em;
}
.field.sel .field-rank { color: var(--accent); }
.field-body { display: grid; gap: 5px; min-width: 0; }
.field-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.field-name {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field.on .field-name::after {
  content: "";
  display: inline-block;
  width: 4px; height: 4px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  vertical-align: middle;
  box-shadow: 0 0 8px var(--accent-2);
}
.field-n {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--mute);
  flex: none;
}
.field-meter {
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
[data-theme="light"] .field-meter { background: rgba(18, 20, 24, 0.07); }
.field-meter i {
  display: block;
  height: 100%;
  width: var(--meter);
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.55;
  transition: opacity 0.15s ease;
}
.field.sel .field-meter i, .field:hover .field-meter i { opacity: 1; }
.rail-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--stroke);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--mute);
  white-space: nowrap;
}
.rail-foot strong { color: var(--ink-2); font-weight: 500; }
.dot-sep { width: 2px; height: 2px; border-radius: 50%; background: var(--faint); }
.rail-foot-hint { margin-left: auto; color: var(--faint); }

/* ---------- Escenario ---------- */
.stage {
  position: relative;
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(70% 60% at 50% 40%, rgba(255, 255, 255, 0.035), transparent 72%),
    var(--stage-bg);
  isolation: isolate;
}
[data-theme="light"] .stage {
  background:
    radial-gradient(70% 60% at 50% 40%, rgba(0, 0, 0, 0.022), transparent 72%),
    var(--stage-bg);
}
.stage-frame {
  position: absolute;
  inset: 10px;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(var(--stroke-2), var(--stroke-2)) left top / 14px 1px no-repeat,
    linear-gradient(var(--stroke-2), var(--stroke-2)) left top / 1px 14px no-repeat,
    linear-gradient(var(--stroke-2), var(--stroke-2)) right top / 14px 1px no-repeat,
    linear-gradient(var(--stroke-2), var(--stroke-2)) right top / 1px 14px no-repeat,
    linear-gradient(var(--stroke-2), var(--stroke-2)) left bottom / 14px 1px no-repeat,
    linear-gradient(var(--stroke-2), var(--stroke-2)) left bottom / 1px 14px no-repeat,
    linear-gradient(var(--stroke-2), var(--stroke-2)) right bottom / 14px 1px no-repeat,
    linear-gradient(var(--stroke-2), var(--stroke-2)) right bottom / 1px 14px no-repeat;
  opacity: 0.55;
}
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 14%, transparent) 1px, transparent 0);
  background-size: 26px 26px;
  mask-image: radial-gradient(120% 100% at 50% 45%, #000 30%, transparent 85%);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}
#c {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
  cursor: grab;
}
#c.dragging { cursor: grabbing; }
#c.pointing { cursor: pointer; }

.stage-topbar {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 4;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  max-width: calc(100% - 230px);
  padding: 5px 7px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--panel-solid) 72%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 30px -22px rgba(0, 0, 0, 0.8);
}
.crumb {
  border: 0;
  background: transparent;
  padding: 4px 8px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: -0.01em;
  color: var(--mute);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}
.crumb:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
.crumb.on { color: var(--ink); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.crumb-sep { color: var(--faint); font-size: 10px; }
.crumb-head { color: var(--faint); font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase; padding: 0 5px 0 3px; }

.stage-zoom {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--panel-solid) 72%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 30px -22px rgba(0, 0, 0, 0.8);
}
.zoom-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--mute);
  font-size: 15px;
  line-height: 1;
}
.zoom-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
.zoom-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.zoom-btn.fit { margin-left: 2px; border-left: 1px solid var(--stroke); border-radius: 0 7px 7px 0; width: 30px; }
.zoom-val {
  min-width: 38px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

.mobile-hint {
  display: none;
  position: absolute;
  left: 50%; bottom: 38px;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--panel-solid) 78%, transparent);
  backdrop-filter: blur(14px);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--mute);
  white-space: nowrap;
}
.linkish {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.stage-legend {
  position: absolute;
  left: 16px; bottom: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--mute);
  pointer-events: none;
}
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.lg-sun { background: var(--accent); box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }
.lg-moon { border: 1px solid var(--mute); }
.lg-path { background: var(--accent-3); box-shadow: 0 0 8px color-mix(in srgb, var(--accent-3) 60%, transparent); }
.lg-hint { color: var(--faint); opacity: 0.85; }

.stage-metrics {
  position: absolute;
  right: 16px; bottom: 14px;
  z-index: 3;
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--mute);
  pointer-events: none;
}
.stage-metrics strong { color: var(--ink-2); font-weight: 500; }

.tooltip {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  min-width: 130px;
  max-width: 260px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--stroke-2);
  background: var(--panel-solid);
  box-shadow: var(--shadow-pop);
  font-size: 11.5px;
  animation: tip-in 0.12s ease both;
}
@keyframes tip-in { from { opacity: 0; transform: translate(-50%, calc(-100% - 10px)); } }
.tip-name { display: block; font-family: var(--font-display); font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.tip-meta { display: block; margin-top: 3px; font-family: var(--font-mono); font-size: 9px; color: var(--mute); }
.tip-hint { display: block; margin-top: 6px; font-family: var(--font-mono); font-size: 8.5px; color: var(--accent); letter-spacing: 0.02em; }

.stage-note {
  position: absolute;
  left: 50%; bottom: 46px;
  transform: translateX(-50%);
  z-index: 6;
  max-width: 80%;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke-2);
  background: var(--panel-strong);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  box-shadow: var(--shadow-pop);
  animation: pop-in 0.18s ease both;
}

/* ---------- Estado vacío ---------- */
.empty {
  position: absolute;
  background: radial-gradient(58% 52% at 50% 50%, color-mix(in srgb, var(--stage-bg) 88%, transparent) 0%, transparent 78%);
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s;
}
.empty.hidden { opacity: 0; visibility: hidden; display: none; }
.empty > * { pointer-events: none; }
.empty-quick { pointer-events: auto; }
.empty-orbit {
  position: relative;
  width: 184px; height: 184px;
  margin-bottom: 24px;
  flex: none;
}
.empty-orbit::before {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.06), transparent 66%);
  filter: blur(14px);
}
[data-theme="light"] .empty-orbit::before {
  background: radial-gradient(circle, rgba(0, 0, 0, 0.05), transparent 66%);
}
.eo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
  opacity: 0.75;
}
.eo-ring.r1 { inset: 30px; animation: spin 26s linear infinite; border-style: dashed; opacity: 0.9; }
.eo-ring.r2 { inset: 58px; border-color: color-mix(in srgb, var(--accent-2) 55%, transparent); }
.eo-ring.r3 { inset: 6px; opacity: 0.35; }
.eo-core {
  position: absolute;
  left: 50%; top: 50%;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent) 45%, transparent 78%);
  box-shadow: 0 0 24px 3px color-mix(in srgb, var(--accent) 40%, transparent), 0 0 60px 10px color-mix(in srgb, var(--accent) 14%, transparent);
}
.eo-dot { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
.eo-dot.d1 { left: 18px; top: 44px; }
.eo-dot.d2 { right: 22px; top: 36px; }
.eo-dot.d3 { right: 44px; bottom: 24px; background: var(--accent-3); box-shadow: 0 0 10px var(--accent-3); }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.empty h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.4vw, 38px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 600;
  background: linear-gradient(180deg, var(--ink) 30%, color-mix(in srgb, var(--ink) 55%, transparent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.empty-copy {
  margin: 0 0 22px;
  max-width: 400px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--mute);
}
.empty-quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-bottom: 24px; }
.quick-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink-2);
  font-size: 11.5px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.quick-chip:hover { border-color: var(--accent-line); color: var(--ink); background: var(--accent-soft); transform: translateY(-1px); }
.quick-chip b { font-family: var(--font-mono); font-size: 9px; font-weight: 400; color: var(--mute); }
.empty-keys {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 16px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--faint);
}
.empty-keys span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Loader ---------- */
.loader {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: color-mix(in srgb, var(--stage-bg) 82%, transparent);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
  transition: opacity 0.4s ease, visibility 0.4s;
}
.loader.gone { opacity: 0; visibility: hidden; display: none; }
.loader-ring {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--stroke-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.loader-ring::after { content: ""; }

/* ---------- Inspector ---------- */
.inspector { display: flex; flex-direction: column; }
.inspector-head { border-bottom: 1px solid var(--stroke); padding-bottom: 14px; }
.inspector-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 16px;
  scrollbar-width: thin;
}
.inspector-foot {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--stroke);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--faint);
}
.inspector-foot span { display: inline-flex; align-items: center; gap: 4px; }

.insp-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 42px 18px;
  color: var(--mute);
}
.insp-placeholder svg { width: 42px; height: 42px; fill: none; stroke: var(--faint); stroke-width: 1; opacity: 0.8; }
.insp-placeholder p { margin: 0; font-size: 12px; line-height: 1.6; max-width: 220px; }
.insp-placeholder strong { color: var(--ink-2); font-weight: 500; }

.insp-head {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--stroke);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute);
}
.badge.campo { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.badge.hoja { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); background: color-mix(in srgb, var(--accent-2) 8%, transparent); }
.insp-name {
  margin: 9px 0 8px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.08;
  overflow-wrap: anywhere;
}
.insp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.025);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--mute);
}
.chip b { color: var(--ink-2); font-weight: 500; }

.insp-section { margin-bottom: 20px; }
.insp-section:last-child { margin-bottom: 0; }
.sec-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 9px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
}
.sec-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--stroke);
}
.sec-head .n { color: var(--faint); font-size: 8.5px; }
.mini-btn {
  border: 0;
  background: transparent;
  padding: 2px 4px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border-radius: 4px;
}
.mini-btn:hover { background: var(--accent-soft); }

.crumbs-list { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 0; padding: 0; list-style: none; }
.trail-pill {
  border: 1px solid var(--stroke);
  background: transparent;
  border-radius: 7px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--mute);
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trail-pill:hover { color: var(--ink); border-color: var(--stroke-2); }
.trail-pill.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.trail-arrow { color: var(--faint); font-size: 9px; }

.filter-box { position: relative; margin-bottom: 8px; }
.filter-box input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11.5px;
  outline: none;
}
[data-theme="light"] .filter-box input { background: rgba(18, 20, 24, 0.03); }
.filter-box input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-box input::placeholder { color: var(--faint); }

.hip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.hip-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  color: var(--ink-2);
  transition: background 0.12s ease, color 0.12s ease;
}
.hip-row:hover { background: rgba(255, 255, 255, 0.04); color: var(--ink); }
[data-theme="light"] .hip-row:hover { background: rgba(18, 20, 24, 0.04); }
.hip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  border: 1px solid var(--faint);
}
.hip-row.path .hip-dot { border-color: var(--accent-3); background: var(--accent-3); box-shadow: 0 0 8px color-mix(in srgb, var(--accent-3) 70%, transparent); }
.hip-row.on { background: var(--accent-soft); color: var(--ink); }
.hip-row.on .hip-dot { border-color: var(--accent); background: var(--accent); }
.hip-lab { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hip-tail { display: inline-flex; align-items: center; gap: 5px; flex: none; }
.hip-tag {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  padding: 1px 4px;
  border-radius: 4px;
}
.hip-chev { color: var(--faint); width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; }
.hip-row:hover .hip-chev { color: var(--accent); opacity: 1; }
.hip-empty { padding: 10px 8px; font-size: 11.5px; color: var(--faint); }
.more-note { padding: 6px 8px; font-family: var(--font-mono); font-size: 9px; color: var(--faint); }

.fieldgroup { border: 1px solid var(--stroke); border-radius: 10px; margin-bottom: 6px; overflow: hidden; }
.fieldgroup-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 10px;
}
.fieldgroup-head:hover { background: rgba(255, 255, 255, 0.035); color: var(--ink); }
.fieldgroup-head .fg-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.fieldgroup-head .fg-tag { font-size: 8px; color: var(--faint); letter-spacing: 0.06em; }

.parent-list { display: grid; gap: 4px; }
.parent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: transparent;
  text-align: left;
  color: var(--ink-2);
  font-size: 11.5px;
  width: 100%;
}
.parent-item:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); }
.parent-item .arrow { color: var(--faint); font-family: var(--font-mono); font-size: 9px; }
.parent-item .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parent-item .pn { font-family: var(--font-mono); font-size: 9px; color: var(--mute); }

.bridge-line {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--stroke);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--mute);
  margin-bottom: 4px;
  overflow: hidden;
}
.bridge-line .bnode { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bridge-line .barrow { color: var(--accent); flex: none; }

/* ---------- Aviso móvil ---------- */
.mobile-hint {
  display: none;
  position: absolute;
  left: 50%; bottom: 38px;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: color-mix(in srgb, var(--panel-solid) 78%, transparent);
  backdrop-filter: blur(14px);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--mute);
  white-space: nowrap;
}
.linkish {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1420px) {
  .layout { grid-template-columns: 272px minmax(0, 1fr) 320px; }
  .brand-version { display: none; }
}
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .rail, .inspector {
    position: fixed;
    top: 70px; bottom: 14px;
    width: min(320px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
  }
  .rail { left: 14px; }
  .inspector { right: 14px; transform: translateX(105%); }
  .rail.open, .inspector.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(3, 5, 10, 0.55);
    backdrop-filter: blur(3px);
  }
  .stage-legend .lg-hint { display: none; }
  .mobile-hint { display: block; }
}
@media (max-width: 640px) {
  .mobile-hint { bottom: 34px; }
}
@media (max-width: 860px) {
  .rail, .inspector { top: 118px; bottom: 10px; }
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 10px;
    padding: 10px 12px 8px;
  }
  .brand { grid-column: 1; }
  .search { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .top-actions { grid-column: 2; grid-row: 1; }
  .stat-pill { display: none; }
  .layout { padding: 0 10px 10px; gap: 10px; }
  .stage-topbar { max-width: calc(100% - 150px); }
  .stage-zoom { top: 12px; right: 12px; }
  .stage-legend { left: 12px; bottom: 10px; gap: 9px; }
  .stage-metrics { right: 12px; bottom: 10px; }
  .empty h2 { font-size: 30px; }
  .empty-copy { max-width: 330px; }
  .empty-keys { display: none; }
}
@media (max-width: 560px) {
  .brand { gap: 9px; }
  .brand h1 { font-size: 14.5px; }
  .brand-kicker { font-size: 8px; letter-spacing: 0.13em; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
  .top-actions { gap: 5px; }
  .insp-name { font-size: 21px; }
  .empty-copy { font-size: 12px; }
  .stage-legend .lg-hint, .stage-metrics { display: none; }
}

@media (max-width: 380px) {
  .top-actions { gap: 4px; }
  .icon-btn { width: 30px; height: 30px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand h1 { font-size: 13.5px; }
  .brand { gap: 7px; }
  .brand-kicker { letter-spacing: 0.1em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
