:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1a2027;
  --line: #252d36;
  --text: #e9eef5;
  --muted: #8d9aa8;
  --accent: #4f8cff;
  --accent-strong: #2f6fed;
  --ok: #38d39f;
  --warn: #ffb020;
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Noto Sans TC", "PingFang TC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 16px 56px;
}

header.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

h1 { font-size: 20px; line-height: 1.25; margin: 0 0 4px; letter-spacing: .01em; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }

.sub { margin: 0; color: var(--muted); font-size: 13px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; letter-spacing: .02em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.card.small { padding: 12px 14px; }
.card.small summary { cursor: pointer; color: var(--muted); font-size: 14px; }

canvas#preview {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  image-rendering: pixelated;
  margin-bottom: 14px;
}

textarea, input[type="text"], input:not([type]), input[readonly], select, .pin {
  width: 100%;
  padding: 12px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea:focus, input:focus, select:focus, .pin:focus {
  outline: 2px solid rgba(79, 140, 255, .45);
  outline-offset: 1px;
  border-color: var(--accent);
}

.pin {
  font: 600 28px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .38em;
  text-align: center;
  padding: 16px 8px 16px 18px;
  margin: 12px 0;
}

label { display: block; font-size: 13px; color: var(--muted); }

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

.grid label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}

.grid select { margin-top: 6px; padding: 9px 10px; font-size: 14px; }
.grid input[type="range"] { width: 100%; margin-top: 12px; accent-color: var(--accent); }

.row { display: flex; gap: 10px; align-items: stretch; }
.row > input, .row > select { flex: 1; }
.row > button { flex: 0 0 auto; }

button {
  padding: 13px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
}

button.primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
button.primary:hover { background: var(--accent); }
button.ghost { background: transparent; color: var(--muted); }
button:disabled { opacity: .55; cursor: default; }

button.primary { width: 100%; margin-top: 4px; }
.row button.primary { width: auto; margin: 0; }

.msg { min-height: 22px; margin: 10px 2px 0; font-size: 14px; color: var(--muted); }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }
.msg.warn { color: var(--warn); }

.note { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 18px 2px 0; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
  vertical-align: 1px;
}
.dot.online { background: var(--ok); box-shadow: 0 0 8px rgba(56, 211, 159, .6); }
.dot.offline { background: var(--warn); }

.devices { list-style: none; margin: 0; padding: 0; }
.devices li + li { border-top: 1px solid var(--line); }
.devices a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 2px;
  color: var(--text);
}
.devices a:hover { text-decoration: none; color: var(--accent); }
.devices .state { color: var(--muted); font-size: 12px; }

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .pin { font-size: 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  button, a, .dot { transition: color .15s, background .15s, border-color .15s; }
}
