:root {
	--bg: #f4f1ea;
	--card: #ffffff;
	--text: #1d1f23;
	--muted: #646a73;
	--line: #e3ded3;
	--accent: #2f5d50;
	--accent-text: #ffffff;
	--ok: #2e7d4f;
	--sleep: #5a5f9e;
	--warn: #b86a00;
	--bad: #b3261e;
	--off: #8a8f98;
	--radius: 14px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #16181c;
		--card: #202329;
		--text: #eceef1;
		--muted: #9aa1ab;
		--line: #30343c;
		--accent: #7fb8a6;
		--accent-text: #102019;
		--ok: #6cc596;
		--sleep: #a5a9e6;
		--warn: #e7a74a;
		--bad: #f08b84;
		--off: #7d838d;
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: #16181c;
	--card: #202329;
	--text: #eceef1;
	--muted: #9aa1ab;
	--line: #30343c;
	--accent: #7fb8a6;
	--accent-text: #102019;
	--ok: #6cc596;
	--sleep: #a5a9e6;
	--warn: #e7a74a;
	--bad: #f08b84;
	--off: #7d838d;
	color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-text-size-adjust: 100%;
}

main {
	max-width: 520px;
	margin: 0 auto;
	padding: calc(12px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

.top { display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 14px; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: 0.01em; }
.top .sub { color: var(--muted); font-size: 14px; }

.card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 14px 16px;
	margin-bottom: 12px;
}

h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; color: var(--muted); }

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="password"], input[type="text"], input[type="time"] {
	width: 100%;
	font: inherit;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--bg);
	color: var(--text);
	margin-bottom: 10px;
}

button {
	font: inherit;
	border: 1px solid var(--line);
	background: var(--bg);
	color: var(--text);
	border-radius: 10px;
	padding: 10px 14px;
	min-height: 44px;
	cursor: pointer;
}

button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); padding: 6px 4px; min-height: 36px; text-decoration: underline; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.error { color: var(--bad); min-height: 1.4em; margin: 8px 0 0; }
.pending { color: var(--warn); font-size: 14px; margin: 8px 0 0; }

.status .state-line { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--off); flex: none; }
.dot.run { background: var(--ok); }
.dot.sleep { background: var(--sleep); }
.dot.manual { background: var(--warn); }
.dot.off { background: var(--off); }
.status.offline { border-color: var(--off); }

.picture { padding: 8px; }
.frame {
	aspect-ratio: 16 / 9;
	background: var(--bg);
	border-radius: 10px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--muted);
	font-size: 14px;
}
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picture .hint { margin: 6px 8px 2px; }
.picture.stale img { filter: grayscale(1); opacity: 0.7; }

.segmented { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.segmented button { padding: 10px 6px; font-size: 15px; line-height: 1.2; }
.segmented button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.segmented button.sending { border-style: dashed; border-color: var(--warn); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.row:first-of-type { margin-top: 0; }
.card h2 + .row { margin-top: 0; }

.hours-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 12px; }
.hours-form label { font-weight: 400; color: var(--muted); }
.hours-form .buttons, .hours-form .hint { grid-column: 1 / -1; }
.hours-form .buttons { display: flex; gap: 8px; }

details summary { cursor: pointer; color: var(--accent); padding: 8px 0 2px; min-height: 36px; }
#volume-details { margin-top: 8px; }
.volume input[type="range"] { flex: 1; accent-color: var(--accent); min-height: 36px; }
.volume span { min-width: 3.5em; text-align: right; color: var(--muted); }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.log li:first-child { border-top: none; }
.log .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .what strong { font-weight: 600; }
.log .result { grid-column: 2; font-size: 13px; color: var(--muted); }
.log .result.ok { color: var(--ok); }
.log .result.bad { color: var(--bad); }
.log .result.wait { color: var(--warn); }
.log .event { color: var(--muted); }

.tech { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 0; font-size: 14px; }
.tech dt { color: var(--muted); }
.tech dd { margin: 0; overflow-wrap: anywhere; }
.tech dd.warn { color: var(--warn); }

.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); font-size: 14px; padding: 4px 2px; }

.toast {
	position: fixed;
	left: 50%;
	bottom: calc(18px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	max-width: calc(100% - 32px);
	background: var(--text);
	color: var(--bg);
	padding: 10px 16px;
	border-radius: 10px;
	font-size: 15px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.toast.bad { background: var(--bad); color: #fff; }

.net-error { color: var(--bad); text-align: center; font-size: 14px; }

@media (prefers-reduced-motion: no-preference) {
	.toast { transition: opacity 0.2s; }
}
