:root {
  --fondo: #fef6e4;
  --pantalla-txt: #ffffff;
  --tecla-num: #333333;
  --tecla-num-hover: #4d4d4d;
  --tecla-fn: #a5a5a5;
  --tecla-fn-txt: #000000;
  --tecla-op: #ff9f0a;
  --tecla-op-txt: #ffffff;
  --burbuja-propia: #0a84ff;
  --burbuja-otro: #262628;
  --acento: #0a84ff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ============ LIBRETA DE NOTAS (disfraz) ============ */
#vista-notas {
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: #fef6e4;
  color: #2b2b2b;
}

.notas-header {
  padding: max(20px, env(safe-area-inset-top)) 20px 16px;
  background: linear-gradient(180deg, #fffaf0, #fef6e4);
}
.notas-titulo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
  color: #262117;
}
.notas-buscador {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #f0e6cc;
  border-radius: 14px;
  padding: 11px 16px;
  color: #9a9482;
  box-shadow: 0 2px 10px rgba(139, 111, 26, 0.05);
  transition: border-color 0.15s ease;
}
.notas-buscador:focus-within { border-color: #f2a93b; }
.notas-buscador input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  color: #2b2b2b;
}
.notas-buscador input::placeholder { color: #b3ab90; }

.notas-lista { flex: 1; overflow-y: auto; padding: 6px 14px 90px; }

.notas-vacio {
  text-align: center;
  color: #a39d87;
  font-size: 14px;
  padding: 60px 24px;
}

.nota-item {
  background: #fff;
  border: none;
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(139, 111, 26, 0.08);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.nota-item:active { transform: scale(0.98); box-shadow: 0 2px 6px rgba(139, 111, 26, 0.1); }
.nota-item-titulo { font-size: 16.5px; font-weight: 700; color: #262117; margin-bottom: 5px; letter-spacing: -0.01em; }
.nota-item-preview { font-size: 14px; color: #93896d; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nota-item-fecha { font-size: 11.5px; color: #f2a93b; margin-top: 9px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }

.notas-fab {
  position: absolute;
  right: 18px;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffc169, #f2a93b);
  border: none;
  box-shadow: 0 8px 20px rgba(242,169,59,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.notas-editor {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #fef6e4;
  display: flex;
  flex-direction: column;
}
.notas-editor-barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 10px 10px;
}
.notas-editor-barra .btn-icono { color: #2b2b2b; }
.notas-editor-fecha { font-size: 12.5px; color: #a39d87; }
.notas-editor-titulo {
  border: none;
  background: none;
  outline: none;
  font-size: 22px;
  font-weight: 700;
  color: #2b2b2b;
  padding: 6px 18px;
}
.notas-editor-titulo::placeholder { color: #cfc7ab; }
.notas-editor-contenido {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  resize: none;
  font-size: 16px;
  line-height: 1.5;
  color: #2b2b2b;
  padding: 6px 18px 24px;
  font-family: -apple-system, sans-serif;
}
.notas-editor-contenido::placeholder { color: #cfc7ab; }

.notas-editor-acciones { display: flex; align-items: center; gap: 4px; }
.notas-editor-guardar-btn {
  background: #f2a93b;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.notas-editor-guardar-btn:active { background: #d9922a; }

/* ============ BANNER DE INSTALACIÓN ============ */
.banner-instalar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 90;
  background: #2b2b2b;
  color: #fff;
  border-radius: 14px;
  padding: 12px 12px 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: hojaSube 0.25s ease;
}
.banner-instalar-icono { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.banner-instalar-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.banner-instalar-texto strong { font-size: 14px; }
.banner-instalar-texto span { font-size: 12px; color: #b3b3b3; }
.banner-instalar-boton {
  background: #f2a93b;
  color: #2b2b2b;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.banner-instalar-x {
  background: none;
  border: none;
  color: #8a8a8a;
  padding: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  position: fixed;
  inset: 0;
  background: var(--fondo);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
}

.vista { display: none; }
.vista.activa { display: flex; }

/* ============ CALCULADORA ============ */
#vista-calculadora {
  flex-direction: column;
  justify-content: flex-end;
  height: 100vh;
  height: 100dvh;
  padding: 0 12px max(24px, env(safe-area-inset-bottom));
}

.pantalla-calc {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px 12px;
  min-height: 30vh;
}

.calc-historial {
  font-size: 28px;
  color: #8e8e93;
  min-height: 34px;
}

.calc-actual {
  font-size: 72px;
  font-weight: 300;
  color: var(--pantalla-txt);
  line-height: 1;
}

.teclado-calc {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.tecla {
  border: none;
  border-radius: 50%;
  aspect-ratio: 1;
  font-size: 32px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tecla-num { background: var(--tecla-num); color: #fff; }
.tecla-num:active { background: var(--tecla-num-hover); }
.tecla-fn { background: var(--tecla-fn); color: var(--tecla-fn-txt); }
.tecla-op { background: var(--tecla-op); color: var(--tecla-op-txt); font-size: 38px; }
.tecla-igual { background: var(--tecla-op); color: var(--tecla-op-txt); font-size: 38px; }

.tecla-cero {
  grid-column: span 2;
  border-radius: 40px;
  justify-content: flex-start;
  padding-left: 32px;
  aspect-ratio: auto;
}

/* ============ DESBLOQUEO ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.94);
  align-items: center;
  justify-content: center;
}

.tarjeta-auth {
  width: 86%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.auth-insignia {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2a8bff, #0a56c4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 14px;
  box-shadow: 0 0 0 6px rgba(10, 132, 255, 0.12);
}

.tarjeta-auth h2 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
  color: #f2f2f2;
}

.auth-subtitulo {
  font-size: 13.5px;
  color: #8e8e93;
  margin: 0 0 22px;
  line-height: 1.4;
}

.auth-campos {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.auth-etiqueta {
  display: block;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6c6c70;
  margin-bottom: 6px;
}

.campo-auth {
  width: 100%;
  background: #1c1c1e;
  border: 1.5px solid #333336;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  color: #fff;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.campo-auth::placeholder { color: #57575b; }

.campo-auth:focus {
  outline: none;
  border-color: var(--acento);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.15);
}

.campo-pin {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 10px;
  font-family: -apple-system, 'Courier New', monospace;
}

.btn-auth {
  width: 100%;
  background: var(--acento);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn-auth:active { transform: scale(0.98); opacity: 0.9; }

.btn-auth-secundario {
  background: transparent;
  color: var(--acento);
  font-weight: 500;
  margin-top: 8px;
  padding: 10px;
}

.auth-error {
  color: #ff453a;
  font-size: 13px;
  min-height: 16px;
  margin: 14px 0 0;
}

.auth-error:not(:empty) { animation: sacudida 0.3s ease; }

@keyframes sacudida {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-error:not(:empty) { animation: none; }
}

/* ============ CHAT (paleta estilo Telegram, tema oscuro) ============ */
:root {
  --tg-fondo: #fdf6f6;
  --tg-header: #ffffff;
  --tg-lista-hover: #f5eeee;
  --tg-borde: #f2f2f4;
  --tg-burbuja-propia: #e6294f;
  --tg-burbuja-otro: #ffffff;
  --tg-acento: #e6294f;
  --tg-acento-2: #ff5d7a;
  --tg-texto-sec: #a5a5aa;
  --tg-texto: #1c1c1e;
}

#vista-chat {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: #f0f1f5;
  position: fixed;
  inset: 0;
  z-index: 50;
}

.chat-header-grande {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 18px 20px;
  background: linear-gradient(160deg, #3a6df0, #1f3fb0);
  padding-top: max(20px, env(safe-area-inset-top));
  border-radius: 0 0 28px 28px;
}
.chat-header-fila { display: flex; align-items: flex-start; gap: 12px; }
.chat-header-textos { flex: 1; min-width: 0; }
.chat-header-titulo-grande {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0;
}
.chat-header-subtitulo {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  margin: 2px 0 0;
}
.chat-header .chat-header-titulo { flex: 1; }
.chat-header-grande .btn-icono { color: #fff; background: rgba(255,255,255,0.16); }
.chat-header-grande .btn-icono:active { background: rgba(255,255,255,0.28); }
#btn-cerrar-chat { background: rgba(255,255,255,0.16); }

.conv-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 34px;
  background: linear-gradient(160deg, #3a6df0, #1f3fb0);
  padding-top: max(16px, env(safe-area-inset-top));
  border-radius: 0 0 30px 30px;
  position: relative;
  overflow: hidden;
  z-index: 2;
  flex-shrink: 0;
}
.conv-header::after {
  content: '';
  position: absolute;
  left: -10%; right: -10%; bottom: -22px;
  height: 40px;
  background: #a9c4ff;
  border-radius: 50%;
}
.conv-titulo { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: #fff; }

.conv-header-textos-nombre { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.conv-subtitulo { font-size: 12px; color: rgba(255,255,255,0.75); min-height: 15px; }
.conv-subtitulo-escribiendo { color: #d7f7c8; font-style: italic; }
.conv-header .btn-icono { color: #fff; }

.btn-icono {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 19px;
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.12s ease;
}
.btn-icono:active { background: rgba(0,0,0,0.06); }

.buscador-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 10px 16px;
  transition: background 0.15s ease;
}
.buscador-wrap:focus-within { background: rgba(255,255,255,0.3); }
.buscador-icono { font-size: 14px; opacity: 0.85; color: #fff; }
.buscador-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 15px;
}
.buscador-input::placeholder { color: rgba(255,255,255,0.7); }

.lista-conversaciones {
  flex: 1;
  overflow-y: auto;
  margin: 16px 14px 0;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(31,63,176,0.12);
}

.item-conversacion {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 10px 12px 14px;
  border-bottom: 1px solid var(--tg-borde);
  cursor: pointer;
  transition: background 0.1s ease;
}
.item-conversacion:last-child { border-bottom: none; }
.item-conversacion:hover { background: #fbf3f3; }
.item-conversacion:active { background: var(--tg-lista-hover); }

.item-opciones {
  background: none;
  border: none;
  color: var(--tg-texto-sec);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-opciones:hover, .item-opciones:active { background: rgba(0,0,0,0.06); color: var(--tg-texto); }

.barra-inferior {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 8px max(10px, env(safe-area-inset-bottom));
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
  position: relative;
  z-index: 4;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: #a5a5aa;
  cursor: pointer;
  padding: 4px 6px;
}
.tab-item span { font-size: 10.5px; }
.tab-item.tab-activo { color: #1f3fb0; }
.tab-item.tab-activo span { font-weight: 600; }

.tab-central {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tg-acento-2), var(--tg-acento));
  border: 4px solid #fff;
  margin-top: -26px;
  box-shadow: 0 6px 16px rgba(230,41,79,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.item-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-linea-superior { display: flex; justify-content: space-between; align-items: baseline; }
.item-linea-inferior { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-nombre { font-size: 16px; font-weight: 600; color: var(--tg-texto); }
.item-hora { font-size: 12.5px; color: var(--tg-texto-sec); flex-shrink: 0; }
.item-preview { flex: 1; min-width: 0; font-size: 14px; color: var(--tg-texto-sec); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-preview-no-leido { color: var(--tg-texto); font-weight: 600; }

.badge-no-leidos {
  flex-shrink: 0;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--tg-acento);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.estado-vacio {
  padding: 40px 24px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.estado-vacio-texto {
  color: #8e8e93;
  font-size: 14px;
  line-height: 1.4;
  margin: 0;
  max-width: 260px;
}

.estado-vacio-texto-chica { font-size: 12.5px; opacity: 0.8; margin-top: 4px; }

.codigo-display-vacio {
  width: 100%;
  max-width: 220px;
  font-size: 22px;
  padding: 16px 10px;
  margin: 6px 0;
}

.estado-vacio .btn-auth { max-width: 220px; }

.fab {
  position: absolute;
  right: 18px;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tg-acento-2), var(--tg-acento));
  box-shadow: 0 8px 20px rgba(230,41,79,0.4);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vista-conversacion {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--tg-fondo);
  display: flex;
  flex-direction: column;
}
.oculto { display: none !important; }

.conv-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.conv-header-perfil-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
}
.conv-header-perfil-btn:active { background: rgba(255,255,255,0.12); }

.perfil-avatar-grande {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  margin: 4px auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #fff;
}

.perfil-codigo {
  font-size: 18px;
  padding: 12px 10px;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.conv-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #eef4ff;
}

.burbuja {
  max-width: 78%;
  padding: 8px 12px 6px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.35;
  word-wrap: break-word;
  position: relative;
}

.burbuja-propia {
  align-self: flex-end;
  background: linear-gradient(135deg, #4a7ef5, #1f3fb0);
  color: #fff;
  border-bottom-right-radius: 4px;
  position: relative;
}
.burbuja-propia::after {
  content: '';
  position: absolute;
  right: -6px; bottom: 0;
  width: 12px; height: 14px;
  background: #1f3fb0;
  clip-path: path('M0,0 C4,6 10,12 12,14 L0,14 Z');
}
.burbuja-otro {
  align-self: flex-start;
  background: #cfe0ff;
  color: #16305e;
  border-bottom-left-radius: 4px;
  position: relative;
}

.burbuja-eliminada {
  background: rgba(0,0,0,0.06) !important;
  color: #6b7280 !important;
}
.burbuja-eliminada::after { display: none; }
.burbuja-eliminada-texto {
  font-style: italic;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.burbuja-otro::after {
  content: '';
  position: absolute;
  left: -6px; bottom: 0;
  width: 12px; height: 14px;
  background: #cfe0ff;
  clip-path: path('M12,0 C8,6 2,12 0,14 L12,14 Z');
}

.fila-mensaje-otro {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  max-width: 85%;
  position: relative;
}

.deslizable { touch-action: pan-y; will-change: transform; }

.icono-deslizar-responder {
  position: absolute;
  left: -34px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
}
.burbuja.deslizable { position: relative; }
.mini-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.fila-mensaje-otro .burbuja-otro { max-width: 100%; }

.burbuja-hora {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 11px;
  margin-top: 2px;
}
.burbuja-propia .burbuja-hora { color: rgba(255,255,255,0.8); }
.burbuja-otro .burbuja-hora { color: #5b74a3; }

.palomitas { display: inline-flex; line-height: 1; }
.palomitas svg { display: block; }
.palomita-leido { color: #bef0ff; }
.palomita-pendiente { color: rgba(255,255,255,0.75); }

.conv-editando-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #c7dbff;
  color: #16305e;
  font-size: 13px;
  font-weight: 600;
}
.conv-editando-bar .btn-icono { color: #16305e; width: 28px; height: 28px; }

.conv-respondiendo-bar { align-items: flex-start; }
.conv-respondiendo-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.conv-respondiendo-titulo { font-size: 12.5px; }
.conv-respondiendo-cita {
  font-size: 12.5px;
  font-weight: 400;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.burbuja-cita {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 3px solid rgba(255,255,255,0.6);
  padding: 3px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.14);
}
.burbuja-otro .burbuja-cita { border-left-color: #1f3fb0; background: rgba(31,63,176,0.08); }
.burbuja-cita-nombre { font-size: 12px; font-weight: 700; }
.burbuja-cita-texto {
  font-size: 12.5px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.editado-etiqueta {
  font-size: 10.5px;
  font-style: italic;
  opacity: 0.75;
  margin-right: 4px;
}

.conv-entrada {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: #dceaff;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -2px 10px rgba(31,63,176,0.08);
  position: relative;
  overflow: visible;
  flex-shrink: 0;
}
.conv-entrada::before {
  content: '';
  position: absolute;
  left: -10%; right: -10%; top: -18px;
  height: 36px;
  background: #eef4ff;
  border-radius: 50%;
  z-index: -1;
}

.conv-entrada input {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: none;
  border-radius: 20px;
  padding: 11px 16px;
  color: var(--tg-texto);
  font-size: 15px;
  outline: none;
}
.conv-entrada input::placeholder { color: #b3b3b8; }

.btn-enviar {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4a7ef5, #1f3fb0);
  color: #fff;
  border: none;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-audio {
  background: linear-gradient(135deg, #4a7ef5, #1f3fb0);
  color: #fff;
  transition: background 0.15s ease, transform 0.15s ease;
}
.conv-entrada > .btn-icono {
  color: #fff;
  background: linear-gradient(135deg, #4a7ef5, #1f3fb0);
  border-radius: 12px;
  width: 38px;
  height: 38px;
}
.btn-audio.grabando {
  background: #ff453a;
  color: #fff;
  animation: pulsoGrabacion 1s ease-in-out infinite;
}

@keyframes pulsoGrabacion {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.conv-mensaje-audio {
  display: flex;
  align-items: center;
  gap: 8px;
}
.conv-mensaje-audio audio {
  height: 32px;
  max-width: 200px;
}

.burbuja-imagen {
  padding: 4px !important;
  max-width: 65% !important;
}
.conv-mensaje-imagen {
  display: block;
  width: 100%;
  border-radius: 12px;
  max-height: 320px;
  object-fit: cover;
  cursor: pointer;
}
.conv-mensaje-imagen-caption {
  padding: 6px 4px 2px;
  font-size: 14px;
}
.burbuja-imagen .burbuja-hora {
  padding: 4px 6px 2px;
}

/* ============ PANELES DE EMOJI Y STICKERS ============ */
.panel-flotante {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 62px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 5;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.emoji-grid button {
  background: none;
  border: none;
  font-size: 24px;
  padding: 6px 0;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-grid button:active { background: var(--tg-lista-hover); }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sticker-grid button {
  background: var(--tg-lista-hover);
  border: none;
  border-radius: 12px;
  font-size: 34px;
  padding: 10px 0;
  cursor: pointer;
}
.sticker-grid button:active { background: #ecdbdb; }

.burbuja-sticker {
  align-self: flex-start;
  background: none !important;
  padding: 0 !important;
  font-size: 64px;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.burbuja-sticker.burbuja-propia { align-self: flex-end; }
.burbuja-sticker .burbuja-hora {
  color: var(--tg-texto-sec);
  margin-top: -4px;
}

/* ============ MODAL AGREGAR CONTACTO / MI CÓDIGO ============ */
.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  animation: fondoAparece 0.15s ease;
}

.modal-contenido {
  width: 86%; max-width: 320px;
  background: #fff;
  border-radius: 16px;
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 10px;
  animation: modalAparece 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-encabezado {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.modal-encabezado h3 { margin: 0; font-size: 16px; text-align: left; color: var(--tg-texto); }

.modal-cerrar-x {
  font-size: 15px;
  color: #a5a5aa;
  padding: 2px 6px;
}

.modal-descripcion {
  font-size: 13px;
  color: var(--tg-texto-sec);
  text-align: center;
  margin: 0 0 6px;
  line-height: 1.4;
}

.codigo-display {
  background: var(--tg-fondo);
  border: 1.5px dashed #f0c3cd;
  border-radius: 12px;
  padding: 18px 10px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  color: var(--tg-acento);
  font-family: -apple-system, 'Courier New', monospace;
  margin-bottom: 4px;
}

.modal .btn-auth, .estado-vacio .btn-auth {
  background: linear-gradient(135deg, var(--tg-acento-2), var(--tg-acento));
}

.modal-botones { display: flex; gap: 10px; margin-top: 6px; }
.modal-botones .btn-auth { flex: 1; }

.modal-confirmacion { text-align: center; }
.modal-confirmacion-titulo { margin: 4px 0 6px; font-size: 17px; color: var(--tg-texto); }
.btn-auth-peligro { background: #d92c4b !important; }

.toast-aviso {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 95;
  background: #2b2b2b;
  color: #fff;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  animation: hojaSube 0.2s ease;
}
@media (prefers-reduced-motion: reduce) { .toast-aviso { animation: none; } }

@keyframes fondoAparece {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalAparece {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .modal, .modal-contenido { animation: none; }
}

/* ============ HOJA DE ACCIONES (vaciar / eliminar contacto) ============ */
.hoja-fondo {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fondoAparece 0.15s ease;
}

.hoja-contenido {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  animation: hojaSube 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.hoja-manija {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #e0dfe1;
  margin: 4px auto 14px;
}

.hoja-titulo {
  text-align: center;
  font-size: 13px;
  color: var(--tg-texto-sec);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hoja-opcion {
  background: none;
  border: none;
  color: var(--tg-texto);
  font-size: 16px;
  text-align: left;
  padding: 14px 8px;
  border-top: 1px solid var(--tg-borde);
  cursor: pointer;
}
.hoja-opcion:active { background: var(--tg-lista-hover); }

.hoja-opcion-peligro { color: #d92c4b; }

.hoja-opcion-valor {
  float: right;
  color: var(--tg-texto-sec);
  font-size: 14px;
}

.hoja-opcion-tiempo { text-align: left; }

.hoja-opcion-cancelar {
  text-align: center;
  font-weight: 600;
  color: var(--tg-acento);
  margin-top: 6px;
  border-top: none;
}

.fila-emojis-reaccion {
  display: flex;
  justify-content: space-around;
  padding: 6px 4px 16px;
}
.fila-emojis-reaccion button {
  background: none;
  border: none;
  font-size: 30px;
  padding: 6px;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.1s ease, background 0.1s ease;
}
.fila-emojis-reaccion button:active { transform: scale(1.25); background: var(--tg-lista-hover); }

.reacciones-badge {
  position: absolute;
  bottom: -10px;
  right: 8px;
  background: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 13px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  line-height: 1.4;
}
.burbuja-otro .reacciones-badge { right: auto; left: 8px; }

@keyframes hojaSube {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .hoja-fondo, .hoja-contenido { animation: none; }
}

/* ============ VISTA PREVIA DE FOTO ANTES DE ENVIAR ============ */
.modal-preview-foto-contenido { max-width: 340px; }
.preview-foto-img {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
  margin: 4px 0 10px;
}
.preview-foto-fila {
  display: flex;
  align-items: center;
  gap: 10px;
}
.preview-foto-fila input {
  flex: 1;
  min-width: 0;
  background: var(--tg-lista-hover);
  border: none;
  border-radius: 20px;
  padding: 11px 16px;
  color: var(--tg-texto);
  font-size: 15px;
  outline: none;
}

/* ============ VISOR DE FOTO A PANTALLA COMPLETA ============ */
.visor-imagen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}
.visor-imagen img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
}
.visor-imagen-cerrar {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ============ SORPRESA ESPECIAL ============ */
.sorpresa-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #080512;
}
.sorpresa-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.sorpresa-volver {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  z-index: 201;
  background: rgba(255,255,255,0.14);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
}