/* ---------- Dropzone ---------- */
.uth-pph-dropzone {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 34px 22px;
	text-align: center;
	background: var(--uth-background);
	border: 2px dashed #cbd5e1;
	border-radius: var(--uth-radius-large);
	cursor: pointer;
	transition: border-color 160ms ease, background-color 160ms ease;
}

.uth-pph-dropzone:hover,
.uth-pph-dropzone:focus-within,
.uth-pph-dropzone.is-dragover {
	border-color: var(--uth-primary);
	background: var(--uth-section-background);
}

.uth-pph-file-input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.uth-pph-dropzone__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	color: var(--uth-primary);
	background: var(--uth-section-background);
	border-radius: 50%;
}

.uth-pph-dropzone__svg {
	width: 30px;
	height: 30px;
}

.uth-pph-dropzone__title {
	margin: 0;
	color: var(--uth-heading);
	font-size: 1.02rem;
	font-weight: 700;
	line-height: 1.4;
}

.uth-pph-dropzone__title strong {
	color: var(--uth-primary);
	font-weight: 700;
}

.uth-pph-dropzone__hint {
	margin: 0;
	color: var(--uth-muted);
	font-size: 0.85rem;
	line-height: 1.5;
}

.uth-pph-dropzone__privacy {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 6px 0 0;
	color: var(--uth-muted);
	font-size: 0.82rem;
	line-height: 1.5;
}

.uth-pph-privacy__lock {
	flex: none;
	width: 15px;
	height: 15px;
	color: var(--uth-success);
}

/* ---------- Editor ---------- */
.uth-pph-editor {
	display: grid;
	gap: 18px;
}

.uth-pph-editor[hidden] {
	display: none;
}

.uth-pph-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	justify-self: end;
	width: 36px;
	height: 36px;
	color: var(--uth-muted);
	background: transparent;
	border: 1px solid var(--uth-border);
	border-radius: 10px;
	cursor: pointer;
	transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.uth-pph-close:hover,
.uth-pph-close:focus-visible {
	color: var(--uth-heading);
	background: var(--uth-section-background);
	border-color: var(--uth-primary);
	outline: none;
}

.uth-pph-close svg {
	width: 18px;
	height: 18px;
}

/* ---------- Stage ---------- */
.uth-pph-stage {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background:
		repeating-conic-gradient(#f0f2f6 0% 25%, #fbfcfe 0% 50%) 0 0 / 22px 22px;
	border: 1px solid var(--uth-border);
	border-radius: var(--uth-radius-large);
	cursor: grab;
	user-select: none;
	touch-action: none;
}

.uth-pph-stage.is-dragging {
	cursor: grabbing;
}

.uth-pph-stage__inner {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 360px;
	height: 460px;
	overflow: hidden;
}

.uth-pph-photo {
	position: absolute;
	max-width: none;
	display: block;
	pointer-events: none;
}

.uth-pph-crop {
	position: absolute;
	margin: auto;
	border: 2px solid var(--uth-primary);
	box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.45);
	pointer-events: none;
}

.uth-pph-crop:focus {
	outline: 2px solid var(--uth-primary);
	outline-offset: 2px;
}

.uth-pph-guide {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	pointer-events: none;
}

.uth-pph-guide__band {
	position: absolute;
	left: 0;
	right: 0;
	background: rgba(56, 189, 248, 0.12);
}

.uth-pph-guide__top,
.uth-pph-guide__bottom {
	position: absolute;
	left: 0;
	right: 0;
	height: 2px;
	background: #38bdf8;
}

.uth-pph-guide__top::after,
.uth-pph-guide__bottom::after {
	content: '';
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: 10px;
	height: 10px;
	background: #38bdf8;
	border-radius: 2px;
}

/* ---------- Toolbar ---------- */
.uth-pph-toolsbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 14px;
	background: var(--uth-background);
	border-top: 1px solid var(--uth-border);
}

.uth-pph-toolsbar__group {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.uth-pph-iconbtn {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 5px;
	padding: 8px 10px;
	color: var(--uth-muted);
	background: transparent;
	border: 1px solid transparent;
	border-radius: 10px;
	font: inherit;
	font-size: 0.72rem;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.uth-pph-iconbtn:hover,
.uth-pph-iconbtn:focus-visible {
	color: var(--uth-heading);
	background: var(--uth-section-background);
	border-color: var(--uth-border);
	outline: none;
}

.uth-pph-iconbtn.is-active {
	color: var(--uth-primary);
	background: rgba(14, 116, 144, 0.08);
	border-color: rgba(14, 116, 144, 0.25);
}

.uth-pph-iconbtn svg {
	width: 20px;
	height: 20px;
}

.uth-pph-iconbtn--generate,
.uth-pph-iconbtn--generate:hover,
.uth-pph-iconbtn--generate:focus-visible {
	color: #fff;
	background: var(--uth-primary);
	border-color: var(--uth-primary);
}

.uth-pph-iconbtn--generate[disabled] {
	opacity: 0.6;
	cursor: default;
}

/* ---------- Settings ---------- */
.uth-pph-settings {
	padding: 20px;
	background: var(--uth-background);
	border: 1px solid var(--uth-border);
	border-radius: 18px;
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

.uth-pph-settings__inner {
	display: grid;
	gap: 16px;
}

.uth-pph-control {
	display: grid;
	gap: 7px;
}

.uth-pph-control[hidden] {
	display: none;
}

.uth-pph-control__label {
	color: var(--uth-muted);
	font-size: 0.82rem;
	font-weight: 600;
	line-height: 1.4;
}

.uth-pph-control__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.uth-pph-control__value {
	color: var(--uth-heading);
	font-size: 0.85rem;
	font-weight: 700;
}

.uth-pph-control__note {
	margin: 0;
	color: var(--uth-muted);
	font-size: 0.82rem;
	line-height: 1.5;
}

.uth-pph-control__note--dim {
	font-size: 0.78rem;
}

.uth-pph-range {
	width: 100%;
	accent-color: var(--uth-primary);
}

.uth-pph-custom-row {
	display: flex;
	align-items: center;
	gap: 8px;
	max-width: 320px;
}

.uth-pph-custom-row .uth-select {
	flex: 1;
	min-width: 0;
}

.uth-pph-custom-row__sep {
	color: var(--uth-muted);
	font-weight: 700;
}

.uth-pph-colors {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.uth-pph-color {
	position: relative;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 2px solid #cbd5e1;
	border-radius: 50%;
	cursor: pointer;
	transition: border-color 160ms ease, box-shadow 160ms ease;
}

.uth-pph-color:hover,
.uth-pph-color:focus-visible {
	border-color: var(--uth-primary);
	outline: none;
}

.uth-pph-color.is-active {
	border-color: var(--uth-primary);
	box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.2);
}

.uth-pph-color--custom {
	overflow: hidden;
	background: conic-gradient(#f43f5e, #f59e0b, #22c55e, #3b82f6, #f43f5e);
}

.uth-pph-color--custom input {
	position: absolute;
	inset: 6px;
	width: calc(100% - 12px);
	height: calc(100% - 12px);
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.uth-pph-btnrow {
	display: flex;
	align-items: center;
	gap: 10px;
}

.uth-pph-check .uth-select {
	min-width: 180px;
}

/* ---------- Status ---------- */
.uth-pph-status {
	min-height: 20px;
	margin-top: 4px;
	color: var(--uth-muted);
	font-size: 0.9rem;
	line-height: 1.5;
	text-align: center;
}

.uth-pph-status.is-error {
	color: var(--uth-danger);
}

/* ---------- Result ---------- */
.uth-pph-result {
	display: grid;
	gap: 16px;
	padding: 24px;
	background: var(--uth-background);
	border: 1px solid var(--uth-border);
	border-radius: 18px;
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

.uth-pph-result[hidden] {
	display: none;
}

.uth-pph-result__preview {
	display: flex;
	justify-content: center;
	padding: 20px;
	background: var(--uth-section-background);
	border: 1px solid var(--uth-border);
	border-radius: 14px;
}

.uth-pph-result__img {
	max-width: 260px;
	max-height: 320px;
	object-fit: contain;
	border: 1px solid var(--uth-border);
	border-radius: 6px;
}

.uth-pph-result__meta {
	margin: 0;
	color: var(--uth-text);
	font-size: 0.95rem;
	line-height: 1.5;
	text-align: center;
}

.uth-pph-result__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
}

.uth-pph-result__actions .uth-button[hidden] {
	display: none;
}

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
	.uth-pph-stage__inner {
		min-height: 300px;
		height: 360px;
	}

	.uth-pph-toolsbar {
		justify-content: center;
	}

	.uth-pph-settings {
		padding: 16px;
	}

	.uth-pph-result__actions .uth-button {
		width: 100%;
	}
}
/* ---------- Full-screen editor ---------- */
body.uth-pph-open {
	overflow: hidden;
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	overscroll-behavior: none;
	touch-action: none;
}

.uth-pph-editor {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: row;
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	padding-bottom: env(safe-area-inset-bottom);
	background: #0f172a;
	color: #e2e8f0;
}

.uth-pph-editor[hidden] {
	display: none;
}

.uth-pph-close {
	position: absolute;
	top: 14px;
	right: 16px;
	z-index: 45;
	width: 42px;
	height: 42px;
	color: #e2e8f0;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 50%;
}

.uth-pph-close:hover,
.uth-pph-close:focus-visible {
	color: #ffffff;
	background: rgba(239, 68, 68, 0.85);
	border-color: transparent;
}

.uth-pph-stage {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 0;
	border: 0;
	border-radius: 0;
	background:
		linear-gradient(45deg, rgba(148, 163, 184, 0.08) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, 0.08) 75%),
		linear-gradient(45deg, rgba(148, 163, 184, 0.08) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, 0.08) 75%);
	background-color: #1e293b;
	background-position: 0 0, 12px 12px;
	background-size: 24px 24px;
}

.uth-pph-stage__inner {
	flex: 1 1 auto;
	min-height: 0;
	height: auto;
	width: 100%;
}

.uth-pph-toolsbar {
	background: rgba(15, 23, 42, 0.96);
	border-top: 1px solid rgba(255, 255, 255, 0.14);
	z-index: 20;
}

.uth-pph-iconbtn {
	color: #cbd5e1;
}

.uth-pph-iconbtn:hover,
.uth-pph-iconbtn:focus-visible {
	color: #ffffff;
	background: rgba(255, 255, 255, 0.12);
	border-color: transparent;
}

.uth-pph-iconbtn.is-active {
	color: #ffffff;
	background: rgba(56, 189, 248, 0.22);
	border-color: rgba(56, 189, 248, 0.4);
}

.uth-pph-settings {
	position: static;
	z-index: 30;
	flex: none;
	width: min(400px, 40vw);
	height: 100%;
	overflow: auto;
	margin: 0;
	padding-top: 72px;
	background: rgba(15, 23, 42, 0.97);
	border: 0;
	border-left: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 0;
	box-shadow: none;
}

.uth-pph-iconbtn--settings {
	display: none;
}

.uth-pph-control__label,
.uth-pph-control__value,
.uth-pph-control__note,
.uth-pph-custom-row__sep,
.uth-pph-outputinfo {
	color: #e2e8f0;
}

.uth-pph-control__note {
	color: #94a3b8;
}

.uth-pph-settings .uth-select,
.uth-pph-settings .uth-pph-check .uth-select {
	color: #e2e8f0;
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(148, 163, 184, 0.3);
}

.uth-pph-status {
	position: absolute;
	left: 14px;
	bottom: 86px;
	z-index: 25;
	max-width: 60%;
	margin: 0;
	padding: 6px 12px;
	color: #cbd5e1;
	background: rgba(15, 23, 42, 0.75);
	border-radius: 999px;
	font-size: 0.82rem;
	pointer-events: none;
}

.uth-pph-status.is-error {
	color: #fecaca;
	background: rgba(153, 27, 27, 0.75);
}

.uth-pph-result {
	position: absolute;
	inset: 0;
	z-index: 40;
	align-content: center;
	justify-items: center;
	gap: 18px;
	padding: 24px 16px;
	overflow: auto;
	background: rgba(15, 23, 42, 0.92);
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.uth-pph-result__preview {
	background: rgba(255, 255, 255, 0.06);
	border-color: rgba(255, 255, 255, 0.14);
}

.uth-pph-result__meta {
	color: #e2e8f0;
}

.uth-pph-result .uth-button[data-pph-regenerate] {
	color: #e2e8f0;
	background: rgba(255, 255, 255, 0.12);
	border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 860px) {
	.uth-pph-editor {
		flex-direction: column;
	}

	.uth-pph-iconbtn--settings {
		display: inline-flex;
	}

	.uth-pph-settings {
		position: static;
		display: none;
		width: 100%;
		height: auto;
		max-height: 42vh;
		flex: none;
		padding-top: 16px;
		border-left: 0;
		border-top: 1px solid rgba(255, 255, 255, 0.14);
		box-shadow: none;
	}

	.uth-pph-settings.is-open {
		display: block;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		top: auto;
		z-index: 50;
		max-height: 52vh;
		border-radius: 16px 16px 0 0;
		border-top: 1px solid rgba(255, 255, 255, 0.16);
	}

	.uth-pph-settings__inner {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 16px 18px;
	}

	.uth-pph-stage__inner {
		min-height: 0;
	}

	.uth-pph-stage {
		min-height: 0;
	}
}

/* Keep the editor above the theme header/footer. */
body.uth-pph-open .uth-page,
body.uth-pph-open .uth-tool-hero {
	z-index: 999999;
}

.uth-pph-editor {
	z-index: 999999;
}

/* Settings close button (mobile only — desktop has a fixed side panel). */
.uth-pph-settings__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.uth-pph-settings-close {
	display: none;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	color: #e2e8f0;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(148, 163, 184, 0.3);
	border-radius: 50%;
	cursor: pointer;
}

.uth-pph-settings-close svg {
	width: 16px;
	height: 16px;
}

@media (max-width: 860px) {
	.uth-pph-settings-close {
		display: inline-flex;
	}
}
