:root {
	color-scheme: light dark;
	--bg: #f6f3ee;
	--surface: #ffffff;
	--surface-sunken: #f0ebe3;
	--border: #d9cfc0;
	--text: #2a241d;
	--text-muted: #6e6253;
	--accent: #9a5b1c;
	--accent-text: #ffffff;
	--danger: #b3261e;
	--danger-bg: #fbeceb;
	--ok: #2e7d32;
	--json-key: #7a4a12;
	--json-string: #2f5f8a;
	--json-literal: #8a3b8f;
	--radius: 8px;
	--font-mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #12100e;
		--surface: #1c1915;
		--surface-sunken: #15120f;
		--border: #3a322a;
		--text: #e8dfd1;
		--text-muted: #a29582;
		--accent: #c0883f;
		--accent-text: #15120f;
		--danger: #f2827a;
		--danger-bg: #2a1614;
		--ok: #81c784;
		--json-key: #e0b06a;
		--json-string: #9cc3e6;
		--json-literal: #d39be0;
	}
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.page-header,
main {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 16px;
}

.page-header {
	padding-top: 24px;
}

/* the same width as the content above, so the line lines up with it */
.page-footer {
	width: min(1168px, 100% - 32px);
	margin: 32px auto 0;
	padding: 16px 0 24px;
	border-top: 1px solid var(--border);
	color: var(--text-muted);
	font-size: 13px;
}

/* one line: the build adds the links as a paragraph before the disclaimer */
.page-footer p {
	display: inline;
	margin: 0;
}

.page-footer p + p::before {
	content: " · ";
}

.page-footer a {
	color: inherit;
}

h1 {
	margin: 0;
	font-size: 1.6rem;
	letter-spacing: 0.02em;
}

.subtitle {
	margin: 4px 0 16px;
	color: var(--text-muted);
}

button {
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 4px 12px;
	cursor: pointer;
}

button:hover:not(:disabled) {
	border-color: var(--accent);
}

button:disabled {
	opacity: 0.5;
	cursor: default;
}

button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-text);
	font-weight: 600;
}

button:focus-visible,
.dropzone:focus-within {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

kbd {
	font: 0.85em var(--font-mono);
	padding: 1px 5px;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--surface-sunken);
}

/* drop zone (also the file picker) */

.dropzone {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 32px 16px;
	text-align: center;
	border: 2px dashed var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	cursor: pointer;
}

.dropzone:hover {
	border-color: var(--accent);
}

.dropzone input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.dropzone-title {
	font-weight: 600;
}


body.has-cards .dropzone {
	padding: 16px;
}

.drop-overlay {
	position: fixed;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	font-weight: 600;
	color: var(--accent);
	background: color-mix(in srgb, var(--bg) 85%, transparent);
	border: 4px dashed var(--accent);
	pointer-events: none;
	z-index: 10;
}

body.dragging .drop-overlay {
	display: flex;
}

/* toolbar and notices */

.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin: 16px 0 8px;
}

.toolbar[hidden],
.notice[hidden] {
	display: none;
}

.summary {
	margin: 0;
	color: var(--text-muted);
}

.toolbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.notice {
	margin: 8px 0;
	padding: 6px 12px;
	border-radius: 6px;
	background: var(--surface-sunken);
	color: var(--text-muted);
}

/* result cards */

.cards {
	list-style: none;
	margin: 8px 0 32px;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.card {
	display: grid;
	grid-template-columns: 280px minmax(0, 1fr);
	gap: 16px;
	padding: 12px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.card[data-status="failed"] {
	border-color: color-mix(in srgb, var(--danger) 50%, var(--border));
}

.thumb {
	display: block;
	align-self: start;
	border-radius: 4px;
	overflow: hidden;
	background: var(--surface-sunken);
	aspect-ratio: 16 / 9;
}

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

.thumb:not([href]) {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: default;
}

.thumb:not([href])::after {
	content: "No preview";
	color: var(--text-muted);
	font-size: 0.85rem;
}

.thumb img[hidden] {
	display: none;
}

.card-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.card-name {
	margin: 0;
	font-size: 1rem;
	overflow-wrap: anywhere;
	flex: 1 1 200px;
}

.card-actions {
	display: flex;
	gap: 6px;
}

.card[data-status="failed"] .copy {
	display: none;
}

.status {
	font-size: 0.8rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--surface-sunken);
	color: var(--text-muted);
}

.card[data-status="processing"] .status {
	color: var(--accent);
	animation: pulse 1.2s ease-in-out infinite;
}

.card[data-status="done"] .status {
	color: var(--ok);
}

.card[data-status="failed"] .status {
	color: var(--danger);
}

@keyframes pulse {
	50% {
		opacity: 0.4;
	}
}

@media (prefers-reduced-motion: reduce) {
	.card[data-status="processing"] .status {
		animation: none;
	}
}

.json {
	margin: 8px 0 0;
	padding: 8px 12px;
	max-height: 420px;
	overflow: auto;
	font: 0.85rem/1.45 var(--font-mono);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	background: var(--surface-sunken);
	border-radius: 6px;
}

.json .key {
	color: var(--json-key);
}

.json .string {
	color: var(--json-string);
}

.json .literal {
	color: var(--json-literal);
}

.error {
	margin-top: 8px;
	padding: 8px 12px;
	border-radius: 6px;
	background: var(--danger-bg);
	color: var(--danger);
}

.error-message {
	margin: 0;
	font-weight: 600;
}

.error-details {
	margin: 4px 0 0;
	padding-left: 18px;
	font: 0.8rem/1.4 var(--font-mono);
	overflow-wrap: anywhere;
}

.error-details:empty {
	display: none;
}

@media (max-width: 640px) {
	.card {
		grid-template-columns: minmax(0, 1fr);
	}
}
