.nc-ai {
	position: fixed;
	inset-block-end: 18px;
	z-index: 280;
	font-family: var(--nc-font-b, system-ui, -apple-system, "Segoe UI", sans-serif);
}

/* Physical sides: the setting must not flip with the document direction. */
.nc-ai--bottom-right { right: 18px; left: auto; }
.nc-ai--bottom-left { left: 18px; right: auto; }

.nc-ai--bottom-right .nc-ai__panel { right: 0; left: auto; }
.nc-ai--bottom-left .nc-ai__panel { left: 0; right: auto; }

.nc-ai__toggle {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 48px;
	padding: 11px 18px;
	border: 0;
	border-radius: 999px;
	background: var(--nc-ai-brand, var(--nc-btn, #1b1b1f));
	color: var(--nc-ai-brand-txt, var(--nc-btn-txt, #fff));
	font: 700 14px/1 var(--nc-font-b, system-ui, sans-serif);
	cursor: pointer;
	box-shadow: 0 12px 30px rgba(16, 24, 40, .24);
}

.nc-ai__toggle:hover { filter: brightness(1.1); }
/* Theme button resets (e.g. `.tpl-fashion button`) outrank the single-class
   rule above; keep the launcher readable on every skin. */
.nc-ai .nc-ai__toggle {
	background: var(--nc-ai-brand, var(--nc-btn, #1b1b1f));
	color: var(--nc-ai-brand-txt, var(--nc-btn-txt, #fff));
}
.nc-ai__toggle:focus-visible { outline: 3px solid var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); outline-offset: 3px; }

.nc-ai__panel {
	position: absolute;
	inset-block-end: 62px;
	display: flex;
	flex-direction: column;
	width: min(380px, calc(100vw - 32px));
	max-height: min(72vh, 580px);
	overflow: hidden;
	border: 1px solid var(--nc-line, #e3e9ee);
	border-radius: var(--nc-r, 16px);
	background: var(--nc-surface-2, #fff);
	color: var(--nc-ink, #1b1b1f);
	box-shadow: 0 24px 60px rgba(16, 24, 40, .28);
}

.nc-ai__panel[hidden] { display: none; }

.nc-ai__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	border-block-end: 1px solid var(--nc-line, #e3e9ee);
	background: var(--nc-surface, #f6f6f8);
}

.nc-ai__identity { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nc-ai__title { margin: 0; font-size: 17px; line-height: 1.4; }
.nc-ai__subtitle {
	margin: 0;
	color: var(--nc-muted, #6b6470);
	font-size: 12px;
	line-height: 1.5;
}
.nc-ai__close {
	flex: 0 0 auto;
	width: 38px;
	height: 38px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--nc-muted, #77707d);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}
.nc-ai__close:hover { color: var(--nc-ink, #1b1b1f); background: var(--nc-line, #e3e9ee); }
.nc-ai__close:focus-visible { outline: 3px solid var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); outline-offset: 1px; }

.nc-ai__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; }
.nc-ai__clear {
	min-height: 34px;
	padding: 4px 9px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--nc-muted, #6b6470);
	font: 600 12px/1.4 var(--nc-font-b, system-ui, sans-serif);
	cursor: pointer;
}
.nc-ai__clear:hover { color: var(--nc-ink, #1b1b1f); background: var(--nc-line, #e3e9ee); }
.nc-ai__clear:focus-visible { outline: 3px solid var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); outline-offset: 1px; }

.nc-ai__log {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 150px;
	padding: 14px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.nc-ai__msg { display: flex; }
.nc-ai__msg--user { justify-content: flex-end; }
.nc-ai__bubble {
	max-width: 88%;
	padding: 9px 12px;
	border-radius: 13px;
	background: var(--nc-surface, #f1f2f5);
	color: var(--nc-ink, #1b1b1f);
	font-size: 14px;
	line-height: 1.7;
	white-space: pre-line;
	overflow-wrap: anywhere;
}
.nc-ai__msg--user .nc-ai__bubble {
	background: var(--nc-ai-brand, var(--nc-btn, #1b1b1f));
	color: var(--nc-ai-brand-txt, #fff);
}
.nc-ai__bubble--wait { color: var(--nc-muted, #6b6470); }
.nc-ai__wait-text { font-variant-numeric: tabular-nums; }
.nc-ai__retry {
	display: block;
	margin-block-start: 8px;
	padding: 6px 10px;
	border: 1px solid currentColor;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font: 600 12px/1.4 var(--nc-font-b, system-ui, sans-serif);
	cursor: pointer;
}
.nc-ai__retry:hover { background: rgba(0, 0, 0, .06); }
.nc-ai__retry:focus-visible { outline: 3px solid var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); outline-offset: 2px; }

.nc-ai__prompts {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 0 14px 12px;
}
.nc-ai__prompt {
	max-width: 100%;
	padding: 7px 11px;
	border: 1px solid var(--nc-ai-brand, var(--nc-line, #e3e9ee));
	border-radius: 999px;
	background: transparent;
	color: var(--nc-ai-brand, var(--nc-btn, #1b1b1f));
	font: 600 12px/1.4 var(--nc-font-b, system-ui, sans-serif);
	text-align: start;
	cursor: pointer;
	overflow-wrap: anywhere;
}
.nc-ai__prompt:hover { background: color-mix(in srgb, var(--nc-ai-brand, #1b1b1f) 10%, transparent); }
.nc-ai__prompt:focus-visible { outline: 3px solid var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); outline-offset: 2px; }
.nc-ai__prompt[hidden] { display: none; }

.nc-ai__product {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px;
	border: 1px solid var(--nc-line, #e3e9ee);
	border-radius: 12px;
	background: var(--nc-surface-2, #fff);
}
.nc-ai__product-link {
	display: flex;
	align-items: center;
	gap: 10px;
	color: inherit;
	text-decoration: none;
}
.nc-ai__product-link img { width: 64px; height: 64px; object-fit: cover; border-radius: 9px; flex: 0 0 auto; }
.nc-ai__product-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nc-ai__product-name { font-size: 14px; line-height: 1.5; }
.nc-ai__product-price { color: var(--nc-muted, #6b6470); font-size: 13px; }
.nc-ai__product-was { margin-inline-end: 6px; font-size: 12px; opacity: .75; }
.nc-ai__product-actions { display: flex; justify-content: flex-end; }
.nc-ai__add {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	padding: 6px 12px;
	border-radius: 8px;
	background: var(--nc-ai-brand, var(--nc-btn, #1b1b1f));
	color: var(--nc-ai-brand-txt, var(--nc-btn-txt, #fff));
	font-size: 12px;
	font-weight: 700;
	text-decoration: none;
}
.nc-ai__add:hover { filter: brightness(1.12); }
.nc-ai__add:focus-visible { outline: 3px solid var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); outline-offset: 2px; }

.nc-ai__form {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-block-start: 1px solid var(--nc-line, #e3e9ee);
	background: var(--nc-surface-2, #fff);
}
.nc-ai__form input {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	padding: 0 12px;
	border: 1px solid var(--nc-line, #e3e9ee);
	border-radius: 10px;
	background: var(--nc-surface, #f6f6f8);
	color: var(--nc-ink, #1b1b1f);
	font-size: 16px;
}
.nc-ai__form input:focus { outline: 0; border-color: var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nc-ai-brand, #8e6a9a) 22%, transparent); }
.nc-ai__form button {
	flex: 0 0 auto;
	min-height: 44px;
	padding: 0 16px;
	border: 0;
	border-radius: 10px;
	background: var(--nc-ai-brand, var(--nc-btn, #1b1b1f));
	color: var(--nc-ai-brand-txt, #fff);
	font-weight: 700;
	cursor: pointer;
}
.nc-ai__form button:disabled { opacity: .6; cursor: wait; }
.nc-ai__form button:focus-visible { outline: 3px solid var(--nc-ai-brand, var(--nc-accent, #8e6a9a)); outline-offset: 2px; }
.nc-ai__hint { margin: 0; padding: 0 14px 6px; color: var(--nc-muted, #6b6470); font-size: 11px; line-height: 1.6; }
.nc-ai__privacy { margin: 0; padding: 0 14px 12px; color: var(--nc-muted, #6b6470); font-size: 11px; line-height: 1.6; }

.nc-ai-visual { margin-block-start: 16px; padding-block-start: 14px; border-block-start: 1px solid var(--nc-line, #e3e9ee); }
.nc-ai-visual__btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 42px;
	padding: 8px 14px;
	border: 1px solid var(--nc-line, #e3e9ee);
	border-radius: 10px;
	background: var(--nc-surface, #f6f6f8);
	color: var(--nc-ink, #1b1b1f);
	font: 600 14px/1 var(--nc-font-b, system-ui, sans-serif);
	cursor: pointer;
}
.nc-ai-visual__btn:hover { border-color: var(--nc-accent, #8e6a9a); }
.nc-ai-visual__btn:focus-visible { outline: 3px solid var(--nc-accent, #8e6a9a); outline-offset: 2px; }
.nc-ai-visual__btn:disabled { opacity: .6; cursor: wait; }
.nc-ai-visual__status { margin: 10px 0 0; color: var(--nc-muted, #6b6470); font-size: 13px; line-height: 1.6; }
.nc-ai-visual__results { display: grid; gap: 10px; max-height: 260px; margin-block-start: 10px; overflow-y: auto; }

@media (max-width: 480px) {
	.nc-ai { inset-block-end: 12px; }
	.nc-ai--bottom-right { right: 12px; }
	.nc-ai--bottom-left { left: 12px; }
	.nc-ai__toggle-text { display: none; }
	.nc-ai__toggle { width: 52px; height: 52px; justify-content: center; padding: 0; }
	/* Fixed + symmetric insets: `100vw` includes the scrollbar and clipped the
	   panel by ~15px on phones. Physical left/right keep the setting stable. */
	.nc-ai__panel {
		position: fixed;
		inset-block-end: 76px;
		left: 12px;
		right: 12px;
		width: auto;
		max-height: 74vh;
	}
	.nc-ai--bottom-right .nc-ai__panel,
	.nc-ai--bottom-left .nc-ai__panel { left: 12px; right: 12px; }
}
