:root { --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #02070b; }
* { box-sizing: border-box; }
button { font: inherit; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--sat) env(safe-area-inset-right) var(--sab) env(safe-area-inset-left);
}

/* barra superior */
.top { position: relative; z-index: 3; display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.top-left, .top-right { display: flex; align-items: center; gap: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.icon-btn { appearance: none; background: none; border: 1px solid transparent; color: var(--hud); width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--hud-faint); }
.icon-btn svg { width: 22px; height: 22px; }

/* escenario */
.stage {
  position: relative; z-index: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(320px, 440px);
  align-items: center; gap: 28px; padding: 0 28px;
}
.feed { align-self: center; justify-self: end; width: min(100%, 360px); min-height: 9em; justify-content: flex-end; }
.center { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.captions { min-height: 4.2em; display: flex; flex-direction: column; gap: 6px; max-width: min(90vw, 560px); }
.caption-line { margin: 0; transition: opacity .4s; }
.caption-line:empty { display: none; }
.panels { align-self: stretch; display: flex; flex-direction: column; gap: 14px; justify-content: center; min-height: 0; overflow: auto; padding: 8px 4px; scrollbar-width: none; }
.panels::-webkit-scrollbar { display: none; }
.app.compact .panels, .app.compact .feed { visibility: hidden; }

/* controles */
.controls { position: relative; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 14px 20px 22px; }
.text-form { flex: 0 1 420px; display: flex; }
.text-form .hud-input { width: 100%; }

/* superposición de confirmación */
.overlay { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.overlay.has-confirm { display: flex; flex-direction: column; gap: 12px; }
.overlay .confirm { width: min(560px, 100%); }

.toasts { position: fixed; z-index: 15; right: 20px; top: calc(64px + var(--sat)); display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }

/* cajón */
.drawer {
  position: fixed; z-index: 10; top: 0; right: 0; bottom: 0; width: min(480px, 100vw);
  background: rgba(2, 10, 15, .94); border-left: 1px solid var(--hud-faint);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transform: translateX(105%); transition: transform .35s cubic-bezier(.2, .9, .2, 1);
  display: flex; flex-direction: column;
  padding: var(--sat) env(safe-area-inset-right) var(--sab) 0;
}
.drawer.open { transform: none; box-shadow: -20px 0 60px rgba(0, 0, 0, .6); }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0 16px; border-bottom: 1px solid var(--hud-faint); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--hud-dim); font: 600 12px/1 var(--font-hud); letter-spacing: .14em; text-transform: uppercase; padding: 12px 10px; white-space: nowrap;
}
.tabs button.on { color: var(--hud); border-bottom-color: var(--hud); text-shadow: var(--glow-text); }
.drawer-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.drawer-body .panel { max-height: none; animation-duration: .3s; }
.row-form { display: flex; gap: 8px; }
.row-form .hud-input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.drawer-body textarea.hud-input { min-height: 160px; resize: vertical; font-family: var(--font-ui); }
.link-row { cursor: pointer; }
.link-row:hover .main { color: #fff; text-shadow: var(--glow-text); }
.x-btn { appearance: none; background: none; border: 0; color: var(--hud-dim); cursor: pointer; font-size: 18px; padding: 0 4px; }
.x-btn:hover { color: var(--bad); }
.token-box { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; padding: 10px; background: rgba(0, 0, 0, .4); border: 1px dashed var(--hud-dim); user-select: all; }
.big-code { font: 700 30px/1 var(--font-hud); letter-spacing: .3em; text-align: center; padding: 14px; color: #fff; text-shadow: var(--glow-text); }
.muted { color: var(--hud-dim); font-size: 13px; }
.audit-row { font-size: 13px; }
.audit-row .sub { font-family: ui-monospace, Consolas, monospace; font-size: 11px; white-space: pre-wrap; max-height: 6em; overflow: hidden; }

/* acceso */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; }
.login[hidden] { display: none; }
.login-panel { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; align-items: stretch; max-height: none; }
.login-panel .panel-title { text-align: center; }
.login-reactor { --reactor: 180px; margin: 4px auto 6px; }
.login-err { margin: 0; min-height: 1.2em; color: var(--bad); text-align: center; font-size: 14px; }

/* móvil */
@media (max-width: 900px) {
  :root { --reactor: min(64vw, 38dvh, 320px); }
  .stage { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; gap: 10px; padding: 0 14px; align-items: start; overflow: hidden; }
  .center { order: 1; gap: 10px; }
  .feed { order: 2; justify-self: stretch; width: 100%; min-height: 0; font-size: 12px; max-height: 4.6em; overflow: hidden; }
  .panels { order: 3; justify-content: flex-start; padding-bottom: 6px; }
  .panel { max-height: none; }
  .captions { min-height: 2.6em; }
  .caption-line { font-size: 16px; }
  .top { padding: 10px 14px; }
  .controls { padding: 10px 14px 14px; gap: 12px; }
  .ptt { width: 68px; height: 68px; flex: none; }
  .toasts { left: 14px; right: 14px; max-width: none; }
}

/* paneles: nunca se encogen; la columna hace scroll */
.panels > .panel { flex: none; }
.status-feed .line > span:last-child { overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .top .hud-label { letter-spacing: .16em; font-size: 10px; }
  #clock { display: none; }
  .status-feed .line .t { display: none; }
  .app:has(.panels .panel) { --reactor: min(46vw, 24dvh, 220px); }
  .app:has(.panels .panel) .captions { min-height: 0; }
  .panels { overflow-y: auto; -webkit-overflow-scrolling: touch; }
}
