:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --fg: #1c1f24; --muted: #6b7280; --card: #fff; --line: #e3e6ea;
  --accent: #2563eb; --ok: #16a34a; --bad: #dc2626;
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171b; --fg: #e8eaed; --muted: #9aa0a6; --card: #1e2126; --line: #2d3137; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 16px; }
button {
  font: inherit; border: 0; border-radius: 6px; padding: 8px 16px; cursor: pointer;
  background: var(--accent); color: #fff;
}
button:disabled { opacity: .55; cursor: default; }
button.ghost { background: transparent; color: inherit; border: 1px solid var(--line); }
input {
  font: inherit; width: 100%; padding: 9px 11px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg);
}
label { display: block; }
.muted { color: var(--muted); }
.error { color: var(--bad); margin: 0; min-height: 1.4em; }
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.narrow { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.topbar.dark { background: #111; color: #eee; border-color: #222; }
.topbar.dark button.ghost { border-color: #444; }
.spacer { flex: 1; }
.page { max-width: 760px; margin: 0 auto; padding: 24px 16px; }

/* ---------- навигация и админка ---------- */
.nav { display: flex; gap: 4px; margin-left: 16px; }
.nav-btn { background: transparent; color: var(--muted); padding: 6px 12px; }
.nav-btn.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.page.wide { max-width: 1200px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { background: transparent; color: var(--muted); border-radius: 6px 6px 0 0; border-bottom: 2px solid transparent; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar h2 { font-size: 18px; margin: 0; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; }
td.actions button { margin: 2px 0 2px 4px; white-space: nowrap; }
@media (max-width: 1000px) {
  th, td { padding: 8px; }
  td.actions { min-width: 120px; }
}
td.empty { text-align: center; color: var(--muted); padding: 24px; }
tr.disabled td { opacity: .55; }
.details { font-size: 12px; color: var(--muted); max-width: 360px; overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--line); color: var(--fg); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.badge.accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.status-dot.on { background: var(--ok); }

button.danger { background: var(--bad); }
button.ghost.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
button.small { padding: 3px 10px; font-size: 13px; }

dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(480px, calc(100vw - 32px));
  background: var(--card); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dlg { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dlg h2 { font-size: 18px; margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg .error { min-height: 0; }
.code-box {
  font: 600 26px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .08em; text-align: center;
  padding: 14px; border: 2px dashed var(--accent); border-radius: 10px; user-select: all;
}
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.checklist { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.check { display: flex; gap: 8px; align-items: center; }
.downloads { border-top: 1px solid var(--line); padding-top: 12px; }
.downloads ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.downloads a { color: var(--accent); font-weight: 600; text-decoration: none; }
.downloads a:hover { text-decoration: underline; }
.sha { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.dlg h3 { font-size: 14px; margin: 6px 0 0; }
.dlg p { margin: 0; }
.qr { width: 200px; height: 200px; align-self: center; background: #fff; border-radius: 8px; image-rendering: pixelated; }
.check input { width: auto; margin: 0; }
.row > label { flex: 1; }
select { font: inherit; width: 100%; padding: 9px 11px; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); }

.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.device {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.device .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.device.online .dot { background: var(--ok); }
.device .name { font-weight: 600; }
.device .meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.device .grow { flex: 1; min-width: 0; }

.session { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }
.session-body { flex: 1; min-height: 0; display: flex; }
.stage { position: relative; flex: 1; min-width: 0; outline: none; cursor: default; }
.drop-hint {
  position: absolute; inset: 12px; display: grid; place-items: center; pointer-events: none;
  border: 3px dashed #60a5fa; border-radius: 12px; background: rgba(37, 99, 235, .25); color: #fff; font-size: 20px;
}
/* Уровень сигнала: 4 палочки + подпись. */
.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; cursor: help; }
.signal i { width: 4px; background: #555; border-radius: 1px; }
.signal i:nth-child(1) { height: 25%; }
.signal i:nth-child(2) { height: 50%; }
.signal i:nth-child(3) { height: 75%; }
.signal i:nth-child(4) { height: 100%; }
.signal[data-level="4"] i { background: #22c55e; }
.signal[data-level="3"] i:nth-child(-n+3) { background: #84cc16; }
.signal[data-level="2"] i:nth-child(-n+2) { background: #f59e0b; }
.signal[data-level="1"] i:nth-child(1) { background: #ef4444; }
.signal-text { margin-left: 6px; font-size: 12px; color: #bbb; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transfer { color: #ddd; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
button.small { padding: 2px 9px; }
.small-text { font-size: 12px; margin: 0; }

.files {
  width: 360px; flex: none; display: flex; flex-direction: column;
  background: var(--card); color: var(--fg); border-left: 1px solid var(--line);
}
.files-head { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.files-path { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.files-list { list-style: none; margin: 0; padding: 4px 0; flex: 1; overflow: auto; }
.files-list li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: default; }
.files-list li:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.files-list .icon { width: 18px; text-align: center; flex: none; }
.files-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-list .dir .fname { cursor: pointer; }
.files-list .size { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.files-list .empty { color: var(--muted); justify-content: center; }
.files-foot { padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage-hint {
  position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
  color: #bbb; pointer-events: none;
}
