:root {
  --red: #d32f2f;
  --red-dark: #a91f1f;
  --bg: #111418;
  --panel: #1b1f25;
  --line: #2b313a;
  --text: #e8eaed;
  --muted: #9aa3ad;
  --ok: #2e7d32;
  --warn: #b26a00;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }

/* ---------- logo ---------- */
.logo {
  width: 44px; height: 44px; border-radius: 10px; background: var(--red);
  color: #fff; font-weight: 800; font-size: 26px;
  display: inline-flex; align-items: center; justify-content: center;
}
.logo.small { width: 26px; height: 26px; font-size: 15px; border-radius: 6px; }

/* ---------- đăng nhập ---------- */
.login-body { display: flex; align-items: center; justify-content: center; padding: 16px; min-height: 100%; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  font-size: 16px; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #0d1014; color: var(--text); outline: none;
}
.login-card input:focus { border-color: var(--red); }
.login-card button {
  margin-top: 6px; padding: 12px; font-size: 16px; font-weight: 600; border: 0; border-radius: 8px;
  background: var(--red); color: #fff; cursor: pointer;
}
.login-card button:hover { background: var(--red-dark); }
.error { background: #3a1517; border: 1px solid #6b2226; color: #ffb4b4; padding: 10px 12px; border-radius: 8px; font-size: 14px; }

/* ---------- màn hình điều khiển ---------- */
.viewer-body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
#bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  padding-top: max(5px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative;
}
#bar .left { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
#bar .tools { display: flex; gap: 6px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
#bar .tools::-webkit-scrollbar { display: none; }
#bar button, #bar select, #clipPanel button {
  flex: 0 0 auto; background: #262b33; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
#bar button:hover, #clipPanel button:hover { background: #313741; }
#bar button.danger { background: #3a1517; border-color: #6b2226; }
#bar button.active { background: var(--red); border-color: var(--red); }
.hide-btn { flex: 0 0 auto; }
body.bar-hidden #bar .tools, body.bar-hidden #bar .left { display: none; }
body.bar-hidden #bar {
  position: fixed; top: 0; right: 8px; z-index: 10; background: transparent; border: 0; padding: 4px;
  padding-top: max(4px, env(safe-area-inset-top));
}
body.bar-hidden #bar .hide-btn { opacity: .55; }

.status { font-size: 12px; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.status.ok { background: #16351a; color: #9be39f; }
.status.wait { background: #3b2a0c; color: #ffd28a; }
.status.err { background: #3a1517; color: #ffb4b4; }

#screen { flex: 1 1 auto; min-height: 0; position: relative; background: #000; overflow: hidden; }

#clipPanel {
  position: fixed; top: 56px; right: 8px; left: 8px; max-width: 520px; margin-left: auto; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#clipPanel[hidden] { display: none; }
#clipPanel textarea {
  width: 100%; height: 140px; resize: vertical; font-size: 14px; background: #0d1014; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
#clipPanel .row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ô nhập ẩn để bật bàn phím ảo trên điện thoại */
#kbdInput {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0;
  font-size: 16px; border: 0; padding: 0; resize: none; pointer-events: none;
}
