:root {
  --bg: #11151c;
  --panel: #1b2230;
  --line: #2c3648;
  --text: #e8ecf3;
  --muted: #93a0b5;
  --accent: #35c6d6;
  --good: #4cd787;
  --warn: #f2b84b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
main { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
p.sub { color: var(--muted); margin: 0 0 20px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }
label:first-child { margin-top: 0; }
textarea, select, input[type="file"] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1 1 180px; }
button, a.button {
  display: inline-block;
  background: var(--accent);
  color: #06222a;
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
button:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.note { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--warn); }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cards a { color: inherit; text-decoration: none; }
.cards h2 { margin: 0 0 6px; font-size: 1.1rem; color: var(--accent); }
.cards p { margin: 0; color: var(--muted); }

/* Sender stage: the code fills the window on a white background. */
#stage { display: none; position: fixed; inset: 0; background: #fff; flex-direction: column; }
body.streaming #stage { display: flex; }
body.streaming main { display: none; }
#codeWrap { flex: 1; min-height: 0; position: relative; }
#code { position: absolute; inset: 0; width: 100%; height: 100%; }
#stageBar {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: var(--bg); font-size: 0.8rem; color: var(--muted);
}
#stageBar button { padding: 6px 12px; font-size: 0.8rem; }
#stageInfo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Receiver */
#view {
  display: block; margin: 0 auto; border-radius: 8px; background: #000; cursor: pointer;
  width: auto; height: auto; max-width: 100%; max-height: 45vh;
}
/* While live video plays, the camera view shrinks to a thumbnail so the video has the screen. */
body.watching:not(.bigcam) #view { max-height: 96px; margin: 0; }
#viewHint { display: none; margin: 6px 0 0; }
body.watching:not(.bigcam) #viewHint { display: block; }
#video, .offscreen { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.status { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); flex: none; }
.dot.found { background: var(--warn); }
.dot.locked { background: var(--good); }
.bar { height: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--good); transition: width 0.15s; }
#stats { font-size: 0.85rem; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
#result { display: none; }
#result.show { display: block; }
#result h2 { margin: 0 0 10px; font-size: 1.1rem; color: var(--good); }
#result img { max-width: 100%; border-radius: 8px; margin-top: 12px; display: block; }
#videoPanel { display: none; }
#videoPanel.show { display: block; }
#videoOut { width: 100%; max-height: 62vh; object-fit: contain; display: block; border-radius: 8px; background: #000; }
