html.hpic-lock,
body.hpic-lock {
	overflow: hidden !important;
	overscroll-behavior: none;
}

.hpic-modal {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(15, 18, 25, 0.72);
	-webkit-tap-highlight-color: transparent;
}

.hpic-modal.is-open {
	display: flex;
}

.hpic-dialog {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 640px;
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	overflow: hidden;
	background: #fff;
	color: #1d2327;
	border-radius: 14px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.hpic-dialog *,
.hpic-dialog *::before,
.hpic-dialog *::after {
	box-sizing: border-box;
}

.hpic-header {
	padding: 18px 20px 6px;
}

.hpic-title {
	margin: 0 0 4px !important;
	font-size: 18px !important;
	line-height: 1.3 !important;
}

.hpic-hint {
	margin: 0 !important;
	font-size: 14px;
	opacity: 0.7;
}

.hpic-body {
	display: flex;
	gap: 16px;
	align-items: flex-start;
	padding: 12px 20px;
	min-height: 0;
}

.hpic-stage {
	flex: 1 1 auto;
	min-width: 0;
	height: 420px;
	max-height: 55vh;
	max-height: 55dvh;
	background: #111;
	border-radius: 10px;
	overflow: hidden;
	touch-action: none;
}

.hpic-stage .hpic-img {
	display: block;
	max-width: 100%; /* required by Cropper.js */
}

.hpic-side {
	flex: 0 0 120px;
	text-align: center;
}

.hpic-preview {
	width: 120px;
	height: 120px;
	overflow: hidden;
	border-radius: 12px;
	background: #f0f0f1;
	border: 1px solid #dcdcde;
}

.hpic-preview-label {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	opacity: 0.6;
}

.hpic-tools {
	display: flex;
	justify-content: center;
	gap: 8px;
	padding: 4px 20px 8px;
}

.hpic-tool {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 44px !important;
	height: 44px !important;
	min-width: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 1px solid #dcdcde !important;
	border-radius: 10px !important;
	background: #fff !important;
	color: #1d2327 !important;
	box-shadow: none !important;
	cursor: pointer;
}

.hpic-tool:hover,
.hpic-tool:focus-visible {
	background: #f6f7f7 !important;
}

.hpic-tool svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.hpic-error {
	margin: 0 20px 8px;
	padding: 10px 12px;
	border-radius: 8px;
	background: #fcf0f1;
	color: #8a2424;
	font-size: 14px;
}

.hpic-error[hidden] {
	display: none;
}

.hpic-footer {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	padding: 12px 20px 18px;
	border-top: 1px solid #f0f0f1;
}

.hpic-btn {
	min-height: 44px;
	padding: 0 18px !important;
	margin: 0 !important;
	border-radius: 10px !important;
	font-size: 15px !important;
	font-weight: 600;
	cursor: pointer;
	line-height: 1 !important;
}

.hpic-btn--ghost {
	background: transparent !important;
	border: 1px solid #dcdcde !important;
	color: #1d2327 !important;
}

.hpic-btn--primary {
	border: 0 !important;
	background: var(--hpic-primary, #1d2327) !important;
	color: #fff !important;
}

.hpic-btn[disabled] {
	opacity: 0.6;
	cursor: wait;
}

.hpic-modal.is-busy .hpic-stage {
	background: #111 linear-gradient(90deg, #111 0%, #1c1c1c 50%, #111 100%);
}

/* Mobile: full-screen sheet, preview on top-right, bigger touch targets */
@media (max-width: 600px) {
	.hpic-modal {
		padding: 0;
		align-items: stretch;
	}

	.hpic-dialog {
		max-width: none;
		max-height: none;
		height: 100%;
		border-radius: 0;
	}

	.hpic-header {
		padding: calc(14px + env(safe-area-inset-top)) 16px 4px;
	}

	.hpic-body {
		flex: 1 1 auto;
		flex-direction: column-reverse;
		align-items: stretch;
		gap: 10px;
		padding: 10px 16px;
	}

	.hpic-stage {
		height: auto;
		flex: 1 1 auto;
		min-height: 240px;
		max-height: none;
	}

	.hpic-side {
		display: flex;
		align-items: center;
		gap: 10px;
		flex: 0 0 auto;
		text-align: left;
	}

	.hpic-preview {
		width: 56px;
		height: 56px;
	}

	.hpic-preview-label {
		margin: 0;
	}

	.hpic-footer {
		padding-bottom: calc(14px + env(safe-area-inset-bottom));
	}

	.hpic-btn {
		flex: 1 1 0;
	}
}
