:root {
	--background: #f7f8fa;
	--surface: #ffffff;
	--surface-subtle: #f9fafb;
	--text: #18181b;
	--text-muted: #71717a;
	--border: #e4e4e7;
	--border-strong: #d4d4d8;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--accent-soft: #eff6ff;
	--danger: #b42318;
	--danger-soft: #fef3f2;
	--radius: 10px;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
}

* {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
}

body {
	min-height: 100vh;
	margin: 0;
	display: flex;
	flex-direction: column;
	color: var(--text);
	background: var(--background);
	font-family:
		Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
		"Segoe UI", sans-serif;
	-webkit-font-smoothing: antialiased;
}

button,
input {
	font: inherit;
}

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

button:focus-visible,
a:focus-visible,
label:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.28);
	outline-offset: 2px;
}

.site-header {
	background: rgba(255, 255, 255, 0.92);
	border-bottom: 1px solid var(--border);
}

.header-inner,
.page-shell,
.footer-inner {
	width: min(1040px, calc(100% - 40px));
	margin: 0 auto;
}

.header-inner {
	display: flex;
	height: 64px;
	align-items: center;
	justify-content: space-between;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-size: 17px;
	font-weight: 650;
	letter-spacing: -0.02em;
	text-decoration: none;
}

.brand-mark {
	display: grid;
	width: 34px;
	height: 34px;
	place-items: center;
	color: #ffffff;
	background: var(--accent);
	border-radius: 8px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: -0.03em;
}

.github-link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #52525b;
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
}

.github-link:hover,
.footer-inner a:hover {
	color: var(--text);
}

.github-link svg {
	width: 14px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.6;
}

.page-shell {
	padding: 64px 0 48px;
}

.intro {
	max-width: 640px;
	margin: 0 auto 36px;
	text-align: center;
}

.eyebrow {
	margin: 0 0 12px;
	color: var(--accent);
	font-size: 13px;
	font-weight: 650;
}

.intro h1 {
	margin: 0;
	font-size: clamp(32px, 5vw, 46px);
	font-weight: 700;
	letter-spacing: -0.045em;
	line-height: 1.12;
}

.intro > p:last-child {
	margin: 16px 0 0;
	color: var(--text-muted);
	font-size: 16px;
	line-height: 1.6;
}

.converter {
	display: grid;
	grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
	overflow: hidden;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: var(--shadow);
}

.controls-panel {
	padding: 32px;
	border-right: 1px solid var(--border);
}

.section-heading h2,
.preview-heading h2 {
	margin: 0;
	font-size: 15px;
	font-weight: 650;
	letter-spacing: -0.01em;
}

.section-heading p {
	margin: 6px 0 18px;
	color: var(--text-muted);
	font-size: 12px;
}

.drop-zone {
	display: flex;
	width: 100%;
	min-height: 160px;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	color: var(--text);
	background: var(--surface-subtle);
	border: 1px dashed var(--border-strong);
	border-radius: var(--radius);
	cursor: pointer;
	transition:
		background-color 160ms ease,
		border-color 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
	background: var(--accent-soft);
	border-color: var(--accent);
}

.upload-icon,
.preview-icon {
	display: grid;
	place-items: center;
	color: #52525b;
}

.upload-icon {
	width: 38px;
	height: 38px;
	margin-bottom: 12px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
}

.upload-icon svg {
	width: 20px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.7;
}

.drop-title {
	font-size: 13px;
	font-weight: 600;
}

.drop-copy {
	margin-top: 4px;
	color: var(--accent);
	font-size: 12px;
	font-weight: 500;
}

.file-chip {
	display: flex;
	min-height: 76px;
	align-items: center;
	gap: 12px;
	padding: 10px;
	background: var(--surface-subtle);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.file-chip[hidden] {
	display: none;
}

.file-thumb-wrap {
	display: grid;
	overflow: hidden;
	flex: 0 0 54px;
	width: 54px;
	height: 54px;
	place-items: center;
	background: #ffffff;
	border: 1px solid var(--border);
	border-radius: 7px;
}

.file-thumb-wrap img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.file-details {
	display: flex;
	min-width: 0;
	flex: 1;
	flex-direction: column;
}

.file-details strong {
	overflow: hidden;
	font-size: 13px;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.file-details span {
	margin-top: 4px;
	color: var(--text-muted);
	font-size: 11px;
}

.file-chip button {
	display: grid;
	width: 30px;
	height: 30px;
	place-items: center;
	color: var(--text-muted);
	background: transparent;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
}

.file-chip button:hover {
	color: var(--text);
	background: #eeeeef;
}

.file-chip button:disabled {
	cursor: wait;
	opacity: 0.45;
}

.file-chip button svg {
	width: 16px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-width: 1.7;
}

.mode-section {
	margin: 28px 0 0;
	padding: 0;
	border: 0;
}

.mode-section legend {
	padding: 0;
	font-size: 15px;
	font-weight: 650;
}

.mode-section > p {
	margin: 6px 0 12px;
	color: var(--text-muted);
	font-size: 12px;
}

.mode-picker {
	display: grid;
	gap: 8px;
}

.mode-option input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.mode-card {
	display: flex;
	min-height: 58px;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	cursor: pointer;
	transition:
		background-color 160ms ease,
		border-color 160ms ease;
}

.mode-card:hover {
	border-color: var(--border-strong);
}

.mode-option input:focus-visible + .mode-card {
	outline: 3px solid rgba(37, 99, 235, 0.28);
	outline-offset: 2px;
}

.mode-card i {
	width: 16px;
	height: 16px;
	flex: 0 0 auto;
	border: 1.5px solid #a1a1aa;
	border-radius: 50%;
}

.mode-card > span {
	display: flex;
	min-width: 0;
	flex-direction: column;
}

.mode-card strong {
	font-size: 13px;
	font-weight: 600;
}

.mode-card small {
	margin-top: 2px;
	color: var(--text-muted);
	font-size: 11px;
}

.mode-option input:checked + .mode-card {
	background: var(--accent-soft);
	border-color: #93b4f4;
}

.mode-option input:checked + .mode-card i {
	background: var(--accent);
	border: 4px solid #ffffff;
	box-shadow: 0 0 0 1.5px var(--accent);
}

.convert-button {
	display: flex;
	width: 100%;
	height: 46px;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 24px;
	color: #ffffff;
	background: var(--accent);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 650;
	transition: background-color 160ms ease;
}

.convert-button:not(:disabled):hover {
	background: var(--accent-hover);
}

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

.button-arrow {
	font-size: 16px;
	line-height: 1;
}

.convert-button.is-loading .button-arrow {
	animation: pulse 900ms ease-in-out infinite alternate;
}

.error-message {
	margin: 12px 0 0;
	padding: 10px 12px;
	color: var(--danger);
	background: var(--danger-soft);
	border: 1px solid #fecdca;
	border-radius: 7px;
	font-size: 12px;
	line-height: 1.5;
}

.preview-panel {
	display: flex;
	min-width: 0;
	padding: 32px;
	flex-direction: column;
	background: var(--surface-subtle);
}

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

.preview-heading > span {
	color: var(--text-muted);
	font-size: 11px;
	font-weight: 500;
}

.preview-stage {
	position: relative;
	display: grid;
	overflow: hidden;
	flex: 1;
	min-height: 430px;
	place-items: center;
	background: #ffffff;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.empty-preview,
.loading-preview {
	display: flex;
	align-items: center;
	flex-direction: column;
	color: var(--text);
	text-align: center;
}

.preview-icon {
	width: 48px;
	height: 48px;
	margin-bottom: 16px;
	color: #a1a1aa;
	background: var(--surface-subtle);
	border: 1px solid var(--border);
	border-radius: 10px;
}

.preview-icon svg {
	width: 24px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.5;
}

.empty-preview strong,
.loading-preview strong {
	font-size: 14px;
	font-weight: 600;
}

.empty-preview > span:last-child,
.loading-preview > span:not(.spinner) {
	margin-top: 6px;
	color: var(--text-muted);
	font-size: 12px;
}

.spinner {
	width: 30px;
	height: 30px;
	margin-bottom: 16px;
	border: 3px solid #dbeafe;
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 800ms linear infinite;
}

.result-preview {
	width: 100%;
	height: 100%;
	padding: 28px;
}

.result-preview img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.result-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-top: 12px;
	padding: 12px 14px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 9px;
}

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

.result-actions > div {
	display: flex;
	flex-direction: column;
}

.result-actions strong {
	font-size: 12px;
	font-weight: 600;
}

.result-actions span {
	margin-top: 3px;
	color: var(--text-muted);
	font-size: 11px;
}

.download-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 9px 12px;
	color: #ffffff;
	background: var(--accent);
	border-radius: 7px;
	font-size: 12px;
	font-weight: 600;
	text-decoration: none;
}

.download-button:hover {
	background: var(--accent-hover);
}

.download-button svg {
	width: 14px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.7;
}

main {
	flex: 1;
}

.privacy-note {
	margin: 18px 0 0;
	color: var(--text-muted);
	font-size: 11px;
	text-align: center;
}

footer {
	background: var(--surface);
	border-top: 1px solid var(--border);
}

.footer-inner {
	display: flex;
	height: 68px;
	align-items: center;
	justify-content: flex-end;
	color: var(--text-muted);
	font-size: 12px;
}

.footer-inner a {
	color: var(--text-muted);
	text-decoration: none;
}

[hidden] {
	display: none;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes pulse {
	to {
		transform: translateX(3px);
	}
}

@media (max-width: 800px) {
	.page-shell {
		padding-top: 48px;
	}

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

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

	.preview-panel {
		min-height: 520px;
	}
}

@media (max-width: 520px) {
	.header-inner,
	.page-shell,
	.footer-inner {
		width: min(100% - 28px, 1040px);
	}

	.page-shell {
		padding: 40px 0 36px;
	}

	.intro {
		margin-bottom: 28px;
	}

	.intro h1 {
		font-size: 32px;
	}

	.intro > p:last-child {
		font-size: 14px;
	}

	.controls-panel,
	.preview-panel {
		padding: 22px;
	}

	.preview-panel {
		min-height: 430px;
	}

	.preview-stage {
		min-height: 320px;
	}

	.result-preview {
		padding: 18px;
	}

	.result-actions {
		align-items: stretch;
		flex-direction: column;
	}
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	.spinner,
	.convert-button.is-loading .button-arrow {
		animation: none;
	}

	.drop-zone,
	.mode-card,
	.convert-button {
		transition: none;
	}
}
