/* ===================================================================
   Custom Pillow Visualizer — самостоятелно приложение на цял екран.
   Фиксиран хедър + фиксиран футър, съдържанието запълва останалото,
   без скрол на цялата страница (само евентуален вътрешен, като защита).
   =================================================================== */

* { box-sizing: border-box; }

html, body {
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
}

.cpv-app-body {
	font-family: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background: linear-gradient(135deg, #8b7cf6 0%, #6c9ef8 45%, #f472b6 100%);
	color: #111827;
	-webkit-font-smoothing: antialiased;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	min-height: 100dvh;
}

button { font-family: inherit; }
img { max-width: 100%; }
a { text-decoration: none; }

.cpv-bubble-font { font-family: 'Rubik Bubbles', cursive; font-weight: 400; letter-spacing: .5px; }

/* ===================================================================
   Приложна "рамка" — цял екран на телефон в портрет; навсякъде другаде
   (desktop, таблет, завъртян телефон) — центрирана карта, ТОЧНИТЕ пиксели
   се изчисляват в JS (resizeAppShell), защото чист CSS "max-width + vh"
   се сплесква грешно при ниска височина (landscape).
   =================================================================== */

.cpv-app-shell {
	width: 100%;
	max-width: 480px;
	height: 100vh;
	height: 100dvh;
	background: #fff;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	position: relative;
	flex-shrink: 0;
	touch-action: manipulation; /* изключва двойния тап за зуум навсякъде в апп-а; canvas-ът си има собствено по-строго правило (touch-action:none), затова не е засегнат */
}

.cpv-app-shell.cpv-shell-framed {
	max-width: none;
	border-radius: 28px;
	box-shadow: 0 30px 70px rgba(0,0,0,.35);
	display: grid;
	grid-template-columns: 1.35fr 1fr;
	grid-template-rows: auto 1fr;
	grid-template-areas:
		"header header"
		"main   footer";
}
.cpv-shell-framed .cpv-app-header { grid-area: header; }
.cpv-shell-framed .cpv-app-main { grid-area: main; min-height: 0; }
.cpv-shell-framed .cpv-app-footer { grid-area: footer; }

/* ===================================================================
   ХЕДЪР — тънка лента, ВИНАГИ един и същ размер: назад | 1-2-3 | X
   =================================================================== */

.cpv-app-header {
	flex-shrink: 0;
	height: 54px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 12px;
	border-bottom: 1px solid #f1f5f9;
	background: #fff;
	z-index: 10;
}

.cpv-nav-icon {
	width: 34px; height: 34px;
	flex-shrink: 0;
	border-radius: 50%;
	background: #f3f4f6;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #374151;
	cursor: pointer;
	transition: background .15s ease;
}
.cpv-nav-icon:hover { background: #e5e7eb; }
.cpv-nav-icon.cpv-hidden { visibility: hidden; }

.cpv-stepper { display: flex; align-items: center; gap: 8px; }
.cpv-stepper-dot {
	width: 22px; height: 22px;
	border-radius: 50%;
	background: #f3f4f6;
	color: #9ca3af;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	font-weight: 700;
	transition: background .2s ease, color .2s ease, transform .2s ease;
}
.cpv-stepper-dot.active,
.cpv-stepper-dot.done {
	background: linear-gradient(135deg, #2563eb, #7c3aed);
	color: #fff;
	transform: scale(1.05);
}
.cpv-stepper-sep { width: 14px; height: 2px; background: #e5e7eb; border-radius: 1px; }

/* ===================================================================
   СЪДЪРЖАНИЕ — запълва останалото място; overflow-y: auto само като
   предпазна мрежа при извънредно малки екрани, не като основен дизайн.
   =================================================================== */

.cpv-app-main {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	position: relative;
	padding: 16px;
	background: linear-gradient(160deg, #8b7cf6 0%, #6c9ef8 50%, #f472b6 100%);
}

.cpv-step-panel {
	display: none;
	height: 100%;
	flex-direction: column;
	opacity: 0;
	transform: translateY(10px);
}
.cpv-step-panel.active { display: flex; }
.cpv-step-panel.cpv-anim-in {
	opacity: 1;
	transform: translateY(0);
	transition: opacity .25s ease, transform .25s ease;
}

.cpv-step-hint {
	text-align: center;
	font-size: 13px;
	color: rgba(255,255,255,.9);
	margin: 0 0 14px;
	flex-shrink: 0;
}

/* --- Стъклени карти --- */
.cpv-glass-card {
	background: rgba(255,255,255,.16);
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	border: 1px solid rgba(255,255,255,.35);
	border-radius: 20px;
}

/* ===================================================================
   Стъпка 1: Категории
   =================================================================== */

.cpv-category-grid {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-content: start;
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	touch-action: pan-y;
}
.cpv-category-card {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 14px 18px;
	background: rgba(255,255,255,.16);
	backdrop-filter: blur(14px);
	border: 1px solid rgba(255,255,255,.35);
	border-radius: 18px;
	cursor: pointer;
	overflow: hidden;
	transition: transform .15s ease, background .15s ease;
}
.cpv-category-card:hover { transform: translateY(-3px); background: rgba(255,255,255,.28); }
.cpv-category-name {
	font-family: 'Jost', sans-serif;
	font-weight: 700;
	font-size: 15px;
	color: #fff;
	text-align: left;
	flex: 1;
	min-width: 0;
}
.cpv-category-image {
	height: 54px;
	width: auto;
	max-width: 84px;
	object-fit: contain;
	opacity: .82;
	flex-shrink: 0;
	pointer-events: none;
}

/* ===================================================================
   Стъпка 2: Решетка от модели (4 на ред) + детайлен преглед отдолу
   =================================================================== */

.cpv-step2-panel { gap: 10px; }

.cpv-model-grid {
	flex: 6 1 0%;
	min-height: 0;
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	align-content: start;
	gap: 10px;
	overflow-y: auto;
	overflow-x: hidden;
	touch-action: pan-y;
	padding-bottom: 4px;
}
.cpv-model-grid-item {
	background: rgba(255,255,255,.14);
	border: 2px solid transparent;
	border-radius: 16px;
	padding: 6px;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.cpv-model-grid-item img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	border-radius: 10px;
	pointer-events: none;
}
.cpv-model-grid-title {
	font-size: 9px;
	font-weight: 700;
	color: #fff;
	text-align: center;
	line-height: 1.25;
	max-height: 23px;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.cpv-model-grid-item:hover { background: rgba(255,255,255,.22); transform: scale(1.03); }
.cpv-model-grid-item-active {
	border-color: #fff;
	background: rgba(255,255,255,.28);
	box-shadow: 0 0 0 3px rgba(124,58,237,.55), 0 6px 18px rgba(0,0,0,.25);
}

.cpv-model-detail {
	flex: 4 1 0%;
	min-height: 0;
	display: flex;
	gap: 12px;
	transition: opacity .12s ease;
}
.cpv-model-detail-image-wrap {
	position: relative;
	flex: 1;
	min-width: 0;
	border-radius: 14px;
	overflow: hidden;
	background: rgba(255,255,255,.12);
}
.cpv-model-detail-image-wrap img {
	width: 100%; height: 100%;
	object-fit: contain;
	display: block;
}
.cpv-model-detail-zoom {
	position: absolute;
	bottom: 8px; right: 8px;
	width: 30px; height: 30px;
	border-radius: 50%;
	border: none;
	background: rgba(255,255,255,.85);
	color: #7c3aed;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 3px 10px rgba(0,0,0,.25);
	transition: transform .15s ease;
}
.cpv-model-detail-zoom:hover { transform: scale(1.1); }

.cpv-model-detail-text {
	flex: 1;
	min-width: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding-right: 2px;
}
.cpv-model-detail-text h3 { margin: 0 0 6px; font-size: 15px; color: #fff; }
.cpv-model-detail-text p { margin: 0; font-size: 11px; line-height: 1.5; color: rgba(255,255,255,.85); }

.cpv-empty { text-align: center; color: rgba(255,255,255,.8); font-size: 13px; margin: auto; grid-column: 1 / -1; }


/* ===================================================================
   Стъпка 3: Редактор — canvas запълва наличната височина
   =================================================================== */

.cpv-canvas-wrap {
	position: relative;
	/* width/height се задават директно през JS (resizeCanvasWrap) с точна
	   аритметика — по-надеждно от CSS "aspect-ratio" + flexbox комбинация,
	   която се оказа непоследователна между браузърите. */
	margin: 0 auto;
	background-color: #fff;
	background-image:
		linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%, #e5e7eb),
		linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%, #e5e7eb);
	background-size: 20px 20px;
	background-position: 0 0, 10px 10px;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 10px 30px rgba(0,0,0,.2);
	flex-shrink: 0;
}
#cpv-canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.cpv-step-panel[data-step="3"] {
	align-items: center;
	justify-content: center;
}

.cpv-loading-overlay {
	position: absolute; inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: rgba(255,255,255,.9);
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease;
	font-size: 13px;
	font-weight: 600;
	color: #374151;
}
.cpv-loading-overlay.cpv-visible { opacity: 1; pointer-events: auto; }
.cpv-spinner {
	width: 32px; height: 32px;
	border: 4px solid #e5e7eb;
	border-top-color: #7c3aed;
	border-radius: 50%;
	animation: cpvSpin .8s linear infinite;
}
@keyframes cpvSpin { to { transform: rotate(360deg); } }

#cpv-app-main .cpv-status {
	flex-shrink: 0;
	text-align: center;
	font-size: 12px;
	font-weight: 600;
	color: #fff;
	margin: 8px 0 0;
	min-height: 14px;
}
.cpv-status-error { color: #fecaca !important; }
.cpv-status-info { color: #dbeafe !important; }

/* ===================================================================
   Стъпка 4: Успех
   =================================================================== */

.cpv-success-panel { align-items: center; justify-content: center; text-align: center; margin: auto 0; }
.cpv-success-check {
	width: 74px; height: 74px;
	border-radius: 50%;
	background: #fff;
	color: #22c55e;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 18px;
	box-shadow: 0 14px 30px rgba(0,0,0,.2);
	animation: cpvPop .4s cubic-bezier(.22,1,.36,1);
}
@keyframes cpvPop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cpv-success-panel h2 { font-size: 21px; margin: 0 0 8px; color: #fff; }
.cpv-success-panel p { color: rgba(255,255,255,.85); margin: 0 0 24px; font-size: 14px; }
.cpv-success-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 280px; margin: 0 auto; }

/* --- "Купи 2, вземи 1 безплатно" лента --- */

.cpv-b2g1-widget {
	max-width: 380px;
	margin: 16px auto;
	padding: 20px;
	border-radius: 18px;
	background: linear-gradient(135deg, #faf5ff, #ede9fe);
	border: 1.5px solid #ddd6fe;
	text-align: center;
}
.cpv-b2g1-title { margin: 0 0 16px; font-size: 16px; font-weight: 800; color: #6d28d9; }
.cpv-b2g1-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; }
.cpv-b2g1-symbol { font-size: 22px; font-weight: 800; color: #7c3aed; flex-shrink: 0; }
.cpv-b2g1-square {
	position: relative;
	width: 84px; height: 84px;
	flex-shrink: 0;
	border-radius: 16px;
	background: #fff;
	border: 2px dashed #c4b5fd;
	display: flex;
	align-items: center;
	justify-content: center;
}
.cpv-b2g1-square-inner {
	width: 100%; height: 100%;
	border-radius: 13px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}
.cpv-b2g1-square.cpv-b2g1-filled { border-style: solid; border-color: #8b5cf6; }
.cpv-b2g1-square.cpv-b2g1-square-free { background: #ddd6fe; border-color: #8b5cf6; }
.cpv-b2g1-square.cpv-b2g1-square-free.cpv-b2g1-filled { border-color: #6d28d9; }
.cpv-b2g1-square[data-cpv-b2g1-empty] { cursor: pointer; transition: transform .15s ease, background .15s ease; }
.cpv-b2g1-square[data-cpv-b2g1-empty]:hover { transform: scale(1.06); background: #f5f3ff; }
.cpv-b2g1-square img { width: 100%; height: 100%; object-fit: cover; }
.cpv-b2g1-plus { font-size: 26px; font-weight: 700; color: #c4b5fd; }
.cpv-b2g1-square-free .cpv-b2g1-plus { color: #7c3aed; }
.cpv-b2g1-free-badge {
	position: absolute;
	top: -6px; right: -6px;
	width: 26px; height: 26px;
	background: #dc2626;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	border: 2px solid #fff;
	box-shadow: 0 2px 6px rgba(220,38,38,.4);
}
.cpv-b2g1-hint { margin: 0; font-size: 13px; font-weight: 700; color: #6d28d9; }

.cpv-secondary-link { text-align: center; color: rgba(255,255,255,.8); font-size: 13px; font-weight: 600; padding: 6px; }
.cpv-secondary-link:hover { color: #fff; }

/* ===================================================================
   ФУТЪР — тънка лента, ВИНАГИ същата височина, съдържанието спрямо стъпката
   =================================================================== */

.cpv-app-footer {
	flex-shrink: 0;
	min-height: 68px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
	border-top: 1px solid #f1f5f9;
	background: #fff;
	z-index: 10;
}
.cpv-footer-state { width: 100%; }

.cpv-b2g1-teaser {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 16px;
	border-radius: 999px;
	background: linear-gradient(135deg, #faf5ff, #ede9fe);
	border: 1.5px solid #ddd6fe;
	color: #6d28d9;
	font-size: 12px;
	font-weight: 800;
}
.cpv-b2g1-teaser svg { flex-shrink: 0; }

.cpv-b2g1-mini-wrap { width: 100%; }
.cpv-b2g1-mini-wrap .cpv-b2g1-widget {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	max-width: 100%;
	margin: 0;
	padding: 8px 12px;
	border-radius: 12px;
	text-align: left;
}
.cpv-b2g1-mini-wrap .cpv-b2g1-title { margin: 0; font-size: 10px; white-space: nowrap; flex-shrink: 0; }
.cpv-b2g1-mini-wrap .cpv-b2g1-row { margin: 0; gap: 4px; flex-shrink: 0; }
.cpv-b2g1-mini-wrap .cpv-b2g1-hint { display: none; }
.cpv-b2g1-mini-wrap .cpv-b2g1-square { width: 30px; height: 30px; border-radius: 8px; border-width: 1.5px; }
.cpv-b2g1-mini-wrap .cpv-b2g1-square-inner { border-radius: 6px; }
.cpv-b2g1-mini-wrap .cpv-b2g1-symbol { font-size: 11px; }
.cpv-b2g1-mini-wrap .cpv-b2g1-plus { font-size: 13px; }
.cpv-b2g1-mini-wrap .cpv-b2g1-free-badge { width: 13px; height: 13px; top: -2px; right: -2px; border-width: 1px; }
.cpv-b2g1-mini-wrap .cpv-b2g1-free-badge svg { width: 8px; height: 8px; }

.cpv-footer-row { display: flex; align-items: center; gap: 6px; width: 100%; }

.cpv-footer-icons-scroll {
	display: flex;
	align-items: center;
	gap: 5px;
	flex-wrap: wrap; /* при наистина много активни бутончета пренася на нов ред, никога не превърта */
	flex: 1;
	min-width: 0;
	justify-content: flex-start;
}
#cpv-add-cart-btn { flex-shrink: 0; }

.cpv-footer-btn-compact {
	flex-direction: row;
	padding: 8px 8px;
	gap: 6px;
	max-width: 99px; /* по-тесен само в мобилния (нерамкиран) режим — виж override-а по-долу за desktop/tablet */
}
#cpv-add-cart-btn.cpv-footer-btn-compact { padding: 8px 8px; }
.cpv-footer-btn-compact .cpv-add-cart-label {
	white-space: normal;
	line-height: 1.2;
	font-size: 10px;
	text-align: left;
}

/* --- 2-колонен режим: футърът става вертикален sidebar вдясно --- */
.cpv-shell-framed .cpv-app-footer {
	align-items: stretch;
	justify-content: flex-start;
	padding: 26px 22px;
	border-top: none;
	border-left: 1px solid #f1f5f9;
	overflow-y: auto;
}
.cpv-shell-framed .cpv-footer-row {
	flex-direction: column;
	align-items: stretch;
	gap: 12px;
}
.cpv-icon-btn-label { display: none; }

.cpv-shell-framed .cpv-footer-row .cpv-icon-btn {
	align-self: stretch;
	width: auto;
	height: auto;
	border-radius: 12px;
	flex-direction: row;
	justify-content: flex-start;
	gap: 10px;
	padding: 10px 12px;
}
.cpv-shell-framed .cpv-icon-btn-label {
	display: block;
	font-size: 12.5px;
	font-weight: 700;
	color: #374151;
	white-space: nowrap;
}
.cpv-shell-framed .cpv-icon-btn.cpv-icon-btn-active .cpv-icon-btn-label { color: #fff; }
.cpv-shell-framed .cpv-footer-icons-scroll {
	flex-wrap: nowrap;
	flex-direction: column;
	overflow-x: visible;
	justify-content: flex-start;
	align-items: stretch;
	gap: 4px;
}
.cpv-shell-framed .cpv-swatch-row { flex-wrap: wrap; }
.cpv-shell-framed .cpv-category-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	align-content: start;
}
.cpv-shell-framed #cpv-select-model-btn,
.cpv-shell-framed #cpv-add-cart-btn { width: 100%; }
.cpv-shell-framed .cpv-footer-btn-compact { padding: 12px 16px; max-width: none; }
.cpv-shell-framed .cpv-footer-btn-compact .cpv-add-cart-label { font-size: 13px; }

.cpv-footer-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	border: none;
	padding: 12px 16px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
	transition: transform .15s ease, box-shadow .15s ease;
	white-space: nowrap;
}
.cpv-footer-btn:active { transform: translateY(0); }
.cpv-footer-btn-half { flex: 1; min-width: 0; }
.cpv-footer-btn-half span { overflow: hidden; text-overflow: ellipsis; }

.cpv-footer-btn-primary {
	background: linear-gradient(135deg, #2563eb, #7c3aed);
	color: #fff;
	box-shadow: 0 6px 16px rgba(37,99,235,.3);
	width: 100%;
}
.cpv-footer-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(37,99,235,.4); }

.cpv-footer-btn-success {
	background: linear-gradient(135deg, #16a34a, #22c55e);
	color: #fff;
	box-shadow: 0 6px 16px rgba(34,197,94,.3);
	flex: 1;
}
.cpv-footer-btn-success:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(34,197,94,.4); }

.cpv-footer-btn-ghost {
	background: #f3f4f6;
	color: #374151;
}
.cpv-footer-btn-ghost:hover { background: #e5e7eb; }

.cpv-footer-btn-danger {
	background: #fef2f2;
	color: #dc2626;
}
.cpv-footer-btn-danger:hover { background: #fee2e2; }

.cpv-icon-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 40px; height: 40px;
	background: #f3f4f6;
	border: none;
	border-radius: 50%;
	padding: 0;
	color: #374151;
	cursor: pointer;
	transition: background .15s ease, transform .15s ease;
}
.cpv-icon-btn:hover { background: #e5e7eb; transform: scale(1.05); }
.cpv-icon-btn svg { display: block; pointer-events: none; }
.cpv-icon-btn.cpv-icon-btn-active {
	background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
	color: #fff !important;
	box-shadow: 0 3px 10px rgba(124,58,237,.4);
}

.cpv-color-row-label {
	font-size: 12px;
	font-weight: 700;
	color: #6b7280;
	flex-shrink: 0;
	white-space: nowrap;
}
.cpv-swatch-row { display: flex; gap: 8px; flex: 1; justify-content: center; overflow-x: auto; }

.cpv-erase-label {
	flex: 1;
	text-align: center;
	font-size: 12px;
	font-weight: 600;
	color: #6b7280;
}
#cpv-canvas.cpv-eraser-cursor { cursor: crosshair; }
.cpv-swatch {
	width: 30px; height: 30px;
	border-radius: 50%;
	border: 2px solid #fff;
	box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.1);
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
	transition: transform .15s ease, box-shadow .15s ease;
}
.cpv-swatch:hover { transform: scale(1.12); }
.cpv-swatch.cpv-swatch-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #7c3aed; transform: scale(1.15); }

/* ===================================================================
   Lightbox
   =================================================================== */

.cpv-lightbox {
	position: fixed; inset: 0;
	z-index: 1000000;
	display: none;
	align-items: center;
	justify-content: center;
}
.cpv-lightbox.cpv-visible { display: flex; }
.cpv-lightbox-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.85); backdrop-filter: blur(4px); }
.cpv-lightbox-close {
	position: absolute;
	top: 20px; right: 20px;
	width: 40px; height: 40px;
	border-radius: 50%;
	border: none;
	background: rgba(255,255,255,.15);
	color: #fff;
	font-size: 24px;
	z-index: 2;
	cursor: pointer;
}
.cpv-lightbox-close:hover { background: rgba(255,255,255,.28); }

.cpv-lightbox-content {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	max-width: 88vw;
	max-height: 88vh;
	padding: 20px;
}
#cpv-lightbox-img {
	position: relative;
	max-width: 100%;
	max-height: 68vh;
	object-fit: contain;
	border-radius: 12px;
	filter: drop-shadow(0 20px 40px rgba(0,0,0,.4));
}
#cpv-lightbox-text {
	display: none;
	max-width: 440px;
	text-align: center;
	color: #fff;
	font-size: 14px;
	line-height: 1.6;
	background: rgba(255,255,255,.1);
	border-radius: 14px;
	padding: 14px 18px;
	margin: 0;
	white-space: pre-line;
}

/* --- Ръководство: книжка с прелистване --- */

.cpv-guide-book {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	max-width: 92vw;
}
#cpv-guide-page-img {
	max-width: 100%;
	max-height: 72vh;
	object-fit: contain;
	border-radius: 14px;
	box-shadow: 0 20px 40px rgba(0,0,0,.4);
	background: #fff;
	user-select: none;
	-webkit-user-drag: none;
}
.cpv-guide-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 42px; height: 42px;
	border-radius: 50%;
	border: none;
	background: rgba(255,255,255,.92);
	color: #7c3aed;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0,0,0,.3);
	z-index: 2;
	transition: transform .15s ease, opacity .15s ease;
}
.cpv-guide-arrow:hover { transform: translateY(-50%) scale(1.08); }
.cpv-guide-arrow:disabled { opacity: .35; cursor: default; }
.cpv-guide-prev { left: -6px; }
.cpv-guide-next { right: -6px; }

.cpv-guide-dots { display: flex; gap: 8px; }
.cpv-guide-dot {
	width: 8px; height: 8px;
	border-radius: 50%;
	background: rgba(255,255,255,.4);
	cursor: pointer;
	transition: background .15s ease, transform .15s ease;
}
.cpv-guide-dot:hover { background: rgba(255,255,255,.7); }
.cpv-guide-dot-active { background: #fff; transform: scale(1.3); }

/* ===================================================================
   Потвърждение при изход
   =================================================================== */

.cpv-confirm-modal {
	position: fixed; inset: 0;
	z-index: 1000001;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.cpv-confirm-modal.cpv-visible { display: flex; }
.cpv-confirm-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.6); }
.cpv-confirm-box {
	position: relative;
	background: #fff;
	border-radius: 20px;
	padding: 24px 20px;
	max-width: 320px;
	width: 100%;
	text-align: center;
	box-shadow: 0 24px 50px rgba(0,0,0,.3);
}
.cpv-confirm-box p { margin: 0 0 18px; font-size: 14px; color: #374151; line-height: 1.5; }
.cpv-confirm-actions { display: flex; gap: 10px; }
.cpv-confirm-actions .cpv-footer-btn { flex: 1; }

/* --- Модал за персонализиран текст --- */

.cpv-text-modal-box {
	max-width: 340px;
	text-align: left;
	max-height: 86vh;
	overflow-y: auto;
}
.cpv-text-modal-box h3 { margin: 0 0 14px; font-size: 18px; color: #111827; text-align: center; }

/* --- История на лицата --- */

.cpv-face-history-box {
	max-width: 360px;
	text-align: center;
	max-height: 86vh;
	overflow-y: auto;
}
.cpv-face-history-box h3 { margin: 0 0 6px; font-size: 18px; color: #111827; }
.cpv-face-history-hint { margin: 0 0 16px; font-size: 13px; color: #6b7280; }

.cpv-face-history-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 10px;
}
.cpv-face-history-item {
	position: relative;
	aspect-ratio: 1 / 1;
	border-radius: 12px;
	overflow: hidden;
	background-color: #fff;
	background-image:
		linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0),
		linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0);
	background-size: 16px 16px;
	background-position: 0 0, 8px 8px;
	border: 1.5px solid #e5e7eb;
	cursor: pointer;
	transition: border-color .15s ease, transform .15s ease;
}
.cpv-face-history-item:hover { border-color: #7c3aed; transform: scale(1.03); }
.cpv-face-history-item img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.cpv-face-history-remove {
	position: absolute;
	top: 3px; right: 3px;
	width: 20px; height: 20px;
	border-radius: 50%;
	border: none;
	background: rgba(17,24,39,.75);
	color: #fff;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.cpv-face-history-remove:hover { background: #dc2626; }
.cpv-face-history-empty { grid-column: 1 / -1; color: #6b7280; font-size: 13px; padding: 20px 0; }

/* --- Библиотека с готови илюстрации (inline ред, като цветовете) --- */

.cpv-illust-inline-row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	overflow-x: auto;
}
.cpv-illust-inline-cat {
	flex-shrink: 0;
	width: 52px; height: 52px;
	border-radius: 12px;
	border: 1.5px solid #e5e7eb;
	background-color: #f9fafb;
	background-size: 60%;
	background-position: center;
	background-repeat: no-repeat;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	cursor: pointer;
	transition: border-color .15s ease, transform .15s ease;
}
.cpv-illust-inline-cat:hover { border-color: #7c3aed; transform: scale(1.05); }
.cpv-illust-inline-cat-name {
	font-size: 8px;
	font-weight: 700;
	color: #374151;
	background: rgba(255,255,255,.85);
	width: 100%;
	text-align: center;
	border-radius: 0 0 10px 10px;
	padding: 1px 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.cpv-illust-inline-miniback {
	flex-shrink: 0;
	width: 32px; height: 32px;
	border-radius: 50%;
	border: none;
	background: #f3f4f6;
	color: #374151;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease;
}
.cpv-illust-inline-miniback:hover { background: #e5e7eb; }
.cpv-illust-inline-item {
	flex-shrink: 0;
	width: 44px; height: 44px;
	border-radius: 10px;
	overflow: hidden;
	background-color: #fff;
	background-image:
		linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0),
		linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0);
	background-size: 12px 12px;
	background-position: 0 0, 6px 6px;
	border: 1.5px solid #e5e7eb;
	cursor: pointer;
	transition: border-color .15s ease, transform .15s ease;
	padding: 0;
}
.cpv-illust-inline-item:hover { transform: scale(1.06); }
.cpv-illust-inline-item.cpv-illust-inline-item-active { border-color: #7c3aed; box-shadow: 0 0 0 2px rgba(124,58,237,.3); }
.cpv-illust-inline-item img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.cpv-illust-inline-remove {
	flex-shrink: 0;
	width: 32px; height: 32px;
	border-radius: 50%;
	border: none;
	background: #fee2e2;
	color: #dc2626;
	font-size: 14px;
	cursor: pointer;
	transition: background .15s ease;
}
.cpv-illust-inline-remove:hover { background: #fecaca; }
.cpv-illust-inline-empty { color: #6b7280; font-size: 13px; }

.cpv-text-input {
	width: 100%;
	border: 1.5px solid #e5e7eb;
	border-radius: 12px;
	padding: 11px 14px;
	font-size: 15px;
	font-family: inherit;
	margin-bottom: 16px;
	box-sizing: border-box;
	resize: vertical;
	min-height: 52px;
}
.cpv-text-input:focus { outline: none; border-color: #7c3aed; }

.cpv-text-modal-label { font-size: 12px; font-weight: 700; color: #6b7280; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .03em; }

.cpv-font-select {
	width: 100%;
	height: 46px;
	border: 1.5px solid #e5e7eb;
	border-radius: 10px;
	padding: 0 12px;
	font-size: 16px;
	background: #fff;
	color: #111827;
	margin-bottom: 16px;
	cursor: pointer;
}
.cpv-font-select:focus { outline: none; border-color: #7c3aed; }

.cpv-color-picker-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 16px;
}
.cpv-text-color-picker {
	width: 46px;
	height: 46px;
	padding: 0;
	border: 1.5px solid #e5e7eb;
	border-radius: 10px;
	cursor: pointer;
	background: none;
}
.cpv-text-color-picker::-webkit-color-swatch-wrapper { padding: 3px; }
.cpv-text-color-picker::-webkit-color-swatch { border: none; border-radius: 7px; }
.cpv-color-picker-hint { font-size: 13px; color: #6b7280; }

.cpv-effect-row { display: flex; gap: 8px; margin-bottom: 20px; }
.cpv-effect-btn {
	flex: 1;
	padding: 9px 6px;
	border: 1.5px solid #e5e7eb;
	border-radius: 10px;
	background: #fff;
	color: #374151;
	font-size: 12px;
	font-weight: 700;
	cursor: pointer;
	transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.cpv-effect-btn:hover { border-color: #c4b5fd; }
.cpv-effect-btn.cpv-effect-active { border-color: #7c3aed; background: #7c3aed; color: #fff; }

/* ===================================================================
   Малки екрани — минимални допълнителни корекции
   =================================================================== */

@media (max-width: 360px) {
	.cpv-app-header { height: 48px; }
	.cpv-app-main { padding: 12px; }
	.cpv-footer-btn { padding: 10px 12px; font-size: 12px; }
}
