/* ai-chat.css -- Estilos del asistente IA de LUN (modal, pills, TTS).
 * Incluido en Mobile Y Desktop. ASCII puro, CRLF. */

/* =============================================================================
 * LUN.COM - AI Chat Modal
 * ============================================================================= */

/* --- Modal (fixed fullscreen overlay) --- */
#ai-chat-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 99999;
	opacity: 0;
	visibility: hidden;
	overflow: hidden;
	-webkit-transition: opacity 0.25s ease, visibility 0s linear 0.25s;
	transition: opacity 0.25s ease, visibility 0s linear 0.25s;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
	overscroll-behavior: none;
}

#ai-chat-modal.show {
	opacity: 1;
	visibility: visible;
	-webkit-transition: opacity 0.25s ease, visibility 0s linear 0s;
	transition: opacity 0.25s ease, visibility 0s linear 0s;
}

/* --- Backdrop --- */
#ai-chat-modal .chat-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(10, 12, 40, 0.55);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	-webkit-tap-highlight-color: transparent;
}

/* --- Sheet (bottom sheet, block layout, calc height) --- */
#ai-chat-modal .chat-sheet {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: calc(100% - 10px);
	background: #f4f6fb;
	border-radius: 18px 18px 0 0;
	box-shadow: 0 -6px 28px rgba(0, 0, 70, 0.22);
	/* Flex column: header / body (flexible) / footer (auto). */
	display: -webkit-box;
	display: -webkit-flex;
	display: flex;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	-webkit-flex-direction: column;
	flex-direction: column;
	overflow: hidden;
	-webkit-transform: translate3d(0, 100%, 0);
	transform: translate3d(0, 100%, 0);
	-webkit-transition: -webkit-transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
	transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
	will-change: transform;
}

#ai-chat-modal.show .chat-sheet {
	-webkit-transform: translate3d(0, 0, 0);
	transform: translate3d(0, 0, 0);
}

/* Grabber (swipe-down para cerrar). Flota sobre el header (absolute);
   touch-action:none para que el gesto no cuente como scroll. */
#ai-chat-modal .chat-grabber {
	position: absolute;
	top: 0;
	left: 50%;
	-webkit-transform: translateX(-50%);
	transform: translateX(-50%);
	width: 100%;
	height: 20px;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	background: transparent;
	z-index: 20;
	cursor: grab;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: none;
}

#ai-chat-modal .chat-grabber:active { cursor: grabbing; }

#ai-chat-modal .chat-grabber-bar {
	width: 50px;
	height: 4px;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.5);
	transition: background 0.15s ease;
}

#ai-chat-modal .chat-grabber:active .chat-grabber-bar {
	background: rgba(255, 255, 255, 0.8);
}

/* --- Header (flex item, gradient, no logo) --- */
#ai-chat-modal .chat-header {
	-webkit-box-flex: 0;
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	height: 64px;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	display: -webkit-flex;
	display: flex;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	-webkit-align-items: center;
	align-items: center;
	padding: 0 14px 0 16px;
	background: -webkit-linear-gradient(left, #000099 0%, #1e3ad6 60%, #3a64ff 100%);
	background: linear-gradient(90deg, #000099 0%, #1e3ad6 60%, #3a64ff 100%);
	border-radius: 18px 18px 0 0;
	z-index: 10;
}

#ai-chat-modal .chat-header-main {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	min-width: 0;
}

#ai-chat-modal .chat-header-avatar {
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	margin-right: 11px;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
}

#ai-chat-modal .chat-header-avatar svg {
	/* Logo LUN multicolor: NO forzar fill (pisaria los colores del path). */
	width: 38px;
	height: 38px;
	border-radius: 8px;
}

#ai-chat-modal .chat-header-text {
	min-width: 0;
}

#ai-chat-modal .chat-header h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	color: #fff;
	line-height: 1.2;
	letter-spacing: 0.2px;
}

/* Oculto: subtitulo del header. Reactivable volviendo display a block. */
#ai-chat-modal .chat-header-sub {
	display: none;
	font-size: 11.5px;
	font-weight: 500;
	color: rgba(255, 255, 255, 0.78);
	margin-top: 1px;
}

#ai-chat-modal .chat-close {
	background: rgba(255, 255, 255, 0.12);
	border: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: #fff;
	padding: 0;
	width: 36px;
	height: 36px;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	border-radius: 50%;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
}

#ai-chat-modal .chat-close:active {
	background: rgba(255, 255, 255, 0.28);
}

/* --- Body (absolute, scrollable, between header+footer) --- */
#ai-chat-modal .chat-body {
	-webkit-box-flex: 1;
	-webkit-flex: 1 1 auto;
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 14px 14px 18px 14px;
}

/* --- Footer (flex item, altura automatica: pills + input) --- */
#ai-chat-modal .chat-footer {
	-webkit-box-flex: 0;
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	padding: 10px 14px 12px 14px;
	border-top: 1px solid #e3e6f0;
	background: #fff;
	z-index: 10;
}

/* --- Input row (margin, not gap - iOS 12) --- */
.ai-chat-input-row {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	background: #f1f3fa;
	border: 1.5px solid #e0e3f0;
	border-radius: 26px;
	padding: 4px 4px 4px 6px;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	-webkit-transition: border-color 0.15s ease, background 0.15s ease;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.ai-chat-input-row.focused,
.ai-chat-input-row:focus-within {
	border-color: #3a64ff;
	background: #fff;
}

.ai-chat-input-row input {
	-webkit-flex: 1;
	flex: 1;
	min-width: 0;
	margin: 0 6px 0 8px;
	padding: 9px 0;
	border: none;
	background: transparent;
	font-size: 16px;
	outline: none;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	font-family: inherit;
	color: #1f2340;
	-webkit-appearance: none;
}

.ai-chat-input-row input::-webkit-input-placeholder { color: #9aa0bd; }
.ai-chat-input-row input:-ms-input-placeholder { color: #9aa0bd; }
.ai-chat-input-row input::placeholder { color: #9aa0bd; }

.ai-chat-input-row input:disabled {
	color: #aab;
}

.ai-chat-send-btn {
	width: 42px;
	min-width: 42px;
	height: 42px;
	border: none;
	border-radius: 50%;
	background: -webkit-linear-gradient(top, #1e3ad6, #000099);
	background: linear-gradient(180deg, #1e3ad6, #000099);
	color: #fff;
	cursor: pointer;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	-webkit-transition: -webkit-transform 0.12s ease, opacity 0.15s ease;
	transition: transform 0.12s ease, opacity 0.15s ease;
}

.ai-chat-send-btn svg {
	width: 20px;
	height: 20px;
	fill: #fff;
	margin-left: 1px;
}

.ai-chat-send-btn:active {
	-webkit-transform: scale(0.92);
	transform: scale(0.92);
}

.ai-chat-send-btn.disabled {
	opacity: 0.4;
	pointer-events: none;
}

/* Preview: imagen (slot izquierdo) + columna de acciones al lado. */
.chat-preview {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: flex-start;
	align-items: flex-start;
	-webkit-justify-content: center;
	justify-content: center;
	padding: 2px 0 12px 0;
}

.chat-preview-imgwrap {
	display: -webkit-inline-flex;
	display: inline-flex;
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
}

.chat-preview img {
	display: block;
	max-height: 120px;
	width: auto;
	border-radius: 10px;
	border: 1px solid #e0e3f0;
	box-shadow: 0 2px 10px rgba(0, 0, 70, 0.10);
	-webkit-transition: max-height 0.3s ease, opacity 0.3s ease;
	transition: max-height 0.3s ease, opacity 0.3s ease;
}

.chat-preview.collapsed img {
	max-height: 72px;
	opacity: 0.7;
}

/* Columna de acciones al lado de la imagen. */
.chat-preview-actions {
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: flex-start;
	justify-content: flex-start;
	margin-left: 10px;
	padding-top: 2px;
}

.chat-preview-share {
	width: 34px;
	height: 34px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 1px 5px rgba(0, 0, 60, 0.25);
	cursor: pointer;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	-webkit-tap-highlight-color: transparent;
}

.chat-preview-share:active {
	background: #fff;
	-webkit-transform: scale(0.9);
	transform: scale(0.9);
}

.chat-preview-share svg {
	width: 18px;
	height: 18px;
	fill: #000099;
}

/* Engranaje: abre el modal de Configuracion. Mismo estilo que el share. */
.chat-preview-settings {
	margin-top: 6px;
	width: 34px;
	height: 34px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 1px 5px rgba(0, 0, 60, 0.25);
	cursor: pointer;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	-webkit-tap-highlight-color: transparent;
}

.chat-preview-settings:active {
	background: #fff;
	-webkit-transform: scale(0.9);
	transform: scale(0.9);
}

.chat-preview-settings svg {
	width: 18px;
	height: 18px;
	fill: #000099;
}

/* Modal de Configuracion: overlay + sheet centrada (no <dialog>: iOS viejo). */
#ai-chat-settings {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 2147483600;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	opacity: 0;
	-webkit-transition: opacity 0.2s ease;
	transition: opacity 0.2s ease;
	/* Vive fuera de #ai-chat-modal: fijar la familia del sitio. */
	font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}

#ai-chat-settings.visible {
	opacity: 1;
}

.chat-settings-overlay {
	position: absolute;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 30, 0.55);
}

.chat-settings-sheet {
	position: relative;
	width: 86%;
	max-width: 380px;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 8px 40px rgba(0, 0, 60, 0.35);
	overflow: hidden;
	-webkit-transform: translateY(12px);
	transform: translateY(12px);
	-webkit-transition: -webkit-transform 0.2s ease;
	transition: transform 0.2s ease;
}

#ai-chat-settings.visible .chat-settings-sheet {
	-webkit-transform: translateY(0);
	transform: translateY(0);
}

.chat-settings-header {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid #eceef5;
}

.chat-settings-header h3 {
	margin: 0;
	font-size: 17px;
	font-weight: 600;
	color: #1a1c2e;
}

.chat-settings-close {
	border: none;
	background: none;
	font-size: 26px;
	line-height: 1;
	color: #8a90b0;
	cursor: pointer;
	padding: 0 4px;
	-webkit-tap-highlight-color: transparent;
}

.chat-settings-body {
	padding: 6px 16px 14px 16px;
}

/* Fila de opcion: label + switch. */
.chat-settings-row {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	padding: 12px 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.chat-settings-label {
	font-size: 15px;
	color: #2a2c44;
	padding-right: 12px;
}

/* Switch tipo iOS: 'is-on' = azul + knob a la derecha. El checkbox real va oculto. */
.chat-settings-switch {
	position: relative;
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	width: 46px;
	height: 28px;
	border-radius: 14px;
	background: #cfd3e2;
	-webkit-transition: background 0.18s ease;
	transition: background 0.18s ease;
}

.chat-settings-switch.is-on {
	background: #000099;
}

.chat-settings-checkbox {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.chat-settings-knob {
	position: absolute;
	left: 3px;
	top: 3px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 30, 0.3);
	-webkit-transition: -webkit-transform 0.18s ease;
	transition: transform 0.18s ease;
}

.chat-settings-switch.is-on .chat-settings-knob {
	-webkit-transform: translateX(18px);
	transform: translateX(18px);
}

/* Boton Info (i): abre el modal de ayuda. Mismo estilo que share/engranaje. */
.chat-preview-info {
	margin-top: 6px;
	width: 34px;
	height: 34px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 1px 5px rgba(0, 0, 60, 0.25);
	cursor: pointer;
	color: #000099;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	-webkit-tap-highlight-color: transparent;
}

.chat-preview-info:active {
	background: #fff;
	-webkit-transform: scale(0.9);
	transform: scale(0.9);
}

/* Icono (i) outline: color via currentColor, por eso no se fija fill. */
.chat-preview-info svg {
	width: 19px;
	height: 19px;
}

/* Preview colapsado: no hay alto para 3 botones -> se oculta el (i). */
.chat-preview.collapsed .chat-preview-info {
	display: none;
}

/* Modal de Ayuda: mismo patron que #ai-chat-settings; sheet mas alta con scroll. */
#ai-chat-help {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 2147483600;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	opacity: 0;
	-webkit-transition: opacity 0.2s ease;
	transition: opacity 0.2s ease;
	-webkit-transform: translateZ(0);
	transform: translateZ(0);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}

#ai-chat-help.visible {
	opacity: 1;
}

.chat-help-overlay {
	position: absolute;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 30, 0.55);
}

.chat-help-sheet {
	position: relative;
	width: 90%;
	max-width: 440px;
	/* dvh evita el salto de altura con la barra de URL de Android; vh es fallback. */
	max-height: 86vh;
	max-height: 86dvh;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 8px 40px rgba(0, 0, 60, 0.35);
	overflow: hidden;
	/* translate3d (no translateY ni will-change): capa GPU estable, evita un frame
	   de hueco al animar la entrada en Chrome de Android. */
	-webkit-transform: translate3d(0, 12px, 0);
	transform: translate3d(0, 12px, 0);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	-webkit-transition: -webkit-transform 0.2s ease;
	transition: transform 0.2s ease;
}

#ai-chat-help.visible .chat-help-sheet {
	-webkit-transform: translate3d(0, 0, 0);
	transform: translate3d(0, 0, 0);
}

.chat-help-header {
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: space-between;
	justify-content: space-between;
	padding: 14px 18px;
	border-bottom: 1px solid #eceef5;
}

.chat-help-header h3 {
	margin: 0;
	font-size: 17px;
	font-weight: 600;
	color: #1a1c2e;
}

.chat-help-close {
	border: none;
	background: none;
	font-size: 26px;
	line-height: 1;
	color: #8a90b0;
	cursor: pointer;
	padding: 0 4px;
	-webkit-tap-highlight-color: transparent;
}

.chat-help-body {
	-webkit-flex: 1 1 auto;
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 16px 18px 20px 18px;
}

/* Indicador "hay mas abajo": degradado + chevron al pie de la sheet. El JS pone
   .at-bottom al llegar al final para ocultarlos. */
.chat-help-sheet::after,
.chat-help-sheet::before {
	pointer-events: none;
}

/* Transicion solo con el modal visible: el estado inicial no debe animar al abrir. */
#ai-chat-help.visible .chat-help-sheet::after,
#ai-chat-help.visible .chat-help-sheet::before {
	-webkit-transition: opacity 0.2s ease;
	transition: opacity 0.2s ease;
}

.chat-help-sheet::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 56px;
	background: -webkit-linear-gradient(top, rgba(255,255,255,0), #fff 78%);
	background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 78%);
	border-radius: 0 0 14px 14px;
}

.chat-help-sheet::before {
	content: "";
	position: absolute;
	left: 50%;
	bottom: 12px;
	z-index: 1;
	width: 12px;
	height: 12px;
	margin-left: -6px;
	border-right: 2px solid #000099;
	border-bottom: 2px solid #000099;
	-webkit-transform: rotate(45deg);
	transform: rotate(45deg);
}

.chat-help-sheet.at-bottom::after,
.chat-help-sheet.at-bottom::before {
	opacity: 0;
}

.chat-help-section-title {
	font-size: 12.5px;
	font-weight: 700;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	color: #000099;
	margin: 4px 0 12px 0;
}

.chat-help-section-title + .chat-help-funcs,
.chat-help-steps + .chat-help-section-title {
	margin-top: 22px;
}

.chat-help-steps {
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
}

.chat-help-step {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: flex-start;
	align-items: flex-start;
	padding: 10px 0;
	border-bottom: 1px solid #f1f2f7;
}

.chat-help-step:last-child {
	border-bottom: none;
}

.chat-help-num {
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	margin-right: 12px;
	background: #000099;
	color: #fff;
	font-weight: 700;
	font-size: 14px;
	border-radius: 50%;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
}

.chat-help-step-title {
	font-weight: 600;
	font-size: 14px;
	color: #1a1c2e;
	margin-bottom: 3px;
}

.chat-help-step-desc {
	font-size: 13px;
	color: #4a4a4a;
	line-height: 1.5;
}

.chat-help-step-desc strong {
	color: #1a1c2e;
	font-weight: 600;
}

.chat-help-chips {
	display: -webkit-flex;
	display: flex;
	-webkit-flex-wrap: wrap;
	flex-wrap: wrap;
	margin-top: 8px;
}

/* Chips de "Explorar": mismo estilo que los pills reales (.ai-chat-pill). */
.chat-help-chip {
	display: -webkit-inline-flex;
	display: inline-flex;
	-webkit-align-items: center;
	align-items: center;
	background: #fff;
	border: 1px solid #000099;
	border-radius: 16px;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.3;
	color: #000099;
	text-decoration: underline;
	padding: 7px 10px;
	margin: 0 6px 6px 0;
	box-shadow: 0 1px 3px rgba(0, 0, 60, 0.05);
}

.chat-help-chips-nota {
	margin-top: 6px;
	font-size: 12px;
	color: #6a6f8c;
	line-height: 1.45;
}

.chat-help-funcs {
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
}

.chat-help-func {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: flex-start;
	align-items: flex-start;
	padding: 9px 0;
	border-bottom: 1px solid #f1f2f7;
}

.chat-help-func:last-child {
	border-bottom: none;
}

.chat-help-func-ico {
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	margin-right: 12px;
	margin-top: 1px;
}

.chat-help-func-ico svg {
	width: 20px;
	height: 20px;
	fill: #000099;
}

.chat-help-func-txt strong {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: #1a1c2e;
	margin-bottom: 2px;
}

.chat-help-func-txt span {
	font-size: 12px;
	color: #4a4a4a;
	line-height: 1.45;
}

/* strong de enfasis inline: sin esto heredan display:block y parten el texto. */
.chat-help-func-txt span strong {
	display: inline;
	font-size: inherit;
	margin-bottom: 0;
	color: #1a1c2e;
}

.chat-help-note {
	margin-top: 18px;
	background: #fff5f5;
	border-radius: 8px;
	padding: 12px 14px;
	font-size: 12.5px;
	color: #4a4a4a;
	line-height: 1.5;
}

.chat-help-note strong {
	color: #ed182c;
	font-weight: 600;
}

.chat-help-fulllink {
	display: block;
	margin-top: 16px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	color: #000099;
	text-decoration: none;
	padding: 10px;
	border: 1px solid #d6d9ec;
	border-radius: 10px;
}

.chat-help-fulllink:active {
	background: #f3f4fa;
}

/* Toast propio del chat (el showToast global no es visible aca). z-index sobre todo. */
#ai-chat-toast {
	position: fixed;
	left: 50%;
	bottom: 64px;
	-webkit-transform: translateX(-50%) translateY(12px);
	transform: translateX(-50%) translateY(12px);
	z-index: 2147483640;
	width: 92%;
	max-width: 460px;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	padding: 13px 22px;
	border-radius: 22px;
	background: rgba(20, 22, 40, 0.92);
	color: #fff;
	font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
	line-height: 1.3;
	text-align: center;
	box-shadow: 0 4px 18px rgba(0, 0, 30, 0.4);
	opacity: 0;
	pointer-events: none;
	-webkit-tap-highlight-color: transparent;
	-webkit-transition: opacity 0.2s ease, -webkit-transform 0.2s ease;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

#ai-chat-toast.visible {
	opacity: 1;
	-webkit-transform: translateX(-50%) translateY(0);
	transform: translateX(-50%) translateY(0);
}

/* Pills: filas sobre el input (margin, no gap: iOS 12). */
.ai-chat-pills-wrap {
	position: relative;
	margin: 0 0 8px 0;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
}

/* Manija "grabber" de los pills: chevron centrado, label en absolute a la izquierda
   (no lo descentra). touch-action:none para que el drag no cuente como scroll. */
.ai-chat-pills-handle {
	position: relative;
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	width: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	cursor: grab;
	font-size: 11px;
	font-weight: 600;
	/* Azul marino LUN: tine el texto y el chevron (fill:currentColor). */
	color: #000099;
	letter-spacing: 0.2px;
	text-transform: uppercase;
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	appearance: none;
	touch-action: none;
}

.ai-chat-pills-handle:active { cursor: grabbing; }

/* Label alineado al borde izquierdo, fuera del flujo (no desplaza el chevron). */
.ai-chat-pills-handle-label {
	position: absolute;
	left: 5px;
	white-space: nowrap;
}

/* Chevron ancho y bajo (preserveAspectRatio=none aplana el trazo). Apunta ABAJO
   abierto; rota 180 (ARRIBA) al colapsar. */
.ai-chat-pills-chevron {
	width: 50px;
	height: 15px;
	margin: 0;
	fill: currentColor;
	-webkit-transform: rotate(0deg);
	transform: rotate(0deg);
	-webkit-transition: -webkit-transform 0.15s ease;
	transition: transform 0.15s ease;
}

.ai-chat-pills-wrap.pills-collapsed .ai-chat-pills-chevron {
	-webkit-transform: rotate(180deg);
	transform: rotate(180deg);
}

/* Sin hueco cuando no hay pills (modo Aviso). */
.ai-chat-pills-wrap:empty {
	display: none;
	margin: 0;
}

.ai-chat-pills {
	display: -webkit-flex;
	display: flex;
	-webkit-flex-wrap: wrap;
	flex-wrap: wrap;
	padding: 2px 0;
	/* "Cajon" colapsable: max-height holgado para 2-3 filas; overflow hidden recorta. */
	max-height: 240px;
	overflow: hidden;
	-webkit-transition: max-height 0.12s ease, opacity 0.12s ease;
	transition: max-height 0.12s ease, opacity 0.12s ease;
}

/* Cajon cerrado: enrolla hacia arriba (~120ms). NO display:none (rompe la animacion). */
.ai-chat-pills-wrap.pills-collapsed .ai-chat-pills {
	max-height: 0;
	padding-top: 0;
	padding-bottom: 0;
	opacity: 0;
}

.ai-chat-pills:empty {
	display: none;
}

.ai-chat-pill {
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	margin: 0 8px 8px 0;
	padding: 7px 10px;
	border: 1px solid #000099;
	border-radius: 16px;
	background: #fff;
	cursor: pointer;
	font-size: 13px;
	/* Pill estilo "link de accion": azul marino LUN, negrita, subrayado. */
	color: #000099;
	text-decoration: underline;
	white-space: nowrap;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	font-weight: 700;
	line-height: 1.3;
	text-align: left;
	box-shadow: 0 1px 3px rgba(0, 0, 60, 0.05);
	-webkit-tap-highlight-color: transparent;
	-webkit-appearance: none;
	-webkit-transition: background 0.15s ease, border-color 0.15s ease, -webkit-transform 0.1s ease;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.ai-chat-pill:active {
	background: #eef1ff;
	border-color: #3a64ff;
	-webkit-transform: scale(0.98);
	transform: scale(0.98);
}

/* Ultimo pill enviado: resaltado azul marino LUN. */
.ai-chat-pill.active {
	background: #000099;
	border-color: #000099;
	color: #fff;
	text-decoration: none;
	box-shadow: 0 2px 6px rgba(0, 0, 153, 0.3);
}

.ai-chat-pill.disabled {
	opacity: 0.45;
	pointer-events: none;
}

/* --- Chat log --- */
#ai-chat-log {
	display: none;
}

#ai-chat-log.visible {
	display: block;
}

#ai-chat-log .chat-turn {
	margin-bottom: 16px;
}

#ai-chat-log .chat-turn:last-child {
	margin-bottom: 0;
}

/* --- Rows (bubble layout) --- */
.chat-row {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: flex-end;
	align-items: flex-end;
	margin-bottom: 10px;
}

.chat-row-user {
	-webkit-justify-content: flex-end;
	justify-content: flex-end;
}

.chat-row-ai {
	-webkit-justify-content: flex-start;
	justify-content: flex-start;
	-webkit-align-items: flex-start;
	align-items: flex-start;
}

/* AI avatar bubble */
.chat-ai-avatar {
	-webkit-flex-shrink: 0;
	flex-shrink: 0;
	width: 30px;
	height: 30px;
	margin-right: 8px;
	border-radius: 50%;
	background: -webkit-linear-gradient(top, #1e3ad6, #000099);
	background: linear-gradient(180deg, #1e3ad6, #000099);
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	box-shadow: 0 1px 4px rgba(0, 0, 80, 0.25);
}

.chat-ai-avatar svg {
	width: 16px;
	height: 16px;
	fill: #fff;
}

/* --- Bubbles --- */
.chat-bubble {
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 18px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

#ai-chat-log .chat-user-msg {
	background: -webkit-linear-gradient(top, #1e3ad6, #000099);
	background: linear-gradient(180deg, #1e3ad6, #000099);
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.45;
	border-bottom-right-radius: 5px;
	box-shadow: 0 1px 5px rgba(0, 0, 80, 0.18);
}

#ai-chat-log .chat-ai-msg {
	background: #fff;
	font-size: 16px;
	line-height: 1.65;
	color: #1f2340;
	border: 1px solid #e8eaf4;
	border-bottom-left-radius: 5px;
	box-shadow: 0 1px 4px rgba(0, 0, 60, 0.06);
}

/* Burbuja de error de conexion/servidor: tono de alerta suave */
#ai-chat-log .chat-ai-msg.chat-error-bubble {
	background: #fff5f5;
	border-color: #f3c2c2;
	color: #9a2b2b;
}

/* Markdown */
#ai-chat-log .chat-ai-msg p { margin: 0 0 10px 0; }
#ai-chat-log .chat-ai-msg p:last-child { margin-bottom: 0; }
#ai-chat-log .chat-ai-msg strong,
#ai-chat-log .chat-ai-msg b { color: #000099; font-weight: 600; }
#ai-chat-log .chat-ai-msg ul,
#ai-chat-log .chat-ai-msg ol { margin: 6px 0; padding-left: 20px; }
#ai-chat-log .chat-ai-msg li { margin-bottom: 4px; }
#ai-chat-log .chat-ai-msg h1,
#ai-chat-log .chat-ai-msg h2,
#ai-chat-log .chat-ai-msg h3,
#ai-chat-log .chat-ai-msg h4 { font-size: 15px; font-weight: 600; color: #000099; margin: 10px 0 4px 0; }
#ai-chat-log .chat-ai-msg blockquote { border-left: 3px solid #3a64ff; margin: 6px 0; padding: 2px 12px; color: #555; font-style: italic; }
#ai-chat-log .chat-ai-msg a { color: #000099; text-decoration: underline; }
#ai-chat-log .chat-ai-msg hr { border: none; border-top: 1px solid #e8eaf4; margin: 10px 0; }

/* Tablas markdown: display:block + overflow-x:auto -> scroll lateral en vez de
   desbordar el layout. */
#ai-chat-log .chat-ai-msg table {
	display: block;
	width: 100%;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border-collapse: collapse;
	font-size: 13px;
	line-height: 1.4;
	margin: 10px 0;
}
#ai-chat-log .chat-ai-msg th,
#ai-chat-log .chat-ai-msg td {
	border: 1px solid #e8eaf4;
	padding: 6px 9px;
	text-align: left;
	vertical-align: top;
	/* nowrap: cada celda en una linea (el scroll horizontal la muestra completa). */
	white-space: nowrap;
}
#ai-chat-log .chat-ai-msg th {
	background: #f4f6fb;
	font-weight: 600;
	color: #000099;
}
#ai-chat-log .chat-ai-msg tr:nth-child(even) td {
	background: #fafbff;
}

/* Cards de notas citadas de LUN: carrusel horizontal. El wrapper posiciona un
   fade a la derecha ("hay mas", con .has-more). margin-left = ancho del avatar. */
.chat-cards-wrap {
	position: relative;
	margin: 8px 0 2px 38px;
}

.chat-cards {
	display: -webkit-flex;
	display: flex;
	-webkit-flex-wrap: nowrap;
	flex-wrap: nowrap;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	/* ocultar scrollbar pero permitir scroll */
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 0 14px 2px 0;
}

.chat-cards::-webkit-scrollbar {
	display: none;
	width: 0;
	height: 0;
}

/* Fade a la derecha ("hay mas cards"). Fijo al wrapper. Solo con .has-more. */
.chat-cards-wrap.has-more::after {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 28px;
	pointer-events: none;
	background: -webkit-linear-gradient(left, rgba(244, 246, 251, 0), #f4f6fb 80%);
	background: linear-gradient(to right, rgba(244, 246, 251, 0), #f4f6fb 80%);
}

.chat-card {
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	width: 200px;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	text-decoration: none;
	border: 1px solid #d7ddf2;
	border-left: 3px solid #000099;
	border-radius: 10px;
	background: #f7f9ff;
	padding: 8px 11px;
	margin-right: 8px;
	-webkit-box-shadow: 0 1px 3px rgba(0, 0, 80, 0.07);
	box-shadow: 0 1px 3px rgba(0, 0, 80, 0.07);
}

.chat-card:last-child {
	margin-right: 0;
}

.chat-card:active {
	background: #eef2ff;
}

.chat-card-kicker {
	display: block;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #000099;
	margin-bottom: 2px;
}

.chat-card-title {
	display: -webkit-box;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	color: #1f2340;
	/* limitar a 3 lineas para que las cards queden parejas */
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.chat-card-meta {
	display: block;
	font-size: 11.5px;
	color: #6b7299;
	margin-top: 3px;
}

/* Linea sutil de fuentes web citadas (nombres de medio, sin link). Bajo la
   respuesta/cards, alineada igual que las herramientas (margin-left avatar). */
.chat-sources {
	/* Ocultas: reactivable quitando este display:none. */
	display: none;
	margin: 6px 0 0 38px;
	font-size: 11.5px;
	line-height: 1.4;
	color: #8a90ab;
}

.chat-turn-tools {
	display: -webkit-flex;
	display: flex;
	/* Alineados a la derecha de la burbuja: margin-left 38px (avatar) + max-width 80%
	   (igual que .chat-bubble) hacen que el borde derecho caiga donde la burbuja. */
	-webkit-justify-content: flex-end;
	justify-content: flex-end;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	max-width: 80%;
	margin: -2px 0 0 38px;
}

.chat-tool-btn {
	display: -webkit-inline-flex;
	display: inline-flex;
	-webkit-align-items: center;
	align-items: center;
	-webkit-justify-content: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	margin-right: 6px;
	border: 1px solid #e3e6f2;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	color: #000099;
	-webkit-tap-highlight-color: transparent;
	-webkit-transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
	transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.chat-tool-btn:active {
	background: #eef1ff;
	color: #000099;
}

.chat-tool-btn svg {
	width: 22px;
	height: 22px;
	fill: currentColor;
}

/* STOP del TTS: fijo a la izquierda del TTS, oculto con espacio reservado
   (visibility:hidden -> la fila no salta). Visible solo en pausa (.tts-stop-visible). */
.chat-tool-tts-stop {
	visibility: hidden;
	pointer-events: none;
	color: #c01826;
}

.chat-tool-tts-stop.tts-stop-visible {
	visibility: visible;
	pointer-events: auto;
}

/* Ultimo boton sin margen: la fila queda pegada al borde derecho. */
.chat-turn-tools .chat-tool-btn:last-child {
	margin-right: 0;
}

.chat-tool-btn.copied {
	color: #16a34a;
	border-color: #bbf7d0;
	background: #f0fdf4;
}

.chat-tool-btn.playing {
	color: #000099;
	border-color: #c0c0ff;
	background: #ededff;
}

.chat-tool-font {
	/* Es texto ("A"), no SVG: 16px acompana a los iconos de 22px. */
	font-size: 16px;
	font-weight: 700;
	font-family: inherit;
	color: #000099;
}

.chat-tool-font.active {
	color: #000099;
	border-color: #c0c0ff;
	background: #ededff;
}

/* Boton "editar pregunta": oculto salvo en el ultimo .chat-turn que no sea .no-user. */
.chat-tool-edit {
	display: none;
}

#ai-chat-log .chat-turn:last-child:not(.no-user) .chat-tool-edit {
	display: -webkit-inline-flex;
	display: inline-flex;
}

/* --- Result cards (carousel at end of an AI answer) --- */
.chat-cards {
	display: -webkit-flex;
	display: flex;
	-webkit-flex-wrap: nowrap;
	flex-wrap: nowrap;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: 12px 0 2px 38px;
	padding-bottom: 4px;
}

.chat-card {
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	width: 140px;
	margin-right: 10px;
	border: 1px solid #e6e9f4;
	border-radius: 12px;
	background: #fff;
	overflow: hidden;
	box-shadow: 0 1px 5px rgba(0, 0, 60, 0.07);
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}

.chat-card:active {
	-webkit-transform: scale(0.98);
	transform: scale(0.98);
}

.chat-card-img {
	width: 100%;
	height: 86px;
	object-fit: cover;
	display: block;
	background: #f1f3fa;
}

.chat-card-body {
	padding: 8px 10px 10px 10px;
}

.chat-card-tag {
	display: inline-block;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.4px;
	text-transform: uppercase;
	color: #fff;
	background: #000099;
	border-radius: 4px;
	padding: 2px 7px;
	margin-bottom: 6px;
}

.chat-card-title {
	font-size: 12.5px;
	font-weight: 600;
	color: #1f2340;
	line-height: 1.3;
	margin: 0;
}

/* --- Cursor --- */
.chat-cursor {
	display: inline-block;
	width: 2px;
	height: 15px;
	background: #000099;
	margin-left: 2px;
	vertical-align: text-bottom;
	-webkit-animation: ai-blink 0.8s step-end infinite;
	animation: ai-blink 0.8s step-end infinite;
}

@-webkit-keyframes ai-blink { 50% { opacity: 0; } }
@keyframes ai-blink { 50% { opacity: 0; } }

/* --- Status --- */
#ai-chat-status {
	font-size: 12px;
	color: #9aa0bd;
	text-align: center;
	padding: 4px 0;
}

#ai-chat-status.error {
	color: #d32f2f;
	background: #ffebee;
	padding: 8px;
	border-radius: 8px;
}

/* --- Thinking dots --- */
.chat-thinking {
	display: -webkit-flex;
	display: flex;
	-webkit-flex-direction: column;
	flex-direction: column;
	-webkit-align-items: flex-start;
	align-items: flex-start;
	padding: 2px 2px;
}

/* Fila del estado: icono + texto del paso actual, con linea divisoria. */
.chat-status-row {
	display: -webkit-flex;
	display: flex;
	-webkit-align-items: center;
	align-items: center;
	padding-bottom: 6px;
	margin-bottom: 6px;
	border-bottom: 1px solid #e8eaf4;
}
/* Si no hay texto de estado, ocultar toda la fila (icono + linea) */
.chat-status-row:not(.has-status) { display: none; }

.chat-status-icon {
	width: 13px;
	height: 13px;
	margin-right: 6px;
	fill: #3a64ff;
	-webkit-flex: 0 0 auto;
	flex: 0 0 auto;
	-webkit-animation: chat-status-pulse 1.6s ease-in-out infinite;
	animation: chat-status-pulse 1.6s ease-in-out infinite;
}

@-webkit-keyframes chat-status-pulse {
	0%, 100% { opacity: 0.5; -webkit-transform: scale(0.9); }
	50% { opacity: 1; -webkit-transform: scale(1.1); }
}
@keyframes chat-status-pulse {
	0%, 100% { opacity: 0.5; transform: scale(0.9); }
	50% { opacity: 1; transform: scale(1.1); }
}

.chat-status-text {
	font-size: 13px;
	color: #6b7396;
	line-height: 1.4;
	font-style: italic;
}

.chat-dots {
	display: -webkit-inline-flex;
	display: inline-flex;
	-webkit-align-items: center;
	align-items: center;
}

.chat-dot {
	width: 7px;
	height: 7px;
	margin-right: 5px;
	background: #3a64ff;
	border-radius: 50%;
	opacity: 0.4;
	-webkit-animation: chat-bounce 1.4s ease-in-out infinite;
	animation: chat-bounce 1.4s ease-in-out infinite;
}

.chat-dots .chat-dot:nth-child(2) { -webkit-animation-delay: 0.2s; animation-delay: 0.2s; }
.chat-dots .chat-dot:nth-child(3) { -webkit-animation-delay: 0.4s; animation-delay: 0.4s; margin-right: 0; }

@-webkit-keyframes chat-bounce {
	0%, 80%, 100% { -webkit-transform: translateY(0); opacity: 0.4; }
	40% { -webkit-transform: translateY(-8px); opacity: 1; }
}
@keyframes chat-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
	40% { transform: translateY(-8px); opacity: 1; }
}


/* =============================================================================
 * DESKTOP: modal como ventana centrada (no bottom-sheet fullscreen).
 * Solo DESKTOP REAL: pantalla ancha (>=800px) Y puntero fino con hover (mouse).
 * ============================================================================= */
@media (min-width: 800px) and (pointer: fine) and (hover: hover) {
	/* Anti "layout shift" */
	html {
		scrollbar-gutter: stable;
	}
	#ai-chat-modal .chat-sheet {
		top: 50%;
		left: 50%;
		bottom: auto;
		right: auto;
		width: 600px;
		max-width: 92vw;
		height: 720px;
		max-height: 90vh;
		border-radius: 20px;
		/* Centrado + estado oculto (baja un poco y transparente hasta .show). */
		-webkit-transform: translate(-50%, -48%);
		transform: translate(-50%, -48%);
		opacity: 0;
	}
	#ai-chat-modal.show .chat-sheet {
		-webkit-transform: translate(-50%, -50%);
		transform: translate(-50%, -50%);
		opacity: 1;
	}
	#ai-chat-modal .chat-grabber {
		display: none;
	}
}