:root {
	--bg: #f6f5f2;
	--surface: #ffffff;
	--border: #dedad2;
	--text: #23211d;
	--text-dim: #6b6558;
	--accent: #8a5a2b;
	--accent-ink: #ffffff;
	--eol-bg: #f6ece4;
	--eol-border: #d9b48a;
	--eol-text: #8a4a1a;
	--mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
	--sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1b1a17;
		--surface: #242220;
		--border: #3a3732;
		--text: #ece8e0;
		--text-dim: #a39d8f;
		--accent: #d99a5b;
		--accent-ink: #201203;
		--eol-bg: #2e2119;
		--eol-border: #5c3d24;
		--eol-text: #e0a877;
	}
}

:root[data-theme="dark"] {
	--bg: #1b1a17; --surface: #242220; --border: #3a3732; --text: #ece8e0;
	--text-dim: #a39d8f; --accent: #d99a5b; --accent-ink: #201203;
	--eol-bg: #2e2119; --eol-border: #5c3d24; --eol-text: #e0a877;
}
:root[data-theme="light"] {
	--bg: #f6f5f2; --surface: #ffffff; --border: #dedad2; --text: #23211d;
	--text-dim: #6b6558; --accent: #8a5a2b; --accent-ink: #ffffff;
	--eol-bg: #f6ece4; --eol-border: #d9b48a; --eol-text: #8a4a1a;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	line-height: 1.45;
}

.wrap {
	max-width: 860px;
	margin: 0 auto;
	padding: 2rem 1.25rem 4rem;
}

header h1 {
	font-size: 1.5rem;
	margin: 0 0 0.15rem;
	text-wrap: balance;
}

header p {
	color: var(--text-dim);
	margin: 0 0 1.5rem;
	font-size: 0.95rem;
}

.search-row {
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
	margin-bottom: 0.5rem;
}

#search {
	flex: 1 1 260px;
	font-size: 1rem;
	padding: 0.6rem 0.8rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
}

#search:focus {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.channel-toggle {
	display: flex;
	gap: 0.3rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 0.2rem;
	background: var(--surface);
}

.channel-toggle button {
	border: none;
	background: transparent;
	color: var(--text-dim);
	padding: 0.4rem 0.7rem;
	border-radius: 4px;
	font-size: 0.85rem;
	cursor: pointer;
}

.channel-toggle button[aria-pressed="true"] {
	background: var(--accent);
	color: var(--accent-ink);
}

#meta {
	color: var(--text-dim);
	font-size: 0.8rem;
	margin: 0 0 1.5rem;
}

#results {
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
}

.device {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 1rem 1.1rem;
}

.device.eol {
	background: var(--eol-bg);
	border-color: var(--eol-border);
}

.device-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	cursor: pointer;
}

.device-name {
	font-weight: 600;
	font-size: 1.05rem;
}

.device-sub {
	color: var(--text-dim);
	font-size: 0.82rem;
	font-family: var(--mono);
}

.badge {
	display: inline-block;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	padding: 0.15rem 0.5rem;
	border-radius: 999px;
	border: 1px solid var(--eol-border);
	color: var(--eol-text);
	background: transparent;
}

.note {
	font-size: 0.85rem;
	color: var(--eol-text);
	margin: 0.5rem 0 0;
}

.unknown-note {
	font-size: 0.78rem;
	color: var(--text-dim);
	font-style: italic;
}

.releases {
	margin-top: 0.75rem;
	border-top: 1px solid var(--border);
	padding-top: 0.6rem;
	display: none;
}

.device.open .releases { display: block; }

.release {
	padding: 0.4rem 0;
}

.release + .release {
	border-top: 1px dashed var(--border);
}

.release-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.88rem;
}

.release-head .version { font-weight: 600; }
.release-head .date { color: var(--text-dim); font-size: 0.78rem; }

.chip {
	font-size: 0.7rem;
	padding: 0.05rem 0.4rem;
	border-radius: 4px;
	background: var(--border);
	color: var(--text-dim);
}

.images {
	margin: 0.35rem 0 0.15rem;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.image-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.82rem;
	flex-wrap: wrap;
}

.image-row a {
	color: var(--accent);
	text-decoration: none;
	font-weight: 500;
}

.image-row a:hover { text-decoration: underline; }

.image-row .sha {
	font-family: var(--mono);
	font-size: 0.72rem;
	color: var(--text-dim);
	cursor: pointer;
}

.image-row .size {
	color: var(--text-dim);
	font-size: 0.75rem;
}

#empty {
	color: var(--text-dim);
	padding: 2rem 0;
	text-align: center;
	display: none;
}

footer {
	margin-top: 2.5rem;
	color: var(--text-dim);
	font-size: 0.78rem;
	border-top: 1px solid var(--border);
	padding-top: 1rem;
}

/* --- backup-tarball identifier (RFC #62 Rung 2) --- */

.identify { margin: 0 0 1.25rem; }

.dropzone {
	border: 1.5px dashed var(--border);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text-dim);
	padding: 0.85rem 1rem;
	font-size: 0.82rem;
	line-height: 1.5;
	cursor: default;
}

.dropzone strong { color: var(--text); margin-right: 0.35rem; }
.dropzone code { font-family: var(--mono); font-size: 0.78rem; }
.dropzone.drag { border-color: var(--accent); color: var(--text); }

.filepick {
	color: var(--accent);
	cursor: pointer;
	text-decoration: underline;
}
.filepick input[type="file"] { display: none; }

.identify-result {
	border: 1px solid var(--border);
	border-top: none;
	border-radius: 0 0 8px 8px;
	background: var(--surface);
	padding: 0.85rem 1rem;
	font-size: 0.82rem;
}

.identify-result p { margin: 0.3rem 0; }
.identify-paths { font-family: var(--mono); font-size: 0.74rem; color: var(--text-dim); overflow-wrap: anywhere; }
.identify-era { color: var(--text-dim); }
.identify-error { color: var(--eol-text); }

.identify-candidates { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }

.candidate {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.75rem;
	align-items: baseline;
	text-align: left;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--bg);
	color: var(--text);
	padding: 0.6rem 0.8rem;
	font: inherit;
	font-size: 0.82rem;
	cursor: pointer;
}
.candidate:hover, .candidate:focus-visible { border-color: var(--accent); outline: none; }
.candidate-name { font-weight: 600; }
.candidate-score { color: var(--accent); font-size: 0.75rem; }
.candidate-advice { flex-basis: 100%; color: var(--text-dim); font-size: 0.76rem; }
