:root {
  --bg: #0e1013;
  --panel: #161a1f;
  --line: #262c34;
  --text: #e8ebef;
  --muted: #8a94a3;
  --accent: #4fd1a5;
  --accent-ink: #062a1e;
  --danger: #ff6b6b;
  --warn: #f5c451;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, sans-serif;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.logo {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0 50%, transparent 50%), #2b3340;
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Buttons & inputs */
.btn {
  border: 1px solid var(--line); background: #1d232a; color: var(--text);
  padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: #3a4350; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: transparent; color: var(--danger); border-color: #5a2a2a; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.small-btn { padding: 4px 10px; font-size: 13px; margin-left: auto; }
input:not([type=checkbox]) {
  width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: #0f1216; color: var(--text); font: inherit;
}
input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.auth-card p { margin: 6px 0 20px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: #0f1216; border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 7px; font: inherit; cursor: pointer; }
.tab.active { background: #222a33; color: var(--text); }
#authForm label { margin-bottom: 14px; }
.error { color: var(--danger); min-height: 1.4em; margin: 10px 0 0; font-size: 14px; }

/* Dashboard */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); gap: 12px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; padding: 24px; max-width: 1100px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel h2 { font-size: 16px; margin: 0; }
.field { margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: #222a33; color: var(--muted); }
.pill.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: #4a5361; display: inline-block; flex: none; }
.dot.ok, .dot.live { background: var(--accent); }
.dot.live { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.dot.warn { background: var(--warn); }
.helper-status { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 14px; }
.session { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px 12px; border-radius: 9px; background: #10161a; border: 1px solid #1f3a31; font-size: 14px; }

.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.device { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.device .info { flex: 1; min-width: 0; }
.device .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device .meta { font-size: 13px; color: var(--muted); }
.device .tag { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); }

/* Remote viewer */
.remote { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }
.remote-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: #0b0d10; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.remote-title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.remote-actions { display: flex; align-items: center; gap: 10px; }
.stage { position: relative; flex: 1; min-height: 0; outline: none; }
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.stage.control video { cursor: crosshair; }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; text-align: center; padding: 16px; }

@media (max-width: 520px) {
  .topbar { padding: 12px 16px; }
  .grid { padding: 16px; }
}

/* Helper downloads */
.helper-panel { grid-column: 1 / -1; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.dl { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dl.mine { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.dl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dl-head .tag { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted); }
.dl-head .dl-this { margin-left: auto; }
.dl-btn { text-align: center; text-decoration: none; align-self: flex-start; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.steps b { color: var(--text); font-weight: 600; }
code { font-family: "JetBrains Mono", monospace; font-size: 12px; background: #0f1216; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
#shareNote a, .dl-foot a { color: var(--accent); }
.dl-foot { margin: 14px 0 0; }
.helper-panel .panel-head { flex-wrap: wrap; gap: 4px 12px; }
