:root {
	--bg: #f8fafc;
	--surface: #ffffff;
	--text: #0f172a;
	--muted: #64748b;
	--border: #e2e8f0;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--danger: #dc2626;
	--radius: 12px;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b1120;
		--surface: #111827;
		--text: #e5e7eb;
		--muted: #94a3b8;
		--border: #1f2937;
		--accent: #3b82f6;
		--accent-hover: #60a5fa;
	}
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	height: 100%;
}

body {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	-webkit-text-size-adjust: 100%;
}

a {
	color: var(--accent);
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 20px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.btn-primary:hover {
	background: var(--accent-hover);
}

/* ---------- Landing ---------- */

.landing {
	display: flex;
	flex-direction: column;
	min-height: 100%;
}

.landing-header {
	padding: 16px max(16px, env(safe-area-inset-left));
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-weight: 700;
	font-size: 18px;
	text-decoration: none;
}

.hero {
	flex: 1;
	width: 100%;
	max-width: 680px;
	margin: 0 auto;
	padding: 8vh 16px 32px;
	text-align: center;
}

.hero h1 {
	margin: 0 0 8px;
	font-size: clamp(26px, 5vw, 40px);
	line-height: 1.15;
}

.lead {
	margin: 0 0 28px;
	color: var(--muted);
	font-size: 16px;
}

.go-form {
	display: flex;
	gap: 8px;
	padding: 6px;
	border: 1px solid var(--border);
	border-radius: calc(var(--radius) + 4px);
	background: var(--surface);
	box-shadow: 0 8px 30px rgb(15 23 42 / 0.08);
}

.go-form input {
	flex: 1;
	min-width: 0;
	padding: 0 12px;
	border: 0;
	background: transparent;
	color: var(--text);
	font-size: 16px; /* 16px stops iOS Safari from zooming on focus */
	outline: none;
}

.start-error {
	margin: 12px 0 0;
	color: var(--danger);
	font-size: 14px;
}

.quick {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 10px;
	margin-top: 28px;
}

.quick-btn {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 52px;
	padding: 8px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	text-align: left;
}

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

.quick-icon {
	display: inline-grid;
	place-items: center;
	flex: none;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	color: #fff;
	font-size: 14px;
	font-weight: 700;
}

.landing-footer {
	padding: 16px;
	color: var(--muted);
	font-size: 13px;
	text-align: center;
}

.landing-footer p {
	margin: 4px 0;
}

@media (max-width: 520px) {
	.quick {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* ---------- Launcher (starts the proxy, then opens the site) ---------- */

.launcher {
	display: grid;
	place-items: center;
	min-height: 100%;
	padding: 24px 16px;
}

.launcher-card {
	text-align: center;
	color: var(--muted);
}

.launcher-card .start-error {
	max-width: 420px;
}

.spinner {
	width: 36px;
	height: 36px;
	margin: 0 auto 12px;
	border: 3px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

.spinner[hidden] {
	display: none;
}

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

/* ---------- Error pages (also used by the service worker) ---------- */

.error-page {
	display: grid;
	place-items: center;
	min-height: 100%;
	padding: 24px 16px;
}

.error-card {
	width: 100%;
	max-width: 480px;
	padding: 32px 24px;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--surface);
	text-align: center;
}

.error-icon {
	display: inline-grid;
	place-items: center;
	width: 52px;
	height: 52px;
	margin-bottom: 8px;
	border-radius: 50%;
	background: #fee2e2;
	color: var(--danger);
	font-size: 26px;
	font-weight: 800;
}

.error-card h1 {
	margin: 8px 0;
	font-size: 22px;
}

.error-card p {
	color: var(--muted);
	line-height: 1.5;
}

.error-url {
	overflow-wrap: anywhere;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 13px;
}

.error-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	margin-top: 20px;
}

.error-details {
	margin-top: 14px;
	text-align: left;
	color: var(--muted);
	font-size: 13px;
}

.error-details pre {
	overflow-x: auto;
	padding: 10px;
	border-radius: 8px;
	background: var(--bg);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
