/* Live Remote Guest — guest page + host console.
   Dark, mobile-first, built to feel like a normal video-call screen. */

:root {
  --bg:        #0b0f14;
  --bg-2:      #121821;
  --surface:   #18202b;
  --surface-2: #202a38;
  --line:      #2a3646;
  --text:      #eef3f8;
  --text-dim:  #93a3b6;
  --accent:    #2f8bff;
  --accent-2:  #1e6fd9;
  --live:      #ff3b30;
  --ok:        #22c55e;
  --warn:      #f59e0b;
  --radius:    16px;
  --radius-sm: 10px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body.guest { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7;
      stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ stage */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.fill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.mirror { transform: scaleX(-1); }

.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 22%,
                    rgba(0,0,0,0) 60%, rgba(0,0,0,.65) 100%);
}

.stage.camoff #localVideo { opacity: 0; }
.stage.camoff::after {
  content: "Camera is off";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 15px;
  background: #0b0f14;
}

/* ----------------------------------------------------------------- topbar */

.topbar {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
}

.spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(10,14,20,.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.09);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}

.chip.quiet { color: var(--text-dim); font-weight: 500; }

.chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: none;
}

.chip.standby .dot { background: var(--warn); }
.chip.onair    { background: rgba(255,59,48,.92); border-color: rgba(255,255,255,.25); color: #fff; }
.chip.onair    .dot { background: #fff; animation: blink 1.4s infinite; }
.chip.bad      .dot { background: var(--live); }
.chip.good     .dot { background: var(--ok); }

@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i {
  width: 3px;
  background: var(--text-dim);
  border-radius: 1px;
  opacity: .3;
}
.bars i:nth-child(1) { height: 5px; }
.bars i:nth-child(2) { height: 9px; }
.bars i:nth-child(3) { height: 12px; }
.net-1 .bars i:nth-child(1),
.net-2 .bars i:nth-child(-n+2),
.net-3 .bars i { opacity: 1; }
.net-1 .bars i { background: var(--live); }
.net-2 .bars i { background: var(--warn); }
.net-3 .bars i { background: var(--ok); }

/* --------------------------------------------------------------- controls */

.controls {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  padding: 14px 10px calc(var(--safe-b) + 16px);
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 5;
}

.ctrl {
  position: relative;
  flex: 1 1 0;
  max-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(18,24,33,.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  transition: background .15s, transform .08s;
}

.ctrl:active { transform: scale(.95); }
.ctrl .lbl { font-size: 10.5px; color: var(--text-dim); font-weight: 600; letter-spacing: .2px; }
.ctrl .off { display: none; }
.ctrl.is-off { background: rgba(255,255,255,.92); color: #12181f; }
.ctrl.is-off .lbl { color: #4a5563; }
.ctrl.is-off .on  { display: none; }
.ctrl.is-off .off { display: block; }
.ctrl.danger { background: rgba(255,59,48,.9); }
.ctrl.danger .lbl { color: rgba(255,255,255,.85); }

.ctrl .meter {
  position: absolute;
  left: 10px; right: 10px; bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255,255,255,.14);
  overflow: hidden;
}
.ctrl .meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ok);
  transition: width .08s linear;
}

/* --------------------------------------------------------------- overlays */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
  background: rgba(5,8,12,.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.overlay.solid { background: var(--bg); backdrop-filter: none; }
.overlay h2 { margin: 4px 0 0; font-size: 19px; font-weight: 700; }
.overlay p  { margin: 0; max-width: 30ch; color: var(--text-dim); font-size: 14px; line-height: 1.5; }

.pulse {
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(.7); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}

.end-icon {
  width: 62px; height: 62px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 28px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.end-icon.bad { background: rgba(255,59,48,.16); color: var(--live); }

/* ----------------------------------------------------------------- sheets */

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92%;
  z-index: 10;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, rgba(24,32,43,.97), rgba(11,15,20,.99));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -18px 50px rgba(0,0,0,.55);
  animation: rise .28s cubic-bezier(.2,.8,.3,1);
}

@keyframes rise { from { transform: translateY(14%); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-inner { padding: 18px 18px calc(var(--safe-b) + 20px); }
.sheet.small .sheet-inner { padding-bottom: calc(var(--safe-b) + 16px); }

.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--text-dim); padding: 0 4px; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.brand-dot {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #7b3bff);
  box-shadow: 0 6px 18px rgba(47,139,255,.35);
}
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.brand .sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }

.step { padding: 14px 0; border-top: 1px solid var(--line); }
.step:first-of-type { border-top: 0; padding-top: 4px; }
.step.done .num { background: var(--ok); border-color: var(--ok); color: #06210f; }
.step.hidden { display: none; }

.step-head { display: flex; align-items: center; gap: 10px; }
.step-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.num {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
}

.hint { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }

.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13.5px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  outline: none;
  font-size: 15px;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input::placeholder { color: #58687c; }

.btn {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 650;
  transition: opacity .15s, transform .08s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { background: var(--surface-2); color: #5f7086; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.big { margin-top: 16px; padding: 16px; font-size: 16px; }
.btn:disabled { cursor: not-allowed; }

.err {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: rgba(255,59,48,.12);
  border: 1px solid rgba(255,59,48,.3);
  color: #ffb3ae;
  font-size: 13px;
  line-height: 1.45;
}

.fineprint { margin: 12px 0 0; text-align: center; font-size: 11px; color: #5d6d80; }

.statsbox {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
}

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: absolute;
  left: 12px; right: 12px;
  bottom: calc(var(--safe-b) + 116px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 90%;
  padding: 10px 15px;
  border-radius: 999px;
  background: rgba(10,14,20,.9);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 13px;
  animation: toastIn .2s ease-out;
}
.toast.bad  { background: rgba(120,20,16,.92); border-color: rgba(255,120,110,.35); }
.toast.good { background: rgba(12,70,40,.92);  border-color: rgba(80,220,150,.3); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

/* =================================================================== HOST */

body.host {
  overflow-y: auto;
  background: var(--bg);
  padding: 0 0 40px;
}

.host-wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }

.host-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 16px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.host-head h1 { margin: 0; font-size: 19px; }
.host-head .sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }

.badge {
  padding: 4px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  background: rgba(245,158,11,.16); color: var(--warn);
  border: 1px solid rgba(245,158,11,.3);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 14px; letter-spacing: .3px; text-transform: uppercase; color: var(--text-dim); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .btn { width: auto; flex: none; padding: 11px 18px; }

.keybox {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; margin-top: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line);
}
.keybox .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 30px; font-weight: 700; letter-spacing: 6px; color: #fff;
}
.keybox .lab { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }

.linkrow {
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.linkhead { display: flex; align-items: center; gap: 10px; }
.linkhead .nm { font-size: 13.5px; font-weight: 600; flex: 1; }
.linkrow .linkbox { margin-top: 10px; flex-wrap: wrap; }
.linkrow .linkbox input { min-width: 180px; }

.linkbox { display: flex; gap: 8px; margin-top: 12px; }
.linkbox input {
  flex: 1; min-width: 0;
  padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-2);
  font-size: 13px; font-family: ui-monospace, Menlo, monospace;
}
.linkbox .btn { width: auto; flex: none; padding: 11px 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tile video { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; display: block; }
.tile .meta { padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.tile .meta .nm { font-size: 13.5px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .acts { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.tile .acts button {
  flex: 1; min-width: 64px;
  padding: 8px 6px; font-size: 11.5px; font-weight: 600;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.tile .acts button.warn { background: rgba(255,59,48,.14); border-color: rgba(255,59,48,.3); color: #ff9e97; }
.tile .acts button.on   { background: var(--accent); border-color: var(--accent); color: #fff; }
.tile .stat { padding: 0 12px 12px; font-size: 11px; color: var(--text-dim); font-family: ui-monospace, Menlo, monospace; }

.waitlist { display: flex; flex-direction: column; gap: 10px; }
.waitrow {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line);
}
.waitrow .nm { flex: 1; font-size: 14px; font-weight: 600; }
.waitrow button { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 600; }
.waitrow button.go { background: var(--ok); border-color: var(--ok); color: #06210f; }
.waitrow button.no { background: transparent; color: #ff9e97; border-color: rgba(255,59,48,.3); }

.empty { padding: 22px; text-align: center; color: var(--text-dim); font-size: 13px; }

.log {
  margin-top: 8px; max-height: 220px; overflow-y: auto;
  font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; line-height: 1.7;
  color: var(--text-dim);
}
.log b { color: var(--text); font-weight: 600; }

@media (min-width: 700px) {
  .sheet { left: 50%; transform: translateX(-50%); max-width: 460px; border-radius: 22px; bottom: 24px; }
  @keyframes rise { from { transform: translateX(-50%) translateY(14%); opacity: 0 } to { transform: translateX(-50%); opacity: 1 } }
  .controls { padding-bottom: 22px; }
  .ctrl { max-width: 92px; }
}
