/* Editor de historias (public/story-editor.js) + overlays en el visor. */

/* ---------- overlays (editor y visor) ---------- */
.so-item { position: absolute; white-space: pre-wrap; line-height: 1.15; user-select: none; -webkit-user-select: none; touch-action: none; }
.so-text { display: inline-block; max-width: 86vw; padding: 0.12em 0.3em; border-radius: 0.28em; overflow-wrap: anywhere; }
.so-bg-solid { padding: 0.18em 0.45em; }
.so-bg-soft { background: rgba(0, 0, 0, 0.45); padding: 0.18em 0.45em; }
.so-sticker { line-height: 1; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3)); }
.so-mention-pill { display: inline-block; background: #fff; color: #7c3aed; font-weight: 800; font-family: "Plus Jakarta Sans", sans-serif; padding: 0.3em 0.7em; border-radius: 0.5em; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); white-space: nowrap; }

.so-font-clasica { font-family: "Plus Jakarta Sans", sans-serif; font-weight: 800; }
.so-font-moderna { font-family: "Poppins", sans-serif; font-weight: 700; }
.so-font-fuerte { font-family: "Anton", sans-serif; text-transform: uppercase; letter-spacing: 0.01em; }
.so-font-titular { font-family: "Bebas Neue", sans-serif; text-transform: uppercase; letter-spacing: 0.04em; }
.so-font-elegante { font-family: "Abril Fatface", serif; }
.so-font-script { font-family: "Pacifico", cursive; }
.so-font-divertida { font-family: "Titan One", sans-serif; }
.so-font-manuscrita { font-family: "Shadows Into Light", cursive; font-weight: 700; }
.so-font-neon { font-family: "Righteous", sans-serif; }
.so-font-retro { font-family: "Press Start 2P", monospace; font-size: 0.6em; line-height: 1.5; }
.so-text:not(.so-bg-solid):not(.so-bg-soft) { text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); }

/* visor */
.so-frame { position: relative; height: 100%; max-width: 100%; aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; }
.so-frame > img, .so-frame > video { width: 100%; height: 100%; object-fit: cover; max-width: none; max-height: none; }
.so-layer { position: absolute; inset: 0; pointer-events: none; }
.so-layer .so-mention { pointer-events: auto; z-index: 7; cursor: pointer; }
.so-music { position: absolute; left: 12px; bottom: 76px; z-index: 6; max-width: 70%; background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* ---------- editor ---------- */
body.se-open { overflow: hidden; }
.se-screen { position: fixed; inset: 0; z-index: 9000; background: #000; color: #fff; display: flex; align-items: center; justify-content: center; }
.se-screen.hidden { display: none; }
.se-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top, 0px) + 6px) 0 calc(env(safe-area-inset-bottom, 0px) + 74px); box-sizing: border-box; }
.se-frame { position: relative; height: 100%; max-width: 100%; aspect-ratio: 9 / 16; overflow: hidden; border-radius: 16px; background: #111; touch-action: none; }
.se-bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) brightness(0.8); }
.se-media { position: absolute; inset: 0; overflow: hidden; }
.se-media img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.se-media video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.se-layer { position: absolute; inset: 0; }
.se-layer .so-item { cursor: grab; }
.se-frame.se-cropping { outline: 2px dashed rgba(255, 255, 255, 0.8); outline-offset: -2px; }
.se-frame.se-cropping .se-layer { pointer-events: none; opacity: 0.35; }

.se-top { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); left: 14px; z-index: 3; }
.se-round { width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 18px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.se-tools { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); right: 12px; z-index: 3; display: flex; flex-direction: column; gap: 10px; }
.se-tool { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: #fff; cursor: pointer; padding: 0; }
.se-tool span { width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, 0.45); display: inline-flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 900; font-family: "Plus Jakarta Sans", sans-serif; }
.se-tool small { font-size: 10.5px; font-weight: 700; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
.se-trash { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); transform: translateX(-50%); z-index: 4; width: 58px; height: 58px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); border: 2px solid rgba(255, 255, 255, 0.7); display: flex; align-items: center; justify-content: center; font-size: 24px; transition: transform 0.15s, background 0.15s; pointer-events: none; }
.se-trash.over { transform: translateX(-50%) scale(1.25); background: #ef4444; }
.se-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 14px); }
.se-music-chip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: none; border-radius: 999px; background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; text-align: left; }
.se-music-chip.hidden { display: none; }
.se-music-chip #seMusicName { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.se-music-x { width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; flex: none; }
.se-publish { margin-left: auto; border: none; border-radius: 999px; padding: 13px 20px; background: #fff; color: #141a33; font-weight: 800; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 10px 22px -10px rgba(0, 0, 0, 0.6); }
.se-publish:disabled { opacity: 0.7; }
.se-publish-dot { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(#7c6cf0, #ec4899, #f59e0b, #7c6cf0); display: inline-block; }
.se-done { border: none; border-radius: 999px; padding: 10px 18px; background: #fff; color: #141a33; font-weight: 800; font-size: 14px; cursor: pointer; }
.se-note { font-size: 12.5px; color: rgba(255, 255, 255, 0.75); margin: 0; }

.se-crop { position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 78px); z-index: 5; background: rgba(20, 20, 30, 0.88); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.se-crop.hidden { display: none; }
.se-seg { display: flex; gap: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 12px; padding: 4px; }
.se-seg button { flex: 1; border: none; background: transparent; color: #fff; font-weight: 700; font-size: 13px; padding: 9px 6px; border-radius: 9px; cursor: pointer; }
.se-seg button.active { background: #fff; color: #141a33; }
.se-zoom { display: flex; align-items: center; gap: 10px; }
.se-zoom.hidden { display: none; }
.se-zoom input { flex: 1; accent-color: #fff; }

.se-text-editor { position: absolute; inset: 0; z-index: 6; background: rgba(0, 0, 0, 0.55); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top, 0px) + 70px) 12px calc(env(safe-area-inset-bottom, 0px) + 14px); box-sizing: border-box; }
.se-text-editor.hidden { display: none; }
.se-text-top { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); left: 14px; right: 14px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.se-text-top .se-done { margin-left: auto; }
.se-text-input { width: 88%; max-height: 40vh; border: none; outline: none; resize: none; background: transparent; font-size: 30px; line-height: 1.2; text-align: center; border-radius: 10px; padding: 8px 12px; }
.se-text-input::placeholder { color: rgba(255, 255, 255, 0.6); }
.se-fonts { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 64px); display: flex; gap: 8px; overflow-x: auto; padding: 0 12px; scrollbar-width: none; }
.se-fonts::-webkit-scrollbar { display: none; }
.se-font { flex: none; border: 1.5px solid rgba(255, 255, 255, 0.5); background: rgba(0, 0, 0, 0.35); color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 15px; cursor: pointer; }
.se-font.active { background: #fff; color: #141a33; border-color: #fff; }
.se-font.so-font-retro { font-size: 9px; }
.se-colors { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); display: flex; gap: 10px; justify-content: center; padding: 0 12px; flex-wrap: wrap; }
.se-color { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); cursor: pointer; padding: 0; }
.se-color.active { transform: scale(1.25); box-shadow: 0 0 0 2px #000, 0 0 0 4px #fff; }

.se-panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; max-height: 62vh; overflow-y: auto; background: #1b1b24; border-radius: 22px 22px 0 0; padding: 14px 14px calc(env(safe-area-inset-bottom, 0px) + 16px); box-sizing: border-box; }
.se-panel.hidden { display: none; }
.se-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.se-panel-head strong { font-size: 17px; }
.se-sticker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.se-sticker-grid button { font-size: 34px; background: none; border: none; cursor: pointer; padding: 6px 0; border-radius: 12px; }
.se-sticker-grid button:active { background: rgba(255, 255, 255, 0.1); }
.se-search { width: 100%; box-sizing: border-box; border: none; border-radius: 999px; padding: 12px 16px; font-size: 15px; background: rgba(255, 255, 255, 0.12); color: #fff; outline: none; margin-bottom: 10px; }
.se-mention-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.se-mention-results button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: none; background: none; color: #fff; font-size: 15px; font-weight: 600; border-radius: 12px; cursor: pointer; text-align: left; }
.se-mention-results button:active { background: rgba(255, 255, 255, 0.08); }

/* Colores en UNA fila que se desliza (en celulares angostos se partía en dos
   y tapaba los botones de letra). */
.se-colors { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 6px 14px; scrollbar-width: none; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
.se-colors::-webkit-scrollbar { display: none; }
.se-color { flex: none; }
.se-fonts { bottom: calc(env(safe-area-inset-bottom, 0px) + 62px); }

/* Nombre de la canción arriba, debajo del nombre de quien publicó (como Instagram). */
.so-music { top: 64px; bottom: auto; left: 14px; }

/* Mientras se escribe un texto se esconden los botones del editor. */
.se-screen.se-typing .se-tools,
.se-screen.se-typing .se-bottom,
.se-screen.se-typing .se-top { display: none; }
.se-text-editor { background: rgba(0, 0, 0, 0.62); }

/* Pedido explícito: las historias se ven GRANDES, a pantalla completa (como
   Facebook/Instagram), no en una cajita. En computador queda centrada con la
   forma del celular. */
#storyViewerModal { padding: 0; background: #000; }
#storyViewerModal .mp-story-viewer { width: 100vw; max-width: none; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
#storyViewerModal .mp-story-viewer-progress { top: calc(env(safe-area-inset-top, 0px) + 8px); }
#storyViewerModal .mp-story-viewer-head { top: calc(env(safe-area-inset-top, 0px) + 18px); }
#storyViewerModal .mp-story-viewer-reply,
#storyViewerModal .mp-story-viewer-own-bar { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
#storyViewerModal .mp-story-viewer-media img,
#storyViewerModal .mp-story-viewer-media video { width: 100%; height: 100%; object-fit: contain; }
/* Historia hecha con el editor: cuadro 9:16 exacto (los textos quedan donde se pusieron). */
#storyViewerModal .so-frame { height: auto; width: min(100%, calc(100dvh * 9 / 16)); aspect-ratio: 9 / 16; }
@media (min-width: 700px) {
  #storyViewerModal { background: rgba(0, 0, 0, 0.92); }
  #storyViewerModal .mp-story-viewer { width: min(100vw, calc(96vh * 9 / 16)); height: 96vh; border-radius: 16px; }
}

/* Botón de sonido de los videos de historias */
.mp-story-sound-btn { margin-left: auto; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.4); color: #fff; font-size: 17px; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.mp-story-sound-btn.hidden { display: none; }
.mp-story-sound-btn.muted { animation: mp-sound-pulse 1.4s ease-in-out 3; }
.mp-story-sound-btn:not(.hidden) + .mp-modal-close { margin-left: 8px; }
@keyframes mp-sound-pulse { 50% { transform: scale(1.15); background: rgba(124, 108, 240, 0.7); } }

/* La foto/video de la historia mantiene el tamaño del momento en que se
   abrió: el teclado (al responder) ya no la angosta, solo la tapa abajo. */
#storyViewerModal .mp-story-viewer-media { position: absolute; left: 0; right: 0; top: 0; height: var(--sv-h0, 100dvh); flex: none; }
#storyViewerModal .so-frame { width: min(100%, calc(var(--sv-h0, 100dvh) * 9 / 16)); }

/* ======================================================================
   Pedido explícito (con capturas): subir historia "prácticamente como
   WhatsApp" -- iconos redondos arriba (música, recortar, sticker, texto,
   lápiz), "Añade un comentario..." abajo y botón verde de enviar -- y el
   visor como lo ven los demás (volver + foto + nombre + hora + menú arriba;
   comentario, "Responder" con emojis, compartir y corazón abajo).
   ====================================================================== */

/* ---------- dibujo (editor y visor) ---------- */
.so-draw { position: absolute; inset: 0; pointer-events: none; }
.so-draw svg { width: 100%; height: 100%; display: block; }

/* ---------- editor ---------- */
#storyEditor .se-stage { padding: env(safe-area-inset-top, 0px) 0 calc(env(safe-area-inset-bottom, 0px) + 78px); }
#storyEditor .se-frame { border-radius: 0; }
#storyEditor .se-top { left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 12px); padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#storyEditor .se-tools { position: static; flex-direction: row; gap: 9px; }
.se-ico { width: 44px; height: 44px; flex: none; border-radius: 50%; border: none; background: rgba(38, 38, 40, 0.62); color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.se-ico.hidden { display: none; }
.se-ico:disabled { opacity: 0.4; }
.se-ico:active { transform: scale(0.94); }
.se-ico-text { font: 700 18px/1 "Plus Jakarta Sans", sans-serif; }
#storyEditor .se-bottom { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
#storyEditor .se-music-chip { flex: none; align-self: flex-start; max-width: calc(100% - 24px); margin: 0 12px 8px; background: rgba(28, 28, 30, 0.8); }
.se-caption { display: flex; align-items: center; gap: 4px; margin: 0 12px 10px; padding: 5px 8px; border-radius: 28px; background: rgba(28, 28, 30, 0.92); border: 1px solid rgba(255, 255, 255, 0.08); }
.se-caption input { flex: 1; min-width: 0; border: none; outline: none; background: none; color: #fff; font-size: 16px; padding: 9px 4px; font-family: inherit; }
.se-caption input::placeholder { color: rgba(255, 255, 255, 0.78); }
.se-caption-btn { width: 40px; height: 40px; flex: none; border: none; border-radius: 50%; background: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.se-caption-btn:active { background: rgba(255, 255, 255, 0.1); }
.se-send-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #000; padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 12px); }
.se-audience { display: inline-flex; align-items: center; gap: 8px; min-width: 0; border: none; border-radius: 12px; background: #242427; color: #fff; padding: 10px 14px; font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; }
.se-send { position: relative; width: 56px; height: 56px; flex: none; border-radius: 50%; border: none; background: linear-gradient(135deg, #22b8ff 0%, #7c3aed 100%); color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0 0 0 3px; cursor: pointer; box-shadow: 0 8px 22px -8px rgba(124, 58, 237, 0.75); }
.se-send:active { transform: scale(0.94); }
.se-send.is-sending svg { opacity: 0; }
.se-send.is-sending::after { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; animation: se-spin 0.8s linear infinite; }
@keyframes se-spin { to { transform: rotate(360deg); } }
#storyEditor .se-trash { bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); }
#storyEditor .se-crop { bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); }

/* Lápiz */
.se-screen.se-drawing .se-top,
.se-screen.se-drawing .se-bottom { display: none; }
.se-draw-bar { position: absolute; z-index: 5; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 12px; right: 12px; display: flex; align-items: center; justify-content: space-between; }
.se-draw-bar.hidden, .se-draw-colors.hidden { display: none; }
.se-draw-colors { position: absolute; z-index: 5; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); display: flex; gap: 10px; justify-content: center; overflow-x: auto; padding: 6px 14px; scrollbar-width: none; }
.se-draw-colors::-webkit-scrollbar { display: none; }
.se-screen.se-drawing .se-frame { cursor: crosshair; }

/* ---------- visor ---------- */
#storyViewerModal .mp-story-viewer-progress { left: 10px; right: 10px; }
#storyViewerModal .mp-story-viewer-seg { height: 2.5px; background: rgba(255, 255, 255, 0.35); }
#storyViewerModal .mp-story-viewer-head { left: 2px; right: 8px; gap: 4px; z-index: 6; }
.sv-back, .sv-more { width: 42px; height: 42px; flex: none; border: none; background: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55)); }
.sv-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: none; background: none; color: #fff; padding: 0; text-align: left; cursor: pointer; font: inherit; }
#storyViewerAvatar { flex: none; display: inline-flex; }
#storyViewerAvatar > * { width: 42px !important; height: 42px !important; border-radius: 50%; object-fit: cover; font-size: 1.2rem; }
.sv-who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.sv-who-text strong { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.sv-who-text small { font-size: 13px; color: rgba(255, 255, 255, 0.88); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
#storyViewerModal .mp-story-sound-btn { margin-left: 0; flex: none; }
.sv-menu { position: absolute; top: 48px; right: 0; z-index: 8; min-width: 230px; display: flex; flex-direction: column; padding: 6px; border-radius: 14px; background: rgba(30, 30, 34, 0.97); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); }
.sv-menu.hidden { display: none; }
.sv-menu button { border: none; background: none; color: #fff; text-align: left; padding: 12px 14px; font-size: 15px; font-family: inherit; border-radius: 10px; cursor: pointer; }
.sv-menu button:active { background: rgba(255, 255, 255, 0.08); }
.so-music { top: 76px; }

#storyViewerModal .sv-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: 10px; padding: 48px 12px calc(env(safe-area-inset-bottom, 0px) + 12px); background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0)); pointer-events: none; }
#storyViewerModal .sv-bottom > * { pointer-events: auto; }
.sv-caption { margin: 0; padding: 0 6px 12px; color: #fff; text-align: center; font-size: 17px; line-height: 1.35; border-bottom: 1px solid rgba(255, 255, 255, 0.35); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30vh; overflow-y: auto; }
.sv-caption.hidden { display: none; }
#storyViewerModal .mp-story-viewer-reply,
#storyViewerModal .mp-story-viewer-own-bar { position: static; padding: 0; background: none; }
#storyViewerModal .mp-story-viewer-own-bar:not(.hidden) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#storyViewerModal .mp-story-viewer-viewers-list { flex-basis: 100%; }
#storyViewerModal #storyViewerDeleteBtn { margin-left: 0; }
.sv-reply-row { display: flex; align-items: center; gap: 10px; }
.sv-reply-pill { flex: 1; min-width: 0; height: 50px; display: flex; align-items: center; gap: 2px; margin: 0; padding: 0 6px 0 18px; border-radius: 26px; background: rgba(58, 58, 62, 0.55); border: 1px solid rgba(255, 255, 255, 0.2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-sizing: border-box; }
.sv-reply-pill input { flex: 1; min-width: 0; height: 100%; border: none; outline: none; background: none; color: #fff; font-size: 17px; font-family: inherit; padding: 0; }
.sv-reply-pill input::placeholder { color: rgba(255, 255, 255, 0.92); }
#storyViewerModal .sv-quick { display: flex; gap: 0; flex: none; }
#storyViewerModal .sv-quick .mp-story-quick-emoji { width: 36px; height: 36px; border: none; background: none; font-size: 24px; }
.sv-send { display: none; width: 38px; height: 38px; flex: none; border: none; border-radius: 50%; background: linear-gradient(135deg, #22b8ff 0%, #7c3aed 100%); color: #fff; align-items: center; justify-content: center; padding: 0 0 0 2px; cursor: pointer; }
.sv-reply-pill.typing .sv-quick { display: none; }
.sv-reply-pill.typing .sv-send { display: inline-flex; }
.sv-circle { position: relative; width: 50px; height: 50px; flex: none; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(58, 58, 62, 0.55); color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.sv-circle:disabled { opacity: 0.5; }
#storyViewerModal .sv-circle.mp-story-viewer-like { position: relative; right: auto; bottom: auto; z-index: auto; flex-direction: row; gap: 0; text-shadow: none; }
#storyViewerModal .sv-circle.mp-story-viewer-like.liked svg { fill: #ff3b5c; stroke: #ff3b5c; transform: none; }
.sv-like-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: #ff3b5c; color: #fff; font-size: 11px !important; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.sv-like-count.hidden { display: none; }
#storyViewerModal #storyReplyMessage:empty { display: none; }
#storyViewerModal #storyReplyMessage { margin-top: 6px; }

/* Estos modos le ganan a las reglas con #storyEditor / #storyViewerModal de arriba. */
#storyEditor.se-drawing .se-top, #storyEditor.se-drawing .se-bottom,
#storyEditor.se-typing .se-top, #storyEditor.se-typing .se-bottom { display: none; }
#storyViewerModal .sv-reply-pill.typing .sv-quick { display: none; }

/* ======================================================================
   Galería para subir historias (public/story-gallery.js, app de Android):
   como WhatsApp -- X y pestañas arriba, accesos Texto / Música / Archivos,
   y la cuadrícula con la cámara de primera.
   ====================================================================== */
body.sg-open { overflow: hidden; }
.sg-screen { position: fixed; inset: 0; z-index: 9500; background: #0b0b0c; color: #fff; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
.sg-screen.hidden { display: none; }
.sg-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px; background: #0b0b0c; border-radius: 0 0 0 0; }
.sg-close { width: 50px; height: 50px; flex: none; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.14); background: #1c1c1e; color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.sg-head-space { width: 50px; flex: none; }
.sg-seg { display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: #1c1c1e; border: 1px solid rgba(255, 255, 255, 0.12); }
.sg-seg button { border: none; background: none; color: #fff; font-weight: 600; font-size: 16px; line-height: 1; font-family: inherit; padding: 11px 20px; border-radius: 999px; cursor: pointer; }
.sg-seg button.active { background: #3a3a3c; }
.sg-quick { display: flex; gap: 10px; padding: 4px 14px 14px; overflow-x: auto; scrollbar-width: none; }
.sg-quick::-webkit-scrollbar { display: none; }
.sg-quick-tile { flex: 1 0 104px; min-height: 88px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 22px; background: #1c1c1e; color: #fff; font-family: inherit; font-size: 17px; cursor: pointer; }
.sg-quick-tile svg, .sg-q-aa { color: #8b7bff; }
.sg-q-aa { font: 600 24px/1 "Plus Jakarta Sans", sans-serif; }
.sg-quick-tile:active { background: #2a2a2d; }
.sg-notice { margin: 0 14px 12px; padding: 14px; border-radius: 16px; background: #1c1c1e; text-align: center; }
.sg-notice.hidden { display: none; }
.sg-notice p { margin: 0 0 10px; font-size: 15px; line-height: 1.4; color: rgba(255, 255, 255, 0.88); }
.sg-notice button { border: none; border-radius: 999px; padding: 11px 20px; margin: 4px; background: linear-gradient(135deg, #22b8ff 0%, #7c3aed 100%); color: #fff; font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer; }
.sg-notice button.sg-link { background: none; color: #8b7bff; }
.sg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.sg-cell { position: relative; aspect-ratio: 1 / 1; border: none; padding: 0; margin: 0; background: #1c1c1e; overflow: hidden; cursor: pointer; }
.sg-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sg-nothumb { display: block; width: 100%; height: 100%; background: #2a2a2d; }
.sg-dur { position: absolute; left: 6px; bottom: 5px; color: #fff; font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.sg-camera { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #0b0b0c; color: #fff; font-family: inherit; font-size: 15px; }
.sg-camera svg { width: 58px; height: 58px; padding: 12px; box-sizing: border-box; border-radius: 50%; background: #1c1c1e; }
.sg-cell.sg-loading::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45) center / 30px no-repeat; }
.sg-cell.sg-loading::before { content: ""; position: absolute; z-index: 1; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; animation: se-spin 0.8s linear infinite; }
.sg-more { display: flex; justify-content: center; padding: 18px; }
.sg-more.hidden { display: none; }
.sg-spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: se-spin 0.8s linear infinite; }

/* ======================================================================
   Quién ve la historia (Todos / Mis amigos / excepto / solo) y la lista de
   amigos con casillas; historia propia como WhatsApp ("Yo" con +, "Visto
   por N" abajo, compartir, y Borrar dentro del menú ⋯).
   ====================================================================== */
#storyEditor .se-aud { z-index: 8; }
.se-aud-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.se-aud-opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 10px; border: none; border-radius: 14px; background: none; color: #fff; text-align: left; font-family: inherit; cursor: pointer; }
.se-aud-opt:active { background: rgba(255, 255, 255, 0.06); }
.se-aud-ic { width: 40px; height: 40px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, 0.08); display: inline-flex; align-items: center; justify-content: center; font-size: 19px; }
.se-aud-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.se-aud-txt b { font-size: 16px; font-weight: 700; }
.se-aud-txt small { font-size: 13px; color: rgba(255, 255, 255, 0.65); }
.se-aud-radio { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.45); box-sizing: border-box; }
.se-aud-opt.active .se-aud-radio { border-color: #8b5cf6; background: radial-gradient(circle, #8b5cf6 0 45%, transparent 50%); }

.sp-screen { position: fixed; inset: 0; z-index: 9700; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.sp-screen.hidden { display: none; }
.sp-sheet { width: 100%; max-width: 560px; height: min(86vh, 720px); height: min(86dvh, 720px); display: flex; flex-direction: column; background: #151517; color: #fff; border-radius: 22px 22px 0 0; padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 14px); box-sizing: border-box; }
.sp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sp-head strong { font-size: 18px; }
.sp-x { width: 40px; height: 40px; flex: none; border: none; border-radius: 50%; background: rgba(255, 255, 255, 0.08); color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.sp-search { width: 100%; box-sizing: border-box; border: none; outline: none; border-radius: 999px; padding: 12px 16px; font-size: 16px; font-family: inherit; background: rgba(255, 255, 255, 0.1); color: #fff; margin-bottom: 8px; }
.sp-list { flex: 1; min-height: 0; overflow-y: auto; }
.sp-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 6px; border: none; border-radius: 12px; background: none; color: #fff; font-family: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.sp-row:active { background: rgba(255, 255, 255, 0.06); }
.sp-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-check { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4); box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; }
.sp-row.on .sp-check { background: linear-gradient(135deg, #22b8ff 0%, #7c3aed 100%); border-color: #7c3aed; }
.sp-row.on .sp-check::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.sp-danger .sp-row.on .sp-check { background: #ef4444; border-color: #ef4444; }
.sp-danger .sp-row.on .sp-check::after { border-color: #fff; }
.sp-empty { margin: 24px 8px; text-align: center; color: rgba(255, 255, 255, 0.7); font-size: 15px; line-height: 1.4; }
.sp-done { margin-top: 10px; border: none; border-radius: 999px; padding: 14px; background: linear-gradient(135deg, #22b8ff 0%, #7c3aed 100%); color: #fff; font-weight: 800; font-size: 16px; font-family: inherit; cursor: pointer; }
.sp-danger .sp-done { background: #ef4444; color: #fff; }

/* Historia propia */
#storyViewerAvatar { position: relative; }
#storyViewerAvatar > .sv-add-badge { position: absolute; right: -3px; bottom: -3px; width: 20px !important; height: 20px !important; border-radius: 50%; background: linear-gradient(135deg, #22b8ff 0%, #7c3aed 100%); color: #fff; border: 2px solid #000; box-sizing: content-box; display: flex; align-items: center; justify-content: center; font: 800 16px/1 "Plus Jakarta Sans", sans-serif; cursor: pointer; }
#storyViewerModal .mp-story-viewer-own-bar:not(.hidden) { flex-wrap: wrap; justify-content: space-between; }
#storyViewerModal #storyViewerOwnLikes,
#storyViewerModal #storyViewerDeleteBtn { display: none; }
#storyViewerModal #storyViewerViewsBtn { height: 50px; padding: 0 20px; gap: 10px; border-radius: 26px; background: rgba(58, 58, 62, 0.6); border: 1px solid rgba(255, 255, 255, 0.18); font-size: 17px; font-weight: 600; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
#storyViewerModal .sv-own-share { margin-left: auto; }
#storyViewerModal .mp-story-viewer-viewers-list { order: -1; }
.sv-menu button.sv-danger { color: #ff6b7a; }
.sv-menu-note { margin: 4px 6px 2px; padding: 10px 8px 4px; border-top: 1px solid rgba(255, 255, 255, 0.1); font-size: 13px; color: rgba(255, 255, 255, 0.7); }

/* Al escribir una respuesta, la barra ocupa todo el ancho: se esconden el
   corazón y compartir (como en el chat). Clase puesta desde client.js. */
#storyViewerModal .sv-reply-row.sv-typing .sv-circle { display: none; }

/* El + de la historia propia: zona de toque más grande que el círculo. */
#storyViewerAvatar > .sv-add-badge::before { content: ""; position: absolute; inset: -12px; }

/* Dedo presionado: historia en pausa y sin botones encima (como Instagram). */
#storyViewerModal .mp-story-viewer-head, #storyViewerModal .sv-bottom, #storyViewerModal .mp-story-viewer-progress, #storyViewerModal .so-music { transition: opacity 0.18s ease; }
#storyViewerModal.sv-holding .mp-story-viewer-head, #storyViewerModal.sv-holding .sv-bottom, #storyViewerModal.sv-holding .mp-story-viewer-progress, #storyViewerModal.sv-holding .so-music { opacity: 0; }
#storyViewerModal .mp-story-viewer-zone, #storyViewerModal .mp-story-viewer-media { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
