.apc {
	/* Tarjeta siempre oscura, sobre negro puro. */
	--apc-ink: #eef0f3;
	--apc-muted: #a4abb5;
	--apc-line: #2c3138;
	--apc-bg: #000000;
	--apc-soft: #000000;
	--apc-raised: #1b1f24;
	/* El gris del fondo del logo de Araintel. */
	--apc-accent: #23282b;
	--apc-link: #7fb0ff;
	position: fixed;
	right: 20px;
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	z-index: 99980;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	font: 14px/1.45 'Satoshi', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--apc-ink);
}

.apc *,
.apc *::before,
.apc *::after {
	box-sizing: border-box;
}

.apc__toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 48px;
	padding: 6px 16px 6px 6px;
	border: 0;
	border-radius: 999px;
	background: var(--apc-accent);
	color: #fff;
	font: inherit;
	font-weight: 700;
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.apc__toggle[hidden] {
	display: none;
}

.apc__toggle:hover {
	background: #1a1e20;
}

.apc__toggle:focus-visible,
.apc__close:focus-visible,
.apc__reset:focus-visible,
.apc__send:focus-visible,
.apc__chip:focus-visible {
	outline: 2px solid #3858e9;
	outline-offset: 2px;
}

.apc__logo {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	background: #fff;
	flex: 0 0 auto;
}

.apc__logo--text {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--apc-accent);
	font-weight: 800;
}

.apc__logo--mark {
	display: none;
}

.apc__panel {
	position: relative;
	width: min(380px, calc(100vw - 40px));
	height: min(560px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	background: var(--apc-bg);
	border: 1px solid var(--apc-line);
	border-radius: 14px;
	box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
	overflow: hidden;
}

.apc__panel[hidden] {
	display: none;
}

/* Capa del color del botón: tapa la tarjeta mientras crece o encoge. */
.apc__veil {
	position: absolute;
	inset: 0;
	z-index: 3;
	background: var(--apc-accent);
	opacity: 0;
	pointer-events: none;
}

.apc__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	background: var(--apc-accent);
	color: #fff;
}

.apc__head .apc__logo {
	width: 30px;
	height: 30px;
}

.apc__title {
	flex: 1 1 auto;
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	color: #fff;
}

.apc__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: none;
	color: #fff;
	width: 36px;
	height: 36px;
	padding: 0;
	border-radius: 50%;
	cursor: pointer;
}

.apc__close:hover,
.apc__reset:hover {
	background: rgba(255, 255, 255, 0.14);
}

.apc__reset {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: none;
	color: #fff;
	width: 36px;
	height: 36px;
	padding: 0;
	border-radius: 50%;
	cursor: pointer;
}

.apc__log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--apc-soft);
	overscroll-behavior: contain;
}

.apc__msg {
	max-width: 92%;
	padding: 9px 12px;
	border-radius: 12px;
	white-space: pre-wrap;
	word-wrap: break-word;
}

/* Las respuestas de ARAINTEL AI, solo texto: sin globo detrás. */
.apc__msg--bot {
	align-self: stretch;
	max-width: none;
	padding: 2px 2px;
	background: none;
	border-radius: 0;
}

.apc__msg--user {
	align-self: flex-end;
	background: #ffffff;
	color: #000000;
	border-bottom-right-radius: 4px;
}

.apc__links {
	list-style: none;
	margin: 8px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.apc__links li {
	padding-top: 8px;
	border-top: 1px solid var(--apc-line);
}

.apc__links a {
	color: var(--apc-link);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
}

.apc__links a:hover {
	text-decoration: underline;
}

.apc__meta {
	display: block;
	margin-top: 2px;
	color: var(--apc-muted);
	font-size: 12px;
}

.apc__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-self: flex-start;
}

.apc__chip {
	border: 0;
	background: var(--apc-raised);
	color: var(--apc-ink);
	border-radius: 999px;
	padding: 6px 11px;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}

.apc__chip:hover {
	background: #262b31;
}

.apc__typing {
	align-self: flex-start;
	color: var(--apc-muted);
	font-size: 12px;
}

.apc__form {
	display: flex;
	gap: 8px;
	padding: 10px;
	background: var(--apc-bg);
}

.apc__input {
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	border-radius: 10px;
	padding: 9px 11px;
	font: inherit;
	font-size: 13px;
	color: var(--apc-ink);
	background: var(--apc-raised);
}

/* La caja de escribir, con el micrófono dentro a la izquierda cuando el navegador puede dictar. */
.apc__field {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
}

.apc__field .apc__input {
	width: 100%;
}

.apc__field--mic .apc__input {
	padding-left: 38px;
}

.apc__mic {
	position: absolute;
	top: 50%;
	left: 5px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--apc-muted);
	cursor: pointer;
	transform: translateY(-50%);
}

.apc__mic[hidden] {
	display: none;
}

.apc__mic:hover {
	color: var(--apc-ink);
}

.apc__mic:focus-visible {
	outline: 2px solid #3858e9;
	outline-offset: 1px;
}

.apc__mic.is-loading {
	opacity: 0.5;
	cursor: progress;
}

.apc__mic.is-recording {
	color: #d93025;
	animation: apc-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes apc-mic-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
	.apc__mic.is-recording {
		animation: none;
	}
}

.apc__input::placeholder {
	font-size: 13px;
	color: var(--apc-muted);
	opacity: 1;
}

/* Safari de iPhone amplía la página al escribir en un campo de menos de 16 px. */
@supports (-webkit-touch-callout: none) {
	.apc__input {
		font-size: 16px;
	}
}

.apc__send {
	border: 0;
	border-radius: 10px;
	padding: 0 14px;
	background: var(--apc-accent);
	color: #fff;
	font: inherit;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
}

.apc__send[disabled] {
	opacity: 0.5;
	cursor: default;
}

.apc__note {
	margin: 0;
	padding: 0 12px 8px;
	background: var(--apc-bg);
	color: var(--apc-muted);
	font-size: 11px;
}

@media (max-width: 600px) {
	.apc {
		right: 12px;
		bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	}

	.apc__label {
		display: none;
	}

	.apc__toggle {
		padding: 6px;
	}

	.apc__toggle .apc__logo {
		width: 44px;
		height: 44px;
	}

	.apc--open {
		left: 12px;
	}

	.apc__panel {
		width: 100%;
		height: min(78vh, calc(100vh - 100px));
	}
}

/* Con la barra inferior del móvil: encima de ella, pegado al borde derecho. */
@media (max-width: 959px), (orientation: portrait) and (max-width: 1400px) {
	html.arrss-bar-active .apc {
		right: 12px;
		bottom: calc(var(--arrss-bar-base-height, 56px) + env(safe-area-inset-bottom, 0px) + var(--arrss-visual-bottom-gap, 0px) + 10px);
	}

	html.arrss-bar-active .apc__panel {
		height: min(72vh, calc(100vh - 170px));
	}
}

html.arrss-sheet-open .apc,
html.agn-navbar-menu-open .apc {
	display: none;
}

/* Con la barra inferior del móvil, el botón flotante sobra: ARAINTEL AI se abre desde la barra. */
@media (max-width: 959px), (orientation: portrait) and (max-width: 1400px) {
	html.arrss-bar-active .apc__toggle {
		display: none !important;
	}
}


@media print {
	.apc {
		display: none;
	}
}

/* La caja de escribir, sin bordes ni anillo al enfocarla. */
.apc__input:focus,
.apc__input:focus-visible {
	outline: none;
	box-shadow: none;
}

/* Botón y tarjeta en blanco con desenfoque, como la tarjeta de cookies, en el ordenador y en el móvil.
   Va al final para mandar sobre los tamaños del móvil de arriba. El desenfoque va en el propio
   elemento: en un ::before dentro de la tarjeta (overflow hidden y esquinas redondeadas) Chrome no
   lo pinta. */
@media all {
	.apc {
		--apc-ink: #0e0e0e;
		--apc-muted: rgba(14, 14, 14, 0.55);
		--apc-line: rgba(14, 14, 14, 0.1);
		--apc-bg: transparent;
		--apc-soft: transparent;
		--apc-raised: rgba(14, 14, 14, 0.06);
		/* El gris del fondo del logo de Araintel, no negro: botón «Enviar» y mensajes enviados. */
		--apc-accent: #23282b;
		--apc-link: #1f4fd1;
	}

	.apc__panel {
		background: rgba(255, 255, 255, 0.72);
		-webkit-backdrop-filter: blur(18px);
		backdrop-filter: blur(18px);
	}

	/* El botón plegado, idéntico a la tarjeta de cookies: el desenfoque en un ::before y sin sombra. */
	.apc__toggle,
	.apc__toggle:hover {
		position: relative;
		isolation: isolate;
		background: transparent;
		box-shadow: none;
	}

	.apc__toggle::before {
		content: "";
		position: absolute;
		inset: 0;
		z-index: -1;
		border-radius: inherit;
		pointer-events: none;
		background: rgba(255, 255, 255, 0.72);
		-webkit-backdrop-filter: blur(18px);
		backdrop-filter: blur(18px);
		transform: translateZ(0);
		backface-visibility: hidden;
	}

	.apc__toggle:hover::before {
		background: rgba(255, 255, 255, 0.86);
	}

	/* Plegado, solo el icono: un cuadrado con las esquinas redondeadas. */
	.apc__toggle {
		padding: 9px;
		border-radius: 16px;
		color: #0e0e0e;
	}

	.apc__toggle .apc__logo {
		width: 54px;
		height: 54px;
	}

	.apc__label {
		display: none;
	}

	.apc__panel {
		border: 0;
		box-shadow: 0 14px 40px rgba(0, 0, 0, 0.14);
	}

	.apc__head {
		background: transparent;
		color: #0e0e0e;
		border-bottom: 1px solid var(--apc-line);
	}

	.apc__title,
	.apc__close,
	.apc__reset {
		color: #0e0e0e;
	}

	.apc__close:hover,
	.apc__reset:hover,
	.apc__chip:hover {
		background: rgba(14, 14, 14, 0.1);
	}

	.apc__veil {
		background: #ffffff;
	}

	.apc__msg--user {
		background: var(--apc-accent);
		color: #ffffff;
	}

	/* Solo la «a» de Araintel, del gris del fondo de su logo y sin el cuadrado. */
	.apc__logo--full {
		display: none;
	}

	.apc__logo--mark {
		display: block;
		background: transparent;
		border-radius: 0;
	}

	.apc__logo--mark.apc__logo--text {
		display: inline-flex;
		color: #23282b;
	}
}

/* Ordenador: ARAINTEL AI fijo en una franja a la derecha (20 % del ancho, mínimo 260 px) y la página
   en el resto, entre el navbar y el pie. Va por media query y no por clase para que la página no salte al cargar el chat. Lo
   que antes ocupaba el ancho de la ventana (100vw) pasa a ocupar el de la página. Al plegarlo
   (html.apc-folded) el ancho de la franja baja a 0 poco a poco y la página se ensancha con él: la
   variable está registrada para poder animarla. */
@property --apc-dock {
	syntax: '<length>';
	inherits: true;
	initial-value: 0px;
}

.apc__fold {
	display: none;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #0e0e0e;
	cursor: pointer;
}

.apc__fold:hover {
	background: rgba(14, 14, 14, 0.1);
}

.apc__fold:focus-visible {
	outline: 2px solid #3858e9;
	outline-offset: 2px;
}

.apc__resize {
	display: none;
}

@media (min-width: 960px) and (orientation: landscape) {
	:root {
		--apc-dock-open: max(20vw, 260px);
		--apc-dock: var(--apc-dock-open);
		--apc-page: calc(100vw - var(--apc-dock));
		transition: --apc-dock 0.38s cubic-bezier(0.22, 1, 0.36, 1);
	}

	html.apc-folded {
		--apc-dock: 0px;
	}

	/* Solo el contenido deja sitio al chat: el navbar y el pie siguen a lo ancho. Este margen guarda
	   el hueco hasta que el JS mete el chat en la rejilla de abajo, para que nada salte. */
	.wp-site-blocks > :not(header):not(footer):not(.apc) {
		margin-right: var(--apc-dock) !important;
	}

	/* Con el chat dentro: rejilla de dos columnas entre el navbar y el pie. El chat es «sticky»: lo
	   mueve el propio scroll del navegador, sin JS, así que no rebota ni pisa el navbar. */
	.wp-site-blocks:has(> .apc--docked) {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) var(--apc-dock);
		grid-template-rows: auto 1fr auto;
		overflow-x: clip;
	}

	.wp-site-blocks:has(> .apc--docked) > * {
		grid-column: 1 / -1;
	}

	.wp-site-blocks:has(> .apc--docked) > :not(header):not(footer):not(.apc) {
		grid-column: 1;
		grid-row: 2;
		margin-right: 0 !important;
	}

	.wp-site-blocks > .apc--docked {
		position: sticky !important;
		top: 0 !important;
		right: auto !important;
		bottom: auto !important;
		z-index: 20;
		grid-column: 2;
		grid-row: 2;
		align-self: start;
		width: auto;
		height: calc(100vh - var(--apc-head, 57px));
		margin: 0 !important;
		gap: 0;
		align-items: stretch;
	}

	/* Arriba del todo, el chat empieza bajo el navbar; según se baja, crece hasta ocupar la pantalla
	   entera, y la caja de escribir queda siempre al pie. */
	@supports (animation-timeline: scroll()) {
		.wp-site-blocks > .apc--docked {
			animation: apc-dock-fit linear both;
			animation-timeline: scroll(root block);
			animation-range: 0px var(--apc-head, 57px);
		}
	}

	.apc--docked .apc__panel {
		width: var(--apc-dock-open);
		height: 100%;
		border-radius: 0;
		box-shadow: none;
		border-left: 1px solid rgba(14, 14, 14, 0.08);
		transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0s;
	}

	.apc--docked .apc__close,
	.apc--docked .apc__toggle {
		display: none !important;
	}

	.apc--docked .apc__fold {
		display: inline-flex;
	}

	/* Plegado: la tarjeta sale por la derecha y queda el botón cuadrado para volver a abrirla. */
	html.apc-folded .apc--docked {
		pointer-events: none;
	}

	html.apc-folded .apc--docked .apc__panel {
		visibility: hidden;
		transform: translateX(100%);
		transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.38s;
	}

	/* El borde izquierdo se arrastra para cambiar el ancho; muy estrecho, se pliega al soltar. */
	.apc--docked .apc__resize {
		position: absolute;
		top: 0;
		bottom: 0;
		left: -5px;
		z-index: 5;
		display: block;
		width: 10px;
		cursor: col-resize;
		touch-action: none;
	}

	.apc--docked .apc__resize::after {
		content: "";
		position: absolute;
		top: 0;
		bottom: 0;
		left: 4px;
		width: 2px;
		background: transparent;
		transition: background 0.15s ease;
	}

	.apc--docked .apc__resize:hover::after,
	.apc--docked .apc__resize:focus-visible::after,
	html.apc-resizing .apc--docked .apc__resize::after {
		background: rgba(14, 14, 14, 0.25);
	}

	.apc--docked .apc__resize:focus-visible {
		outline: none;
	}

	html.apc-resizing,
	html.apc-resizing * {
		cursor: col-resize !important;
		user-select: none !important;
		transition: none !important;
	}

	html.apc-will-fold .apc--docked .apc__panel {
		opacity: 0.45;
	}

	html.apc-folded .apc--docked .apc__resize {
		display: none;
	}

	html.apc-folded .apc--docked .apc__toggle {
		position: fixed;
		right: 20px;
		bottom: 20px;
		display: inline-flex !important;
		pointer-events: auto;
	}

	html body .agn-content--breakout {
		width: calc(var(--apc-page) - (var(--agn-breakout-gutter) * 2)) !important;
		margin-left: calc(50% - (var(--apc-page) / 2) + var(--agn-breakout-gutter)) !important;
		margin-right: calc(50% - (var(--apc-page) / 2) + var(--agn-breakout-gutter)) !important;
	}

	html body.single-post .ara-sp-hero,
	html body.single-post .ara-sp-hero-actions {
		width: var(--apc-page);
	}

	html body.single-post .ara-sp-hero > .wp-element-caption {
		top: calc(var(--apc-page) / 2 * 9 / 16 - 12px);
		max-width: calc(var(--apc-page) / 2 - 48px);
	}

	html body.single-post .ara-sp-hero > .wp-element-caption.is-expanded {
		max-width: calc(var(--apc-page) / 2 - 48px);
	}

	html body.single-post .ara-sp-hero > .wp-element-caption.is-expanded .araintel-credit-text {
		max-width: calc(var(--apc-page) / 2 - 96px);
	}

	html body .aph.alignfull {
		margin-right: calc(50% - var(--apc-page) / 2);
		margin-left: calc(50% - var(--apc-page) / 2);
	}
}

@keyframes apc-dock-fit {
	from {
		height: calc(100vh - var(--apc-head, 57px));
	}

	to {
		height: 100vh;
	}
}

/* La caja de escribir, el doble de alta: el texto arriba; el micrófono abajo a la izquierda y
   «Enviar», un círculo con una flecha del mismo tamaño, abajo a la derecha. */
.apc__field {
	display: block;
	min-height: 80px;
	padding: 6px 8px 42px;
	border-radius: 12px;
	background: var(--apc-raised);
	cursor: text;
}

.apc__field .apc__input,
.apc__field--mic .apc__input {
	width: 100%;
	padding: 6px 4px;
	border-radius: 0;
	background: transparent;
}

.apc__field .apc__mic {
	top: auto;
	bottom: 6px;
	left: 6px;
	transform: none;
}

.apc__field .apc__send {
	position: absolute;
	right: 6px;
	bottom: 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	border-radius: 50%;
	background: var(--apc-accent);
	color: #ffffff;
}

.apc__field .apc__send:hover {
	filter: brightness(1.25);
}
