/* NexusSapiens V0.1 — estilos. Pensado para equipos modestos: sin desenfoques de fondo, sin sombras grandes, transiciones mínimas. */
:root {
  --bg: #0b1020; --bg2: #141d3a; --panel: 17 24 45; --texto: #e8ecf6; --suave: #9aa6c4;
  --acento: #6ee7c8; --color-borde: #4b6a9b; --borde: 3px; --opacidad: 1; --escala: 1;
  --campo: #0e1530; --linea: rgba(255, 255, 255, .14);
  font-size: calc(16px * var(--escala));
  color-scheme: dark;
}
:root[data-tema="claro"] {
  --bg: #eef1f8; --bg2: #d9e0f1; --panel: 255 255 255; --texto: #161b2e; --suave: #55607f;
  --campo: #f3f5fb; --linea: rgba(0, 0, 0, .16);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--texto); font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
h2, h3 { margin: 0 0 .4rem; font-weight: 600; }
h2 { font-size: 1.05rem; } h3 { font-size: .9rem; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; margin-top: 1.1rem; }
p { margin: 0 0 .4rem; }
.suave { color: var(--suave); }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }

/* ----- escenario y ventanas ----- */
#escenario { position: fixed; inset: 0; background: radial-gradient(120% 90% at 15% 0%, var(--bg2), var(--bg)); overflow: hidden; }
#escenario[data-modo="mosaico"] { display: grid; }
.win {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background: rgb(var(--panel) / var(--opacidad));
  border: var(--borde) solid var(--color-borde);
}
.win.activa, .win:focus-within { border-color: var(--acento); }
.win-body { position: absolute; inset: 0; overflow: auto; }
#escenario[data-modo="flotante"] .win {
  position: absolute; left: calc(var(--x, 0) * 100%); top: calc(var(--y, 0) * 100%);
  width: calc(var(--w, .3) * 100%); height: calc(var(--h, .4) * 100%); z-index: var(--z, 10);
}
#escenario[data-modo="foco"] .win { display: none; }
#escenario[data-modo="foco"] .win.foco { display: block; position: absolute; inset: 0; }
.win.arrastrando { z-index: 9999 !important; opacity: .92; }
#escenario[data-modo="mosaico"] .win.arrastrando { outline: 2px dashed var(--acento); outline-offset: -4px; }
.win.destino { outline: 3px solid var(--acento); outline-offset: -6px; }

/* título flotante: aparece al pasar el ratón y se desvanece */
.win-title {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 5;
  max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 12px; border-radius: 999px; font-size: .75rem; color: #e8ecf6;
  background: rgba(8, 12, 24, .86); border: 1px solid rgba(255, 255, 255, .22);
  opacity: 0; pointer-events: none; cursor: grab; user-select: none; touch-action: none;
  transition: opacity .25s ease;
}
.win.titulo-visible .win-title { opacity: 1; pointer-events: auto; }
.win.arrastrando .win-title { cursor: grabbing; }
#escenario[data-modo="foco"] .win-title { cursor: default; }

/* asas de redimensión (solo en flotante) y separadores (solo en mosaico) */
.rz { position: absolute; z-index: 6; display: none; touch-action: none; }
#escenario[data-modo="flotante"] .rz { display: block; }
.rz-n, .rz-s { left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.rz-e, .rz-w { top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.rz-n { top: 0; } .rz-s { bottom: 0; } .rz-e { right: 0; } .rz-w { left: 0; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 14px; height: 14px; }
.rz-ne { top: 0; right: 0; cursor: nesw-resize; } .rz-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.rz-nw { top: 0; left: 0; cursor: nwse-resize; } .rz-se { bottom: 0; right: 0; cursor: nwse-resize; }

.split { position: absolute; z-index: 7; display: none; touch-action: none; }
#escenario[data-modo="mosaico"] .split { display: block; }
.split-v { top: 0; bottom: 0; width: 12px; margin-left: -6px; cursor: col-resize; }
.split-h { left: 0; right: 0; height: 12px; margin-top: -6px; cursor: row-resize; }
.split:hover, .split.activo { background: color-mix(in srgb, var(--acento) 35%, transparent); }

/* ----- contenidos básicos ----- */
.centrado { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1rem; }
.reloj { font-size: clamp(1.6rem, 6vw, 3.4rem); font-variant-numeric: tabular-nums; margin: 0; letter-spacing: .02em; }
.fecha::first-letter { text-transform: uppercase; }
.notas { width: 100%; height: 100%; resize: none; border: 0; padding: 2.2rem 1rem 1rem; background: transparent; color: inherit; font: inherit; }
.notas:focus-visible { outline-offset: -3px; }
.estado, .reg { padding: 2.2rem 1rem 1rem; }
.estado dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; margin: .8rem 0 0; font-size: .88rem; }
.estado dt { color: var(--suave); } .estado dd { margin: 0; overflow-wrap: anywhere; }
.reg ol { list-style: none; margin: .5rem 0 0; padding: 0; font: .78rem/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.reg li.error { color: #f87171; }

/* ----- botón de la consola con la luz del puente ----- */
#consolaBoton {
  /* zona pulsable de 44×44; el círculo visible sigue siendo de 24 px (::before) */
  position: fixed; right: 0; bottom: 0; z-index: 40; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border: 0; background: transparent; cursor: pointer;
}
#consolaBoton::before {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 24px; height: 24px; border-radius: 50%;
  background: rgb(var(--panel)); border: 1px solid var(--suave); opacity: .8;
}
#consolaBoton:hover::before, #consolaBoton:focus-visible::before { opacity: 1; border-color: var(--acento); }
#puenteLed { position: relative; width: 10px; height: 10px; border-radius: 50%; background: #6b7280; }
#puenteLed[data-estado="conectado"] { background: #34d399; }
#puenteLed[data-estado="bloqueado"] { background: #fbbf24; }
#puenteLed[data-estado="sin-extension"] { background: #6b7280; box-shadow: inset 0 0 0 2px rgb(var(--panel)); }
#puenteLed[data-estado="comprobando"] { background: #60a5fa; }

/* ----- medidor de rendimiento ----- */
#hud {
  position: fixed; left: 8px; bottom: 8px; z-index: 60; pointer-events: none; white-space: pre;
  font: 12px/1.4 ui-monospace, Consolas, monospace; color: #b9f5e6; background: rgba(0, 0, 0, .78); padding: 6px 8px; border-radius: 4px;
}
#hud[hidden] { display: none; }

/* ----- consola de mandos ----- */
#consola {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(460px, 100vw);
  display: flex; flex-direction: column; background: rgb(var(--panel)); border-left: 3px solid var(--color-borde);
}
#consola[hidden] { display: none; }
.c-cab { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem .4rem; }
.c-cab h2 { margin: 0; }
.c-cerrar { font-size: 1.4rem; line-height: 1; width: 2rem; height: 2rem; border: 0; background: transparent; color: var(--texto); cursor: pointer; border-radius: 6px; }
.c-cerrar:hover { background: var(--linea); }
.c-pestanas { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0 1rem .5rem; border-bottom: 1px solid var(--linea); }
.c-pestanas button { border: 1px solid transparent; background: transparent; color: var(--suave); padding: .3rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; font-size: .88rem; }
.c-pestanas button.on { color: var(--texto); border-color: var(--acento); }
.c-panel { flex: 1; overflow: auto; padding: .6rem 1rem 1rem; }
.c-fila { display: grid; gap: .25rem; padding: .55rem 0; border-bottom: 1px solid var(--linea); }
.c-etiqueta { font-size: .9rem; }
.c-etiqueta em { color: var(--suave); font-style: normal; }
.c-control { display: flex; align-items: center; gap: .6rem; }
.c-control input[type=range] { flex: 1; accent-color: var(--acento); }
.c-control select, .c-pie select, .c-pie input[type=text] {
  flex: 1; min-width: 0; font: inherit; font-size: .88rem; color: var(--texto); background: var(--campo);
  border: 1px solid var(--linea); border-radius: 6px; padding: .3rem .5rem;
}
.c-control input[type=color] { width: 3rem; height: 1.8rem; padding: 0; border: 1px solid var(--linea); background: transparent; border-radius: 4px; }
.c-control input[type=checkbox] { width: 1.3rem; height: 1.3rem; accent-color: var(--acento); }
.c-fila-toggle { grid-template-columns: 1fr auto; align-items: center; column-gap: 1rem; }
.c-fila-toggle .c-ayuda { grid-column: 1 / -1; }
.c-valor { min-width: 3.6rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--suave); font-size: .85rem; }
.c-reset { border: 0; background: transparent; color: var(--suave); cursor: pointer; font-size: 1rem; padding: 0 .3rem; border-radius: 4px; }
.c-reset:hover { color: var(--texto); background: var(--linea); }
.c-reset[hidden] { display: none; }
.c-ayuda { margin: 0; font-size: .78rem; color: var(--suave); }
.c-extra { padding-top: .2rem; }
.c-fila-corta { padding: .35rem 0; }
.c-botones { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.c-boton { font: inherit; font-size: .84rem; color: var(--texto); background: var(--campo); border: 1px solid var(--linea); border-radius: 6px; padding: .3rem .7rem; cursor: pointer; }
.c-boton:hover:not(:disabled) { border-color: var(--acento); }
.c-boton:disabled { opacity: .45; cursor: default; }
.c-mas summary { cursor: pointer; padding: .35rem 0; font-size: .88rem; color: var(--suave); }
.c-mas[open] summary { color: var(--texto); }
.c-aviso { min-height: 1.3rem; margin: 0; padding: 0 1rem; font-size: .82rem; color: var(--acento); }
.c-pie { padding: .3rem 1rem .8rem; border-top: 1px solid var(--linea); }
.c-puente { font-size: .88rem; }

@media (prefers-reduced-motion: reduce) { .win-title { transition: none; } }
