:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --border: #2a2e38;
  --text: #e6e8ee;
  --muted: #8b91a1;
  --accent: #4f8cff;
  --danger: #ff5c5c;
  --ok: #3ccf7a;
  --warn: #f0b429;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button, select, input, textarea {
  font: inherit;
  color: inherit;
}

button, a.button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  color: #fff;
  text-decoration: none;
}
a.button[hidden] { display: none; }
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
button:disabled { opacity: .6; cursor: default; }

select, input:not([type=checkbox]):not([type=range]), textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; }
label { display: flex; flex-direction: column; gap: 4px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.row { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- login */

.login-page { display: grid; place-items: center; padding: 16px; }
.card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h1 { margin: 0; font-size: 22px; }
.card p { margin: 0; }
.card button { padding: 10px; }

/* ---------- viewer */

.viewer-page { display: flex; flex-direction: column; overflow: hidden; }

#toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
#toolbar .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#toolbar .status { display: flex; align-items: center; gap: 8px; }

:fullscreen #toolbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; transform: translateY(-100%); transition: transform .15s; }
:fullscreen #toolbar:hover, :fullscreen #toolbar:focus-within { transform: none; }
:fullscreen #toolbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 6px; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.idle { background: var(--accent); }
.dot.busy { background: var(--warn); }
.dot.off { background: var(--danger); }

#screen { flex: 1; position: relative; overflow: hidden; background: #000; }
#screen > div:not(.placeholder) { background: #000 !important; }

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.panel {
  position: fixed;
  right: 12px;
  top: 56px;
  width: min(420px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel[hidden] { display: none; }
.panel h3 { margin: 0; }
.panel p { margin: 0; }
.panel textarea { width: 100%; resize: vertical; }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: min(380px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h3, dialog p { margin: 0; }

@media (max-width: 700px) {
  #toolbar label.inline:first-of-type { display: none; }
}
