:root {
	--bg: #f3f4f6;
	--panel: #ffffff;
	--panel-soft: #f8f9fb;
	--text: #17181b;
	--muted: #747982;
	--line: #e3e5e9;
	--accent: #6d5dfc;
	--accent-dark: #5647e8;
	--success: #21865a;
	--warning: #a66a09;
	--danger: #b43838;
	--shadow: 0 22px 65px rgba(22, 24, 29, 0.08);
	--radius: 22px;
}

* {
	box-sizing: border-box;
}

html {
	min-height: 100%;
	background: var(--bg);
}

body {
	margin: 0;
	min-height: 100vh;
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: var(--text);
	background:
		radial-gradient(circle at 12% -8%, rgba(109, 93, 252, 0.13), transparent 29rem),
		var(--bg);
}

button,
input,
select {
	font: inherit;
}

button {
	border: 0;
}

.page-shell {
	width: min(1180px, calc(100% - 40px));
	margin: 0 auto;
	padding: 52px 0 72px;
}

.site-header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
	margin-bottom: 28px;
}

.eyebrow {
	font-size: 0.72rem;
	font-weight: 800;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: var(--accent);
}

.site-header h1 {
	margin: 5px 0 3px;
	font-size: clamp(2.35rem, 5vw, 4.4rem);
	line-height: 0.95;
	letter-spacing: -0.06em;
}

.site-header p {
	margin: 12px 0 0;
	font-size: 1rem;
	color: var(--muted);
}

.workspace-card,
.queue-section {
	border: 1px solid rgba(224, 226, 231, 0.9);
	border-radius: var(--radius);
	background: rgba(255, 255, 255, 0.94);
	box-shadow: var(--shadow);
}

.workspace-card {
	overflow: hidden;
}

.workspace-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.06fr) minmax(360px, 0.94fr);
}

.upload-panel,
.settings-panel {
	padding: 30px;
}

.upload-panel {
	border-right: 1px solid var(--line);
}

.section-heading,
.queue-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 18px;
}

.section-heading {
	margin-bottom: 20px;
}

.section-heading > div,
.queue-heading > div {
	display: flex;
	align-items: baseline;
	gap: 12px;
}

.section-heading h2,
.queue-heading h2,
.modal-card h2 {
	margin: 0;
	font-size: 1.3rem;
	letter-spacing: -0.025em;
}

.section-meta {
	font-size: 0.78rem;
	color: var(--muted);
}

/* Keep the artwork area fixed so large source images cannot expand the page. */
.upload-dropzone {
	display: flex;
	height: 480px;
	min-height: 480px;
	max-height: 480px;
	align-items: center;
	justify-content: center;
	border: 1.5px dashed #cfd2d9;
	border-radius: 18px;
	background:
		linear-gradient(45deg, rgba(237, 238, 242, 0.6) 25%, transparent 25%),
		linear-gradient(-45deg, rgba(237, 238, 242, 0.6) 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, rgba(237, 238, 242, 0.6) 75%),
		linear-gradient(-45deg, transparent 75%, rgba(237, 238, 242, 0.6) 75%);
	background-size: 24px 24px;
	background-position: 0 0, 0 12px, 12px -12px, -12px 0;
	cursor: pointer;
	overflow: hidden;
	transition: border-color 160ms ease, transform 160ms ease, background-color 160ms ease;
}

.upload-dropzone:hover,
.upload-dropzone.is-dragging {
	border-color: var(--accent);
	transform: translateY(-1px);
}

/* Ensure hidden upload states are not overridden by their display rules. */
.upload-empty[hidden],
.upload-preview-wrap[hidden] {
	display: none;
}

.upload-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 35px;
	text-align: center;
	background: rgba(255, 255, 255, 0.9);
	border-radius: 18px;
	box-shadow: 0 8px 28px rgba(31, 34, 41, 0.07);
}

.upload-empty strong {
	font-size: 1rem;
}

.upload-empty span {
	font-size: 0.8rem;
	color: var(--muted);
}

.upload-mark {
	display: grid;
	width: 42px;
	height: 42px;
	place-items: center;
	margin-bottom: 3px;
	border-radius: 50%;
	background: var(--text);
	color: #fff;
	font-size: 1.7rem;
	font-weight: 300;
	line-height: 1;
}

.upload-preview-wrap {
	position: relative;
	width: 100%;
	height: 100%;
	min-height: 480px;
	background: #eceef1;
}

/* Fit the selected artwork inside the preview without using its intrinsic dimensions. */
.upload-preview {
	display: block;
	width: 100%;
	max-width: 100%;
	height: 480px;
	max-height: 480px;
	object-fit: contain;
}

.preview-overlay {
	position: absolute;
	right: 14px;
	bottom: 14px;
	padding: 8px 11px;
	border-radius: 999px;
	background: rgba(20, 21, 24, 0.82);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 700;
}

.settings-form {
	display: grid;
	gap: 18px;
}

.field {
	display: grid;
	gap: 7px;
}

.field-label {
	font-size: 0.89rem;
	font-weight: 800;
}

.field-help {
	margin-top: -3px;
	font-size: 0.77rem;
	line-height: 1.45;
	color: var(--muted);
}

.field input,
.field select {
	width: 100%;
	height: 48px;
	padding: 0 13px;
	border: 1px solid var(--line);
	border-radius: 12px;
	outline: none;
	background: var(--panel-soft);
	color: var(--text);
	transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input:focus,
.field select:focus {
	border-color: rgba(109, 93, 252, 0.7);
	background: #fff;
	box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.09);
}

.input-suffix-wrap {
	position: relative;
}

.input-suffix-wrap input {
	padding-right: 54px;
}

.input-suffix-wrap > span {
	position: absolute;
	top: 50%;
	right: 13px;
	transform: translateY(-50%);
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--muted);
}

.primary-button {
	cursor: pointer;
	transition: transform 150ms ease, opacity 150ms ease, background 150ms ease;
}

.primary-button {
	display: flex;
	width: 100%;
	height: 54px;
	align-items: center;
	justify-content: space-between;
	margin-top: 24px;
	padding: 0 18px 0 20px;
	border-radius: 14px;
	background: var(--accent);
	color: #fff;
	font-weight: 800;
}

.primary-button:not(:disabled):hover {
	transform: translateY(-1px);
	background: var(--accent-dark);
}

.primary-button:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.button-arrow {
	font-size: 1.2rem;
}

.form-message {
	margin-top: 18px;
	padding: 11px 13px;
	border-radius: 11px;
	font-size: 0.8rem;
	line-height: 1.45;
}

.form-message[data-type="error"] {
	background: #fff0f0;
	color: var(--danger);
}

.form-message[data-type="success"] {
	background: #edf8f2;
	color: var(--success);
}

.queue-section {
	margin-top: 24px;
	padding: 28px 30px 30px;
}

.queue-heading {
	margin-bottom: 20px;
}

.queue-empty[hidden] {
	display: none;
}

.queue-empty {
	display: flex;
	min-height: 135px;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 7px;
	border: 1px dashed var(--line);
	border-radius: 16px;
	background: var(--panel-soft);
	text-align: center;
}

.queue-empty strong {
	font-size: 0.92rem;
}

.queue-empty span {
	font-size: 0.78rem;
	color: var(--muted);
}

.queue-list {
	display: grid;
	gap: 11px;
}

.queue-item {
	display: grid;
	grid-template-columns: 68px minmax(0, 1fr) auto;
	align-items: center;
	gap: 16px;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 15px;
	background: #fff;
	transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.queue-item.is-clickable {
	cursor: pointer;
}

.queue-item.is-clickable:hover {
	border-color: #cfd2d9;
	transform: translateY(-1px);
	box-shadow: 0 8px 25px rgba(25, 28, 33, 0.05);
}

.queue-item.is-disabled {
	cursor: default;
}

.queue-thumb {
	display: grid;
	width: 68px;
	height: 68px;
	place-items: center;
	overflow: hidden;
	border-radius: 11px;
	background: #eff0f3;
	font-size: 1.25rem;
	font-weight: 800;
	color: #9a9ea6;
}

.queue-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.queue-title {
	margin-bottom: 5px;
	font-size: 0.9rem;
	font-weight: 800;
}

.queue-details {
	display: flex;
	flex-wrap: wrap;
	gap: 5px 13px;
	font-size: 0.75rem;
	color: var(--muted);
}

.queue-progress {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 38px;
	align-items: center;
	gap: 10px;
	margin-top: 10px;
	font-size: 0.72rem;
	font-weight: 800;
	color: var(--muted);
}

.queue-progress-track {
	height: 7px;
	overflow: hidden;
	border-radius: 999px;
	background: #eceef2;
}

.queue-progress-fill {
	height: 100%;
	border-radius: inherit;
	background: var(--accent);
	transition: width 240ms ease;
}

.queue-progress span {
	text-align: right;
}

.queue-status {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 7px 10px;
	border-radius: 999px;
	background: #f0f1f3;
	font-size: 0.73rem;
	font-weight: 800;
	text-transform: capitalize;
}

.queue-status[data-state="complete"] {
	background: #edf8f2;
	color: var(--success);
}

.queue-status[data-state="working"] {
	background: #fff6e6;
	color: var(--warning);
}

.queue-status[data-state="error"] {
	background: #fff0f0;
	color: var(--danger);
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 50;
	overflow-y: auto;
	padding: 24px;
}

.modal[hidden] {
	display: none;
}

.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(18, 20, 24, 0.56);
	backdrop-filter: blur(5px);
}

.modal-card {
	position: relative;
	z-index: 1;
	width: min(1120px, 100%);
	margin: 24px auto;
	padding: 28px;
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
}

.modal-close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: #f0f1f3;
	cursor: pointer;
	font-weight: 800;
}

.modal-body {
	margin-top: 18px;
}

.result-loading,
.result-state-card {
	display: flex;
	min-height: 180px;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 30px;
	border: 1px dashed var(--line);
	border-radius: 16px;
	background: var(--panel-soft);
	text-align: center;
}

.result-loading strong,
.result-state-card strong {
	font-size: 1rem;
}

.result-loading span,
.result-state-card span {
	max-width: 520px;
	font-size: 0.82rem;
	line-height: 1.5;
	color: var(--muted);
}

.result-state-card.is-error {
	border-color: #f0caca;
	background: #fff5f5;
}

.result-state-card.is-error strong {
	color: var(--danger);
}

.result-state-progress {
	width: min(380px, 100%);
	height: 8px;
	overflow: hidden;
	margin-top: 10px;
	border-radius: 999px;
	background: #e7e9ed;
}

.result-state-progress span {
	display: block;
	height: 100%;
	border-radius: inherit;
	background: var(--accent);
}

.result-viewer {
	display: grid;
	gap: 18px;
}

.result-gallery,
.result-information,
.thread-section {
	min-width: 0;
}

.result-image-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
}

.result-image-card {
	display: grid;
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: 15px;
	background: var(--panel-soft);
	color: var(--text);
	text-decoration: none;
	transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.result-image-card:hover {
	border-color: #cfd2d9;
	transform: translateY(-1px);
	box-shadow: 0 8px 25px rgba(25, 28, 33, 0.05);
}

.result-image-card img {
	display: block;
	width: 100%;
	height: 330px;
	object-fit: contain;
	background:
		linear-gradient(45deg, rgba(237, 238, 242, 0.72) 25%, transparent 25%),
		linear-gradient(-45deg, rgba(237, 238, 242, 0.72) 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, rgba(237, 238, 242, 0.72) 75%),
		linear-gradient(-45deg, transparent 75%, rgba(237, 238, 242, 0.72) 75%);
	background-size: 20px 20px;
	background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.result-image-card > span {
	padding: 9px 12px;
	border-top: 1px solid var(--line);
	background: #fff;
	font-size: 0.77rem;
	font-weight: 800;
}

.result-information {
	padding: 17px;
	border: 1px solid var(--line);
	border-radius: 17px;
	background: var(--panel-soft);
}

.result-section-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 12px;
}

.result-section-heading h3,
.thread-heading h4 {
	margin: 0;
	font-size: 1rem;
	letter-spacing: -0.015em;
}

.download-button {
	display: inline-flex;
	min-height: 38px;
	align-items: center;
	justify-content: center;
	padding: 0 14px;
	border-radius: 11px;
	background: var(--accent);
	color: #fff;
	font-size: 0.76rem;
	font-weight: 800;
	text-decoration: none;
	white-space: nowrap;
	transition: transform 150ms ease, background 150ms ease;
}

.download-button:hover {
	transform: translateY(-1px);
	background: var(--accent-dark);
}

.embroidery-summary {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 9px;
}

.summary-stat {
	display: grid;
	gap: 4px;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: #fff;
}

.summary-stat span {
	font-size: 0.69rem;
	color: var(--muted);
}

.summary-stat strong {
	font-size: 0.88rem;
	font-weight: 800;
}

.thread-section {
	padding: 17px;
	border: 1px solid var(--line);
	border-radius: 17px;
	background: var(--panel-soft);
}

.thread-heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.thread-heading span {
	font-size: 0.7rem;
	color: var(--muted);
}

.thread-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
	gap: 8px;
}

.thread-swatch {
	display: flex;
	min-width: 0;
	align-items: center;
	gap: 9px;
	padding: 7px 9px;
	border: 1px solid var(--line);
	border-radius: 11px;
	background: #fff;
}

.thread-chip {
	width: 30px;
	height: 30px;
	flex: 0 0 30px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 8px;
}

.thread-swatch-details {
	display: grid;
	min-width: 0;
}

.thread-swatch-details span {
	overflow: hidden;
	font-size: 0.68rem;
	font-weight: 700;
	color: var(--muted);
	text-overflow: ellipsis;
}

.result-empty {
	padding: 18px;
	border: 1px dashed var(--line);
	border-radius: 13px;
	background: #fff;
	font-size: 0.78rem;
	line-height: 1.5;
	color: var(--muted);
}

@media (max-width: 820px) {
	.page-shell {
		width: min(100% - 24px, 720px);
		padding-top: 28px;
	}

	.site-header {
		align-items: flex-start;
		flex-direction: column;
	}

	.workspace-grid {
		grid-template-columns: 1fr;
	}

	.upload-panel {
		border-right: 0;
		border-bottom: 1px solid var(--line);
	}

	.upload-dropzone,
	.upload-preview-wrap,
	.upload-preview {
		min-height: 360px;
		height: 360px;
	}

	.result-image-card img {
		height: 300px;
	}

	.embroidery-summary {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 540px) {
	.page-shell {
		width: min(100% - 18px, 520px);
		padding-top: 20px;
	}

	.upload-panel,
	.settings-panel,
	.queue-section {
		padding: 20px;
	}

	.section-heading {
		align-items: flex-start;
		flex-direction: column;
		gap: 7px;
	}

	.section-heading > div,
	.queue-heading > div {
		align-items: flex-start;
		flex-direction: column;
		gap: 4px;
	}

	.upload-dropzone,
	.upload-preview-wrap,
	.upload-preview {
		min-height: 300px;
		height: 300px;
	}

	.queue-item {
		grid-template-columns: 54px minmax(0, 1fr);
	}

	.queue-thumb {
		width: 54px;
		height: 54px;
	}

	.queue-status {
		grid-column: 2;
		justify-self: start;
	}

	.modal {
		padding: 9px;
	}

	.modal-card {
		margin: 9px auto;
		padding: 22px 18px 18px;
	}

	.result-image-grid,
	.embroidery-summary {
		grid-template-columns: 1fr;
	}

	.result-image-card img {
		height: 280px;
	}
}
