:root {
	--ink: #28253d;
	--muted: #77748a;
	--purple: #7047eb;
	--purple-dark: #5935c6;
	--surface: #ffffff;
	--background: #f7f5f0;
	--border: #e9e6ef;
}

* {
	box-sizing: border-box;
}

body {
	min-width: 320px;
	margin: 0;
	padding: 24px 18px 16px;
	background: var(--background);
	color: var(--ink);
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
	font: inherit;
}

.app {
	width: min(100%, 850px);
	margin: 0 auto;
}

.app-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 2px 20px;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	color: var(--ink);
	font-size: 22px;
	font-weight: 850;
	letter-spacing: -1px;
	text-decoration: none;
}

.brand-icon {
	display: grid;
	width: 38px;
	height: 38px;
	place-items: center;
	border-radius: 13px;
	background: #ece5ff;
	font-size: 21px;
}

.app-header p,
.section-heading p {
	margin: 0;
	color: var(--muted);
	font-size: 14px;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: 14px;
}

.button-install {
	min-height: 38px;
	padding: 0 14px;
	background: #ece5ff;
	color: var(--purple-dark);
	font-size: 12px;
}

.button-install:hover {
	background: #ded3ff;
}

.install-message {
	margin: -7px 2px 16px;
	color: var(--muted);
	font-size: 13px;
	text-align: right;
}

.card {
	overflow: hidden;
	border: 1px solid rgba(40, 37, 61, 0.06);
	border-radius: 22px;
	background: var(--surface);
	box-shadow: 0 16px 45px rgba(47, 37, 76, 0.07);
}

.camera-view,
.editor-view {
	padding: clamp(20px, 5vw, 38px);
}

.section-heading {
	margin-bottom: 23px;
	text-align: center;
}

.step-label {
	display: inline-block;
	margin-bottom: 9px;
	color: var(--purple);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 1.4px;
}

h1,
h2,
p {
	margin-top: 0;
}

.section-heading h1 {
	margin-bottom: 7px;
	font-size: clamp(23px, 5vw, 32px);
	letter-spacing: -1px;
}

.camera-frame {
	position: relative;
	display: grid;
	width: 100%;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	place-items: center;
	border-radius: 16px;
	background: #211e2b;
}

#video {
	display: none;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

#video.is-active {
	display: block;
}

.camera-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 18px;
	color: white;
	text-align: center;
}

.camera-placeholder > span {
	margin-bottom: 10px;
	font-size: 40px;
}

.camera-placeholder p {
	margin-bottom: 18px;
	color: rgba(255, 255, 255, 0.77);
	font-size: 14px;
}

.button {
	display: inline-flex;
	min-height: 46px;
	align-items: center;
	justify-content: center;
	padding: 0 19px;
	border: 0;
	border-radius: 12px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 750;
	text-align: center;
	transition: background-color 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.button:not(:disabled):active {
	transform: translateY(1px);
}

.button:focus-visible,
.mask-option:focus-visible,
input:focus-visible {
	outline: 3px solid rgba(112, 71, 235, 0.35);
	outline-offset: 3px;
}

.button-primary {
	background: var(--purple);
	color: white;
}

.button-primary:hover:not(:disabled) {
	background: var(--purple-dark);
}

.button-secondary {
	border: 1px solid var(--border);
	background: white;
	color: var(--ink);
}

.button-secondary:hover {
	background: #f4f1fb;
}

.button-quiet {
	min-height: 40px;
	padding: 0 12px;
	background: #f4f2f8;
	color: var(--ink);
}

.button-quiet:hover:not(:disabled) {
	background: #eae6f4;
}

.button:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.message {
	min-height: 0;
	margin: 10px 0 0;
	color: #a23a48;
	font-size: 13px;
	text-align: center;
}

.message:empty {
	display: none;
}

.capture-actions {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 17px;
}

.action-divider {
	color: #aaa7b5;
	font-size: 12px;
}

.upload-button {
	cursor: pointer;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	clip-path: inset(50%);
}

.privacy-note,
footer {
	margin: 15px 0 0;
	color: #9996a3;
	font-size: 12px;
	text-align: center;
}

[hidden] {
	display: none !important;
}

.editor-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	text-align: left;
}

.editor-heading h1 {
	margin-bottom: 6px;
}

.editor-heading .step-label {
	margin-bottom: 7px;
}

.editor-stage {
	position: relative;
	width: 100%;
	overflow: hidden;
	border-radius: 14px;
	background: #f0edf5;
	touch-action: none;
}

#canvas {
	display: block;
	width: 100%;
	height: auto;
}

.mask-layer {
	position: absolute;
	inset: 0;
	overflow: hidden;
	touch-action: none;
}

.placed-mask {
	position: absolute;
	max-width: none;
	height: auto;
	cursor: grab;
	touch-action: none;
	transform: translate(-50%, -50%);
	user-select: none;
	-webkit-user-drag: none;
}

.placed-mask:active {
	cursor: grabbing;
}

.editor-controls {
	padding-top: 23px;
}

.control-heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.control-heading h2 {
	margin-bottom: 12px;
	font-size: 15px;
}

.control-heading span,
.editor-tip,
.range-labels {
	color: var(--muted);
	font-size: 12px;
}

.mask-picker {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 10px;
}

.mask-option {
	display: grid;
	height: 82px;
	place-items: center;
	overflow: hidden;
	border: 2px solid transparent;
	border-radius: 13px;
	background: #f5f3f8;
	cursor: pointer;
	transition: border-color 150ms ease, background-color 150ms ease;
}

.mask-option:hover {
	background: #efebf8;
}

.mask-option.is-selected {
	border-color: var(--purple);
	background: #f0ebff;
}

.mask-option img {
	display: block;
	width: auto;
	max-width: 72%;
	height: 70%;
	object-fit: contain;
	pointer-events: none;
}

.size-control {
	margin-top: 22px;
}

.size-control label {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	font-size: 14px;
	font-weight: 750;
}

.size-control output {
	color: var(--purple);
}

.size-control input {
	width: 100%;
	margin: 15px 0 5px;
	accent-color: var(--purple);
	cursor: pointer;
}

.range-labels {
	display: flex;
	justify-content: space-between;
}

.editor-tip {
	margin: 16px 0 0;
}

.editor-actions {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
	body {
		padding: 14px 10px 12px;
	}

	.app-header {
		margin-bottom: 13px;
	}

	.brand {
		font-size: 19px;
	}

	.brand-icon {
		width: 34px;
		height: 34px;
	}

	.app-header p {
		max-width: 145px;
		font-size: 11px;
		text-align: right;
	}

	.header-actions {
		gap: 7px;
	}

	.button-install {
		min-height: 35px;
		padding: 0 10px;
		font-size: 11px;
		white-space: nowrap;
	}

	.install-message {
		font-size: 12px;
	}

	.card {
		border-radius: 17px;
	}

	.capture-actions {
		flex-wrap: wrap;
		gap: 9px;
	}

	.capture-actions .button {
		min-height: 43px;
		padding: 0 13px;
		font-size: 12px;
	}

	.editor-heading {
		align-items: flex-start;
	}

	.editor-heading .button {
		min-height: 36px;
		padding: 0 9px;
		font-size: 11px;
		white-space: nowrap;
	}

	.editor-heading p {
		max-width: 240px;
		font-size: 12px;
	}

	.mask-picker {
		gap: 6px;
	}

	.mask-option {
		height: 66px;
		border-radius: 10px;
	}

	.control-heading {
		align-items: flex-start;
	}

	.control-heading span {
		max-width: 145px;
		text-align: right;
	}

	.editor-actions .button {
		min-height: 42px;
		padding: 0 11px;
		font-size: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}
