/* La misma paleta y las mismas medidas que la app de Windows (main.cpp: C_*,
   HEADER_H, SIDEBAR_W, BAR_H, ROW_H, PAD). Los radios salen de RoundRect de
   GDI, que recibe el DIAMETRO de la esquina: S(9) en la app son 4.5 px aca. */
:root {
  --bg: #0B0D12;
  --sidebar: #10131C;
  --header: #121520;
  --header-top: #1B202E;
  --chatbg: #141722;
  --campo: #1B2030;
  --borde: #262C3D;
  --texto: #E9EEF8;
  --tenue: #8895AF;
  --apagado: #606C86;
  --acento: #00E6A7;
  --acento2: #38BDF8;
  --peligro: #FF3B30;
  --sel: #1E2740;
  --boton: #1A1F2E;

  --header-h: 66px;
  --barra-h: 58px;
  --sidebar-w: 250px;
  --pad: 12px;
  --fila: 30px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--texto);
  font: 15px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
.oculto { display: none !important; }

/* Barras de scroll finas y oscuras. */
* { scrollbar-width: thin; scrollbar-color: #3E485E transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2E3648; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- controles basicos (draw_button) ---- */
.boton {
  background: var(--boton);
  border: 1px solid var(--borde);
  border-radius: 5px;
  color: var(--texto);
  height: 36px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.boton:active:not(:disabled) { filter: brightness(1.25); }
.boton:disabled { background: #11141E; border-color: #1E2331; color: var(--apagado); cursor: default; }
.boton:focus-visible, .campo:focus-visible { outline: 1px solid var(--acento2); outline-offset: 1px; }
.boton.icono { width: 44px; padding: 0; }
.boton.icono svg { width: 20px; height: 20px; }
.boton.ancho { width: 100%; }
.boton.verde { background: #0A4637; border-color: var(--acento); color: var(--acento); }
.boton.rojo { border-color: #46282C; color: #E28080; }
.boton.alerta { background: #5C1A18; border-color: var(--peligro); }
.boton.salir:not(:disabled) { background: #501614; border-color: var(--peligro); }
.boton.enviar { background: #13598C; border-color: var(--acento2); width: 46px; padding: 0; font-size: 16px; }
.boton.supresor-off { color: var(--apagado); }

.campo {
  background: var(--campo);
  border: 1px solid var(--borde);
  border-radius: 5px;
  color: var(--texto);
  height: 36px;
  padding: 0 10px;
  width: 100%;
  min-width: 0;
}
.campo:focus { outline: none; border-color: #3A4560; }

.logo { font-size: 23px; font-weight: 600; line-height: 28px; }
.tag { font-size: 12px; color: var(--apagado); }
.sub { font-size: 12px; color: var(--apagado); }
.etiqueta { font-size: 12px; color: var(--tenue); display: block; margin: 2px 0 6px; }
.ayuda { font-size: 12px; color: var(--apagado); margin: 8px 0 0; }
.error { color: #FF8A80; font-size: 13px; margin: 10px 0 0; min-height: 1em; }

/* ---- entrada ---- */
.pantalla-entrar {
  position: fixed;
  inset: 0;
  background: #06070B;
  overflow-y: auto;
  padding: 16px;
}
.panel-cfg {
  width: 100%;
  max-width: 520px;
  margin: 54px auto 20px;
  background: var(--sidebar);
  border: 1px solid #2E3850;
  border-radius: 8px;
  padding: 20px 24px 24px;
}
.panel-cfg.entrar { max-width: 400px; }
.panel-cfg.entrar .boton.verde { width: 100%; margin-top: 16px; font-weight: 600; }
.caja {
  background: var(--chatbg);
  border: 1px solid var(--borde);
  border-radius: 6px;
  padding: 10px 18px 14px;
  margin-top: 16px;
}
.caja .campo + .etiqueta { margin-top: 12px; }
.fila-botones { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.fila-botones .boton { flex: 1; }

/* ---- estructura ---- */
.app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--barra-h);
  height: 100%;
  height: 100dvh;
}

.header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 44px 0 calc(var(--pad) + 6px);
  background: linear-gradient(var(--header-top), var(--header));
  border-bottom: 1px solid var(--borde);
  min-width: 0;
}
.marca { flex: 1; min-width: 0; }
.marca .tag { margin-left: 2px; margin-top: -1px; }
.header-der { display: flex; align-items: center; gap: 10px; }
.punto-conexion { width: 8px; height: 8px; background: #F5C542; flex: none; margin-right: 8px; }
.punto-conexion.ok { background: var(--acento); }
.nick-header { width: 150px; height: 34px; }

.cuerpo { display: flex; min-height: 0; }

/* ---- sidebar (draw_room_item) ---- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--borde);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.arbol {
  list-style: none;
  margin: 0;
  padding: 12px 8px 8px;
  flex: 1;
  overflow-y: auto;
}
.fila {
  position: relative;
  height: var(--fila);
  display: flex;
  align-items: center;
  cursor: pointer;
  white-space: nowrap;
}
.fila:hover { background: var(--sel); }
.fila.titulo {
  cursor: default;
  font-size: 12px;
  color: var(--apagado);
  padding: 6px 0 0 10px;
}
.fila.titulo:hover { background: none; }
.fila .barrita {
  position: absolute;
  left: 4px; top: 6px; bottom: 6px;
  width: 3px;
}
.fila .hash { width: 18px; margin-left: 16px; color: var(--apagado); flex: none; }
.fila .nombre { overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-right: 10px; }
.fila.canal .barrita { background: var(--acento2); }
.fila.canal .hash, .fila.canal .nombre { color: var(--acento2); font-weight: 600; }
.fila.musica .hash { display: flex; align-items: center; }
.fila.musica .hash svg { width: 14px; height: 14px; }
.fila.musica, .fila.musica .hash { color: var(--tenue); }
.fila.musica.suena, .fila.musica.suena .hash { color: var(--acento); }
.fila.musica.activa .barrita { background: var(--acento); }
.fila.musica.activa .nombre { font-weight: 600; }
.fila.sala.mia .barrita { background: var(--acento); }
.fila.sala.mia .hash, .fila.sala.mia .nombre { color: var(--acento); font-weight: 600; }
.fila.sala.activa-vista { background: var(--sel); }

/* gente colgando de una sala */
.fila.persona { font-size: 12px; color: var(--tenue); }
.fila.persona .guia { position: absolute; left: 24px; top: 0; bottom: 0; width: 1px; background: #222838; }
.fila.persona.lobby .guia { display: none; }
.fila.persona .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 40px;
  margin-right: 10px;
  flex: none;
  background: #2E3648;
  border: 1px solid #3E485E;
}
.fila.persona.habla { color: var(--texto); }
.fila.persona.habla .dot { background: var(--acento); border-color: #96FFDC; }
.fila.persona .nombre { flex: 1; }
.fila.persona .estado-icono { width: 16px; height: 16px; margin-right: 6px; flex: none; color: var(--tenue); }

.cluster {
  flex: none;
  margin: 0 var(--pad);
  border-top: 1px solid var(--borde);
  padding: 10px 0 6px;
}
.botones-audio { display: flex; gap: 8px; }
.cluster .boton.ancho { margin-top: 8px; }

/* ---- vistas ---- */
.principal { flex: 1; min-width: 0; background: var(--chatbg); position: relative; }
.vista { display: none; position: absolute; inset: 0; flex-direction: column; }
.vista.activa { display: flex; }
.titulo-vista {
  flex: none;
  margin: 0 var(--pad);
  height: 43px;
  padding: 0 0 0 4px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--borde);
  white-space: nowrap;
  overflow: hidden;
}
.titulo-vista b { font-weight: 600; }

/* chat (el RichEdit de la app) */
.mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 8px var(--pad) 8px calc(var(--pad) + 11px);
  line-height: 20px;
  overflow-wrap: anywhere;
}
.mensajes .cabeza { margin-top: 0; }
.mensajes .quien { color: var(--acento2); font-weight: 600; }
.mensajes .hora { color: var(--apagado); margin-left: 12px; }
.mensajes .linea { white-space: pre-wrap; }
.mensajes .linea.mia { cursor: context-menu; }
.mensajes .sistema { color: var(--apagado); font-style: italic; }
.mensajes a { color: var(--texto); }
.escribir {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px var(--pad) 12px var(--pad);
}

/* llamada: los tiles (draw_tile) */
.tiles {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 12px;
  padding: 9px var(--pad) 12px;
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
}
.tiles .vacio { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; color: var(--apagado); }
.tile {
  position: relative;
  background: #0E1119;
  border: 1px solid #202636;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  cursor: pointer;
}
.tile.habla { border-color: var(--acento); box-shadow: inset 0 0 0 2px var(--acento); }
.tile .avatar {
  width: var(--av, 92px);
  height: var(--av, 92px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #10121A;
  font-weight: 600;
  font-size: calc(var(--av, 92px) / 2);
  margin-top: -16px;
  flex: none;
}
.tile.sordo .avatar { background: #461A1A !important; border: 1px solid var(--peligro); color: #E28080; }
.tile .nick {
  position: absolute;
  left: 8px; right: 8px; bottom: 8px;
  text-align: center;
  font-weight: 600;
  color: var(--tenue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile.habla .nick { color: var(--texto); }
.tile .estado-icono { position: absolute; left: 10px; top: 10px; width: 18px; height: 18px; color: var(--tenue); }

/* musica (lo que se puede desde la web por ahora) */
.musica-web { padding: 16px calc(var(--pad) + 4px); }
.mus-estado {
  background: var(--sidebar);
  border: 1px solid var(--borde);
  border-radius: 6px;
  padding: 14px 16px;
  color: var(--tenue);
  margin-bottom: 10px;
}
.mus-estado b { color: var(--texto); font-weight: 600; }

/* ---- barra de abajo y deck de audio ---- */
.barra {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 var(--pad);
  background: linear-gradient(var(--header), var(--header-top));
  border-top: 1px solid var(--borde);
  min-width: 0;
}
.deck {
  width: 200px;
  height: 44px;
  flex: none;
  background: var(--bg);
  border: 1px solid var(--borde);
  border-radius: 5px;
  padding: 3px 11px 0;
  display: flex;
  flex-direction: column;
}
.deck-fila { display: flex; align-items: center; gap: 8px; height: 22px; min-width: 0; }
.deck-fila b { font-weight: 600; color: var(--tenue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck.en-sala .deck-fila b { color: var(--texto); }
.deck-punto { width: 8px; height: 8px; flex: none; background: #3E485E; }
.estado { font-size: 12px; color: var(--tenue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* VU segmentado (draw_vu): 12 bloques, los ultimos amarillos y rojos. Apagado
   = el mismo color hundido 82 % hacia el fondo. */
.vu { display: flex; gap: 3px; height: 8px; margin-top: 5px; position: relative; }
.vu i { flex: 1; background: #09342D; position: relative; }
.vu i.a { background: #352E1B; }
.vu i.r { background: #371517; }
.vu i.on { background: var(--acento); }
.vu i.a.on { background: #F5C542; }
.vu i.r.on { background: var(--peligro); }
.vu i.umbral::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: -5px;
  height: 3px;
  background: #F5D25A;
}
.vu.grande { height: 14px; margin: 14px 0 6px; gap: 4px; }
.vu.grande i.umbral::before { top: -7px; }

/* ---- configuracion ---- */
.cfg {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: var(--header-h);
  background: #06070B;
  overflow-y: auto;
  padding: 0 16px;
  z-index: 20;
}
.cfg .panel-cfg { margin-top: 4px; }

.deslizador { width: 100%; margin: 4px 0 0; accent-color: var(--acento2); height: 24px; }

/* ---- tarjeta de usuario (vol_pintar) ---- */
.velo-tarjeta { position: fixed; inset: 0; z-index: 30; }
.tarjeta {
  position: fixed;
  z-index: 31;
  width: 240px;
  background: var(--sidebar);
  border: 1px solid #323E58;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55);
  padding-bottom: 8px;
}
.tarjeta .cab { display: flex; align-items: center; gap: 10px; padding: 12px 14px 0; }
.tarjeta .av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #0A0C10;
  flex: none;
}
.tarjeta .quien { min-width: 0; }
.tarjeta .quien b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarjeta .quien span { font-size: 12px; color: var(--apagado); }
.tarjeta .vol { display: flex; justify-content: space-between; font-size: 12px; color: var(--tenue); padding: 12px 16px 0; }
.tarjeta .vol .v { color: var(--tenue); }
.tarjeta .vol .v.cambiado { color: var(--acento2); }
.tarjeta .vol .v.cero { color: var(--peligro); }
.tarjeta .riel { position: relative; margin: 6px 16px 0; height: 24px; }
.tarjeta .riel .marca100 { position: absolute; top: 2px; width: 2px; height: 4px; background: var(--apagado); margin-left: -1px; }
.tarjeta input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.tarjeta input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, var(--lleno, var(--acento2)) var(--p, 50%), #283044 var(--p, 50%));
}
.tarjeta input[type=range]::-moz-range-track {
  height: 4px;
  background: linear-gradient(to right, var(--lleno, var(--acento2)) var(--p, 50%), #283044 var(--p, 50%));
}
.tarjeta input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #F0F5FF;
  border: 1px solid #96AFDC;
}
.tarjeta input[type=range]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #F0F5FF;
  border: 1px solid #96AFDC;
}
.tarjeta .sep { height: 1px; background: var(--borde); margin: 10px 10px 4px; }
.tarjeta .accion {
  display: block;
  width: calc(100% - 12px);
  margin: 0 6px;
  height: 32px;
  text-align: left;
  padding: 0 10px;
  background: none;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}
.tarjeta .accion:hover { background: var(--sel); }
.tarjeta .accion.peligro { color: var(--peligro); }
.tarjeta .accion.peligro:hover { background: #5C1A18; color: #FFC8C4; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--barra-h) + 12px);
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  background: var(--campo);
  border: 1px solid var(--borde);
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 13px;
  z-index: 40;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}

.solo-movil { display: none !important; }
.velo-menu { display: none; }

/* ---- celular / pantallas angostas ---- */
@media (max-width: 899px) {
  :root { --header-h: 56px; --barra-h: 62px; }

  .solo-movil { display: flex !important; }
  .header { padding: 0 10px; gap: 8px; }
  .header .logo { font-size: 20px; line-height: 24px; }
  .nick-header { display: none; }
  .punto-conexion { margin-right: 2px; }

  /* La barra lateral pasa a ser un cajon que sale de la izquierda. */
  .sidebar {
    position: fixed;
    z-index: 25;
    top: 0; bottom: 0; left: 0;
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform .18s ease-out;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 8px 0 30px rgba(0, 0, 0, .5);
  }
  .sidebar.abierta { transform: none; }
  .velo-menu:not(.oculto) { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 24; }
  .fila { height: 40px; }
  .fila.persona { height: 34px; }
  .cluster .botones-audio { display: none; }

  /* Mute, ensordecer y salir quedan abajo, a mano con el pulgar. */
  .barra { gap: 8px; padding-bottom: env(safe-area-inset-bottom); height: calc(var(--barra-h) + env(safe-area-inset-bottom)); }
  .app { grid-template-rows: var(--header-h) 1fr calc(var(--barra-h) + env(safe-area-inset-bottom)); }
  .deck { flex: 1; width: auto; min-width: 0; }
  .barra .boton.icono { height: 44px; width: 48px; }
  .estado { display: none; }

  .escribir { padding: 8px 10px; }
  .escribir .campo { height: 42px; font-size: 16px; }   /* 16px: iOS no hace zoom al tocar */
  .escribir .boton.enviar { height: 42px; }
  .campo { font-size: 16px; }
  .mensajes { padding-left: 14px; }
  .titulo-vista { height: 40px; }
  .tiles { gap: 8px; padding: 8px; }
  .panel-cfg { margin-top: 16px; padding: 16px; }
  .cfg { padding: 0 10px; }
}

@media (min-width: 900px) {
  .toast { display: none !important; }
}
