:root {
  --bg: #f1f5f9; --card: #ffffff; --fg: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --on: #16a34a; --off: #94a3b8; --danger: #dc2626; --hdr: #0f172a;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --card: #131c2e; --fg: #e2e8f0; --muted: #94a3b8; --line: #1e293b; --hdr: #020617; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--hdr); color: #fff; }
header h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#back { color: #fff; text-decoration: none; font-size: 28px; line-height: 1; padding: 0 6px 0 0; }
main { padding: 12px 16px calc(env(safe-area-inset-bottom) + 24px); max-width: 900px; margin: 0 auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); display: inline-block; flex: none; }
.dot.on { background: var(--on); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 8px; }
.dev { display: block; color: inherit; text-decoration: none; }
.row { display: flex; align-items: center; gap: 8px; }
.row .grow { flex: 1; min-width: 0; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 10px; }
.kv { background: var(--bg); border-radius: 8px; padding: 6px 8px; }
.kv b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.kv span { font-size: 12px; color: var(--muted); }
button, select, input { font: inherit; color: inherit; }
button { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #fff; cursor: pointer; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--fg); }
button.danger { background: var(--danger); }
button:disabled { opacity: .5; }
input, select { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
label { display: block; margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.switch { position: relative; width: 52px; height: 30px; border-radius: 15px; background: var(--off); flex: none;
  border: 0; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: left .15s; }
.switch.on { background: var(--on); }
.switch.on::after { left: 25px; }
.switch.busy { opacity: .5; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.tabs button { background: var(--card); color: var(--fg); border: 1px solid var(--line); padding: 7px 12px; white-space: nowrap; }
.tabs button.sel { background: var(--accent); color: #fff; border-color: var(--accent); }
.chart { width: 100%; overflow: hidden; }
.chart .u-legend { font-size: 12px; }
.logs { font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; max-height: 60vh; overflow: auto;
  background: var(--bg); border-radius: 8px; padding: 8px; }
.logs div { white-space: pre-wrap; word-break: break-all; }
.logs time { color: var(--muted); margin-right: 6px; }
.stack > * + * { margin-top: 8px; }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 10; max-width: 90vw; }
.login { max-width: 360px; margin: 10vh auto; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
textarea { font: inherit; color: inherit; width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); resize: vertical; }
.row.wrap { flex-wrap: wrap; }
button.sm { padding: 6px 10px; font-size: 13px; }
label.btn { display: inline-block; margin: 0; padding: 10px 14px; border-radius: 10px; cursor: pointer; font-size: 15px; color: var(--fg); }
label.btn.ghost { border: 1px solid var(--line); }
.fan-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fan-info > div { background: var(--bg); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.fan-info span { display: block; font-size: 12px; color: var(--muted); }
.fan-info b { display: block; overflow-wrap: anywhere; }
.fan-info .note { grid-column: 1 / -1; white-space: pre-wrap; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--bg); cursor: pointer; }
.mount { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.mount-wrap { border-top: 1px solid var(--line); padding: 4px 0 10px; }
.mount-wrap:first-child { border-top: 0; }
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--bg); flex: none; }
.viewer { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.92); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 16px; }
.viewer img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 8px; }
.viewer button.ghost { color: #fff; border-color: #fff6; }
