/*
 * Tainacan Acervo em Cena — base styles.
 * Look: light and airy. The "stage" is a soft lavender-grey surface with
 * rounded corners and gentle shadows; tools float on white pills; the record
 * uses pastel chips (mint, lilac, peach, sky). One modern accent (violet)
 * plus the pastels; no dark surfaces.
 */
:root {
	--aec-accent: #5b4ee0;
	--aec-accent-ink: #4a3fc4;
	--aec-accent-soft: #ece9fd;
	--aec-ink: #24223a;
	--aec-ink-2: #625e7c;
	--aec-paper: #ffffff;
	--aec-paper-2: #f6f5fb;
	--aec-rule: #e6e3f1;
	--aec-radius: 12px;
	--aec-radius-lg: 22px;
	--aec-shadow: 0 1px 2px rgba(52, 44, 110, 0.06), 0 10px 28px rgba(52, 44, 110, 0.08);
	--aec-shadow-lift: 0 2px 4px rgba(52, 44, 110, 0.08), 0 16px 36px rgba(52, 44, 110, 0.14);

	--aec-pastel-lilac: #efebfd;
	--aec-pastel-mint: #e2f4ef;
	--aec-pastel-peach: #fdebe2;
	--aec-pastel-sky: #e4eefb;
	--aec-pastel-butter: #fff4cf;

	--aec-stage: #f3f2f9;
	--aec-stage-2: #ffffff;
	--aec-stage-3: #ebe8f6;
	--aec-stage-rule: #e1ddf0;
	--aec-stage-fg: #2a2840;
	--aec-stage-fg-2: #67637f;
	--aec-stage-accent: #6a5cf0;
	--aec-mark: #ffd96a;
	--aec-mark-ink: #3b2f00;

	--aec-good: #2c8a63;
	--aec-warn: #a5661a;
	--aec-crit: #c0473a;

	--aec-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	--aec-stage-h: min(74vh, 740px);
}

.aec-item,
.aec-drawer,
.aec-compare,
.aec-mode {
	box-sizing: border-box;
}
.aec-item *,
.aec-drawer *,
.aec-compare *,
.aec-mode * {
	box-sizing: inherit;
}

.aec-main {
	display: block;
}

/* ---------- Page frame ---------- */
.aec-item {
	max-width: min(1400px, 100%);
	margin: 0 auto;
	padding: 24px max(16px, 4vw) 64px;
	display: grid;
	gap: 22px;
	color: var(--aec-ink);
}
.aec-crumbs {
	font-size: 0.875rem;
	color: var(--aec-ink-2);
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}
.aec-crumbs a {
	color: var(--aec-accent-ink);
}
.aec-head {
	display: grid;
	gap: 6px;
}
.aec-title {
	margin: 0;
	font-size: clamp(1.7rem, 3.2vw, 2.6rem);
	line-height: 1.15;
	text-wrap: balance;
	font-weight: 600;
}
.aec-headline {
	margin: 0;
	color: var(--aec-ink-2);
	font-size: 1.05rem;
}
.aec-subtitle {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px 14px;
	margin: 0 0 4px;
}
.aec-subtitle-name {
	font-size: 1.35rem;
	font-weight: 600;
	color: var(--aec-ink);
	text-wrap: balance;
}
.aec-subtitle-reg {
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--aec-pastel-butter);
	color: var(--aec-mark-ink);
	font-size: 0.82rem;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
}
.aec-h2 {
	font-size: 1.15rem;
	margin: 0 0 10px;
	font-weight: 600;
}

/* ---------- Stage ---------- */
.aec-stage {
	background: var(--aec-stage);
	color: var(--aec-stage-fg);
	border-radius: 10px;
	overflow: hidden;
	display: grid;
	min-width: 0;
	view-transition-name: aec-stage;
}
.aec-stage-canvas {
	position: relative;
	height: var(--aec-stage-h);
	min-height: 280px;
	display: grid;
	place-items: center;
	overflow: hidden;
}
/* With a stage module mounted, the canvas is a full-width block: viewers
   (PDF.js, OpenSeadragon) measure their container when they start. */
:where(.aec-stage[data-stage]) > .aec-stage-canvas {
	display: block;
}
:where(.aec-stage[data-stage] > .aec-stage-canvas) > * {
	width: 100%;
	max-width: 100%;
}
.aec-stage-canvas > .aec-stage-fallback {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}
.aec-text-fallback {
	background: #f7f3ea;
	color: #2a241b;
	max-width: 72ch;
	padding: 32px;
	overflow: auto;
	height: 100%;
}
.aec-stage-empty {
	color: var(--aec-stage-fg-2);
}
.aec-stage-loading {
	color: var(--aec-stage-fg-2);
	font-family: var(--aec-mono);
	font-size: 0.8rem;
}
.aec-stage-error {
	color: var(--aec-stage-fg);
	background: var(--aec-stage-2);
	padding: 16px 20px;
	border-radius: 8px;
	max-width: 52ch;
}
.aec-stage-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	padding: 8px 10px;
	background: var(--aec-stage-2);
	border-top: 1px solid var(--aec-stage-rule);
	min-height: 48px;
}
.aec-stage-bar .aec-spacer {
	flex: 1;
}
.aec-stage-side {
	background: var(--aec-stage-2);
	border-top: 1px solid var(--aec-stage-rule);
	padding: 14px 16px;
	color: var(--aec-stage-fg);
	min-width: 0;
}
.aec-tool {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font: inherit;
	font-size: 0.875rem;
	line-height: 1;
	color: var(--aec-stage-fg);
	background: transparent;
	border: 1px solid transparent;
	border-radius: 6px;
	padding: 7px 9px;
	cursor: pointer;
	min-height: 34px;
}
.aec-tool:hover {
	background: var(--aec-stage-3);
}
.aec-tool[aria-pressed="true"] {
	background: var(--aec-stage-accent);
	color: var(--aec-stage);
}
.aec-tool[disabled] {
	opacity: 0.45;
	cursor: default;
}
.aec-tool.has-text {
	border-color: var(--aec-stage-rule);
}
.aec-readout {
	font-family: var(--aec-mono);
	font-size: 0.75rem;
	color: var(--aec-stage-fg-2);
	font-variant-numeric: tabular-nums;
}
.aec-stage :focus-visible,
.aec-drawer :focus-visible,
.aec-mode :focus-visible {
	outline: 3px solid var(--aec-stage-accent);
	outline-offset: 2px;
}
.aec-badge-machine {
	display: inline-block;
	font-family: var(--aec-mono);
	font-size: 0.7rem;
	letter-spacing: 0.02em;
	padding: 2px 7px;
	border: 1px solid var(--aec-mark);
	color: var(--aec-mark);
	border-radius: 4px;
}

/* ---------- Strip of files ---------- */
.aec-strip ol {
	list-style: none;
	margin: 0;
	padding: 2px 2px 8px;
	display: flex;
	gap: 10px;
	overflow-x: auto;
}
.aec-strip-item {
	display: grid;
	gap: 6px;
	width: 112px;
	text-decoration: none;
	color: var(--aec-ink);
	font-size: 0.8rem;
}
.aec-strip-item img,
.aec-strip-kind {
	width: 112px;
	height: 84px;
	object-fit: cover;
	border-radius: 6px;
	background: var(--aec-paper-2);
	border: 2px solid transparent;
	display: block;
}
.aec-strip-item[aria-current="true"] img,
.aec-strip-item[aria-current="true"] .aec-strip-kind {
	border-color: var(--aec-accent);
}
.aec-strip-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---------- Body: record + threads ---------- */
.aec-body {
	display: grid;
	gap: 40px;
	grid-template-columns: minmax(0, 1fr);
	margin-top: 10px;
}
@media (min-width: 960px) {
	.aec-body {
		grid-template-columns: minmax(0, 1fr) 320px;
		gap: 56px;
	}
}
.aec-record {
	display: grid;
	gap: 18px;
	align-content: start;
	min-width: 0;
	max-width: 78ch;
}
.aec-essential,
.aec-fields {
	margin: 0;
	display: grid;
	grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr);
	gap: 10px 18px;
	font-size: 1rem;
	line-height: 1.5;
}
.aec-essential dt,
.aec-fields dt {
	color: var(--aec-ink-2);
	font-weight: 400;
}
.aec-essential dd,
.aec-fields dd {
	margin: 0;
	min-width: 0;
	overflow-wrap: anywhere;
}
.aec-essential dd {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
@media (max-width: 520px) {
	.aec-essential,
	.aec-fields {
		grid-template-columns: minmax(0, 1fr);
		gap: 2px;
	}
	.aec-essential dd,
	.aec-fields dd {
		margin-bottom: 10px;
	}
}
.aec-facet {
	color: var(--aec-ink);
	text-decoration: none;
	border: 1px solid var(--aec-rule);
	border-radius: 999px;
	padding: 1px 10px;
	font-size: 0.95rem;
}
.aec-facet:hover,
.aec-facet:focus-visible {
	border-color: var(--aec-accent);
	color: var(--aec-accent-ink);
}
.aec-hint {
	margin: -6px 0 0;
	font-size: 0.85rem;
	color: var(--aec-ink-2);
}
.aec-description {
	font-size: 1.05rem;
	line-height: 1.65;
}
.aec-section {
	border-top: 1px solid var(--aec-rule);
	padding-top: 10px;
}
/* Slots other plugins fill around the sections (print button, provenance). */
.aec-section-slot {
	margin: 10px 0;
}
.aec-section > summary {
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	gap: 12px;
	font-weight: 600;
	padding: 4px 0;
	list-style: none;
}
.aec-section > summary::-webkit-details-marker {
	display: none;
}
.aec-section > summary::before {
	content: "▸";
	color: var(--aec-accent);
	margin-right: 8px;
	transition: transform 0.15s;
}
.aec-section[open] > summary::before {
	transform: rotate(90deg);
	display: inline-block;
}
.aec-section-name {
	flex: 1;
}
.aec-section-count {
	font-weight: 400;
	color: var(--aec-ink-2);
	font-family: var(--aec-mono);
	font-size: 0.8rem;
}
.aec-section .aec-fields {
	margin-top: 12px;
}

/* ---------- Citation ---------- */
.aec-cite {
	background: var(--aec-paper-2);
	border-radius: 8px;
	padding: 16px;
	display: grid;
	gap: 10px;
}
.aec-cite .aec-h2 {
	margin: 0;
}
.aec-cite-styles {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}
.aec-cite-tab {
	font: inherit;
	font-size: 0.8rem;
	padding: 4px 10px;
	border-radius: 999px;
	border: 1px solid var(--aec-rule);
	background: transparent;
	color: var(--aec-ink);
	cursor: pointer;
}
.aec-cite-tab[aria-selected="true"] {
	background: var(--aec-accent);
	border-color: var(--aec-accent);
	color: #fff;
}
.aec-cite-text {
	margin: 0;
	font-size: 0.95rem;
	line-height: 1.55;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}
.aec-cite-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}
.aec-cite-fragment {
	font-size: 0.85rem;
	color: var(--aec-ink-2);
}
.aec-btn {
	font: inherit;
	font-size: 0.9rem;
	border: 1px solid var(--aec-accent);
	color: var(--aec-accent-ink);
	background: transparent;
	border-radius: var(--aec-radius);
	padding: 6px 14px;
	cursor: pointer;
}
.aec-btn:hover {
	background: color-mix(in srgb, var(--aec-accent) 12%, transparent);
}
.aec-btn.is-primary,
body a.aec-btn.is-primary,
body a.aec-btn.is-primary:visited,
body a.aec-btn.is-primary:hover,
body a.aec-btn.is-primary:focus {
	background: var(--aec-accent);
	color: #fff;
	text-decoration: none;
}
body a.aec-btn {
	text-decoration: none;
	display: inline-block;
}
.aec-btn[disabled] {
	opacity: 0.5;
	cursor: default;
}

/* ---------- Threads ---------- */
.aec-threads {
	display: grid;
	gap: 22px;
	align-content: start;
}
.aec-thread h3 {
	font-size: 0.95rem;
	margin: 0 0 8px;
	font-weight: 600;
}
.aec-thread h3 small {
	font-weight: 400;
	color: var(--aec-ink-2);
}
.aec-thread-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	list-style: none;
	margin: 0;
	padding: 0;
}
.aec-thread-grid a {
	display: grid;
	gap: 4px;
	text-decoration: none;
	color: var(--aec-ink);
	font-size: 0.75rem;
	line-height: 1.3;
}
.aec-thread-grid img,
.aec-thread-grid .aec-noimg {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: 6px;
	background: var(--aec-paper-2);
	display: block;
}
.aec-thread-grid span {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.aec-prevnext {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}
.aec-prevnext a {
	border: 1px solid var(--aec-rule);
	border-radius: 8px;
	padding: 8px 10px;
	text-decoration: none;
	color: var(--aec-ink);
	font-size: 0.85rem;
	display: grid;
	gap: 2px;
}
.aec-prevnext a small {
	color: var(--aec-ink-2);
}
.aec-prevnext a.is-next {
	text-align: right;
}

/* ---------- AI layer (I06) ---------- */
.aec-ai {
	border: 1px dashed var(--aec-warn);
	border-radius: 8px;
	padding: 14px 16px;
	display: grid;
	gap: 10px;
}
.aec-ai .aec-badge-ai {
	font-family: var(--aec-mono);
	font-size: 0.72rem;
	color: var(--aec-warn);
	border: 1px solid var(--aec-warn);
	border-radius: 4px;
	padding: 1px 6px;
	justify-self: start;
}
.aec-ai textarea {
	width: 100%;
	min-height: 64px;
	font: inherit;
	padding: 8px 10px;
	border: 1px solid var(--aec-rule);
	border-radius: 6px;
}
.aec-ai-answer {
	white-space: pre-wrap;
	line-height: 1.55;
}

/* ---------- Toast ---------- */
.aec-toast {
	position: fixed;
	left: 50%;
	bottom: calc(18px + env(safe-area-inset-bottom, 0px));
	transform: translate(-50%, 20px);
	background: #13201f;
	color: #fff;
	padding: 10px 16px;
	border-radius: 8px;
	font-size: 0.9rem;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s, transform 0.2s;
	z-index: 100000;
	max-width: calc(100vw - 32px);
}
.aec-toast.is-on {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ---------- Comparison tray (L09) ---------- */
.aec-tray {
	position: fixed;
	right: calc(16px + env(safe-area-inset-right, 0px));
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	z-index: 99990;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	max-width: calc(100vw - 32px);
	background: var(--aec-paper);
	color: var(--aec-ink);
	border: 1px solid var(--aec-rule);
	border-radius: 10px;
	padding: 10px 12px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
	font-size: 0.9rem;
}
.aec-tray-title {
	font-weight: 600;
}
.aec-tray-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	gap: 6px;
}
.aec-tray-list li {
	position: relative;
}
.aec-tray-list img,
.aec-tray-list .aec-noimg {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 5px;
	display: block;
	background: var(--aec-paper-2);
}
.aec-tray-remove {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	border: 0;
	padding: 0;
	display: grid;
	place-items: center;
	background: var(--aec-ink);
	color: var(--aec-paper);
	cursor: pointer;
}
.aec-tray-remove .aec-icon {
	width: 12px;
	height: 12px;
}
.aec-tray-hint {
	color: var(--aec-ink-2);
	font-size: 0.85rem;
}
.aec-stage-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
}
.aec-stage-error-thumb {
	max-width: 220px;
	border-radius: 6px;
	display: block;
	margin-bottom: 10px;
}
.aec-embed {
	width: 100%;
	height: 100%;
	display: grid;
	place-items: center;
}
.aec-embed iframe {
	width: 100%;
	height: 100%;
	border: 0;
}
.aec-thread-more {
	margin: 6px 0 0;
	font-size: 0.85rem;
}
.aec-ai-answer.is-error {
	color: var(--aec-crit);
}
.aec-ai-form {
	display: grid;
	gap: 8px;
}

.aec-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

@view-transition {
	navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
	.aec-item *,
	.aec-drawer *,
	.aec-mode * {
		transition: none !important;
		animation: none !important;
	}
	@view-transition {
		navigation: none;
	}
}

/* =====================================================================
   Soft, light finish (pastel). Overrides the structural rules above.
   ===================================================================== */
.aec-item {
	gap: 26px;
}
.aec-title {
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--aec-ink);
}
.aec-headline {
	color: var(--aec-ink-2);
}
.aec-stage {
	background: linear-gradient(180deg, #f8f7fc 0%, var(--aec-stage) 100%);
	border-radius: var(--aec-radius-lg);
	border: 1px solid var(--aec-stage-rule);
	box-shadow: var(--aec-shadow);
}
.aec-stage-bar {
	background: rgba(255, 255, 255, 0.86);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	border-top: 1px solid var(--aec-stage-rule);
	padding: 10px 12px;
	gap: 6px;
}
.aec-tool {
	border-radius: 999px;
	padding: 8px 11px;
	color: var(--aec-stage-fg);
	transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.aec-tool:hover {
	background: var(--aec-pastel-lilac);
	color: var(--aec-accent-ink);
}
.aec-tool[aria-pressed="true"] {
	background: var(--aec-accent-soft);
	color: var(--aec-accent-ink);
	box-shadow: inset 0 0 0 1px #d8d2fb;
}
.aec-tool.has-text {
	border-color: var(--aec-stage-rule);
	background: #ffffff;
}
.aec-stage-side {
	background: #ffffff;
	border-top: 1px solid var(--aec-stage-rule);
}
.aec-stage-error {
	background: #ffffff;
	border: 1px solid var(--aec-stage-rule);
	border-radius: var(--aec-radius);
	box-shadow: var(--aec-shadow);
	color: var(--aec-stage-fg);
}
.aec-badge-machine {
	border-color: #e8b54a;
	color: #8a5a00;
	background: var(--aec-pastel-butter);
	border-radius: 999px;
}

/* Strip of files */
.aec-strip-item img,
.aec-strip-kind {
	border-radius: 14px;
	border-width: 3px;
	box-shadow: var(--aec-shadow);
	transition: transform 0.15s, box-shadow 0.15s;
}
.aec-strip-item:hover img,
.aec-strip-item:hover .aec-strip-kind {
	transform: translateY(-2px);
	box-shadow: var(--aec-shadow-lift);
}
.aec-strip-kind {
	background: linear-gradient(135deg, var(--aec-pastel-lilac), var(--aec-pastel-sky));
}

/* Record */
.aec-essential dt,
.aec-fields dt {
	color: var(--aec-ink-2);
	font-size: 0.92rem;
}
.aec-facet {
	background: var(--aec-pastel-lilac);
	border-color: transparent;
	color: var(--aec-accent-ink);
	padding: 3px 12px;
	font-size: 0.93rem;
	transition: background-color 0.15s, box-shadow 0.15s;
}
.aec-essential dd:nth-of-type(2n) .aec-facet {
	background: var(--aec-pastel-mint);
	color: #1f6f5c;
}
.aec-essential dd:nth-of-type(3n) .aec-facet {
	background: var(--aec-pastel-peach);
	color: #9a4a2a;
}
.aec-facet:hover,
.aec-facet:focus-visible {
	border-color: transparent;
	box-shadow: 0 0 0 2px var(--aec-accent);
	color: var(--aec-accent-ink);
}
.aec-section {
	border: 1px solid var(--aec-rule);
	border-radius: var(--aec-radius);
	padding: 12px 16px;
	background: #ffffff;
	box-shadow: 0 1px 2px rgba(52, 44, 110, 0.04);
}
.aec-section[open] {
	box-shadow: var(--aec-shadow);
}
.aec-section > summary::before {
	content: "+";
	font-weight: 700;
	width: 1.2em;
	display: inline-block;
	color: var(--aec-accent);
}
.aec-section[open] > summary::before {
	content: "–";
	transform: none;
}
.aec-cite {
	background: linear-gradient(135deg, var(--aec-pastel-lilac) 0%, var(--aec-pastel-sky) 100%);
	border-radius: var(--aec-radius-lg);
	padding: 20px 22px;
	box-shadow: var(--aec-shadow);
}
.aec-cite-tab {
	background: rgba(255, 255, 255, 0.7);
	border-color: transparent;
	transition: background-color 0.15s;
}
.aec-cite-tab:hover {
	background: #ffffff;
}
.aec-cite-tab[aria-selected="true"] {
	background: var(--aec-accent);
	color: #ffffff;
}
.aec-cite-text {
	background: rgba(255, 255, 255, 0.75);
	border-radius: var(--aec-radius);
	padding: 12px 14px;
}
.aec-btn {
	border-radius: 999px;
	padding: 8px 18px;
	font-weight: 600;
	border-color: var(--aec-accent);
	color: var(--aec-accent-ink);
	background: #ffffff;
	transition: background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.aec-btn:hover {
	background: var(--aec-accent-soft);
}
.aec-btn.is-primary,
body a.aec-btn.is-primary,
body a.aec-btn.is-primary:visited,
body a.aec-btn.is-primary:hover,
body a.aec-btn.is-primary:focus {
	background: linear-gradient(135deg, #6a5cf0 0%, #5b4ee0 100%);
	border-color: transparent;
	color: #ffffff;
	box-shadow: 0 6px 16px rgba(91, 78, 224, 0.28);
}
.aec-btn.is-primary:hover {
	transform: translateY(-1px);
}

/* Threads */
.aec-threads {
	background: var(--aec-paper-2);
	border-radius: var(--aec-radius-lg);
	padding: 20px;
	align-self: start;
}
.aec-thread-grid img,
.aec-thread-grid .aec-noimg {
	border-radius: 14px;
	box-shadow: var(--aec-shadow);
	transition: transform 0.15s, box-shadow 0.15s;
	background: linear-gradient(135deg, var(--aec-pastel-lilac), var(--aec-pastel-mint));
}
.aec-thread-grid a:hover img {
	transform: translateY(-2px) scale(1.02);
	box-shadow: var(--aec-shadow-lift);
}
.aec-prevnext a {
	background: #ffffff;
	border-color: transparent;
	border-radius: var(--aec-radius);
	box-shadow: var(--aec-shadow);
}

/* AI layer */
.aec-ai {
	border: 0;
	background: linear-gradient(135deg, var(--aec-pastel-butter) 0%, var(--aec-pastel-peach) 100%);
	border-radius: var(--aec-radius-lg);
	padding: 18px 20px;
	box-shadow: var(--aec-shadow);
}
.aec-ai .aec-badge-ai {
	background: #ffffff;
	border-color: #e3a05c;
	color: #8a4d12;
	border-radius: 999px;
	padding: 2px 10px;
}
.aec-ai textarea {
	background: #ffffff;
	color: var(--aec-ink);
	border: 1px solid #f0d6c4;
	border-radius: var(--aec-radius);
	color-scheme: light;
}
.aec-ai-desc {
	background: rgba(255, 255, 255, 0.7);
	border-radius: var(--aec-radius);
	padding: 12px 14px;
}

/* Tray and toast */
.aec-tray {
	border-radius: 999px;
	border-color: var(--aec-rule);
	box-shadow: var(--aec-shadow-lift);
	padding: 8px 10px 8px 18px;
}
.aec-tray-list img,
.aec-tray-list .aec-noimg {
	border-radius: 50%;
	border: 2px solid #ffffff;
	box-shadow: 0 1px 4px rgba(52, 44, 110, 0.18);
}
.aec-toast {
	background: #ffffff;
	color: var(--aec-ink);
	border-radius: 999px;
	box-shadow: var(--aec-shadow-lift);
	border: 1px solid var(--aec-rule);
}

/* Real-size calibration dialog (shared by I08 and I09, built by aec-core). */
.aec-calib-back {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(36, 34, 58, 0.32);
	backdrop-filter: blur(3px);
}

.aec-calib {
	display: flex;
	flex-direction: column;
	gap: 14px;
	align-items: center;
	max-width: min(92vw, 720px);
	padding: 24px 26px;
	border-radius: var(--aec-radius-lg, 22px);
	background: var(--aec-paper, #fff);
	color: var(--aec-ink, #24223a);
	box-shadow: var(--aec-shadow-lift, 0 16px 36px rgba(52, 44, 110, 0.14));
	overflow: auto;
	max-height: 92vh;
}

.aec-calib h2 {
	margin: 0;
	font-size: 1.2rem;
}

.aec-calib p {
	margin: 0;
	max-width: 56ch;
	text-align: center;
	color: var(--aec-ink-2, #625e7c);
}

.aec-calib-card {
	position: relative;
	max-width: 100%;
	border-radius: 3.2% / 5%;
	background: linear-gradient(135deg, var(--aec-pastel-lilac, #efebfd), var(--aec-pastel-sky, #e4eefb));
	border: 2px solid var(--aec-accent, #5b4ee0);
	box-sizing: border-box;
}

.aec-calib-chip {
	position: absolute;
	left: 12%;
	top: 34%;
	width: 14%;
	height: 22%;
	border-radius: 18%;
	background: var(--aec-pastel-butter, #fff4cf);
	border: 1px solid rgba(165, 102, 26, 0.4);
}

.aec-calib input[type="range"] {
	width: min(100%, 420px);
	accent-color: var(--aec-accent, #5b4ee0);
}

.aec-calib-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
}

/* Themes without a [hidden] reset (Blocksy): our display rules must never win over the attribute. */
[class*="aec-"][hidden] {
	display: none !important;
}

/* The comparison tray steps aside while the preview drawer is open. */
body.aec-drawer-open .aec-tray {
	right: calc(min(480px, 100vw) + 16px + env(safe-area-inset-right, 0px));
}
@media (max-width: 960px) {
	body.aec-drawer-open .aec-tray {
		display: none;
	}
}
