:root {
	color-scheme: light;
	--ink: #253b36;
	--muted: #727b73;
	--line: #e1e5dd;
	--green: #28715a;
	--paper: #fff;
	--bg: #fffffd;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0px;
	color: var(--ink);
	background: var(--bg);
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Noto Sans", sans-serif;
	font-size: 14px;
	line-height: 1.7;
}

button, input {
	font: inherit;
}

button, a, input {
	-webkit-tap-highlight-color: transparent;
}

button, a, input[type="range"] {
	touch-action: manipulation;
}

button {
	cursor: pointer;
}

button:disabled, fieldset:disabled {
	opacity: 0.45;
}

button:disabled {
	cursor: default;
}

[hidden] {
	display: none !important;
}

a {
	color: inherit;
	text-decoration: none;
}

.header {
	min-height: 84px;
	padding: 0px 5%;
	border-bottom: 1px solid var(--line);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
}

main {
	max-width: 1200px;
	margin: auto;
	padding: 48px 32px 64px;
}

.workspace {
	display: grid;
	grid-template-columns: minmax(0px, 1fr) 330px;
	gap: 24px;
	align-items: start;
}

.editor, .card {
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: 16px;
}

.editor {
	overflow: hidden;
}

h2 {
	font-size: 15px;
	margin: 0px;
	font-weight: 650;
}

.stage {
	background: radial-gradient(rgb(203, 209, 198) 0.7px, transparent 0.7px) 0% 0% / 10px 10px rgb(233, 236, 230);
	padding: 24px;
	display: flex;
	justify-content: center;
	overflow: hidden;
	position: relative;
}

#imageContainer {
	position: relative;
	background: white;
	overflow: hidden;
	touch-action: none;
	user-select: none;
	cursor: grab;
	box-shadow: rgba(35, 53, 46, 0.07) 0px 8px 30px;
}

#imageContainer.dragging {
	cursor: grabbing;
}

#image {
	position: absolute;
	pointer-events: none;
	max-width: none;
	transform-origin: center center;
}

#mask {
	position: absolute;
	width: 84%;
	height: 88.1306%;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	pointer-events: none;
}

#mask img {
	width: 100%;
	display: block;
}

#mask::before {
	content: "";
	position: absolute;
	inset: 0px;
	border: 1px dashed rgba(86, 118, 102, 0.5);
	box-shadow: rgba(37, 68, 53, 0.08) 0px 0px 0px 1000px;
	z-index: 1;
}

#emptyState {
	position: absolute;
	inset: 0px;
	background: rgba(253, 253, 251, 0.96);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	text-align: center;
	cursor: default;
}

.primary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0px;
	border-radius: 9px;
	background: var(--green);
	color: white;
	padding: 12px 22px;
	font-size: 13px;
	font-weight: 600;
	min-height: 44px;
	cursor: pointer;
	transition: background 0.15s, transform 0.15s;
}

.primary:hover:not(:disabled) {
	background: rgb(32, 93, 74);
}

.primary:active:not(:disabled) {
	transform: translateY(1px);
}

.full {
	width: 100%;
}

.editor-footer {
	position: absolute;
	font-size: 10px;
	color: var(--muted);
	bottom: 5px;
	right: 5px;
	margin: 0px;
}

.card {
	padding: 22px;
}

.text-button {
	margin-left: auto;
	border: 0px;
	background: none;
	color: var(--muted);
	font-size: 11px;
	padding: 7px 0px 7px 10px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

fieldset {
	padding: 0px;
	margin: 0px;
	border: 0px;
	min-width: 0px;
}

.range-heading {
	font-size: 12px;
}

.range-heading {
	justify-content: space-between;
}

.range-heading output {
	font-variant-numeric: tabular-nums;
	font-size: 11px;
	color: var(--green);
	background: rgb(239, 244, 237);
	padding: 1px 7px;
	border-radius: 4px;
}

input[type="range"] {
	width: 100%;
	accent-color: var(--green);
	height: 24px;
	margin: 0px;
	cursor: pointer;
}

.help {
	border-top: 1px solid var(--line);
	margin-top: 20px;
	padding-top: 14px;
	color: var(--muted);
	font-size: 11px;
}

.help summary {
	cursor: pointer;
}

.help p {
	line-height: 1.9;
}

.preview {
	padding: 16px;
	background: rgb(233, 236, 230);
	border-radius: 8px;
}

#canvas {
	display: block;
	width: 100%;
	height: auto;
	box-shadow: rgba(35, 53, 46, 0.07) 0px 4px 16px;
}

@media (max-width: 800px) {
	.header {
		min-height: 70px;
	}

	main {
		padding: 32px 18px 40px;
	}

	.workspace {
		grid-template-columns: minmax(0px, 1fr) 290px;
		gap: 16px;
	}

	.card {
		padding: 18px;
	}

	.stage {
		padding: 18px;
	}

}

@media (max-width: 620px) {
	.workspace {
		grid-template-columns: 1fr;
	}

	.stage {
		padding: 20px;
	}

	.card {
		padding: 20px;
	}

	.preview {
		max-width: 260px;
		width: 100%;
		margin: auto;
	}

}

#imageContainer {
	width: 88%;
	max-width: 23.1rem;
	aspect-ratio: 1051 / 1500;
}

#imageContainer #image {
	z-index: 0;
}

#imageContainer #mask {
	width: calc(95.4545%);
	height: calc(95.4545%);
	z-index: 1;
}

#imageContainer #mask img {
	width: 100%;
	height: 100%;
}

#emptyState {
	z-index: 2;
}

.logo {
	width: 200px;
	max-width: 70%;
	height: auto;
}

.start-card {
	max-width: 440px;
	margin: 0px auto;
	padding: 28px;
}

.start-card h1 {
	font-size: 20px;
	margin: 0px 0px 16px;
}

.start-card > p {
	color: var(--muted);
	font-size: 12px;
}

.start-form {
	display: grid;
	gap: 12px;
}

.start-form input[type="text"] {
	width: 100%;
	font-size: 1rem;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
}

.id-bar {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 18px;
	margin-bottom: 20px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: white;
	overflow-wrap: anywhere;
}

.id-bar a {
	color: var(--green);
	text-decoration: underline;
}

.control-heading {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 18px;
}

.control-heading h1 {
	font-size: 15px;
	font-weight: 650;
	margin: 0px;
}

.range-heading {
	display: grid;
	grid-template-columns: 5rem minmax(0px, 1fr) 3rem;
	gap: 0.5rem;
	align-items: center;
	margin: 0.75rem 0px;
}

.range-heading label {
	white-space: nowrap;
}

.range-heading input[type="range"] {
	min-width: 0px;
}

.range-heading output {
	justify-self: end;
}

#saveButton {
	width: 100%;
	margin-top: 20px;
}

dialog {
	width: min(460px, 100% - 24px);
	max-height: calc(100dvh - 24px);
	padding: 24px;
	background: var(--paper);
	color: var(--ink);
	border: 1px solid var(--line);
	border-radius: 16px;
}

dialog::backdrop {
	background: rgba(0, 0, 0, 0.55);
}

dialog[open] {
	display: flex;
	flex-direction: column;
}

dialog h2 {
	text-align: center;
	margin-bottom: 16px;
}

dialog .preview {
	min-height: 0px;
	display: flex;
	justify-content: center;
}

dialog #canvas {
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: calc(100dvh - 280px);
	object-fit: contain;
}

#uploadStatus {
	font-size: 13px;
	margin: 8px 0px;
	overflow-wrap: anywhere;
}

#uploadStatus:empty {
	margin: 0px;
}

.dialog-actions {
	display: flex;
	gap: 12px;
	margin-top: 16px;
}

.dialog-actions button {
	flex: 1 1 0%;
}

#backButton {
	min-height: 44px;
	padding: 12px 22px;
	border: 1px solid var(--line);
	border-radius: 9px;
	background: var(--paper);
	color: var(--ink);
	font-size: 13px;
}

.start-card > a.primary {
	display: flex;
	width: fit-content;
	margin: 0px auto;
}

@media (min-width: 38.8125em) and (orientation: landscape) and (pointer: coarse) {
	.header {
		min-height: 3.5rem;
		padding: 0px 1rem;
	}

	.logo {
		width: 10rem;
	}

	main {
		padding: 1rem 1.5rem 1.5rem;
	}

	.workspace {
		grid-template-columns: minmax(0px, 1fr) 20.625rem;
		gap: 1rem;
	}

	.stage {
		padding: 0.75rem;
	}

	#imageContainer {
		max-width: min(23.1rem, -5.54928rem + 61.6587svh);
	}

}

@media (max-width: 38.75em), (max-width: 75em) and (orientation: portrait), (max-width: 64em) and (max-height: 30em) {
	.header {
		min-height: 3.5rem;
		padding: 0px 1rem;
	}

	.logo {
		width: 10rem;
	}

	main {
		padding: 0.75rem 1rem 1rem;
	}

	.workspace {
		grid-template-columns: 1fr;
		gap: 0.75rem;
		max-width: 30rem;
		margin: 0px auto;
	}

	.right {
		min-width: 0px;
	}

	.stage {
		padding: 0.5rem;
	}

	#imageContainer {
		width: 88%;
		max-width: 23.1rem;
	}
	.editor-footer {
		padding: 0px;
		bottom:0;
	}

	.id-bar {
		padding: 0.5rem 0.75rem;
		margin-bottom: 0.5rem;
	}

	.controls {
		padding: 0.75rem;
	}

	.control-heading {
		margin-bottom: 0;
		gap:0;
	}
	.control-heading h1{
		font-size:13px;
	}

	.text-button{padding:0;}

	.range-heading {
		margin: 0.375rem 0px;
	}

	input[type="range"] {
		height: 1.75rem;
	}

	.help {
		margin-top: 0.625rem;
		padding-top: 0.5rem;
	}

	#saveButton {
		margin-top: 0.5rem;
	}

	dialog {
		padding: 0.75rem;
		max-height: calc(-1.5rem + 100svh);
	}

	dialog .preview {
		padding: 0.5rem;
	}

	dialog #canvas {
		max-height: calc(-11rem + 100svh);
	}

}

