:root {
  color-scheme: dark;
  --bg: #0b0f12;
  --panel: #141a1f;
  --line: #243038;
  --text: #e6eef2;
  --muted: #8aa0ab;
  --accent: #7ff6ff;
  --ok: #4cd98a;
  --bad: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

.app {
  display: grid;
  gap: 16px;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 { margin: 0; font-size: 1.25rem; }
h1 span { color: var(--muted); font-weight: 400; }
h2 { margin: 0 0 12px; font-size: 0.95rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }

.pill {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.pill[data-ok="true"] { color: var(--ok); border-color: var(--ok); }

.device {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 20px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.screen-frame {
  padding: 10px;
  background: #000;
  border: 2px solid #2a3640;
  border-radius: 10px;
}

#screen {
  display: block;
  width: min(256px, 64vw);
  aspect-ratio: 1;
  image-rendering: pixelated;
}

#leds { width: 100%; max-width: 384px; height: auto; }

.caption {
  min-height: 3em;
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.card {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

button {
  min-height: 44px;
  padding: 0 16px;
  background: #1c262d;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { width: 100%; background: var(--accent); color: #031418; border-color: var(--accent); font-weight: 600; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { color: var(--muted); font-size: 0.9rem; }
input[type="password"] {
  min-height: 44px;
  padding: 0 12px;
  background: #0b1115;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.check { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.slider { display: grid; gap: 4px; margin-top: 8px; }
.slider span { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; }
.slider input { width: 100%; accent-color: var(--accent); }

.hint { margin: 12px 0 0; color: var(--muted); font-size: 0.85rem; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; }

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; }

.log {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  font: 12px/1.5 ui-monospace, Menlo, monospace;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
