/* Paleta de marca de El Origen, la misma de los correos de Karos Online:
   fondo #060d1a, tarjeta #0c1828, borde #1a3050, dorado #D4A84B, azul #00A8FF.
   Se fija el tema oscuro y no se ofrece variante clara: la identidad es oscura
   y en claro el dorado sobre blanco pierde todo el contraste. */
:root {
  --bg: #060d1a;
  --panel: #0c1828;
  --panel-2: #112036;
  --line: #1a3050;
  --text: #e6ecf5;
  --muted: #7d8fa8;
  --accent: #00a8ff;
  --gold: #d4a84b;
  --gold-soft: #ffd780;
  --accent-2: #2ecc9a;
  --danger: #ff5c5c;
  --hover: #112036;
  --radius: 10px;
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { height: 100vh; display: flex; flex-direction: column; }
#join { align-items: center; justify-content: center; }

/* ------------------------------------------------------------------- entrada */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(400px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card .logo { width: 170px; height: auto; align-self: center; }
.accent { color: var(--gold); }
.logo-sm { height: 30px; width: auto; display: block; }

/* ------------------------------------------------------------ manos alzadas */

.hands {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #d4a84b1f, transparent);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.hands-label { color: var(--gold); font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.hands-list { display: flex; gap: 8px; flex-wrap: wrap; }

.hand-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 3px 10px 3px 4px;
  font-size: 13px;
}
.hand-chip.mine { background: #d4a84b26; }
.hand-num {
  background: var(--gold);
  color: #060d1a;
  font-weight: 700;
  font-size: 11px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hand-name { white-space: nowrap; }
.card .sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input, select, button {
  font: inherit;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

button {
  cursor: pointer;
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
button:hover { filter: brightness(1.1); }

button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost.danger { color: var(--danger); }
button.ghost[aria-pressed="true"] { background: var(--accent-2); color: #061a13; border-color: transparent; font-weight: 600; }
button.small { padding: 5px 10px; font-size: 12px; }

.error { color: var(--danger); font-size: 13px; margin: 0; }

/* --------------------------------------------------------------------- avatar */

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}

/* ---------------------------------------------------------------------- chat */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}

.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.head-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.tag.warn { color: #f5a623; border-color: #f5a62355; }
.tag.ok { color: var(--accent-2); border-color: #2ecc9a55; }

.mic { display: flex; align-items: center; gap: 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.mic .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.mic[aria-pressed="true"] { background: var(--danger); color: #fff; border-color: transparent; font-weight: 600; }
.mic[aria-pressed="true"] .dot { background: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

main { flex: 1; display: flex; min-height: 0; }

.log { flex: 1; overflow-y: auto; padding: 12px 0; }

/* ------------------------------------------------------ pantalla compartida */

.stage {
  background: #000;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  max-height: 46vh;
}
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--panel);
  font-size: 13px;
  color: var(--muted);
}
.stage video {
  width: 100%;
  min-height: 0;
  flex: 1;
  object-fit: contain;
  background: #000;
}

/* ------------------------------------------------- modo pantalla completa */

.stage:fullscreen {
  max-height: none;
  height: 100vh;
  width: 100vw;
}
.stage:fullscreen video { flex: 1; height: auto; }

/* El chat flotante se ancla sobre el video, sin robarle sitio. */
.float-chat {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(400px, 34vw);
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  background: rgba(6, 13, 26, .82);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  overflow: hidden;
  z-index: 5;
}
.float-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.float-title { font-size: 12px; font-weight: 700; color: var(--gold); }

.float-slot { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.float-slot .log { flex: 1; min-height: 0; }
.float-slot #send-form { padding: 8px; border-top: 1px solid var(--line); flex-shrink: 0; }

/* Plegado: se queda solo la barra de titulo, para no tapar la presentacion. */
.float-chat.collapsed { max-height: none; }
.float-chat.collapsed .float-slot { display: none; }

/* En pantalla completa los subtitulos suben, o el chat flotante los taparia. */
.stage:fullscreen .captions { bottom: 24px; left: 24px; transform: none; width: min(620px, 60vw); }

@media (max-width: 900px) {
  .float-chat { width: min(340px, 80vw); right: 10px; bottom: 10px; }
}

/* ------------------------------------------------------------------ roster */

.roster {
  width: 210px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  overflow-y: auto;
  font-size: 13px;
}
.roster h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }
.roster .who { display: flex; align-items: center; gap: 9px; padding: 5px 0; }
.roster .who-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.roster .who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .flag { color: var(--muted); font-size: 10px; letter-spacing: .05em; }
.roster .who-line { display: flex; align-items: center; gap: 5px; min-width: 0; }
.roster .icon { font-size: 11px; line-height: 1; }
.roster .icon.hand { animation: wave 1.4s ease-in-out infinite; }
.roster .icon.share-on { color: var(--accent-2); }
@keyframes wave { 50% { transform: translateY(-2px) rotate(-12deg); } }

.peer-mute {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 6px;
  flex-shrink: 0;
}
.peer-mute.on { color: var(--danger); border-color: #ff5c5c55; }

/* selector de pantalla cuando hay varias compartiendo */
.picker { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: center; }
.picker .pick {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
}
.picker .pick.on { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }

/* --------------------------------------------------------------- mensajes */

.row {
  display: flex;
  gap: 12px;
  padding: 3px 16px;
}
.row:hover { background: var(--hover); }
.row.grouped { padding-top: 0; }
.row .gutter { width: 38px; flex-shrink: 0; }
.row .body { min-width: 0; flex: 1; }

.row .head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; flex-wrap: wrap; }
.row .author { font-weight: 600; }
.row .time { font-size: 11px; color: var(--muted); }

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  letter-spacing: .04em;
}
.badge.voice-badge { color: var(--accent-2); border-color: #2ecc9a55; }

.row .text { line-height: 1.5; overflow-wrap: anywhere; }
.row .orig {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}

/* El propio mensaje se marca con una linea de acento, no cambiando de lado:
   con avatares, alinear a la derecha rompe la rejilla. */
.row.mine { border-left: 2px solid var(--accent); padding-left: 14px; }

.msg.sys {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 6px 16px;
}

/* -------------------------------------------------------------- subtitulos */

.captions {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: min(760px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.caption {
  background: rgba(0, 0, 0, .78);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 17px;
  line-height: 1.4;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 9px;
}
.caption .who { color: var(--accent-2); font-weight: 700; font-size: 14px; }
.caption .body { flex: 1; }
.caption.partial { opacity: .72; }

/* --------------------------------------------------------------------- pie */

footer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px; }
#send-form { display: flex; gap: 8px; }
#send-form input { flex: 1; }

.stt-status { margin: 6px 2px 0; font-size: 11px; color: var(--muted); min-height: 14px; }

@media (max-width: 720px) {
  .roster { display: none; }
  .stage { max-height: 38vh; }
}
