/**
 * Card Codex Scan — isolated scanner UI (cc-scan-*). Scoped to #cc-scan-root only.
 */

#cc-scan-root.cc-scan {
	--cc-scan-bg-deep: #070b14;
	--cc-scan-bg-panel: #0c1222;
	--cc-scan-surface: #131d33;
	--cc-scan-surface2: #1e2d4d;
	--cc-scan-text: #f4f7ff;
	--cc-scan-muted: #8b9cbb;
	--cc-scan-accent: #3b82f6;
	--cc-scan-accent-hover: #2563eb;
	--cc-scan-accent-soft: rgba(59, 130, 246, 0.22);
	--cc-scan-success: #34d399;
	--cc-scan-success-dim: rgba(52, 211, 153, 0.18);
	--cc-scan-danger: #f87171;
	--cc-scan-warn: #fbbf24;
	--cc-scan-radius: 20px;
	--cc-scan-radius-sm: 12px;
	--cc-scan-card-aspect: 63 / 88;

	position: fixed;
	inset: 0;
	z-index: 99999999999;
	display: flex;
	flex-direction: column;
	justify-content: center;
	font-size: 16px;
	line-height: 1.45;
	color: var(--cc-scan-text);
	-webkit-font-smoothing: antialiased;
	box-sizing: border-box;
}

#cc-scan-root.cc-scan *,
#cc-scan-root.cc-scan *::before,
#cc-scan-root.cc-scan *::after {
	box-sizing: border-box;
}

#cc-scan-root.cc-scan[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan-icon,
#cc-scan-root.cc-scan svg.cc-scan-icon,
#cc-scan-root.cc-scan svg.lucide {
	width: 1.25em;
	height: 1.25em;
	flex-shrink: 0;
	stroke-width: 1.75;
}

#cc-scan-root.cc-scan .cc-scan__backdrop {
	position: absolute;
	inset: 0;
	background: radial-gradient(100% 80% at 50% 0%, #152238 0%, var(--cc-scan-bg-deep) 55%);
}

#cc-scan-root.cc-scan .cc-scan__shell {
	position: relative;
	min-height: 100%;
	min-height: 100dvh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
		max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

#cc-scan-root.cc-scan .cc-scan__panel {
	position: relative;
	width: 100%;
	max-width: 440px;
	height: auto;
	max-height: min(920px, calc(100dvh - 24px));
	background: var(--cc-scan-bg-panel);
	border-radius: var(--cc-scan-radius);
	border: 1px solid rgba(139, 156, 187, 0.18);
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#cc-scan-root.cc-scan .cc-scan__phase {
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
}

#cc-scan-root.cc-scan .cc-scan__phase--capture {
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
}

#cc-scan-root.cc-scan .cc-scan__phase--results {
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
}

#cc-scan-root.cc-scan .cc-scan__phase[hidden] {
	display: none !important;
}

/* ——— TinEye attribution (in-phase, normal flow — not a separate docked bar) ——— */
#cc-scan-root.cc-scan .cc-scan__powered {
	position: static;
	flex-shrink: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	margin-top: auto;
	padding: 10px;
	border-top: none;
	background: transparent;
}

#cc-scan-root.cc-scan .cc-scan__phase--results .cc-scan__powered {
	margin-top: 0;
}

#cc-scan-root.cc-scan .cc-scan__powered-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	color: var(--cc-scan-muted);
	font-size: 0.625rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	transition: color 0.15s;
	opacity: 0.85;
}

#cc-scan-root.cc-scan .cc-scan__powered-link:hover {
	color: var(--cc-scan-text);
	opacity: 1;
}

#cc-scan-root.cc-scan .cc-scan__powered-logo {
	height: 13px;
	width: auto;
	max-width: 96px;
	object-fit: contain;
	display: block;
}

@media (max-width: 520px) {
	#cc-scan-root.cc-scan .cc-scan__powered-logo {
		height: 12px;
		max-width: 88px;
	}
}

/* ——— Top bar ——— */
#cc-scan-root.cc-scan .cc-scan__topbar {
	display: grid;
	grid-template-columns: 44px 1fr 44px;
	align-items: center;
	gap: 8px;
	padding: 10px 12px 8px;
	flex-shrink: 0;
}

#cc-scan-root.cc-scan .cc-scan__title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	text-align: center;
}

#cc-scan-root.cc-scan .cc-scan__icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.06);
	color: var(--cc-scan-text);
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

#cc-scan-root.cc-scan .cc-scan__icon-btn:hover {
	background: rgba(255, 255, 255, 0.12);
	color: var(--cc-scan-accent);
}

#cc-scan-root.cc-scan .cc-scan__icon-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

/* ——— Quota pill ——— */
#cc-scan-root.cc-scan .cc-scan__pill {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 0;
	margin: 0 14px 12px;
	padding: 12px 14px;
	border-radius: var(--cc-scan-radius-sm);
	background: rgba(19, 29, 51, 0.95);
	border: 1px solid var(--cc-scan-accent-soft);
	font-size: 0.8125rem;
	color: var(--cc-scan-muted);
	flex-shrink: 0;
}

#cc-scan-root.cc-scan .cc-scan__pill[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__pill-row {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
	min-width: 0;
}

#cc-scan-root.cc-scan .cc-scan__pill-text {
	flex: 1;
	color: var(--cc-scan-text);
	font-weight: 600;
	min-width: 0;
	line-height: 1.35;
}

#cc-scan-root.cc-scan .cc-scan__pill-info {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--cc-scan-muted);
	cursor: pointer;
}

#cc-scan-root.cc-scan .cc-scan__pill-info:hover {
	color: var(--cc-scan-accent);
}

/* ——— Upsell (quota exhausted) ——— */
#cc-scan-root.cc-scan .cc-scan__upsell {
	margin: 0 14px 14px;
	padding: 20px 18px;
	border-radius: var(--cc-scan-radius-sm);
	background: var(--cc-scan-surface);
	border: 1px solid var(--cc-scan-accent-soft);
	flex-shrink: 0;
	text-align: center;
}

#cc-scan-root.cc-scan .cc-scan__upsell[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__upsell-title {
	margin: 0 0 10px;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--cc-scan-text);
}

#cc-scan-root.cc-scan .cc-scan__upsell-body {
	margin: 0 0 18px;
	font-size: 0.9rem;
	color: var(--cc-scan-muted);
	line-height: 1.5;
}

#cc-scan-root.cc-scan .cc-scan__upsell-renew {
	margin: 0 0 14px;
	font-size: 0.85rem;
	color: var(--cc-scan-muted);
	line-height: 1.45;
	font-weight: 600;
}

#cc-scan-root.cc-scan .cc-scan__upsell-renew[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__upsell-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#cc-scan-root.cc-scan .cc-scan__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 48px;
	padding: 0 20px;
	border-radius: 12px;
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
	border: none;
	text-decoration: none;
	transition: background 0.15s, transform 0.1s;
}

#cc-scan-root.cc-scan .cc-scan__btn:active {
	transform: scale(0.98);
}

#cc-scan-root.cc-scan .cc-scan__btn--primary {
	background: var(--cc-scan-accent);
	color: #fff;
}

#cc-scan-root.cc-scan .cc-scan__btn--primary:hover {
	background: var(--cc-scan-accent-hover);
}

#cc-scan-root.cc-scan .cc-scan__btn--primary[data-upsell-upgrade],
#cc-scan-root.cc-scan .cc-scan__btn--primary.cc-scan__sheet-upgrade {
	background: linear-gradient(135deg, #38bdf8 0%, #696cd5 100%);
}

#cc-scan-root.cc-scan .cc-scan__btn--primary[data-upsell-upgrade]:hover,
#cc-scan-root.cc-scan .cc-scan__btn--primary.cc-scan__sheet-upgrade:hover {
	background: linear-gradient(135deg, #2ea8de 0%, #585bc4 100%);
}

#cc-scan-root.cc-scan .cc-scan__btn--ghost {
	background: transparent;
	color: var(--cc-scan-accent);
	border: 1px solid rgba(59, 130, 246, 0.45);
}

#cc-scan-root.cc-scan .cc-scan__btn--ghost:hover {
	background: var(--cc-scan-accent-soft);
}

/* ——— Capture viewport ——— */
#cc-scan-root.cc-scan .cc-scan__capture-stack {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	padding: 0 14px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

#cc-scan-root.cc-scan .cc-scan__capture-stack[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__viewport-card {
	position: relative;
	flex: 0 0 auto;
	align-self: stretch;
	/* Explicit height breaks % / container-query cycles (was only max-height → collapsed area). */
	height: clamp(280px, min(56vh, 85vmin), 420px);
	background: #050810;
	border-radius: var(--cc-scan-radius-sm);
	overflow: hidden;
	border: 1px solid rgba(139, 156, 187, 0.15);
}

#cc-scan-root.cc-scan .cc-scan__viewport-inner {
	position: absolute;
	inset: 0;
	display: block;
	container-type: size;
}

/*
 * Video + preview are siblings; flex row placed them side-by-side so the still
 * image was pushed right. Stack both layers.
 */
#cc-scan-root.cc-scan .cc-scan__viewport-inner video,
#cc-scan-root.cc-scan .cc-scan__viewport-inner .cc-scan__preview {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	z-index: 0;
}

#cc-scan-root.cc-scan .cc-scan__viewport-inner .cc-scan__preview[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__viewport-inner video {
	background: #000;
}

#cc-scan-root.cc-scan .cc-scan__viewport-inner canvas {
	display: none !important;
}

/* Viewfinder: four backdrop strips around the card frame (no full-layer mask — backdrop-filter often ignores it). */
#cc-scan-root.cc-scan .cc-scan__blur-fringe {
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	isolation: isolate;
}

#cc-scan-root.cc-scan .cc-scan__blur-fringe__piece {
	position: absolute;
	box-sizing: border-box;
	transform: translateZ(0);
	-webkit-backdrop-filter: blur(14px) saturate(1.06);
	backdrop-filter: blur(14px) saturate(1.06);
	background: rgba(7, 11, 20, 0.22);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
	#cc-scan-root.cc-scan .cc-scan__blur-fringe__piece {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		background: rgba(7, 11, 20, 0.62);
	}
}

/* Card-ratio frame + corner brackets */
#cc-scan-root.cc-scan .cc-scan__frame {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	z-index: 2;
}

/*
 * Card frame: keep strict portrait ratio (63×88). Width must shrink when vertical
 * space is tight — otherwise max-height alone squashes the box toward square.
 * cqw/cqh are relative to .cc-scan__viewport-inner (container-type: size).
 */
#cc-scan-root.cc-scan .cc-scan__frame-box {
	position: relative;
	box-sizing: border-box;
	aspect-ratio: var(--cc-scan-card-aspect);
	/* Fits inside overlay: ≤78% container width, ≤280px, and wide enough that height ≤88% container */
	width: min(78cqw, 280px, 63cqh);
	max-width: 100%;
	height: auto;
}

/* No container-query units: approximate height limit so ratio stays portrait */
@supports not (width: 1cqw) {
	#cc-scan-root.cc-scan .cc-scan__frame-box {
		width: min(78%, 280px, 63vmin);
	}
}

#cc-scan-root.cc-scan .cc-scan__corner {
	position: absolute;
	width: 28px;
	height: 28px;
	border-color: rgba(255, 255, 255, 0.92);
	border-style: solid;
	filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.35));
}

#cc-scan-root.cc-scan .cc-scan__corner--tl {
	top: 0;
	left: 0;
	border-width: 3px 0 0 3px;
	border-radius: 4px 0 0 0;
}

#cc-scan-root.cc-scan .cc-scan__corner--tr {
	top: 0;
	right: 0;
	border-width: 3px 3px 0 0;
	border-radius: 0 4px 0 0;
}

#cc-scan-root.cc-scan .cc-scan__corner--bl {
	bottom: 0;
	left: 0;
	border-width: 0 0 3px 3px;
	border-radius: 0 0 0 4px;
}

#cc-scan-root.cc-scan .cc-scan__corner--br {
	bottom: 0;
	right: 0;
	border-width: 0 3px 3px 0;
	border-radius: 0 0 4px 0;
}

#cc-scan-root.cc-scan .cc-scan__flip-row {
	margin-top: 12px;
	display: flex;
	justify-content: center;
	flex-shrink: 0;
}

#cc-scan-root.cc-scan .cc-scan__flip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.78rem;
	color: var(--cc-scan-muted);
	cursor: pointer;
	user-select: none;
}

#cc-scan-root.cc-scan .cc-scan__flip input {
	appearance: auto;
	width: 16px;
	height: 16px;
	accent-color: var(--cc-scan-accent);
}

/* Dock controls */
#cc-scan-root.cc-scan .cc-scan__dock {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 28px;
	padding: 18px 8px 12px;
	flex-shrink: 0;
}

#cc-scan-root.cc-scan .cc-scan__dock-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	transition: transform 0.12s, box-shadow 0.15s;
	color: var(--cc-scan-text);
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(139, 156, 187, 0.22);
}

#cc-scan-root.cc-scan .cc-scan__dock-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
	transform: none;
}

#cc-scan-root.cc-scan .cc-scan__dock-btn:not(:disabled):active {
	transform: scale(0.94);
}

#cc-scan-root.cc-scan .cc-scan__dock-btn--side {
	width: 52px;
	height: 52px;
}

#cc-scan-root.cc-scan .cc-scan__dock-btn--main {
	width: 76px;
	height: 76px;
	background: #38bdf8;
	color: #0c1222;
	box-shadow: 0 0 0 4px var(--cc-scan-accent-soft), 0 12px 36px rgba(59, 130, 246, 0.35);
	border: none;
}

#cc-scan-root.cc-scan .cc-scan__dock-btn--main:not(:disabled):hover {
	box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.45), 0 14px 40px rgba(59, 130, 246, 0.42);
}

#cc-scan-root.cc-scan .cc-scan__dock-btn--main .cc-scan-icon,
#cc-scan-root.cc-scan .cc-scan__dock-btn--main svg {
	width: 2rem;
	height: 2rem;
	stroke-width: 2;
}

#cc-scan-root.cc-scan .cc-scan__file {
	position: absolute;
	width: 0;
	height: 0;
	opacity: 0;
	pointer-events: none;
}

/* Tip */
#cc-scan-root.cc-scan .cc-scan__tip {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	gap: 10px;
	margin: 4px 14px 0;
	padding: 12px 14px;
	border-radius: var(--cc-scan-radius-sm);
	background: rgba(19, 29, 51, 0.65);
	border: 1px solid rgba(139, 156, 187, 0.12);
	font-size: 0.8125rem;
	color: var(--cc-scan-muted);
	flex-shrink: 0;
}

#cc-scan-root.cc-scan .cc-scan__tip .cc-scan-icon {
	color: var(--cc-scan-warn);
	flex-shrink: 0;
	margin-top: 2px;
}

#cc-scan-root.cc-scan .cc-scan__tip p {
	margin: 0;
	line-height: 1.45;
}

/* ——— Loading overlay ——— */
#cc-scan-root.cc-scan .cc-scan__loading {
	position: absolute;
	inset: 0;
	z-index: 30;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	background: rgba(7, 11, 20, 0.72);
	backdrop-filter: blur(6px);
	border-radius: inherit;
}

#cc-scan-root.cc-scan .cc-scan__loading[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__spinner {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 3px solid rgba(59, 130, 246, 0.2);
	border-top-color: var(--cc-scan-accent);
	animation: cc-scan-spin 0.75s linear infinite;
}

@keyframes cc-scan-spin {
	to {
		transform: rotate(360deg);
	}
}

#cc-scan-root.cc-scan .cc-scan__loading-text {
	font-size: 0.9rem;
	color: var(--cc-scan-muted);
	font-weight: 600;
}

/* ——— Scanner toasts (unique cc-scan-toast-*; body-level, isolated from theme .toast) ——— */
.cc-scan-toast-container {
	position: fixed;
	bottom: 1.5rem;
	right: 1.5rem;
	z-index: 999999999999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-end;
	gap: 0.75rem;
	pointer-events: none;
}

.cc-scan-toast {
	display: flex;
	align-items: flex-start;
	background: var(--theme-bg-light, rgba(19, 29, 51, 0.98));
	padding: 1rem 1.25rem;
	border-radius: 0.75rem;
	font-size: 0.9rem;
	line-height: 1.5;
	opacity: 0;
	transform: translateX(120%);
	transition:
		transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
		opacity 0.4s ease,
		box-shadow 0.3s ease;
	max-width: calc(100vw - (max(25px, 4.5vw) * 2));
	min-width: 280px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
	pointer-events: auto;
	position: relative;
	overflow: hidden;
	color: var(--theme-text, var(--cc-scan-text));
	font-weight: 500;
}

.cc-scan-toast__icon {
	margin-right: 0.875rem;
	margin-top: 2px;
	font-size: 1.1rem;
	flex-shrink: 0;
	width: 20px;
	text-align: center;
}

.cc-scan-toast__icon.fa-circle-info {
	color: var(--theme-link, var(--cc-scan-accent));
}

.cc-scan-toast__icon.fa-triangle-exclamation {
	color: var(--theme-error, #f87171);
}

.cc-scan-toast__icon.fa-circle-xmark {
	color: var(--theme-error, #f87171);
}

.cc-scan-toast[data-cc-type='error'] .cc-scan-toast__icon {
	color: var(--theme-error, #f87171);
}

.cc-scan-toast__message {
	flex: 1;
	min-width: 0;
	white-space: pre-line;
}

.cc-scan-toast:hover {
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
	transform: translateX(0) translateY(-2px);
}

.cc-scan-toast.cc-scan-toast--show {
	opacity: 1;
	transform: translateX(0);
}

@media (max-width: 1024px) {
	.cc-scan-toast-container {
		right: max(25px, 4.5vw);
		bottom: 1rem;
	}

	.cc-scan-toast {
		min-width: auto;
		max-width: calc(100vw - (max(25px, 4.5vw) * 2));
		padding: 0.875rem 1rem;
		font-size: 0.875rem;
	}
}

@media (max-width: 480px) {
	.cc-scan-toast-container {
		right: 1rem;
		left: 1rem;
		align-items: stretch;
	}

	.cc-scan-toast {
		min-width: auto;
		max-width: 100%;
		transform: translateY(100%);
		font-size: 13px;
	}

	.cc-scan-toast.cc-scan-toast--show {
		transform: translateY(0);
	}

	.cc-scan-toast:hover {
		transform: translateY(0);
	}
}

/* ——— Info sheet (help / quota / replaces alert) ——— */
#cc-scan-root.cc-scan .cc-scan__sheet {
	position: absolute;
	inset: 0;
	z-index: 60;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 16px;
	padding-bottom: max(16px, env(safe-area-inset-bottom));
}

#cc-scan-root.cc-scan .cc-scan__sheet[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__sheet-bg {
	position: absolute;
	inset: 0;
	background: rgba(7, 11, 20, 0.65);
	backdrop-filter: blur(4px);
}

#cc-scan-root.cc-scan .cc-scan__sheet-card {
	position: relative;
	width: 100%;
	max-width: 380px;
	max-height: min(70vh, 420px);
	display: flex;
	flex-direction: column;
	background: var(--cc-scan-surface);
	border: 1px solid rgba(139, 156, 187, 0.22);
	border-radius: var(--cc-scan-radius-sm);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
	padding: 20px 18px 18px;
	animation: cc-scan-sheet-up 0.28s ease-out;
}

@keyframes cc-scan-sheet-up {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

#cc-scan-root.cc-scan .cc-scan__sheet-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 40px;
	height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--cc-scan-muted);
	cursor: pointer;
}

#cc-scan-root.cc-scan .cc-scan__sheet-close:hover {
	color: var(--cc-scan-text);
	background: rgba(255, 255, 255, 0.06);
}

#cc-scan-root.cc-scan .cc-scan__sheet-title {
	margin: 0 44px 12px 0;
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1.25;
	color: var(--cc-scan-text);
}

#cc-scan-root.cc-scan .cc-scan__sheet-title[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__sheet-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 16px;
	font-size: 0.9rem;
	line-height: 1.55;
	color: var(--cc-scan-muted);
}

#cc-scan-root.cc-scan .cc-scan__sheet-body p {
	margin: 0 0 12px;
}

#cc-scan-root.cc-scan .cc-scan__sheet-body p:last-child {
	margin-bottom: 0;
}

#cc-scan-root.cc-scan .cc-scan__sheet-upgrade {
	width: 100%;
	min-height: 48px;
	margin-bottom: 10px;
	text-decoration: none;
	box-sizing: border-box;
}

#cc-scan-root.cc-scan .cc-scan__sheet-upgrade[hidden] {
	display: none !important;
}

#cc-scan-root.cc-scan .cc-scan__sheet-cta {
	width: 100%;
	min-height: 48px;
}

/* ——— Results phase ——— */
#cc-scan-root.cc-scan .cc-scan__results-body {
	flex: 1 1 0;
	min-height: 0;
	display: flex;
	flex-direction: column;
	padding: 0 14px 14px;
}

#cc-scan-root.cc-scan .cc-scan__statusbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
	flex-shrink: 0;
}

#cc-scan-root.cc-scan .cc-scan__status-left {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--cc-scan-success);
}

#cc-scan-root.cc-scan .cc-scan__status-left .cc-scan-icon {
	color: var(--cc-scan-success);
}

#cc-scan-root.cc-scan .cc-scan__sort {
	min-height: 40px;
	padding: 0 2.25rem 0 12px;
	border-radius: 10px;
	border: 1px solid rgba(139, 156, 187, 0.25);
	background-color: var(--cc-scan-surface);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b9cbb' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	background-size: 16px 16px;
	color: var(--cc-scan-text);
	font-size: 0.8125rem;
	font-weight: 600;
	max-width: 52%;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
}

#cc-scan-root.cc-scan .cc-scan__sort::-ms-expand {
	display: none;
}

#cc-scan-root.cc-scan .cc-scan__sort:focus-visible {
	outline: 2px solid var(--cc-scan-accent);
	outline-offset: 2px;
}

#cc-scan-root.cc-scan .cc-scan__results-scroll {
	flex: 1 1 0;
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 12px;
	padding-bottom: 8px;
}

/* Column flex defaults to flex-shrink:1 — without this, cards squish instead of scrolling */
#cc-scan-root.cc-scan .cc-scan__results-scroll > .cc-scan-result-card {
	flex-shrink: 0;
}

/*
 * Desktop: panel stays height:auto — flex:1 on the scroll region collapses without
 * a definite parent. Size the list from content and cap with max-height so many
 * matches scroll inside the cap instead of stretching the modal. Mobile keeps
 * flex:1 + full-height panel (see max-width:520px rules).
 */
@media (min-width: 521px) {
	#cc-scan-root.cc-scan .cc-scan__phase--results {
		flex: 0 1 auto;
	}

	#cc-scan-root.cc-scan .cc-scan__results-body {
		flex: 0 1 auto;
	}

	#cc-scan-root.cc-scan .cc-scan__results-scroll {
		flex: 0 1 auto;
		max-height: min(520px, calc(100dvh - 12rem));
	}
}

#cc-scan-root.cc-scan .cc-scan__results-footer {
	flex-shrink: 0;
	padding: 8px 14px 14px;
	background: linear-gradient(180deg, transparent, var(--cc-scan-bg-panel) 28%);
}

#cc-scan-root.cc-scan .cc-scan__results-footer .cc-scan__btn {
	width: 100%;
}

/* Result cards */
#cc-scan-root.cc-scan .cc-scan-result-card {
	position: relative;
	border-radius: var(--cc-scan-radius-sm);
	background: var(--cc-scan-surface);
	border: 1px solid rgba(139, 156, 187, 0.15);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	gap: 0;
	transition: border-color 0.15s, box-shadow 0.15s;
}

#cc-scan-root.cc-scan .cc-scan-result-card__top {
	display: flex;
	flex-direction: row;
	gap: 12px;
	align-items: stretch;
	min-width: 0;
}

#cc-scan-root.cc-scan .cc-scan-result-card--best {
	border-color: var(--cc-scan-accent);
	box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35), 0 12px 32px rgba(59, 130, 246, 0.12);
}

#cc-scan-root.cc-scan .cc-scan-result-card__badge {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 0.65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	background: var(--cc-scan-accent);
	color: #fff;
}

#cc-scan-root.cc-scan .cc-scan-result-card__media {
	width: 92px;
	flex-shrink: 0;
	aspect-ratio: var(--cc-scan-card-aspect);
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

#cc-scan-root.cc-scan .cc-scan-result-card__media img {
	max-width: 82%;
	max-height: 82%;
	object-fit: contain;
	filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
}

#cc-scan-root.cc-scan .cc-scan-result-card__main {
	flex: 1;
	min-width: 0;
	padding: 14px 14px 12px 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

#cc-scan-root.cc-scan .cc-scan-result-card__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.25;
	padding-right: 72px;
}

#cc-scan-root.cc-scan .cc-scan-result-card__variant {
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--cc-scan-accent);
}

#cc-scan-root.cc-scan .cc-scan-result-card__condition {
	margin: 0;
	font-size: 0.8125rem;
	color: var(--cc-scan-text);
}

#cc-scan-root.cc-scan .cc-scan-result-card__condition--muted {
	color: var(--cc-scan-muted);
	font-weight: 500;
}

#cc-scan-root.cc-scan .cc-scan-result-card__price-row {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 8px 12px;
	margin-top: 4px;
}

#cc-scan-root.cc-scan .cc-scan-result-card__price {
	font-size: 1.2rem;
	font-weight: 800;
	color: var(--cc-scan-success);
}

#cc-scan-root.cc-scan .cc-scan-result-card__delta {
	font-size: 0.8125rem;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

#cc-scan-root.cc-scan .cc-scan-result-card__delta--up {
	color: var(--cc-scan-success);
}

#cc-scan-root.cc-scan .cc-scan-result-card__delta--down {
	color: var(--cc-scan-danger);
}

#cc-scan-root.cc-scan .cc-scan-result-card__actions {
	display: flex;
	gap: 8px;
	padding: 0 12px 12px;
}

#cc-scan-root.cc-scan .cc-scan-result-card__actions .cc-scan__btn {
	flex: 1;
	min-height: 44px;
	font-size: 0.8125rem;
}

#cc-scan-root.cc-scan .cc-scan-result-card__actions .cc-scan__btn--ghost {
	color: var(--cc-scan-text);
	border-color: rgba(139, 156, 187, 0.28);
}

/* Add to collection — click pop, loading pulse, success state */
@keyframes cc-scan-add-pop {
	0% {
		transform: scale(1);
	}
	45% {
		transform: scale(1.07);
	}
	100% {
		transform: scale(1);
	}
}

@keyframes cc-scan-add-pulse {
	0%,
	100% {
		box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
	}
	50% {
		box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.08);
	}
}

#cc-scan-root.cc-scan .cc-scan__btn--add-collection {
	transition:
		background 0.32s ease,
		transform 0.2s ease,
		box-shadow 0.32s ease,
		filter 0.2s ease;
}

#cc-scan-root.cc-scan .cc-scan__btn--add-collection.cc-scan__btn--pop {
	animation: cc-scan-add-pop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#cc-scan-root.cc-scan .cc-scan__btn--add-collection.cc-scan__btn--adding:not(.cc-scan__btn--added) {
	animation: cc-scan-add-pulse 1s ease-in-out infinite;
}

#cc-scan-root.cc-scan .cc-scan__btn--add-collection.cc-scan__btn--added {
	background: linear-gradient(135deg, #34d399 0%, #059669 100%);
	color: #fff;
	box-shadow: 0 4px 18px rgba(52, 211, 153, 0.4);
	cursor: default;
	pointer-events: none;
}

#cc-scan-root.cc-scan .cc-scan__btn--add-collection.cc-scan__btn--added:hover {
	background: linear-gradient(135deg, #34d399 0%, #059669 100%);
	filter: brightness(1.03);
}

#cc-scan-root.cc-scan .cc-scan-result-card__note {
	margin: 0 12px 10px;
	padding: 10px;
	border-radius: 8px;
	font-size: 0.78rem;
	background: rgba(59, 130, 246, 0.1);
	border: 1px solid rgba(59, 130, 246, 0.25);
	color: var(--cc-scan-muted);
}

@media (max-width: 380px) {
	#cc-scan-root.cc-scan .cc-scan-result-card__media {
		width: 80px;
	}

	#cc-scan-root.cc-scan .cc-scan__dock {
		gap: 20px;
	}
}

body.cc-scan-open {
	overflow: hidden;
}

@media (max-width: 520px) {
	#cc-scan-root.cc-scan .cc-scan__shell {
		align-items: stretch;
		padding-left: 0;
		padding-right: 0;
		padding-top: 0;
		padding-bottom: 0;
		min-height: 100dvh;
	}

	#cc-scan-root.cc-scan .cc-scan__panel {
		max-width: none;
		width: 100%;
		height: 100dvh;
		min-height: 0;
		max-height: 100dvh;
		border-radius: 0;
		border-left: none;
		border-right: none;
		padding-top: env(safe-area-inset-top, 0);
		padding-bottom: env(safe-area-inset-bottom, 0);
	}
}
