/* AM Surveys AI Assistant. */
		/* Chat Box Container */
		#amsurveys-chat-box {
			--amsurveys-safe-top: 0px;
			font-family: "Noto Sans", Arial, sans-serif;
			position: fixed;
			bottom: 20px;
			right: 20px;
			width: min(420px, calc(100vw - 32px));
			height: min(820px, calc(100vh - var(--amsurveys-safe-top) - 20px));
			height: min(820px, calc(100dvh - var(--amsurveys-safe-top) - 20px));
			max-height: calc(100vh - var(--amsurveys-safe-top) - 20px);
			max-height: calc(100dvh - var(--amsurveys-safe-top) - 20px);
			transition: height .22s ease, max-height .22s ease;
			background: #1b1915;
			color: #f2f3f4;
			border: 1px solid rgba(181,131,11,0.5);
			border-radius: 10px;
			display: none;
			flex-direction: column;
			box-shadow: 0 18px 48px rgba(0,0,0,0.45);
			overflow: hidden;
			animation: amsurveysSlideUp 0.25s ease-out;
			z-index: 99998;
		}

		@keyframes amsurveysSlideUp {
			from { opacity: 0; transform: translateY(12px); }
			to   { opacity: 1; transform: translateY(0); }
		}

		/* Header */
		.amsurveys-header {
			background: linear-gradient(180deg, #2b2620 0%, #211e18 100%);
			color: #fff;
			padding: 12px 14px;
			font-size: 15px;
			font-weight: 500;
			display: flex;
			align-items: center;
			gap: 10px;
			border-bottom: 1px solid rgba(181,131,11,0.45);
			flex: 0 0 auto;
		}

		.amsurveys-header svg { width: 22px; height: 22px; }

		.amsurveys-voice-btn {
			margin-left: auto;
			width: 34px;
			height: 34px;
			border: 1px solid rgba(255,255,255,0.14);
			border-radius: 6px;
			background: rgba(255,255,255,0.08);
			color: #fff;
			display: flex;
			align-items: center;
			justify-content: center;
			cursor: pointer;
			padding: 0;
		}

		.amsurveys-voice-btn:hover,
		.amsurveys-voice-btn:focus {
			background: rgba(181,131,11,0.42);
			border-color: rgba(255,255,255,0.24);
			outline: none;
		}

		.amsurveys-voice-btn.is-muted {
			background: rgba(181,131,11,0.95);
			border-color: rgba(255,255,255,0.24);
		}

		.amsurveys-voice-btn svg {
			width: 19px;
			height: 19px;
		}

		/* Al-Bot animated character stage */
		.amsurveys-albot-band {
			position: relative;
			width: 100%;
			height: 320px;
			/* Light band matching the media's own near-white (#fbf9fa) background so
			   letterbox/pillarbox bars blend invisibly with the media edges. The
			   full-width overlay fades the whole band into the dark chat below. */
			background: linear-gradient(to bottom, #fbfbfb 0%, #f6f6f7 52%, #eceef0 100%);
			overflow: hidden;
			/* Keep the character at its intended size; message history owns overflow. */
			flex: 0 0 auto;
			min-height: 150px;
		}
		.amsurveys-albot-band::after {
			content: "";
			position: absolute;
			left: 0;
			right: 0;
			bottom: 0;
			height: 55%;
			z-index: 4;
			pointer-events: none;
			/* Full-width white->dark fade covers media and any side/letterbox bars
			   identically, so the robot floats and sinks into the chat with no
			   visible lateral seam at any band height. */
			background: linear-gradient(to bottom, rgba(27,25,21,0) 0%, rgba(27,25,21,0) 40%, rgba(27,25,21,0.55) 74%, rgba(27,25,21,0.88) 90%, #1b1915 100%);
		}
		.amsurveys-albot-band .albot-stage {
			position: absolute;
			inset: 0;
			z-index: 1;
		}
		.amsurveys-albot-band .albot-poster,
		.amsurveys-albot-band .albot-video {
			position: absolute;
			inset: 0;
			width: 100%;
			height: 100%;
			object-fit: contain;
			object-position: center bottom;
		}
		.amsurveys-albot-band .albot-video { opacity: 0; }
		.amsurveys-albot-band .albot-poster { opacity: 1; z-index: 1; }
		/* Hide the whole band if videos can't run and there's no poster paint. */
		.amsurveys-albot-band[hidden] { display: none; }

		/* Messages */
		#amsurveys-chat-messages {
			padding: 14px;
			min-height: 0;
			flex: 1 1 auto;
			overflow-y: auto;
			font-size: 14px;
			line-height: 1.45;
			background: #1b1915;
			scrollbar-color: #b5830b #26221b;
		}

		.amsurveys-msg {
			max-width: 88%;
			margin: 0 0 10px;
			padding: 10px 12px;
			border-radius: 8px;
			border: 1px solid rgba(255,255,255,0.08);
			box-shadow: 0 8px 20px rgba(0,0,0,0.16);
			word-break: break-word;
		}

		.amsurveys-msg b {
			color: #ff8a8f;
			font-weight: 600;
		}

		.amsurveys-msg.amsurveys-ai {
			background: #26221b;
			color: #f2f3f4;
			margin-right: auto;
		}

		.amsurveys-msg.amsurveys-user {
			background: #b5830b;
			color: #fff;
			margin-left: auto;
			border-color: rgba(255,255,255,0.12);
		}

		.amsurveys-msg.amsurveys-user b {
			color: #fff;
		}

		.amsurveys-msg.amsurveys-error {
			border-color: rgba(255,160,122,0.45);
			background: #2a1215;
		}

		.amsurveys-msg.amsurveys-success {
			border-color: rgba(141,226,166,0.45);
			background: #241215;
		}

		.amsurveys-chat-actions {
			display: flex;
			flex-wrap: wrap;
			gap: 8px;
			margin: 8px 0 12px;
		}

		.amsurveys-chat-action {
			border: 1px solid rgba(255,255,255,0.14);
			border-radius: 8px;
			background: #332d25;
			color: #fff;
			font-family: "Noto Sans", Arial, sans-serif;
			font-size: 13px;
			font-weight: 600;
			padding: 8px 10px;
			cursor: pointer;
		}

		.amsurveys-chat-action.is-primary {
			background: #b5830b;
			border-color: #b5830b;
		}

		.amsurveys-chat-action:hover,
		.amsurveys-chat-action:focus {
			outline: none;
			background: #d9a428;
		}

		/* Input */
		.amsurveys-input-wrap {
			border-top: 1px solid rgba(181,131,11,0.45);
			background: #211e18;
			padding: 10px;
			flex: 0 0 auto;
		}

		.amsurveys-input-wrap.is-hidden { display: none; }

		.amsurveys-input-form {
			display: flex;
			align-items: center;
			gap: 8px;
		}

		#amsurveys-chat-input {
			width: 100%;
			min-height: 44px;
			max-height: 126px;
			padding: 11px 12px;
			border: 1px solid rgba(255,255,255,0.14);
			border-radius: 8px;
			background: #2b2620;
			color: #fff;
			font-size: 14px;
			line-height: 1.35;
			resize: none;
			overflow-y: auto;
		}

		#amsurveys-chat-input::placeholder { color: rgba(255,255,255,0.58); }
		#amsurveys-chat-input:focus {
			outline: none;
			border-color: #b5830b;
			box-shadow: 0 0 0 3px rgba(181,131,11,0.22);
		}

		#amsurveys-chat-send,
		.amsurveys-form-submit,
		.amsurveys-form-cancel {
			border: 0;
			border-radius: 8px;
			cursor: pointer;
			font-family: "Noto Sans", Arial, sans-serif;
			font-weight: 600;
			transition: background .18s ease, transform .18s ease, opacity .18s ease;
		}

		#amsurveys-chat-send {
			width: 48px;
			min-height: 44px;
			height: 44px;
			flex: 0 0 48px;
			display: inline-flex;
			align-items: center;
			justify-content: center;
			background: #b5830b;
			color: #fff;
		}

		#amsurveys-chat-send:hover,
		#amsurveys-chat-send:focus,
		.amsurveys-form-submit:hover,
		.amsurveys-form-submit:focus {
			background: #d9a428;
			outline: none;
		}

		#amsurveys-chat-send:disabled,
		.amsurveys-form-submit:disabled {
			opacity: .55;
			cursor: not-allowed;
			transform: none;
		}

		#amsurveys-chat-send svg {
			width: 20px;
			height: 20px;
		}

		#amsurveys-contact-form {
			display: none;
			padding: 14px;
			font-size: 14px;
			background: #1b1915;
			color: #f2f3f4;
			overflow-y: auto;
			flex: 1 1 auto;
		}

		#amsurveys-contact-form.is-open {
			display: block;
		}

		#amsurveys-chat-box.amsurveys-contact-open #amsurveys-chat-messages {
			display: none;
		}

		.amsurveys-form-title {
			margin: 0 0 10px;
			font-size: 15px;
			font-weight: 600;
			color: #fff;
		}

		.amsurveys-form-field {
			display: block;
			margin: 0 0 10px;
			color: rgba(255,255,255,0.78);
			font-size: 13px;
		}

		.amsurveys-form-field span {
			display: block;
			margin-bottom: 5px;
		}

		#amsurveys-contact-form input,
		#amsurveys-contact-form textarea {
			width: 100%;
			padding: 10px 11px;
			border: 1px solid rgba(255,255,255,0.14);
			border-radius: 8px;
			background: #2b2620;
			color: #fff;
			font-family: "Noto Sans", Arial, sans-serif;
			font-size: 14px;
		}

		#amsurveys-contact-form textarea {
			min-height: 96px;
			resize: vertical;
		}

		#amsurveys-contact-form input:focus,
		#amsurveys-contact-form textarea:focus {
			outline: none;
			border-color: #b5830b;
			box-shadow: 0 0 0 3px rgba(181,131,11,0.22);
		}

		.amsurveys-form-actions {
			display: grid;
			grid-template-columns: 1fr 1fr;
			gap: 8px;
			margin-top: 12px;
		}

		.amsurveys-form-submit {
			background: #b5830b;
			color: #fff;
			padding: 10px 12px;
		}

		.amsurveys-form-cancel {
			background: #332d25;
			color: #fff;
			border: 1px solid rgba(255,255,255,0.14);
			padding: 10px 12px;
		}

		.amsurveys-form-cancel:hover,
		.amsurveys-form-cancel:focus {
			background: #332d25;
			outline: none;
		}

		/* Typing dots */
		.amsurveys-typing-dot {
			width: 6px;
			height: 6px;
			margin: 0 2px;
			background: #ff8a8f;
			border-radius: 50%;
			display: inline-block;
			animation: amsurveysDotBounce 1.2s infinite;
		}
		.amsurveys-typing-dot:nth-child(2) { animation-delay: .15s }
		.amsurveys-typing-dot:nth-child(3) { animation-delay: .3s }

		@keyframes amsurveysDotBounce {
			0%, 100% { transform: translateY(0); }
			50% { transform: translateY(-5px); }
		}

		#amsurveys-msg { min-height:100px; }

		/* --- Chat Launcher (bubble + label) --- */
		#amsurveys-chat-launch {
			position: fixed;
			bottom: 20px;
			right: 20px;
			display: flex;
			flex-direction: row-reverse;
			align-items: center;
			gap: 10px;
			z-index: 99999;
			cursor: pointer;
		}

		body.amsurveys-chat-open #amsurveys-chat-launch {
			display: none !important;
			pointer-events: none;
		}

		/* Bubble button */
		#amsurveys-chat-btn {
			width: 56px;
			height: 56px;
			border-radius: 50%;
			background: #b5830b;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 26px;
			color: white;
			box-shadow: 0 6px 18px rgba(0,0,0,0.25);
			transition: 0.2s ease;
		}

		#amsurveys-chat-btn:hover { transform: scale(1.07); }

		/* Label */
		#amsurveys-chat-label {
			background: #fff;
			color: #b5830b;
			border: 1px solid #ddd;
			border-radius: 8px;
			padding: 8px 14px;
			font-size: 13px;
			font-weight: 600;
			font-family: "Noto Sans", Arial, sans-serif;
			box-shadow: 0 4px 12px rgba(0,0,0,.15);
			white-space: nowrap;
			animation: amsurveysFadeIn .3s ease;
		}

		/* Hide label on small screens */
		@media(max-width:500px) {
			#amsurveys-chat-label { display:none; }
		}

		@media(max-width:640px) {
			#amsurveys-chat-box {
				--amsurveys-safe-top: 0px !important;
				top: calc(8px + env(safe-area-inset-top, 0px));
				right: calc(8px + env(safe-area-inset-right, 0px));
				bottom: auto;
				left: calc(8px + env(safe-area-inset-left, 0px));
				width: auto;
				height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
				height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
				max-height: none;
				border-radius: 8px;
			}
			.amsurveys-albot-band { height: clamp(150px, 32dvh, 240px); }
			.amsurveys-header { padding: 10px 12px; }
			#amsurveys-chat-messages { min-height: 0; }
			.amsurveys-form-actions { grid-template-columns: 1fr; }
		}

		@media(max-height:500px) {
			#amsurveys-chat-box {
				--amsurveys-safe-top: 0px !important;
				top: calc(8px + env(safe-area-inset-top, 0px));
				right: calc(8px + env(safe-area-inset-right, 0px));
				bottom: auto;
				height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
				height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
				max-height: none;
			}
			.amsurveys-header { padding: 8px 10px; }
			.amsurveys-albot-band { height: clamp(110px, 34dvh, 175px); }
			#amsurveys-chat-messages { min-height: 0; }
		}

		@keyframes amsurveysFadeIn {
			from { opacity:0; transform:translateY(4px); }
			to { opacity:1; transform:translateY(0); }
		}

		/* --- Attention nudge: mini bot waves a few seconds after first load --- */
		#amsurveys-bot-nudge {
			position: fixed;
			right: 20px;
			bottom: 90px;
			z-index: 99999;
			width: min(430px, calc(100vw - 40px));
			background: #26221b;
			border: 1px solid rgba(181,131,11,0.25);
			border-radius: 10px;
			box-shadow: 0 16px 42px rgba(0,0,0,0.28);
			padding: 14px 16px;
			display: none;
			opacity: 0;
			transform: translateY(10px);
			transition: opacity .35s ease, transform .35s ease;
			cursor: pointer;
			font-family: "Noto Sans", Arial, sans-serif;
		}
		#amsurveys-bot-nudge.amsurveys-show { opacity: 1; transform: translateY(0); }
		#amsurveys-bot-nudge .amsurveys-nudge-row { display: flex; gap: 14px; align-items: center; }
		#amsurveys-nudge-botwrap {
			position: relative;
			flex: 0 0 132px;
			width: 132px;
			aspect-ratio: 44 / 37;
			border-radius: 8px;
			overflow: hidden;
			background: transparent;
			border: 0;
		}
		#amsurveys-nudge-botwrap img, #amsurveys-nudge-botwrap video {
			position: absolute; inset: 0; width: 100%; height: 100%;
			object-fit: contain; object-position: center center;
		}
		#amsurveys-nudge-botwrap video { opacity: 0; }
		#amsurveys-nudge-copy { font-size: 15px; color: #f2f3f4; line-height: 1.35; font-weight: 600; }
		#amsurveys-nudge-close {
			position: absolute; top: 6px; right: 8px;
			border: 0; background: transparent; color: #aaa;
			font-size: 18px; line-height: 1; cursor: pointer; padding: 2px;
		}
		#amsurveys-nudge-close:hover { color: #555; }
		#amsurveys-bot-nudge::after {
			content: ""; position: absolute; right: 26px; bottom: -8px;
			width: 15px; height: 15px; background: #26221b;
			border-right: 1px solid rgba(181,131,11,0.25); border-bottom: 1px solid rgba(181,131,11,0.25);
			transform: rotate(45deg);
		}
		@media (max-width: 500px) {
			#amsurveys-bot-nudge { width: calc(100vw - 28px); right: 14px; bottom: 84px; padding: 12px; }
			#amsurveys-nudge-botwrap { flex-basis: 104px; width: 104px; }
			#amsurveys-nudge-copy { font-size: 13px; }
		}

		/* Avatar inside header */
		.amsurveys-header .amsurveys-avatar {
		  width: 26px;
		  height: 26px;
		  border-radius: 50%;
		  object-fit: cover;
		}

		/* Minimise button */
		.amsurveys-min-btn {
		  margin-left: 0;
		  cursor: pointer;
		  font-size: 18px;
		  font-weight: 700;
		  width: 34px;
		  height: 34px;
		  padding: 0;
		  color: #fff;
		  border: 1px solid rgba(255,255,255,0.14);
		  border-radius: 6px;
		  background: rgba(255,255,255,0.08);
		  line-height: 1;
		  user-select: none;
		  display: inline-flex;
		  align-items: center;
		  justify-content: center;
		}

		.amsurveys-min-btn:hover,
		.amsurveys-min-btn:focus {
		  background: rgba(255,255,255,0.18);
		  outline: none;
		}

		/* Left-side call button wrapper */
		#amsurveys-call-launch {
		  position: fixed;
		  bottom: 20px;
		  left: 20px;
		  display: flex;
		  align-items: center;
		  gap: 8px;
		  z-index: 10001;
		  cursor: pointer;
		}

		/* Circle button */
		#amsurveys-call-btn {
		  width: 56px;
		  height: 56px;
		  border-radius: 50%;
		  background: #b5830b;
		  display: flex;
		  align-items: center;
		  justify-content: center;
		  box-shadow: 0 6px 18px rgba(0,0,0,0.25); /* match chat */
		  transition: transform 0.15s ease;
		}
		#amsurveys-call-btn:hover {
		  transform: scale(1.07);
		}

		/* SVG icon */
		#amsurveys-call-btn svg {
		  width: 26px;
		  height: 26px;
		  fill: white;
		}

		/* Label next to it */
		#amsurveys-call-label {
		  background: #fff;
		  color: #b5830b;
		  font-weight: 600;
		  border: 1px solid #ddd;
		  border-radius: 8px;
		  padding: 8px 12px;
		  font-size: 13px;
		  font-family: "Noto Sans", Arial, sans-serif;
		  box-shadow: 0 4px 12px rgba(0,0,0,.15);
		  animation: amsurveysFadeIn .3s ease;
		}

		/* Optional: hide label on small screens */
		@media (max-width:480px){ #amsurveys-call-label{ display:none; } }

		@keyframes amsurveysFadeIn {
		  from { opacity:0; transform:translateY(4px) }
		  to { opacity:1; transform:translateY(0) }
		}

		/* Hide chat + call labels on small screens */
		@media (max-width: 580px) {
		  #amsurveys-chat-label,
		  #amsurveys-call-label {
			display: none !important;
		  }
		}

		/*
		 * TEMPORARY CLIENT-PREVIEW LIGHT THEME
		 * Remove this entire block when the site-wide dark theme is uploaded.
		 * All overrides are confined to the AI widget.
		 */
		#amsurveys-chat-box {
			background: #fff;
			color: #242424;
			border-color: rgba(181,131,11,.5);
			box-shadow: 0 18px 48px rgba(0,0,0,.2);
		}
		.amsurveys-header {
			background: #fff;
			color: #242424;
			border-bottom-color: #e6e0d3;
		}
		.amsurveys-header > svg { stroke: #6f5410; }
		.amsurveys-voice-btn,
		.amsurveys-min-btn {
			background: #f5f2eb;
			border-color: #d8d1c4;
			color: #242424;
		}
		.amsurveys-voice-btn:hover,
		.amsurveys-voice-btn:focus,
		.amsurveys-min-btn:hover,
		.amsurveys-min-btn:focus {
			background: #ece6d9;
			border-color: #c7b98f;
		}
		.amsurveys-voice-btn.is-muted {
			background: #b5830b;
			border-color: #b5830b;
			color: #fff;
		}
		.amsurveys-albot-band::after {
			background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 48%, rgba(255,255,255,.65) 78%, #fff 100%);
		}
		#amsurveys-chat-messages {
			background: #fff;
			color: #242424;
			scrollbar-color: #b5830b #eee9df;
		}
		.amsurveys-msg {
			border-color: #ddd6ca;
			box-shadow: 0 5px 14px rgba(0,0,0,.08);
		}
		.amsurveys-msg b { color: #745607; }
		.amsurveys-msg.amsurveys-ai {
			background: #f5f2eb;
			color: #242424;
		}
		.amsurveys-msg.amsurveys-error {
			background: #fff3f3;
			color: #672020;
			border-color: #e6b7b7;
		}
		.amsurveys-msg.amsurveys-success {
			background: #f0faf2;
			color: #24542f;
			border-color: #b8d9bf;
		}
		.amsurveys-chat-action,
		.amsurveys-form-cancel {
			background: #f1ede5;
			color: #242424;
			border-color: #d8d1c4;
		}
		.amsurveys-chat-action:hover,
		.amsurveys-chat-action:focus,
		.amsurveys-form-cancel:hover,
		.amsurveys-form-cancel:focus {
			background: #e5ded1;
		}
		.amsurveys-chat-action.is-primary {
			background: #b5830b;
			border-color: #b5830b;
			color: #fff;
		}
		.amsurveys-input-wrap {
			background: #f8f6f1;
			border-top-color: #ddd6ca;
		}
		#amsurveys-chat-input,
		#amsurveys-contact-form input,
		#amsurveys-contact-form textarea {
			background: #fff;
			color: #242424;
			border-color: #cfc7ba;
		}
		#amsurveys-chat-input::placeholder { color: #777; }
		#amsurveys-contact-form {
			background: #fff;
			color: #242424;
		}
		.amsurveys-form-title { color: #242424; }
		.amsurveys-form-field { color: #4c4c4c; }
		#amsurveys-bot-nudge {
			background: #fff;
			border-color: #d8d1c4;
			box-shadow: 0 16px 42px rgba(0,0,0,.18);
		}
		#amsurveys-nudge-copy { color: #242424; }
		#amsurveys-bot-nudge::after {
			background: #fff;
			border-color: #d8d1c4;
		}
