:root {
  --bg: #081726;
  --bg2: #0b1f33;
  --card: #11293f;
  --text: #eaf2fb;
  --muted: #9fb4c9;
  --primary: #1f9d55;
  --primary-press: #18803f;
  --danger: #d84545;
  --accent: #ffb020;
  --live: #ff4d4d;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  line-height: 1.45;
}

.wrap {
  max-width: 540px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
}
.brand .logo {
  font-size: 30px;
}
.brand h1 {
  font-size: 20px;
  margin: 0;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.card.center {
  text-align: center;
}
.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

/* Botones grandes, fáciles de pulsar */
.big-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 22px 18px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: #2b4a66;
  margin: 10px 0;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.big-btn:active {
  transform: scale(0.98);
}
.big-btn:disabled {
  opacity: 0.5;
}
.big-btn.primary {
  background: var(--primary);
  color: var(--primary-text, #fff);
}
.big-btn.primary:active {
  background: var(--primary-press);
}
.big-btn.danger {
  background: var(--danger);
}
.big-btn.is-muted {
  background: var(--accent);
  color: #1a1300;
}

.small-btn {
  background: transparent;
  border: 1px solid #2f5273;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}

/* Estado de conexión */
.status {
  display: inline-block;
  font-weight: 700;
  font-size: 16px;
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.status-idle,
.status-preparando {
  background: #20364c;
  color: var(--muted);
}
.status-connecting,
.status-waiting {
  background: #3a3410;
  color: var(--accent);
}
.status-reconnecting {
  background: #4a2410;
  color: #ffb27a;
}
.status-paused {
  background: #2a2f1a;
  color: #e8d56b;
}
.status-live {
  background: rgba(255, 77, 77, 0.16);
  color: var(--live);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.listeners {
  color: var(--muted);
  font-size: 15px;
  margin: 6px 0 0;
}
.ratings-summary {
  margin-top: 12px;
  padding: 12px;
  background: #0a1c2e;
  border: 1px solid #2f5273;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  text-align: left;
}

.room-line {
  font-size: 17px;
  margin: 14px 0 6px;
}
.room-line strong {
  letter-spacing: 4px;
  font-size: 26px;
  color: var(--accent);
}

.link {
  display: block;
  word-break: break-all;
  color: #7fc4ff;
  font-size: 14px;
  text-decoration: none;
  margin-top: 4px;
}

.qr {
  display: flex;
  justify-content: center;
  background: #fff;
  width: fit-content;
  margin: 12px auto;
  padding: 12px;
  border-radius: 12px;
}
.qr img,
.qr canvas {
  display: block;
}

.tips {
  font-size: 14px;
  color: var(--muted);
}
.tips p {
  margin: 6px 0;
}

.vol-label {
  display: block;
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 14px;
}
input[type="range"] {
  width: 100%;
  height: 36px;
  accent-color: var(--primary);
}

.error {
  /* Fondo casi opaco: legible sobre cualquier color de marca */
  background: rgba(105, 22, 22, 0.94);
  border: 1px solid var(--danger);
  color: #ffd9d9;
  padding: 14px;
  border-radius: 12px;
  font-size: 14px;
}

/* Levantar la mano (oyente) */
.hand-area {
  margin-top: 14px;
  border-top: 1px solid #21384e;
  padding-top: 14px;
}
.name-label {
  display: block;
  text-align: left;
  margin: 4px 0 6px;
  font-size: 14px;
  color: var(--muted);
}
.name-input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2f5273;
  background: #0a1c2e;
  color: #eaf2fb; /* fijo: el fondo del campo es siempre oscuro */
  font-size: 16px;
  margin-bottom: 14px;
}
.hand-status {
  font-size: 16px;
  font-weight: 600;
  margin: 6px 0 10px;
  color: var(--accent);
}

/* Peticiones de palabra (guía) */
.hands-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.hands-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid #21384e;
}
.hand-name {
  flex: 1 1 100%;
  font-size: 16px;
  font-weight: 600;
}
.small-btn.give {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text, #fff);
}
.small-btn:disabled {
  opacity: 0.4;
}
.speaker-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(255, 77, 77, 0.14);
  border: 1px solid var(--live);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  font-weight: 700;
}

/* Valoración por estrellas */
.stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 16px 0;
}
.stars button {
  background: none;
  border: none;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
  color: #3a5572;
  padding: 2px 4px;
  transition: transform 0.05s ease;
}
.stars button:active {
  transform: scale(0.9);
}
.stars button.on {
  color: var(--accent);
}
.stars.stars-mini button {
  font-size: 26px;
}
.rating-details {
  text-align: left;
  margin-top: 10px;
}
.rating-details textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #2f5273;
  background: #0a1c2e;
  color: #eaf2fb; /* fijo: campo siempre oscuro */
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 10px;
}
.aspect-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  font-size: 15px;
}

.diag {
  background: #04101c;
  border: 1px solid #2f5273;
  color: #8fe39a;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 12px;
  border-radius: 10px;
  margin-top: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

/* Header: nombres de empresa y guía */
.brand-names {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.brand-names h1 {
  margin: 0;
  font-size: 20px;
}
.guide-name-tag {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

/* Logo de marca en el header del oyente */
.brand-logo-img {
  max-height: 40px;
  max-width: 140px;
  object-fit: contain;
  border-radius: 6px;
}

/* Configuración de sala (guía) */
.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.setting-row label {
  color: var(--muted);
  font-size: 14px;
  min-width: 100px;
}
.setting-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #2f5273;
  background: #0a1c2e;
  color: #eaf2fb; /* fijo: campo siempre oscuro */
  font-size: 15px;
  min-width: 0;
}
.setting-input:disabled {
  opacity: 0.4;
}
input[type="color"] {
  width: 44px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #2f5273;
  background: #0a1c2e;
  cursor: pointer;
  padding: 2px;
}
input[type="color"]:disabled {
  opacity: 0.4;
}
.setting-ctrl {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
}
.setting-sep {
  border: none;
  border-top: 1px solid #21384e;
  margin: 12px 0;
}
.setting-label {
  margin: 0 0 4px;
}

/* Recovery banner (guía: volver a última sala) */
.recovery-banner {
  border: 1px solid var(--accent);
}
.recovery-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

/* Q&A de texto (oyente) */
.question-area {
  margin-top: 14px;
  border-top: 1px solid #21384e;
  padding-top: 14px;
}
.question-textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #2f5273;
  background: #0a1c2e;
  color: #eaf2fb; /* fijo: campo siempre oscuro */
  font-size: 15px;
  font-family: inherit;
  resize: none;
  margin-bottom: 8px;
}
.question-form-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Q&A (guía): texto de la pregunta */
.question-text {
  flex: 1 1 100%;
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0 6px;
  line-height: 1.4;
}

/* Lista de oyentes (guía) con botón de expulsar */
.listeners-panel {
  margin-top: 8px;
}
.listeners-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}
.listener-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #21384e;
  font-size: 14px;
}
.kick-btn {
  color: var(--danger);
  border-color: var(--danger);
  font-size: 12px;
  padding: 6px 10px;
  flex-shrink: 0;
}

/* Entrada manual de código (turista) */
.code-entry {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.code-input {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  text-transform: uppercase;
}

/* Botones post-valoración (propina, reseña) */
.post-action-btn {
  text-decoration: none;
  text-align: center;
}

/* Destello de la tarjeta cuando llega una interacción nueva (pregunta / mano) */
@keyframes cardFlash {
  0% { box-shadow: 0 0 0 3px var(--primary); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}
.card.flash {
  animation: cardFlash 1.1s ease-out 2;
}

/* Barra de sesión del guía + página de acceso (/login) */
.session-bar {
  text-align: center;
  font-size: 13px;
  margin: -6px 0 14px;
}
.session-bar a {
  color: inherit;
  text-decoration: underline;
}
.login-input {
  width: 100%;
  margin: 10px 0 12px;
}

/* Casilla con etiqueta (login: mantener sesión; admin: personalización) */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 12px;
  cursor: pointer;
  text-align: left;
}
.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin: 0;
}

/* Manuales de uso (/manual/turista, /manual/guia, /manual/admin) */
.manual-link {
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
}
.manual-card h2 {
  font-size: 17px;
  margin: 20px 0 6px;
}
.manual-card h2:first-of-type {
  margin-top: 0;
}
.manual-card p {
  font-size: 15px;
  margin: 6px 0;
}
.manual-card ul,
.manual-card ol {
  margin: 6px 0 4px;
  padding-left: 20px;
}
.manual-card li {
  font-size: 15px;
  margin: 6px 0;
}
.manual-intro {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 6px;
}
.manual-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 6px;
}
.manual-table td {
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid #21384e;
  vertical-align: top;
}
.manual-table td:first-child {
  color: var(--muted);
}
/* Botón de volver del manual: arriba discreto, abajo grande */
.manual-back {
  display: inline-block;
  align-self: flex-start;
  text-decoration: none;
  margin-top: 0;
}
.manual-back-bottom {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* Hub de tours (guía): un botón grande por tour de la empresa */
.tour-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}
.tour-btn {
  text-align: left;
  font-size: 18px;
  padding: 18px;
}
/* Botón de vuelta a la lista de tours desde la sala (guía) */
.back-tours-btn {
  margin: 0 0 12px;
}

/* Tarjetas translúcidas (marca de empresa): cristal sobre el degradado del
   fondo. Color y opacidad llegan en --card-glass (rgba que fija theme.js);
   el cristal es claro sobre fondos claros y oscuro sobre oscuros, así el
   texto de la tarjeta siempre tiene una superficie legible detrás. */
body.cards-translucent .card {
  background: var(--card-glass, rgba(17, 41, 63, 0.55));
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
  backdrop-filter: blur(16px) saturate(1.35);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
}

/* Texto DENTRO de las tarjetas: theme.js decide la clase según la superficie
   real (color de tarjeta o cristal ya mezclado con el fondo). Redefinir las
   variables scoped a .card cubre títulos, .muted, etiquetas… de una vez. */
body.card-text-dark .card {
  --text: #0f2233;
  --muted: #33465a;
  color: var(--text);
}
body.card-text-light .card {
  --text: #eaf2fb;
  --muted: #9fb4c9;
  color: var(--text);
}
/* Elementos con colores fijos pensados para tarjeta oscura → variante clara */
body.card-text-dark .card .link {
  color: #0b5aa5;
}
body.card-text-dark .card .hand-status {
  color: #7a4d00;
}
body.card-text-dark .card .room-line strong {
  color: #8a5a00;
}
body.card-text-dark .card .stars button {
  color: #92a6ba;
}
body.card-text-dark .card .stars button.on {
  color: #b57a00;
}

/* Botón con cambios sin guardar (admin): imposible no verlo */
@keyframes attentionPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 176, 32, 0.9); }
  50% { box-shadow: 0 0 0 8px rgba(255, 176, 32, 0); }
}
.big-btn.attention {
  animation: attentionPulse 1.2s ease-out infinite;
  outline: 2px solid var(--accent);
}

/* Deslizador de opacidad del cristal (admin) */
.glass-slider-row input[type="range"] {
  flex: 1;
  height: 32px;
}
.glass-slider-row .glass-value {
  min-width: 44px;
  text-align: right;
}

/* Biblioteca de imágenes: galería de miniaturas (guía y admin) */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.media-item {
  position: relative;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
  background: #0a1c2e;
  cursor: pointer;
  aspect-ratio: 1;
}
.media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.media-item .media-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(105, 22, 22, 0.92);
  color: #ffd9d9;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  padding: 3px 7px;
  cursor: pointer;
}
.media-group-label {
  margin: 12px 0 0;
  font-weight: 600;
}
.media-upload-row {
  margin-top: 12px;
}
.media-quota-note {
  font-size: 13px;
}

/* Imagen que el guía lanza al grupo (vista del turista) */
.media-area {
  margin-top: 14px;
  border-top: 1px solid #21384e;
  padding-top: 14px;
}
.media-area img {
  width: 100%;
  border-radius: 12px;
  display: block;
  cursor: zoom-in;
}
.media-caption {
  margin: 10px 0 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
}

/* Pantalla completa de la imagen con su pie (toque para cerrar) */
.media-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  cursor: zoom-out;
  padding: 16px;
}
.media-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
}
.media-overlay img {
  max-width: 100%;
  max-height: 78dvh;
  border-radius: 8px;
}
.media-overlay-caption {
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  margin: 14px 0 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Editor de punto de encuentro por tour (admin): desplegable bajo la fila */
.meeting-editor {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid #2f5273;
  border-radius: 12px;
}
.meeting-editor p {
  margin: 0;
}
.meeting-editor-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.meeting-editor-btns .small-btn {
  margin-top: 0;
}

/* Ubicación del guía + punto de encuentro (turista) */
.loc-area {
  margin-top: 14px;
  border-top: 1px solid #21384e;
  padding-top: 14px;
}
/* position + z-index 0: los planos internos de Leaflet (z 400-700) quedan
   encerrados en este contexto y nunca tapan la foto a pantalla completa */
.loc-map {
  width: 100%;
  height: 300px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  z-index: 0;
  background: #dbe6ee;
}
.loc-info {
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 600;
}
.loc-meeting-label {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 600;
}
.loc-pin-wrap {
  background: none;
  border: none;
}
.loc-emoji-pin {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}
.loc-you-dot {
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.3);
}
/* El botón del punto de encuentro en la puerta es un enlace: sin subrayado */
.gate-meeting-btn {
  display: inline-block;
  text-decoration: none;
  margin-top: 10px;
}

/* Salir de la emisión (turista) */
.leave-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  color: var(--danger);
  border-color: var(--danger);
}

.hidden {
  display: none !important;
}
