:root {
  --bg-0: #141517;
  --bg-1: #1c1e21;
  --bg-2: #26292d;
  --ash: #3a3d42;
  --line: rgba(255, 196, 20, 0.55);
  --line-soft: rgba(255, 196, 20, 0.22);
  --line-faint: rgba(200, 210, 220, 0.10);
  --accent: #ffc414;
  --accent-2: #ffdd66;
  --cyan: #5fd4ff;
  --text: #e9ecef;
  --text-dim: #9aa3ad;
  --text-faint: #6b737c;
  --panel: rgba(22, 24, 27, 0.82);
  --panel-solid: #181a1d;
  --danger: #ff5a4f;
  --ok: #45d483;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --disp: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(ellipse at 50% 42%, #44474c 0%, #2e3135 38%, #1b1d20 75%, #121315 100%);
  color: var(--text);
  font-family: var(--disp);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { font-family: inherit; }

#scene { position: fixed; inset: 0; display: block; width: 100%; height: 100%; outline: none; touch-action: none; }

/* ---------- Capas de fondo tecnológicas ---------- */
#bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 85%);
}
#scene { z-index: 1; }
#overlay { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#overlay svg { width: 100%; height: 100%; overflow: visible; }

/* Marco HUD (esquinas) */
.frame-corner { position: fixed; width: 34px; height: 34px; border: 0 solid var(--line); z-index: 6; pointer-events: none; }
.frame-corner.tl { top: 64px; left: 10px; border-top-width: 2px; border-left-width: 2px; }
.frame-corner.tr { top: 64px; right: 10px; border-top-width: 2px; border-right-width: 2px; }
.frame-corner.bl { bottom: 10px; left: 10px; border-bottom-width: 2px; border-left-width: 2px; }
.frame-corner.br { bottom: 10px; right: 10px; border-bottom-width: 2px; border-right-width: 2px; }
.crosshair { position: fixed; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 4; pointer-events: none; opacity: .35; }
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: var(--accent); }
.crosshair::before { left: 10px; top: 0; width: 1px; height: 22px; }
.crosshair::after { top: 10px; left: 0; height: 1px; width: 22px; }

/* ---------- Barra superior ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 54px; z-index: 20;
  display: flex; align-items: center; gap: 18px; padding: 0 18px;
  background: linear-gradient(180deg, rgba(16,17,19,.96), rgba(16,17,19,.78));
  border-bottom: 1px solid var(--line-soft);
}
#topbar::after { /* línea con marcas */
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, var(--accent) 0 160px, transparent 160px 100%);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-title { font-weight: 700; font-size: 19px; letter-spacing: .06em; white-space: nowrap; }
.brand-title b { color: var(--accent); }
.brand-sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); letter-spacing: .14em; white-space: nowrap; }
.hazard { width: 62px; height: 14px; flex: none; background: repeating-linear-gradient(-45deg, var(--accent) 0 7px, transparent 7px 14px); opacity: .85; }
.hud-readouts { margin-left: auto; display: flex; gap: 6px; font-family: var(--mono); font-size: 11px; }
.ro { border: 1px solid var(--line-faint); padding: 4px 9px; color: var(--text-dim); white-space: nowrap; position: relative; }
.ro b { color: var(--text); font-weight: 500; }
.ro::before { content: ''; position: absolute; left: -1px; top: -1px; width: 5px; height: 5px; border-left: 1px solid var(--accent); border-top: 1px solid var(--accent); }

/* ---------- Paneles ---------- */
.panel {
  position: fixed; z-index: 15;
  background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}
.panel::before { /* línea diagonal en la esquina */
  content: ''; position: absolute; top: 0; right: 0; width: 20px; height: 20px;
  background: linear-gradient(225deg, transparent 0 9px, var(--line) 9px 10px, transparent 10px);
  pointer-events: none;
}
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line-faint);
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em; color: var(--accent); text-transform: uppercase;
}
.panel-head .idx { color: var(--text-faint); }
.panel-head .grow { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-soft), transparent); }

#left { top: 66px; left: 12px; bottom: 76px; width: 300px; display: flex; flex-direction: column; }
#left.collapsed { width: 46px; }
#left.collapsed .tab-body, #left.collapsed .tabs .tab span { display: none; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line-faint); }
#left.collapsed .tabs { grid-template-columns: 1fr; }
.tab {
  background: none; border: 0; color: var(--text-dim); padding: 9px 2px 7px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; border-bottom: 2px solid transparent;
}
.tab svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: linear-gradient(0deg, rgba(255,196,20,.08), transparent); }
.tab-body { flex: 1; overflow-y: auto; padding: 12px 14px 16px; display: none; }
.tab-body.active { display: block; }
.tab-body::-webkit-scrollbar { width: 6px; }
.tab-body::-webkit-scrollbar-thumb { background: var(--ash); }

.sec-title {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em; color: var(--text-faint);
  text-transform: uppercase; margin: 14px 0 8px; display: flex; align-items: center; gap: 8px;
}
.sec-title:first-child { margin-top: 2px; }
.sec-title::after { content: ''; flex: 1; height: 1px; background: repeating-linear-gradient(90deg, var(--line-faint) 0 4px, transparent 4px 7px); }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tbtn {
  position: relative; background: rgba(255,255,255,.03); color: var(--text);
  border: 1px solid var(--line-faint); padding: 9px 10px; cursor: pointer; text-align: left;
  font-size: 14px; font-weight: 600; letter-spacing: .03em; transition: border-color .15s, background .15s;
  display: flex; align-items: center; gap: 8px;
}
.tbtn small { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); font-weight: 400; letter-spacing: .1em; }
.tbtn svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 1.6; flex: none; }
.tbtn:hover { border-color: var(--line); background: rgba(255,196,20,.06); }
.tbtn.on { border-color: var(--accent); background: rgba(255,196,20,.13); }
.tbtn.on::after { content: ''; position: absolute; right: 6px; top: 6px; width: 6px; height: 6px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.tbtn.wide { grid-column: span 2; }

/* Interruptores */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px dashed var(--line-faint); cursor: pointer;
}
.switch-row .lbl { font-weight: 600; font-size: 14px; }
.switch-row .lbl small { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); font-weight: 400; letter-spacing: .08em; }
.sw { width: 40px; height: 18px; border: 1px solid var(--line-soft); position: relative; flex: none; transition: .2s; }
.sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--text-faint); transition: .2s; }
.switch-row.on .sw { border-color: var(--accent); background: rgba(255,196,20,.15); }
.switch-row.on .sw::after { left: 24px; background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* Sliders */
.slider { margin: 9px 0 12px; }
.slider .top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; font-weight: 600; }
.slider .top span:last-child { font-family: var(--mono); font-size: 11.5px; color: var(--accent); font-weight: 500; }
.slider .top small { font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); font-weight: 400; margin-left: 6px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 2px 0 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border: 1px solid var(--line-faint);
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.10) 0 1px, transparent 1px 10%), rgba(255,255,255,.04);
}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 16px; margin-top: -7px; background: var(--accent); border: 0; clip-path: polygon(50% 0, 100% 25%, 100% 100%, 0 100%, 0 25%); }
input[type=range]::-moz-range-track { height: 4px; background: rgba(255,255,255,.08); border: 1px solid var(--line-faint); }
input[type=range]::-moz-range-thumb { width: 10px; height: 16px; background: var(--accent); border: 0; border-radius: 0; }

/* Lista de partes */
.search {
  width: 100%; background: rgba(0,0,0,.3); border: 1px solid var(--line-faint); color: var(--text);
  padding: 8px 10px; font-family: var(--mono); font-size: 12px; outline: none;
}
.search:focus { border-color: var(--line); }
.cat-block { margin-top: 10px; }
.cat-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 0;
  font-weight: 700; font-size: 14px; letter-spacing: .02em;
}
.cat-head .num { font-family: var(--mono); font-size: 10.5px; color: var(--bg-0); background: var(--accent); padding: 1px 5px; }
.cat-head .maps { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); }
.cat-head .chev { width: 10px; height: 10px; border-right: 1.5px solid var(--text-faint); border-bottom: 1.5px solid var(--text-faint); transform: rotate(-45deg); transition: .2s; flex: none; }
.cat-block.open .chev { transform: rotate(45deg); }
.cat-list { display: none; border-left: 1px solid var(--line-soft); margin-left: 5px; padding-left: 10px; }
.cat-block.open .cat-list { display: block; }
.part-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px; cursor: pointer; font-size: 13.5px; color: var(--text-dim);
  position: relative;
}
.part-item::before { content: ''; position: absolute; left: -11px; top: 50%; width: 8px; height: 1px; background: var(--line-soft); }
.part-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.part-item.sel { color: var(--accent); background: rgba(255,196,20,.08); }
.part-item .mp { margin-left: auto; font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); }

.anom { border: 1px solid var(--line-faint); padding: 10px 12px; margin-bottom: 8px; position: relative; }
.anom::before { content: ''; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 3px; background: var(--danger); }
.anom h4 { margin: 0 0 6px; font-size: 14.5px; display: flex; gap: 8px; align-items: center; }
.anom h4 span { font-family: var(--mono); font-size: 9.5px; color: var(--text-faint); font-weight: 400; margin-left: auto; }
.anom ol { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 13px; line-height: 1.4; }
.anom ol li::marker { color: var(--accent); font-family: var(--mono); font-size: 11px; }

.note { font-family: var(--mono); font-size: 10px; color: var(--text-faint); line-height: 1.5; margin-top: 12px; border-top: 1px dashed var(--line-faint); padding-top: 10px; }
.kbd { display: inline-block; font-family: var(--mono); font-size: 10px; border: 1px solid var(--line-faint); padding: 0 4px; margin-right: 3px; color: var(--text-dim); }

/* ---------- Panel derecho: detalle ---------- */
#detail { top: 66px; right: 12px; width: 340px; max-height: calc(100% - 152px); display: flex; flex-direction: column; transform: translateX(380px); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
#detail.show { transform: none; }
#detail:not(.show) { opacity: 0; pointer-events: none; }
#detail .body { overflow-y: auto; padding: 14px 16px 16px; }
.d-code { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); letter-spacing: .12em; }
.d-name { font-size: 24px; font-weight: 700; line-height: 1.1; margin: 4px 0 2px; }
.d-pt { font-family: var(--mono); font-size: 11px; color: var(--cyan); margin-bottom: 10px; }
.d-maps { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 12px; }
.d-maps span { font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--line); color: var(--accent); padding: 2px 6px; }
.d-block { margin-top: 12px; }
.d-block h5 { margin: 0 0 4px; font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--text-faint); font-weight: 400; text-transform: uppercase; display: flex; gap: 8px; align-items: center; }
.d-block h5::after { content: ''; flex: 1; height: 1px; background: var(--line-faint); }
.d-block p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.45; }
.d-block.insp p { color: #ffd98a; }
.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table td { padding: 5px 0; border-bottom: 1px dashed var(--line-faint); vertical-align: top; }
.spec-table td:first-child { color: var(--text-faint); font-family: var(--mono); font-size: 10.5px; padding-right: 10px; width: 46%; }
.d-actions { display: flex; gap: 6px; margin-top: 14px; }
.d-actions .tbtn { flex: 1; justify-content: center; font-size: 13px; }
.close-x { margin-left: auto; background: none; border: 1px solid var(--line-faint); color: var(--text-dim); width: 24px; height: 24px; cursor: pointer; font-size: 14px; line-height: 1; }
.close-x:hover { color: var(--accent); border-color: var(--line); }

/* Ficha técnica */
#specs { right: 12px; bottom: 76px; width: 340px; max-height: 46%; display: none; flex-direction: column; }
#specs.show { display: flex; }
#specs .body { overflow-y: auto; padding: 8px 16px 14px; }

/* ---------- Barra inferior ---------- */
#dock {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 16;
  display: flex; gap: 4px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line-soft);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#dock::before, #dock::after { content: ''; position: absolute; top: 50%; width: 40px; height: 1px; background: var(--line-soft); }
#dock::before { right: 100%; } #dock::after { left: 100%; }
.dbtn {
  background: none; border: 1px solid transparent; color: var(--text-dim); cursor: pointer; padding: 6px 10px 5px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; min-width: 62px;
}
.dbtn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.dbtn:hover { color: var(--text); border-color: var(--line-faint); }
.dbtn.on { color: var(--accent); border-color: var(--line); background: rgba(255,196,20,.1); }
.dsep { width: 1px; background: var(--line-faint); margin: 4px 2px; }

/* Brújula */
#compass { position: fixed; left: 326px; bottom: 18px; width: 92px; height: 92px; z-index: 14; pointer-events: none; transition: left .3s; }
#left.collapsed ~ #compass { left: 70px; }

/* Etiqueta flotante (hover) */
#tip {
  position: fixed; z-index: 30; pointer-events: none; display: none;
  font-family: var(--mono); font-size: 11.5px; color: var(--text); background: rgba(14,15,17,.9);
  border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap;
}
#tip b { color: var(--accent); font-weight: 500; margin-right: 6px; }

/* Toast */
#toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 40; pointer-events: none;
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em; color: var(--accent);
  background: rgba(14,15,17,.92); border: 1px solid var(--line); padding: 7px 14px; opacity: 0; transition: opacity .3s;
}
#toast.show { opacity: 1; }

/* Cargando */
#loader {
  position: fixed; inset: 0; z-index: 100; background: #16181a; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  transition: opacity .6s;
}
#loader.hide { opacity: 0; pointer-events: none; }
#loader .bar { width: 260px; height: 3px; background: var(--ash); position: relative; overflow: hidden; }
#loader .bar::after { content: ''; position: absolute; top: 0; left: -40%; width: 40%; height: 100%; background: var(--accent); animation: load 1.1s linear infinite; }
@keyframes load { to { left: 100%; } }
#loader .t { font-family: var(--mono); font-size: 12px; letter-spacing: .25em; color: var(--text-dim); }
#loader .err { color: var(--danger); font-family: var(--mono); font-size: 12px; max-width: 520px; text-align: center; display: none; }

/* Etiquetas SVG */
.cl-line { stroke: var(--accent); stroke-width: 1.2; fill: none; }
.cl-line.dim { stroke: rgba(255,196,20,.55); stroke-width: 1; }
.cl-dot { fill: var(--accent); }
.cl-ring { fill: none; stroke: var(--accent); stroke-width: 1; }
.cl-box { fill: rgba(14,15,17,.88); stroke: var(--accent); stroke-width: 1; }
.cl-box.dim { stroke: rgba(255,196,20,.45); }
.cl-text { fill: var(--text); font-family: var(--disp); font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.cl-text.sm { font-size: 12.5px; font-weight: 600; }
.cl-code { fill: var(--accent); font-family: var(--mono); font-size: 10px; letter-spacing: .1em; }
.cl-tick { stroke: var(--accent); stroke-width: 2; }
.mini-label { pointer-events: auto; cursor: pointer; }
.mini-label:hover .cl-box { fill: rgba(255,196,20,.18); }

/* Responsive */
@media (max-width: 900px) {
  .hud-readouts, .brand-sub { display: none; }
  #left { width: 260px; }
  #detail, #specs { width: calc(100% - 24px); right: 12px; left: 12px; top: auto; bottom: 84px; max-height: 48%; transform: translateY(120%); }
  #detail.show { transform: none; }
  #compass { display: none; }
  .dbtn { min-width: 44px; padding: 6px 5px; font-size: 9px; }
  .dbtn span { display: none; }
}
@media (max-width: 600px) {
  #left:not(.collapsed) { width: calc(100% - 24px); bottom: 84px; }
  .brand-title { font-size: 15px; }
  .hazard { display: none; }
}
